Revision: 14613
          http://gate.svn.sourceforge.net/gate/?rev=14613&view=rev
Author:   nirajaswani
Date:     2011-11-26 23:38:08 +0000 (Sat, 26 Nov 2011)
Log Message:
-----------
couple of fixes: now all documents closes properly, save as a single xml works 
nicely

Modified Paths:
--------------
    gate/trunk/plugins/Alignment/src/gate/alignment/gui/AlignmentEditor.java
    
gate/trunk/plugins/Alignment/src/gate/compound/gui/CompoundDocumentEditor.java
    
gate/trunk/plugins/Alignment/src/gate/compound/impl/AbstractCompoundDocument.java

Modified: 
gate/trunk/plugins/Alignment/src/gate/alignment/gui/AlignmentEditor.java
===================================================================
--- gate/trunk/plugins/Alignment/src/gate/alignment/gui/AlignmentEditor.java    
2011-11-26 02:17:45 UTC (rev 14612)
+++ gate/trunk/plugins/Alignment/src/gate/alignment/gui/AlignmentEditor.java    
2011-11-26 23:38:08 UTC (rev 14613)
@@ -29,7 +29,6 @@
 import java.awt.event.ActionListener;
 import java.awt.event.FocusEvent;
 import java.awt.event.FocusListener;
-import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
 import java.awt.event.MouseListener;
 import java.awt.event.MouseMotionListener;
@@ -72,8 +71,7 @@
 import javax.swing.text.DefaultHighlighter.DefaultHighlightPainter;
 
 /**
- * This class provides an editor for aligning texts in a compound
- * document.
+ * This class provides an editor for aligning texts in a compound document.
  */
 public class AlignmentEditor extends JFrame implements FeatureMapListener,
                                            DocumentListener {
@@ -84,8 +82,8 @@
   AlignmentEditor editor = null;
 
   /**
-   * Menus for creating new alignment tasks, setting up active learning
-   * setup, specifying user preferences etc.
+   * Menus for creating new alignment tasks, setting up active learning setup,
+   * specifying user preferences etc.
    */
   JMenuBar menubar;
 
@@ -180,28 +178,29 @@
   private static final int MOUSE_MOVEMENT_TIMER_DELAY = 300;
 
   /**
-   * Action that should be taken when the mouse has stopped moving and
-   * is on one of the highlights
+   * Action that should be taken when the mouse has stopped moving and is on 
one
+   * of the highlights
    */
   protected MouseStoppedMovingAction mouseStoppedMovingAction;
 
   /**
    * Highlight used for highlighting aligned annotations.
    */
-  final DefaultHighlighter.DefaultHighlightPainter HIGHLIGHT = new 
DefaultHighlighter.DefaultHighlightPainter(
+  final DefaultHighlighter.DefaultHighlightPainter HIGHLIGHT =
+      new DefaultHighlighter.DefaultHighlightPainter(
           getColor(Color.GREEN, 0.1f));
 
   /**
    * Highlight used for highlighting selected aligned annotations.
    */
-  final DefaultHighlighter.DefaultHighlightPainter SELECTED_HIGHLIGHT = new 
DefaultHighlighter.DefaultHighlightPainter(
-          getColor(Color.RED, 0.5f));
+  final DefaultHighlighter.DefaultHighlightPainter SELECTED_HIGHLIGHT =
+      new DefaultHighlighter.DefaultHighlightPainter(getColor(Color.RED, 
0.5f));
 
   /**
    * Highlight used for highlighting selected aligned annotations.
    */
-  final DefaultHighlighter.DefaultHighlightPainter PROCESSING_HIGHLIGHT = new 
DefaultHighlighter.DefaultHighlightPainter(
-          getColor(Color.BLUE, 0.5f));
+  final DefaultHighlighter.DefaultHighlightPainter PROCESSING_HIGHLIGHT =
+      new DefaultHighlighter.DefaultHighlightPainter(getColor(Color.BLUE, 
0.5f));
 
   /**
    * Color generator used for generatig color
@@ -221,7 +220,8 @@
   /**
    * Stores alignment tasks objects
    */
-  private Map<String, AlignmentTask> alignmentTasks = new HashMap<String, 
AlignmentTask>();
+  private Map<String, AlignmentTask> alignmentTasks =
+      new HashMap<String, AlignmentTask>();
 
   /**
    * The current alignment task that is being shown on the screen
@@ -229,10 +229,11 @@
   private AlignmentTask currentAT = null;
 
   /**
-   * every alignment task has a view associated with it. This map is
-   * used for storing the reference
+   * every alignment task has a view associated with it. This map is used for
+   * storing the reference
    */
-  private HashMap<AlignmentTask, AlignmentTaskView> alignmentTaskViews = new 
HashMap<AlignmentTask, AlignmentTaskView>();
+  private HashMap<AlignmentTask, AlignmentTaskView> alignmentTaskViews =
+      new HashMap<AlignmentTask, AlignmentTaskView>();
 
   /**
    * Alignment task panel
@@ -287,7 +288,6 @@
     srcDoc.addDocumentListener(this);
     tgtDoc.addDocumentListener(this);
 
-    Document doc = this.document.getCurrentDocument();
     this.document.getFeatures().addFeatureMapListener(this);
   }
 
@@ -304,18 +304,16 @@
   public void cleanup() {
 
     // delete document listeners and feature update listener
-    if(this.srcDoc != null)
-      this.srcDoc.removeDocumentListener(this);
-    
-    if(this.tgtDoc != null)
-      this.tgtDoc.removeDocumentListener(this);
-    
+    if(this.srcDoc != null) this.srcDoc.removeDocumentListener(this);
+
+    if(this.tgtDoc != null) this.tgtDoc.removeDocumentListener(this);
+
     this.document.getFeatures().removeFeatureMapListener(this);
   }
 
   /**
-   * Introduces transparency to the given color. If c is null, a new
-   * random color is generated using the color generater class.
+   * Introduces transparency to the given color. If c is null, a new random
+   * color is generated using the color generater class.
    * 
    * @param c
    * @return
@@ -326,8 +324,8 @@
       components = colorGenerator.getNextColor().getComponents(null);
     else components = c.getComponents(null);
 
-    Color colour = new Color(components[0], components[1], components[2],
-            alphaValue);
+    Color colour =
+        new Color(components[0], components[1], components[2], alphaValue);
     int rgb = colour.getRGB();
     int alpha = colour.getAlpha();
     int rgba = rgb | (alpha << 24);
@@ -398,8 +396,8 @@
     /**
      * Obtain all the alignment feature names
      */
-    List<String> alignmentFeatureNames = new ArrayList<String>(document
-            .getAllAlignmentFeatureNames());
+    List<String> alignmentFeatureNames =
+        new ArrayList<String>(document.getAllAlignmentFeatureNames());
     this.alignmentFeatures = new JComboBox(alignmentFeatureNames.toArray());
 
     controls.add(new JLabel("Alignment Features:"));
@@ -417,7 +415,8 @@
     controls.add(refreshHighlights);
 
     mouseStoppedMovingAction = new MouseStoppedMovingAction();
-    mouseMovementTimer = new javax.swing.Timer(MOUSE_MOVEMENT_TIMER_DELAY,
+    mouseMovementTimer =
+        new javax.swing.Timer(MOUSE_MOVEMENT_TIMER_DELAY,
             mouseStoppedMovingAction);
     mouseMovementTimer.setRepeats(false);
     alignmentTaskPanel = new JPanel();
@@ -448,7 +447,8 @@
       // add new highlights
       if(pair.sourceAnnotations != null) {
         for(Annotation a : pair.sourceAnnotations) {
-          Object o = sourceEditor.getHighlighter().addHighlight(
+          Object o =
+              sourceEditor.getHighlighter().addHighlight(
                   a.getStartNode().getOffset().intValue(),
                   a.getEndNode().getOffset().intValue(), PROCESSING_HIGHLIGHT);
           srcSelectedHighlights.add(o);
@@ -458,14 +458,14 @@
       // add new highlights
       if(pair.targetAnnotations != null) {
         for(Annotation a : pair.targetAnnotations) {
-          Object o = targetEditor.getHighlighter().addHighlight(
+          Object o =
+              targetEditor.getHighlighter().addHighlight(
                   a.getStartNode().getOffset().intValue(),
                   a.getEndNode().getOffset().intValue(), PROCESSING_HIGHLIGHT);
           tgtSelectedHighlights.add(o);
         }
       }
-    }
-    catch(BadLocationException e) {
+    } catch(BadLocationException e) {
       throw new GateRuntimeException(e);
     }
   }
@@ -474,7 +474,6 @@
    * Action to show the next pair
    * 
    * @author niraj
-   * 
    */
   class NextPairAction extends AbstractAction {
 
@@ -501,16 +500,14 @@
 
         // ask this only if the pair hasn't been marked as finished
         if(!task.current().isAlignmentFinished()) {
-          int answer = JOptionPane.showConfirmDialog(editor,
+          int answer =
+              JOptionPane.showConfirmDialog(editor,
                   "Is alignment complete for this pair?");
           if(answer == JOptionPane.YES_OPTION) {
             task.getAlignmentActionsManager().executeFinishedAlignmentActions(
-                    task.current());
+                task.current());
             task.current().setAlignmentFinished(true);
-          }
-          else if(answer == JOptionPane.CANCEL_OPTION) {
-            return;
-          }
+          } else if(answer == JOptionPane.CANCEL_OPTION) { return; }
         }
       }
 
@@ -519,8 +516,7 @@
         task.getAlignmentActionsManager().executePreDisplayActions(pair);
         highlightParentAnnotations(pair);
         view.updateView(pair);
-      }
-      else {
+      } else {
         JOptionPane.showMessageDialog(editor, "Reached End of the Document");
       }
     }
@@ -530,7 +526,6 @@
    * Shows the previous pair
    * 
    * @author niraj
-   * 
    */
   class PreviousPairAction extends AbstractAction {
 
@@ -548,24 +543,21 @@
 
       // ask this only if the pair hasn't been marked as finished
       if(!task.current().isAlignmentFinished()) {
-        int answer = JOptionPane.showConfirmDialog(editor,
+        int answer =
+            JOptionPane.showConfirmDialog(editor,
                 "Is alignment complete for this pair?");
         if(answer == JOptionPane.YES_OPTION) {
           task.getAlignmentActionsManager().executeFinishedAlignmentActions(
-                  task.current());
+              task.current());
           task.current().setAlignmentFinished(true);
-        }
-        else if(answer == JOptionPane.CANCEL_OPTION) {
-          return;
-        }
+        } else if(answer == JOptionPane.CANCEL_OPTION) { return; }
       }
 
       if(task.hasPrevious()) {
         PUAPair pair = task.previous();
         highlightParentAnnotations(pair);
         view.updateView(pair);
-      }
-      else {
+      } else {
         JOptionPane.showMessageDialog(editor, "Reached Start of the Document");
       }
     }
@@ -575,7 +567,6 @@
    * Create a new alignment task
    * 
    * @author niraj
-   * 
    */
   class NewAlignmentTaskAction extends AbstractAction {
 
@@ -588,7 +579,7 @@
       if(alignmentTask == null) return;
       alignmentTasks.put(alignmentTask.getName(), alignmentTask);
       alignmentTasksMenu.add(new SwitchAlignmentTaskAction(alignmentTask
-              .getName()));
+          .getName()));
       currentAT = alignmentTask;
 
       // updateGUI
@@ -657,8 +648,8 @@
 
         for(int i = 0; i < alignmentTasksMenu.getItemCount(); i++) {
           JMenuItem mi = alignmentTasksMenu.getItem(i);
-          SwitchAlignmentTaskAction sata = (SwitchAlignmentTaskAction)mi
-                  .getAction();
+          SwitchAlignmentTaskAction sata =
+              (SwitchAlignmentTaskAction)mi.getAction();
           if(sata.taskName.equals(currentAT.getName())) {
             alignmentTasksMenu.remove(mi);
             alignmentTasksMenu.updateUI();
@@ -694,7 +685,7 @@
         currentAT = AlignmentTask.fromXML(document, 
selected.getAbsolutePath());
         alignmentTasks.put(currentAT.getName(), currentAT);
         alignmentTasksMenu.add(new SwitchAlignmentTaskAction(currentAT
-                .getName()));
+            .getName()));
 
         // updateGUI
         alignmentTaskPanel.removeAll();
@@ -748,8 +739,8 @@
       public void focusGained(FocusEvent e) {
         if(reload) {
           JOptionPane
-                  .showMessageDialog(editor,
-                          "Alignment information has changed - the document 
will be refreshed!");
+              .showMessageDialog(editor,
+                  "Alignment information has changed - the document will be 
refreshed!");
           reload = false;
 
           // execute the refreshHighlight action
@@ -786,15 +777,18 @@
     if(selectedIndex == -1) return;
 
     boolean isDefault = srcAnnotationSets.getSelectedIndex() == 0;
-    srcAS = isDefault ? srcDoc.getAnnotations() : srcDoc
+    srcAS =
+        isDefault ? srcDoc.getAnnotations() : srcDoc
             .getAnnotations((String)srcAnnotationSets.getSelectedItem());
 
     isDefault = tgtAnnotationSets.getSelectedIndex() == 0;
-    tgtAS = isDefault ? tgtDoc.getAnnotations() : tgtDoc
+    tgtAS =
+        isDefault ? tgtDoc.getAnnotations() : tgtDoc
             .getAnnotations((String)tgtAnnotationSets.getSelectedItem());
 
     // obtain the alignment object
-    alignment = document.getAlignmentInformation((String)alignmentFeatures
+    alignment =
+        document.getAlignmentInformation((String)alignmentFeatures
             .getSelectedItem());
 
     refreshHighlights();
@@ -813,8 +807,7 @@
   }
 
   /**
-   * Adds highlights to the document - indicating which annotations are
-   * aligned
+   * Adds highlights to the document - indicating which annotations are aligned
    * 
    * @param alignment
    * @param editorPane
@@ -836,13 +829,12 @@
    * @param painter
    */
   private Object addHighlight(Annotation a, JTextArea editorPane,
-          DefaultHighlightPainter painter) {
+      DefaultHighlightPainter painter) {
     try {
       return editorPane.getHighlighter().addHighlight(
-              a.getStartNode().getOffset().intValue(),
-              a.getEndNode().getOffset().intValue(), painter);
-    }
-    catch(BadLocationException e) {
+          a.getStartNode().getOffset().intValue(),
+          a.getEndNode().getOffset().intValue(), painter);
+    } catch(BadLocationException e) {
       throw new GateRuntimeException(e);
     }
   }
@@ -892,22 +884,20 @@
         Rectangle viewLocation = textPane.modelToView(textLocation);
         // expand the rectangle a bit
         int error = 10;
-        viewLocation = new Rectangle(viewLocation.x - error, viewLocation.y
-                - error, viewLocation.width + 2 * error, viewLocation.height
-                + 2 * error);
+        viewLocation =
+            new Rectangle(viewLocation.x - error, viewLocation.y - error,
+                viewLocation.width + 2 * error, viewLocation.height + 2 * 
error);
         if(viewLocation.contains(e.getPoint())) {
           mouseStoppedMovingAction.setTextLocation(textLocation);
           mouseStoppedMovingAction.setEditorPane(textPane);
-        }
-        else {
+        } else {
           mouseStoppedMovingAction.setTextLocation(-1);
         }
       }
 
       catch(BadLocationException e1) {
         // don't do anything
-      }
-      finally {
+      } finally {
         mouseMovementTimer.restart();
       }
     }
@@ -918,22 +908,22 @@
 
     public void mouseClicked(MouseEvent e) {
       // do nothing
-      
+
     }
 
     public void mouseEntered(MouseEvent e) {
       // do nothing
-      
+
     }
 
     public void mousePressed(MouseEvent e) {
       // do nothing
-      
+
     }
 
     public void mouseReleased(MouseEvent e) {
       // do nothing
-      
+
     }
   }
 
@@ -946,13 +936,14 @@
   /**
    * types of views we support
    */
-  private final String[] VIEWS = new String[] {LINKS_VIEW, MATRIX_VIEW,
+  private final String[] VIEWS = new String[]{LINKS_VIEW, MATRIX_VIEW,
       PARALLEL_VIEW};
 
   private AlignmentTask createAlignmentTask() {
     JPanel mainPanel = new JPanel(new GridBagLayout());
     // two combo-boxes
-    JTextField taskName = new JTextField("AlignmentTask"
+    JTextField taskName =
+        new JTextField("AlignmentTask"
             + ("" + Math.random() * 5000).substring(0, 4), 25);
     JTextField unitOfAlignment = new JTextField("Token", 25);
     JTextField parentOfUnitOfAlignment = new JTextField("Sentence", 25);
@@ -1109,9 +1100,8 @@
         if(result == JFileChooser.APPROVE_OPTION) {
           try {
             actionsFile.setText(fileChooser.getSelectedFile().toURI().toURL()
-                    .toExternalForm());
-          }
-          catch(Exception e) {
+                .toExternalForm());
+          } catch(Exception e) {
             actionsFile.setText("");
           }
         }
@@ -1119,24 +1109,23 @@
       }
     });
 
-    int returnValue = JOptionPane.showOptionDialog(editor.getContentPane(),
-            mainPanel, "New Alignment Task", JOptionPane.PLAIN_MESSAGE,
+    int returnValue =
+        JOptionPane.showOptionDialog(editor.getContentPane(), mainPanel,
+            "New Alignment Task", JOptionPane.PLAIN_MESSAGE,
             JOptionPane.OK_CANCEL_OPTION, MainFrame.getIcon("annotation-diff"),
-            new String[] {"OK", "Cancel"}, "OK");
+            new String[]{"OK", "Cancel"}, "OK");
     if(returnValue == JOptionPane.OK_OPTION) {
       AlignmentTask alignmentTask = new AlignmentTask(document);
 
       File actionsConfFile = null;
       if(actionsFile.getText().trim().length() > 0) {
         try {
-          actionsConfFile = new File(new URL(actionsFile.getText().trim())
-                  .toURI());
-        }
-        catch(MalformedURLException e) {
+          actionsConfFile =
+              new File(new URL(actionsFile.getText().trim()).toURI());
+        } catch(MalformedURLException e) {
           e.printStackTrace();
           actionsConfFile = null;
-        }
-        catch(URISyntaxException e) {
+        } catch(URISyntaxException e) {
           e.printStackTrace();
           actionsConfFile = null;
         }
@@ -1145,29 +1134,25 @@
       // MainFrame.lockGUI("Initializing alignment task : "+
       // taskName.getText()+"... ");
       try {
-        alignmentTask.initialize(taskName.getText(), srcDoc.getName(), tgtDoc
-                .getName(), (String)srcAnnotationSets.getSelectedItem(),
-                (String)tgtAnnotationSets.getSelectedItem(), unitOfAlignment
-                        .getText(), parentOfUnitOfAlignment.getText(),
-                (String)dataSources.getSelectedItem(), (String)storeAlignmentIn
-                        .getSelectedItem(), (String)viewsToSelectFrom
-                        .getSelectedItem(), actionsConfFile == null
-                        ? null
-                        : actionsConfFile.getAbsolutePath());
-      }
-      finally {
+        alignmentTask.initialize(taskName.getText(), srcDoc.getName(),
+            tgtDoc.getName(), (String)srcAnnotationSets.getSelectedItem(),
+            (String)tgtAnnotationSets.getSelectedItem(),
+            unitOfAlignment.getText(), parentOfUnitOfAlignment.getText(),
+            (String)dataSources.getSelectedItem(),
+            (String)storeAlignmentIn.getSelectedItem(),
+            (String)viewsToSelectFrom.getSelectedItem(),
+            actionsConfFile == null ? null : 
actionsConfFile.getAbsolutePath());
+      } finally {
         // MainFrame.unlockGUI();
       }
       return alignmentTask;
-    }
-    else {
+    } else {
       return null;
     }
   }
 
   /**
-   * This method invokes a dialog that asks for source and target
-   * documents
+   * This method invokes a dialog that asks for source and target documents
    * 
    * @return
    */
@@ -1212,19 +1197,18 @@
     constraints.insets = new Insets(0, 0, 0, 10);
     mainPanel.add(targetDocs, constraints);
 
-    int returnValue = JOptionPane.showOptionDialog(editor.getContentPane(),
-            mainPanel, "Select Source and Target Documents",
-            JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, MainFrame
-                    .getIcon("annotation-diff"), new String[] {"OK", "Cancel"},
-            "OK");
+    int returnValue =
+        JOptionPane.showOptionDialog(editor.getContentPane(), mainPanel,
+            "Select Source and Target Documents", JOptionPane.PLAIN_MESSAGE,
+            JOptionPane.OK_CANCEL_OPTION, MainFrame.getIcon("annotation-diff"),
+            new String[]{"OK", "Cancel"}, "OK");
     if(returnValue == JOptionPane.OK_OPTION) {
-      Document srcDoc = document.getDocument((String)sourceDocs
-              .getSelectedItem());
-      Document tgtDoc = document.getDocument((String)targetDocs
-              .getSelectedItem());
-      return new Document[] {srcDoc, tgtDoc};
-    }
-    else {
+      Document srcDoc =
+          document.getDocument((String)sourceDocs.getSelectedItem());
+      Document tgtDoc =
+          document.getDocument((String)targetDocs.getSelectedItem());
+      return new Document[]{srcDoc, tgtDoc};
+    } else {
       return null;
     }
   }
@@ -1238,7 +1222,7 @@
     JTextArea container;
 
     public HighlightAlignedAnnotation(Annotation a, Alignment alignment,
-            JTextArea container) {
+        JTextArea container) {
       super(a.getType());
       this.a = a;
       this.alignment = alignment;
@@ -1273,12 +1257,12 @@
 
       for(Annotation a : srcAlignedAnnots) {
         srcSelectedHighlights.add(addHighlight(a, sourceEditor,
-                SELECTED_HIGHLIGHT));
+            SELECTED_HIGHLIGHT));
       }
 
       for(Annotation a : tgtAlignedAnnots) {
         tgtSelectedHighlights.add(addHighlight(a, targetEditor,
-                SELECTED_HIGHLIGHT));
+            SELECTED_HIGHLIGHT));
       }
     }
   }
@@ -1290,15 +1274,14 @@
       JPopupMenu popup = new JPopupMenu();
 
       // check for annotations at location
-      JTextArea editorToUse = editorPane == sourceEditor
-              ? sourceEditor
-              : targetEditor;
+      JTextArea editorToUse =
+          editorPane == sourceEditor ? sourceEditor : targetEditor;
       AnnotationSet setToUse = editorPane == sourceEditor ? srcAS : tgtAS;
       Document docToUse = editorPane == sourceEditor ? srcDoc : tgtDoc;
 
       HighlightAlignedAnnotation haa = null;
-      for(Annotation a : setToUse.get(Math.max(0l, textLocation - 1), Math.min(
-              docToUse.getContent().size() - 1, textLocation + 1))) {
+      for(Annotation a : setToUse.get(Math.max(0l, textLocation - 1),
+          Math.min(docToUse.getContent().size() - 1, textLocation + 1))) {
 
         if(alignment.isAnnotationAligned(a)) {
           haa = new HighlightAlignedAnnotation(a, alignment, editorPane);
@@ -1311,12 +1294,10 @@
         if(popup.getComponentCount() > 1) {
           rect = editorToUse.modelToView(textLocation);
           popup.show(editorToUse, rect.x + 10, rect.y);
-        }
-        else if(popup.getComponentCount() == 1) {
+        } else if(popup.getComponentCount() == 1) {
           haa.actionPerformed(null);
         }
-      }
-      catch(BadLocationException e) {
+      } catch(BadLocationException e) {
         e.printStackTrace();
       }
     }
@@ -1356,21 +1337,18 @@
 
       if(alignmentTask.getAlignmentView().equals(LINKS_VIEW)) {
         alignmentView = new LinksView(alignmentTask);
-      }
-      else if(alignmentTask.getAlignmentView().equals(MATRIX_VIEW)) {
+      } else if(alignmentTask.getAlignmentView().equals(MATRIX_VIEW)) {
         alignmentView = new MatrixView(alignmentTask);
-      }
-      else if(alignmentTask.getAlignmentView().endsWith(PARALLEL_VIEW)) {
+      } else if(alignmentTask.getAlignmentView().endsWith(PARALLEL_VIEW)) {
         alignmentView = new ParallelTextView(alignmentTask);
-      }
-      else {
+      } else {
         throw new GateRuntimeException("Invalid alignment view :"
-                + alignmentTask.getAlignmentView());
+            + alignmentTask.getAlignmentView());
       }
 
       thisInstance.add((JPanel)alignmentView, BorderLayout.CENTER);
       viewsToolbar.add(new JLabel("Selected View:"
-              + alignmentTask.getAlignmentView()));
+          + alignmentTask.getAlignmentView()));
       viewsToolbar.addSeparator();
 
       viewsToolbar.add(new JLabel("Pair:"));
@@ -1403,16 +1381,16 @@
       selectedFeature = (String)this.alignmentFeatures.getSelectedItem();
     }
 
-    List<String> alignmentFeatureNames = new ArrayList<String>(document
-            .getAllAlignmentFeatureNames());
-    final boolean reselect = selectedFeature != null ? alignmentFeatureNames
+    List<String> alignmentFeatureNames =
+        new ArrayList<String>(document.getAllAlignmentFeatureNames());
+    final boolean reselect =
+        selectedFeature != null ? alignmentFeatureNames
             .contains(selectedFeature) : false;
-    DefaultComboBoxModel model = new DefaultComboBoxModel(alignmentFeatureNames
-            .toArray());
+    DefaultComboBoxModel model =
+        new DefaultComboBoxModel(alignmentFeatureNames.toArray());
     if(this.alignmentFeatures == null) {
       this.alignmentFeatures = new JComboBox(model);
-    }
-    else {
+    } else {
       this.alignmentFeatures.setModel(model);
     }
 
@@ -1425,8 +1403,7 @@
         if(reselect) {
           alignmentFeatures.setSelectedItem(featureToReselect);
           refreshHighlightsAction();
-        }
-        else {
+        } else {
           // delete any highlights
           sourceEditor.getHighlighter().removeAllHighlights();
           targetEditor.getHighlighter().removeAllHighlights();
@@ -1436,19 +1413,17 @@
   }
 
   /**
-   * update the src or target annotation sets when there's any new
-   * annotation set added
+   * update the src or target annotation sets when there's any new annotation
+   * set added
    */
   public void annotationSetAdded(DocumentEvent e) {
     Document doc = (Document)e.getSource();
     JComboBox comboBox = null;
     if(srcDoc == doc) {
       comboBox = this.srcAnnotationSets;
-    }
-    else if(tgtDoc == doc) {
+    } else if(tgtDoc == doc) {
       comboBox = this.tgtAnnotationSets;
-    }
-    else {
+    } else {
       return;
     }
 
@@ -1476,8 +1451,7 @@
         if(ASToReselect != null) {
           finalComboBox.setSelectedItem(ASToReselect);
           refreshHighlightsAction();
-        }
-        else {
+        } else {
           // delete any highlights
           sourceEditor.getHighlighter().removeAllHighlights();
           targetEditor.getHighlighter().removeAllHighlights();
@@ -1487,19 +1461,17 @@
   }
 
   /**
-   * update the src or target annotation set combobox when an annotation
-   * set is deleted.
+   * update the src or target annotation set combobox when an annotation set is
+   * deleted.
    */
   public void annotationSetRemoved(DocumentEvent e) {
     Document doc = (Document)e.getSource();
     JComboBox comboBox = null;
     if(srcDoc == doc) {
       comboBox = this.srcAnnotationSets;
-    }
-    else if(tgtDoc == doc) {
+    } else if(tgtDoc == doc) {
       comboBox = this.tgtAnnotationSets;
-    }
-    else {
+    } else {
       return;
     }
 
@@ -1516,9 +1488,8 @@
     DefaultComboBoxModel model = (DefaultComboBoxModel)comboBox.getModel();
     model.removeElement(deletedASName);
 
-    final String ASToReselect = selectedASName.equals(deletedASName)
-            ? null
-            : deletedASName;
+    final String ASToReselect =
+        selectedASName.equals(deletedASName) ? null : deletedASName;
     final JComboBox finalComboBox = comboBox;
 
     // update ui
@@ -1529,8 +1500,7 @@
         if(ASToReselect != null) {
           finalComboBox.setSelectedItem(ASToReselect);
           refreshHighlightsAction();
-        }
-        else {
+        } else {
           // delete any highlights
           sourceEditor.getHighlighter().removeAllHighlights();
           targetEditor.getHighlighter().removeAllHighlights();

Modified: 
gate/trunk/plugins/Alignment/src/gate/compound/gui/CompoundDocumentEditor.java
===================================================================
--- 
gate/trunk/plugins/Alignment/src/gate/compound/gui/CompoundDocumentEditor.java  
    2011-11-26 02:17:45 UTC (rev 14612)
+++ 
gate/trunk/plugins/Alignment/src/gate/compound/gui/CompoundDocumentEditor.java  
    2011-11-26 23:38:08 UTC (rev 14613)
@@ -429,6 +429,8 @@
   }
 
   public void cleanup() {
+    super.cleanup();
+    
     // close all open alignment editors
     for(AlignmentEditor editor : alignmentEditors) {
       // dispose will clean up the editor internally
@@ -441,7 +443,6 @@
       tabbedPane.remove(h.getLargeView());
       h.cleanup();
     }
-    super.cleanup();
+    
   }
-
 }

Modified: 
gate/trunk/plugins/Alignment/src/gate/compound/impl/AbstractCompoundDocument.java
===================================================================
--- 
gate/trunk/plugins/Alignment/src/gate/compound/impl/AbstractCompoundDocument.java
   2011-11-26 02:17:45 UTC (rev 14612)
+++ 
gate/trunk/plugins/Alignment/src/gate/compound/impl/AbstractCompoundDocument.java
   2011-11-26 23:38:08 UTC (rev 14613)
@@ -8,16 +8,15 @@
 import gate.FeatureMap;
 import gate.Gate;
 import gate.Resource;
-import gate.annotation.AnnotationSetImpl;
 import gate.compound.CompoundDocument;
 import gate.corpora.DocumentContentImpl;
 import gate.corpora.DocumentImpl;
 import gate.event.CreoleEvent;
 import gate.event.DatastoreEvent;
 import gate.event.DocumentListener;
+import gate.util.GateRuntimeException;
 import gate.util.InvalidOffsetException;
 import gate.util.Strings;
-import gate.util.GateRuntimeException;
 
 import java.io.IOException;
 import java.io.ObjectInputStream;
@@ -26,7 +25,6 @@
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -34,9 +32,9 @@
 import java.util.Vector;
 
 /**
- * This is an abstract implementation of the AbstractAlignedDocument
- * This class overrides the methods of DocumentImpl and provide generic
- * implementation of some of the methods of AlignedDocument
+ * This is an abstract implementation of the AbstractAlignedDocument This class
+ * overrides the methods of DocumentImpl and provide generic implementation of
+ * some of the methods of AlignedDocument
  * 
  * @author niraj
  */
@@ -47,16 +45,15 @@
   protected String encoding = null;
 
   /**
-   * If you set this flag to true the repositioning information for the
-   * document will be kept in the document feature. <br>
-   * Default value is false to avoid the unnecessary waste of time and
-   * memory
+   * If you set this flag to true the repositioning information for the 
document
+   * will be kept in the document feature. <br>
+   * Default value is false to avoid the unnecessary waste of time and memory
    */
   protected Boolean collectRepositioningInfo = new Boolean(false);
 
   /**
-   * If you set this flag to true the original content of the document
-   * will be kept in the document feature. <br>
+   * If you set this flag to true the original content of the document will be
+   * kept in the document feature. <br>
    * Default value is false to avoid the unnecessary waste of memory
    */
   protected Boolean preserveOriginalContent = new Boolean(false);
@@ -88,14 +85,14 @@
   private transient Vector<DocumentListener> documentListeners;
 
   /**
-   * The start of the range that the content comes from at the source
-   * URL (or null if none).
+   * The start of the range that the content comes from at the source URL (or
+   * null if none).
    */
   protected Long sourceUrlStartOffset;
 
   /**
-   * The end of the range that the content comes from at the source URL
-   * (or null if none).
+   * The end of the range that the content comes from at the source URL (or 
null
+   * if none).
    */
   protected Long sourceUrlEndOffset;
 
@@ -103,12 +100,12 @@
   protected Boolean markupAware = new Boolean(false);
 
   /** exception message when the current document is not set */
-  protected String CURR_DOC_NOT_SET_MSG = "Please use " +
-        "setCurrentDocument(...) " +
-        " method first.";
+  protected String CURR_DOC_NOT_SET_MSG = "Please use "
+      + "setCurrentDocument(...) method first!";
 
   /** Clear all the data members of the object. */
   public void cleanup() {
+    setCurrentDocument(null);
     Iterator<Document> iter = documents.values().iterator();
     while(iter.hasNext()) {
       Document doc = iter.next();
@@ -121,28 +118,21 @@
   } // cleanup()
 
   /**
-   * This method always returns features of the compound document. If
-   * you want access to features of the member document - you can use
+   * This method always returns features of the compound document. If you want
+   * access to features of the member document - you can use
    * getDocument(documentId).getFeatures()
-   * */
+   */
   @Override
   public FeatureMap getFeatures() {
-    if(currentDocument == null) {
-      if(this.features == null) {
-        this.features = Factory.newFeatureMap();
-      }
-      return this.features;
-    } else {
-      return currentDocument.getFeatures();  
+    if(this.features == null) {
+      this.features = Factory.newFeatureMap();
     }
+    return this.features;
   }
 
-  
   /** gets the name of the current document */
   public String getName() {
-    if(currentDocument == null) {
-      return super.getName();
-    }
+    if(currentDocument == null) { return super.getName(); }
     return currentDocument.getName();
   }
 
@@ -154,12 +144,10 @@
       currentDocument.setName(name);
     }
   }
-  
+
   /** Documents are identified by URLs */
   public URL getSourceUrl() {
-    if(currentDocument == null) {
-      return sourceUrl;
-    }
+    if(currentDocument == null) { return sourceUrl; }
     return currentDocument.getSourceUrl();
   }
 
@@ -167,33 +155,30 @@
   public void setSourceUrl(URL sourceUrl) {
     if(currentDocument == null) {
       this.sourceUrl = sourceUrl;
-    }
-    else {
+    } else {
       currentDocument.setSourceUrl(sourceUrl);
     }
   } // setSourceUrl
 
   /**
-   * Documents may be packed within files; in this case an optional pair
-   * of offsets refer to the location of the document.
+   * Documents may be packed within files; in this case an optional pair of
+   * offsets refer to the location of the document.
    */
   public Long[] getSourceUrlOffsets() {
-    if(currentDocument == null) {
-      return new Long[] {sourceUrlStartOffset, sourceUrlEndOffset};
-    }
+    if(currentDocument == null) { return new Long[]{sourceUrlStartOffset,
+        sourceUrlEndOffset}; }
     return currentDocument.getSourceUrlOffsets();
   } // getSourceUrlOffsets
 
   /**
    * Allow/disallow preserving of the original document content. If is
-   * <B>true</B> the original content will be retrieved from the
-   * DocumentContent object and preserved as document feature.
+   * <B>true</B> the original content will be retrieved from the 
DocumentContent
+   * object and preserved as document feature.
    */
   public void setPreserveOriginalContent(Boolean b) {
     if(currentDocument == null) {
       this.preserveOriginalContent = b;
-    }
-    else {
+    } else {
       currentDocument.setPreserveOriginalContent(b);
     }
   } // setPreserveOriginalContent
@@ -206,16 +191,14 @@
   public Boolean getPreserveOriginalContent() {
     if(currentDocument == null) {
       return preserveOriginalContent;
-    }
-    else {
+    } else {
       return currentDocument.getPreserveOriginalContent();
     }
   } // getPreserveOriginalContent
 
   /**
-   * Allow/disallow collecting of repositioning information. If is
-   * <B>true</B> information will be retrieved and preserved as document
-   * feature.<BR>
+   * Allow/disallow collecting of repositioning information. If is <B>true</B>
+   * information will be retrieved and preserved as document feature.<BR>
    * Preserving of repositioning information give the possibilities for
    * converting of coordinates between the original document content and
    * extracted from the document text.
@@ -223,97 +206,88 @@
   public void setCollectRepositioningInfo(Boolean b) {
     if(currentDocument == null) {
       collectRepositioningInfo = b;
-    }
-    else {
+    } else {
       currentDocument.setCollectRepositioningInfo(b);
     }
   } // setCollectRepositioningInfo
 
   /**
-   * Get the collectiong and preserving of repositioning information for
-   * the Document. <BR>
+   * Get the collectiong and preserving of repositioning information for the
+   * Document. <BR>
    * Preserving of repositioning information give the possibilities for
    * converting of coordinates between the original document content and
    * extracted from the document text.
    * 
-   * @return whether the Document should collect and preserve
-   *         information.
+   * @return whether the Document should collect and preserve information.
    */
   public Boolean getCollectRepositioningInfo() {
     if(currentDocument == null) {
       return collectRepositioningInfo;
-    }
-    else {
+    } else {
       return currentDocument.getCollectRepositioningInfo();
     }
   } // getCollectRepositioningInfo
 
   /**
-   * Documents may be packed within files; in this case an optional pair
-   * of offsets refer to the location of the document. This method gets
-   * the start offset.
+   * Documents may be packed within files; in this case an optional pair of
+   * offsets refer to the location of the document. This method gets the start
+   * offset.
    */
   public Long getSourceUrlStartOffset() {
     if(currentDocument == null) {
       return sourceUrlStartOffset;
-    }
-    else {
+    } else {
       return currentDocument.getSourceUrlStartOffset();
     }
   }
 
   /**
-   * Documents may be packed within files; in this case an optional pair
-   * of offsets refer to the location of the document. This method sets
-   * the start offset.
+   * Documents may be packed within files; in this case an optional pair of
+   * offsets refer to the location of the document. This method sets the start
+   * offset.
    */
   public void setSourceUrlStartOffset(Long sourceUrlStartOffset) {
     if(currentDocument == null) {
       this.sourceUrlStartOffset = sourceUrlStartOffset;
-    }
-    else {
+    } else {
       currentDocument.setSourceUrlStartOffset(sourceUrlStartOffset);
     }
 
   } // setSourceUrlStartOffset
 
   /**
-   * Documents may be packed within files; in this case an optional pair
-   * of offsets refer to the location of the document. This method gets
-   * the end offset.
+   * Documents may be packed within files; in this case an optional pair of
+   * offsets refer to the location of the document. This method gets the end
+   * offset.
    */
   public Long getSourceUrlEndOffset() {
     if(currentDocument == null) {
       return sourceUrlEndOffset;
-    }
-    else {
+    } else {
       return currentDocument.getSourceUrlEndOffset();
     }
   }
 
   /**
-   * Documents may be packed within files; in this case an optional pair
-   * of offsets refer to the location of the document. This method sets
-   * the end offset.
+   * Documents may be packed within files; in this case an optional pair of
+   * offsets refer to the location of the document. This method sets the end
+   * offset.
    */
   public void setSourceUrlEndOffset(Long sourceUrlEndOffset) {
     if(currentDocument == null) {
       this.sourceUrlEndOffset = sourceUrlEndOffset;
-    }
-    else {
+    } else {
       currentDocument.setSourceUrlEndOffset(sourceUrlEndOffset);
     }
   } // setSourceUrlStartOffset
 
   /**
-   * The content of the document: a String for text; MPEG for video;
-   * etc.
+   * The content of the document: a String for text; MPEG for video; etc.
    */
   public DocumentContent getContent() {
     if(currentDocument == null) {
-      throw new GateRuntimeException(CURR_DOC_NOT_SET_MSG);
-    }
-    else {
+      return new DocumentContentImpl("");
+    } else {
       return currentDocument.getContent();
     }
   }
@@ -329,8 +303,7 @@
   public String getEncoding() {
     if(currentDocument == null) {
       return this.encoding;
-    }
-    else {
+    } else {
       return ((DocumentImpl)currentDocument).getEncoding();
     }
   }
@@ -339,53 +312,49 @@
   public void setEncoding(String encoding) {
     if(currentDocument == null) {
       this.encoding = encoding;
-    }
-    else {
+    } else {
       ((DocumentImpl)currentDocument).setEncoding(encoding);
     }
   }
 
   /**
-   * Get the default set of annotations. The set is created if it
-   * doesn't exist yet.
+   * Get the default set of annotations. The set is created if it doesn't exist
+   * yet.
    */
   public AnnotationSet getAnnotations() {
     if(currentDocument == null) {
-       throw new GateRuntimeException(CURR_DOC_NOT_SET_MSG);
-    }
-    else {
+      throw new GateRuntimeException(CURR_DOC_NOT_SET_MSG);
+    } else {
       return currentDocument.getAnnotations();
     }
   } // getAnnotations()
 
   /**
-   * Get a named set of annotations. Creates a new set if one with this
-   * name doesn't exist yet. If the provided name is null then it
-   * returns the default annotation set.
+   * Get a named set of annotations. Creates a new set if one with this name
+   * doesn't exist yet. If the provided name is null then it returns the 
default
+   * annotation set.
    */
   public AnnotationSet getAnnotations(String name) {
     if(currentDocument == null) {
       throw new GateRuntimeException(CURR_DOC_NOT_SET_MSG);
-    }
-    else {
+    } else {
       return currentDocument.getAnnotations(name);
     }
   } // getAnnotations(name)
 
   /**
    * Make the document markup-aware. This will trigger the creation of a
-   * DocumentFormat object at Document initialisation time; the
-   * DocumentFormat object will unpack the markup in the Document and
-   * add it as annotations. Documents are <B>not</B> markup-aware by
-   * default.
+   * DocumentFormat object at Document initialisation time; the DocumentFormat
+   * object will unpack the markup in the Document and add it as annotations.
+   * Documents are <B>not</B> markup-aware by default.
    * 
-   * @param newMarkupAware markup awareness status.
+   * @param newMarkupAware
+   *          markup awareness status.
    */
   public void setMarkupAware(Boolean newMarkupAware) {
     if(currentDocument == null) {
       this.markupAware = newMarkupAware;
-    }
-    else {
+    } else {
       currentDocument.setMarkupAware(newMarkupAware);
     }
   }
@@ -399,69 +368,65 @@
   public Boolean getMarkupAware() {
     if(currentDocument == null) {
       return this.markupAware;
-    }
-    else {
+    } else {
       return currentDocument.getMarkupAware();
     }
   }
 
   /**
    * Returns an XML document aming to preserve the original markups( the
-   * original markup will be in the same place and format as it was
-   * before processing the document) and include (if possible) the
-   * annotations specified in the aSourceAnnotationSet. It is equivalent
-   * to toXml(aSourceAnnotationSet, true).
+   * original markup will be in the same place and format as it was before
+   * processing the document) and include (if possible) the annotations
+   * specified in the aSourceAnnotationSet. It is equivalent to
+   * toXml(aSourceAnnotationSet, true).
    */
   public String toXml(Set aSourceAnnotationSet) {
     if(currentDocument == null) {
-      throw new GateRuntimeException(CURR_DOC_NOT_SET_MSG +
-              " OR call toXmlAsSingleDocument(...)");
-    }
-    else {
+      throw new GateRuntimeException(CURR_DOC_NOT_SET_MSG);
+    } else {
       return currentDocument.toXml(aSourceAnnotationSet);
     }
   }
 
   /**
    * Returns an XML document aming to preserve the original markups( the
-   * original markup will be in the same place and format as it was
-   * before processing the document) and include (if possible) the
-   * annotations specified in the aSourceAnnotationSet. <b>Warning:</b>
-   * Annotations from the aSourceAnnotationSet will be lost if they will
-   * cause a crosed over situation.
+   * original markup will be in the same place and format as it was before
+   * processing the document) and include (if possible) the annotations
+   * specified in the aSourceAnnotationSet. <b>Warning:</b> Annotations from 
the
+   * aSourceAnnotationSet will be lost if they will cause a crosed over
+   * situation.
    * 
-   * @param aSourceAnnotationSet is an annotation set containing all the
-   *          annotations that will be combined with the original marup
-   *          set. If the param is <code>null</code> it will only dump
-   *          the original markups.
-   * @param includeFeatures is a boolean that controls whether the
-   *          annotation features should be included or not. If false,
-   *          only the annotation type is included in the tag.
-   * @return a string representing an XML document containing the
-   *         original markup + dumped annotations form the
-   *         aSourceAnnotationSet
+   * @param aSourceAnnotationSet
+   *          is an annotation set containing all the annotations that will be
+   *          combined with the original marup set. If the param is
+   *          <code>null</code> it will only dump the original markups.
+   * @param includeFeatures
+   *          is a boolean that controls whether the annotation features should
+   *          be included or not. If false, only the annotation type is 
included
+   *          in the tag.
+   * @return a string representing an XML document containing the original
+   *         markup + dumped annotations form the aSourceAnnotationSet
    */
   public String toXml(Set aSourceAnnotationSet, boolean includeFeatures) {
     if(currentDocument == null) {
       throw new GateRuntimeException(CURR_DOC_NOT_SET_MSG);
-    }
-    else {
+    } else {
       return currentDocument.toXml(aSourceAnnotationSet, includeFeatures);
     }
   }// End toXml()
 
   /**
-   * Returns a GateXml document that is a custom XML format for wich
-   * there is a reader inside GATE called gate.xml.GateFormatXmlHandler.
-   * What it does is to serialize a GATE document in an XML format.
+   * Returns a GateXml document that is a custom XML format for wich there is a
+   * reader inside GATE called gate.xml.GateFormatXmlHandler. What it does is 
to
+   * serialize a GATE document in an XML format.
    * 
    * @return a string representing a Gate Xml document.
    */
   public String toXml() {
     if(currentDocument == null) {
+
       return toXmlAsASingleDocument(this);
-    }
-    else {
+    } else {
       return currentDocument.toXml();
     }
   }// toXml
@@ -484,38 +449,44 @@
     globalMap.put("docXmls", docXmls);
 
     // we would use XStream library to store annic patterns
-    com.thoughtworks.xstream.XStream xstream = new 
com.thoughtworks.xstream.XStream();
+    com.thoughtworks.xstream.XStream xstream =
+        new com.thoughtworks.xstream.XStream();
 
     // Saving is accomplished just using XML serialization of the map.
     StringWriter stringToReturn = new StringWriter();
 
+    Document currentDoc = aCompoundDoc.getCurrentDocument();
+    aCompoundDoc.setCurrentDocument(null);
+
     // other features
     Map<String, Object> features = new HashMap<String, Object>();
     features.put("encoding", aCompoundDoc.getEncoding());
-    features.put("collectRepositioningInfo", aCompoundDoc
-            .getCollectRepositioningInfo());
-    features.put("preserveOriginalContent", aCompoundDoc
-            .getPreserveOriginalContent());
+    features.put("collectRepositioningInfo",
+        aCompoundDoc.getCollectRepositioningInfo());
+    features.put("preserveOriginalContent",
+        aCompoundDoc.getPreserveOriginalContent());
     features.put("documentIDs", aCompoundDoc.getDocumentIDs());
     features.put("markupAware", new Boolean(true));
     features.put("name", aCompoundDoc.getName());
     globalMap.put("feats", features);
-
     globalMap.put("docFeats", aCompoundDoc.getFeatures());
 
+    // restore the original settings
+    aCompoundDoc.setCurrentDocument(currentDoc == null ? null : currentDoc
+        .getName());
+
     xstream.toXML(globalMap, stringToReturn);
     return stringToReturn.toString();
   }
 
   /**
-   * Returns a map with the named annotation sets. It returns
-   * <code>null</code> if no named annotaton set exists.
+   * Returns a map with the named annotation sets. It returns <code>null</code>
+   * if no named annotaton set exists.
    */
   public Map<String, AnnotationSet> getNamedAnnotationSets() {
     if(currentDocument == null) {
       throw new GateRuntimeException(CURR_DOC_NOT_SET_MSG);
-    }
-    else {
+    } else {
       return currentDocument.getNamedAnnotationSets();
     }
   } // getNamedAnnotationSets
@@ -523,17 +494,17 @@
   public Set<String> getAnnotationSetNames() {
     if(currentDocument == null) {
       throw new GateRuntimeException(CURR_DOC_NOT_SET_MSG);
-    }
-    else {
+    } else {
       return currentDocument.getAnnotationSetNames();
     }
   }
 
   /**
-   * Removes one of the named annotation sets. Note that the default
-   * annotation set cannot be removed.
+   * Removes one of the named annotation sets. Note that the default annotation
+   * set cannot be removed.
    * 
-   * @param name the name of the annotation set to be removed
+   * @param name
+   *          the name of the annotation set to be removed
    */
   public void removeAnnotationSet(String name) {
     if(currentDocument != null) {
@@ -543,7 +514,7 @@
 
   /** Propagate edit changes to the document content and annotations. */
   public void edit(Long start, Long end, DocumentContent replacement)
-          throws InvalidOffsetException {
+      throws InvalidOffsetException {
     if(currentDocument != null) {
       currentDocument.edit(start, end, replacement);
     }
@@ -566,8 +537,7 @@
       s.append("  sourceUrl:" + sourceUrl + n);
       s.append(n);
       return s.toString();
-    }
-    else {
+    } else {
       return currentDocument.toString();
     }
   } // toString
@@ -581,8 +551,7 @@
   public synchronized void removeDocumentListener(DocumentListener l) {
     if(currentDocument != null) {
       currentDocument.removeDocumentListener(l);
-    }
-    else {
+    } else {
       if(documentListeners != null && documentListeners.contains(l)) {
         Vector v = (Vector)documentListeners.clone();
         v.removeElement(l);
@@ -594,9 +563,9 @@
   public synchronized void addDocumentListener(DocumentListener l) {
     if(currentDocument != null) {
       currentDocument.addDocumentListener(l);
-    }
-    else {
-      Vector v = documentListeners == null
+    } else {
+      Vector v =
+          documentListeners == null
               ? new Vector<DocumentListener>(2)
               : (Vector)documentListeners.clone();
       if(!v.contains(l)) {
@@ -665,7 +634,7 @@
   }
 
   public void setDataStore(DataStore dataStore)
-          throws gate.persist.PersistenceException {
+      throws gate.persist.PersistenceException {
     super.setDataStore(dataStore);
     if(this.dataStore != null) this.dataStore.addDatastoreListener(this);
   }
@@ -678,8 +647,7 @@
     Object obj = documents.get(documentID);
     if(obj == null) {
       return this;
-    }
-    else {
+    } else {
       return (Document)obj;
     }
   }
@@ -693,8 +661,7 @@
     Object obj = documents.get(documentID);
     if(obj == null) {
       currentDocument = null;
-    }
-    else {
+    } else {
       currentDocument = (Document)obj;
     }
   }
@@ -711,8 +678,7 @@
     if(docIDs != null) {
       this.documentIDs = new ArrayList<String>();
       this.documentIDs.addAll(docIDs);
-    }
-    else {
+    } else {
       this.documentIDs = null;
     }
   }
@@ -722,7 +688,7 @@
    * register when this compound is deserialized.
    */
   private void readObject(ObjectInputStream stream) throws IOException,
-          ClassNotFoundException {
+      ClassNotFoundException {
     stream.defaultReadObject();
     // register a validation callback to add our child documents
     // to the creole register and fire the relevant events. This
@@ -732,9 +698,9 @@
       public void validateObject() {
         for(Document d : documents.values()) {
           Gate.getCreoleRegister().get(d.getClass().getName())
-                  .addInstantiation(d);
+              .addInstantiation(d);
           Gate.getCreoleRegister().resourceLoaded(
-                  new CreoleEvent(d, CreoleEvent.RESOURCE_LOADED));
+              new CreoleEvent(d, CreoleEvent.RESOURCE_LOADED));
         }
       }
     }, 0);

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


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs

Reply via email to