Revision: 14452
          http://gate.svn.sourceforge.net/gate/?rev=14452&view=rev
Author:   markagreenwood
Date:     2011-10-28 15:36:26 +0000 (Fri, 28 Oct 2011)
Log Message:
-----------
added a new right-click option that allows you to convert a normal corpus 
pipeline into a conditional corpus pipeline -- really helpful when testing 
other peoples pipelines as you can selectively disable PRs without removing 
them from the pipeline

Modified Paths:
--------------
    gate/trunk/src/gate/gui/NameBearerHandle.java

Modified: gate/trunk/src/gate/gui/NameBearerHandle.java
===================================================================
--- gate/trunk/src/gate/gui/NameBearerHandle.java       2011-10-28 10:48:56 UTC 
(rev 14451)
+++ gate/trunk/src/gate/gui/NameBearerHandle.java       2011-10-28 15:36:26 UTC 
(rev 14452)
@@ -26,6 +26,7 @@
 import gate.FeatureMap;
 import gate.Gate;
 import gate.GateConstants;
+import gate.LanguageAnalyser;
 import gate.LanguageResource;
 import gate.ProcessingResource;
 import gate.Resource;
@@ -34,8 +35,10 @@
 import gate.creole.AbstractResource;
 import gate.creole.AnnotationSchema;
 import gate.creole.ConditionalController;
+import gate.creole.ConditionalSerialAnalyserController;
 import gate.creole.ResourceData;
 import gate.creole.ResourceInstantiationException;
+import gate.creole.SerialAnalyserController;
 import gate.creole.ir.DefaultIndexDefinition;
 import gate.creole.ir.DocumentContentReader;
 import gate.creole.ir.FeatureReader;
@@ -47,7 +50,6 @@
 import gate.event.CreoleListener;
 import gate.event.ProgressListener;
 import gate.event.StatusListener;
-import gate.gui.teamware.InputOutputAnnotationSetsDialog;
 import gate.persist.LuceneDataStoreImpl;
 import gate.persist.PersistenceException;
 import gate.security.Group;
@@ -420,6 +422,11 @@
     if(target instanceof Controller) {
       // Applications
       staticPopupItems.add(null);
+      
+      if (target instanceof SerialAnalyserController) {
+        staticPopupItems.add(new XJMenuItem(new MakeConditionalAction(), 
sListenerProxy));
+      }
+            
       staticPopupItems.add(new XJMenuItem(new DumpToFileAction(),
               sListenerProxy));
       staticPopupItems.add(new XJMenuItem(new ExportApplicationAction(),
@@ -1012,7 +1019,37 @@
       }
     }
   }
+  
+  class MakeConditionalAction extends AbstractAction {
+    private static final long serialVersionUID = 1L;
 
+    public MakeConditionalAction() {
+      super("Make Pipeline Conditional");
+      putValue(SHORT_DESCRIPTION, "Convert to a Conditional Corpus Pipeline");
+    }
+
+    public void actionPerformed(ActionEvent e) {
+      SerialAnalyserController existingController =
+          (SerialAnalyserController)target;
+      try {
+        ConditionalSerialAnalyserController newController =
+            (ConditionalSerialAnalyserController)Factory
+                
.createResource("gate.creole.ConditionalSerialAnalyserController");
+        newController.setName(existingController.getName());
+        Iterator<?> it = existingController.getPRs().iterator();
+        while(it.hasNext()) {
+          newController.add((ProcessingResource)it.next());
+        }
+        existingController.setPRs(Collections.emptyList());
+        Factory.deleteResource(existingController);
+      } catch(Exception ex) {
+        JOptionPane.showMessageDialog(getLargeView(),
+            "Error!\n" + ex.toString(), "GATE", JOptionPane.ERROR_MESSAGE);
+        ex.printStackTrace(Err.getPrintWriter());
+      }
+    }
+  }
+
   class SaveAction extends AbstractAction {
     private static final long serialVersionUID = 1L;
 

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
The demand for IT networking professionals continues to grow, and the
demand for specialized networking skills is growing even more rapidly.
Take a complimentary Learning@Cisco Self-Assessment and learn 
about Cisco certifications, training, and career opportunities. 
http://p.sf.net/sfu/cisco-dev2dev
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs

Reply via email to