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;
}
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;
}
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;
}
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();
}
}
}
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, ""));
}
}
Aggregations