Author: mtoepfer Date: Tue Feb 4 17:11:01 2014 New Revision: 1564380 URL: http://svn.apache.org/r1564380 Log: UIMA-3469 Ruta: Annotation Browser View Extensions
Refactored code; now ActionBar contributions are only applicable when a cas editor document is open. Removed: uima/ruta/trunk/ruta-ep-caseditor/src/main/java/org/apache/uima/ruta/caseditor/view/tree/handler/ Modified: uima/ruta/trunk/ruta-ep-caseditor/plugin.xml uima/ruta/trunk/ruta-ep-caseditor/src/main/java/org/apache/uima/ruta/caseditor/view/tree/AnnotationTreeViewPage.java Modified: uima/ruta/trunk/ruta-ep-caseditor/plugin.xml URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-ep-caseditor/plugin.xml?rev=1564380&r1=1564379&r2=1564380&view=diff ============================================================================== --- uima/ruta/trunk/ruta-ep-caseditor/plugin.xml (original) +++ uima/ruta/trunk/ruta-ep-caseditor/plugin.xml Tue Feb 4 17:11:01 2014 @@ -71,46 +71,4 @@ under the License. class="org.apache.uima.ruta.caseditor.view.preferences.CasEditorViewPreferenceInitializer"> </initializer> </extension> - <extension - point="org.eclipse.ui.commands"> - <command - description="Checks all types visible in the Annotation Browser to be highlighted in the CAS editor" - id="org.apache.uima.ruta.caseditor.view.tree.commands.checkAllTypesHighlighted" - name="Highlight All (visible) Types"> - </command> - <command - description="Resets type highlighting. No type will be checked." - id="org.apache.uima.ruta.caseditor.view.tree.commands.clearTypeHighlighting" - name="Clear Type Highlighting"> - </command> - </extension> - <extension - point="org.eclipse.ui.handlers"> - <handler - class="org.apache.uima.ruta.caseditor.view.tree.handler.CheckAll" - commandId="org.apache.uima.ruta.caseditor.view.tree.commands.checkAllTypesHighlighted"> - </handler> - <handler - class="org.apache.uima.ruta.caseditor.view.tree.handler.UncheckAll" - commandId="org.apache.uima.ruta.caseditor.view.tree.commands.clearTypeHighlighting"> - </handler> - </extension> - <extension - point="org.eclipse.ui.menus"> - <menuContribution - allPopups="false" - locationURI="toolbar:org.apache.uima.caseditor.browser"> - <command - commandId="org.apache.uima.ruta.caseditor.view.tree.commands.checkAllTypesHighlighted" - icon="icons/lightbulb_add.png" - style="push"> - </command> - <command - commandId="org.apache.uima.ruta.caseditor.view.tree.commands.clearTypeHighlighting" - icon="icons/lightbulb_off.png" - style="push"> - </command> - </menuContribution> - </extension> - </plugin> Modified: uima/ruta/trunk/ruta-ep-caseditor/src/main/java/org/apache/uima/ruta/caseditor/view/tree/AnnotationTreeViewPage.java URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-ep-caseditor/src/main/java/org/apache/uima/ruta/caseditor/view/tree/AnnotationTreeViewPage.java?rev=1564380&r1=1564379&r2=1564380&view=diff ============================================================================== --- uima/ruta/trunk/ruta-ep-caseditor/src/main/java/org/apache/uima/ruta/caseditor/view/tree/AnnotationTreeViewPage.java (original) +++ uima/ruta/trunk/ruta-ep-caseditor/src/main/java/org/apache/uima/ruta/caseditor/view/tree/AnnotationTreeViewPage.java Tue Feb 4 17:11:01 2014 @@ -40,8 +40,13 @@ import org.apache.uima.caseditor.editor. import org.apache.uima.caseditor.editor.ICasDocument; import org.apache.uima.ruta.caseditor.RutaCasEditorPlugin; import org.apache.uima.ruta.caseditor.view.preferences.CasEditorViewsPreferenceConstants; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.action.IStatusLineManager; +import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.viewers.CheckStateChangedEvent; import org.eclipse.jface.viewers.CheckboxTreeViewer; import org.eclipse.jface.viewers.DoubleClickEvent; @@ -60,8 +65,6 @@ import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Image; @@ -71,7 +74,6 @@ import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; @@ -101,6 +103,21 @@ public class AnnotationTreeViewPage exte } + private class CheckAllVisibleAction extends Action { + @Override + public void run() { + uncheckAll(); + checkAllVisible(); + } + } + + private class UncheckAllAction extends Action { + @Override + public void run() { + uncheckAll(); + } + } + private CheckboxTreeViewer treeView; private AnnotationTreeLabelProvider lableProvider; @@ -158,16 +175,11 @@ public class AnnotationTreeViewPage exte layout.marginHeight = 0; overlay.setLayout(layout); - KeyListener checkSelectedKeyListener = new KeyListener() { - - public void keyReleased(KeyEvent arg0) { - // TODO Auto-generated method stub - - } - + KeyListener checkSelectedKeyListener = new KeyAdapter() { + public void keyPressed(KeyEvent keyEvent) { int keyCode = keyEvent.keyCode; - if (keyCode == SWT.CR) { + if (keyCode == SWT.CR || keyCode == SWT.LF || keyCode == SWT.KEYPAD_CR) { uncheckAll(); checkAllVisible(); } @@ -272,6 +284,24 @@ public class AnnotationTreeViewPage exte } + @Override + public void makeContributions(IMenuManager menuManager, IToolBarManager toolBarManager, + IStatusLineManager statusLineManager) { + // + Action createActionCheckVisible = new CheckAllVisibleAction(); + createActionCheckVisible.setText("Set all types visible in the Annotation Browser to be highlighted in the CAS editor."); + ImageDescriptor imageDescriptor = RutaCasEditorPlugin + .getImageDescriptor("/icons/lightbulb_add.png"); + createActionCheckVisible.setImageDescriptor(imageDescriptor); + toolBarManager.add(createActionCheckVisible); + // + Action createActionUncheckAll = new UncheckAllAction(); + createActionUncheckAll.setText("Reset type highlighting. No type will be checked."); + createActionUncheckAll.setImageDescriptor(RutaCasEditorPlugin + .getImageDescriptor("/icons/lightbulb_off.png")); + toolBarManager.add(createActionUncheckAll); + } + /** * Unchecks all types of the typesystem so that they are not highlighted anymore. */