Search in sources :

Example 21 with MenuListener

use of javax.swing.event.MenuListener in project cytoscape-api by cytoscape.

the class JMenuTracker method getGravityTracker.

/**
	 * This method will fetch an existing menu or create a new one if a menu
	 * with the specified name does not exist. The menu name is specified
	 * with a '.' delimited string, such that each token creates a new child
	 * menu.  Insertion locations are determined in two possible ways: 1) a "gravity" or "weight"
	 * may be specified in square brackets after each item name.  If the gravity has been
	 * omitted, the insertion location will be based on a case-insensitive alphanumeric
	 * ordering.   An example of a string using weights is "File[10].New[40]".
	 *
	 * @param menuString A '.' delimited string identifying menu names.
	 * @return The last child JMenu object specified by the menu_string parameter.
	 */
public GravityTracker getGravityTracker(final String menuString) {
    if (menuString == null)
        throw new NullPointerException("menu string is null");
    if (menuString.isEmpty())
        throw new IllegalArgumentException("menu string has zero length");
    // Special case: if we have a popup menu and the menu is "." return the rootGravityTracker
    if (menuString.equals(".") && rootPopupGravityTracker != null)
        return rootPopupGravityTracker;
    final List<MenuNameAndGravity> namesAndGravities = parseMenuString(menuString);
    MenuGravityTracker parentGravityTracker = null;
    MenuGravityTracker gravityTracker = null;
    String menu_key = null;
    for (final MenuNameAndGravity nameAndGravity : namesAndGravities) {
        final String menu_token = nameAndGravity.getMenuName();
        menu_key = menu_key == null ? menu_token : menu_key + "." + menu_token;
        gravityTracker = menuMap.get(menu_key);
        if (gravityTracker == null) {
            final JMenu menu = new JMenu(menu_token);
            menu.addMenuListener(new MenuListener() {

                @Override
                public void menuSelected(MenuEvent e) {
                    // Force update of enabled state of all of its direct menu items
                    final int itemCount = menu.getItemCount();
                    for (int i = 0; i < itemCount; i++) {
                        final JMenuItem item = menu.getItem(i);
                        if (item != null && item.getAction() != null)
                            item.setEnabled(item.getAction().isEnabled());
                    }
                }

                @Override
                public void menuDeselected(MenuEvent e) {
                }

                @Override
                public void menuCanceled(MenuEvent e) {
                }
            });
            // if there is a JMenu parent, use that
            if (parentGravityTracker != null)
                parentGravityTracker.addMenu(menu, nameAndGravity.getGravity());
            else // otherwise use add the menu to the root component
            if (rootMenuBar != null && rootPopupGravityTracker == null)
                rootMenuBar.add(menu);
            else if (rootMenuBar == null && rootPopupGravityTracker != null)
                rootPopupGravityTracker.addMenu(menu, nameAndGravity.getGravity());
            else
                throw new IllegalStateException("we have no root popup menu or menu bar.");
            gravityTracker = new MenuGravityTracker(menu);
            menuMap.put(menu_key, gravityTracker);
        }
        parentGravityTracker = gravityTracker;
    }
    return gravityTracker;
}
Also used : MenuListener(javax.swing.event.MenuListener) JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu) MenuEvent(javax.swing.event.MenuEvent)

Example 22 with MenuListener

use of javax.swing.event.MenuListener in project cuba by cuba-platform.

the class MenuBuilder method createMenuBarItem.

private void createMenuBarItem(JMenuBar menuBar, MenuItem item) {
    String caption = menuConfig.getItemCaption(item.getId());
    if (!item.getChildren().isEmpty() || item.isMenu()) {
        final JMenu jMenu = new JMenu(caption);
        jMenu.addMenuListener(new MenuListener() {

            @Override
            public void menuSelected(MenuEvent e) {
                jMenu.requestFocus();
            }

            @Override
            public void menuDeselected(MenuEvent e) {
            }

            @Override
            public void menuCanceled(MenuEvent e) {
            }
        });
        jMenu.setName(item.getId());
        menuBar.add(jMenu);
        createSubMenu(jMenu, item);
    } else {
        JMenuItem jMenuItem = new JMenuItem(caption);
        jMenuItem.setName(item.getId());
        // todo remove hardcoded border
        jMenuItem.setBorder(BorderFactory.createEmptyBorder(1, 4, 2, 4));
        assignShortcut(jMenuItem, item);
        jMenuItem.setMaximumSize(new Dimension(jMenuItem.getPreferredSize().width, jMenuItem.getMaximumSize().height));
        assignCommand(jMenuItem, item);
        menuBar.add(jMenuItem);
    }
}
Also used : MenuListener(javax.swing.event.MenuListener) MenuEvent(javax.swing.event.MenuEvent)

Example 23 with MenuListener

use of javax.swing.event.MenuListener in project artisynth_core by artisynth.

the class MenuBarHandler method createMenus.

/**
 * creates menu items
 */
public void createMenus() {
    JPopupMenu.setDefaultLightWeightPopupEnabled(false);
    myMenuBar = new JMenuBar();
    myToolBar = new JPanel();
    myToolBar.setLayout(new BoxLayout(myToolBar, BoxLayout.LINE_AXIS));
    myToolBar.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
    // File menu
    JMenu menu = new JMenu("File");
    menu.addMenuListener(new MenuListener() {

        public void menuCanceled(MenuEvent m_evt) {
        }

        public void menuDeselected(MenuEvent m_evt) {
            JMenu menu = (JMenu) m_evt.getSource();
            menu.removeAll();
        }

        public void menuSelected(MenuEvent m_evt) {
            createFileMenu((JMenu) m_evt.getSource());
        }
    });
    myMenuBar.add(menu);
    // Create the menu with models (taken from .demoModels)
    menu = new JMenu("Models");
    myMenuBar.add(menu);
    createDemosMenu(menu);
    menu = createScriptsMenu("Scripts");
    if (menu != null) {
        myMenuBar.add(menu);
    }
    // "Edit" menu:
    menu = new JMenu("Edit");
    menu.addMenuListener(new MenuListener() {

        public void menuCanceled(MenuEvent m_evt) {
        }

        public void menuDeselected(MenuEvent m_evt) {
            JMenu menu = (JMenu) m_evt.getSource();
            menu.removeAll();
        }

        public void menuSelected(MenuEvent m_evt) {
            createEditMenu((JMenu) m_evt.getSource());
        }
    });
    myMenuBar.add(menu);
    // "Settings" menu:
    menu = new JMenu("Settings");
    menu.addMenuListener(new MenuListener() {

        public void menuCanceled(MenuEvent m_evt) {
        }

        public void menuDeselected(MenuEvent m_evt) {
            JMenu menu = (JMenu) m_evt.getSource();
            menu.removeAll();
        }

        public void menuSelected(MenuEvent m_evt) {
            createSettingsMenu((JMenu) m_evt.getSource());
        }
    });
    myMenuBar.add(menu);
    // Create the view menu
    menu = new JMenu("View");
    menu.addMenuListener(new MenuListener() {

        public void menuSelected(MenuEvent m_evt) {
            createViewMenu((JMenu) m_evt.getSource());
        }

        public void menuDeselected(MenuEvent m_evt) {
            JMenu menu = (JMenu) m_evt.getSource();
            menu.removeAll();
        }

        public void menuCanceled(MenuEvent m_evt) {
        }
    });
    myMenuBar.add(menu);
    // Help menu section
    menu = new JMenu("Help");
    menu.addMenuListener(new MenuListener() {

        public void menuCanceled(MenuEvent m_evt) {
        }

        public void menuDeselected(MenuEvent m_evt) {
            JMenu menu = (JMenu) m_evt.getSource();
            menu.removeAll();
        }

        public void menuSelected(MenuEvent m_evt) {
            createHelpMenu((JMenu) m_evt.getSource());
        }
    });
    myMenuBar.add(menu);
    // Application menu section
    menu = new JMenu("Application");
    menu.addMenuListener(new MenuListener() {

        public void menuCanceled(MenuEvent m_evt) {
        }

        public void menuDeselected(MenuEvent m_evt) {
            JMenu menu = (JMenu) m_evt.getSource();
            menu.removeAll();
        }

        public void menuSelected(MenuEvent m_evt) {
            createApplicationMenu((JMenu) m_evt.getSource());
        }
    });
    myApplicationMenu = menu;
    // myFrame.setJMenuBar(myMenuBar);
    // Adding iconic buttons
    // Create a space separator
    // height makes space for GridDisplay box
    myMenuBar.add(Box.createRigidArea(new Dimension(20, 28)));
    // Create navigation bar button
    navBarButton = ButtonCreator.createIconicButton(GuiStorage.getNavBarIcon(), myFrame.getNavPanel().getStatus() ? "Hide NavBar" : "Show Navbar", myFrame.getNavPanel().getStatus() ? "Hide NavBar" : "Show Navbar", ButtonCreator.BUTTON_ENABLED, false, this);
    myToolBar.add(Box.createRigidArea(new Dimension(2, 0)));
    myToolBar.add(navBarButton);
    myToolBar.add(Box.createRigidArea(new Dimension(2, 0)));
    rerenderButton = ButtonCreator.createIconicButton(GuiUtils.loadIcon(ControlPanel.class, "icon/refresh.png"), "Re-render", "Re-render", ButtonCreator.BUTTON_ENABLED, false, this);
    myToolBar.add(rerenderButton);
    // Charles modification
    // creates a message Box. Currently only used for Units
    // grid not visible reset textField
    myToolBar.add(Box.createRigidArea(new Dimension(10, 0)));
    myToolBar.add(Box.createHorizontalGlue());
    myGridDisplayIndex = myToolBar.getComponentCount();
    myToolBar.add(GridDisplay.createPlaceHolder());
    myStepDisplay = createStepDisplay();
    myToolBar.add(myStepDisplay);
    // myToolBar.add (Box.createRigidArea (new Dimension (4, 0)));
    myTimeDisplay = createTimeDisplay();
    myToolBar.add(myTimeDisplay);
    myToolBar.add(Box.createRigidArea(new Dimension(4, 0)));
    // Create reset button
    resetButton = ButtonCreator.createIconicButton(GuiStorage.getResetIcon(), "Reset", "Reset", ButtonCreator.BUTTON_ENABLED, false, this);
    myToolBar.add(resetButton);
    myToolBar.add(Box.createRigidArea(new Dimension(2, 0)));
    // Create play button
    playButton = ButtonCreator.createIconicButton(GuiStorage.getPlayIcon(), "Play", "Play", ButtonCreator.BUTTON_DISABLED, false, this);
    myToolBar.add(playButton);
    myToolBar.add(Box.createRigidArea(new Dimension(2, 0)));
    // Create step button
    singleStepButton = ButtonCreator.createIconicButton(GuiStorage.getStepForwardIcon(), "Single step", "Single step", ButtonCreator.BUTTON_DISABLED, false, this);
    myToolBar.add(singleStepButton);
    myToolBar.add(Box.createRigidArea(new Dimension(2, 0)));
    // Set the menu bar
    myFrame.setJMenuBar(myMenuBar);
    myFrame.add(myToolBar, BorderLayout.NORTH);
}
Also used : JPanel(javax.swing.JPanel) MenuListener(javax.swing.event.MenuListener) BoxLayout(javax.swing.BoxLayout) Dimension(java.awt.Dimension) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu) MenuEvent(javax.swing.event.MenuEvent)

Example 24 with MenuListener

use of javax.swing.event.MenuListener in project narchy by automenta.

the class JCTermSwingFrame method getJMenuBar.

public JMenuBar getJMenuBar() {
    JMenuBar mb = new JMenuBar();
    JMenu m;
    JMenuItem mi;
    m = new JMenu("File");
    mi = new JMenuItem("Open SHELL Session...");
    mi.addActionListener(this);
    mi.setActionCommand("Open SHELL Session...");
    m.add(mi);
    mi = new JMenuItem("Open SFTP Session...");
    mi.addActionListener(this);
    mi.setActionCommand("Open SFTP Session...");
    m.add(mi);
    mi = new JMenuItem("Quit");
    mi.addActionListener(this);
    mi.setActionCommand("Quit");
    m.add(mi);
    mb.add(m);
    m = new JMenu("Proxy");
    mi = new JMenuItem("HTTP...");
    mi.addActionListener(this);
    mi.setActionCommand("HTTP...");
    m.add(mi);
    mi = new JMenuItem("SOCKS5...");
    mi.addActionListener(this);
    mi.setActionCommand("SOCKS5...");
    m.add(mi);
    mb.add(m);
    m = new JMenu("PortForwarding");
    mi = new JMenuItem("Local Port...");
    mi.addActionListener(this);
    mi.setActionCommand("Local Port...");
    m.add(mi);
    mi = new JMenuItem("Remote Port...");
    mi.addActionListener(this);
    mi.setActionCommand("Remote Port...");
    m.add(mi);
    mi = new JMenuItem("X11 Forwarding...");
    mi.addActionListener(this);
    mi.setActionCommand("X11 Forwarding...");
    m.add(mi);
    mb.add(m);
    m = new JMenu("Etc");
    mi = new JMenuItem("AntiAliasing");
    mi.addActionListener(this);
    mi.setActionCommand("AntiAliasing");
    m.add(mi);
    mi = new JMenuItem("Compression...");
    mi.addActionListener(this);
    mi.setActionCommand("Compression...");
    m.add(mi);
    JMenu mcolor = new JMenu("Color");
    final ActionListener mcolor_action = e -> setFgBg(e.getActionCommand());
    mcolor.addMenuListener(new MenuListener() {

        public void menuSelected(MenuEvent me) {
            JMenu jm = (JMenu) me.getSource();
            String[] fg_bg = JCTermSwing.getCR().load(configName).fg_bg;
            for (int i = 0; i < fg_bg.length; i++) {
                String[] tmp = fg_bg[i].split(":");
                JMenuItem mi = new JMenuItem("ABC");
                mi.setForeground(JCTermSwing.toColor(tmp[0]));
                mi.setBackground(JCTermSwing.toColor(tmp[1]));
                mi.setActionCommand(fg_bg[i]);
                mi.addActionListener(mcolor_action);
                jm.add(mi);
            }
        }

        public void menuDeselected(MenuEvent me) {
            JMenu jm = (JMenu) me.getSource();
            jm.removeAll();
        }

        public void menuCanceled(MenuEvent arg) {
        }
    });
    m.add(mcolor);
    JMenu mfsize = new JMenu("Font size");
    final ActionListener mfsize_action = e -> {
        String _font_size = e.getActionCommand();
        try {
            setFontSize(Integer.parseInt(_font_size));
        } catch (NumberFormatException nfe) {
        }
    };
    mfsize.addMenuListener(new MenuListener() {

        public void menuSelected(MenuEvent me) {
            JMenuItem mi;
            JMenu jm = (JMenu) me.getSource();
            int font_size = JCTermSwing.getCR().load(configName).font_size;
            mi = new JMenuItem("Smaller (" + (font_size - 1) + ')');
            mi.setActionCommand("" + (font_size - 1));
            mi.addActionListener(mfsize_action);
            jm.add(mi);
            mi = new JMenuItem("Larger (" + (font_size + 1) + ')');
            mi.setActionCommand("" + (font_size + 1));
            mi.addActionListener(mfsize_action);
            jm.add(mi);
        }

        public void menuDeselected(MenuEvent me) {
            JMenu jm = (JMenu) me.getSource();
            jm.removeAll();
        }

        public void menuCanceled(MenuEvent arg) {
        }
    });
    m.add(mfsize);
    mb.add(m);
    m = new JMenu("Help");
    mi = new JMenuItem("About...");
    mi.addActionListener(this);
    mi.setActionCommand("About...");
    m.add(mi);
    mb.add(m);
    return mb;
}
Also used : java.awt(java.awt) OutputStream(java.io.OutputStream) SHELL(com.jcraft.jcterm.Terminal.SHELL) SFTP(com.jcraft.jcterm.Terminal.SFTP) PipedInputStream(java.io.PipedInputStream) java.awt.event(java.awt.event) MenuEvent(javax.swing.event.MenuEvent) PipedOutputStream(java.io.PipedOutputStream) com.jcraft.jsch(com.jcraft.jsch) javax.swing(javax.swing) MenuListener(javax.swing.event.MenuListener) InputStream(java.io.InputStream) MenuListener(javax.swing.event.MenuListener) MenuEvent(javax.swing.event.MenuEvent)

Example 25 with MenuListener

use of javax.swing.event.MenuListener in project fql by CategoricalData.

the class SketchFrame method buildMenu.

/**
 * Builds the menu
 */
private void buildMenu() {
    final JMenuBar mainMenu;
    final JMenu menuFile;
    final JMenu menuHelp;
    mainMenu = new JMenuBar();
    // Make the File Menu
    menuFile = new JMenu("File");
    mainMenu.add(menuFile);
    menuFile.setMnemonic(KeyEvent.VK_F);
    final JMenu exportMenu = new JMenu("Export to");
    menuFile.add(exportMenu);
    // Export to server:
    addMenuItem(exportMenu, new JMenuItem(new ExportDatabaseAction(this, _ourSketch)), KeyEvent.VK_D);
    // Export to SQL text dump:
    addMenuItem(exportMenu, new JMenuItem(new ExportFileAction(this, _ourSketch)), KeyEvent.VK_F);
    addMenuItem(exportMenu, new JMenuItem(new ExportImageAction<>(this)), null);
    addMenuItem(exportMenu, new JMenuItem(new SketchExportAction(this)), null);
    menuFile.addSeparator();
    addMenuItem(menuFile, new JMenuItem(new DocumentInfoAction(this)), KeyEvent.VK_I);
    menuFile.addSeparator();
    addMenuItem(menuFile, new JMenuItem(new FileQuitAction(this)), KeyEvent.VK_W);
    // Make the Edit menu for "edit mode"
    menuEditEdit = new JMenu("Edit");
    mainMenu.add(menuEditEdit);
    addMenuItem(menuEditEdit, _UndoItem = new JMenuItem(new UndoAction(_ourSketch)), KeyEvent.VK_Z);
    addMenuItem(menuEditEdit, _RedoItem = new JMenuItem(new RedoAction(_ourSketch)), KeyEvent.VK_Y);
    menuEditEdit.addSeparator();
    menuEditEdit.add(menuEditAdd = new JMenu("Add"));
    addMenuItem(menuEditAdd, _AddEntityItem = new JMenuItem(new NewEntityAction<>(null, this)), null);
    menuEditAdd.add(menuEditAddEdge = new JMenu("Add edge"));
    addMenuItem(menuEditAddEdge, addEdge = new JMenuItem(new NewSketchEdgeAction(this, Edge.NORMAL)), null);
    addMenuItem(menuEditAddEdge, addInjEdge = new JMenuItem(new NewSketchEdgeAction(this, Edge.INJECTIVE)), null);
    addMenuItem(menuEditAddEdge, addParEdge = new JMenuItem(new NewSketchEdgeAction(this, Edge.PARTIAL)), null);
    addMenuItem(menuEditAddEdge, addSelfParEdge = new JMenuItem(new NewSketchEdgeAction(this, Edge.SELF)), null);
    addMenuItem(menuEditAdd, addAtt = new JMenuItem(new AddAttributeAction<>(this)), null);
    addMenuItem(menuEditAdd, addUK = new JMenuItem(new AddUniqueKeyAction<>(this)), null);
    addMenuItem(menuEditEdit, del = new JMenuItem(new DeleteFromSketchAction(this)), null);
    addMenuItem(menuEditEdit, rename = new JMenuItem(new RenameInSketchAction(this)), KeyEvent.VK_R);
    menuEditEdit.add(new JSeparator());
    addMenuItem(menuEditEdit, editEdge = new JMenuItem(new EditSketchEdgeAction(this)), KeyEvent.VK_E);
    menuEditEdit.add(new JSeparator());
    // If
    addMenuItem(menuEditEdit, _ProgramSettingsItem = new JMenuItem("Preferences"), KeyEvent.VK_P);
    // you
    // change
    // this
    // title,
    // update
    // OSX.java
    _ProgramSettingsItem.setToolTipText("Set global EASIK preferences");
    _ProgramSettingsItem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e1) {
            final ProgramSettingsUI myUI = new ProgramSettingsUI(SketchFrame.this);
            myUI.showDialog();
        }
    });
    // add listener to enable appropriate menu items
    menuEditEdit.addMenuListener(new MenuListener() {

        @Override
        public void menuCanceled(final MenuEvent e) {
        }

        @Override
        public void menuDeselected(final MenuEvent e) {
        }

        @Override
        public void menuSelected(final MenuEvent e) {
            final Object[] selection = _ourSketch.getSelectionCells();
            final SketchGraphModel model = _ourSketch.getGraphModel();
            final boolean undoable = model.canUndo() && !_ourSketch.getDatabase().hasConnection() && !_ourSketch.isSynced();
            final boolean redoable = model.canRedo() && !_ourSketch.getDatabase().hasConnection() && !_ourSketch.isSynced();
            _UndoItem.setEnabled(undoable);
            _RedoItem.setEnabled(redoable);
            menuEditAdd.setEnabled(true);
            menuEditAddEdge.setEnabled(true);
            _AddEntityItem.setEnabled(false);
            addEdge.setEnabled(false);
            addInjEdge.setEnabled(false);
            addParEdge.setEnabled(false);
            addSelfParEdge.setEnabled(false);
            addAtt.setEnabled(false);
            addUK.setEnabled(false);
            rename.setEnabled(false);
            del.setEnabled(false);
            editEdge.setEnabled(false);
            if (selection.length == 0) {
                _AddEntityItem.setEnabled(true);
                menuEditAddEdge.setEnabled(false);
            }
            if (selection.length >= 1) {
                del.setEnabled(true);
                if (selection.length == 1) {
                    if (selection[0] instanceof EntityNode) {
                        rename.setEnabled(true);
                    }
                    if (selection[0] instanceof EntityNode) {
                        addSelfParEdge.setEnabled(true);
                        addAtt.setEnabled(true);
                        addUK.setEnabled(true);
                    } else if (selection[0] instanceof SketchEdge) {
                        editEdge.setEnabled(true);
                    }
                }
                // if selection contains an edge, dissable edit|add...
                for (int i = 0; i < selection.length; i++) {
                    if (selection[i] instanceof SketchEdge) {
                        menuEditAdd.setEnabled(false);
                    }
                }
                if (selection.length >= 3) {
                    menuEditAdd.setEnabled(false);
                }
            }
            if ((selection.length == 2) && (selection[0] instanceof EntityNode) && (selection[1] instanceof EntityNode)) {
                addEdge.setEnabled(true);
                addInjEdge.setEnabled(true);
                addParEdge.setEnabled(true);
            }
        }
    });
    // Make the Edit menu for "manipulate mode"
    @SuppressWarnings("unused") final JMenuItem updateRowMenuItem;
    @SuppressWarnings("unused") final JMenuItem viewDataMenuItem;
    menuEditManip = new JMenu("Edit");
    mainMenu.add(menuEditManip);
    menuEditManip.add(addRowMenuItem = new JMenuItem(new AddRowAction(_ourSketch)));
    menuEditManip.add(insertQueryMenuItem = new JMenuItem(new ExecPreparedInsertAction(_ourSketch)));
    menuEditManip.addSeparator();
    menuEditManip.add(updateRowMenuItem = new JMenuItem(new UpdateRowAction(_ourSketch)));
    menuEditManip.addSeparator();
    menuEditManip.add(deleteRowMenuItem = new JMenuItem(new DeleteRowAction(_ourSketch)));
    menuEditManip.add(deleteQueryMenuItem = new JMenuItem(new ExecPreparedDeleteAction(_ourSketch)));
    menuEditManip.addSeparator();
    menuEditManip.add(viewDataMenuItem = new JMenuItem(new ViewDataAction(_ourSketch)));
    menuEditManip.addMenuListener(new MenuListener() {

        @Override
        public void menuCanceled(final MenuEvent e) {
        }

        @Override
        public void menuDeselected(final MenuEvent e) {
        }

        @Override
        public void menuSelected(final MenuEvent e) {
            final Object[] selection = _ourSketch.getSelectionCells();
            final boolean enable = (selection.length == 1) && (selection[0] instanceof EntityNode);
            for (final Component c : menuEditManip.getMenuComponents()) {
                c.setEnabled(enable);
            }
            if (!enable) {
                return;
            }
            if (!_ourSketch.editable((EntityNode) selection[0])) {
                addRowMenuItem.setEnabled(false);
                insertQueryMenuItem.setEnabled(false);
                deleteRowMenuItem.setEnabled(false);
                deleteQueryMenuItem.setEnabled(false);
            }
        }
    });
    menuView = new JMenu("View");
    mainMenu.add(menuView);
    menuView.add(_ShowAttributesToggle = new JCheckBoxMenuItem("Attributes/keys visible"));
    _ShowAttributesToggle.setToolTipText("Toggle display of attributes and unique keys");
    _ShowAttributesToggle.setState("show".equals(Easik.getInstance().getSettings().getProperty("attrib_display", "show")));
    _ShowAttributesToggle.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e1) {
            _ourSketch.refresh();
        }
    });
    menuView.add(_ShowConstraintToggle = new JCheckBoxMenuItem("Constraints visible"));
    _ShowConstraintToggle.setToolTipText("Toggle display of constraints");
    _ShowConstraintToggle.setState(true);
    _ShowConstraintToggle.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e1) {
            ModelConstraint.setAllConstraintsVisible(_ourSketch.getConstraints(), _ShowConstraintToggle.getState());
        }
    });
    // Create constraints menu
    menuConstraint = new JMenu("Constraints");
    menuConstraint.setMnemonic(KeyEvent.VK_C);
    mainMenu.add(menuConstraint);
    addMenuItem(menuConstraint, _AddCommutativeDiagramMenuItem = new JMenuItem(new AddCommutativeDiagramAction<>(this)), null);
    addMenuItem(menuConstraint, _AddSumMenuItem = new JMenuItem(new AddSumConstraintAction<>(this)), null);
    addMenuItem(menuConstraint, _AddProductMenuItem = new JMenuItem(new AddProductConstraintAction<>(this)), null);
    addMenuItem(menuConstraint, _AddPullbackMenuItem = new JMenuItem(new AddPullbackConstraintAction<>(this)), null);
    addMenuItem(menuConstraint, _AddEqualizerMenuItem = new JMenuItem(new AddEqualizerConstraintAction(this)), null);
    // addMenuItem(menuConstraint, _AddLimMenuItem = new JMenuItem(new
    // AddLimitConstraintAction<SketchFrame,
    // SketchGraphModel,Sketch,EntityNode, SketchEdge>(this)), null);
    // Make SQL connection menu
    menuSQL = new JMenu("SQL Connection");
    menuSQL.setMnemonic(KeyEvent.VK_S);
    mainMenu.add(menuSQL);
    addMenuItem(menuSQL, new JMenuItem(new DisconnectAction(_ourSketch)), null);
    // DTRIG
    addMenuItem(menuSQL, new JMenuItem(new OverrideConstraintAction(_ourSketch)), null);
    // CF2012
    // Create help menu
    menuHelp = new JMenu("Help");
    mainMenu.add(menuHelp);
    menuHelp.setMnemonic(KeyEvent.VK_H);
    menuHelp.add(new HelpAction());
    menuHelp.add(new AboutAction());
    setJMenuBar(mainMenu);
}
Also used : HelpAction(easik.ui.menu.HelpAction) ActionEvent(java.awt.event.ActionEvent) MenuListener(javax.swing.event.MenuListener) ExecPreparedDeleteAction(easik.ui.datamanip.jdbc.ExecPreparedDeleteAction) ExportFileAction(easik.ui.menu.ExportFileAction) ViewDataAction(easik.ui.menu.popup.ViewDataAction) NewSketchEdgeAction(easik.ui.menu.popup.NewSketchEdgeAction) DeleteRowAction(easik.ui.menu.popup.DeleteRowAction) JSeparator(javax.swing.JSeparator) EntityNode(easik.sketch.vertex.EntityNode) DeleteFromSketchAction(easik.ui.menu.popup.DeleteFromSketchAction) ExecPreparedInsertAction(easik.ui.datamanip.jdbc.ExecPreparedInsertAction) RedoAction(easik.ui.menu.RedoAction) JMenuItem(javax.swing.JMenuItem) Component(java.awt.Component) MenuEvent(javax.swing.event.MenuEvent) SketchExportAction(easik.ui.menu.SketchExportAction) UpdateRowAction(easik.ui.menu.popup.UpdateRowAction) AddRowAction(easik.ui.menu.popup.AddRowAction) AboutAction(easik.ui.menu.AboutAction) EditSketchEdgeAction(easik.ui.menu.popup.EditSketchEdgeAction) RenameInSketchAction(easik.ui.menu.popup.RenameInSketchAction) ExportImageAction(easik.ui.menu.ExportImageAction) ExportDatabaseAction(easik.ui.menu.ExportDatabaseAction) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) SketchGraphModel(easik.sketch.util.graph.SketchGraphModel) DisconnectAction(easik.ui.menu.popup.DisconnectAction) FileQuitAction(easik.ui.menu.FileQuitAction) ActionListener(java.awt.event.ActionListener) SketchEdge(easik.sketch.edge.SketchEdge) OverrideConstraintAction(easik.ui.menu.popup.OverrideConstraintAction) DocumentInfoAction(easik.ui.menu.DocumentInfoAction) AddEqualizerConstraintAction(easik.ui.menu.AddEqualizerConstraintAction) UndoAction(easik.ui.menu.UndoAction) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Aggregations

MenuListener (javax.swing.event.MenuListener)40 MenuEvent (javax.swing.event.MenuEvent)39 JMenu (javax.swing.JMenu)35 ActionEvent (java.awt.event.ActionEvent)23 JMenuItem (javax.swing.JMenuItem)23 ActionListener (java.awt.event.ActionListener)22 ItemEvent (java.awt.event.ItemEvent)18 ItemListener (java.awt.event.ItemListener)18 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)14 ButtonGroup (javax.swing.ButtonGroup)13 JPanel (javax.swing.JPanel)10 JRadioButtonMenuItem (javax.swing.JRadioButtonMenuItem)10 BorderLayout (java.awt.BorderLayout)9 HousePart (org.concord.energy3d.model.HousePart)9 Foundation (org.concord.energy3d.model.Foundation)8 JDialog (javax.swing.JDialog)7 JMenuBar (javax.swing.JMenuBar)7 JTextField (javax.swing.JTextField)6 BoxLayout (javax.swing.BoxLayout)5 JRadioButton (javax.swing.JRadioButton)5