You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by jo...@apache.org on 2011/04/20 09:34:31 UTC

svn commit: r1095309 - in /uima/uimaj/trunk/uimaj-ep-cas-editor: ./ src/main/java/org/apache/uima/caseditor/editor/ src/main/java/org/apache/uima/caseditor/editor/action/ src/main/java/org/apache/uima/caseditor/editor/outline/

Author: joern
Date: Wed Apr 20 07:34:30 2011
New Revision: 1095309

URL: http://svn.apache.org/viewvc?rev=1095309&view=rev
Log:
UIMA-2125 Defined commands and key bindings. Linked actions in the Annotation Editor and Annotation Outline view to the defined commands.

Modified:
    uima/uimaj/trunk/uimaj-ep-cas-editor/plugin.xml
    uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditor.java
    uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/LowerLeftAnnotationSideAction.java
    uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/LowerRightAnnotationSideAction.java
    uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/WideLeftAnnotationSideAction.java
    uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/WideRightAnnotationSideAction.java
    uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationOutline.java

Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/plugin.xml
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/plugin.xml?rev=1095309&r1=1095308&r2=1095309&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-ep-cas-editor/plugin.xml (original)
+++ uima/uimaj/trunk/uimaj-ep-cas-editor/plugin.xml Wed Apr 20 07:34:30 2011
@@ -311,4 +311,79 @@
           class="org.apache.uima.caseditor.editor.DefaultCasDocumentProvider">
     </provider>
  </extension>
+ 
+ 
+ <extension
+	point="org.eclipse.ui.commands">
+      <category
+            name="Annotate"
+            description="Annotate"
+            id="org.apache.uima.caseditor.annotate">
+      </category>
+      
+      <command
+            categoryId="org.apache.uima.caseditor.annotate"
+            id="Enter"
+            description="Quick Annotate"
+            name="Quick Annotate">
+      </command>
+      <command
+            categoryId="org.apache.uima.caseditor.annotate"
+            id="WideRightAnnotationSide"
+            description="WideRightAnnotationSide"
+            name="WideRightAnnotationSide">
+      </command>
+      <command
+            categoryId="org.apache.uima.caseditor.annotate"
+            id="LowerRightAnnotationSide"
+            description="LowerRightAnnotationSide"
+            name="LowerRightAnnotationSide">
+      </command>
+      <command
+            categoryId="org.apache.uima.caseditor.annotate"
+            id="WideLeftAnnotationSide"
+            description="WideLeftAnnotationSide"
+            name="WideLeftAnnotationSide">
+      </command>
+      <command
+            categoryId="org.apache.uima.caseditor.annotate"
+            id="LowerLeftAnnotationSide"
+            description="LowerLeftAnnotationSide"
+            name="LowerLeftAnnotationSide">
+      </command>
+</extension>
+
+	<extension
+	         point="org.eclipse.ui.bindings">
+	<key
+	            commandId="Enter"
+	            contextId="org.eclipse.ui.contexts.window"
+	            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+	            sequence="CR">
+	</key>
+	<key
+	            commandId="WideLeftAnnotationSide"
+	            contextId="org.eclipse.ui.contexts.window"
+	            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+	            sequence="M1+K">
+	</key>
+	<key
+	            commandId="LowerLeftAnnotationSide"
+	            contextId="org.eclipse.ui.contexts.window"
+	            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+	            sequence="M1+L">
+	</key>
+	<key
+	            commandId="WideRightAnnotationSide"
+	            contextId="org.eclipse.ui.contexts.window"
+	            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+	            sequence="M3+L">
+	</key>
+	<key
+	            commandId="LowerRightAnnotationSide"
+	            contextId="org.eclipse.ui.contexts.window"
+	            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+	            sequence="M3+K">
+	</key>
+	</extension> 
 </plugin>

Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditor.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditor.java?rev=1095309&r1=1095308&r2=1095309&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditor.java (original)
+++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditor.java Wed Apr 20 07:34:30 2011
@@ -1390,11 +1390,8 @@ public final class AnnotationEditor exte
 
     annotateAction.setActionDefinitionId(annotateActionID);
     annotateAction.setText("Quick Annotate");
-    annotateAction.setAccelerator(SWT.CR);
-    getSite().getSelectionProvider().addSelectionChangedListener(annotateAction);
-    
     setAction(annotateActionID, annotateAction);
-    setActionActivationCode(annotateActionID, '\r', -1, SWT.DEFAULT);
+    getSite().getSelectionProvider().addSelectionChangedListener(annotateAction);
 
     SmartAnnotateAction smartAnnotateAction = new SmartAnnotateAction();
     smartAnnotateAction.setActionDefinitionId(ITextEditorActionDefinitionIds.SMART_ENTER);
@@ -1431,30 +1428,26 @@ public final class AnnotationEditor exte
     
     // Lower left side of annotation action
     LowerLeftAnnotationSideAction lowerLeftAnnotationSideAction = new LowerLeftAnnotationSideAction(getDocument());
-    lowerLeftAnnotationSideAction.setActionDefinitionId("LowerLeftAnnotationSide");
-    setActionActivationCode("LowerLeftAnnotationSide", 'm', -1, SWT.CTRL);
-    setAction("LowerLeftAnnotationSide", lowerLeftAnnotationSideAction);
+    lowerLeftAnnotationSideAction.setActionDefinitionId(LowerLeftAnnotationSideAction.ID);
+    setAction(LowerLeftAnnotationSideAction.ID, lowerLeftAnnotationSideAction);
     getSite().getSelectionProvider().addSelectionChangedListener(lowerLeftAnnotationSideAction);
     
     // Wide left side of annotation action
     WideLeftAnnotationSideAction wideLeftAnnotationSide = new WideLeftAnnotationSideAction(getDocument());
-    wideLeftAnnotationSide.setActionDefinitionId("WideLeftAnnotationSide");
-    setActionActivationCode("WideLeftAnnotationSide", 'n', -1, SWT.CTRL);
-    setAction("WideLeftAnnotationSide", wideLeftAnnotationSide);
+    wideLeftAnnotationSide.setActionDefinitionId(WideLeftAnnotationSideAction.ID);
+    setAction(WideLeftAnnotationSideAction.ID, wideLeftAnnotationSide);
     getSite().getSelectionProvider().addSelectionChangedListener(wideLeftAnnotationSide);
     
     // Lower right side of annotation
     LowerRightAnnotationSideAction lowerRightAnnotationSideAction = new LowerRightAnnotationSideAction(getDocument());
-    lowerRightAnnotationSideAction.setActionDefinitionId("LowerRightAnnotationSide");
-    setActionActivationCode("LowerRightAnnotationSide", ',', -1, SWT.CTRL);
-    setAction("LowerRightAnnotationSide", lowerRightAnnotationSideAction);
+    lowerRightAnnotationSideAction.setActionDefinitionId(LowerRightAnnotationSideAction.ID);
+    setAction(LowerRightAnnotationSideAction.ID, lowerRightAnnotationSideAction);
     getSite().getSelectionProvider().addSelectionChangedListener(lowerRightAnnotationSideAction);
     
     // Wide right side of annotation
     WideRightAnnotationSideAction wideRightAnnotationSideAction = new WideRightAnnotationSideAction(getDocument());
-    wideRightAnnotationSideAction.setActionDefinitionId("WideRightAnnotationSide");
-    setActionActivationCode("WideRightAnnotationSide", '.', -1, SWT.CTRL);
-    setAction("WideRightAnnotationSide", wideRightAnnotationSideAction);
+    wideRightAnnotationSideAction.setActionDefinitionId(WideRightAnnotationSideAction.ID);
+    setAction(WideRightAnnotationSideAction.ID, wideRightAnnotationSideAction);
     getSite().getSelectionProvider().addSelectionChangedListener(wideRightAnnotationSideAction);
   }
 

Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/LowerLeftAnnotationSideAction.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/LowerLeftAnnotationSideAction.java?rev=1095309&r1=1095308&r2=1095309&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/LowerLeftAnnotationSideAction.java (original)
+++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/LowerLeftAnnotationSideAction.java Wed Apr 20 07:34:30 2011
@@ -32,6 +32,9 @@ import org.eclipse.ui.actions.BaseSelect
  * Lowers the left side of the currently selected annotation by one.
  */
 public final class LowerLeftAnnotationSideAction extends BaseSelectionListenerAction {
+  
+  public static final String ID = "LowerLeftAnnotationSide";
+  
   private ICasDocument mDocument;
 
   /**

Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/LowerRightAnnotationSideAction.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/LowerRightAnnotationSideAction.java?rev=1095309&r1=1095308&r2=1095309&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/LowerRightAnnotationSideAction.java (original)
+++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/LowerRightAnnotationSideAction.java Wed Apr 20 07:34:30 2011
@@ -32,6 +32,9 @@ import org.eclipse.ui.actions.BaseSelect
  * Lowers the right side of the currently selected annotation by one.
  */
 public final class LowerRightAnnotationSideAction extends BaseSelectionListenerAction {
+  
+  public static final String ID = "LowerRightAnnotationSide";
+  
   private ICasDocument mDocument;
 
   /**

Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/WideLeftAnnotationSideAction.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/WideLeftAnnotationSideAction.java?rev=1095309&r1=1095308&r2=1095309&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/WideLeftAnnotationSideAction.java (original)
+++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/WideLeftAnnotationSideAction.java Wed Apr 20 07:34:30 2011
@@ -32,6 +32,9 @@ import org.eclipse.ui.actions.BaseSelect
  * Widens the left side of the currently selected annotation by one.
  */
 public final class WideLeftAnnotationSideAction extends BaseSelectionListenerAction {
+  
+  public static final String ID = "WideLeftAnnotationSide";
+  
   private ICasDocument mDocument;
 
   /**

Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/WideRightAnnotationSideAction.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/WideRightAnnotationSideAction.java?rev=1095309&r1=1095308&r2=1095309&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/WideRightAnnotationSideAction.java (original)
+++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/WideRightAnnotationSideAction.java Wed Apr 20 07:34:30 2011
@@ -32,6 +32,9 @@ import org.eclipse.ui.actions.BaseSelect
  * Widens the right side of the currently selected annotation by one.
  */
 public final class WideRightAnnotationSideAction extends BaseSelectionListenerAction {
+  
+  public static final String ID = "WideRightAnnotationSide";
+  
   private ICasDocument mDocument;
 
   /**

Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationOutline.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationOutline.java?rev=1095309&r1=1095308&r2=1095309&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationOutline.java (original)
+++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationOutline.java Wed Apr 20 07:34:30 2011
@@ -62,6 +62,7 @@ import org.eclipse.ui.IActionBars;
 import org.eclipse.ui.ISelectionListener;
 import org.eclipse.ui.IWorkbenchPart;
 import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.part.IPageSite;
 import org.eclipse.ui.views.contentoutline.ContentOutline;
 import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
 
@@ -179,58 +180,85 @@ public final class AnnotationOutline ext
   }
 
   /**
-   * Adds the actions to the tool bar.
+   * Retrieves the control.
    *
-   * @param menuManager
-   * @param toolBarManager
-   * @param statusLineManager
+   * @return the control
    */
   @Override
-  public void makeContributions(IMenuManager menuManager, IToolBarManager toolBarManager,
-          IStatusLineManager statusLineManager) {
+  public Control getControl() {
+    return mOutlineComposite;
+  }
+
+  /**
+   * Adds the these actions to the global action handler: {@link DeleteFeatureStructureAction}
+   * SelectAllAction
+   *
+   * @param actionBars
+   */
+  @Override
+  public void setActionBars(IActionBars actionBars) {
+    DeleteFeatureStructureAction deleteAction = new DeleteFeatureStructureAction(editor
+            .getDocument());
+
+    actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), deleteAction);
+
+    getSite().getSelectionProvider().addSelectionChangedListener(deleteAction);
+
+    actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), new SelectAllAction());
+    
+    Action action = new SwitchStyleAction(this);
+    
+    IMenuManager dropDownMenu = actionBars.getMenuManager();
+    dropDownMenu.add(action);
+    
+    IToolBarManager toolBarManager = actionBars.getToolBarManager();
+    
     // wide left annotation side action
     WideLeftAnnotationSideAction wideLeftAnnotationSideAction = new WideLeftAnnotationSideAction(
             editor.getDocument());
+    wideLeftAnnotationSideAction.setActionDefinitionId(WideLeftAnnotationSideAction.ID);
     wideLeftAnnotationSideAction.setText("Wides the left annotation side");
     wideLeftAnnotationSideAction.setImageDescriptor(CasEditorPlugin
             .getTaeImageDescriptor(Images.WIDE_LEFT_SIDE));
 
     getSite().getSelectionProvider().addSelectionChangedListener(wideLeftAnnotationSideAction);
-
+    actionBars.setGlobalActionHandler(WideLeftAnnotationSideAction.ID, wideLeftAnnotationSideAction);
     toolBarManager.add(wideLeftAnnotationSideAction);
 
     // lower left annotation side action
     LowerLeftAnnotationSideAction lowerLeftAnnotationSideAction = new LowerLeftAnnotationSideAction(
             editor.getDocument());
+    lowerLeftAnnotationSideAction.setActionDefinitionId(LowerLeftAnnotationSideAction.ID);
     lowerLeftAnnotationSideAction.setText("Lowers the left annotation side");
     lowerLeftAnnotationSideAction.setImageDescriptor(CasEditorPlugin
             .getTaeImageDescriptor(Images.LOWER_LEFT_SIDE));
 
     getSite().getSelectionProvider().addSelectionChangedListener(lowerLeftAnnotationSideAction);
-
+    actionBars.setGlobalActionHandler(LowerLeftAnnotationSideAction.ID, lowerLeftAnnotationSideAction);
     toolBarManager.add(lowerLeftAnnotationSideAction);
 
     // lower right annotation side action
-    LowerRightAnnotationSideAction lowerRightAnnotionSideAction =
+    LowerRightAnnotationSideAction lowerRightAnnotationSideAction =
       new LowerRightAnnotationSideAction(editor.getDocument());
-    lowerRightAnnotionSideAction.setText("Lowers the right annotation side");
-    lowerRightAnnotionSideAction.setImageDescriptor(CasEditorPlugin
+    lowerRightAnnotationSideAction.setActionDefinitionId(LowerRightAnnotationSideAction.ID);
+    lowerRightAnnotationSideAction.setText("Lowers the right annotation side");
+    lowerRightAnnotationSideAction.setImageDescriptor(CasEditorPlugin
             .getTaeImageDescriptor(Images.LOWER_RIGHT_SIDE));
 
-    getSite().getSelectionProvider().addSelectionChangedListener(lowerRightAnnotionSideAction);
-
-    toolBarManager.add(lowerRightAnnotionSideAction);
+    getSite().getSelectionProvider().addSelectionChangedListener(lowerRightAnnotationSideAction);
+    actionBars.setGlobalActionHandler(LowerRightAnnotationSideAction.ID, lowerRightAnnotationSideAction);
+    toolBarManager.add(lowerRightAnnotationSideAction);
 
     // wide right annotation side action
     WideRightAnnotationSideAction wideRightAnnotationSideAction = new WideRightAnnotationSideAction(
             editor.getDocument());
+    wideRightAnnotationSideAction.setActionDefinitionId(WideRightAnnotationSideAction.ID);
     wideRightAnnotationSideAction.setText("Wides the right annotation side");
-
     wideRightAnnotationSideAction.setImageDescriptor(CasEditorPlugin
             .getTaeImageDescriptor(Images.WIDE_RIGHT_SIDE));
 
     getSite().getSelectionProvider().addSelectionChangedListener(wideRightAnnotationSideAction);
-
+    actionBars.setGlobalActionHandler(WideRightAnnotationSideAction.ID, wideRightAnnotationSideAction);
     toolBarManager.add(wideRightAnnotationSideAction);
 
     // merge action
@@ -242,39 +270,6 @@ public final class AnnotationOutline ext
 
     // delete action
     toolBarManager.add(ActionFactory.DELETE.create(getSite().getWorkbenchWindow()));
-  }
-
-  /**
-   * Retrieves the control.
-   *
-   * @return the control
-   */
-  @Override
-  public Control getControl() {
-    return mOutlineComposite;
-  }
-
-  /**
-   * Adds the these actions to the global action handler: {@link DeleteFeatureStructureAction}
-   * SelectAllAction
-   *
-   * @param actionBars
-   */
-  @Override
-  public void setActionBars(IActionBars actionBars) {
-    DeleteFeatureStructureAction deleteAction = new DeleteFeatureStructureAction(editor
-            .getDocument());
-
-    actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), deleteAction);
-
-    getSite().getSelectionProvider().addSelectionChangedListener(deleteAction);
-
-    actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), new SelectAllAction());
-    
-    Action action = new SwitchStyleAction(this);
-    
-    IMenuManager dropDownMenu = actionBars.getMenuManager();
-    dropDownMenu.add(action);
     
     super.setActionBars(actionBars);
   }