Search in sources :

Example 76 with ActionEvent

use of java.awt.event.ActionEvent in project gephi by gephi.

the class DesktopToolController method getToolbar.

@Override
public JComponent getToolbar() {
    //Get tools ui
    HashMap<ToolUI, Tool> toolMap = new HashMap<>();
    List<ToolUI> toolsUI = new ArrayList<>();
    for (Tool tool : tools) {
        ToolUI ui = tool.getUI();
        if (ui != null) {
            toolsUI.add(ui);
            toolMap.put(ui, tool);
        }
    }
    //Sort by priority
    Collections.sort(toolsUI, new Comparator() {

        @Override
        public int compare(Object o1, Object o2) {
            Integer p1 = ((ToolUI) o1).getPosition();
            Integer p2 = ((ToolUI) o2).getPosition();
            return p1.compareTo(p2);
        }
    });
    //Create toolbar
    final Toolbar toolbar = new Toolbar();
    for (final ToolUI toolUI : toolsUI) {
        final Tool tool = toolMap.get(toolUI);
        JToggleButton btn;
        if (toolUI.getIcon() != null) {
            btn = new JToggleButton(toolUI.getIcon());
        } else {
            btn = new JToggleButton(new ImageIcon(getClass().getResource("/org/gephi/desktop/tools/tool.png")));
        }
        btn.setToolTipText(toolUI.getName() + " - " + toolUI.getDescription());
        btn.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                //Let the user unselect a tool (by clicking on it again) without having to select other tool:
                if (tool == currentTool) {
                    toolbar.clearSelection();
                    unselect();
                } else {
                    try {
                        select(tool);
                        propertiesBar.select(toolUI.getPropertiesBar(tool));
                    } catch (UnselectToolException unselectToolException) {
                        toolbar.clearSelection();
                        unselect();
                    }
                }
            }
        });
        toolbar.add(btn);
    }
    //SelectionManager events
    VizController.getInstance().getSelectionManager().addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            SelectionManager selectionManager = VizController.getInstance().getSelectionManager();
            if (selectionManager.isRectangleSelection() && currentTool != null) {
                toolbar.clearSelection();
                unselect();
            } else if (selectionManager.isSelectionEnabled() && currentTool != null && currentTool.getSelectionType() == ToolSelectionType.NONE) {
                toolbar.clearSelection();
                unselect();
            } else if (selectionManager.isDraggingEnabled() && currentTool != null) {
                toolbar.clearSelection();
                unselect();
            }
        }
    });
    return toolbar;
}
Also used : ImageIcon(javax.swing.ImageIcon) SelectionManager(org.gephi.visualization.api.selection.SelectionManager) HashMap(java.util.HashMap) UnselectToolException(org.gephi.tools.spi.UnselectToolException) ActionEvent(java.awt.event.ActionEvent) ArrayList(java.util.ArrayList) ToolUI(org.gephi.tools.spi.ToolUI) Comparator(java.util.Comparator) JToggleButton(javax.swing.JToggleButton) ActionListener(java.awt.event.ActionListener) ChangeEvent(javax.swing.event.ChangeEvent) ChangeListener(javax.swing.event.ChangeListener) Tool(org.gephi.tools.spi.Tool)

Example 77 with ActionEvent

use of java.awt.event.ActionEvent in project gephi by gephi.

the class PropertiesBar method getFullScreenIcon.

private JComponent getFullScreenIcon() {
    int logoWidth = 27;
    int logoHeight = 28;
    //fullscreen icon size
    if (UIUtils.isAquaLookAndFeel()) {
        logoWidth = 34;
    }
    JPanel c = new JPanel(new BorderLayout());
    c.setBackground(Color.WHITE);
    JButton fullScreenButton = new JButton();
    fullScreenButton.setIcon(new ImageIcon(getClass().getResource("/org/gephi/desktop/tools/gephilogo_std.png")));
    fullScreenButton.setRolloverEnabled(true);
    fullScreenButton.setRolloverIcon(new ImageIcon(getClass().getResource("/org/gephi/desktop/tools/gephilogo_glow.png")));
    fullScreenButton.setToolTipText(NbBundle.getMessage(PropertiesBar.class, "PropertiesBar.fullScreenButton.tooltip"));
    fullScreenButton.setBorderPainted(false);
    fullScreenButton.setContentAreaFilled(false);
    fullScreenButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    fullScreenButton.setBorder(BorderFactory.createEmptyBorder());
    fullScreenButton.setPreferredSize(new Dimension(logoWidth, logoHeight));
    fullScreenButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            Lookup lookup = Lookups.forPath("org-gephi-desktop-tools/Actions/ToggleFullScreenAction");
            for (Action a : lookup.lookupAll(Action.class)) {
                a.actionPerformed(null);
            }
        }
    });
    c.add(fullScreenButton, BorderLayout.CENTER);
    return c;
}
Also used : JPanel(javax.swing.JPanel) ImageIcon(javax.swing.ImageIcon) Action(javax.swing.Action) BorderLayout(java.awt.BorderLayout) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) Lookup(org.openide.util.Lookup) Dimension(java.awt.Dimension)

Example 78 with ActionEvent

use of java.awt.event.ActionEvent in project gephi by gephi.

the class RecentFiles method getMenuPresenter.

@Override
public JMenuItem getMenuPresenter() {
    JMenu menu = new JMenu(NbBundle.getMessage(RecentFiles.class, "CTL_OpenRecentFiles"));
    MostRecentFiles mru = Lookup.getDefault().lookup(MostRecentFiles.class);
    for (String filePath : mru.getMRUFileList()) {
        final File file = new File(filePath);
        if (file.exists()) {
            final String fileName = file.getName();
            JMenuItem menuItem = new JMenuItem(new AbstractAction(fileName) {

                @Override
                public void actionPerformed(ActionEvent e) {
                    FileObject fileObject = FileUtil.toFileObject(file);
                    if (fileObject.hasExt(GEPHI_EXTENSION)) {
                        ProjectControllerUI pc = Lookup.getDefault().lookup(ProjectControllerUI.class);
                        try {
                            pc.openProject(file);
                        } catch (Exception ex) {
                            Exceptions.printStackTrace(ex);
                        }
                    } else {
                        ImportControllerUI importController = Lookup.getDefault().lookup(ImportControllerUI.class);
                        if (importController.getImportController().isFileSupported(file)) {
                            importController.importFile(fileObject);
                        }
                    }
                }
            });
            menu.add(menuItem);
        }
    }
    return menu;
}
Also used : MostRecentFiles(org.gephi.desktop.mrufiles.api.MostRecentFiles) ActionEvent(java.awt.event.ActionEvent) MostRecentFiles(org.gephi.desktop.mrufiles.api.MostRecentFiles) ImportControllerUI(org.gephi.desktop.importer.api.ImportControllerUI) FileObject(org.openide.filesystems.FileObject) JMenuItem(javax.swing.JMenuItem) File(java.io.File) AbstractAction(javax.swing.AbstractAction) JMenu(javax.swing.JMenu) ProjectControllerUI(org.gephi.desktop.project.api.ProjectControllerUI)

Example 79 with ActionEvent

use of java.awt.event.ActionEvent in project gephi by gephi.

the class DirectoryChooserUI method checkUpdate.

private void checkUpdate() {
    if (Utilities.isWindows() && useShellFolder) {
        Long startTime = (Long) fileChooser.getClientProperty(DelegatingChooserUI.START_TIME);
        if (startTime == null) {
            return;
        }
        // clean for future marking
        fileChooser.putClientProperty(DelegatingChooserUI.START_TIME, null);
        long elapsed = System.currentTimeMillis() - startTime.longValue();
        long timeOut = NbPreferences.forModule(DirectoryChooserUI.class).getLong(TIMEOUT_KEY, 10000);
        if (timeOut > 0 && elapsed > timeOut && slownessPanel == null) {
            JLabel slownessNote = new JLabel(NbBundle.getMessage(DirectoryChooserUI.class, "MSG_SlownessNote"));
            slownessNote.setForeground(Color.RED);
            slownessPanel = new JPanel();
            JButton notShow = new JButton(NbBundle.getMessage(DirectoryChooserUI.class, "BTN_NotShow"));
            notShow.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    NbPreferences.forModule(DirectoryChooserUI.class).putLong(TIMEOUT_KEY, 0);
                    centerPanel.remove(slownessPanel);
                    centerPanel.revalidate();
                }
            });
            JPanel notShowP = new JPanel();
            notShowP.add(notShow);
            slownessPanel.setLayout(new BorderLayout());
            slownessPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
            slownessPanel.add(BorderLayout.CENTER, slownessNote);
            slownessPanel.add(BorderLayout.SOUTH, notShowP);
            centerPanel.add(BorderLayout.NORTH, slownessPanel);
            centerPanel.revalidate();
        }
    }
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent)

Example 80 with ActionEvent

use of java.awt.event.ActionEvent in project binnavi by google.

the class CProjectNode method doubleClicked.

@Override
public void doubleClicked() {
    // Open projects on double-click.
    if (!m_project.isLoaded()) {
        final Action action = CActionProxy.proxy(new CLoadProjectAction(getProjectTree(), new INaviProject[] { m_project }));
        action.actionPerformed(new ActionEvent(this, 0, ""));
    }
}
Also used : Action(javax.swing.Action) CLoadProjectAction(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Actions.CLoadProjectAction) INaviProject(com.google.security.zynamics.binnavi.disassembly.INaviProject) ActionEvent(java.awt.event.ActionEvent) CLoadProjectAction(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Actions.CLoadProjectAction)

Aggregations

ActionEvent (java.awt.event.ActionEvent)1619 ActionListener (java.awt.event.ActionListener)1289 JButton (javax.swing.JButton)417 JPanel (javax.swing.JPanel)391 JLabel (javax.swing.JLabel)253 JMenuItem (javax.swing.JMenuItem)219 BoxLayout (javax.swing.BoxLayout)172 AbstractAction (javax.swing.AbstractAction)166 FlowLayout (java.awt.FlowLayout)130 Insets (java.awt.Insets)129 GridBagConstraints (java.awt.GridBagConstraints)127 Dimension (java.awt.Dimension)126 GridBagLayout (java.awt.GridBagLayout)120 JMenu (javax.swing.JMenu)118 JScrollPane (javax.swing.JScrollPane)117 JCheckBox (javax.swing.JCheckBox)109 BorderLayout (java.awt.BorderLayout)108 JTextField (javax.swing.JTextField)85 JComboBox (javax.swing.JComboBox)77 ButtonGroup (javax.swing.ButtonGroup)72