Skip to content

Commit

Permalink
8288750: IGV: Improve Shortcuts
Browse files Browse the repository at this point in the history
Reviewed-by: chagedorn, thartmann
  • Loading branch information
tobiasholenstein committed Jun 27, 2022
1 parent 210a06a commit be6be15
Show file tree
Hide file tree
Showing 33 changed files with 504 additions and 288 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.netbeans.api.visual.action.SelectProvider;
import org.netbeans.api.visual.action.WidgetAction;
import org.netbeans.api.visual.widget.Widget;
import org.openide.util.Utilities;

/**
* Selection action that acts on double-click only. Does not support aiming.
Expand All @@ -42,14 +43,18 @@ public DoubleClickSelectAction(SelectProvider provider) {
this.provider = provider;
}

protected int getModifierMask () {
return Utilities.isMac() ? MouseEvent.META_DOWN_MASK : MouseEvent.CTRL_DOWN_MASK;
}

protected boolean isLocked() {
return false;
}

@Override
public State mousePressed(Widget widget, WidgetMouseEvent event) {
if (event.getClickCount() >= 2 && (event.getButton() == MouseEvent.BUTTON1 || event.getButton() == MouseEvent.BUTTON2)) {
boolean invert = (event.getModifiersEx() & MouseEvent.CTRL_DOWN_MASK) != 0;
boolean invert = (event.getModifiersEx() & getModifierMask()) != 0;
Point point = event.getPoint();
if (provider.isSelectionAllowed(widget, point, invert)) {
provider.select(widget, point, invert);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,36 +42,22 @@
import javax.swing.JFileChooser;
import javax.swing.SwingUtilities;
import javax.swing.filechooser.FileFilter;
import javax.swing.Action;
import org.netbeans.api.progress.ProgressHandle;
import org.netbeans.api.progress.ProgressHandleFactory;
import org.openide.util.Exceptions;
import org.openide.util.RequestProcessor;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
import org.openide.awt.ActionReferences;
import org.openide.awt.ActionRegistration;
import org.openide.util.HelpCtx;
import org.openide.util.NbBundle;
import org.openide.util.actions.SystemAction;
import org.openide.util.actions.CallableSystemAction;
import org.openide.util.Utilities;

/**
*
* @author Thomas Wuerthinger
*/

@ActionID(
category = "File",
id = "com.sun.hotspot.igv.coordinator.actions.ImportAction"
)
@ActionRegistration(
iconBase = "com/sun/hotspot/igv/coordinator/images/import.png",
displayName = "#CTL_ImportAction"
)
@ActionReferences({
@ActionReference(path = "Menu/File", position = 0),
@ActionReference(path = "Shortcuts", name = "C-O")
})
public final class ImportAction extends SystemAction {
public final class ImportAction extends CallableSystemAction {
private static final int WORKUNITS = 10000;

public static FileFilter getFileFilter() {
Expand All @@ -90,7 +76,7 @@ public String getDescription() {
}

@Override
public void actionPerformed(ActionEvent e) {
public void performAction() {
JFileChooser fc = new JFileChooser();
fc.setFileFilter(ImportAction.getFileFilter());
fc.setCurrentDirectory(new File(Settings.get().get(Settings.DIRECTORY, Settings.DIRECTORY_DEFAULT)));
Expand Down Expand Up @@ -170,13 +156,24 @@ public String getName() {
return NbBundle.getMessage(ImportAction.class, "CTL_ImportAction");
}

@Override
protected String iconResource() {
return "com/sun/hotspot/igv/coordinator/images/import.png";
public ImportAction() {
putValue(Action.SHORT_DESCRIPTION, "Open");
// D is the Control key on most platforms, the Command (meta) key on Macintosh
putValue(Action.ACCELERATOR_KEY, Utilities.stringToKey("D-O"));
}

@Override
public HelpCtx getHelpCtx() {
return HelpCtx.DEFAULT_HELP;
}

@Override
protected boolean asynchronous() {
return false;
}

@Override
protected String iconResource() {
return "com/sun/hotspot/igv/coordinator/images/import.png";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected void performAction(Node[] activatedNodes) {
}

public RemoveAction() {
putValue(Action.SHORT_DESCRIPTION, "Remove selected graphs and groups");
putValue(Action.SHORT_DESCRIPTION, getName());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,13 @@
*/
public final class RemoveAllAction extends CallableSystemAction {


@Override
public String getName() {
return NbBundle.getMessage(RemoveAllAction.class, "CTL_RemoveAllAction");
}

public RemoveAllAction() {
putValue(Action.SHORT_DESCRIPTION, "Remove all graphs and groups");
putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_SHIFT, InputEvent.CTRL_MASK));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,17 @@
import java.awt.event.KeyEvent;
import javax.swing.Action;
import javax.swing.KeyStroke;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
import org.openide.awt.ActionReferences;
import org.openide.awt.ActionRegistration;
import org.openide.util.HelpCtx;
import org.openide.util.NbBundle;
import org.openide.util.NbBundle.Messages;
import org.openide.util.actions.CallableSystemAction;
import org.openide.util.Utilities;

/**
*
* @author Thomas Wuerthinger
*/
@ActionID(
category = "File",
id = "com.sun.hotspot.igv.coordinator.actions.SaveAllAction"
)
@ActionRegistration(
displayName = "#CTL_SaveAllAction"
)
@ActionReferences({
@ActionReference(path = "Menu/File", position = 0),
@ActionReference(path = "Shortcuts", name = "C-S")
})

public final class SaveAllAction extends CallableSystemAction {

@Override
Expand All @@ -68,7 +55,8 @@ public String getName() {

public SaveAllAction() {
putValue(Action.SHORT_DESCRIPTION, "Save all groups to XML file...");
putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK));
// D is the Control key on most platforms, the Command (meta) key on Macintosh
putValue(Action.ACCELERATOR_KEY, Utilities.stringToKey("D-S"));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
<filesystem>
<folder name="Shortcuts">
<file name="D-Z.shadow">
<attr name="originalFile" stringvalue="Actions/Edit/org-openide-actions-UndoAction.instance"/>
</file>
<file name="DS-Z.shadow">
<attr name="originalFile" stringvalue="Actions/Edit/org-openide-actions-RedoAction.instance"/>
</file>
<file name="D-Y.shadow">
<attr name="originalFile" stringvalue="Actions/Edit/org-openide-actions-RedoAction.instance"/>
</file>
<file name="D-BACK_SPACE.shadow">
<attr name="originalFile" stringvalue="Actions/File/com-sun-hotspot-igv-coordinator-actions-RemoveAction.instance"/>
</file>
<file name="D-DELETE.shadow">
<attr name="originalFile" stringvalue="Actions/File/com-sun-hotspot-igv-coordinator-actions-RemoveAction.instance"/>
</file>
<file name="DS-W.shadow">
<attr name="originalFile" stringvalue="Actions/File/com-sun-hotspot-igv-coordinator-actions-RemoveAllAction.instance"/>
</file>
</folder>
<folder name="Actions">
<folder name="File">
<file name="com-sun-hotspot-igv-coordinator-actions-SaveAsAction.instance"/>
<file name="com-sun-hotspot-igv-coordinator-actions-SaveAllAction.instance"/>
<file name="com-sun-hotspot-igv-coordinator-actions-ImportAction.instance"/>
</folder>
<folder name="Edit">
<file name="com-sun-hotspot-igv-coordinator-actions-RemoveAction.instance"/>
<file name="com-sun-hotspot-igv-coordinator-actions-RemoveAllAction.instance"/>
</folder>
<folder name="Edit">
<file name="org-openide-actions-UndoAction.instance">
<attr name="instanceCreate" methodvalue="org.openide.actions.UndoRedoAction.create"/>
<attr name="undo" boolvalue="true"/>
</file>
<file name="org-openide-actions-RedoAction.instance">
<attr name="instanceCreate" methodvalue="org.openide.actions.UndoRedoAction.create"/>
<attr name="redo" boolvalue="true"/>
</file>
</folder>
<folder name="Window">
<file name="com-sun-hotspot-igv-coordinator-actions-OutlineAction.instance"/>
</folder>
Expand Down Expand Up @@ -44,14 +72,13 @@
<attr name="position" intvalue="350"/>
</file>
<file name="com-sun-hotspot-igv-coordinator-actions-RemoveAction.shadow">
<attr name="originalFile" stringvalue="Actions/Edit/com-sun-hotspot-igv-coordinator-actions-RemoveAction.instance"/>
<attr name="originalFile" stringvalue="Actions/File/com-sun-hotspot-igv-coordinator-actions-RemoveAction.instance"/>
<attr name="position" intvalue="400"/>
</file>
<file name="com-sun-hotspot-igv-coordinator-actions-RemoveAllAction.shadow">
<attr name="originalFile" stringvalue="Actions/Edit/com-sun-hotspot-igv-coordinator-actions-RemoveAllAction.instance"/>
<attr name="originalFile" stringvalue="Actions/File/com-sun-hotspot-igv-coordinator-actions-RemoveAllAction.instance"/>
<attr name="position" intvalue="500"/>
</file>

<!-- Hidden menu entries from other modules -->
<file name="org-netbeans-modules-editor-ExportHtmlAction.shadow_hidden"/>
<file name="org-netbeans-modules-openfile-OpenFileAction.shadow_hidden"/>
Expand All @@ -71,6 +98,14 @@
</folder>

<folder name="Edit">
<file name="org-openide-actions-UndoAction.shadow">
<attr name="originalFile" stringvalue="Actions/Edit/org-openide-actions-UndoAction.instance"/>
<attr name="position" intvalue="100"/>
</file>
<file name="org-openide-actions-RedoAction.shadow">
<attr name="originalFile" stringvalue="Actions/Edit/org-openide-actions-RedoAction.instance"/>
<attr name="position" intvalue="150"/>
</file>
<!-- Hidden menu entries from other modules -->
<file name="Separator1.instance_hidden"/>
<file name="Separator2.instance_hidden"/>
Expand Down Expand Up @@ -104,6 +139,7 @@
<file name="org-netbeans-core-actions-LogAction.shadow_hidden"/>
<file name="org-netbeans-core-multiview-EditorsAction.instance_hidden"/>
<file name="org-netbeans-core-windows-actions-ToolbarsListAction.instance_hidden"/>
<file name="org-netbeans-core-windows-actions-ToolbarsListAction.shadow_hidden"/>
<file name="org-netbeans-modules-editor-NbCodeFoldingAction.instance_hidden"/>
<file name="org-netbeans-modules-project-ui-SyncEditorWithViewsAction.shadow_hidden"/>
<file name="org-netbeans-modules-versioning-ShowTextAnnotationsAction.shadow_hidden"/>
Expand All @@ -114,34 +150,21 @@
</folder>

<!-- Hidden menus -->
<folder name="Tools_hidden"/>
<folder name="GoTo_hidden"/>
<folder name="Source_hidden"/>
<folder name="Refactoring_hidden"/>
<folder name="BuildProject_hidden"/>
<folder name="RunProject_hidden"/>
<folder name="Versioning_hidden"/>

<folder name="Tools">
<!-- Hidden menu entries from other modules -->
<file name="LibrariesCustomizerAction.shadow_hidden"/>
<file name="PaletteManager_hidden"/>
<file name="Separator1.instance_hidden"/>
<file name="Separator2.instance_hidden"/>
<file name="ServerManagerAction3.shadow_hidden"/>
<file name="VariablesCustomizerAction.shadow_hidden"/>
<file name="org-netbeans-modules-autoupdate-ui-actions-PluginManagerAction.shadow_hidden"/>
<file name="org-netbeans-modules-templates-actions-TemplatesAction.shadow_hidden"/>
<file name="org-netbeans-modules-options-OptionsWindowAction-separatorBefore.instance_hidden"/>
<file name="org-netbeans-modules-xml-catalog-CatalogAction.shadow_hidden"/>
<file name="org-openide-actions-ToolsAction.shadow_hidden"/>
</folder>


<folder name="Window">
<file name="OutlineAction.shadow">
<attr name="originalFile" stringvalue="Actions/Window/com-sun-hotspot-igv-coordinator-actions-OutlineAction.instance"/>
</file>

<!-- Hidden menu entries from other modules -->
<file name="Web_hidden"/>
<file name="org-netbeans-modules-tasks-ui-DashboardTopComponent.shadow_hidden"/>
<file name="Debug_hidden"/>
<file name="Navigator_hidden"/>
<file name="Other_hidden"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@ public String getName() {
return NbBundle.getMessage(SaveFilterSettingsAction.class, "CTL_NewFilterAction");
}

@Override
protected void initialize() {
super.initialize();
}

@Override
public HelpCtx getHelpCtx() {
return HelpCtx.DEFAULT_HELP;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@ public RemoveFilterSettingsAction() {
putValue(Action.SHORT_DESCRIPTION, "Delete current filter profile");
}

@Override
protected void initialize() {
super.initialize();
}

@Override
public HelpCtx getHelpCtx() {
return HelpCtx.DEFAULT_HELP;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ public String getName() {
return NbBundle.getMessage(SaveFilterSettingsAction.class, "CTL_SaveFilterSettingsAction");
}

@Override
protected void initialize() {
super.initialize();
}

public SaveFilterSettingsAction() {
putValue(Action.SHORT_DESCRIPTION, "Save filter configuration as profile...");
}
Expand Down

1 comment on commit be6be15

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.