You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by mb...@apache.org on 2007/02/14 15:35:47 UTC
svn commit: r507542 [7/10] - in /incubator/uima/sandbox/trunk/CasEditor: ./
icons/ src/ src/main/ src/main/java/ src/main/java/org/
src/main/java/org/apache/ src/main/java/org/apache/uima/
src/main/java/org/apache/uima/caseditor/ src/main/java/org/apac...
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/properties/validator/CellEditorValidatorFacotory.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/properties/validator/CellEditorValidatorFacotory.java?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/properties/validator/CellEditorValidatorFacotory.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/properties/validator/CellEditorValidatorFacotory.java Wed Feb 14 06:35:40 2007
@@ -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.properties.validator;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.jface.viewers.ICellEditorValidator;
+
+/**
+ * TODO: add javadoc here
+ *
+ * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
+ * @version $Revision: 1.2.2.2 $, $Date: 2007/01/04 15:00:53 $
+ */
+public class CellEditorValidatorFacotory {
+ private static Map<Class, ICellEditorValidator> sValidatorMap = new HashMap<Class, ICellEditorValidator>();
+
+ static {
+ sValidatorMap.put(Byte.class, new ByteCellEditorValidator());
+ sValidatorMap.put(Short.class, new ShortCellEditorValidator());
+ sValidatorMap.put(Integer.class, new IntegerCellEditorValidator());
+ sValidatorMap.put(Long.class, new LongCellEditorValidator());
+ sValidatorMap.put(Float.class, new FloatCellEditorValidator());
+ }
+
+ private CellEditorValidatorFacotory() {
+ // must not be instanciated
+ }
+
+ /**
+ * Retrives the appropritae {@link ICellEditorValidator} for the given class or none if not
+ * available.
+ *
+ * @param type
+ *
+ * @return {@link ICellEditorValidator} or null
+ */
+ public static ICellEditorValidator createValidator(Class type) {
+ if (type == null) {
+ throw new IllegalArgumentException("type must not be null!");
+ }
+
+ return sValidatorMap.get(type);
+ }
+}
\ No newline at end of file
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/properties/validator/FloatCellEditorValidator.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/properties/validator/FloatCellEditorValidator.java?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/properties/validator/FloatCellEditorValidator.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/properties/validator/FloatCellEditorValidator.java Wed Feb 14 06:35:40 2007
@@ -0,0 +1,51 @@
+/*
+ * 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.properties.validator;
+
+import org.eclipse.jface.viewers.ICellEditorValidator;
+
+/**
+ * This {@link ICellEditorValidator} validates {@link String} values which represents a
+ * {@link Float}.
+ *
+ * For validation {@link Float#parseFloat(String)} is used.
+ *
+ * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
+ * @version $Revision: 1.1.2.2 $, $Date: 2007/01/04 15:00:53 $
+ */
+class FloatCellEditorValidator implements ICellEditorValidator {
+ /**
+ * Checks if the given value is a valid {@link Float}.
+ *
+ * @param value
+ * @return null if valid otherwise an error message
+ */
+ public String isValid(Object value) {
+ assert value instanceof String;
+
+ try {
+ Float.parseFloat((String) value);
+ } catch (NumberFormatException e) {
+ return "Not a float!";
+ }
+
+ return null;
+ }
+}
\ No newline at end of file
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/properties/validator/IntegerCellEditorValidator.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/properties/validator/IntegerCellEditorValidator.java?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/properties/validator/IntegerCellEditorValidator.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/properties/validator/IntegerCellEditorValidator.java Wed Feb 14 06:35:40 2007
@@ -0,0 +1,51 @@
+/*
+ * 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.properties.validator;
+
+import org.eclipse.jface.viewers.ICellEditorValidator;
+
+/**
+ * This {@link ICellEditorValidator} validates {@link String} values which represents a
+ * {@link Integer}.
+ *
+ * For validation {@link Integer#parseInt(String)} is used.
+ *
+ * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
+ * @version $Revision: 1.1.2.2 $, $Date: 2007/01/04 15:00:53 $
+ */
+class IntegerCellEditorValidator implements ICellEditorValidator {
+ /**
+ * Checks if the given value is a valid {@link Integer}.
+ *
+ * @param value
+ * @return null if valid otherwise an error message
+ */
+ public String isValid(Object value) {
+ assert value instanceof String;
+
+ try {
+ Integer.parseInt((String) value);
+ } catch (NumberFormatException e) {
+ return "Not an integer!";
+ }
+
+ return null;
+ }
+}
\ No newline at end of file
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/properties/validator/LongCellEditorValidator.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/properties/validator/LongCellEditorValidator.java?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/properties/validator/LongCellEditorValidator.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/properties/validator/LongCellEditorValidator.java Wed Feb 14 06:35:40 2007
@@ -0,0 +1,51 @@
+/*
+ * 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.properties.validator;
+
+import org.eclipse.jface.viewers.ICellEditorValidator;
+
+/**
+ * This {@link ICellEditorValidator} validates {@link String} values which represents a {@link Long}.
+ *
+ * For validation {@link Long#parseLong(String)} is used.
+ *
+ * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
+ * @version $Revision: 1.1.2.2 $, $Date: 2007/01/04 15:00:53 $
+ */
+public class LongCellEditorValidator implements ICellEditorValidator {
+
+ /**
+ * Checks if the given value is a valid {@link Long}.
+ *
+ * @param value
+ * @return null if valid otherwise an error message
+ */
+ public String isValid(Object value) {
+ assert value instanceof String;
+
+ try {
+ Long.parseLong((String) value);
+ } catch (NumberFormatException e) {
+ return "Not a long!";
+ }
+
+ return null;
+ }
+}
\ No newline at end of file
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/properties/validator/ShortCellEditorValidator.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/properties/validator/ShortCellEditorValidator.java?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/properties/validator/ShortCellEditorValidator.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/properties/validator/ShortCellEditorValidator.java Wed Feb 14 06:35:40 2007
@@ -0,0 +1,52 @@
+/*
+ * 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.properties.validator;
+
+import org.eclipse.jface.viewers.ICellEditorValidator;
+
+/**
+ * This {@link ICellEditorValidator} validates {@link String} values which represents a
+ * {@link Short}.
+ *
+ * For validation {@link Short#parseShort(String)} is used.
+ *
+ * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
+ * @version $Revision: 1.1.2.2 $, $Date: 2007/01/04 15:00:53 $
+ */
+public class ShortCellEditorValidator implements ICellEditorValidator {
+
+ /**
+ * Checks if the given value is a valid {@link Short}.
+ *
+ * @param value
+ * @return null if valid otherwise an error message
+ */
+ public String isValid(Object value) {
+ assert value instanceof String;
+
+ try {
+ Short.parseShort((String) value);
+ } catch (NumberFormatException e) {
+ return "Not a short!";
+ }
+
+ return null;
+ }
+}
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/FeatureStructureTransfer.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/FeatureStructureTransfer.java?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/FeatureStructureTransfer.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/FeatureStructureTransfer.java Wed Feb 14 06:35:40 2007
@@ -0,0 +1,58 @@
+/*
+ * 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.ui;
+
+/**
+ * This class is able to transfer a {@link com.ibm.uima.cas.FeatureStructure}
+ * objects.
+ *
+ * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
+ * @version $Revision: 1.1.2.1 $, $Date: 2007/01/04 14:37:53 $
+ */
+public class FeatureStructureTransfer extends ObjectTransfer
+{
+ private static FeatureStructureTransfer sFeatureStructureTransfer;
+
+ /**
+ * Initializes a new instance.
+ *
+ * Note: Use {@link #getInstance() } to get a instance of
+ * the FeatureStructureTransfer, singleton pattern.
+ */
+ private FeatureStructureTransfer()
+ {
+ super("FeatureStructureTransfer");
+ }
+
+ /**
+ * Returns the singelton instance of the FeatureStructureTransfer.
+ *
+ * @return the lonly FeatureStructureTransfer object
+ */
+ public static FeatureStructureTransfer getInstance()
+ {
+ if (sFeatureStructureTransfer == null)
+ {
+ sFeatureStructureTransfer = new FeatureStructureTransfer();
+ }
+
+ return sFeatureStructureTransfer;
+ }
+}
\ No newline at end of file
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/Images.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/Images.java?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/Images.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/Images.java Wed Feb 14 06:35:40 2007
@@ -0,0 +1,80 @@
+/*
+ * 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.ui;
+
+/**
+ * This enumeration contains all images supplyed by the
+ * tae ui plugin.
+ *
+ * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
+ * @version $Revision: 1.2.2.1 $, $Date: 2007/01/04 14:37:53 $
+ */
+public enum Images
+{
+ /**
+ * The corpus image.
+ */
+ MODEL_CORPUS("model/corpus.gif"),
+
+ /**
+ * The document image.
+ */
+ MODEL_DOCUMENT("model/document.png"),
+
+ /**
+ * The source folder image.
+ */
+ MODEL_SOURCE_FOLDER("model/uima-source-folder.png"),
+
+ /**
+ * The config folder image.
+ */
+ MODEL_CONFIG_FOLDER("model/config.png"),
+
+ /**
+ * The enabled refresh icon.
+ */
+ EXPLORER_E_REFRESH("eceview16/refresh_nav.gif"),
+
+ /**
+ * The disabled refresh icon.
+ */
+ EXPLORER_D_REFRESH("dceview16/refresh_nav.gif");
+
+ private String mPath;
+
+ /**
+ * Initializes a new instance.
+ */
+ private Images(String path)
+ {
+ mPath = path;
+ }
+
+ /**
+ * Retrives the path
+ *
+ * @return the path
+ */
+ public String getPath()
+ {
+ return mPath;
+ }
+}
\ No newline at end of file
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/NlpPerspectiveFactory.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/NlpPerspectiveFactory.java?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/NlpPerspectiveFactory.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/NlpPerspectiveFactory.java Wed Feb 14 06:35:40 2007
@@ -0,0 +1,94 @@
+/*
+ * 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.ui;
+
+
+import org.apache.uima.caseditor.ui.corpusview.CorpusExplorerView;
+import org.apache.uima.caseditor.ui.wizards.NewCorpusWizard;
+import org.apache.uima.caseditor.ui.wizards.NlpProjectWizard;
+import org.eclipse.ui.IFolderLayout;
+import org.eclipse.ui.IPageLayout;
+import org.eclipse.ui.IPerspectiveFactory;
+
+/**
+ * This <code>PerspectiveFactory</code> generates the intial layout
+ * for the NLP perspective.
+ *
+ * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
+ * @version $Revision: 1.4.2.1 $, $Date: 2007/01/04 14:37:53 $
+ */
+public class NlpPerspectiveFactory implements IPerspectiveFactory
+{
+ /**
+ * ID of the perpective factory. Use this ID for example in the plugin.xml
+ * file.
+ */
+ public static String ID = "Annotator.perspective.NLP";
+
+ /**
+ * Define the initial layout of the nlp perspective
+ */
+ public void createInitialLayout(IPageLayout layout)
+ {
+ defineActions(layout);
+ defineLayout(layout);
+ }
+
+ private void defineActions(IPageLayout layout)
+ {
+ // add "new wizards"
+ layout.addNewWizardShortcut(NlpProjectWizard.ID);
+ layout.addNewWizardShortcut(NewCorpusWizard.ID);
+ layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.folder");
+ layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.file");
+
+ // layout.addNewWizardShortcut("Annotator.NewDocumentWizard");
+
+ // add "show views"
+ layout.addShowViewShortcut(CorpusExplorerView.ID);
+ layout.addShowViewShortcut(IPageLayout.ID_OUTLINE);
+ layout.addShowViewShortcut(IPageLayout.ID_PROP_SHEET);
+
+ // add "open perpective"
+ layout.addPerspectiveShortcut(NlpPerspectiveFactory.ID);
+ }
+
+ private void defineLayout(IPageLayout layout)
+ {
+ String editorArea = layout.getEditorArea();
+
+ // left views
+ IFolderLayout left = layout.createFolder("left", IPageLayout.LEFT,
+ 0.19f, editorArea);
+ left.addView(CorpusExplorerView.ID);
+
+ // right views
+ IFolderLayout right = layout.createFolder("right", IPageLayout.RIGHT,
+ 0.70f, editorArea);
+
+ right.addView(IPageLayout.ID_OUTLINE);
+
+ // bottom views
+ IFolderLayout bottom = layout.createFolder("rightBottom",
+ IPageLayout.BOTTOM, 0.75f, editorArea);
+
+ bottom.addView(IPageLayout.ID_PROP_SHEET);
+ }
+}
\ No newline at end of file
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/ObjectTransfer.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/ObjectTransfer.java?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/ObjectTransfer.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/ObjectTransfer.java Wed Feb 14 06:35:40 2007
@@ -0,0 +1,98 @@
+/*
+ * 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.ui;
+
+import java.util.Arrays;
+
+
+import org.apache.uima.caseditor.core.util.IDGenerator;
+import org.eclipse.swt.dnd.ByteArrayTransfer;
+import org.eclipse.swt.dnd.TransferData;
+
+/**
+ * This class is able to transfer an {@link Object} object. The object gets
+ * saved and only an Id is transfered.
+ *
+ * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
+ * @version $Revision: 1.1.2.1 $, $Date: 2007/01/04 14:37:53 $
+ */
+public abstract class ObjectTransfer extends ByteArrayTransfer
+{
+ private IDGenerator mIdGenerator = IDGenerator.getInstance();
+
+ private String mTransferName;
+
+ private int mTransferID;
+
+ private byte[] mCurrentID;
+
+ private Object mObject;
+
+ /**
+ * Initializes a new instance with a name.
+ *
+ * @param name - the name of current instance.
+ */
+ protected ObjectTransfer(String name)
+ {
+ mTransferName = name;
+
+ mTransferID = registerType(mTransferName);
+ }
+
+ @Override
+ protected void javaToNative(Object object, TransferData transferData)
+ {
+ mCurrentID = mIdGenerator.nextUniqueID();
+
+ mObject = object;
+
+ if (transferData != null)
+ {
+ super.javaToNative(mCurrentID, transferData);
+ }
+ }
+
+ @Override
+ protected Object nativeToJava(TransferData transferData)
+ {
+ byte bytes[] = (byte[]) super.nativeToJava(transferData);
+
+ return (Arrays.equals(mCurrentID, bytes)) ? mObject : null;
+ }
+
+ @Override
+ protected int[] getTypeIds()
+ {
+ return new int[]
+ {
+ mTransferID
+ };
+ }
+
+ @Override
+ protected String[] getTypeNames()
+ {
+ return new String[]
+ {
+ mTransferName
+ };
+ }
+}
\ No newline at end of file
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/TaeUiPlugin.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/TaeUiPlugin.java?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/TaeUiPlugin.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/TaeUiPlugin.java Wed Feb 14 06:35:40 2007
@@ -0,0 +1,158 @@
+/*
+ * 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.ui;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+
+import org.apache.uima.caseditor.core.TaeCorePlugin;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * TODO: add javadoc here
+ *
+ * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
+ * @version $Revision: 1.4.2.1 $, $Date: 2007/01/04 14:37:53 $
+ */
+public class TaeUiPlugin extends AbstractUIPlugin
+{
+ /**
+ * The Tae plugin id.
+ */
+ public static final String ID = "net.sf.tae.ui";
+
+ private static final String ICONS_PATH = "icons/";
+
+ /**
+ * The shared instance.
+ */
+ private static TaeUiPlugin sPlugin;
+
+ /**
+ * Resource bundle.
+ */
+ private ResourceBundle mResourceBundle;
+
+ /**
+ * Initializes a new instance.
+ */
+ public TaeUiPlugin()
+ {
+ super();
+
+ TaeUiPlugin.sPlugin = this;
+ }
+
+ /**
+ * This method is called upon plug-in activation
+ *
+ * @param context
+ * @throws Exception
+ */
+ @Override
+ public void start(BundleContext context) throws Exception
+ {
+ super.start(context);
+ }
+
+ /**
+ * This method is called when the plug-in is stopped.
+ *
+ * @param context
+ * @throws Exception
+ */
+ @Override
+ public void stop(BundleContext context) throws Exception
+ {
+ super.stop(context);
+
+ TaeUiPlugin.sPlugin = null;
+ mResourceBundle = null;
+ }
+
+ /**
+ * Returns the shared instance.
+ *
+ * @return the TaeUiPlugin
+ */
+ public static TaeUiPlugin getDefault()
+ {
+ return TaeUiPlugin.sPlugin;
+ }
+
+ /**
+ * Returns the string from the plugin's resource bundle, or 'key' if not
+ * found.
+ *
+ * @param key
+ * @return resource string
+ */
+ public static String getResourceString(String key)
+ {
+ ResourceBundle bundle = TaeCorePlugin.getDefault().getResourceBundle();
+
+ try
+ {
+ return (bundle != null) ? bundle.getString(key) : key;
+ }
+ catch (MissingResourceException e)
+ {
+ return key;
+ }
+ }
+
+ /**
+ * Returns the plugin's resource bundle.
+ *
+ * @return the ResourceBbundle or null if missing
+ */
+ public ResourceBundle getResourceBundle()
+ {
+ try
+ {
+ if (mResourceBundle == null)
+ {
+ mResourceBundle = ResourceBundle
+ .getBundle("Annotator.AnnotatorPluginResources");
+ }
+ }
+ catch (MissingResourceException x)
+ {
+ mResourceBundle = null;
+ }
+
+ return mResourceBundle;
+ }
+
+ /**
+ * Retrives an image.
+ *
+ * @param image
+ * @return the requested image if not available null
+ */
+ public static ImageDescriptor getTaeImageDescriptor(Images image)
+ {
+ return imageDescriptorFromPlugin(TaeUiPlugin.ID,
+ TaeUiPlugin.ICONS_PATH + image.getPath());
+ }
+}
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/action/AnnotatorActionRunnable.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/action/AnnotatorActionRunnable.java?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/action/AnnotatorActionRunnable.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/action/AnnotatorActionRunnable.java Wed Feb 14 06:35:40 2007
@@ -0,0 +1,116 @@
+/*
+ * 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.ui.action;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Collection;
+
+
+import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
+import org.apache.uima.analysis_engine.TextAnalysisEngine;
+import org.apache.uima.caseditor.core.IDocument;
+import org.apache.uima.caseditor.core.model.DocumentElement;
+import org.apache.uima.caseditor.core.uima.AnnotatorConfiguration;
+import org.apache.uima.resource.ResourceInitializationException;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+
+/**
+ * TODO: synchronize filesystem after annotator run.
+ * TODO: move this over to core plugin
+ *
+ * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
+ * @version $Revision: 1.4.2.1 $, $Date: 2007/01/04 14:37:53 $
+ */
+public final class AnnotatorActionRunnable implements IRunnableWithProgress
+{
+ private AnnotatorConfiguration mAnnotatorConfiguration;
+
+ private Collection<DocumentElement> mDocuments;
+
+ /**
+ * Initializes a new instance.
+ *
+ * @param annotator
+ * @param documents
+ * @param shell
+ */
+ public AnnotatorActionRunnable(AnnotatorConfiguration annotator,
+ Collection<DocumentElement> documents)
+ {
+ mAnnotatorConfiguration = annotator;
+ mDocuments = documents;
+ }
+
+ /**
+ * Excecutes the action.
+ */
+ public void run(IProgressMonitor monitor)
+ throws InvocationTargetException, InterruptedException
+ {
+ monitor.beginTask("Tagging", IProgressMonitor.UNKNOWN);
+
+ monitor.subTask("Initializing tagger, "
+ + "please stand by.");
+
+ TextAnalysisEngine annotatorInstance;
+
+ try
+ {
+ annotatorInstance = mAnnotatorConfiguration
+ .createAnnotator();
+ }
+ catch (final ResourceInitializationException e)
+ {
+ throw new InvocationTargetException(e);
+ }
+
+ monitor.subTask("Tagging, please stand by.");
+
+ for (IDocument document : mDocuments)
+ {
+ try
+ {
+ annotatorInstance.process(document.getCAS());
+ }
+ catch (AnalysisEngineProcessException e)
+ {
+ throw new InvocationTargetException(e);
+ }
+
+ // TODO: refactor here, add working copy support
+ try
+ {
+ ((DocumentElement) document).writeToFile();
+ }
+ catch (CoreException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ annotatorInstance.destroy();
+ annotatorInstance = null;
+
+ monitor.done();
+ }
+}
\ No newline at end of file
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/action/ConsumerActionRunnable.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/action/ConsumerActionRunnable.java?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/action/ConsumerActionRunnable.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/action/ConsumerActionRunnable.java Wed Feb 14 06:35:40 2007
@@ -0,0 +1,310 @@
+/*
+ * 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.ui.action;
+
+import java.io.File;
+import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Collection;
+
+
+import org.apache.uima.UIMAFramework;
+import org.apache.uima.analysis_engine.TextAnalysisEngine;
+import org.apache.uima.cas.CAS;
+import org.apache.uima.caseditor.core.model.CorpusElement;
+import org.apache.uima.caseditor.core.model.NlpProject;
+import org.apache.uima.caseditor.core.uima.CasConsumerConfiguration;
+import org.apache.uima.caseditor.uima.CorporaCollectionReader;
+import org.apache.uima.collection.CollectionProcessingManager;
+import org.apache.uima.collection.CollectionReader;
+import org.apache.uima.collection.CollectionReaderDescription;
+import org.apache.uima.collection.EntityProcessStatus;
+import org.apache.uima.collection.StatusCallbackListener;
+import org.apache.uima.resource.ResourceConfigurationException;
+import org.apache.uima.resource.ResourceInitializationException;
+import org.apache.uima.resource.ResourceSpecifier;
+import org.apache.uima.resource.metadata.FsIndexDescription;
+import org.apache.uima.resource.metadata.ProcessingResourceMetaData;
+import org.apache.uima.resource.metadata.TypeSystemDescription;
+import org.apache.uima.util.InvalidXMLException;
+import org.apache.uima.util.XMLInputSource;
+import org.apache.uima.util.XMLParser;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+
+/**
+ * This action launches the cpm with the configured cas consumer.
+ *
+ * TODO: move over to core plugin
+ *
+ * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
+ * @version $Revision: 1.3.2.1 $, $Date: 2007/01/04 14:37:53 $
+ */
+public class ConsumerActionRunnable implements IRunnableWithProgress
+{
+ private CasConsumerConfiguration mConfiguration;
+
+ private Collection<CorpusElement> mCorpora;
+
+ private boolean mIsProcessing = true;
+
+ /**
+ * Initializes a new instance.
+ *
+ * @param config
+ * @param corpora
+ */
+ public ConsumerActionRunnable(CasConsumerConfiguration config,
+ Collection<CorpusElement> corpora)
+ {
+ mConfiguration = config;
+
+ mCorpora = corpora;
+ }
+
+ public void run(IProgressMonitor monitor)
+ throws InvocationTargetException, InterruptedException
+ {
+ monitor.beginTask("Consuming", IProgressMonitor.UNKNOWN);
+
+ monitor.subTask("Initializing, please stand by.");
+
+ InputStream inCollectionReaderDescripton = getClass()
+ .getResourceAsStream("CorporaCollectionReader.xml");
+
+ // TODO: inCollectionReaderDescripton check for null
+
+ CollectionReaderDescription collectionReaderDescripton;
+ try
+ {
+ collectionReaderDescripton = (CollectionReaderDescription)
+ UIMAFramework.getXMLParser().parseResourceSpecifier(
+ new XMLInputSource(inCollectionReaderDescripton,
+ new File("")));
+ }
+ catch (InvalidXMLException e)
+ {
+ throw new InvocationTargetException(e, "CorporaCollectionReader.xml"
+ + " could ne be parsed!");
+ }
+
+ NlpProject project =
+ mConfiguration.getConsumerElement().getNlpProject();
+
+ InputStream inTypeSystemDescription;
+ try
+ {
+ inTypeSystemDescription =
+ project.getDotCorpus().getTypeSystemFile().getContents();
+ }
+ catch (CoreException e)
+ {
+ throw new InvocationTargetException(e);
+ }
+
+ TypeSystemDescription typeSystemDescriptor;
+ try
+ {
+ typeSystemDescriptor = UIMAFramework.getXMLParser()
+ .parseTypeSystemDescription(
+ new XMLInputSource(inTypeSystemDescription, new File("")));
+
+ typeSystemDescriptor.resolveImports();
+ }
+ catch (InvalidXMLException e)
+ {
+ throw new InvocationTargetException(e);
+ }
+
+// set type system to collection reader
+ ProcessingResourceMetaData collectionReaderMetaData =
+ collectionReaderDescripton.getCollectionReaderMetaData();
+
+ collectionReaderMetaData.setTypeSystem(typeSystemDescriptor);
+
+ XMLParser xmlParser = UIMAFramework.getXMLParser();
+
+ InputStream inIndex = getClass().getClassLoader().getResourceAsStream(
+ "net/sf/tae/core/Index.xml");
+
+ if (inIndex == null)
+ {
+ throw new InvocationTargetException(null,
+ "net/sf/tae/ui/action/Index.xml"
+ + " is missing on the classpath");
+ }
+
+ XMLInputSource xmlIndexSource = new XMLInputSource(inIndex,
+ new File(""));
+
+ xmlIndexSource = new XMLInputSource(inIndex, new File(""));
+
+ FsIndexDescription indexDesciptor;
+
+ try
+ {
+ indexDesciptor = (FsIndexDescription) xmlParser
+ .parse(xmlIndexSource);
+ }
+ catch (InvalidXMLException e)
+ {
+ throw new InvocationTargetException(e);
+ }
+
+ collectionReaderMetaData.setFsIndexes(new FsIndexDescription[]
+ {indexDesciptor});
+
+ CollectionReader collectionReader;
+ try
+ {
+ collectionReader = UIMAFramework
+ .produceCollectionReader(collectionReaderDescripton);
+ }
+ catch (ResourceInitializationException e)
+ {
+ throw new InvocationTargetException(e);
+ }
+
+ ((CorporaCollectionReader) collectionReader).setCorpora(mCorpora);
+
+ InputStream in = getClass().getResourceAsStream("DummyTAE.xml");
+
+// load dummy descriptor
+ ResourceSpecifier textAnalysisEngineSpecifier;
+ try
+ {
+ textAnalysisEngineSpecifier = UIMAFramework.getXMLParser()
+ .parseResourceSpecifier(
+ new XMLInputSource(in, new File("")));
+ }
+ catch (InvalidXMLException e)
+ {
+ throw new InvocationTargetException(e);
+ }
+
+ TextAnalysisEngine textAnalysisEngine;
+ try
+ {
+ textAnalysisEngine = UIMAFramework
+ .produceTAE(textAnalysisEngineSpecifier);
+ }
+ catch (ResourceInitializationException e)
+ {
+ throw new InvocationTargetException(e);
+ }
+
+ CollectionProcessingManager collectionProcessingEngine = UIMAFramework
+ .newCollectionProcessingManager();
+
+ try
+ {
+ collectionProcessingEngine.setAnalysisEngine(textAnalysisEngine);
+ }
+ catch (ResourceConfigurationException e)
+ {
+ throw new InvocationTargetException(e);
+ }
+
+ try
+ {
+ collectionProcessingEngine.addCasConsumer(mConfiguration
+ .createConsumer());
+ }
+ catch (ResourceConfigurationException e)
+ {
+ throw new InvocationTargetException(e);
+ }
+
+ collectionProcessingEngine.setPauseOnException(false);
+
+ collectionProcessingEngine.addStatusCallbackListener(
+ new StatusCallbackListener(){
+
+ public void entityProcessComplete(CAS cas,
+ EntityProcessStatus status)
+ {
+ // not implemented
+ }
+
+ public void aborted()
+ {
+ finishProcessing();
+ }
+
+ public void batchProcessComplete()
+ {
+ // not implemented
+ }
+
+ public void collectionProcessComplete()
+ {
+ finishProcessing();
+ }
+
+ public void initializationComplete()
+ {
+ // not implemented
+ }
+
+ public void paused()
+ {
+ // not implemented
+ }
+
+ public void resumed()
+ {
+ // not implemented
+ }
+
+ private void finishProcessing()
+ {
+ synchronized (ConsumerActionRunnable.this)
+ {
+ mIsProcessing = false;
+ ConsumerActionRunnable.this.notifyAll();
+ }
+ }
+ });
+
+ monitor.subTask("Feeding comsumer, please stand by.");
+
+ try
+ {
+ collectionProcessingEngine.process(collectionReader);
+ }
+ catch (ResourceInitializationException e)
+ {
+ throw new InvocationTargetException(e);
+ }
+
+ synchronized(this)
+ {
+ // TODO: for cancel poll here
+ // and call .stop()
+ while (mIsProcessing)
+ {
+ wait();
+ }
+ }
+
+ monitor.done();
+ }
+}
\ No newline at end of file
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/action/CorporaCollectionReader.xml
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/action/CorporaCollectionReader.xml?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/action/CorporaCollectionReader.xml (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/action/CorporaCollectionReader.xml Wed Feb 14 06:35:40 2007
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<collectionReaderDescription xmlns="http://uima.watson.ibm.com/resourceSpecifier">
+ <frameworkImplementation>com.ibm.uima.java</frameworkImplementation>
+ <implementationName>net.sf.tae.uima.CorporaCollectionReader</implementationName>
+ <processingResourceMetaData>
+ <name>Corpora Collection Reader</name>
+ <description></description>
+ <version>1.0</version>
+ <vendor>Calcucare GmbH</vendor>
+ </processingResourceMetaData>
+</collectionReaderDescription>
\ No newline at end of file
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/action/DummyTAE.xml
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/action/DummyTAE.xml?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/action/DummyTAE.xml (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/action/DummyTAE.xml Wed Feb 14 06:35:40 2007
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<taeDescription xmlns="http://uima.watson.ibm.com/resourceSpecifier">
+ <frameworkImplementation>com.ibm.uima.java</frameworkImplementation>
+ <primitive>true</primitive>
+ <annotatorImplementationName>net.sf.tae.uima.DummyAnnotator</annotatorImplementationName>
+ <analysisEngineMetaData>
+ <name>DummyAnnotator</name>
+ <description></description>
+ <version>1.0</version>
+ <vendor>sourceforge.net/projects/tae</vendor>
+ <capabilities>
+ <capability>
+ <inputs/>
+ <outputs/>
+ <languagesSupported>
+ <language>en</language>
+ </languagesSupported>
+ </capability>
+ </capabilities>
+ </analysisEngineMetaData>
+</taeDescription>
\ No newline at end of file
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/action/Index.xml
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/action/Index.xml?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/action/Index.xml (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/action/Index.xml Wed Feb 14 06:35:40 2007
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<fsIndexDescription>
+ <label>TOPIndex</label>
+ <typeName>uima.cas.TOP</typeName>
+ <kind>sorted</kind>
+</fsIndexDescription>
\ No newline at end of file
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/action/RunnableAction.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/action/RunnableAction.java?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/action/RunnableAction.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/action/RunnableAction.java Wed Feb 14 06:35:40 2007
@@ -0,0 +1,110 @@
+/*
+ * 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.ui.action;
+
+import java.lang.reflect.InvocationTargetException;
+
+
+import org.apache.uima.UIMAException;
+import org.apache.uima.caseditor.core.TaeCorePlugin;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.util.Assert;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.progress.IProgressService;
+
+/**
+ * TODO: add javadoc here
+ *
+ * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
+ * @version $Revision: 1.2.2.1 $, $Date: 2007/01/04 14:37:53 $
+ */
+public class RunnableAction extends Action
+{
+ private Shell mShell;
+ private IRunnableWithProgress mRunnable;
+ private String mName;
+
+ /**
+ * Initializes a new instance.
+ *
+ * @param shell
+ * @param name
+ * @param runnable
+ */
+ public RunnableAction(Shell shell, String name, IRunnableWithProgress runnable)
+ {
+ Assert.isNotNull(shell);
+ mShell = shell;
+
+ Assert.isNotNull(name);
+ mName = name;
+ setText(name);
+
+ Assert.isNotNull(runnable);
+ mRunnable = runnable;
+ }
+
+ @Override
+ public void run()
+ {
+ IProgressService progressService = PlatformUI.getWorkbench()
+ .getProgressService();
+
+ try
+ {
+ progressService.run(true, false, mRunnable);
+ }
+ catch (InvocationTargetException e)
+ {
+ Throwable cause = e.getCause();
+
+ Status status;
+ // TODO: Workarround for UIMAException problems ...
+ if (cause instanceof UIMAException)
+ {
+ UIMAException uimaException = (UIMAException) cause;
+
+ Object[] argument = uimaException.getArguments();
+
+ status = new Status(IStatus.ERROR, TaeCorePlugin.ID, 0,
+ argument.length > 0 ? argument[0].toString() :
+ "Unkown error, see log.", cause);
+ }
+ else
+ {
+ status = new Status(IStatus.ERROR, TaeCorePlugin.ID, 0,
+ cause.getMessage() != null ? cause.getMessage() :
+ "Unkown error, see log.", cause);
+ }
+
+ ErrorDialog.openError(mShell, "Unexpected exception in " +
+ mName, null, status);
+ }
+ catch (InterruptedException e)
+ {
+ // task terminated ... just ignore
+ }
+ }
+}
\ No newline at end of file
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/action/package.html
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/action/package.html?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/action/package.html (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/action/package.html Wed Feb 14 06:35:40 2007
@@ -0,0 +1,12 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
+ <head>
+ <title>net.sf.tae.corpusview</title>
+ </head>
+
+ <body>
+ <p>This package contains the action classes.</p>
+ </body>
+</html>
\ No newline at end of file
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/AnnotatorActionGroup.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/AnnotatorActionGroup.java?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/AnnotatorActionGroup.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/AnnotatorActionGroup.java Wed Feb 14 06:35:40 2007
@@ -0,0 +1,150 @@
+/*
+ * 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.ui.corpusview;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedList;
+
+
+import org.apache.uima.caseditor.core.model.AnnotatorElement;
+import org.apache.uima.caseditor.core.model.CorpusElement;
+import org.apache.uima.caseditor.core.model.DocumentElement;
+import org.apache.uima.caseditor.core.model.NlpProject;
+import org.apache.uima.caseditor.core.model.UimaConfigurationElement;
+import org.apache.uima.caseditor.core.model.UimaSourceFolder;
+import org.apache.uima.caseditor.core.uima.AnnotatorConfiguration;
+import org.apache.uima.caseditor.ui.action.AnnotatorActionRunnable;
+import org.apache.uima.caseditor.ui.action.RunnableAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.actions.ActionGroup;
+
+/**
+ * This is an action group for annotator actions.
+ *
+ * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
+ * @version $Revision: 1.2.2.1 $, $Date: 2007/01/04 14:37:51 $
+ */
+final class AnnotatorActionGroup extends ActionGroup
+{
+ private Shell mShell;
+
+ /**
+ * Initializes a new instance with the given shell.
+ *
+ * @param shell
+ */
+ AnnotatorActionGroup(Shell shell)
+ {
+ mShell = shell;
+ }
+
+ /**
+ * Adds for each uima annotator an appropriate configured
+ * <code>AnnotatorAction</code> to the given menu.
+ *
+ * Note: The action appears only in the menu if a document or
+ * corpus is selected.
+ *
+ * @param menu - the context menu manager // hier auf listen ???
+ */
+ @Override
+ public void fillContextMenu(IMenuManager menu)
+ {
+ IStructuredSelection selection = (IStructuredSelection) getContext()
+ .getSelection();
+
+ LinkedList<DocumentElement> documentElements = new LinkedList<DocumentElement>();
+
+ if (!CorpusExplorerUtil
+ .isContaingNLPProjectOrNonNLPResources(selection))
+ {
+ Iterator resources = selection.iterator();
+ while (resources.hasNext())
+ {
+ Object resource = resources.next();
+
+ if (resource instanceof CorpusElement)
+ {
+ documentElements.addAll(((CorpusElement) resource)
+ .getDocuments());
+ }
+
+ if (resource instanceof DocumentElement)
+ {
+ documentElements.add(((DocumentElement) resource));
+ }
+ }
+ }
+
+ // TODO: refactor this
+ // how to retrive the project of the selected elements ?
+ // what happends if someone selectes DocumentElements form
+ // different projects ?
+ if (!documentElements.isEmpty())
+ {
+ DocumentElement aDocument = documentElements.getFirst();
+
+ NlpProject project = aDocument.getNlpProject();
+
+ Collection<UimaSourceFolder> sourceFolders =
+ project.getUimaSourceFolder();
+
+
+ for (UimaSourceFolder sourceFolder : sourceFolders)
+ {
+ Collection<UimaConfigurationElement> configElements =
+ sourceFolder.getUimaConfigurationElements();
+
+ for (UimaConfigurationElement element : configElements)
+ {
+
+ Collection<AnnotatorElement> annotators = element
+ .getAnnotators();
+
+ for (AnnotatorElement annotator : annotators)
+ {
+ AnnotatorConfiguration config =
+ annotator.getAnnotatorConfiguration();
+
+ if (config != null)
+ {
+ IRunnableWithProgress annotatorRunnableAction =
+ new AnnotatorActionRunnable(
+ config, documentElements);
+
+
+ RunnableAction annotatorAction =
+ new RunnableAction(mShell,
+ annotator.getName(),
+ annotatorRunnableAction);
+
+
+ menu.add(annotatorAction);
+ }
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/ConsumerCorpusActionGroup.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/ConsumerCorpusActionGroup.java?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/ConsumerCorpusActionGroup.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/ConsumerCorpusActionGroup.java Wed Feb 14 06:35:40 2007
@@ -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.ui.corpusview;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedList;
+
+
+import org.apache.uima.caseditor.core.model.ConsumerElement;
+import org.apache.uima.caseditor.core.model.CorpusElement;
+import org.apache.uima.caseditor.core.model.NlpProject;
+import org.apache.uima.caseditor.core.model.UimaConfigurationElement;
+import org.apache.uima.caseditor.core.model.UimaSourceFolder;
+import org.apache.uima.caseditor.core.uima.CasConsumerConfiguration;
+import org.apache.uima.caseditor.ui.action.ConsumerActionRunnable;
+import org.apache.uima.caseditor.ui.action.RunnableAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.actions.ActionGroup;
+
+/**
+ * This is an action group for cas consumer actions.
+ *
+ * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
+ * @version $Revision: 1.2.2.1 $, $Date: 2007/01/04 14:37:51 $
+ */
+final class ConsumerCorpusActionGroup extends ActionGroup
+{
+ private Shell mShell;
+
+ ConsumerCorpusActionGroup(Shell shell)
+ {
+ mShell = shell;
+ }
+ /**
+ * Adds for each uima cas consumer an appropriate configured
+ * <code>CasConsumerAction</code> to the given menu.
+ * The action apears only in the menu if a document or corpus is selected.
+ */
+ @Override
+ public void fillContextMenu(IMenuManager menu)
+ {
+ IStructuredSelection selection = (IStructuredSelection) getContext()
+ .getSelection();
+
+ if (!CorpusExplorerUtil
+ .isContaingNLPProjectOrNonNLPResources(selection))
+ {
+ // TODO: add here also single documents
+ LinkedList<CorpusElement> corpora = new LinkedList<CorpusElement>();
+
+
+ for (Iterator resources = selection.iterator();
+ resources.hasNext();)
+ {
+ Object resource = resources.next();
+
+ if (resource instanceof CorpusElement)
+ {
+ corpora.add((CorpusElement) resource);
+ }
+ }
+
+ // TODO: refactor this here
+ if (!corpora.isEmpty())
+ {
+ CorpusElement aCorpus = corpora.getFirst();
+ NlpProject project = aCorpus.getNlpProject();
+
+ Collection<UimaSourceFolder> sourceFolders =
+ project.getUimaSourceFolder();
+
+ for (UimaSourceFolder sourceFolder : sourceFolders)
+ {
+ Collection<UimaConfigurationElement> configElements =
+ sourceFolder.getUimaConfigurationElements();
+
+ for (UimaConfigurationElement element : configElements)
+ {
+ Collection<ConsumerElement> consumers =
+ element.getConsumers();
+
+ for (ConsumerElement consumer : consumers)
+ {
+ CasConsumerConfiguration config =
+ consumer.getConsumerConfiguration();
+
+ if (config != null)
+ {
+ ConsumerActionRunnable consumerRunnableAction =
+ new ConsumerActionRunnable(config,
+ corpora);
+
+ RunnableAction consumerAction =
+ new RunnableAction(mShell,
+ consumer.getName(),
+ consumerRunnableAction);
+
+ menu.add(consumerAction);
+
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/CorpusExplorerActionGroup.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/CorpusExplorerActionGroup.java?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/CorpusExplorerActionGroup.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/CorpusExplorerActionGroup.java Wed Feb 14 06:35:40 2007
@@ -0,0 +1,245 @@
+/*
+ * 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.ui.corpusview;
+
+
+import org.apache.uima.caseditor.core.model.INlpElement;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.window.SameShellProvider;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.actions.ActionContext;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.actions.ActionGroup;
+import org.eclipse.ui.actions.ExportResourcesAction;
+import org.eclipse.ui.actions.ImportResourcesAction;
+import org.eclipse.ui.dialogs.PropertyDialogAction;
+import org.eclipse.ui.ide.IDEActionFactory;
+
+/**
+ * Main corpus explorer action group.
+ *
+ * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
+ * @version $Revision: 1.2.2.1 $, $Date: 2007/01/04 14:37:51 $
+ */
+final class CorpusExplorerActionGroup extends ActionGroup implements
+ ICorpusExplorerActionGroup
+{
+ private OpenActionGroup mOpenActionGroup;
+
+ private RefactorGroup mRefactorGroup;
+
+ protected ImportResourcesAction mImportAction;
+
+ protected ExportResourcesAction mExportAction;
+
+ private WorkspaceActionGroup mWorkspaceGroup;
+
+ private AnnotatorActionGroup mAnnotatorActionGroup;
+
+ private ConsumerCorpusActionGroup mConsumerCorpusActionGroup;
+
+ private PropertyDialogAction mPropertyAction;
+
+ private IWorkbenchWindow mWindow;
+
+ private IAction mRetargetPropertiesAction;
+
+ /**
+ * Creates a <code>CorpusExplorerActionGroup</code> object.
+ *
+ * @param view -
+ * the coresponding <code>CorpusExplorerView</code>
+ */
+ CorpusExplorerActionGroup(CorpusExplorerView view)
+ {
+ mWindow = view.getSite().getPage().getWorkbenchWindow();
+
+ Shell shell = view.getSite().getShell();
+
+ mOpenActionGroup = new OpenActionGroup(view.getSite().getPage());
+
+ mRefactorGroup = new RefactorGroup(shell, mWindow);
+
+ mImportAction = new ImportResourcesAction(mWindow);
+
+ mExportAction = new ExportResourcesAction(mWindow);
+
+ mWorkspaceGroup = new WorkspaceActionGroup(shell, mWindow);
+
+ mAnnotatorActionGroup = new AnnotatorActionGroup(shell);
+
+ mConsumerCorpusActionGroup = new ConsumerCorpusActionGroup(shell);
+
+ mPropertyAction = new PropertyDialogAction(
+ new SameShellProvider(shell), view.getTreeViewer());
+
+ mRetargetPropertiesAction = ActionFactory.PROPERTIES.create(mWindow);
+ }
+
+ /**
+ * Fills the context menu with all the actions.
+ */
+ @Override
+ public void fillContextMenu(IMenuManager menu)
+ {
+ IStructuredSelection selection = (IStructuredSelection) getContext()
+ .getSelection();
+
+ // For action order see "Eclipse User Interface Guidelines"
+
+ // 1. New actions
+ menu.add(IDEActionFactory.NEW_WIZARD_DROP_DOWN.create(mWindow));
+ menu.add(new Separator());
+
+ // 2. Open actions
+ mOpenActionGroup.fillContextMenu(menu);
+ menu.add(new Separator());
+
+ // 3. Navigate + Show In
+
+ // 4.1 Cut, Copy, Paste, Delete, Rename and other refactoring commands
+ mRefactorGroup.fillContextMenu(menu);
+ menu.add(new Separator());
+
+ // 4.2
+ menu.add(ActionFactory.IMPORT.create(mWindow));
+
+ menu.add(ActionFactory.EXPORT.create(mWindow));
+
+ menu.add(new Separator());
+
+ // 5. Other Plugin Additons
+ mWorkspaceGroup.fillContextMenu(menu);
+ menu.add(new Separator());
+
+ // 5.2 annotator additions
+ MenuManager taggerMenu = new MenuManager("Annotator");
+ menu.add(taggerMenu);
+
+ mAnnotatorActionGroup.fillContextMenu(taggerMenu);
+
+ // 5.3 consumer additions
+ MenuManager trainerMenu = new MenuManager("Consumer");
+ menu.add(trainerMenu);
+
+ mConsumerCorpusActionGroup.fillContextMenu(trainerMenu);
+
+ // 5.4 Annotator Plugin Additions
+ menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+
+ // 6. Properties action
+ boolean isOnlyOneResourceSelected = selection.size() == 1;
+ if (isOnlyOneResourceSelected)
+ {
+ menu.add(mRetargetPropertiesAction);
+ }
+ }
+
+ /**
+ * Fills the action bars
+ */
+ @Override
+ public void fillActionBars(IActionBars actionBars)
+ {
+ actionBars.setGlobalActionHandler(ActionFactory.PROPERTIES.getId(),
+ mPropertyAction);
+
+ actionBars.updateActionBars();
+
+ mOpenActionGroup.fillActionBars(actionBars);
+ mRefactorGroup.fillActionBars(actionBars);
+ mWorkspaceGroup.fillActionBars(actionBars);
+ }
+
+ /**
+ * Updates the actions.
+ */
+ @Override
+ public void updateActionBars()
+ {
+ IStructuredSelection selection = (IStructuredSelection) getContext()
+ .getSelection();
+
+ mPropertyAction.setEnabled(selection.size() == 1);
+
+ mOpenActionGroup.updateActionBars();
+ mRefactorGroup.updateActionBars();
+ mWorkspaceGroup.updateActionBars();
+ }
+
+ /**
+ * Sets the context to the action groups.
+ */
+ @Override
+ public void setContext(ActionContext context)
+ {
+ super.setContext(context);
+
+ mOpenActionGroup.setContext(context);
+ mRefactorGroup.setContext(context);
+ mWorkspaceGroup.setContext(context);
+ mAnnotatorActionGroup.setContext(context);
+ mConsumerCorpusActionGroup.setContext(context);
+ }
+
+ /**
+ * Executes the default action, in this case the open action.
+ */
+ public void executeDefaultAction(IStructuredSelection selection)
+ {
+ if (selection.getFirstElement() instanceof INlpElement)
+ {
+ INlpElement nlpElement = (INlpElement) selection.getFirstElement();
+
+ mOpenActionGroup.executeDefaultAction(new StructuredSelection(
+ nlpElement.getResource()));
+ }
+ else
+ {
+ mOpenActionGroup.executeDefaultAction(selection);
+ }
+ }
+
+ /**
+ * Dispose all resources created by the current object.
+ */
+ @Override
+ public void dispose()
+ {
+ super.dispose();
+
+ mOpenActionGroup.dispose();
+ mRefactorGroup.dispose();
+ mImportAction.dispose();
+ mExportAction.dispose();
+ mWorkspaceGroup.dispose();
+ mAnnotatorActionGroup.dispose();
+ mConsumerCorpusActionGroup.dispose();
+ mPropertyAction.dispose();
+ }
+}
\ No newline at end of file
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/CorpusExplorerContentProvider.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/CorpusExplorerContentProvider.java?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/CorpusExplorerContentProvider.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/CorpusExplorerContentProvider.java Wed Feb 14 06:35:40 2007
@@ -0,0 +1,159 @@
+/*
+ * 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.ui.corpusview;
+
+
+import org.apache.uima.caseditor.core.TaeCorePlugin;
+import org.apache.uima.caseditor.core.model.INlpElement;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+
+/**
+ * TODO: add javadoc here
+ *
+ * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
+ * @version $Revision: 1.4.2.1 $, $Date: 2007/01/04 14:37:51 $
+ */
+public class CorpusExplorerContentProvider implements
+ ITreeContentProvider
+{
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
+ {
+ }
+
+ public Object[] getElements(Object inputElement)
+ {
+ IWorkbenchAdapter workbenchAdapter =
+ getWorkbenchAdapter(inputElement);
+
+ return workbenchAdapter != null ?
+ workbenchAdapter.getChildren(inputElement) :
+ new Object[]{};
+ }
+
+ public Object[] getChildren(Object parentElement)
+ {
+ IWorkbenchAdapter workbenchAdapter =
+ getWorkbenchAdapter(parentElement);
+
+ return workbenchAdapter != null ?
+ workbenchAdapter.getChildren(parentElement) :
+ new Object[]{};
+ }
+
+ public Object getParent(Object element)
+ {
+ IWorkbenchAdapter workbenchAdapter =
+ getWorkbenchAdapter(element);
+
+ Object result;
+
+ if (element instanceof INlpElement)
+ {
+ result = workbenchAdapter.getParent(element);
+ }
+ else
+ {
+ if (element instanceof IResource)
+ {
+ IResource resource = (IResource) element;
+
+ try
+ {
+ result = TaeCorePlugin.getNlpModel().getParent(resource);
+ }
+ catch (CoreException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ return null;
+ }
+
+ if (result == null)
+ {
+ result = resource.getParent();
+ }
+ }
+ else
+ {
+ result = null;
+ }
+ }
+
+ return result;
+ }
+
+ public boolean hasChildren(Object element)
+ {
+ IWorkbenchAdapter workbenchAdapter =
+ getWorkbenchAdapter(element);
+
+ Object childs[] = workbenchAdapter.getChildren(element);
+
+ boolean result;
+
+ if (childs != null && childs.length == 0)
+ {
+ result = false;
+ }
+ else
+ {
+ result = true;
+ }
+
+ return result;
+ }
+
+ private static IWorkbenchAdapter getWorkbenchAdapter(Object input)
+ {
+ IWorkbenchAdapter result;
+
+ if (input instanceof IAdaptable)
+ {
+ IAdaptable adapter = (IAdaptable) input;
+
+ IWorkbenchAdapter workbenchAdapter = (IWorkbenchAdapter)
+ adapter.getAdapter(IWorkbenchAdapter.class);
+
+ result = workbenchAdapter;
+ }
+ else
+ {
+ result = null;
+ }
+
+// TODO: log this as error if result == null
+
+
+ return result;
+ }
+
+ /**
+ * Disposes allocated resources.
+ */
+ public void dispose()
+ {
+ // currently there are no resources allocated
+ }
+}
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/CorpusExplorerUtil.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/CorpusExplorerUtil.java?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/CorpusExplorerUtil.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/CorpusExplorerUtil.java Wed Feb 14 06:35:40 2007
@@ -0,0 +1,104 @@
+/*
+ * 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.ui.corpusview;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+
+
+import org.apache.uima.caseditor.core.model.INlpElement;
+import org.apache.uima.caseditor.core.model.NlpProject;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+
+
+/**
+ * TODO: add javadoc here.
+ *
+ * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
+ * @version $Revision: 1.1.2.1 $, $Date: 2007/01/04 14:37:51 $
+ */
+final class CorpusExplorerUtil
+{
+ /**
+ * Avoids instanciation of this utility class
+ */
+ private CorpusExplorerUtil()
+ {
+ // overridden to change access to private
+ }
+
+ static IStructuredSelection convertNLPElementsToResources(
+ IStructuredSelection selection)
+ {
+
+ LinkedList<Object> newSelectionList = new LinkedList<Object>();
+
+ for (Iterator elements = selection.iterator(); elements.hasNext();)
+ {
+ Object element = elements.next();
+
+ if (element instanceof INlpElement)
+ {
+ INlpElement nlpElement = (INlpElement) element;
+ newSelectionList.add(nlpElement.getResource());
+ }
+ else
+ {
+ newSelectionList.add(element);
+ }
+ }
+
+ return new StructuredSelection(newSelectionList);
+ }
+
+ /**
+ * TODO: Replace this method, the name is very ugly.
+ *
+ * @param selection
+ * @return true if NLPProject or NonNLPResource is included
+ *
+ * @deprecated
+ */
+ static boolean isContaingNLPProjectOrNonNLPResources(
+ IStructuredSelection selection)
+ {
+ boolean isNLPProjectOrNonNLPResource = false;
+
+ for (Iterator resources = selection.iterator() ;
+ resources.hasNext() && !isNLPProjectOrNonNLPResource;)
+ {
+ Object resource = resources.next();
+
+ if (! (resource instanceof INlpElement))
+ {
+ isNLPProjectOrNonNLPResource = true;
+ }
+
+ // if nlp project return also
+ if ((resource instanceof NlpProject))
+ {
+ isNLPProjectOrNonNLPResource = true;
+ }
+ }
+
+ return isNLPProjectOrNonNLPResource;
+ }
+}
\ No newline at end of file