@Override public Popup getPopup(final Component owner, final Component contents, final int x, final int y) throws IllegalArgumentException { final Point point = fixPopupLocation(contents, x, y); final int popupType = UIUtil.isUnderGTKLookAndFeel() ? WEIGHT_HEAVY : PopupUtil.getPopupType(this); if (popupType == WEIGHT_HEAVY && OurHeavyWeightPopup.isEnabled()) { return new OurHeavyWeightPopup(owner, contents, point.x, point.y); } if (popupType >= 0) { PopupUtil.setPopupType(myDelegate, popupType); } final Popup popup = myDelegate.getPopup(owner, contents, point.x, point.y); fixPopupSize(popup, contents); return popup; }
@NotNull private PairConsumer<Long, MergeDialogI> createMoreChangeListsLoader() { return new PairConsumer<Long, MergeDialogI>() { @Override public void consume(@NotNull Long bunchSize, @NotNull MergeDialogI dialog) { LoadRecentBranchRevisions loader = new LoadRecentBranchRevisions(myMergeContext, dialog.getLastNumber(), bunchSize.intValue()); TaskDescriptor updater = createUpdateDialogTask(dialog, loader); Continuation fragmented = Continuation.createFragmented(myMergeContext.getProject(), true); fragmented.addExceptionHandler(VcsException.class, new Consumer<VcsException>() { @Override public void consume(VcsException e) { PopupUtil.showBalloonForActiveComponent(e.getMessage() == null ? e.getClass().getName() : e.getMessage(), MessageType.ERROR); } }); fragmented.run(loader, updater); } }; }
private void addCloseOnEsc(final RootPaneContainer frame) { JRootPane rootPane = frame.getRootPane(); ActionListener closeAction = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (!PopupUtil.handleEscKeyEvent()) { // if you remove this line problems will start happen on Mac OS X // 2 projects opened, call Cmd+D on the second opened project and then Esc. // Weird situation: 2nd IdeFrame will be active, but focus will be somewhere inside the 1st IdeFrame // App is unusable until Cmd+Tab, Cmd+tab FrameWrapper.this.myFrame.setVisible(false); close(); } } }; rootPane.registerKeyboardAction(closeAction, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW); ActionUtil.registerForEveryKeyboardShortcut(rootPane, closeAction, CommonShortcuts.getCloseActiveWindow()); }
public boolean dominatesOver(FocusCommand cmd) { final Component thisComponent = PopupUtil.getOwner(getDominationComponent()); final Component thatComponent = PopupUtil.getOwner(cmd.getDominationComponent()); if (thisComponent != null && thatComponent != null) { return thisComponent != thatComponent && SwingUtilities.isDescendingFrom(thisComponent, thatComponent); } return false; }
private void revalidate() { JBPopup popup = PopupUtil.getPopupContainerFor(mySearchField); if (popup != null) { popup.pack(false, true); } ListWithFilter.this.revalidate(); }
public PasswordAuthentication getGenericPromptedAuthentication(final String prefix, final String host, final String prompt, final int port, final boolean remember) { if (ApplicationManager.getApplication().isUnitTestMode()) { return myTestGenericAuthRunnable.get(); } final Ref<PasswordAuthentication> value = Ref.create(); runAboveAll(new Runnable() { @Override public void run() { if (isGenericPasswordCanceled(host, port)) { return; } PasswordAuthentication password = getGenericPassword(host, port); if (password != null) { value.set(password); return; } AuthenticationDialog dialog = new AuthenticationDialog(PopupUtil.getActiveComponent(), prefix + host, "Please enter credentials for: " + prompt, "", "", remember); dialog.show(); if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) { AuthenticationPanel panel = dialog.getPanel(); PasswordAuthentication passwordAuthentication = new PasswordAuthentication(panel.getLogin(), panel.getPassword()); putGenericPassword(host, port, passwordAuthentication, remember && panel.isRememberPassword()); value.set(passwordAuthentication); } else { setGenericPasswordCanceled(host, port); } } }); return value.get(); }
public PopupComponent getPopup(Component owner, Component content, int x, int y, JBPopup jbPopup) { if (OurHeavyWeightPopup.isEnabled()) { return new AwtPopupWrapper(new OurHeavyWeightPopup(owner, content, x, y), jbPopup); } final PopupFactory factory = PopupFactory.getSharedInstance(); final int oldType = PopupUtil.getPopupType(factory); PopupUtil.setPopupType(factory, 2); final Popup popup = factory.getPopup(owner, content, x, y); if (oldType >= 0) PopupUtil.setPopupType(factory, oldType); return new AwtPopupWrapper(popup, jbPopup); }
/** * The following code is a trick! By default Swing uses lightweight and "medium" weight * popups to show JPopupMenu. The code below force the creation of real heavyweight menus - * this increases speed of popups and allows to get rid of some drawing artifacts. */ private static void fixPopupWeight() { int popupWeight = OurPopupFactory.WEIGHT_MEDIUM; String property = System.getProperty("idea.popup.weight"); if (property != null) property = property.toLowerCase(Locale.ENGLISH).trim(); if (SystemInfo.isMacOSLeopard) { // force heavy weight popups under Leopard, otherwise they don't have shadow or any kind of border. popupWeight = OurPopupFactory.WEIGHT_HEAVY; } else if (property == null) { // use defaults if popup weight isn't specified if (SystemInfo.isWindows) { popupWeight = OurPopupFactory.WEIGHT_HEAVY; } } else { if ("light".equals(property)) { popupWeight = OurPopupFactory.WEIGHT_LIGHT; } else if ("medium".equals(property)) { popupWeight = OurPopupFactory.WEIGHT_MEDIUM; } else if ("heavy".equals(property)) { popupWeight = OurPopupFactory.WEIGHT_HEAVY; } else { LOG.error("Illegal value of property \"idea.popup.weight\": " + property); } } PopupFactory factory = PopupFactory.getSharedInstance(); if (!(factory instanceof OurPopupFactory)) { factory = new OurPopupFactory(factory); PopupFactory.setSharedInstance(factory); } PopupUtil.setPopupType(factory, popupWeight); }
private void canNotLoadRevisionMessage(final VcsException e) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { if (! VcsHistoryDialog.this.isShowing()) return; PopupUtil.showBalloonForComponent(VcsHistoryDialog.this.getRootPane(), canNoLoadMessage(e), MessageType.ERROR, true, myProject); } }); }
private static void showFailedAuthenticateProxy() { HttpConfigurable instance = HttpConfigurable.getInstance(); String message = instance.USE_HTTP_PROXY || instance.USE_PROXY_PAC ? "Failed to authenticate to proxy. You can change proxy credentials in HTTP proxy settings." : "Failed to authenticate to proxy."; PopupUtil.showBalloonForActiveComponent(message, MessageType.ERROR); }
@Nullable @Override public List<VcsException> commit(final List<Change> changes, final String preparedComment, @NotNull final NullableFunction<Object, Object> parametersHolder, final Set<String> feedback) { final boolean wasToPush = myPush; myPush = false; final CheckinUtil checkinUtil = new CheckinUtil(myFossilVcs.getProject()); final List<File> files = ChangesUtil.getIoFilesFromChanges(changes); final List<VcsException> exceptions = new ArrayList<VcsException>(); try { final List<String> hashes = checkinUtil.checkin(files, preparedComment); if (hashes != null && ! hashes.isEmpty()) { if (feedback == null) { // popup PopupUtil.showBalloonForActiveComponent(createMessage(hashes), MessageType.INFO); } else { feedback.add(createMessage(hashes)); } // something committed & need to push if (wasToPush) { checkinUtil.push(); } } } catch (VcsException e) { exceptions.add(e); } return exceptions; }
public PasswordAuthentication getGenericPromptedAuthentication(final String prefix, final String host, final String prompt, final int port, final boolean remember) { if (ApplicationManager.getApplication().isUnitTestMode()) { return myTestGenericAuthRunnable.get(); } final PasswordAuthentication[] value = new PasswordAuthentication[1]; final Runnable runnable = new Runnable() { public void run() { if (isGenericPasswordCanceled(host, port)) return; final PasswordAuthentication password = getGenericPassword(host, port); if (password != null) { value[0] = password; return; } final AuthenticationDialog dlg = new AuthenticationDialog(PopupUtil.getActiveComponent(), prefix + host, "Please enter credentials for: " + prompt, "", "", remember); dlg.show(); if (dlg.getExitCode() == DialogWrapper.OK_EXIT_CODE) { final AuthenticationPanel panel = dlg.getPanel(); final boolean remember1 = remember && panel.isRememberPassword(); value[0] = new PasswordAuthentication(panel.getLogin(), panel.getPassword()); putGenericPassword(host, port, value[0], remember1); } else { setGenericPasswordCanceled(host, port); } } }; runAboveAll(runnable); return value[0]; }
public PopupComponent getPopup(Component owner, Component content, int x, int y, JBPopup jbPopup) { final PopupFactory factory = PopupFactory.getSharedInstance(); final int oldType = PopupUtil.getPopupType(factory); PopupUtil.setPopupType(factory, 2); final Popup popup = factory.getPopup(owner, content, x, y); if (oldType >= 0) PopupUtil.setPopupType(factory, oldType); return new AwtPopupWrapper(popup, jbPopup); }
/** * The following code is a trick! By default Swing uses lightweight and "medium" weight * popups to show JPopupMenu. The code below force the creation of real heavyweight menus - * this increases speed of popups and allows to get rid of some drawing artifacts. */ private static void fixPopupWeight() { int popupWeight = OurPopupFactory.WEIGHT_MEDIUM; String property = System.getProperty("idea.popup.weight"); if (property != null) property = property.toLowerCase().trim(); if (SystemInfo.isMacOSLeopard) { // force heavy weight popups under Leopard, otherwise they don't have shadow or any kind of border. popupWeight = OurPopupFactory.WEIGHT_HEAVY; } else if (property == null) { // use defaults if popup weight isn't specified if (SystemInfo.isWindows) { popupWeight = OurPopupFactory.WEIGHT_HEAVY; } } else { if ("light".equals(property)) { popupWeight = OurPopupFactory.WEIGHT_LIGHT; } else if ("medium".equals(property)) { popupWeight = OurPopupFactory.WEIGHT_MEDIUM; } else if ("heavy".equals(property)) { popupWeight = OurPopupFactory.WEIGHT_HEAVY; } else { LOG.error("Illegal value of property \"idea.popup.weight\": " + property); } } PopupFactory factory = PopupFactory.getSharedInstance(); if (!(factory instanceof OurPopupFactory)) { factory = new OurPopupFactory(factory); PopupFactory.setSharedInstance(factory); } PopupUtil.setPopupType(factory, popupWeight); }
public Popup getPopup(final Component owner, final Component contents, final int x, final int y) throws IllegalArgumentException { final Point point = fixPopupLocation(contents, x, y); final int popupType = UIUtil.isUnderGTKLookAndFeel() ? WEIGHT_HEAVY : PopupUtil.getPopupType(this); if (popupType >= 0) { PopupUtil.setPopupType(myDelegate, popupType); } final Popup popup = myDelegate.getPopup(owner, contents, point.x, point.y); fixPopupSize(popup, contents); return popup; }
/** * @return null if we should ignore <Esc> for window closing */ @Nullable protected ActionListener createCancelAction() { return new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (!PopupUtil.handleEscKeyEvent()) { doCancelAction(e); } } }; }
public PasswordAuthentication getGenericPromptedAuthentication(final String prefix, final String host, final String prompt, final int port, final boolean remember) { if (ApplicationManager.getApplication().isUnitTestMode()) { return myTestGenericAuthRunnable.get(); } final Ref<PasswordAuthentication> value = Ref.create(); runAboveAll(() -> { if (isGenericPasswordCanceled(host, port)) { return; } PasswordAuthentication password = getGenericPassword(host, port); if (password != null) { value.set(password); return; } AuthenticationDialog dialog = new AuthenticationDialog(PopupUtil.getActiveComponent(), prefix + host, "Please enter credentials for: " + prompt, "", "", remember); dialog.show(); if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) { AuthenticationPanel panel = dialog.getPanel(); PasswordAuthentication passwordAuthentication = new PasswordAuthentication(panel.getLogin(), panel.getPassword()); putGenericPassword(host, port, passwordAuthentication, remember && panel.isRememberPassword()); value.set(passwordAuthentication); } else { setGenericPasswordCanceled(host, port); } }); return value.get(); }
@Override public Popup getPopup(final Component owner, final Component contents, final int x, final int y) throws IllegalArgumentException { final Point point = fixPopupLocation(contents, x, y); final int popupType = UIUtil.isUnderGTKLookAndFeel() ? WEIGHT_HEAVY : PopupUtil.getPopupType(this); if (popupType >= 0) { PopupUtil.setPopupType(myDelegate, popupType); } final Popup popup = myDelegate.getPopup(owner, contents, point.x, point.y); fixPopupSize(popup, contents); return popup; }
@Override public Object getData(@Nonnull @NonNls Key<?> dataId) { if (CommonDataKeys.PSI_ELEMENT == dataId) { final int[] selected = getSelectedRows(); if (selected.length == 1) { return getPsiElementForHint(getValueAt(selected[0], 0)); } } else if (LangDataKeys.POSITION_ADJUSTER_POPUP == dataId) { return PopupUtil.getPopupContainerFor(this); } return null; }
public RepositoryWithBranchPanel(@NotNull final Project project, @NotNull String repoName, @NotNull String sourceName, @NotNull PushTargetPanel<T> destPushTargetPanelComponent) { super(); setLayout(new BorderLayout()); myRepositoryCheckbox = new JBCheckBox(); myRepositoryCheckbox.setFocusable(false); myRepositoryCheckbox.setOpaque(false); myRepositoryCheckbox.setBorder(null); myRepositoryCheckbox.addActionListener(new ActionListener() { @Override public void actionPerformed(@NotNull ActionEvent e) { fireOnSelectionChange(myRepositoryCheckbox.isSelected()); } }); myRepositoryLabel = new JLabel(repoName); myLocalBranch = new JBLabel(sourceName); myArrowLabel = new JLabel(" " + UIUtil.rightArrow() + " "); myDestPushTargetPanelComponent = destPushTargetPanelComponent; myTextRenderer = new ColoredTreeCellRenderer() { public void customizeCellRenderer(@NotNull JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { } }; myTextRenderer.setOpaque(false); layoutComponents(); setInputVerifier(new InputVerifier() { @Override public boolean verify(JComponent input) { ValidationInfo error = myDestPushTargetPanelComponent.verify(); if (error != null) { //noinspection ConstantConditions PopupUtil.showBalloonForComponent(error.component, error.message, MessageType.WARNING, false, project); } return error == null; } }); JCheckBox emptyBorderCheckBox = new JCheckBox(); emptyBorderCheckBox.setBorder(null); Dimension size = emptyBorderCheckBox.getPreferredSize(); myCheckBoxWidth = size.width; myCheckBoxHeight = size.height; myLoadingIcon = LoadingIcon.create(myCheckBoxWidth, size.height); myCheckBoxLoadingIconGapH = myCheckBoxWidth - myLoadingIcon.getIconWidth(); myCheckBoxLoadingIconGapV = size.height - myLoadingIcon.getIconHeight(); }
private void showDisablePluginDialog() { DisablePluginWarningDialog dialog = new DisablePluginWarningDialog(plugin.getPluginId(), PopupUtil.getActiveComponent()); dialog.showAndDisablePlugin(); }
private void execute(final Project project, final VCSBuilder vcsBuilder, VirtualFile[] vFiles) throws Exception { vcsBuilder.build(project, vFiles); final String diff = vcsBuilder.getDiff(); if (diff == null) { Messages.showMessageDialog(project, "No diff generated", "Warn", null); return; } final ReviewBoardClient reviewBoardClient = new ReviewBoardClient(); Task.Backgroundable task = new Task.Backgroundable(project, "Query Repository...", false, new PerformInBackgroundOption() { @Override public boolean shouldStartInBackground() { return false; } @Override public void processSentToBackground() { } }) { @Override public void run(@NotNull ProgressIndicator progressIndicator) { progressIndicator.setIndeterminate(true); Repository[] repositories; try { repositories = reviewBoardClient.getRepositories().repositories; } catch (Exception e) { PopupUtil.showBalloonForActiveFrame("Error to list repository:" + e.getMessage(), MessageType.ERROR); throw new RuntimeException(e); } if (repositories != null) { final Repository[] finalRepositories = repositories; ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { showPostForm(project, vcsBuilder, finalRepositories); } }); } } }; ProgressManager.getInstance().run(task); }
private void showPostForm(final Project project, final VCSBuilder vcsBuilder, Repository[] repositories) { int possibleRepoIndex = getPossibleRepoIndex(vcsBuilder.getRepositoryURL(), repositories); final PrePostReviewForm prePostReviewForm = new PrePostReviewForm(project, changeMessage, vcsBuilder.getDiff(), repositories, possibleRepoIndex) { @Override protected void doOKAction() { if (!isOKActionEnabled()) { return; } final ReviewSettings setting = this.getSetting(); if (setting == null) { return; } if (vcsBuilder.getBasePath() == null) { setting.setSvnBasePath(""); } else { setting.setSvnBasePath(vcsBuilder.getBasePath()); } setting.setSvnRoot(vcsBuilder.getRepositoryURL()); if (this.getDiff() != null) { setting.setDiff(this.getDiff()); } else { setting.setDiff(vcsBuilder.getDiff()); } Task.Backgroundable task = new Task.Backgroundable(project, "Running", false, new PerformInBackgroundOption() { @Override public boolean shouldStartInBackground() { return false; } @Override public void processSentToBackground() { } }) { boolean result; @Override public void onSuccess() { if (result) { String url = ReviewBoardSettings.getSettings().getServer() + "/r/" + setting.getReviewId() + "/diff/"; int success = Messages.showYesNoDialog("The review url is " + url + "\r\n" + "Open the url?", "Success", null); if (success == 0) { BrowserUtil.browse(url); } } else { // Messages.showErrorDialog("Post review failure", "Error"); PopupUtil.showBalloonForActiveFrame("Post review failure", MessageType.ERROR); } } @Override public void run(@NotNull ProgressIndicator progressIndicator) { progressIndicator.setIndeterminate(true); try { result = ReviewBoardClient.postReview(setting, progressIndicator); } catch (Exception e) { e.printStackTrace(); } } }; ProgressManager.getInstance().run(task); super.doOKAction(); } }; prePostReviewForm.show(); }
public RepositoryWithBranchPanel(@Nonnull final Project project, @Nonnull String repoName, @Nonnull String sourceName, @Nonnull PushTargetPanel<T> destPushTargetPanelComponent) { super(); setLayout(new BorderLayout()); myRepositoryCheckbox = new JBCheckBox(); myRepositoryCheckbox.setFocusable(false); myRepositoryCheckbox.setOpaque(false); myRepositoryCheckbox.setBorder(null); myRepositoryCheckbox.addActionListener(new ActionListener() { @Override public void actionPerformed(@Nonnull ActionEvent e) { fireOnSelectionChange(myRepositoryCheckbox.isSelected()); } }); myRepositoryLabel = new JLabel(repoName); myLocalBranch = new JBLabel(sourceName); myArrowLabel = new JLabel(" " + UIUtil.rightArrow() + " "); myDestPushTargetPanelComponent = destPushTargetPanelComponent; myTextRenderer = new ColoredTreeCellRenderer() { @RequiredDispatchThread @Override public void customizeCellRenderer(@Nonnull JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { } }; myTextRenderer.setOpaque(false); layoutComponents(); setInputVerifier(new InputVerifier() { @Override public boolean verify(JComponent input) { ValidationInfo error = myDestPushTargetPanelComponent.verify(); if (error != null) { //noinspection ConstantConditions PopupUtil.showBalloonForComponent(error.component, error.message, MessageType.WARNING, false, project); } return error == null; } }); JCheckBox emptyBorderCheckBox = new JCheckBox(); emptyBorderCheckBox.setBorder(null); }