Revision: 18191
          http://sourceforge.net/p/gate/code/18191
Author:   markagreenwood
Date:     2014-07-17 07:50:05 +0000 (Thu, 17 Jul 2014)
Log Message:
-----------
a little more code cleanup

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

Modified: gate/trunk/src/main/gate/gui/DocumentExportMenu.java
===================================================================
--- gate/trunk/src/main/gate/gui/DocumentExportMenu.java        2014-07-17 
07:36:53 UTC (rev 18190)
+++ gate/trunk/src/main/gate/gui/DocumentExportMenu.java        2014-07-17 
07:50:05 UTC (rev 18191)
@@ -1,3 +1,16 @@
+/*
+ *  Copyright (c) 1995-2014, The University of Sheffield. See the file
+ *  COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
+ *
+ *  This file is part of GATE (see http://gate.ac.uk/), and is free
+ *  software, licenced under the GNU Library General Public License,
+ *  Version 2, June 1991 (in the distribution as file licence.html,
+ *  and also available at http://gate.ac.uk/gate/licence.html).
+ *
+ *  Mark A. Greenwood 11/07/2014
+ *
+ */
+
 package gate.gui;
 
 import gate.Corpus;
@@ -52,16 +65,15 @@
 import javax.swing.KeyStroke;
 import javax.swing.table.TableCellEditor;
 
+/**
+ * A menu which updates as plugins are (un)loaded to allow the export of
+ * documents and corpora to any of the supported output formats.
+ */
 @SuppressWarnings("serial")
 public class DocumentExportMenu extends XJMenu implements CreoleListener {
-  
+
   static DocumentExportDialog dialog = new DocumentExportDialog();
 
-  /**
-   * The first position in the menu that can be used by dynamic items.
-   */
-  protected int firstPluginItem = 0;
-
   protected IdentityHashMap<Resource, JMenuItem> itemByResource =
           new IdentityHashMap<Resource, JMenuItem>();
 
@@ -88,12 +100,13 @@
   }
 
   private void init() {
-    
-    DocumentExporter gateXMLExporter = 
(DocumentExporter)Gate.getCreoleRegister()
-            .get(GateXMLExporter.class.getCanonicalName())
-            .getInstantiations().iterator().next();
+
+    DocumentExporter gateXMLExporter =
+            (DocumentExporter)Gate.getCreoleRegister()
+                    .get(GateXMLExporter.class.getCanonicalName())
+                    .getInstantiations().iterator().next();
     addExporter(gateXMLExporter);
-    
+
     Set<String> toolTypes = Gate.getCreoleRegister().getToolTypes();
     for(String type : toolTypes) {
       List<Resource> instances =
@@ -127,13 +140,12 @@
             fileName =
                     document.getContent()
                             .getContent(
-                                    document.getAnnotations(
-                                            "Original markups").get("title")
-                                            .firstNode().getOffset(),
-                                    document.getAnnotations(
-                                            "Original markups").get("title")
-                                            .lastNode().getOffset())
-                            .toString();
+                                    document.getAnnotations("Original markups")
+                                            .get("title").firstNode()
+                                            .getOffset(),
+                                    document.getAnnotations("Original markups")
+                                            .get("title").lastNode()
+                                            .getOffset()).toString();
           } catch(InvalidOffsetException e) {
             e.printStackTrace();
           }
@@ -201,9 +213,9 @@
     }
 
     JMenuItem item =
-            DocumentExportMenu.this.add(new AbstractAction(de.getFileType() + 
" (."
-                    + de.getDefaultExtension() + ")", MainFrame.getIcon(rd
-                    .getIcon())) {
+            DocumentExportMenu.this.add(new AbstractAction(de.getFileType()
+                    + " (." + de.getDefaultExtension() + ")", MainFrame
+                    .getIcon(rd.getIcon())) {
 
               @Override
               public void actionPerformed(ActionEvent ae) {
@@ -213,8 +225,7 @@
 
                 final FeatureMap options = Factory.newFeatureMap();
 
-                final File selectedFile =
-                        getSelectedFile(params, de, options);
+                final File selectedFile = getSelectedFile(params, de, options);
 
                 if(selectedFile == null) return;
 
@@ -245,8 +256,8 @@
                           if(!dir.mkdirs()) {
                             JOptionPane.showMessageDialog(
                                     MainFrame.getInstance(),
-                                    "Could not create top directory!",
-                                    "GATE", JOptionPane.ERROR_MESSAGE);
+                                    "Could not create top directory!", "GATE",
+                                    JOptionPane.ERROR_MESSAGE);
                             return;
                           }
                         }
@@ -258,7 +269,7 @@
                         // them
                         Iterator<Document> docIter = corpus.iterator();
                         boolean overwriteAll = false;
-                        //int docCnt = corpus.size();
+                        // int docCnt = corpus.size();
                         int currentDocIndex = 0;
                         Set<String> usedFileNames = new HashSet<String>();
                         while(docIter.hasNext()) {
@@ -280,13 +291,11 @@
                           // any
                           // forbidden character
                           fileName =
-                                  fileName.replaceAll("[\\/:\\*\\?\"<>|]",
-                                          "_");
+                                  fileName.replaceAll("[\\/:\\*\\?\"<>|]", 
"_");
                           if(fileName.toLowerCase().endsWith(
                                   "." + de.getDefaultExtension())) {
                             fileName =
-                                    fileName.substring(0,
-                                            fileName.length() - 5);
+                                    fileName.substring(0, fileName.length() - 
5);
                           }
                           if(usedFileNames.contains(fileName)) {
                             // name clash -> add unique ID
@@ -314,8 +323,8 @@
                               MainFrame.unlockGUI();
                               int answer =
                                       JOptionPane.showOptionDialog(
-                                              MainFrame.getInstance(),
-                                              "File " + docFile.getName()
+                                              MainFrame.getInstance(), "File "
+                                                      + docFile.getName()
                                                       + " already exists!\n"
                                                       + "Overwrite?", "GATE",
                                               JOptionPane.DEFAULT_OPTION,
@@ -416,8 +425,8 @@
 
   /**
    * If the resource just loaded is a tool (according to the creole
-   * register) then see if it publishes any actions and if so, add
-   * them to the menu in the appropriate places.
+   * register) then see if it publishes any actions and if so, add them
+   * to the menu in the appropriate places.
    */
   @Override
   public void resourceLoaded(CreoleEvent e) {
@@ -460,10 +469,9 @@
   }
 
   @Override
-  public void resourceRenamed(Resource resource, String oldName,
-          String newName) {
+  public void resourceRenamed(Resource resource, String oldName, String 
newName) {
   }
-  
+
   private static class DocumentExportDialog extends JDialog {
 
     private DocumentExporter de;
@@ -589,7 +597,8 @@
       KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
       im.put(enter, "none");
 
-      // define keystrokes action bindings at the level of the main window
+      // define keystrokes action bindings at the level of the main
+      // window
       InputMap inputMap =
               ((JComponent)this.getContentPane())
                       .getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
@@ -647,4 +656,4 @@
       return txtFileName.getText();
     }
   }
-}
\ No newline at end of file
+}

Modified: gate/trunk/src/main/gate/gui/NameBearerHandle.java
===================================================================
--- gate/trunk/src/main/gate/gui/NameBearerHandle.java  2014-07-17 07:36:53 UTC 
(rev 18190)
+++ gate/trunk/src/main/gate/gui/NameBearerHandle.java  2014-07-17 07:50:05 UTC 
(rev 18191)
@@ -301,25 +301,6 @@
                 sListenerProxy));
         staticPopupItems.add(null);
         staticPopupItems.add(new DocumentExportMenu((Corpus)target, 
sListenerProxy));
-        // staticPopupItems.add(new XJMenuItem(new
-        // SaveCorpusAsXmlAction(true), sListenerProxy));
-        
-        //This has been moved into the IR plugin
-        /*if(target instanceof IndexedCorpus) {
-          IndexedCorpus ic = (IndexedCorpus)target;
-          if(ic.getDataStore() != null
-                  && ic.getDataStore() instanceof LuceneDataStoreImpl) {
-            // do nothing
-          }
-          else {
-            staticPopupItems.add(new XJMenuItem(new CreateIndexAction(),
-                    sListenerProxy));
-            staticPopupItems.add(new XJMenuItem(new OptimizeIndexAction(),
-                    sListenerProxy));
-            staticPopupItems.add(new XJMenuItem(new DeleteIndexAction(),
-                    sListenerProxy));
-          }
-        }*/
       }
       if(((LanguageResource)target).getDataStore() != null) {
         // this item can be used only if the resource belongs to a

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


------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs

Reply via email to