Java 类com.intellij.openapi.ui.JBPopupMenu 实例源码

项目:PackageTemplates    文件:GlobalVariableWrapper.java   
@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;
}
项目:intellij-ce-playground    文件:TabContentLayout.java   
private void showPopup() {
  myPopup = new JBPopupMenu();
  myPopup.addPopupMenuListener(myPopupListener);

  ArrayList<ContentTabLabel> tabs = myTabs;

  for (final ContentTabLabel each : tabs) {
    final JCheckBoxMenuItem item = new JCheckBoxMenuItem(each.getText());
    if (myUi.myManager.isSelected(each.myContent)) {
      item.setSelected(true);
    }
    item.addActionListener(new ActionListener() {
      public void actionPerformed(final ActionEvent e) {
        myUi.myManager.setSelectedContent(each.myContent, true);
      }
    });
    myPopup.add(item);
  }
  myPopup.show(myUi, myLastLayout.moreRect.x, myLastLayout.moreRect.y);
}
项目:intellij-ce-playground    文件:LafManagerImpl.java   
private static void fixGtkPopupStyle() {
  if (!UIUtil.isUnderGTKLookAndFeel()) 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);
}
项目:intellij-ce-playground    文件:DeviceDefinitionList.java   
private void possiblyShowPopup(MouseEvent e) {
  if (!e.isPopupTrigger()) {
    return;
  }
  Point p = e.getPoint();
  int row = myTable.rowAtPoint(p);
  int col = myTable.columnAtPoint(p);
  if (row != -1 && col != -1) {
    JBPopupMenu menu = new JBPopupMenu();
    menu.add(createMenuItem(new CloneDeviceAction(this)));
    menu.add(createMenuItem(new EditDeviceAction(this)));
    menu.add(createMenuItem(new ExportDeviceAction(this)));
    menu.add(createMenuItem(new DeleteDeviceAction(this)));
    menu.show(myTable, p.x, p.y);
  }
}
项目:tools-idea    文件:TabContentLayout.java   
private void showPopup() {
  myPopup = new JBPopupMenu();
  myPopup.addPopupMenuListener(myPopupListener);

  ArrayList<ContentTabLabel> tabs = myTabs;

  for (final ContentTabLabel each : tabs) {
    final JCheckBoxMenuItem item = new JCheckBoxMenuItem(each.getText());
    if (myUi.myManager.isSelected(each.myContent)) {
      item.setSelected(true);
    }
    item.addActionListener(new ActionListener() {
      public void actionPerformed(final ActionEvent e) {
        myUi.myManager.setSelectedContent(each.myContent, true);
      }
    });
    myPopup.add(item);
  }
  myPopup.show(myUi, myLastLayout.moreRect.x, myLastLayout.moreRect.y);
}
项目:consulo    文件:TabContentLayout.java   
private void showPopup() {
  myPopup = new JBPopupMenu();
  myPopup.addPopupMenuListener(myPopupListener);

  ArrayList<ContentTabLabel> tabs = myTabs;

  for (final ContentTabLabel each : tabs) {
    final JCheckBoxMenuItem item = new JCheckBoxMenuItem(each.getText());
    if (myUi.myManager.isSelected(each.myContent)) {
      item.setSelected(true);
    }
    item.addActionListener(new ActionListener() {
      public void actionPerformed(final ActionEvent e) {
        myUi.myManager.setSelectedContent(each.myContent, true);
      }
    });
    myPopup.add(item);
  }
  myPopup.show(myUi, myLastLayout.moreRect.x, myLastLayout.moreRect.y);
}
项目:PackageTemplates    文件:ElementWrapper.java   
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 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());
    itemDelete.addActionListener(e -> deleteElement());

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

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

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

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

    popupMenu.show(jlName, mouseEvent.getX(), mouseEvent.getY());
}
项目:intellij-ce-playground    文件:FilterDialog.java   
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());
}
项目:intellij-ce-playground    文件:ThemeEditorTable.java   
public ThemeEditorTable() {
  myPopupMenu = new JBPopupMenu();
  myGoToDefinitionItem = myPopupMenu.add(new JMenuItem("Go to definition"));
  myGoToDefinitionItem.setVisible(false);
  myResetItem = myPopupMenu.add(new JMenuItem("Reset value"));
  myResetItem.setVisible(false);
}
项目:vso-intellij    文件:TabFormImpl.java   
/**
 * 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);
}
项目:tools-idea    文件:LafManagerImpl.java   
private static void fixGtkPopupStyle() {
  if (!UIUtil.isUnderGTKLookAndFeel()) 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) {
          try {
            Field f = style.getClass().getDeclaredField("xThickness");
            f.setAccessible(true);
            final Object x = f.get(style);
            if (x instanceof Integer && (Integer)x == 0) {
              // workaround for Sun bug #6636964
              f.set(style, 1);
              f = style.getClass().getDeclaredField("yThickness");
              f.setAccessible(true);
              f.set(style, 3);
            }
          }
          catch (Exception ignore) { }
        }
        return style;
      }
    });

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

  SynthLookAndFeel.setStyleFactory(original);
}
项目:tools-idea    文件:FilterDialog.java   
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());
}
项目:consulo    文件:LafManagerImpl.java   
private static void fixGtkPopupStyle() {
  if (!UIUtil.isUnderGTKLookAndFeel()) 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) {
        try {
          Field f = style.getClass().getDeclaredField("xThickness");
          f.setAccessible(true);
          final Object x = f.get(style);
          if (x instanceof Integer && (Integer)x == 0) {
            // workaround for Sun bug #6636964
            f.set(style, 1);
            f = style.getClass().getDeclaredField("yThickness");
            f.setAccessible(true);
            f.set(style, 3);
          }
        }
        catch (Exception ignore) {
        }
      }
      return style;
    }
  });

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

  SynthLookAndFeel.setStyleFactory(original);
}
项目:consulo    文件:FilterDialog.java   
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());
}
项目:netbeans-mmd-plugin    文件:IdeaUIComponentFactory.java   
@Override
@Nonnull
public JPopupMenu makePopupMenu() {
    return new JBPopupMenu();
}