private void showSliderMenu() {
    Point location = new Point(getX(), getY() + getHeight());

    SwingUtilities.convertPointToScreen(location, InputVolumeControlButton.this.getParent());

    if (isFullScreen()) {
      location.setLocation(
          location.getX(),
          location.getY() - sliderMenu.getPreferredSize().getHeight() - getHeight());
    }

    sliderMenu.setLocation(location);

    sliderMenu.addPopupMenuListener(
        new PopupMenuListener() {
          public void popupMenuWillBecomeVisible(PopupMenuEvent ev) {
            sliderMenuIsVisible = true;
          }

          public void popupMenuWillBecomeInvisible(PopupMenuEvent ev) {
            sliderMenuIsVisible = false;
          }

          public void popupMenuCanceled(PopupMenuEvent ev) {}
        });

    sliderMenu.setVisible(!sliderMenu.isVisible());
  }
Exemple #2
0
 public final void setJPopupMenu(JPopupMenu menu) {
   if (this.menu != null) {
     this.menu.removePopupMenuListener(popupListener);
   }
   this.menu = menu;
   menu.addPopupMenuListener(popupListener);
 }
Exemple #3
0
  /** constructor */
  public MPopButton() {
    popListeners = new Vector();

    popup = new JPopupMenu();
    popActionListener = new MPopActionListener(this);

    addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            popup.show(MPopButton.this, 6, getSize().height - 6);
          }
        });

    popup.addPopupMenuListener(
        new PopupMenuListener() {
          public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
            Util.setMenuUp(true);
          }

          public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
            Util.setMenuUp(false);
          }

          public void popupMenuCanceled(PopupMenuEvent e) {}
        });
  } // MPopButton()
 public void setPopupMenu(JPopupMenu menu) {
   this.menu = menu;
   menu.addPopupMenuListener(padapter);
 }
  public void showPopup(final Action actionToSelect, final boolean ensureSelection) {
    if (myPopupIsShowing) return;

    myPopupIsShowing = true;
    final Point loc = getLocationOnScreen();
    final Rectangle screen = ScreenUtil.getScreenRectangle(loc);
    final Dimension popupSize = myUnderPopup.getPreferredSize();
    final Rectangle intersection =
        screen.intersection(new Rectangle(new Point(loc.x, loc.y + getHeight()), popupSize));
    final boolean above = intersection.height < popupSize.height;
    int y = above ? getY() - popupSize.height : getY() + getHeight();

    final JPopupMenu popup = above ? myAbovePopup : myUnderPopup;

    final Ref<PopupMenuListener> listener = new Ref<PopupMenuListener>();
    listener.set(
        new PopupMenuListener() {
          @Override
          public void popupMenuWillBecomeVisible(PopupMenuEvent e) {}

          @Override
          public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
            if (popup != null && listener.get() != null) {
              popup.removePopupMenuListener(listener.get());
            }
            SwingUtilities.invokeLater(
                new Runnable() {
                  @Override
                  public void run() {
                    myPopupIsShowing = false;
                  }
                });
          }

          @Override
          public void popupMenuCanceled(PopupMenuEvent e) {}
        });
    popup.addPopupMenuListener(listener.get());
    popup.show(this, 0, y);

    SwingUtilities.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            if (popup == null || !popup.isShowing() || !myPopupIsShowing) return;

            Action selection = actionToSelect;
            if (selection == null && myOptions.length > 0 && ensureSelection) {
              selection = getAction();
            }

            if (selection == null) return;

            final MenuElement[] elements = popup.getSubElements();
            for (MenuElement eachElement : elements) {
              if (eachElement instanceof JMenuItem) {
                JMenuItem eachItem = (JMenuItem) eachElement;
                if (selection.equals(eachItem.getAction())) {
                  final MenuSelectionManager mgr = MenuSelectionManager.defaultManager();
                  final MenuElement[] path = new MenuElement[2];
                  path[0] = popup;
                  path[1] = eachItem;
                  mgr.setSelectedPath(path);
                  break;
                }
              }
            }
          }
        });
  }
  private void createPopUp() {
    _popUp = new JPopupMenu();

    // i18n[graph.saveGraph=Save graph]
    _mnuSaveGraph = new JMenuItem(s_stringMgr.getString("graph.saveGraph"));
    _mnuSaveGraph.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onSaveGraph();
          }
        });

    // i18n[graph.renameGraph=Rename graph]
    _mnuRenameGraph = new JMenuItem(s_stringMgr.getString("graph.renameGraph"));
    _mnuRenameGraph.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onRenameGraph();
          }
        });

    // i18n[graph.removeGraph=Remove graph]
    _mnuRemoveGraph = new JMenuItem(s_stringMgr.getString("graph.removeGraph"));
    _mnuRemoveGraph.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onRemoveGraph();
          }
        });

    // i18n[graph.refreshAllTables=Refresh all tables]
    _mnuRefreshAllTables = new JMenuItem(s_stringMgr.getString("graph.refreshAllTables"));
    _mnuRefreshAllTables.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onRefreshAllTables();
          }
        });

    // i18n[graph.scriptAllTables=Script all tables]
    _mnuScriptAllTables = new JMenuItem(s_stringMgr.getString("graph.scriptAllTables"));
    _mnuScriptAllTables.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onScriptAllTables();
          }
        });

    /////////////////////////////////////////////////////////
    // Tablegroups
    // i18n[graph.scriptAllTables=Script all tables]
    _mnuSelectAllTables = new JMenuItem(s_stringMgr.getString("graph.selectAllTables"));
    _mnuSelectAllTables.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onSelectAllTables();
          }
        });

    // i18n[graph.scriptAllTables=Script all tables]
    _mnuSelectTablesByName = new JMenuItem(s_stringMgr.getString("graph.selectTablesByName"));
    _mnuSelectTablesByName.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onSelectTablesByName();
          }
        });
    /////////////////////////////////////////////////////////

    // i18n[graph.showConstr=Show constraint names]
    _mnuShowConstraintNames = new JCheckBoxMenuItem(s_stringMgr.getString("graph.showConstr"));
    _mnuShowConstraintNames.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            _desktopPane.repaint();
          }
        });

    // i18n[graph.showQualifiedTableNames=Show qualified table names]
    _mnuShowQualifiedTableNames =
        new JCheckBoxMenuItem(s_stringMgr.getString("graph.showQualifiedTableNames"));
    _mnuShowQualifiedTableNames.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onShowQualifiedTableNames();
          }
        });

    ImageIcon toWInIcon = _graphPluginResources.getIcon(GraphPluginResources.IKeys.TO_WINDOW);
    _mnuToggleWindowTab = new JMenuItem(s_stringMgr.getString("graph.toggleWindowTab"), toWInIcon);
    _mnuToggleWindowTab.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            onToggleWindowTab();
          }
        });

    _mnuAllTablesDbOrder = new JMenuItem(s_stringMgr.getString("graph.allTablesDbOrderRequested"));
    _mnuAllTablesDbOrder.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onAllTablesDbOrder();
          }
        });

    _mnuAllTablesByNameOrder =
        new JMenuItem(s_stringMgr.getString("graph.allTablesByNameOrderRequested"));
    _mnuAllTablesByNameOrder.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onAllTablesByNameOrder();
          }
        });

    _mnuAllTablesPkConstOrder =
        new JMenuItem(s_stringMgr.getString("graph.allTablesPkConstOrderRequested"));
    _mnuAllTablesPkConstOrder.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onAllTablesPkConstOrder();
          }
        });

    _mnuAllFilteredSelectedOrder =
        new JMenuItem(s_stringMgr.getString("graph.allTablesFilteredSelectedOrderRequested"));
    _mnuAllFilteredSelectedOrder.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onAllTablesFilteredSelectedOrder();
          }
        });

    _popUp.add(_mnuSaveGraph);
    _popUp.add(_mnuRenameGraph);
    _popUp.add(_mnuRemoveGraph);
    _popUp.add(new JSeparator());
    _popUp.add(_mnuRefreshAllTables);
    _popUp.add(_mnuScriptAllTables);
    _popUp.add(new JSeparator());
    /////////////////////////////////////////////////////////
    // Tablegroups
    _popUp.add(_mnuSelectAllTables);
    _popUp.add(_mnuSelectTablesByName);
    _popUp.add(new JSeparator());
    /////////////////////////////////////////////////////////
    _popUp.add(_mnuAllTablesDbOrder);
    _popUp.add(_mnuAllTablesByNameOrder);
    _popUp.add(_mnuAllTablesPkConstOrder);
    _popUp.add(_mnuAllFilteredSelectedOrder);
    _popUp.add(new JSeparator());
    _popUp.add(_mnuShowConstraintNames);
    _popUp.add(_mnuShowQualifiedTableNames);
    _popUp.add(new JSeparator());
    _popUp.add(_mnuToggleWindowTab);
    _popUp.add(new JSeparator());
    _popUp.add(_modeManager.getModeMenuItem());

    _modeManager.addModeManagerListener(
        new ModeManagerListener() {
          @Override
          public void modeChanged(Mode newMode) {
            _popUp.setVisible(false);
          }
        });

    _popUp.addPopupMenuListener(
        new PopupMenuListener() {
          @Override
          public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
            onPopupMenuWillBecomeInvisible();
          }

          @Override
          public void popupMenuWillBecomeVisible(PopupMenuEvent e) {}

          @Override
          public void popupMenuCanceled(PopupMenuEvent e) {}
        });
  }