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 2008/11/04 21:59:13 UTC

svn commit: r711402 [5/6] - in /incubator/uima/sandbox/trunk/CasEditorEclipsePlugin: ./ META-INF/ icons/ icons/svgicons/ main/ main/java/ main/java/src/ main/java/src/org/ main/java/src/org/apache/ main/java/src/org/apache/uima/ main/java/src/org/apach...

Added: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/fsview/FeatureStructureBrowserViewPage.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/fsview/FeatureStructureBrowserViewPage.java?rev=711402&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/fsview/FeatureStructureBrowserViewPage.java (added)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/fsview/FeatureStructureBrowserViewPage.java Tue Nov  4 12:59:10 2008
@@ -0,0 +1,509 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.caseditor.editor.fsview;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Vector;
+
+import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.FSIterator;
+import org.apache.uima.cas.Feature;
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.Type;
+import org.apache.uima.cas.TypeSystem;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.caseditor.editor.CasEditorPlugin;
+import org.apache.uima.caseditor.editor.Images;
+import org.apache.uima.caseditor.editor.AbstractAnnotationDocumentListener;
+import org.apache.uima.caseditor.editor.AnnotationDocument;
+import org.apache.uima.caseditor.editor.FeatureValue;
+import org.apache.uima.caseditor.editor.ModelFeatureStructure;
+import org.apache.uima.caseditor.editor.action.DeleteFeatureStructureAction;
+import org.apache.uima.caseditor.editor.util.Primitives;
+import org.apache.uima.caseditor.editor.util.StrictTypeConstraint;
+import org.apache.uima.jcas.cas.StringArray;
+import org.eclipse.core.runtime.IAdaptable;
+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.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.ListViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.part.Page;
+
+/**
+ * TODO: add javadoc here
+ */
+public final class FeatureStructureBrowserViewPage extends Page {
+
+  final class FeatureStructureTreeContentProvider extends AbstractAnnotationDocumentListener
+          implements ITreeContentProvider {
+
+    private AnnotationDocument mDocument;
+
+    private CAS mCAS;
+
+    private Type mCurrentType;
+
+    FeatureStructureTreeContentProvider(AnnotationDocument document, CAS tcas) {
+      mCAS = tcas;
+      mDocument = document;
+    }
+
+    public Object[] getElements(Object inputElement) {
+      if (mCurrentType == null) {
+        return new Object[] {};
+      }
+
+      StrictTypeConstraint typeConstrain = new StrictTypeConstraint(mCurrentType);
+
+      FSIterator strictTypeIterator = mCAS.createFilteredIterator(
+              mCAS.getIndexRepository().getAllIndexedFS(mCurrentType), typeConstrain);
+
+      LinkedList<ModelFeatureStructure> featureStrucutreList = new LinkedList<ModelFeatureStructure>();
+
+      for (int i = 0; strictTypeIterator.hasNext(); i++) {
+        featureStrucutreList.add(new ModelFeatureStructure(mDocument,
+                (FeatureStructure) strictTypeIterator.next()));
+      }
+
+      ModelFeatureStructure[] featureStructureArray = new ModelFeatureStructure[featureStrucutreList
+              .size()];
+
+      featureStrucutreList.toArray(featureStructureArray);
+
+      return featureStructureArray;
+    }
+
+    public void dispose() {
+    }
+
+    public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+
+      if (oldInput != null) {
+        mDocument.removeChangeListener(this);
+      }
+
+      if (newInput == null) {
+
+        mCurrentType = null;
+        return;
+      }
+
+      mCurrentType = (Type) newInput;
+
+      mDocument.addChangeListener(this);
+
+      Display.getDefault().syncExec(new Runnable() {
+        public void run() {
+          mFSList.refresh();
+        }
+      });
+    }
+
+    /**
+     * Retrieves children for a FeatureStrcuture and for FeatureValues if they have children.
+     *
+     * @param parentElement
+     * @return the children
+     */
+    public Object[] getChildren(Object parentElement) {
+      Collection<Object> childs = new LinkedList<Object>();
+
+      FeatureStructure featureStructure;
+
+      if (parentElement instanceof ModelFeatureStructure) {
+        featureStructure = ((ModelFeatureStructure) parentElement).getStructre();
+      } else if (parentElement instanceof FeatureValue) {
+        FeatureValue value = (FeatureValue) parentElement;
+
+        if (parentElement instanceof StringArray) {
+          StringArray array = (StringArray) parentElement;
+          return array.toArray();
+        }
+
+        featureStructure = (FeatureStructure) value.getValue();
+      } else {
+        assert false : "Unexpected element!";
+
+        return new Object[] {};
+      }
+
+      Type type = featureStructure.getType();
+
+      Vector featureTypes = type.getAppropriateFeatures();
+
+      Iterator featuresItertor = featureTypes.iterator();
+
+      while (featuresItertor.hasNext()) {
+        Feature feature = (Feature) featuresItertor.next();
+
+        if (Primitives.isPrimitive(feature)) {
+          // create a new pair
+          // feature and value
+          // add string
+          childs.add(new FeatureValue(mDocument, featureStructure, feature));
+        } else {
+          childs.add(new FeatureValue(mDocument, featureStructure, feature));
+        }
+      }
+
+      assert childs.size() > 0;
+
+      return childs.toArray();
+    }
+
+    public Object getParent(Object element) {
+      return null;
+    }
+
+    public boolean hasChildren(Object element) {
+      if (element instanceof IAdaptable
+              && ((IAdaptable) element).getAdapter(FeatureStructure.class) != null) {
+        return true;
+      } else if (element instanceof FeatureValue) {
+        FeatureValue featureValue = (FeatureValue) element;
+
+        if (Primitives.isPrimitive(featureValue.getFeature())) {
+          Object value = featureValue.getValue();
+
+          if (value == null) {
+            return false;
+          }
+
+          if (value instanceof StringArray) {
+            StringArray array = (StringArray) featureValue.getValue();
+
+            if (array.size() > 0) {
+              return true;
+            } else {
+              return false;
+            }
+          }
+
+          return false;
+        } else {
+          return featureValue.getValue() != null ? true : false;
+        }
+      } else {
+        assert false : "Unexpected element";
+
+        return false;
+      }
+    }
+
+    @Override
+    protected void addedAnnotation(Collection<AnnotationFS> annotations) {
+
+      final LinkedList<ModelFeatureStructure> featureStrucutreList =
+        new LinkedList<ModelFeatureStructure>();
+
+      for (AnnotationFS annotation : annotations) {
+        if (annotation.getType() == mCurrentType) {
+          featureStrucutreList.add(new ModelFeatureStructure(mDocument, annotation));
+        }
+      }
+
+      Display.getDefault().syncExec(new Runnable() {
+        public void run() {
+          mFSList.add(featureStrucutreList.toArray());
+        }
+      });
+    }
+
+    @Override
+    public void added(Collection<FeatureStructure> structres) {
+      final LinkedList<ModelFeatureStructure> featureStrucutreList =
+        new LinkedList<ModelFeatureStructure>();
+
+      for (FeatureStructure structure : structres) {
+        if (structure.getType() == mCurrentType) {
+          featureStrucutreList.add(new ModelFeatureStructure(mDocument, structure));
+        }
+      }
+
+      Display.getDefault().syncExec(new Runnable() {
+        public void run() {
+          mFSList.add(featureStrucutreList.toArray());
+        }
+      });
+    }
+
+    @Override
+    protected void removedAnnotation(Collection<AnnotationFS> annotations) {
+
+      final LinkedList<ModelFeatureStructure> featureStrucutreList =
+        new LinkedList<ModelFeatureStructure>();
+
+      for (AnnotationFS annotation : annotations) {
+        if (annotation.getType() == mCurrentType) {
+          featureStrucutreList.add(new ModelFeatureStructure(mDocument, annotation));
+        }
+      }
+
+      Display.getDefault().syncExec(new Runnable() {
+        public void run() {
+          mFSList.remove(featureStrucutreList.toArray());
+        }
+      });
+
+    }
+
+    @Override
+    public void removed(Collection<FeatureStructure> structres) {
+      final LinkedList<ModelFeatureStructure> featureStrucutreList =
+        new LinkedList<ModelFeatureStructure>();
+
+      for (FeatureStructure structure : structres) {
+        if (structure.getType() == mCurrentType) {
+          featureStrucutreList.add(new ModelFeatureStructure(mDocument, structure));
+        }
+      }
+
+      Display.getDefault().syncExec(new Runnable() {
+        public void run() {
+          mFSList.remove(featureStrucutreList.toArray());
+        }
+      });
+    }
+
+    @Override
+    protected void updatedAnnotation(Collection<AnnotationFS> annotations) {
+      // ignore
+    }
+
+    public void changed() {
+      mFSList.refresh();
+    }
+  }
+
+  private class CreateAction extends Action {
+    // TOOD: extract it and add setType(...)
+    @Override
+    public void run() {
+      // TODO: check if an AnnotationFS was created, if so
+      // add it to the document
+
+      mDocument.fireDocumentChanged();
+
+      // inserts a new feature strucutre of current type
+      if (mCurrentType == null) {
+        return;
+      }
+
+      FeatureStructure newFeatureStructure = mCAS.createFS(mCurrentType);
+
+      mCAS.getIndexRepository().addFS(newFeatureStructure);
+
+      mFSList.refresh();
+    }
+  }
+
+  private class SelectAllAction extends Action {
+    @Override
+    public void run() {
+      mFSList.getList().selectAll();
+      mFSList.setSelection(mFSList.getSelection());
+    }
+  }
+
+  private AnnotationDocument mDocument;
+
+  private CAS mCAS;
+
+  private ListViewer mFSList;
+
+  private Composite mInstanceComposite;
+
+  private Type mCurrentType;
+
+  private DeleteFeatureStructureAction mDeleteAction;
+
+  private Action mSelectAllAction;
+
+  private Collection<Type> filterTypes;
+
+  /**
+   * Initializes a new instance.
+   *
+   * @param document
+   */
+  public FeatureStructureBrowserViewPage(AnnotationDocument document) {
+
+	if (document == null)
+		throw new IllegalArgumentException("document parameter must not be null!");
+
+    mCAS = document.getCAS();
+    mDocument = document;
+
+    mDeleteAction = new DeleteFeatureStructureAction(this.mDocument);
+
+    mSelectAllAction = new SelectAllAction();
+
+    TypeSystem ts = mCAS.getTypeSystem();
+
+    filterTypes = new HashSet<Type>();
+    filterTypes.add(ts.getType(CAS.TYPE_NAME_ARRAY_BASE));
+    filterTypes.add(ts.getType(CAS.TYPE_NAME_BOOLEAN_ARRAY));
+    filterTypes.add(ts.getType(CAS.TYPE_NAME_BYTE_ARRAY));
+    filterTypes.add(ts.getType(CAS.TYPE_NAME_LONG_ARRAY));
+    filterTypes.add(ts.getType(CAS.TYPE_NAME_SHORT_ARRAY));
+    filterTypes.add(ts.getType(CAS.TYPE_NAME_FLOAT_ARRAY));
+    filterTypes.add(ts.getType(CAS.TYPE_NAME_DOUBLE_ARRAY));
+    filterTypes.add(ts.getType(CAS.TYPE_NAME_BYTE));
+    filterTypes.add(ts.getType(CAS.TYPE_NAME_ANNOTATION_BASE));
+    filterTypes.add(ts.getType(CAS.TYPE_NAME_SHORT));
+    filterTypes.add(ts.getType(CAS.TYPE_NAME_LONG));
+    filterTypes.add(ts.getType(CAS.TYPE_NAME_FLOAT));
+    filterTypes.add(ts.getType(CAS.TYPE_NAME_DOUBLE));
+    filterTypes.add(ts.getType(CAS.TYPE_NAME_BOOLEAN));
+    filterTypes.add(ts.getType(CAS.TYPE_NAME_EMPTY_FLOAT_LIST));
+    filterTypes.add(ts.getType(CAS.TYPE_NAME_EMPTY_FS_LIST));
+    filterTypes.add(ts.getType(CAS.TYPE_NAME_EMPTY_INTEGER_LIST));
+    filterTypes.add(ts.getType(CAS.TYPE_NAME_EMPTY_STRING_LIST));
+    filterTypes.add(ts.getType(CAS.TYPE_NAME_FLOAT));
+    filterTypes.add(ts.getType(CAS.TYPE_NAME_FLOAT_ARRAY));
+    filterTypes.add(ts.getType(CAS.TYPE_NAME_FLOAT_LIST));
+    filterTypes.add(ts.getType(CAS.TYPE_NAME_FS_ARRAY));
+    filterTypes.add(ts.getType(CAS.TYPE_NAME_FS_LIST));
+    filterTypes.add(ts.getType(CAS.TYPE_NAME_INTEGER));
+    filterTypes.add(ts.getType(CAS.TYPE_NAME_INTEGER_ARRAY));
+    filterTypes.add(ts.getType(CAS.TYPE_NAME_INTEGER_LIST));
+    filterTypes.add(ts.getType(CAS.TYPE_NAME_LIST_BASE));
+    filterTypes.add(ts.getType(CAS.TYPE_NAME_NON_EMPTY_FLOAT_LIST));
+    filterTypes.add(ts.getType(CAS.TYPE_NAME_NON_EMPTY_FS_LIST));
+    filterTypes.add(ts.getType(CAS.TYPE_NAME_NON_EMPTY_INTEGER_LIST));
+    filterTypes.add(ts.getType(CAS.TYPE_NAME_NON_EMPTY_STRING_LIST));
+    filterTypes.add(ts.getType(CAS.TYPE_NAME_SOFA));
+    filterTypes.add(ts.getType(CAS.TYPE_NAME_STRING));
+    filterTypes.add(ts.getType(CAS.TYPE_NAME_STRING_ARRAY));
+    filterTypes.add(ts.getType(CAS.TYPE_NAME_STRING_LIST));
+  }
+
+  @Override
+  public void createControl(Composite parent) {
+    mInstanceComposite = new Composite(parent, SWT.NONE);
+
+    GridLayout layout = new GridLayout();
+
+    layout.numColumns = 1;
+
+    mInstanceComposite.setLayout(layout);
+
+    TypeSelectionPane mTypePane = new TypeSelectionPane(mInstanceComposite,
+            mCAS.getTypeSystem().getType(CAS.TYPE_NAME_TOP),mCAS.getTypeSystem(), filterTypes);
+
+    GridData typePaneData = new GridData();
+    typePaneData.grabExcessHorizontalSpace = true;
+    typePaneData.grabExcessVerticalSpace = false;
+    typePaneData.horizontalAlignment = SWT.FILL;
+    mTypePane.setLayoutData(typePaneData);
+
+    mFSList = new ListViewer(mInstanceComposite, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER);
+    GridData instanceListData = new GridData();
+    instanceListData.grabExcessHorizontalSpace = true;
+    instanceListData.grabExcessVerticalSpace = true;
+    instanceListData.horizontalAlignment = SWT.FILL;
+    instanceListData.verticalAlignment = SWT.FILL;
+    mFSList.getList().setLayoutData(instanceListData);
+    mFSList
+            .setContentProvider(new FeatureStructureTreeContentProvider(mDocument, mCAS));
+    mFSList.setLabelProvider(new FeatureStructureLabelProvider());
+
+    mFSList.setUseHashlookup(true);
+
+    mTypePane.setListener(new ITypePaneListener() {
+      public void typeChanged(Type newType) {
+        mCurrentType = newType;
+
+        mFSList.setInput(newType);
+      }
+    });
+
+    getSite().setSelectionProvider(mFSList);
+  }
+
+  /**
+   * Retrieves the control
+   *
+   * @return the control
+   */
+  @Override
+  public Control getControl() {
+    return mInstanceComposite;
+  }
+
+  /**
+   * Adds the following actions to the toolbar: {@link CreateAction} {@link DereferenceAction}
+   * {@link DeleteAction}
+   *
+   * @param menuManager
+   * @param toolBarManager
+   * @param statusLineManager
+   */
+  @Override
+  public void makeContributions(IMenuManager menuManager, IToolBarManager toolBarManager,
+          IStatusLineManager statusLineManager) {
+    // create
+    Action createAction = new CreateAction();
+    createAction.setText("Create");
+    createAction.setImageDescriptor(CasEditorPlugin.getTaeImageDescriptor(Images.ADD));
+    toolBarManager.add(createAction);
+
+    // delete
+    toolBarManager.add(ActionFactory.DELETE.create(getSite().getWorkbenchWindow()));
+  }
+
+  /**
+   * Sets global action handlers for: delete select all
+   *
+   * @param actionBars
+   */
+  @Override
+  public void setActionBars(IActionBars actionBars) {
+    actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), mDeleteAction);
+
+    getSite().getSelectionProvider().addSelectionChangedListener(mDeleteAction);
+
+    actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), mSelectAllAction);
+
+    super.setActionBars(actionBars);
+  }
+
+  /**
+   * Sets the focus.
+   */
+  @Override
+  public void setFocus() {
+    mInstanceComposite.setFocus();
+  }
+}
\ No newline at end of file

Propchange: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/fsview/FeatureStructureBrowserViewPage.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/fsview/FeatureStructureLabelProvider.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/fsview/FeatureStructureLabelProvider.java?rev=711402&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/fsview/FeatureStructureLabelProvider.java (added)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/fsview/FeatureStructureLabelProvider.java Tue Nov  4 12:59:10 2008
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.caseditor.editor.fsview;
+
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.impl.FeatureStructureImpl;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.caseditor.editor.FeatureValue;
+import org.apache.uima.caseditor.editor.util.Primitives;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * Provide the labels for the given {@link FeatureStructure}s.
+ */
+public final class FeatureStructureLabelProvider implements ILabelProvider {
+  public String getText(Object element) {
+    if (element instanceof FeatureValue) {
+      FeatureValue featureValue = (FeatureValue) element;
+      Object value = featureValue.getValue();
+
+      if (value == null) {
+        return featureValue.getFeature().getShortName() + ": null";
+      }
+
+      if (Primitives.isPrimitive(featureValue.getFeature())) {
+        return featureValue.getFeature().getShortName() + " : " + value.toString();
+      }
+
+      return featureValue.getFeature().getShortName();
+    }
+    else if (element instanceof IAdaptable) {
+
+      FeatureStructure structure = null;
+
+      if (((IAdaptable) element).getAdapter(AnnotationFS.class) != null) {
+        structure = (AnnotationFS) ((IAdaptable) element)
+                .getAdapter(AnnotationFS.class);
+      }
+
+      if (structure == null) {
+        structure = (FeatureStructure) ((IAdaptable) element).getAdapter(FeatureStructure.class);
+      }
+
+      return structure.getType().getShortName() + " (id=" +
+      		((FeatureStructureImpl) structure).getAddress() + ")";
+    }
+    else {
+      assert false : "Unexpected element!";
+
+      return element.toString();
+    }
+  }
+
+  public Image getImage(Object element) {
+    return null;
+  }
+
+  public boolean isLabelProperty(Object element, String property) {
+    return false;
+  }
+
+  public void addListener(ILabelProviderListener listener) {
+  }
+
+  public void removeListener(ILabelProviderListener listener) {
+  }
+
+  public void dispose() {
+  }
+}
\ No newline at end of file

Propchange: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/fsview/FeatureStructureLabelProvider.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/fsview/ITypePaneListener.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/fsview/ITypePaneListener.java?rev=711402&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/fsview/ITypePaneListener.java (added)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/fsview/ITypePaneListener.java Tue Nov  4 12:59:10 2008
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.caseditor.editor.fsview;
+
+import org.apache.uima.cas.Type;
+
+/**
+ * Notifies clients about type changes.
+ */
+public interface ITypePaneListener {
+  /**
+   * Called after the type was changed.
+   *
+   * @param newType
+   */
+  void typeChanged(Type newType);
+}
\ No newline at end of file

Propchange: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/fsview/ITypePaneListener.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/fsview/TypeSelectionPane.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/fsview/TypeSelectionPane.java?rev=711402&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/fsview/TypeSelectionPane.java (added)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/fsview/TypeSelectionPane.java Tue Nov  4 12:59:10 2008
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.caseditor.editor.fsview;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedList;
+
+import org.apache.uima.cas.Type;
+import org.apache.uima.cas.TypeSystem;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+/**
+ * The <code>TypeSelctionPane</code> notifies a listener about the selected type. Types are
+ * retrieved format the type system.
+ *
+ * TODO: Should be a types set to default ?
+ */
+public final class TypeSelectionPane extends Composite {
+
+  private ITypePaneListener mListener;
+
+  private TypeSystem mTypeSystem;
+
+  private Combo mTypeCombo;
+
+  public TypeSelectionPane(Composite parent, Type superType, TypeSystem typeSystem) {
+    this(parent, superType, typeSystem, new LinkedList<Type>());
+  }
+
+  public TypeSelectionPane(Composite parent, Type superType, TypeSystem typeSystem,
+          Collection<Type> filterTypes) {
+    super(parent, SWT.NONE);
+
+    mTypeSystem = typeSystem;
+
+    GridLayout layout = new GridLayout();
+    layout.numColumns = 2;
+
+    setLayout(layout);
+
+    Label mTypeLabel = new Label(this, SWT.NONE);
+    mTypeLabel.setText("Type: ");
+
+    GridData typeLabelData = new GridData();
+    typeLabelData.horizontalAlignment = SWT.LEFT;
+    mTypeLabel.setLayoutData(typeLabelData);
+
+    // insert list box
+
+    mTypeCombo = new Combo(this, SWT.READ_ONLY);
+    mTypeCombo.addModifyListener(new ModifyListener() {
+      public void modifyText(ModifyEvent e) {
+        Type newType = mTypeSystem.getType(mTypeCombo.getText());
+
+        if (mListener != null && newType != null) {
+          mListener.typeChanged(newType);
+        }
+      }
+    });
+
+    GridData typeComboData = new GridData();
+    typeComboData.grabExcessHorizontalSpace = true;
+    typeComboData.horizontalAlignment = SWT.FILL;
+    mTypeCombo.setLayoutData(typeComboData);
+
+    LinkedList<String> typeNameList = new LinkedList<String>();
+
+    typeNameList.add(superType.getName());
+
+    // get a collection of all types
+    Iterator typeIterator = mTypeSystem.getProperlySubsumedTypes(superType).iterator();
+
+    while (typeIterator.hasNext()) {
+      Type type = (Type) typeIterator.next();
+
+      if (!filterTypes.contains(type)) {
+        typeNameList.add(type.getName());
+      }
+    }
+
+    mTypeCombo.setItems(typeNameList.toArray(new String[typeNameList.size()]));
+
+    // select the super type, its the first element (and must be there)
+    mTypeCombo.select(0);
+  }
+
+  public void setListener(ITypePaneListener listener) {
+    mListener = listener;
+  }
+
+  public Type getType() {
+    return mTypeSystem.getType(mTypeCombo.getText());
+  }
+}
\ No newline at end of file

Propchange: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/fsview/TypeSelectionPane.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/fsview/package.html
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/fsview/package.html?rev=711402&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/fsview/package.html (added)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/fsview/package.html Tue Nov  4 12:59:10 2008
@@ -0,0 +1,32 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+	<!--
+	 ***************************************************************
+	 * Licensed to the Apache Software Foundation (ASF) under one
+	 * or more contributor license agreements.  See the NOTICE file
+	 * distributed with this work for additional information
+	 * regarding copyright ownership.  The ASF licenses this file
+	 * to you under the Apache License, Version 2.0 (the
+	 * "License"); you may not use this file except in compliance
+	 * with the License.  You may obtain a copy of the License at
+     *
+	 *   http://www.apache.org/licenses/LICENSE-2.0
+	 * 
+	 * Unless required by applicable law or agreed to in writing,
+	 * software distributed under the License is distributed on an
+	 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+	 * KIND, either express or implied.  See the License for the
+	 * specific language governing permissions and limitations
+	 * under the License.
+	 ***************************************************************
+   -->
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
+	<head>
+		<title>org.apache.uima.caseditor.editor.fsview</title>
+	</head>
+
+	<body>
+		<p>This package contains the feature structure view classes.</p>
+	</body>
+</html>
\ No newline at end of file

Propchange: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/fsview/package.html
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/AnnotationOutline.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/AnnotationOutline.java?rev=711402&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/AnnotationOutline.java (added)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/AnnotationOutline.java Tue Nov  4 12:59:10 2008
@@ -0,0 +1,401 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.caseditor.editor.outline;
+
+import java.util.Collection;
+
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.Type;
+import org.apache.uima.caseditor.editor.CasEditorPlugin;
+import org.apache.uima.caseditor.editor.Images;
+import org.apache.uima.caseditor.editor.AnnotationEditor;
+import org.apache.uima.caseditor.editor.AnnotationSelection;
+import org.apache.uima.caseditor.editor.CasEditorError;
+import org.apache.uima.caseditor.editor.IAnnotationEditorModifyListener;
+import org.apache.uima.caseditor.editor.action.DeleteFeatureStructureAction;
+import org.apache.uima.caseditor.editor.action.LowerLeftAnnotationSideAction;
+import org.apache.uima.caseditor.editor.action.LowerRightAnnotationSideAction;
+import org.apache.uima.caseditor.editor.action.MergeAnnotationAction;
+import org.apache.uima.caseditor.editor.action.WideLeftAnnotationSideAction;
+import org.apache.uima.caseditor.editor.action.WideRightAnnotationSideAction;
+import org.apache.uima.caseditor.editor.util.FeatureStructureTransfer;
+import org.eclipse.core.runtime.IAdaptable;
+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.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DragSource;
+import org.eclipse.swt.dnd.DragSourceEvent;
+import org.eclipse.swt.dnd.DragSourceListener;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.swt.widgets.TreeItem;
+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.views.contentoutline.ContentOutline;
+import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
+
+/**
+ * This outline view displays all <code>AnnotationFS</code>s of the current
+ * mode/type from the binded editor.
+ */
+public final class AnnotationOutline extends ContentOutlinePage 
+		implements ISelectionListener {
+  
+  /**
+   * This listener receive events from the bound editor.
+   */
+  protected class EditorListener implements IAnnotationEditorModifyListener {
+	  
+    /**
+     * Called if the editor annotation mode was changed.
+     *
+     * @param newMode
+     */
+    public void annotationModeChanged(Type newMode) {
+      changeAnnotationMode();
+      mTableViewer.refresh();
+    }
+
+	public void showAnnotationsChanged(Collection<Type> shownAnnotationTypes) {
+		mTableViewer.refresh();
+	}
+  }
+
+  /**
+   * Selects all elements in the tree viewer.
+   */
+  private class SelectAllAction extends Action {
+    /**
+     * Selects all elements in the tree viewer.
+     */
+    @Override
+    public void run() {
+      mTableViewer.getTree().selectAll();
+      mTableViewer.setSelection(mTableViewer.getSelection());
+    }
+  }
+
+  private OutlineStyles style = OutlineStyles.TYPE;
+  
+  private Composite mOutlineComposite;
+
+  private TreeViewer mTableViewer;
+
+  /**
+   * The <code>AnnotationEditor</code> which is bound to this outline view.
+   */
+  private AnnotationEditor editor;
+
+  /**
+   * Creates a new <code>AnnotationOutline</code> object.
+   *
+   * @param editor -
+   *          the editor to bind
+   */
+  public AnnotationOutline(AnnotationEditor editor) {
+    this.editor = editor;
+  }
+
+  /**
+   * Creates the outline table control.
+   *
+   * @param parent
+   */
+  @Override
+  public void createControl(Composite parent) {
+    mOutlineComposite = new Composite(parent, SWT.NONE);
+    mOutlineComposite.setLayout(new FillLayout());
+
+    createTableViewer(mOutlineComposite);
+    mOutlineComposite.layout(true);
+
+    getSite().getPage().addSelectionListener(this);
+    getSite().setSelectionProvider(mTableViewer);
+
+    changeAnnotationMode();
+
+    // TODO: create a listener interface ... for editor listener
+    editor.addAnnotationListener(new EditorListener());
+
+    DragSource source = new DragSource(mTableViewer.getTree(), DND.DROP_COPY);
+
+    source.setTransfer(new Transfer[] { FeatureStructureTransfer.getInstance() });
+
+    source.addDragListener(new DragSourceListener() {
+      TreeItem dragSourceItem = null;
+
+      public void dragStart(DragSourceEvent event) {
+        TreeItem[] selection = mTableViewer.getTree().getSelection();
+
+        if (selection.length > 0) {
+          event.doit = true;
+          dragSourceItem = selection[0];
+        } else {
+          event.doit = false;
+        }
+      }
+
+      public void dragSetData(DragSourceEvent event) {
+        IAdaptable adaptable = (IAdaptable) dragSourceItem.getData();
+
+        event.data = adaptable.getAdapter(FeatureStructure.class);
+      }
+
+      public void dragFinished(DragSourceEvent event) {
+        // not needed
+      }
+    });
+  }
+
+  /**
+   * Adds the actions to the tool bar.
+   *
+   * @param menuManager
+   * @param toolBarManager
+   * @param statusLineManager
+   */
+  @Override
+  public void makeContributions(IMenuManager menuManager, IToolBarManager toolBarManager,
+          IStatusLineManager statusLineManager) {
+    // wide left annotation side action
+    WideLeftAnnotationSideAction wideLeftAnnotationSideAction = new WideLeftAnnotationSideAction(
+            editor.getDocument());
+    wideLeftAnnotationSideAction.setText("Wides the left annotation side");
+    wideLeftAnnotationSideAction.setImageDescriptor(CasEditorPlugin
+            .getTaeImageDescriptor(Images.WIDE_LEFT_SIDE));
+
+    getSite().getSelectionProvider().addSelectionChangedListener(wideLeftAnnotationSideAction);
+
+    toolBarManager.add(wideLeftAnnotationSideAction);
+
+    // lower left annotation side action
+    LowerLeftAnnotationSideAction lowerLeftAnnotationSideAction = new LowerLeftAnnotationSideAction(
+            editor.getDocument());
+    lowerLeftAnnotationSideAction.setText("Lowers the left annotation side");
+    lowerLeftAnnotationSideAction.setImageDescriptor(CasEditorPlugin
+            .getTaeImageDescriptor(Images.LOWER_LEFT_SIDE));
+
+    getSite().getSelectionProvider().addSelectionChangedListener(lowerLeftAnnotationSideAction);
+
+    toolBarManager.add(lowerLeftAnnotationSideAction);
+
+    // lower right annotation side action
+    LowerRightAnnotationSideAction lowerRightAnnotionSideAction =
+      new LowerRightAnnotationSideAction(editor.getDocument());
+    lowerRightAnnotionSideAction.setText("Lowers the right annotation side");
+    lowerRightAnnotionSideAction.setImageDescriptor(CasEditorPlugin
+            .getTaeImageDescriptor(Images.LOWER_RIGHT_SIDE));
+
+    getSite().getSelectionProvider().addSelectionChangedListener(lowerRightAnnotionSideAction);
+
+    toolBarManager.add(lowerRightAnnotionSideAction);
+
+    // wide right annotation side action
+    WideRightAnnotationSideAction wideRightAnnotationSideAction = new WideRightAnnotationSideAction(
+            editor.getDocument());
+    wideRightAnnotationSideAction.setText("Wides the right annotation side");
+
+    wideRightAnnotationSideAction.setImageDescriptor(CasEditorPlugin
+            .getTaeImageDescriptor(Images.WIDE_RIGHT_SIDE));
+
+    getSite().getSelectionProvider().addSelectionChangedListener(wideRightAnnotationSideAction);
+
+    toolBarManager.add(wideRightAnnotationSideAction);
+
+    // merge action
+    MergeAnnotationAction mergeAction = new MergeAnnotationAction(editor.getDocument());
+    getSite().getSelectionProvider().addSelectionChangedListener(mergeAction);
+    mergeAction.setImageDescriptor(CasEditorPlugin.getTaeImageDescriptor(Images.MERGE));
+
+    toolBarManager.add(mergeAction);
+
+    // 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);
+  }
+
+  OutlineStyles currentStyle() {
+	  return style;
+  }
+  
+  void switchStyle(OutlineStyles style) {
+	  
+	  this.style = style;
+	  
+	  if (OutlineStyles.MODE.equals(style)) {
+		  mTableViewer.setContentProvider(new ModeSensitiveContentProvider(
+				  editor, mTableViewer));
+	  } else if (OutlineStyles.TYPE.equals(style)) {
+		  mTableViewer.setContentProvider(new TypeGroupedContentProvider(
+				  editor, mTableViewer));
+	  } else {
+		  throw new CasEditorError("Unkown style!");
+	  }
+
+		mTableViewer.refresh();
+  }
+  
+  /**
+   * Sets the focus.
+   */
+  @Override
+  public void setFocus() {
+    mOutlineComposite.setFocus();
+  }
+
+  private void changeAnnotationMode() {
+    mTableViewer.setInput(editor.getDocument());
+    mTableViewer.refresh();
+  }
+
+  private void createTableViewer(Composite parent) {
+    int style = SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION;
+
+    if (mTableViewer != null) {
+      mTableViewer.getTree().dispose();
+    }
+
+    mTableViewer = new TreeViewer(parent, style);
+
+    GridData gridData = new GridData(GridData.FILL_BOTH);
+    gridData.grabExcessVerticalSpace = true;
+    gridData.horizontalSpan = 3;
+    mTableViewer.getTree().setLayoutData(gridData);
+
+    mTableViewer.getTree().setLinesVisible(true);
+    mTableViewer.getTree().setHeaderVisible(true);
+
+    TreeColumn textColumn = new TreeColumn(mTableViewer.getTree(), SWT.LEFT);
+    textColumn.setText("Text");
+    textColumn.setWidth(130);
+
+    // performance optimization, the table can contain many items
+    mTableViewer.setUseHashlookup(false);
+
+    // Note: The type style is considered as the default
+    mTableViewer.setContentProvider(new TypeGroupedContentProvider(editor, mTableViewer));
+    
+    mTableViewer.setFilters(new ViewerFilter[]{new ViewerFilter() {
+
+    	// TODO: Improve this filter ... it is to sloooooooooow
+		@Override
+		public boolean select(Viewer viewer, Object parentElement,
+				Object element) {
+			Collection<Type> shownTypes = editor.getShownAnnotationTypes();
+			
+			if (element instanceof AnnotationTypeTreeNode) {
+				AnnotationTypeTreeNode typeNode = (AnnotationTypeTreeNode) element;
+				
+				if (shownTypes.contains(typeNode.getType()))
+					return true;
+				else 
+					return false;
+			}
+			else if (element instanceof AnnotationTreeNode) {
+				AnnotationTreeNode annotationNode = (AnnotationTreeNode) element;
+				
+				return shownTypes.contains(annotationNode.getAnnotation().getType());
+			}
+			else {
+				throw new CasEditorError("Unxexpected element type!");
+			}
+		}}});
+    
+    mTableViewer.setLabelProvider(new OutlineLabelProvider());
+
+    mTableViewer.setSorter(new OutlineTableSorter());
+
+    mTableViewer.setAutoExpandLevel(3);
+
+    // set input element here ... this is the document
+  }
+
+  public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+    boolean isForeignSelection = !(part instanceof ContentOutline && ((ContentOutline) part)
+            .getCurrentPage() == this);
+
+    if (isForeignSelection) {
+      if (selection instanceof StructuredSelection) {
+        AnnotationSelection annotations = new AnnotationSelection((StructuredSelection) selection);
+
+        if (!annotations.isEmpty()) {
+          ISelection tableSelection = new StructuredSelection(new AnnotationTreeNode(editor
+                  .getDocument(), annotations.getFirst()));
+
+          mTableViewer.setSelection(tableSelection, true);
+        }
+      }
+    }
+  }
+
+  @Override
+  public void dispose() {
+    // remove selection listener
+    getSite().getWorkbenchWindow().getSelectionService().removeSelectionListener(this);
+  }
+}
\ No newline at end of file

Propchange: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/AnnotationOutline.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/AnnotationTreeNode.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/AnnotationTreeNode.java?rev=711402&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/AnnotationTreeNode.java (added)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/AnnotationTreeNode.java Tue Nov  4 12:59:10 2008
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.caseditor.editor.outline;
+
+import java.util.List;
+
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.caseditor.editor.IDocument;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IAdaptable;
+
+/**
+ * TODO: add javadoc here
+ */
+public class AnnotationTreeNode implements IAdaptable {
+  private AnnotationTreeNode mParent;
+
+  private AnnotationTreeNodeList mChildren;
+
+  private AnnotationFS mAnnotation;
+
+  private IDocument mDocument;
+
+  AnnotationTreeNode(IDocument document, AnnotationFS annotation) {
+    Assert.isNotNull(document);
+    mDocument = document;
+
+    Assert.isNotNull(annotation);
+    mAnnotation = annotation;
+
+    mChildren = new AnnotationTreeNodeList(mDocument);
+  }
+
+  AnnotationTreeNode getParent() {
+    return mParent;
+  }
+
+  List<AnnotationTreeNode> getChildren() {
+    return mChildren.getElements();
+  }
+
+  AnnotationFS getAnnotation() {
+    return mAnnotation;
+  }
+
+  /**
+   * Checks if the given node is completly contained by the current node instance.
+   *
+   * @param node
+   * @return true if completly contained otherwise false
+   */
+  boolean isChild(AnnotationTreeNode node) {
+    return getAnnotation().getBegin() <= node.getAnnotation().getBegin()
+            && getAnnotation().getEnd() >= node.getAnnotation().getEnd();
+  }
+
+  void addChild(AnnotationTreeNode node) {
+    node.mParent = this;
+
+    mChildren.add(node);
+
+    mChildren.buildTree();
+  }
+
+  public Object getAdapter(Class adapter) {
+    // TODO:
+    // use ModelFeatureStructure
+    // create a AdapterFactory which just calls the
+    // ModelFeatureStructureAdpaterFactory
+
+    if (AnnotationFS.class.equals(adapter) || FeatureStructure.class.equals(adapter)) {
+      return getAnnotation();
+    }
+    else {
+      return null;
+    }
+  }
+
+  @Override
+  public int hashCode() {
+    final int PRIME = 31;
+    int result = 1;
+    result = PRIME * result + ((mAnnotation == null) ? 0 : mAnnotation.hashCode());
+    result = PRIME * result + ((mChildren == null) ? 0 : mChildren.hashCode());
+    result = PRIME * result + ((mParent == null) ? 0 : mParent.hashCode());
+    return mAnnotation.hashCode();
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if (getClass() != obj.getClass()) {
+      return false;
+    }
+
+    final AnnotationTreeNode other = (AnnotationTreeNode) obj;
+
+    /*
+     * if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() !=
+     * obj.getClass()) return false; final AnnotationTreeNode other = (AnnotationTreeNode) obj; if
+     * (mAnnotation == null) { if (other.mAnnotation != null) return false; } else if
+     * (!mAnnotation.equals(other.mAnnotation)) return false; if (mChildren == null) { if
+     * (other.mChildren != null) return false; } else if (!mChildren.equals(other.mChildren)) return
+     * false; if (mParent == null) { if (other.mParent != null) return false; } else if
+     * (!mParent.equals(other.mParent)) return false;
+     */
+    return other.getAnnotation().equals(mAnnotation);
+  }
+
+}
\ No newline at end of file

Propchange: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/AnnotationTreeNode.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/AnnotationTreeNodeList.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/AnnotationTreeNodeList.java?rev=711402&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/AnnotationTreeNodeList.java (added)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/AnnotationTreeNodeList.java Tue Nov  4 12:59:10 2008
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.caseditor.editor.outline;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.caseditor.editor.AnnotationDocument;
+import org.apache.uima.caseditor.editor.IDocument;
+
+/**
+ * The {@link AnnotationTreeNodeList} class can build a tree of
+ * {@link AnnotationTreeNode} objects.
+ * 
+ * Currently this is not used, because it slows down the Cas Editor UI
+ * if the document contains to many annotations.
+ * 
+ * TODO: Rename this class
+ */
+public class AnnotationTreeNodeList {
+  private List<AnnotationTreeNode> mElements = new ArrayList<AnnotationTreeNode>();
+
+  private IDocument mDocument;
+
+  AnnotationTreeNodeList(IDocument document) {
+    mDocument = document;
+  }
+
+  AnnotationTreeNodeList(AnnotationDocument document, Collection<AnnotationFS> annotations) {
+    mDocument = document;
+
+    for (AnnotationFS annotation : annotations) {
+      mElements.add(new AnnotationTreeNode(mDocument, annotation));
+    }
+
+    // buildTree();
+  }
+
+  List<AnnotationTreeNode> getElements() {
+    return mElements;
+  }
+
+  void add(AnnotationTreeNode node) {
+    mElements.add(node);
+  }
+
+  void remove(AnnotationTreeNode node) {
+    if (mElements.contains(node)) {
+      // insert children in the list
+      // remove the node from the list
+      // AnnotationTreeNode nodeFromList = mElements.get(mElements.indexOf(node));
+    } else {
+      // search the node
+    }
+
+    mElements.remove(node);
+  }
+
+  void buildTree() {
+    for (Iterator it = mElements.iterator(); it.hasNext();) {
+      AnnotationTreeNode aNode = (AnnotationTreeNode) it.next();
+
+      boolean isMoved = false;
+
+      for (AnnotationTreeNode bNode : mElements) {
+        // if identical do nothing and go on
+        if (aNode == bNode) {
+          continue;
+        }
+
+        if (bNode.isChild(aNode)) {
+          bNode.addChild(aNode);
+          isMoved = true;
+          break;
+        }
+      }
+
+      if (isMoved) {
+        it.remove();
+      }
+    }
+  }
+}
\ No newline at end of file

Propchange: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/AnnotationTreeNodeList.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/AnnotationTypeTreeNode.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/AnnotationTypeTreeNode.java?rev=711402&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/AnnotationTypeTreeNode.java (added)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/AnnotationTypeTreeNode.java Tue Nov  4 12:59:10 2008
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.caseditor.editor.outline;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.uima.cas.Type;
+import org.eclipse.core.runtime.IAdaptable;
+
+/**
+ * The {@link AnnotationTreeNode} is used to group annotations
+ * by their type. Only the {@link TypeGroupedContentProvider} creates
+ * {@link AnnotationTreeNode} objects. 
+ */
+public class AnnotationTypeTreeNode implements IAdaptable {
+
+	// annotation type
+	private Type type;
+	
+	private List<AnnotationTreeNode> annotations = new ArrayList<AnnotationTreeNode>();
+	
+	public AnnotationTypeTreeNode(Type type) {
+		this.type = type;
+	}
+	
+	public void add(AnnotationTreeNode annotation) {
+		annotations.add(annotation);
+	}
+	
+	public AnnotationTreeNode[] getAnnotations() {
+		return annotations.toArray(new AnnotationTreeNode[annotations.size()]);
+	}
+	
+	public void remove(AnnotationTreeNode annotation) {
+		annotations.remove(annotation);
+	}
+	
+	@SuppressWarnings("unchecked")
+	public Object getAdapter(Class adapter) {
+		
+		if (Type.class.equals(adapter)) {
+			return type;
+		}
+		
+		return null;
+	}
+	
+	@Override
+	public int hashCode() {
+		return type.hashCode();
+	} 
+	
+	@Override
+	public boolean equals(Object obj) {
+		
+		if (obj == this) {
+			return true;
+		}
+		else if (obj instanceof AnnotationTypeTreeNode) {
+			AnnotationTypeTreeNode otherTypeNode = (AnnotationTypeTreeNode) obj;
+			
+			return type.equals(otherTypeNode.type);
+		}
+		else {
+			return false;
+		}
+	}
+	
+	@Override
+	public String toString() {
+		return type.getShortName() + " #chhildren = " + annotations.size();
+	}
+
+	public Object getType() {
+		return type;
+	}
+}
\ No newline at end of file

Propchange: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/AnnotationTypeTreeNode.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/ModeSensitiveContentProvider.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/ModeSensitiveContentProvider.java?rev=711402&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/ModeSensitiveContentProvider.java (added)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/ModeSensitiveContentProvider.java Tue Nov  4 12:59:10 2008
@@ -0,0 +1,152 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.caseditor.editor.outline;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.caseditor.editor.AnnotationEditor;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.widgets.Display;
+
+/**
+   * This <code>OutlineContentProvider</code> synchronizes the <code>AnnotationFS</code>s with
+   * the <code>TableViewer</code>.
+   */
+  class ModeSensitiveContentProvider extends OutlineContentProviderBase {
+	  
+    private AnnotationTreeNodeList mAnnotationNodeList;
+
+    private Map<AnnotationFS, AnnotationTreeNode> mParentNodeLookup =
+      new HashMap<AnnotationFS, AnnotationTreeNode>();
+
+    protected ModeSensitiveContentProvider(AnnotationEditor editor, TreeViewer viewer) {
+    	super(editor, viewer);
+    	this.viewer = viewer;
+    }
+
+    /**
+     * Adds the added annotations to the viewer.
+     *
+     * @param annotations
+     */
+    @Override
+    public void addedAnnotation(Collection<AnnotationFS> annotations) {
+      for (AnnotationFS annotation : annotations) {
+        if (!annotation.getType().getName().equals(mEditor.getAnnotationMode().getName())) {
+          return;
+        }
+
+        final AnnotationTreeNode annotationNode = new AnnotationTreeNode(mEditor.getDocument(),
+                annotation);
+
+        mAnnotationNodeList.add(annotationNode);
+        // mAnnotationNodeList.buildTree();
+
+        Display.getDefault().syncExec(new Runnable() {
+          public void run() {
+        	  viewer.add(annotationNode.getParent() != null ? annotationNode.getParent()
+                    : mInputDocument, annotationNode);
+          }
+        });
+      }
+    }
+
+    /**
+     * Removes the removed annoations from the viewer.
+     *
+     * @param deletedAnnotations
+     */
+    @Override
+    public void removedAnnotation(Collection<AnnotationFS> deletedAnnotations) {
+      // TODO: what happens if someone removes an annoation which
+      // is not an element of this list e.g in the featruestructure view ?
+      final AnnotationTreeNode[] items = new AnnotationTreeNode[deletedAnnotations.size()];
+
+      int i = 0;
+      for (AnnotationFS annotation : deletedAnnotations) {
+        // TODO: maybe it is a problem if the parent is not correctly set!
+        items[i] = new AnnotationTreeNode(mEditor.getDocument(), annotation);
+        mAnnotationNodeList.remove(items[i]);
+        i++;
+      }
+
+
+      Display.getDefault().syncExec(new Runnable() {
+        public void run() {
+        	viewer.remove(items);
+        }
+      });
+    }
+
+    public void changed() {
+
+      Collection<AnnotationFS> annotations = mEditor.getDocument().getAnnotations(
+              mEditor.getAnnotationMode());
+
+      mAnnotationNodeList = annotations != null ? new AnnotationTreeNodeList(mEditor
+              .getDocument(), annotations) : null;
+
+      mParentNodeLookup.clear();
+
+      Display.getDefault().syncExec(new Runnable() {
+        public void run() {
+        	viewer.refresh();
+        }
+      });
+    }
+
+    /**
+	 * Retrieves all children of the {@link NlpModel}. That are the {@link NlpProject}s and
+	 * {@link IProject}s.
+	 *
+	 * @param inputElement
+	 *          the {@link NlpModel}
+	 *          
+	 * @return the nlp-projects and non-nlp projects
+	 */
+	public Object[] getElements(Object inputElement) {
+	  if (mAnnotationNodeList == null) {
+	    return new Object[0];
+	  }
+	
+	  return mAnnotationNodeList.getElements().toArray();
+	}
+
+	public Object getParent(Object element) {
+	  AnnotationTreeNode node = (AnnotationTreeNode) element;
+	
+	  return node.getParent();
+	}
+
+	public boolean hasChildren(Object element) {
+	  AnnotationTreeNode node = (AnnotationTreeNode) element;
+	
+	  return node.getChildren().size() > 0;
+	}
+
+	public Object[] getChildren(Object parentElement) {
+      AnnotationTreeNode node = (AnnotationTreeNode) parentElement;
+
+      return node.getChildren().toArray();
+    }
+  }
\ No newline at end of file

Propchange: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/ModeSensitiveContentProvider.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/OutlineContentProviderBase.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/OutlineContentProviderBase.java?rev=711402&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/OutlineContentProviderBase.java (added)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/OutlineContentProviderBase.java Tue Nov  4 12:59:10 2008
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.caseditor.editor.outline;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.caseditor.editor.AbstractAnnotationDocumentListener;
+import org.apache.uima.caseditor.editor.AnnotationDocument;
+import org.apache.uima.caseditor.editor.AnnotationEditor;
+import org.apache.uima.caseditor.editor.IDocument;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.widgets.Display;
+
+abstract class OutlineContentProviderBase extends AbstractAnnotationDocumentListener
+		implements ITreeContentProvider {
+	
+	protected AnnotationEditor mEditor;
+	  
+	protected IDocument mInputDocument;
+
+    protected TreeViewer viewer;
+
+    protected OutlineContentProviderBase(AnnotationEditor editor, TreeViewer viewer) {
+    	this.viewer = viewer;
+    	this.mEditor = editor;
+    }
+    
+    /**
+     * not implemented
+     */
+    public void dispose() {
+      // currently not implemented
+    }
+
+	/**
+	 * Gets called if the viewer input was changed. In this case, this only happens once if the
+	 * {@link AnnotationOutline} is initialized.
+	 *
+	 * @param viewer
+	 * @param oldInput
+	 * @param newInput
+	 */
+	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+	  if (oldInput != null) {
+	    ((AnnotationDocument) oldInput).removeChangeListener(this);
+	  }
+	
+	  if (newInput != null) {
+	    ((AnnotationDocument) newInput).addChangeListener(this);
+	
+	    mInputDocument = (IDocument) newInput;
+	    
+	    changed();
+	  }
+	}
+
+	/**
+	 * Updates the given annotation in the viewer.
+	 *
+	 * @param annotations
+	 */
+	@Override
+	protected void updatedAnnotation(Collection<AnnotationFS> featureStructres) {
+	  Collection<AnnotationFS> annotations = new ArrayList<AnnotationFS>(featureStructres.size());
+	
+	  for (FeatureStructure structure : featureStructres) {
+	    if (structure instanceof AnnotationFS) {
+	      annotations.add((AnnotationFS) structure);
+	    }
+	  }
+	
+	  final Object[] items = new Object[annotations.size()];
+	
+	  int i = 0;
+	  for (AnnotationFS annotation : annotations) {
+	    items[i++] = new AnnotationTreeNode(mEditor.getDocument(), annotation);
+	  }
+	
+	  Display.getDefault().syncExec(new Runnable() {
+	    public void run() {
+	    	viewer.update(items, null);
+	    }
+	  });
+	}
+}
\ No newline at end of file

Propchange: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/OutlineContentProviderBase.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/OutlineLabelProvider.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/OutlineLabelProvider.java?rev=711402&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/OutlineLabelProvider.java (added)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/OutlineLabelProvider.java Tue Nov  4 12:59:10 2008
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.caseditor.editor.outline;
+
+import org.apache.uima.cas.Type;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * This <code>OutlineLabelProvider</code> returns the covered text of an <code>AnnotationFS</code>.
+ */
+class OutlineLabelProvider extends LabelProvider implements ITableLabelProvider {
+  public Image getColumnImage(Object element, int columnIndex) {
+    // no image available, just return null
+    return null;
+  }
+
+  public String getColumnText(Object element, int columnIndex) {
+    // there is only one column, if column index something
+    // else than 0, then there is an error
+    if (columnIndex != 0) {
+      // ... just return null
+      return null;
+    }
+
+    AnnotationFS annotation = (AnnotationFS) ((IAdaptable) element).getAdapter(AnnotationFS.class);
+
+    if (annotation != null) {
+    	return getStringWithoutNewLine(annotation.getCoveredText());
+    }
+    
+    Type type = (Type) ((IAdaptable) element).getAdapter(Type.class);
+    
+    if (type != null) {
+    	return type.getShortName();
+    }
+    
+    return "Unkown type";
+  }
+
+  private static String getStringWithoutNewLine(String string) {
+    StringBuilder stringBuilder = new StringBuilder(string.length());
+
+    char stringChars[] = string.toCharArray();
+
+    for (char element : stringChars) {
+      if ((element == '\r')) {
+        continue;
+      }
+
+      if (element == '\n') {
+        stringBuilder.append(' ');
+        continue;
+      }
+
+      stringBuilder.append(element);
+    }
+
+    return stringBuilder.toString();
+  }
+}
\ No newline at end of file

Propchange: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/OutlineLabelProvider.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/OutlineStyles.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/OutlineStyles.java?rev=711402&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/OutlineStyles.java (added)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/OutlineStyles.java Tue Nov  4 12:59:10 2008
@@ -0,0 +1,7 @@
+package org.apache.uima.caseditor.editor.outline;
+
+public enum OutlineStyles {
+
+	MODE,
+	TYPE
+}

Propchange: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/OutlineStyles.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/OutlineTableSorter.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/OutlineTableSorter.java?rev=711402&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/OutlineTableSorter.java (added)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/OutlineTableSorter.java Tue Nov  4 12:59:10 2008
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.caseditor.editor.outline;
+
+
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.caseditor.editor.util.AnnotationComparator;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+
+/**
+ * Sorts <code>AnnotationFS</code>s for a Viewer. This implementation is based on
+ * <code>AnnotationComparator</code>.
+ *
+ * @see AnnotationComparator
+ */
+class OutlineTableSorter extends ViewerSorter {
+  private AnnotationComparator mComperator = new AnnotationComparator();
+
+  /**
+   * Uses <code>AnnotationComparator</code> to compare the both objects.
+   *
+   * @return int the return value is if aObject < bObject negative number, if aObject == bObject 0,
+   *         aObject > bObject a positive number or if both objects have different types 1.
+   *
+   * @see ViewerSorter
+   */
+  @Override
+  public int compare(Viewer viewer, Object aObject, Object bObject) {
+    int result = 1;
+
+    if ((aObject instanceof IAdaptable && bObject instanceof IAdaptable)) {
+      AnnotationFS aAnnotation = (AnnotationFS) ((IAdaptable) aObject)
+              .getAdapter(AnnotationFS.class);
+
+      AnnotationFS bAnnotation = (AnnotationFS) ((IAdaptable) bObject)
+              .getAdapter(AnnotationFS.class);
+
+      if (aAnnotation != null && bAnnotation != null)
+    	  result = mComperator.compare(aAnnotation, bAnnotation);
+    }
+
+    return result;
+  }
+}
\ No newline at end of file

Propchange: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/OutlineTableSorter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/SwitchStyleAction.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/SwitchStyleAction.java?rev=711402&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/SwitchStyleAction.java (added)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/SwitchStyleAction.java Tue Nov  4 12:59:10 2008
@@ -0,0 +1,35 @@
+package org.apache.uima.caseditor.editor.outline;
+
+import org.apache.uima.caseditor.editor.CasEditorError;
+import org.eclipse.jface.action.Action;
+
+/**
+ * This action triggers the switch of the outline style.
+ */
+public class SwitchStyleAction extends Action {
+	
+	private AnnotationOutline outline;
+	
+	SwitchStyleAction(AnnotationOutline outline) {
+		this.outline = outline;
+	}
+	
+	@Override
+	public String getText() {
+		return "Switch style";
+	}
+	
+	@Override
+	public void run() {
+		
+		if (OutlineStyles.MODE.equals(outline.currentStyle())) {
+			outline.switchStyle(OutlineStyles.TYPE);
+		}
+		else if (OutlineStyles.TYPE.equals(outline.currentStyle())) {
+			outline.switchStyle(OutlineStyles.MODE);
+		}
+		else {
+			throw new CasEditorError("Unkown style!");
+		}
+	}	
+}

Propchange: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/SwitchStyleAction.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/TypeGroupedContentProvider.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/TypeGroupedContentProvider.java?rev=711402&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/TypeGroupedContentProvider.java (added)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/TypeGroupedContentProvider.java Tue Nov  4 12:59:10 2008
@@ -0,0 +1,160 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.caseditor.editor.outline;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.FSIterator;
+import org.apache.uima.cas.Type;
+import org.apache.uima.cas.TypeSystem;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.cas.text.AnnotationIndex;
+import org.apache.uima.caseditor.editor.AnnotationDocument;
+import org.apache.uima.caseditor.editor.AnnotationEditor;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+
+/**
+ * TODO:
+ * Make it sensitive to show annotations menu from the editor ...
+ * 
+ * Who sends selection events which are not from the UI thread ?
+ */
+public class TypeGroupedContentProvider extends OutlineContentProviderBase {
+
+	// map of AnnotationTypeTreeNode
+	private Map<String, AnnotationTypeTreeNode> nameAnnotationTypeNodeMap = 
+			new HashMap<String, AnnotationTypeTreeNode>();
+
+	TypeGroupedContentProvider(AnnotationEditor editor, TreeViewer viewer) {
+		super(editor, viewer);
+	}
+	
+	@Override
+	protected void addedAnnotation(Collection<AnnotationFS> annotations) {
+
+		for (AnnotationFS annotation : annotations) {
+			String name = annotation.getType().getName();
+
+			AnnotationTypeTreeNode typeNode = nameAnnotationTypeNodeMap
+					.get(name);
+
+			AnnotationTreeNode annotationNode = new AnnotationTreeNode(mInputDocument, annotation); 
+			typeNode.add(annotationNode);
+			
+			viewer.add(typeNode, annotationNode);
+		}
+	}
+
+	@Override
+	protected void removedAnnotation(Collection<AnnotationFS> annotations) {
+
+		for (AnnotationFS annotation : annotations) {
+			String name = annotation.getType().getName();
+
+			AnnotationTypeTreeNode typeNode = nameAnnotationTypeNodeMap.get(name);
+
+			AnnotationTreeNode annotationNode = new AnnotationTreeNode(mInputDocument, annotation); 
+			typeNode.remove(annotationNode);
+			
+			viewer.remove(annotationNode);
+		}
+	}
+
+	public Object[] getElements(Object inputElement) {
+	
+		return nameAnnotationTypeNodeMap.values().toArray();
+	}
+
+	public Object getParent(Object element) {
+	
+		AnnotationTreeNode annotation = (AnnotationTreeNode) element;
+	
+		String name = annotation.getAnnotation().getType().getName();
+	
+		return nameAnnotationTypeNodeMap.get(name);
+	}
+
+	public boolean hasChildren(Object element) {
+		if (element instanceof AnnotationTypeTreeNode) {
+			AnnotationTypeTreeNode treeNode = (AnnotationTypeTreeNode) element;
+			
+			return treeNode.getAnnotations().length > 0;
+		} else {
+			return false;
+		}
+	}
+
+	public Object[] getChildren(Object parentElement) {
+
+		AnnotationTypeTreeNode typeNode = (AnnotationTypeTreeNode) parentElement;
+
+		return typeNode.getAnnotations();
+	}
+
+	public void dispose() {
+	}
+
+	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+		if (oldInput != null) {
+			((AnnotationDocument) oldInput).removeChangeListener(this);
+		}
+
+		if (newInput != null) {
+			mInputDocument = (AnnotationDocument) newInput;
+			
+			mInputDocument.addChangeListener(this);
+
+			nameAnnotationTypeNodeMap.clear();
+			
+			TypeSystem typeSystem = mInputDocument.getCAS().getTypeSystem();
+			
+			List<Type> types = typeSystem.getProperlySubsumedTypes(
+					typeSystem.getType(CAS.TYPE_NAME_ANNOTATION));
+			
+			for (Type type : types) {
+				
+				AnnotationTypeTreeNode typeNode = new AnnotationTypeTreeNode(type);
+				
+				nameAnnotationTypeNodeMap.put(type.getName(), typeNode);
+				
+				CAS cas = mInputDocument.getCAS();
+				
+				AnnotationIndex index = cas.getAnnotationIndex(type);
+				
+				for (FSIterator it = index.iterator(); it.hasNext(); ) {
+					AnnotationFS annotation = (AnnotationFS) it.next();
+					
+					typeNode.add(new AnnotationTreeNode(mInputDocument, annotation));
+				}
+			}
+			
+			viewer.refresh();
+		}
+	}
+
+	public void changed() {
+		// update on changes
+	}
+}
\ No newline at end of file

Propchange: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/TypeGroupedContentProvider.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/package.html
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/package.html?rev=711402&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/package.html (added)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/package.html Tue Nov  4 12:59:10 2008
@@ -0,0 +1,32 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+	<!--
+	 ***************************************************************
+	 * Licensed to the Apache Software Foundation (ASF) under one
+	 * or more contributor license agreements.  See the NOTICE file
+	 * distributed with this work for additional information
+	 * regarding copyright ownership.  The ASF licenses this file
+	 * to you under the Apache License, Version 2.0 (the
+	 * "License"); you may not use this file except in compliance
+	 * with the License.  You may obtain a copy of the License at
+     *
+	 *   http://www.apache.org/licenses/LICENSE-2.0
+	 * 
+	 * Unless required by applicable law or agreed to in writing,
+	 * software distributed under the License is distributed on an
+	 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+	 * KIND, either express or implied.  See the License for the
+	 * specific language governing permissions and limitations
+	 * under the License.
+	 ***************************************************************
+   -->
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
+	<head>
+		<title>org.apache.uima.caseditor.editor.outline</title>
+	</head>
+
+	<body>
+		<p>This package contains the outline classes.</p>
+	</body>
+</html>
\ No newline at end of file

Propchange: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/main/java/src/org/apache/uima/caseditor/editor/outline/package.html
------------------------------------------------------------------------------
    svn:mime-type = text/plain