com.intellij.openapi.ui.popup.JBPopupFactory Java Examples

The following examples show how to use com.intellij.openapi.ui.popup.JBPopupFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ChangeGoToChangePopupAction.java    From consulo with Apache License 2.0 7 votes vote down vote up
@Nonnull
@Override
protected JBPopup createPopup(@Nonnull AnActionEvent e) {
  Project project = e.getProject();
  if (project == null) project = ProjectManager.getInstance().getDefaultProject();

  Ref<JBPopup> popup = new Ref<JBPopup>();
  ChangesBrowser cb = new MyChangesBrowser(project, getChanges(), getCurrentSelection(), popup);

  popup.set(JBPopupFactory.getInstance()
                    .createComponentPopupBuilder(cb, cb.getPreferredFocusedComponent())
                    .setResizable(true)
                    .setModalContext(false)
                    .setFocusable(true)
                    .setRequestFocus(true)
                    .setCancelOnWindowDeactivation(true)
                    .setCancelOnOtherWindowOpen(true)
                    .setMovable(true)
                    .setCancelKeyEnabled(true)
                    .setCancelOnClickOutside(true)
                    .setDimensionServiceKey(project, "Diff.GoToChangePopup", false)
                    .createPopup());

  return popup.get();
}
 
Example #2
Source File: FlutterLogView.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 7 votes vote down vote up
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
  app.getFlutterLog().getLoggingChannels().thenAccept(channels -> ApplicationManager.getApplication().invokeAndWait(() -> {
    final ChannelPanel panel = new ChannelPanel(channels);
    final Rectangle visibleRect = logTree.getVisibleRect();
    // TODO(pq): make width dynamic based on channel name length
    final Point topRight = new Point(logTree.getLocationOnScreen().x + visibleRect.width - 150,
                                     logTree.getLocationOnScreen().y + visibleRect.y);
    JBPopupFactory.getInstance()
      .createComponentPopupBuilder(panel, panel)
      .setTitle("Logging channels")
      .setMovable(true)
      .setRequestFocus(true)
      .createPopup().show(RelativePoint.fromScreen(topRight));
  })).exceptionally(throwable -> {
    throwable.printStackTrace();
    return null;
  });
}
 
Example #3
Source File: MultilinePopupBuilder.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
JBPopup createPopup() {
  JPanel panel = new JPanel(new BorderLayout());
  panel.add(myTextField, BorderLayout.CENTER);
  ComponentPopupBuilder builder = JBPopupFactory.getInstance().createComponentPopupBuilder(panel, myTextField)
          .setCancelOnClickOutside(true)
          .setAdText(KeymapUtil.getShortcutsText(CommonShortcuts.CTRL_ENTER.getShortcuts()) + " to finish")
          .setRequestFocus(true)
          .setResizable(true)
          .setMayBeParent(true);

  final JBPopup popup = builder.createPopup();
  popup.setMinimumSize(new JBDimension(200, 90));
  AnAction okAction = new DumbAwareAction() {
    @Override
    public void actionPerformed(@Nonnull AnActionEvent e) {
      unregisterCustomShortcutSet(popup.getContent());
      popup.closeOk(e.getInputEvent());
    }
  };
  okAction.registerCustomShortcutSet(CommonShortcuts.CTRL_ENTER, popup.getContent());
  return popup;
}
 
Example #4
Source File: FlatWelcomePanel.java    From consulo with Apache License 2.0 6 votes vote down vote up
private JComponent createActionLink(final String text, final String groupId, Icon icon, boolean focusListOnLeft) {
  final Ref<ActionLink> ref = new Ref<>(null);
  AnAction action = new AnAction() {
    @RequiredUIAccess
    @Override
    public void actionPerformed(@Nonnull AnActionEvent e) {
      ActionGroup configureGroup = (ActionGroup)ActionManager.getInstance().getAction(groupId);
      final PopupFactoryImpl.ActionGroupPopup popup = (PopupFactoryImpl.ActionGroupPopup)JBPopupFactory.getInstance()
              .createActionGroupPopup(null, new IconsFreeActionGroup(configureGroup), e.getDataContext(), JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false, ActionPlaces.WELCOME_SCREEN);
      popup.showUnderneathOfLabel(ref.get());
      UsageTrigger.trigger("welcome.screen." + groupId);
    }
  };
  JComponent panel = createActionLink(text, icon, ref, action);
  installFocusable(panel, action, KeyEvent.VK_UP, KeyEvent.VK_DOWN, focusListOnLeft);
  return panel;
}
 
Example #5
Source File: ApplyPatchDifferentiatedDialog.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
  final List<AbstractFilePatchInProgress.PatchChange> selectedChanges = myChangesTreeList.getSelectedChanges();
  if ((selectedChanges.size() >= 1) && (sameBase(selectedChanges))) {
    final AbstractFilePatchInProgress.PatchChange patchChange = selectedChanges.get(0);
    final AbstractFilePatchInProgress patch = patchChange.getPatchInProgress();
    final List<VirtualFile> autoBases = patch.getAutoBasesCopy();
    if (autoBases.isEmpty() || (autoBases.size() == 1 && autoBases.get(0).equals(patch.getBase()))) {
      myNewBaseSelector.run();
    }
    else {
      autoBases.add(null);
      final MapPopup step = new MapPopup(autoBases, myNewBaseSelector);
      JBPopupFactory.getInstance().createListPopup(step).showCenteredInCurrentWindow(myProject);
    }
  }
}
 
Example #6
Source File: DiffUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static void showSuccessPopup(@Nonnull String message,
                                    @Nonnull RelativePoint point,
                                    @Nonnull Disposable disposable,
                                    @Nullable Runnable hyperlinkHandler) {
  HyperlinkListener listener = null;
  if (hyperlinkHandler != null) {
    listener = new HyperlinkAdapter() {
      @Override
      protected void hyperlinkActivated(HyperlinkEvent e) {
        hyperlinkHandler.run();
      }
    };
  }

  Color bgColor = MessageType.INFO.getPopupBackground();

  Balloon balloon = JBPopupFactory.getInstance()
          .createHtmlTextBalloonBuilder(message, null, bgColor, listener)
          .setAnimationCycle(200)
          .createBalloon();
  balloon.show(point, Balloon.Position.below);
  Disposer.register(disposable, balloon);
}
 
Example #7
Source File: RunIdeConsoleAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
  List<String> languages = IdeScriptEngineManager.getInstance().getLanguages();
  if (languages.size() == 1) {
    runConsole(e, languages.iterator().next());
    return;
  }

  DefaultActionGroup actions =
          new DefaultActionGroup(ContainerUtil.map(languages, (NotNullFunction<String, AnAction>)language -> new DumbAwareAction(language) {
            @Override
            public void actionPerformed(@Nonnull AnActionEvent e1) {
              runConsole(e1, language);
            }
          }));
  JBPopupFactory.getInstance().createActionGroupPopup("Script Engine", actions, e.getDataContext(), JBPopupFactory.ActionSelectionAid.NUMBERING, false).
          showInBestPositionFor(e.getDataContext());
}
 
Example #8
Source File: DropDownLink.java    From consulo with Apache License 2.0 6 votes vote down vote up
public DropDownLink(@Nonnull T initialItem, @Nonnull List<T> items, @Nullable Consumer<? super T> itemChosenAction, boolean updateLabel) {
  this(initialItem, linkLabel -> {
    IPopupChooserBuilder<T> popupBuilder = JBPopupFactory.getInstance().createPopupChooserBuilder(items).
            setRenderer(new LinkCellRenderer<>(linkLabel)).
            setItemChosenCallback(t -> {
              if (updateLabel) {
                linkLabel.setText(t.toString());
              }

              if (itemChosenAction != null && !linkLabel.chosenItem.equals(t)) {
                itemChosenAction.consume(t);
              }
              linkLabel.chosenItem = t;
            });
    return popupBuilder.createPopup();
  });
}
 
Example #9
Source File: ShowFilterAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void showPopup(@Nonnull Project project, @Nonnull Component anchor) {
  if (myFilterPopup != null || !anchor.isValid()) {
    return;
  }
  JBPopupListener popupCloseListener = new JBPopupListener() {
    @Override
    public void onClosed(@Nonnull LightweightWindowEvent event) {
      myFilterPopup = null;
    }
  };
  myFilterPopup = JBPopupFactory.getInstance().createComponentPopupBuilder(createFilterPanel(), null).setModalContext(false).setFocusable(false).setResizable(true).setCancelOnClickOutside(false)
          .setMinSize(new Dimension(200, 200)).setDimensionServiceKey(project, getDimensionServiceKey(), false).addListener(popupCloseListener).createPopup();
  anchor.addHierarchyListener(new HierarchyListener() {
    @Override
    public void hierarchyChanged(HierarchyEvent e) {
      if (e.getID() == HierarchyEvent.HIERARCHY_CHANGED && !anchor.isValid()) {
        anchor.removeHierarchyListener(this);
        if (myFilterPopup != null) {
          myFilterPopup.cancel();
        }
      }
    }
  });
  myFilterPopup.showUnderneathOf(anchor);
}
 
Example #10
Source File: GTMProject.java    From gtm-jetbrains-plugin with MIT License 6 votes vote down vote up
private void installGtmWidget() {
    StatusBar statusBar = WindowManager.getInstance().getStatusBar(myProject);
    if (statusBar != null) {
        statusBar.addWidget(myStatusWidget, myProject);
        myStatusWidget.installed();
        if (!GTMRecord.initGtmExePath()) {
            JBPopupFactory.getInstance()
                    .createHtmlTextBalloonBuilder(GTMConfig.getInstance().gtmNotFound, ERROR, null)
                    .setFadeoutTime(30000)
                    .createBalloon()
                    .show(RelativePoint.getSouthEastOf(statusBar.getComponent()),
                            Balloon.Position.atRight);
            return;
        }
        if (!GTMRecord.checkVersion()) {
            JBPopupFactory.getInstance()
                    .createHtmlTextBalloonBuilder(GTMConfig.getInstance().gtmVerOutdated, WARNING, null)
                    .setFadeoutTime(30000)
                    .createBalloon()
                    .show(RelativePoint.getSouthEastOf(statusBar.getComponent()),
                            Balloon.Position.atRight);
        }
    }
}
 
Example #11
Source File: UiUtils.java    From Crucible4IDEA with MIT License 6 votes vote down vote up
public static void showBalloon(@NotNull final Project project, @NotNull final String message,
                               @NotNull final MessageType messageType) {
  final JFrame frame = WindowManager.getInstance().getFrame(project.isDefault() ? null : project);
  if (frame == null) return;
  final JComponent component = frame.getRootPane();
  if (component == null) return;
  final Rectangle rect = component.getVisibleRect();
  final Point p = new Point(rect.x + rect.width - 10, rect.y + 10);
  final RelativePoint point = new RelativePoint(component, p);

  final BalloonBuilder balloonBuilder = JBPopupFactory.getInstance().
    createHtmlTextBalloonBuilder(message, messageType.getDefaultIcon(),
                                 messageType.getPopupBackground(), null);
  balloonBuilder.setShowCallout(false).setCloseButtonEnabled(true)
                .createBalloon().show(point, Balloon.Position.atLeft);
}
 
Example #12
Source File: CommonProgramParametersPanel.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Deprecated // use MacroComboBoxWithBrowseButton instead
protected JComponent createComponentWithMacroBrowse(@Nonnull final TextFieldWithBrowseButton textAccessor) {
  final FixedSizeButton button = new FixedSizeButton(textAccessor);
  button.setIcon(AllIcons.RunConfigurations.Variables);
  button.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      //noinspection unchecked
      final JList list = new JBList(myWorkingDirectoryComboBox.getChildComponent().getModel());
      JBPopupFactory.getInstance().createListPopupBuilder(list).setItemChoosenCallback(() -> {
        final Object value = list.getSelectedValue();
        if (value instanceof String) {
          textAccessor.setText((String)value);
        }
      }).setMovable(false).setResizable(false).createPopup().showUnderneathOf(button);
    }
  });

  JPanel panel = new JPanel(new BorderLayout());
  panel.add(textAccessor, BorderLayout.CENTER);
  panel.add(button, BorderLayout.EAST);
  return panel;
}
 
Example #13
Source File: ShowBaseRevisionAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
@RequiredUIAccess
@Override
public void onSuccess() {
  if (myProject.isDisposed() || ! myProject.isOpen()) return;

  if (myDescription != null) {
    NotificationPanel panel = new NotificationPanel();
    panel.setText(createMessage(myDescription, selectedFile));
    final JBPopup message = JBPopupFactory.getInstance().createComponentPopupBuilder(panel, panel.getLabel()).createPopup();
    if (vcsContext.getEditor() != null) {
      message.showInBestPositionFor(vcsContext.getEditor());
    } else {
      message.showCenteredInCurrentWindow(vcsContext.getProject());
    }
  }
}
 
Example #14
Source File: FileChooserDialogImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void showRecentFilesPopup() {
  final JBList files = new JBList(getRecentFiles()) {
    @Override
    public Dimension getPreferredSize() {
      return new Dimension(myPathTextField.getField().getWidth(), super.getPreferredSize().height);
    }
  };
  files.setCellRenderer(new ColoredListCellRenderer() {
    @Override
    protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
      final String path = value.toString();
      append(path);
      final VirtualFile file = LocalFileSystem.getInstance().findFileByIoFile(new File(path));
      if (file != null) {
        setIcon(VfsIconUtil.getIcon(file, Iconable.ICON_FLAG_READ_STATUS, null));
      }
    }
  });
  JBPopupFactory.getInstance().createListPopupBuilder(files).setItemChoosenCallback(new Runnable() {
    @Override
    public void run() {
      myPathTextField.getField().setText(files.getSelectedValue().toString());
    }
  }).createPopup().showUnderneathOf(myPathTextField.getField());
}
 
Example #15
Source File: QueryPanel.java    From nosql4idea with Apache License 2.0 6 votes vote down vote up
void notifyOnErrorForOperator(JComponent component, Exception ex) {
    String message;
    if (ex instanceof JSONParseException) {
        message = StringUtils.removeStart(ex.getMessage(), "\n");
    } else {
        message = String.format("%s: %s", ex.getClass().getSimpleName(), ex.getMessage());
    }
    NonOpaquePanel nonOpaquePanel = new NonOpaquePanel();
    JTextPane textPane = Messages.configureMessagePaneUi(new JTextPane(), message);
    textPane.setFont(COURIER_FONT);
    textPane.setBackground(MessageType.ERROR.getPopupBackground());
    nonOpaquePanel.add(textPane, BorderLayout.CENTER);
    nonOpaquePanel.add(new JLabel(MessageType.ERROR.getDefaultIcon()), BorderLayout.WEST);

    JBPopupFactory.getInstance().createBalloonBuilder(nonOpaquePanel)
            .setFillColor(MessageType.ERROR.getPopupBackground())
            .createBalloon()
            .show(new RelativePoint(component, new Point(0, 0)), Balloon.Position.above);
}
 
Example #16
Source File: PendingWebTestContext.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Override
public void resolve(
    ExecutionEnvironment env, BlazeCommandRunConfiguration config, Runnable rerun) {
  DataContext dataContext = env.getDataContext();
  if (dataContext == null) {
    return;
  }
  JBPopup popup =
      JBPopupFactory.getInstance()
          .createPopupChooserBuilder(wrapperTests)
          .setTitle("Choose Web Test to Run")
          .setMovable(false)
          .setResizable(false)
          .setRequestFocus(true)
          .setCancelOnWindowDeactivation(false)
          .setItemChosenCallback(
              (wrapperTest) -> updateContextAndRerun(config, wrapperTest, rerun))
          .createPopup();
  TransactionGuard.getInstance()
      .submitTransactionAndWait(() -> popup.showInBestPositionFor(dataContext));
}
 
Example #17
Source File: NavBarListener.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void processFocusLost(FocusEvent e) {
  final Component opposite = e.getOppositeComponent();

  if (myPanel.isInFloatingMode() && opposite != null && DialogWrapper.findInstance(opposite) != null) {
    myPanel.hideHint();
    return;
  }

  final boolean nodePopupInactive = !myPanel.isNodePopupActive();
  boolean childPopupInactive = !JBPopupFactory.getInstance().isChildPopupFocused(myPanel);
  if (nodePopupInactive && childPopupInactive) {
    if (opposite != null && opposite != myPanel && !myPanel.isAncestorOf(opposite) && !e.isTemporary()) {
      myPanel.setContextComponent(null);
      myPanel.hideHint();
    }
  }

  myPanel.updateItems();
}
 
Example #18
Source File: LivePreview.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void showBalloon(Editor editor, String replacementPreviewText) {
  if (ApplicationManager.getApplication().isUnitTestMode()) {
    myReplacementPreviewText = replacementPreviewText;
    return;
  }

  ReplacementView replacementView = new ReplacementView(replacementPreviewText);

  BalloonBuilder balloonBuilder = JBPopupFactory.getInstance().createBalloonBuilder(replacementView);
  balloonBuilder.setFadeoutTime(0);
  balloonBuilder.setFillColor(IdeTooltipManager.GRAPHITE_COLOR);
  balloonBuilder.setAnimationCycle(0);
  balloonBuilder.setHideOnClickOutside(false);
  balloonBuilder.setHideOnKeyOutside(false);
  balloonBuilder.setHideOnAction(false);
  balloonBuilder.setCloseButtonEnabled(true);
  myReplacementBalloon = balloonBuilder.createBalloon();
  EditorUtil.disposeWithEditor(editor, myReplacementBalloon);
  myReplacementBalloon.show(new ReplacementBalloonPositionTracker(editor), Balloon.Position.below);
}
 
Example #19
Source File: CopyToDbUnit.java    From dbunit-extractor with MIT License 6 votes vote down vote up
private void showPopup(DataContext dataContext, XmlOutput xmlOutput) {
    MessageType messageType = MessageType.INFO;
    String htmlMessage = "";
    if (xmlOutput != null && xmlOutput.getRowSize() > 0 && xmlOutput.getColumnsSize() > 0) {
        if (xmlOutput.getTableName() == null || xmlOutput.getTableName().isEmpty()) {
            messageType = MessageType.WARNING;
            htmlMessage += "Table name is missing. Please try to synchronize database connection. <br/>";
        }
        htmlMessage += "Copied: " + xmlOutput.getRowSize() + " entries (selected " + xmlOutput.getColumnsSize() + " columns)";
    } else {
        messageType = MessageType.ERROR;
        if (xmlOutput == null) {
            htmlMessage = "Failed to copy entries. No grid available.";
        } else if (xmlOutput.getRowSize() <= 0) {
            htmlMessage = "No rows selected.";
        } else if (xmlOutput.getColumnsSize() <= 0) {
            htmlMessage = "No columns selected.";
        }
    }
    JBPopupFactory.getInstance()
            .createHtmlTextBalloonBuilder(htmlMessage, messageType, null)
            .setFadeoutTime(7500)
            .createBalloon().show(JBPopupFactory.getInstance().guessBestPopupLocation(dataContext), Balloon.Position.atRight);
}
 
Example #20
Source File: SettingsForm.java    From PhpMetrics-jetbrains with MIT License 5 votes vote down vote up
private void inform(JComponent target, String text, MessageType messageType) {
    JBPopupFactory.getInstance()
            .createHtmlTextBalloonBuilder(text, messageType, null)
            .setFadeoutTime(2000)
            .createBalloon()
            .show(RelativePoint.getNorthEastOf(target), Balloon.Position.atRight);
}
 
Example #21
Source File: GuiUtils.java    From nosql4idea with Apache License 2.0 5 votes vote down vote up
public static void showNotification(final JComponent component, final MessageType info, final String message, final Balloon.Position position) {
    runInSwingThread(new Runnable() {
        @Override
        public void run() {
            JBPopupFactory.getInstance().createBalloonBuilder(new JLabel(message))
                    .setFillColor(info.getPopupBackground())
                    .createBalloon()
                    .show(new RelativePoint(component, new Point(0, 0)), position);
        }
    });
}
 
Example #22
Source File: StructureViewWrapperImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void checkUpdate() {
  if (myProject.isDisposed()) return;

  final Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
  final boolean insideToolwindow = SwingUtilities.isDescendingFrom(myToolWindow.getComponent(), owner);
  if (!myFirstRun && (insideToolwindow || JBPopupFactory.getInstance().isPopupActive())) {
    return;
  }

  final DataContext dataContext = DataManager.getInstance().getDataContext(owner);
  if (dataContext.getData(ourDataSelectorKey) == this) return;
  if (dataContext.getData(CommonDataKeys.PROJECT) != myProject) return;

  final VirtualFile[] files = hasFocus() ? null : dataContext.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
  if (!myToolWindow.isVisible()) {
    if (files != null && files.length > 0) {
      myFile = files[0];
    }
    return;
  }

  if (files != null && files.length == 1) {
    setFile(files[0]);
  }
  else if (files != null && files.length > 1) {
    setFile(null);
  } else if (myFirstRun) {
    final FileEditorManagerImpl editorManager = (FileEditorManagerImpl)FileEditorManager.getInstance(myProject);
    final List<Pair<VirtualFile, EditorWindow>> history = editorManager.getSelectionHistory();
    if (! history.isEmpty()) {
      setFile(history.get(0).getFirst());
    }
  }

  myFirstRun = false;
}
 
Example #23
Source File: GLSLDeduceExpressionTypeAction.java    From glsl4idea with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void showBalloon(AnActionEvent e, String html) {
    final Editor editor = e.getData(CommonDataKeys.EDITOR_EVEN_IF_INACTIVE);
    if(editor == null) return;
    final JBPopupFactory factory = JBPopupFactory.getInstance();
    final BalloonBuilder builder = factory.createBalloonBuilder(new JLabel(html));
    Balloon balloon = builder.createBalloon();
    RelativePoint position = factory.guessBestPopupLocation(editor);
    balloon.show(position, Balloon.Position.below);
}
 
Example #24
Source File: DaemonTooltipWithActionRenderer.java    From consulo with Apache License 2.0 5 votes vote down vote up
private JPanel createActionPanelWithBackground(boolean highlight) {
  JPanel wrapper;

  if (highlight) {
    wrapper = new JPanel(new BorderLayout()) {
      @Override
      public void paint(Graphics g) {
        g.setColor(UIUtil.getToolTipActionBackground());
        if (JBPopupFactory.getInstance().getParentBalloonFor(this) == null) {
          g.fillRect(0, 0, getWidth(), getHeight());
        }
        else {
          Graphics2D graphics2D = (Graphics2D)g;
          GraphicsConfig cfg = new GraphicsConfig(g);
          cfg.setAntialiasing(true);

          Rectangle bounds = getBounds();
          graphics2D.fill(new RoundRectangle2D.Double(1.0, 0.0, bounds.width - 2.5, (bounds.height / 2), 0.0, 0.0));

          double arc = BalloonImpl.ARC.get();

          RoundRectangle2D.Double d = new RoundRectangle2D.Double(1.0, 0.0, bounds.width - 2.5, (bounds.height - 1), arc, arc);

          graphics2D.fill(d);

          cfg.restore();
        }

        super.paint(g);
      }
    };
  }
  else {
    wrapper = new JPanel(new BorderLayout());
  }

  wrapper.setOpaque(false);
  wrapper.setBorder(JBUI.Borders.empty());
  return wrapper;
}
 
Example #25
Source File: ToolSelectDialog.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected void doOKAction() {
  try {
    myToolsPanel.apply();
  }
  catch (IOException e) {
    String message = ToolsBundle.message("tools.failed.to.save.changes.0", StringUtil.decapitalize(e.getMessage()));
    final JLayeredPane pane = myToolsPanel.getRootPane().getLayeredPane();
    JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(message, MessageType.ERROR, null)
      .setShowCallout(false).setFadeoutTime(3000).setHideOnAction(true).setHideOnClickOutside(true).setHideOnKeyOutside(true).
      createBalloon().show(new RelativePoint(pane, new Point(pane.getWidth(), 0)), Balloon.Position.above);
    return;
  }
  super.doOKAction();
}
 
Example #26
Source File: Toast.java    From GsonFormat with Apache License 2.0 5 votes vote down vote up
/**
 * Display simple notification of given type
 *
 * @param project
 * @param type
 * @param text
 */
public static void make(Project project, MessageType type, String text) {

    StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);

    JBPopupFactory.getInstance()
            .createHtmlTextBalloonBuilder(text, type, null)
            .setFadeoutTime(7500)
            .createBalloon()
            .show(RelativePoint.getCenterOf(statusBar.getComponent()), Balloon.Position.atRight);
}
 
Example #27
Source File: ComboBox.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void eventDispatched(AWTEvent event) {
  if (event.getID() == WindowEvent.WINDOW_OPENED) {
    final WindowEvent we = (WindowEvent)event;
    final List<JBPopup> popups = JBPopupFactory.getInstance().getChildPopups(this);
    if (popups != null) {
      for (JBPopup each : popups) {
        if (each.getContent() != null && SwingUtilities.isDescendingFrom(each.getContent(), we.getWindow())) {
          super.setPopupVisible(false);
        }
      }
    }
  }
}
 
Example #28
Source File: Toast.java    From GsonFormat with Apache License 2.0 5 votes vote down vote up
/**
 * Display simple notification of given type
 *
 * @param project
 * @param type
 * @param text
 */
public static void make(Project project, JComponent jComponent, MessageType type, String text) {

    StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);

    JBPopupFactory.getInstance()
            .createHtmlTextBalloonBuilder(text, type, null)
            .setFadeoutTime(7500)
            .createBalloon()
            .show(RelativePoint.getCenterOf(jComponent), Balloon.Position.above);
}
 
Example #29
Source File: SearchTextField.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected void showPopup() {
  if (myPopup == null || !myPopup.isVisible()) {
    final JList list = new JBList(myModel);
    final Runnable chooseRunnable = createItemChosenCallback(list);
    myPopup = JBPopupFactory.getInstance().createListPopupBuilder(list)
            .setMovable(false)
            .setRequestFocus(true)
            .setItemChoosenCallback(chooseRunnable).createPopup();
    if (isShowing()) {
      myPopup.showUnderneathOf(getPopupLocationComponent());
    }
  }
}
 
Example #30
Source File: SelectInAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static void invoke(DataContext dataContext, SelectInContext context) {
  final List<SelectInTarget> targetVector = Arrays.asList(getSelectInManager(context.getProject()).getTargets());
  ListPopup popup;
  if (targetVector.isEmpty()) {
    DefaultActionGroup group = new DefaultActionGroup();
    group.add(new NoTargetsAction());
    popup = JBPopupFactory.getInstance().createActionGroupPopup(IdeBundle.message("title.popup.select.target"), group, dataContext,
                                                                JBPopupFactory.ActionSelectionAid.MNEMONICS, true);
  }
  else {
    popup = JBPopupFactory.getInstance().createListPopup(new SelectInActionsStep(targetVector, context));
  }

  popup.showInBestPositionFor(dataContext);
}