com.intellij.openapi.ui.JBPopupMenu Java Examples

The following examples show how to use com.intellij.openapi.ui.JBPopupMenu. 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: GlobalVariableWrapper.java    From PackageTemplates with Apache License 2.0 6 votes vote down vote up
@NotNull
private JPopupMenu getPopupMenu(final PackageTemplateWrapper ptWrapper) {
    JPopupMenu popupMenu = new JBPopupMenu();

    JMenuItem itemAddVariable = new JBMenuItem(Localizer.get("AddVariable"), AllIcons.Nodes.Variable);
    JMenuItem itemDelete = new JBMenuItem(Localizer.get("Delete"), AllIcons.Actions.Delete);

    itemAddVariable.addActionListener(e -> addVariable(ptWrapper));
    itemDelete.addActionListener(e -> deleteVariable(ptWrapper));

    popupMenu.add(itemAddVariable);
    addScriptMenuItems(popupMenu, ptWrapper.getProject());
    if (!getGlobalVariable().getName().equals(ATTRIBUTE_BASE_NAME)) {
        popupMenu.add(itemDelete);
    }
    return popupMenu;
}
 
Example #2
Source File: TabFormImpl.java    From azure-devops-intellij with MIT License 5 votes vote down vote up
/**
 * Display popup menu on the view
 *
 * @param component
 * @param x
 * @param y
 * @param listener
 */
protected void showPopupMenu(final Component component, final int x, final int y, final ActionListener listener) {
    final JBPopupMenu menu = new JBPopupMenu();
    final List<JBMenuItem> openMenuItems = getMenuItems(listener);
    for (JBMenuItem menuItem : openMenuItems) {
        menu.add(menuItem);
    }
    menu.show(component, x, y);
}
 
Example #3
Source File: FollowButton.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
private void createMenu() {
  popupMenu = new JBPopupMenu();

  popupMenu.setForeground(FOREGROUND_COLOR);
  popupMenu.setBackground(BACKGROUND_COLOR);

  menuItemPrefix = Messages.FollowButton_user_entry_prefix;

  ISarosSession currentSession = session;
  FollowModeManager currentFollowModeManager = followModeManager;

  if (currentSession == null || currentFollowModeManager == null) {
    return;
  }

  for (User user : currentSession.getRemoteUsers()) {
    JMenuItem menuItem = createItemForUser(user);
    popupMenu.add(menuItem);
  }

  popupMenu.addSeparator();

  JMenuItem leaveItem = new JBMenuItem(Messages.FollowButton_leave_follow_mode_entry);

  leaveItem.setForeground(FOREGROUND_COLOR);
  leaveItem.setBackground(BACKGROUND_COLOR);

  leaveItem.addActionListener(e -> followModeAction.execute(session, followModeManager, null));
  leaveItem.setEnabled(currentFollowModeManager.getFollowedUser() != null);

  popupMenu.add(leaveItem);
}
 
Example #4
Source File: FilterDialog.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void makePopup() {
  myPopup = new JBPopupMenu();
  String[] macrosName = RegexpFilter.getMacrosName();
  JMenuItem[] items = new JMenuItem[macrosName.length];
  for (int i = 0; i < macrosName.length; i++) {
    items[i] = myPopup.add(macrosName[i]);
    items[i].addActionListener(new MenuItemListener(macrosName[i]));
  }
  myRegexpField.addMouseListener(new PopupListener());
}
 
Example #5
Source File: LafManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static void fixGtkPopupStyle() {
  if (!UIUtil.isUnderGTKLookAndFeel()) return;

  // it must be instance of com.sun.java.swing.plaf.gtk.GTKStyleFactory, but class package-local
  if (SystemInfo.isJavaVersionAtLeast(10, 0, 0)) {
    return;
  }

  final SynthStyleFactory original = SynthLookAndFeel.getStyleFactory();

  SynthLookAndFeel.setStyleFactory(new SynthStyleFactory() {
    @Override
    public SynthStyle getStyle(final JComponent c, final Region id) {
      final SynthStyle style = original.getStyle(c, id);
      if (id == Region.POPUP_MENU) {
        final Integer x = ReflectionUtil.getField(style.getClass(), style, int.class, "xThickness");
        if (x != null && x == 0) {
          // workaround for Sun bug #6636964
          ReflectionUtil.setField(style.getClass(), style, int.class, "xThickness", 1);
          ReflectionUtil.setField(style.getClass(), style, int.class, "yThickness", 3);
        }
      }
      return style;
    }
  });

  new JBPopupMenu();  // invokes updateUI() -> updateStyle()

  SynthLookAndFeel.setStyleFactory(original);
}
 
Example #6
Source File: ElementWrapper.java    From PackageTemplates with Apache License 2.0 4 votes vote down vote up
private void createPopupForEditMode(MouseEvent mouseEvent) {
    JPopupMenu popupMenu = new JBPopupMenu();

    JMenuItem itemAddFile = new JBMenuItem(Localizer.get("AddFile"), AllIcons.FileTypes.Text);
    JMenuItem itemAddDirectory = new JBMenuItem(Localizer.get("AddDirectory"), AllIcons.Nodes.Package);
    JMenuItem itemAddBinaryFile = new JBMenuItem(Localizer.get("action.AddBinaryFile"), AllIcons.FileTypes.Text);
    JMenuItem itemEditSourcePath = new JBMenuItem(Localizer.get("action.EditSourcePath"), AllIcons.FileTypes.Text);
    JMenuItem itemChangeFileTemplate = new JBMenuItem(Localizer.get("action.ChangeFileTemplate"), AllIcons.Actions.Edit);
    JMenuItem itemDelete = new JBMenuItem(Localizer.get("Delete"), AllIcons.Actions.Delete);

    itemAddFile.addActionListener(e -> AddFile());
    itemAddDirectory.addActionListener(e -> addDirectory());
    itemAddBinaryFile.addActionListener(e -> addBinaryFile());
    itemDelete.addActionListener(e -> deleteElement());

    popupMenu.add(itemAddFile);
    popupMenu.add(itemAddDirectory);
    popupMenu.add(itemAddBinaryFile);

    // if NOT root element
    if (getParent() != null) {
        popupMenu.add(itemDelete);
    }

    // Dir Specific
    if (isDirectory()) {
        //nothing
    } else {
        // File Specific
        if (this instanceof FileWrapper) {
            itemChangeFileTemplate.addActionListener(e -> changeFileTemplate());
            popupMenu.add(itemChangeFileTemplate);
        } else if (this instanceof BinaryFileWrapper){
            itemEditSourcePath.addActionListener(e -> changeFileTemplate());
            popupMenu.add(itemEditSourcePath);
        }
    }

    addScriptMenuItems(popupMenu);
    addCustomPathMenuItems(popupMenu);
    addWriteRulesMenuItems(popupMenu);

    popupMenu.show(jlName, mouseEvent.getX(), mouseEvent.getY());
}
 
Example #7
Source File: IdeaUIComponentFactory.java    From netbeans-mmd-plugin with Apache License 2.0 4 votes vote down vote up
@Override
@Nonnull
public JPopupMenu makePopupMenu() {
  return new JBPopupMenu();
}
 
Example #8
Source File: ConnectButton.java    From saros with GNU General Public License v2.0 4 votes vote down vote up
public ConnectButton(@NotNull Project project) {
  super(
      project,
      ConnectServerAction.NAME,
      Messages.ConnectButton_tooltip,
      IconManager.CONNECT_ICON);

  SarosPluginContext.initComponent(this);

  disconnectAction = new DisconnectServerAction(project);
  connectAction = new ConnectServerAction(project);
  configureAccounts =
      new AbstractSarosAction() {
        @Override
        public String getActionName() {
          throw new UnsupportedOperationException("Not yet implemented");
        }

        @Override
        public void execute() {
          throw new UnsupportedOperationException("Not yet implemented");
        }
      };

  popupMenu = new JBPopupMenu();

  addAccountItem = createAddAccountMenuItem();
  createAccountItem = createCreateAccountMenuItem();
  configureAccountItem = createConfigureAccountMenuItem();
  disconnectItem = createDisconnectMenuItem();

  popupMenu.setForeground(FOREGROUND_COLOR);
  popupMenu.setBackground(BACKGROUND_COLOR);

  addMenuItems();

  addActionListener(
      actionEvent -> {
        if (accountStore.isEmpty()) {
          XMPPAccount account = createNewAccount();

          if (account != null) {
            addMenuItems();

            askToConnectToAccount(account);

            return;
          }
        }

        popupMenu.show(ConnectButton.this, 0, getBounds().y + getBounds().height);
      });
}