Search in sources :

Example 6 with JSeparator

use of javax.swing.JSeparator in project gephi by gephi.

the class LayoutPanel method initEvents.

private void initEvents() {
    layoutCombobox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (layoutCombobox.getSelectedItem().equals(NO_SELECTION) && model.getSelectedLayout() != null) {
                setSelectedLayout(null);
            } else if (layoutCombobox.getSelectedItem() instanceof LayoutBuilderWrapper) {
                LayoutBuilder builder = ((LayoutBuilderWrapper) layoutCombobox.getSelectedItem()).getLayoutBuilder();
                if (model.getSelectedLayout() == null || model.getSelectedBuilder() != builder) {
                    setSelectedLayout(builder);
                }
            }
        }
    });
    infoLabel.addMouseListener(new MouseAdapter() {

        RichTooltip richTooltip;

        @Override
        public void mouseEntered(MouseEvent e) {
            if (infoLabel.isEnabled() && model != null && model.getSelectedLayout() != null) {
                richTooltip = buildTooltip(model.getSelectedBuilder());
                richTooltip.showTooltip(infoLabel, e.getLocationOnScreen());
            }
        }

        @Override
        public void mouseExited(MouseEvent e) {
            if (richTooltip != null) {
                richTooltip.hideTooltip();
                richTooltip = null;
            }
        }
    });
    presetsButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            JPopupMenu menu = new JPopupMenu();
            List<Preset> presets = layoutPresetPersistence.getPresets(model.getSelectedLayout());
            if (presets != null && !presets.isEmpty()) {
                for (final Preset p : presets) {
                    JMenuItem item = new JMenuItem(p.toString());
                    item.addActionListener(new ActionListener() {

                        @Override
                        public void actionPerformed(ActionEvent e) {
                            layoutPresetPersistence.loadPreset(p, model.getSelectedLayout());
                            refreshProperties();
                            StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(LayoutPanel.class, "LayoutPanel.status.loadPreset", model.getSelectedBuilder().getName(), p.toString()));
                        }
                    });
                    menu.add(item);
                }
            } else {
                menu.add("<html><i>" + NbBundle.getMessage(LayoutPanel.class, "LayoutPanel.presetsButton.nopreset") + "</i></html>");
            }
            JMenuItem saveItem = new JMenuItem(NbBundle.getMessage(LayoutPanel.class, "LayoutPanel.presetsButton.savePreset"));
            saveItem.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    String lastPresetName = NbPreferences.forModule(LayoutPanel.class).get("LayoutPanel.lastPresetName", "");
                    NotifyDescriptor.InputLine question = new NotifyDescriptor.InputLine(NbBundle.getMessage(LayoutPanel.class, "LayoutPanel.presetsButton.savePreset.input"), NbBundle.getMessage(LayoutPanel.class, "LayoutPanel.presetsButton.savePreset.input.name"));
                    question.setInputText(lastPresetName);
                    if (DialogDisplayer.getDefault().notify(question) == NotifyDescriptor.OK_OPTION) {
                        String input = question.getInputText();
                        if (input != null && !input.isEmpty()) {
                            layoutPresetPersistence.savePreset(input, model.getSelectedLayout());
                            StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(LayoutPanel.class, "LayoutPanel.status.savePreset", model.getSelectedBuilder().getName(), input));
                            NbPreferences.forModule(LayoutPanel.class).put("LayoutPanel.lastPresetName", input);
                        }
                    }
                }
            });
            menu.add(new JSeparator());
            menu.add(saveItem);
            menu.show(layoutToolbar, 0, -menu.getPreferredSize().height);
        }
    });
}
Also used : LayoutBuilder(org.gephi.layout.spi.LayoutBuilder) ItemEvent(java.awt.event.ItemEvent) MouseEvent(java.awt.event.MouseEvent) ActionEvent(java.awt.event.ActionEvent) Preset(org.gephi.desktop.layout.LayoutPresetPersistence.Preset) MouseAdapter(java.awt.event.MouseAdapter) JPopupMenu(javax.swing.JPopupMenu) JSeparator(javax.swing.JSeparator) NotifyDescriptor(org.openide.NotifyDescriptor) RichTooltip(org.gephi.ui.components.richtooltip.RichTooltip) ActionListener(java.awt.event.ActionListener) ItemListener(java.awt.event.ItemListener) ArrayList(java.util.ArrayList) List(java.util.List) JMenuItem(javax.swing.JMenuItem)

Example 7 with JSeparator

use of javax.swing.JSeparator in project binnavi by google.

the class CModuleContainerNodeMenuBuilder method createMenu.

@Override
protected void createMenu(final JComponent menu) {
    if (m_containerNode == null) {
        m_containerNode = getModuleContainerNode(CNodeExpander.findNode(getProjectTree(), m_database));
    }
    menu.add(new JMenuItem(CActionProxy.proxy(new CImportModuleAction(getParent(), m_database))));
    menu.add(new JMenuItem(CActionProxy.proxy(new CRefreshRawModulesAction(getParent(), m_database))));
    menu.add(new JMenuItem(CActionProxy.proxy(new CResolveAllFunctionsAction(menu, m_database))));
    menu.add(new JSeparator());
    final JMenu sortMenu = new JMenu("Sort");
    final JRadioButtonMenuItem idMenu = new JRadioButtonMenuItem(new CActionSortModulesById(m_containerNode));
    idMenu.setSelected(!m_containerNode.isSorted());
    sortMenu.add(idMenu);
    final JRadioButtonMenuItem nameMenu = new JRadioButtonMenuItem(new CActionSortModulesByName(m_containerNode));
    nameMenu.setSelected(m_containerNode.isSorted());
    sortMenu.add(nameMenu);
    menu.add(sortMenu);
}
Also used : CResolveAllFunctionsAction(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Actions.CResolveAllFunctionsAction) CActionSortModulesByName(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Actions.CActionSortModulesByName) CActionSortModulesById(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Actions.CActionSortModulesById) CImportModuleAction(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Actions.CImportModuleAction) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) CRefreshRawModulesAction(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Actions.CRefreshRawModulesAction) JMenuItem(javax.swing.JMenuItem) JSeparator(javax.swing.JSeparator) JMenu(javax.swing.JMenu)

Example 8 with JSeparator

use of javax.swing.JSeparator in project binnavi by google.

the class CTagNodeMenuBuilder method createMenu.

@Override
protected void createMenu(final JComponent menu) {
    menu.add(new JMenuItem(CActionProxy.proxy(new CAddTagAction(getParent(), m_database.getContent().getViewTagManager(), m_tag, "New Tag"))));
    menu.add(new JMenuItem(CActionProxy.proxy(new CInsertTagAction(getParent(), m_database.getContent().getViewTagManager(), m_tag, "New Tag"))));
    menu.add(new JSeparator());
    menu.add(new JMenuItem(CActionProxy.proxy(new CDeleteTagAction(getParent(), m_database.getContent().getViewTagManager(), m_tag))));
    menu.add(new JSeparator());
    menu.add(new JMenuItem(CActionProxy.proxy(new CDeleteTagSubtreeAction(getParent(), m_database.getContent().getViewTagManager(), m_tag))));
}
Also used : CDeleteTagSubtreeAction(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Actions.CDeleteTagSubtreeAction) CDeleteTagAction(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Actions.CDeleteTagAction) CAddTagAction(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Actions.CAddTagAction) JMenuItem(javax.swing.JMenuItem) CInsertTagAction(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Actions.CInsertTagAction) JSeparator(javax.swing.JSeparator)

Example 9 with JSeparator

use of javax.swing.JSeparator in project binnavi by google.

the class CProjectContainerNodeMenuBuilder method createMenu.

@Override
protected void createMenu(final JComponent menu) {
    menu.add(new JMenuItem(CActionProxy.proxy(new CCreateProjectAction(getParent(), database, new CNodeSelectionUpdater(getProjectTree(), findNode())))));
    final List<IProjectFolderMenuPlugin> plugins = new ArrayList<IProjectFolderMenuPlugin>();
    for (final IPlugin<IPluginInterface> plugin : PluginInterface.instance().getPluginRegistry()) {
        if (plugin instanceof IProjectFolderMenuPlugin) {
            plugins.add((IProjectFolderMenuPlugin) plugin);
        }
    }
    if (!plugins.isEmpty()) {
        menu.add(new JSeparator());
        for (final IProjectFolderMenuPlugin plugin : plugins) {
            try {
                final List<JComponent> menuItems = plugin.extendProjectFolderMenu(getPluginDatabase());
                if (menuItems != null) {
                    for (final JComponent menuItem : menuItems) {
                        menu.add(menuItem);
                    }
                }
            } catch (final Exception exception) {
                CUtilityFunctions.logException(exception);
                final String innerMessage = "E00089: " + "Plugin caused an unexpected exception";
                final String innerDescription = CUtilityFunctions.createDescription(String.format("The plugin %s caused an unexpected exception.", plugin.getName()), new String[] { "The plugin contains a bug." }, new String[] { "The plugin probably behaves erroneously from this point on but it remains active" });
                NaviErrorDialog.show(getParent(), innerMessage, innerDescription, exception);
            }
        }
    }
}
Also used : IPluginInterface(com.google.security.zynamics.binnavi.api2.IPluginInterface) ArrayList(java.util.ArrayList) JComponent(javax.swing.JComponent) CCreateProjectAction(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Actions.CCreateProjectAction) JSeparator(javax.swing.JSeparator) IProjectFolderMenuPlugin(com.google.security.zynamics.binnavi.API.plugins.IProjectFolderMenuPlugin) CNodeSelectionUpdater(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Updaters.CNodeSelectionUpdater) JMenuItem(javax.swing.JMenuItem)

Example 10 with JSeparator

use of javax.swing.JSeparator in project OpenNotebook by jaltekruse.

the class ProblemListPanel method createPanelForProblems.

public JPanel createPanelForProblems() {
    ProblemList panel = new ProblemList();
    JPanel tempPanel;
    GridBagConstraints con = new GridBagConstraints();
    JComboBox frequencyChoices;
    Component[] othersInRow = new Component[2];
    ;
    int numProblemsToShow = notebookPanel.getDatabase().getAllProblems().size();
    if (numProblemsToShow > 20) {
        // limit the number of problems in the list
        // to 20 at a time
        numProblemsToShow = 20;
    }
    con.gridy = 0;
    panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    panel.setLayout(new GridBagLayout());
    for (final ProblemGenerator g : notebookPanel.getDatabase().getAllProblems()) {
        // add checkbox
        con.fill = GridBagConstraints.NONE;
        con.gridx = 0;
        con.gridwidth = 1;
        con.weightx = 0;
        con.insets = new Insets(0, 0, 0, 0);
        final JCheckBox checkbox = new JCheckBox();
        checkbox.addItemListener(new ItemListener() {

            @Override
            public void itemStateChanged(ItemEvent ev) {
                if (ev.getStateChange() == ItemEvent.SELECTED) {
                    selectedFrequencies.add(10);
                    selectedProblems.add(g);
                } else {
                    selectedFrequencies.remove(selectedProblems.indexOf(g));
                    selectedProblems.remove(g);
                }
                previewPanel.getDoc().getPage(0).removeAllObjects();
                // set the page size big to prevent problem generation from spawning pages
                previewPanel.getDoc().setHeight(5000);
                previewPanel.getDoc().setWidth(5000);
                previewPanel.getDoc().generateProblem(g);
                previewPanel.resizeViewWindow();
                MathObject mObj = previewPanel.getDoc().getPage(0).getObjects().get(0);
                previewPanel.getDoc().setWidth(mObj.getWidth() + 2 * problemBuffer);
                previewPanel.getDoc().setHeight(mObj.getHeight() + 2 * problemBuffer);
                mObj.setxPos(problemBuffer);
                mObj.setyPos(problemBuffer);
                previewPanel.resizeViewWindow();
            }
        });
        frequencyChoices = new JComboBox(frequencies);
        panel.add(checkbox, con);
        othersInRow[0] = checkbox;
        othersInRow[1] = frequencyChoices;
        con.fill = GridBagConstraints.HORIZONTAL;
        con.insets = new Insets(0, 5, 0, 0);
        con.weightx = 1;
        con.gridx = 1;
        tempPanel = new ProblemDescriptionPanel(g, othersInRow);
        tempPanel.addMouseListener(new MouseListener() {

            public void mouseClicked(MouseEvent arg0) {
            }

            public void mouseEntered(MouseEvent arg0) {
            }

            public void mouseExited(MouseEvent arg0) {
            }

            @Override
            public void mousePressed(MouseEvent arg0) {
                checkbox.setSelected(!checkbox.isSelected());
            }

            public void mouseReleased(MouseEvent arg0) {
            }
        });
        panel.add(tempPanel, con);
        //			// add frequency selection menu
        //			con.fill = GridBagConstraints.NONE;
        //			con.gridx = 2;
        //			con.weightx = 0;
        //			con.insets = new Insets(0, 5, 0, 5);
        //			frequencyChoices.setSelectedItem(AVERAGE);
        //			panel.add(frequencyChoices, con);
        con.gridy++;
        con.gridx = 0;
        con.gridwidth = 2;
        con.insets = new Insets(0, 0, 0, 0);
        panel.add(new JSeparator(), con);
        con.gridy++;
    }
    return panel;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) ItemEvent(java.awt.event.ItemEvent) Insets(java.awt.Insets) MouseEvent(java.awt.event.MouseEvent) JComboBox(javax.swing.JComboBox) GridBagLayout(java.awt.GridBagLayout) JSeparator(javax.swing.JSeparator) ProblemGenerator(doc.mathobjects.ProblemGenerator) JCheckBox(javax.swing.JCheckBox) MouseListener(java.awt.event.MouseListener) ItemListener(java.awt.event.ItemListener) JComponent(javax.swing.JComponent) Component(java.awt.Component) MathObject(doc.mathobjects.MathObject)

Aggregations

JSeparator (javax.swing.JSeparator)147 JPanel (javax.swing.JPanel)74 JLabel (javax.swing.JLabel)65 ActionEvent (java.awt.event.ActionEvent)44 BoxLayout (javax.swing.BoxLayout)44 JButton (javax.swing.JButton)44 JMenuItem (javax.swing.JMenuItem)38 JMenu (javax.swing.JMenu)32 GridBagConstraints (java.awt.GridBagConstraints)31 Insets (java.awt.Insets)30 ActionListener (java.awt.event.ActionListener)30 Dimension (java.awt.Dimension)24 FlowLayout (java.awt.FlowLayout)24 JScrollPane (javax.swing.JScrollPane)24 GridBagLayout (java.awt.GridBagLayout)22 JPopupMenu (javax.swing.JPopupMenu)19 BorderLayout (java.awt.BorderLayout)16 JTextField (javax.swing.JTextField)16 JCheckBox (javax.swing.JCheckBox)13 AbstractAction (javax.swing.AbstractAction)12