From 59c82ac4da609c13757df7c521e7531eafdc1278 Mon Sep 17 00:00:00 2001 From: sarker Date: Fri, 5 Oct 2018 21:49:30 -0400 Subject: [PATCH] mac keyboard shortcut added --- .gitignore | 3 + pom.xml | 2 +- .../swing/handler/mxKeyboardHandler.java | 22 ++-- .../dase/swing/editor/EditorActions.java | 5 +- .../dase/swing/editor/EditorMenuBar.java | 120 +++++++++--------- .../swing/editor/SchemaEditorMenuBar.java | 18 +-- .../resources/resources/editor.properties | 2 +- update.properties | 4 +- 8 files changed, 89 insertions(+), 87 deletions(-) diff --git a/.gitignore b/.gitignore index bf78e94..4a2ece4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# intellij idea +.idea/ +*.iml # Java build artifacts class files *.class diff --git a/pom.xml b/pom.xml index bbd493c..10df9b7 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ edu.wright.dase OWLAx - 1.1.0 + 1.2.0 OWLAx Protege 5.0+ Plugin Ontology Design Pattern Plugin for Desktop Protege 5.0+ bundle diff --git a/src/main/java/com/mxgraph/swing/handler/mxKeyboardHandler.java b/src/main/java/com/mxgraph/swing/handler/mxKeyboardHandler.java index 3a34b7a..b8d82e7 100644 --- a/src/main/java/com/mxgraph/swing/handler/mxKeyboardHandler.java +++ b/src/main/java/com/mxgraph/swing/handler/mxKeyboardHandler.java @@ -57,28 +57,28 @@ protected InputMap getInputMap(int condition) { if (OSNAME.indexOf("mac") != -1) { map.put(KeyStroke.getKeyStroke("F2"), "edit"); - map.put(KeyStroke.getKeyStroke("DELETE"), "delete"); - map.put(KeyStroke.getKeyStroke("UP"), "selectParent"); - map.put(KeyStroke.getKeyStroke("DOWN"), "selectChild"); - map.put(KeyStroke.getKeyStroke("RIGHT"), "selectNext"); - map.put(KeyStroke.getKeyStroke("LEFT"), "selectPrevious"); + map.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, KeyEvent.META_DOWN_MASK), "delete"); + map.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, KeyEvent.META_DOWN_MASK), "selectParent"); + map.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, KeyEvent.META_DOWN_MASK), "selectChild"); + map.put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, KeyEvent.META_DOWN_MASK), "selectNext"); + map.put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, KeyEvent.META_DOWN_MASK), "selectPrevious"); map.put(KeyStroke.getKeyStroke("PAGE_DOWN"), "enterGroup"); map.put(KeyStroke.getKeyStroke("PAGE_UP"), "exitGroup"); map.put(KeyStroke.getKeyStroke("HOME"), "home"); map.put(KeyStroke.getKeyStroke("ENTER"), "expand"); map.put(KeyStroke.getKeyStroke("BACK_SPACE"), "collapse"); - map.put(KeyStroke.getKeyStroke("control A"), "selectAll"); - map.put(KeyStroke.getKeyStroke("control D"), "selectNone"); + map.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.META_DOWN_MASK), "selectAll"); + map.put(KeyStroke.getKeyStroke(KeyEvent.VK_D, KeyEvent.META_DOWN_MASK), "selectNone"); map.put(KeyStroke.getKeyStroke(KeyEvent.VK_X, KeyEvent.META_DOWN_MASK), "cut"); map.put(KeyStroke.getKeyStroke("CUT"), "cut"); map.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.META_DOWN_MASK), "copy"); map.put(KeyStroke.getKeyStroke("COPY"), "copy"); map.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, KeyEvent.META_DOWN_MASK), "paste"); map.put(KeyStroke.getKeyStroke("PASTE"), "paste"); - map.put(KeyStroke.getKeyStroke("control G"), "group"); - map.put(KeyStroke.getKeyStroke("control U"), "ungroup"); - map.put(KeyStroke.getKeyStroke("control ADD"), "zoomIn"); - map.put(KeyStroke.getKeyStroke("control SUBTRACT"), "zoomOut"); + map.put(KeyStroke.getKeyStroke(KeyEvent.VK_G, KeyEvent.META_DOWN_MASK), "group"); + map.put(KeyStroke.getKeyStroke(KeyEvent.VK_U, KeyEvent.META_DOWN_MASK), "ungroup"); + map.put(KeyStroke.getKeyStroke(KeyEvent.VK_ADD, KeyEvent.META_DOWN_MASK), "zoomIn"); + map.put(KeyStroke.getKeyStroke(KeyEvent.VK_SUBTRACT, KeyEvent.META_DOWN_MASK), "zoomOut"); } // if (OSNAME.indexOf("windows") != -1) // windows or linux then similar keyboard else { diff --git a/src/main/java/edu/wright/dase/swing/editor/EditorActions.java b/src/main/java/edu/wright/dase/swing/editor/EditorActions.java index a76d4f9..0fb1df0 100644 --- a/src/main/java/edu/wright/dase/swing/editor/EditorActions.java +++ b/src/main/java/edu/wright/dase/swing/editor/EditorActions.java @@ -645,7 +645,7 @@ public boolean accept(File file) { } else if (editor.getCurrentFile() != null) { wd = editor.getCurrentFile().getParent(); } else { - wd = System.getProperty("user.dir"); + wd = System.getProperty("user.home"); } JFileChooser fc = new JFileChooser(wd); @@ -685,7 +685,6 @@ public boolean accept(File file) { try { String ext = filename.substring(filename.lastIndexOf('.') + 1); - { Color bg = null; @@ -1471,7 +1470,7 @@ public void actionPerformed(ActionEvent e) { mxGraph graph = editor.getGraphComponent().getGraph(); if (graph != null) { - String wd = (lastDir != null) ? lastDir : System.getProperty("user.dir"); + String wd = (lastDir != null) ? lastDir : System.getProperty("user.home"); JFileChooser fc = new JFileChooser(wd); diff --git a/src/main/java/edu/wright/dase/swing/editor/EditorMenuBar.java b/src/main/java/edu/wright/dase/swing/editor/EditorMenuBar.java index 26f0392..e83cd7b 100644 --- a/src/main/java/edu/wright/dase/swing/editor/EditorMenuBar.java +++ b/src/main/java/edu/wright/dase/swing/editor/EditorMenuBar.java @@ -142,59 +142,59 @@ public EditorMenuBar(final BasicGraphEditor editor) { // Creates the view menu menu = add(new JMenu(mxResources.get("view"))); - JMenuItem item = menu.add(new TogglePropertyItem(graphComponent, mxResources.get("pageLayout"), "PageVisible", - true, new ActionListener() { - public void actionPerformed(ActionEvent e) { - if (graphComponent.isPageVisible() && graphComponent.isCenterPage()) { - graphComponent.zoomAndCenter(); - } else { - graphComponent.getGraphControl().updatePreferredSize(); - } - } - })); - - item.addActionListener(new ActionListener() { - /* - * (non-Javadoc) - * - * @see - * java.awt.event.ActionListener#actionPerformed(java.awt.event. - * ActionEvent) - */ - public void actionPerformed(ActionEvent e) { - if (e.getSource() instanceof TogglePropertyItem) { - final mxGraphComponent graphComponent = editor.getGraphComponent(); - TogglePropertyItem toggleItem = (TogglePropertyItem) e.getSource(); - - if (toggleItem.isSelected()) { - // Scrolls the view to the center - SwingUtilities.invokeLater(new Runnable() { - /* - * (non-Javadoc) - * - * @see java.lang.Runnable#run() - */ - public void run() { - graphComponent.scrollToCenter(true); - graphComponent.scrollToCenter(false); - } - }); - } else { - // Resets the translation of the view - mxPoint tr = graphComponent.getGraph().getView().getTranslate(); - - if (tr.getX() != 0 || tr.getY() != 0) { - graphComponent.getGraph().getView().setTranslate(new mxPoint()); - } - } - } - } - }); - - // menu.add(new TogglePropertyItem(graphComponent, - // mxResources.get("antialias"), "AntiAlias", true)); - - menu.addSeparator(); +// JMenuItem item = menu.add(new TogglePropertyItem(graphComponent, mxResources.get("pageLayout"), "PageVisible", +// true, new ActionListener() { +// public void actionPerformed(ActionEvent e) { +// if (graphComponent.isPageVisible() && graphComponent.isCenterPage()) { +// graphComponent.zoomAndCenter(); +// } else { +// graphComponent.getGraphControl().updatePreferredSize(); +// } +// } +// })); +// +// item.addActionListener(new ActionListener() { +// /* +// * (non-Javadoc) +// * +// * @see +// * java.awt.event.ActionListener#actionPerformed(java.awt.event. +// * ActionEvent) +// */ +// public void actionPerformed(ActionEvent e) { +// if (e.getSource() instanceof TogglePropertyItem) { +// final mxGraphComponent graphComponent = editor.getGraphComponent(); +// TogglePropertyItem toggleItem = (TogglePropertyItem) e.getSource(); +// +// if (toggleItem.isSelected()) { +// // Scrolls the view to the center +// SwingUtilities.invokeLater(new Runnable() { +// /* +// * (non-Javadoc) +// * +// * @see java.lang.Runnable#run() +// */ +// public void run() { +// graphComponent.scrollToCenter(true); +// graphComponent.scrollToCenter(false); +// } +// }); +// } else { +// // Resets the translation of the view +// mxPoint tr = graphComponent.getGraph().getView().getTranslate(); +// +// if (tr.getX() != 0 || tr.getY() != 0) { +// graphComponent.getGraph().getView().setTranslate(new mxPoint()); +// } +// } +// } +// } +// }); +// +// // menu.add(new TogglePropertyItem(graphComponent, +// // mxResources.get("antialias"), "AntiAlias", true)); +// +// menu.addSeparator(); menu.add(new ToggleGridItem(editor, mxResources.get("grid"))); menu.add(new ToggleRulersItem(editor, mxResources.get("rulers"))); @@ -219,14 +219,14 @@ public void run() { menu.add(editor.bind(mxResources.get("zoomIn"), mxGraphActions.getZoomInAction())); menu.add(editor.bind(mxResources.get("zoomOut"), mxGraphActions.getZoomOutAction())); - menu.addSeparator(); + //menu.addSeparator(); - menu.add(editor.bind(mxResources.get("page"), new ZoomPolicyAction(mxGraphComponent.ZOOM_POLICY_PAGE))); - menu.add(editor.bind(mxResources.get("width"), new ZoomPolicyAction(mxGraphComponent.ZOOM_POLICY_WIDTH))); +// menu.add(editor.bind(mxResources.get("page"), new ZoomPolicyAction(mxGraphComponent.ZOOM_POLICY_PAGE))); +// menu.add(editor.bind(mxResources.get("width"), new ZoomPolicyAction(mxGraphComponent.ZOOM_POLICY_WIDTH))); - menu.addSeparator(); + //menu.addSeparator(); - menu.add(editor.bind(mxResources.get("actualSize"), mxGraphActions.getZoomActualAction())); + //menu.add(editor.bind(mxResources.get("actualSize"), mxGraphActions.getZoomActualAction())); // Creates the format menu menu = add(new JMenu(mxResources.get("format"))); @@ -552,8 +552,8 @@ public void run() { // } // }); - item = menu.add(new JMenuItem(mxResources.get("aboutGraphEditor"))); - item.addActionListener(new ActionListener() { + JMenuItem aboutItem = menu.add(new JMenuItem(mxResources.get("aboutGraphEditor"))); + aboutItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { editor.about(); } diff --git a/src/main/java/edu/wright/dase/swing/editor/SchemaEditorMenuBar.java b/src/main/java/edu/wright/dase/swing/editor/SchemaEditorMenuBar.java index 327e5e2..50eb93f 100644 --- a/src/main/java/edu/wright/dase/swing/editor/SchemaEditorMenuBar.java +++ b/src/main/java/edu/wright/dase/swing/editor/SchemaEditorMenuBar.java @@ -129,7 +129,7 @@ public SchemaEditorMenuBar(final BasicGraphEditor editor) new ActionListener() { /** - * + * */ public void actionPerformed(ActionEvent e) { @@ -220,15 +220,15 @@ public void run() menu.addSeparator(); - menu.add(editor.bind(mxResources.get("page"), new ZoomPolicyAction( - mxGraphComponent.ZOOM_POLICY_PAGE))); - menu.add(editor.bind(mxResources.get("width"), new ZoomPolicyAction( - mxGraphComponent.ZOOM_POLICY_WIDTH))); +// menu.add(editor.bind(mxResources.get("page"), new ZoomPolicyAction( +// mxGraphComponent.ZOOM_POLICY_PAGE))); +// menu.add(editor.bind(mxResources.get("width"), new ZoomPolicyAction( +// mxGraphComponent.ZOOM_POLICY_WIDTH))); - menu.addSeparator(); - - menu.add(editor.bind(mxResources.get("actualSize"), mxGraphActions - .getZoomActualAction())); +// menu.addSeparator(); +// +// menu.add(editor.bind(mxResources.get("actualSize"), mxGraphActions +// .getZoomActualAction())); // Creates the diagram menu menu = add(new JMenu(mxResources.get("diagram"))); diff --git a/src/main/resources/resources/editor.properties b/src/main/resources/resources/editor.properties index beaefd2..c3f6912 100644 --- a/src/main/resources/resources/editor.properties +++ b/src/main/resources/resources/editor.properties @@ -203,4 +203,4 @@ noCellSelected=No cell selected. loseChanges=Lose Changes? noLayout=Layout unavailable error=Error -owlaxVersion=1.0.0 +owlaxVersion=1.2.0 diff --git a/update.properties b/update.properties index a6d0120..ffa8cf8 100644 --- a/update.properties +++ b/update.properties @@ -1,6 +1,6 @@ id=OWLAx -version=1.1.0 -download=https://github.com/md-k-sarker/OWLAx/releases/download/v1.1.0/OWLAx-1.1.0.jar?raw=true +version=1.2.0 +download=https://github.com/md-k-sarker/OWLAx/releases/download/v1.2.0/OWLAx-1.2.0.jar?raw=true name=OWLAx: OWL Axiomatizer readme=https://raw.githubusercontent.com/md-k-sarker/OWLAx/master/plugin/binary/version-info.html license=http://opensource.org/licenses/BSD-2-Clause