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 [9/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/ui/property/DotCorpusPreferenceStore.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/DotCorpusPreferenceStore.java?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/DotCorpusPreferenceStore.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/DotCorpusPreferenceStore.java Wed Feb 14 06:35:40 2007
@@ -0,0 +1,460 @@
+/*
+ * 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.property;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.StringTokenizer;
+
+
+import org.apache.uima.caseditor.core.model.DotCorpusElement;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.preference.IPersistentPreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+
+/**
+ * TODO: add javdoc here
+ *
+ * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
+ * @version $Revision: 1.1.2.1 $, $Date: 2007/01/04 14:37:52 $
+ */
+public class DotCorpusPreferenceStore implements IPersistentPreferenceStore
+{
+ /**
+ * This is the config key, should only be used combindes with the
+ * <code>DotCorpusPreferenceStore</code>
+ *
+ * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
+ */
+ public enum Key
+ {
+ /**
+ * Name of the type sytem file
+ */
+ TYPE_SYSTEM_FILE,
+
+ /**
+ * The tagger configuration folder
+ */
+ TAGGER_CONFIG_FOLDER,
+
+ /**
+ * The corpus folders
+ */
+ CORPUS_FOLDERS,
+
+ /**
+ * Line length hint for the editor.
+ */
+ EDITOR_LINE_LENGTH_HINT;
+ }
+
+ private DotCorpusElement mDotCorpusElement;
+
+
+ /**
+ * Initializes new instance with a <code>DotCorpus</code> config object.
+ *
+ * @param dotCorpusElement
+ */
+ public DotCorpusPreferenceStore(DotCorpusElement dotCorpusElement)
+ {
+ mDotCorpusElement = dotCorpusElement;
+ }
+
+ /**
+ * @return always false
+ */
+ public boolean needsSaving()
+ {
+ return false;
+ }
+
+ /**
+ * Writes the DotCorpus to the filesystem.
+ *
+ * @throws IOException -
+ * if writing fails
+ */
+ public void save() throws IOException
+ {
+ try
+ {
+ mDotCorpusElement.serialize();
+ }
+ catch (CoreException e)
+ {
+ throw new IOException(e.getMessage());
+ }
+ }
+
+ /**
+ * Not implemented
+ */
+ public void addPropertyChangeListener(IPropertyChangeListener listener)
+ {
+ // currently not implemented, no need for this method
+ }
+
+ /**
+ * Not implemented
+ */
+ public void removePropertyChangeListener(IPropertyChangeListener listener)
+ {
+ // currently not implemented, no need for this method
+ }
+
+ /**
+ * Not implemented
+ */
+ public void firePropertyChangeEvent(String name, Object oldValue,
+ Object newValue)
+ {
+ // currently not implemented, no need for this method
+ }
+
+ /**
+ * Not implemented.
+ *
+ * @return always false
+ */
+ public boolean contains(String name)
+ {
+ return false;
+ }
+
+ /**
+ * Not implemented
+ */
+ public boolean isDefault(String name)
+ {
+ return false;
+ }
+
+ /**
+ * Not implemented
+ */
+ public void setToDefault(String name)
+ {
+ // currently not implemented, no need for this method
+ }
+
+ // boolean
+
+ /**
+ * Not implemented
+ */
+ public boolean getDefaultBoolean(String name)
+ {
+ throw new IllegalArgumentException("Not expected to be used!");
+ }
+
+ /**
+ * Not implemented
+ */
+ public void setDefault(String name, boolean value)
+ {
+ throw new IllegalArgumentException("Not expected to be used!");
+ }
+
+ /**
+ * Not implemented
+ */
+ public boolean getBoolean(String name)
+ {
+ throw new IllegalArgumentException("Not expected to be used!");
+ }
+
+ /**
+ * Not implemented
+ */
+ public void setValue(String name, boolean value)
+ {
+ throw new IllegalArgumentException("Not expected to be used!");
+ }
+
+ // int
+
+ /**
+ * Not implemented
+ */
+ public int getDefaultInt(String name)
+ {
+ return getInt(name);
+ }
+
+ /**
+ * Not implemented
+ */
+ public void setDefault(String name, int value)
+ {
+ throw new IllegalArgumentException("Not expected to be used!");
+ }
+
+ /**
+ * Retrvies the following parameters:
+ * + editor line length hint
+ */
+ public int getInt(String name)
+ {
+ if (Key.EDITOR_LINE_LENGTH_HINT.equals(Key.valueOf(name)))
+ {
+ return mDotCorpusElement.getEditorLineLengthHint();
+ }
+ else
+ {
+ throw new IllegalArgumentException("Unkown name: " + name);
+ }
+ }
+
+ /**
+ * Sets the following parameters:
+ * + editor line length hint
+ */
+ public void setValue(String name, int value)
+ {
+ if (Key.EDITOR_LINE_LENGTH_HINT.equals(Key.valueOf(name)))
+ {
+ mDotCorpusElement.setEditorLineLengthHint(value);
+ }
+ else
+ {
+ throw new IllegalArgumentException("Unkown name: " + name);
+ }
+ }
+
+ // long
+
+ /**
+ * Not implemented
+ */
+ public long getDefaultLong(String name)
+ {
+ throw new IllegalArgumentException("Not expected to be used!");
+ }
+
+ /**
+ * Not implemented
+ */
+ public void setDefault(String name, long value)
+ {
+ throw new IllegalArgumentException("Not expected to be used!");
+ }
+
+ /**
+ * Not implemented
+ */
+ public long getLong(String name)
+ {
+ throw new IllegalArgumentException("Not expected to be used!");
+ }
+
+ /**
+ * Not implemented
+ */
+ public void setValue(String name, long value)
+ {
+ throw new IllegalArgumentException("Not expected to be used!");
+ }
+
+ // float
+
+ /**
+ * Not implemented
+ */
+ public float getDefaultFloat(String name)
+ {
+ throw new IllegalArgumentException("Not expected to be used!");
+ }
+
+ /**
+ * Not implemented
+ */
+ public void setDefault(String name, float value)
+ {
+ throw new IllegalArgumentException("Not expected to be used!");
+ }
+
+ /**
+ * Not implemented
+ */
+ public float getFloat(String name)
+ {
+ throw new IllegalArgumentException("Not expected to be used!");
+ }
+
+ /**
+ * Not implemented
+ */
+ public void setValue(String name, float value)
+ {
+ throw new IllegalArgumentException("Not expected to be used!");
+ }
+
+ // double
+
+ /**
+ * Not implemented
+ */
+ public double getDefaultDouble(String name)
+ {
+ throw new IllegalArgumentException("Not expected to be used!");
+ }
+
+ /**
+ * Not implemented
+ */
+ public void setDefault(String name, double value)
+ {
+ throw new IllegalArgumentException("Not expected to be used!");
+ }
+
+ /**
+ * Not implemented
+ */
+ public double getDouble(String name)
+ {
+ throw new IllegalArgumentException("Not expected to be used!");
+ }
+
+ /**
+ * Not implemented
+ */
+ public void setValue(String name, double value)
+ {
+ throw new IllegalArgumentException("Not expected to be used!");
+ }
+
+ // string
+
+ /**
+ * @return always null
+ */
+ public String getDefaultString(String name)
+ {
+ return getString(name);
+ }
+
+ /**
+ * Not implemented
+ */
+ public void setDefault(String name, String defaultObject)
+ {
+ throw new IllegalArgumentException("Not expected to be used!");
+ }
+
+ /**
+ * Retrives the config value for the given name.
+ *
+ * @param name
+ * the config key
+ */
+ public String getString(String name)
+ {
+ Key key = Key.valueOf(name);
+
+ if (Key.TAGGER_CONFIG_FOLDER.equals(key))
+ {
+ return mDotCorpusElement.getUimaConfigFolder() != null ? mDotCorpusElement
+ .getUimaConfigFolder().getName() : "";
+ }
+ else if (Key.TYPE_SYSTEM_FILE.equals(key))
+ {
+ return mDotCorpusElement.getTypeSystemFile() != null ? mDotCorpusElement
+ .getTypeSystemFile().getName() : "";
+ }
+ else if (Key.CORPUS_FOLDERS.equals(key))
+ {
+ Collection<IFolder> corpusFolderNames = mDotCorpusElement
+ .getCorpusFolderNameList();
+
+ StringBuilder pathStringBuilder = new StringBuilder();
+
+ for (IFolder folderName : corpusFolderNames)
+ {
+ pathStringBuilder.append(folderName.getName());
+ pathStringBuilder.append(File.pathSeparator);
+ }
+
+ return pathStringBuilder.toString();
+ }
+ else
+ {
+ throw new IllegalArgumentException("Provided key is unkown!");
+ }
+ }
+
+ /**
+ * Sets the config value for the given config key.
+ */
+ public void setValue(String name, String value)
+ {
+ Key key = Key.valueOf(name);
+
+ if (Key.TAGGER_CONFIG_FOLDER.equals(key))
+ {
+ if (value.length() != 0)
+ {
+ mDotCorpusElement.setUimaConfigFolderName(value);
+ }
+ else
+ {
+ mDotCorpusElement.setUimaConfigFolderName(null);
+ }
+ }
+ else if (Key.TYPE_SYSTEM_FILE.equals(key))
+ {
+ if (value.length() != 0)
+ {
+ mDotCorpusElement.setTypeSystemFilename(value);
+ }
+ else
+ {
+ mDotCorpusElement.setTypeSystemFilename(null);
+ }
+ }
+ else if (Key.CORPUS_FOLDERS.equals(key))
+ {
+ StringTokenizer tokenizer = new StringTokenizer(value,
+ File.pathSeparator);
+
+ // delete all corpus folders
+ for (IFolder corpus : mDotCorpusElement.getCorpusFolderNameList())
+ {
+ mDotCorpusElement.removeCorpusFolder(corpus);
+ }
+
+ while (tokenizer.hasMoreTokens())
+ {
+ mDotCorpusElement.addCorpusFolder(tokenizer.nextToken());
+ }
+ }
+ }
+
+ /**
+ * Not implemented
+ */
+ public void putValue(String name, String value)
+ {
+ throw new IllegalArgumentException("Not expected to be used!");
+ }
+}
\ No newline at end of file
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/FileSelectionFieldEditor.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/FileSelectionFieldEditor.java?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/FileSelectionFieldEditor.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/FileSelectionFieldEditor.java Wed Feb 14 06:35:40 2007
@@ -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.ui.property;
+
+
+import org.apache.uima.caseditor.core.TaeCorePlugin;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.preference.StringButtonFieldEditor;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+import org.eclipse.ui.dialogs.ISelectionStatusValidator;
+import org.eclipse.ui.model.BaseWorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+
+/**
+ * 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:52 $
+ */
+class FileSelectionFieldEditor extends StringButtonFieldEditor
+{
+ private IProject mProject;
+
+ FileSelectionFieldEditor(String name, String labelText, Composite parent,
+ IProject project)
+ {
+ super(name, labelText, parent);
+
+ mProject = project;
+ }
+
+ @Override
+ protected String changePressed()
+ {
+ // String currentText = getTextControl().getText();
+
+ // IFile candidateFile = mProject.getFile(currentText);
+
+ // if (!candidateFile.exists())
+ // {
+ // return null;
+ // }
+
+ // TODO: preselect entered text entry
+
+ final ElementTreeSelectionDialog fileSelectionDialog = new ElementTreeSelectionDialog(
+ getShell(), new WorkbenchLabelProvider(),
+ new BaseWorkbenchContentProvider());
+
+ fileSelectionDialog.setInput(mProject);
+ fileSelectionDialog.setTitle("testTitle");
+ fileSelectionDialog.setMessage("testMessage");
+ fileSelectionDialog.setValidator(new ISelectionStatusValidator()
+ {
+ public IStatus validate(Object[] selection)
+ {
+ if (selection.length == 1)
+ {
+ if (selection[0] instanceof IFile)
+ {
+ return Status.OK_STATUS;
+ }
+ }
+
+ return new Status(IStatus.ERROR, TaeCorePlugin.ID, 0,
+ "Please select a file!", null);
+ }
+ });
+
+ fileSelectionDialog.open();
+
+ Object[] results = fileSelectionDialog.getResult();
+
+ if (results.length != 1)
+ {
+ return null;
+ }
+
+ return ((IFile) results[0]).getFullPath().removeFirstSegments(1)
+ .toString();
+ }
+}
\ No newline at end of file
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/FolderFieldEditor.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/FolderFieldEditor.java?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/FolderFieldEditor.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/FolderFieldEditor.java Wed Feb 14 06:35:40 2007
@@ -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.ui.property;
+
+
+import org.apache.uima.caseditor.core.TaeCorePlugin;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.preference.StringButtonFieldEditor;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+import org.eclipse.ui.dialogs.ISelectionStatusValidator;
+import org.eclipse.ui.model.BaseWorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+
+/**
+ * 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:52 $
+ */
+class FolderFieldEditor extends StringButtonFieldEditor
+{
+ private IProject mProject;
+
+ FolderFieldEditor(String name, String labelText, Composite parent,
+ IProject project)
+ {
+ super(name, labelText, parent);
+
+ mProject = project;
+ }
+
+ @Override
+ protected String changePressed()
+ {
+ // TODO: preselect entered text entry
+
+ final ElementTreeSelectionDialog folderSelectionDialog = new ElementTreeSelectionDialog(
+ getShell(), new WorkbenchLabelProvider(),
+ new BaseWorkbenchContentProvider());
+
+ folderSelectionDialog.setInput(mProject);
+ folderSelectionDialog.setTitle("testTitle");
+ folderSelectionDialog.setMessage("testMessage");
+ folderSelectionDialog.setValidator(new ISelectionStatusValidator()
+ {
+ public IStatus validate(Object[] selection)
+ {
+ if (selection.length == 1)
+ {
+ if (selection[0] instanceof IFolder)
+ {
+ return Status.OK_STATUS;
+ }
+ }
+
+ return new Status(IStatus.ERROR, TaeCorePlugin.ID, 0,
+ "Please select a folder!", null);
+ }
+ });
+
+ folderSelectionDialog.open();
+
+ Object[] results = folderSelectionDialog.getResult();
+
+ if (results.length != 1)
+ {
+ return null;
+ }
+
+ return ((IFolder) results[0]).getFullPath().removeFirstSegments(1)
+ .toString();
+ }
+
+}
\ No newline at end of file
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/FolderPathEditor.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/FolderPathEditor.java?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/FolderPathEditor.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/FolderPathEditor.java Wed Feb 14 06:35:40 2007
@@ -0,0 +1,93 @@
+/*
+ * 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.property;
+
+
+import org.apache.uima.caseditor.core.TaeCorePlugin;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.preference.PathEditor;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+import org.eclipse.ui.dialogs.ISelectionStatusValidator;
+import org.eclipse.ui.model.BaseWorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+
+/**
+ * TODO: add javadoc here TODO: Remove the up and down buttons, they are not
+ * needed
+ *
+ * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
+ * @version $Revision: 1.1.2.1 $, $Date: 2007/01/04 14:37:52 $
+ */
+class FolderPathEditor extends PathEditor
+{
+ private IProject mProject;
+
+ FolderPathEditor(String name, String labelText, String folderChooserLabel,
+ Composite parent, IProject project)
+ {
+ super(name, labelText, folderChooserLabel, parent);
+
+ mProject = project;
+ }
+
+ @Override
+ protected String getNewInputObject()
+ {
+ final ElementTreeSelectionDialog folderSelectionDialog = new ElementTreeSelectionDialog(
+ getShell(), new WorkbenchLabelProvider(),
+ new BaseWorkbenchContentProvider());
+
+ folderSelectionDialog.setInput(mProject);
+ folderSelectionDialog.setTitle("testTitle");
+ folderSelectionDialog.setMessage("testMessage");
+ folderSelectionDialog.setValidator(new ISelectionStatusValidator()
+ {
+ public IStatus validate(Object[] selection)
+ {
+ if (selection.length == 1)
+ {
+ if (selection[0] instanceof IFolder)
+ {
+ return Status.OK_STATUS;
+ }
+ }
+
+ return new Status(IStatus.ERROR, TaeCorePlugin.ID, 0,
+ "Please select a folder!", null);
+ }
+ });
+
+ folderSelectionDialog.open();
+
+ Object[] results = folderSelectionDialog.getResult();
+
+ if (results.length != 1)
+ {
+ return null;
+ }
+
+ return ((IFolder) results[0]).getFullPath().removeFirstSegments(1)
+ .toString();
+ }
+}
\ No newline at end of file
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/NlpProjectFieldEditorPage.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/NlpProjectFieldEditorPage.java?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/NlpProjectFieldEditorPage.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/NlpProjectFieldEditorPage.java Wed Feb 14 06:35:40 2007
@@ -0,0 +1,135 @@
+/*
+ * 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.property;
+
+
+import org.apache.uima.caseditor.core.model.INlpElement;
+import org.apache.uima.caseditor.core.model.NlpProject;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IWorkbenchPropertyPage;
+
+/**
+ * TODO: add javadoc here
+ *
+ * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
+ * @version $Revision: 1.3.2.1 $, $Date: 2007/01/04 14:37:52 $
+ */
+public abstract class NlpProjectFieldEditorPage extends FieldEditorPreferencePage
+ implements IWorkbenchPropertyPage
+{
+ private ImageDescriptor mImage;
+
+ private IAdaptable mElement;
+
+ private IPreferenceStore mPreferenceStore;
+
+ NlpProjectFieldEditorPage(int style)
+ {
+ super(style);
+ }
+
+ public NlpProjectFieldEditorPage(String title, int style)
+ {
+ super(title, style);
+ }
+
+ public NlpProjectFieldEditorPage(String title, ImageDescriptor image,
+ int style)
+ {
+ super(title, image, style);
+
+ mImage = image;
+ }
+
+ /**
+ * Retrives the project of the currently selected NLPElement.
+ *
+ * @return - project of selected NLPElement.
+ */
+ protected NlpProject getProject()
+ {
+ return ((INlpElement) getElement()).getNlpProject();
+ }
+
+ @Override
+ public void createControl(Composite parent)
+ {
+ if (isPropertyPage())
+ {
+ NlpProject nlpProject = getProject();
+
+ mPreferenceStore = new DotCorpusPreferenceStore(
+ nlpProject.getDotCorpus());
+ }
+
+ super.createControl(parent);
+
+ if (isPropertyPage())
+ {
+ // updateFieldEditors();
+ }
+ }
+
+ @Override
+ public IPreferenceStore getPreferenceStore()
+ {
+ IPreferenceStore result;
+
+ if (isPropertyPage())
+ {
+ result = mPreferenceStore;
+ }
+ else
+ {
+ result = super.getPreferenceStore();
+ }
+
+ return result;
+ }
+
+ @Override
+ protected void createFieldEditors()
+ {
+ }
+
+ public IAdaptable getElement()
+ {
+ return mElement;
+ }
+
+ public void setElement(IAdaptable element)
+ {
+ mElement = element;
+ }
+
+ /**
+ * Indicates if current is used as a property page.
+ *
+ * @return - true if property page
+ */
+ public boolean isPropertyPage()
+ {
+ return mElement != null;
+ }
+}
\ No newline at end of file
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/ProjectPropertyPage.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/ProjectPropertyPage.java?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/ProjectPropertyPage.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/ProjectPropertyPage.java Wed Feb 14 06:35:40 2007
@@ -0,0 +1,133 @@
+/*
+ * 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.property;
+
+import java.io.IOException;
+
+
+import org.apache.uima.caseditor.core.model.INlpElement;
+import org.apache.uima.caseditor.core.model.NlpProject;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.jface.preference.IntegerFieldEditor;
+import org.eclipse.swt.widgets.Composite;
+
+
+/**
+ * TODO: add javadoc here
+ *
+ * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
+ * @version $Revision: 1.6.2.1 $, $Date: 2007/01/04 14:37:52 $
+ */
+public class ProjectPropertyPage extends NlpProjectFieldEditorPage
+{
+ private DotCorpusPreferenceStore mDotCorpusPropertyStore;
+
+ private FileSelectionFieldEditor mTypeSystemFile;
+
+ private FolderFieldEditor mUimaConfigFolder;
+
+ private FolderPathEditor mCorpusFolders;
+
+ private IntegerFieldEditor mEditorLineLengthHint;
+
+ /**
+ * Initialize a new instance.
+ */
+ public ProjectPropertyPage()
+ {
+ super(FieldEditorPreferencePage.GRID);
+ }
+
+ @Override
+ protected void createFieldEditors()
+ {
+ IProject project = (IProject) getProject().getResource();
+
+ NlpProject nlpProject = ((INlpElement) getElement()).getNlpProject();
+
+ mDotCorpusPropertyStore = new DotCorpusPreferenceStore(nlpProject
+ .getDotCorpus());
+
+ Composite parent = getFieldEditorParent();
+
+ // uima config folder
+ mUimaConfigFolder = new FolderFieldEditor(
+ DotCorpusPreferenceStore.Key.TAGGER_CONFIG_FOLDER.name(),
+ "Uima Config", parent, project);
+ mUimaConfigFolder.setChangeButtonText("Browse...");
+ mUimaConfigFolder.setPreferenceStore(mDotCorpusPropertyStore);
+ addField(mUimaConfigFolder);
+
+ // corpus folder
+ mCorpusFolders = new FolderPathEditor(
+ DotCorpusPreferenceStore.Key.CORPUS_FOLDERS.name(),
+ "CorpusFolders", "folderChooserLabel", parent, project);
+
+ mCorpusFolders.setPreferenceStore(mDotCorpusPropertyStore);
+ addField(mCorpusFolders);
+
+ // type system file
+ mTypeSystemFile = new FileSelectionFieldEditor(
+ DotCorpusPreferenceStore.Key.TYPE_SYSTEM_FILE.name(),
+ "Typesystem", parent, project);
+ mTypeSystemFile.setChangeButtonText("Browse...");
+ mTypeSystemFile.setPreferenceStore(mDotCorpusPropertyStore);
+ addField(mTypeSystemFile);
+
+ // editor line length hint
+ mEditorLineLengthHint = new IntegerFieldEditor(
+ DotCorpusPreferenceStore.Key.EDITOR_LINE_LENGTH_HINT.name(),
+ "Line Length Hint", parent);
+ mEditorLineLengthHint.setPreferenceStore(mDotCorpusPropertyStore);
+ addField(mEditorLineLengthHint);
+ }
+
+ @Override
+ public boolean performOk()
+ {
+ mTypeSystemFile.store();
+ mCorpusFolders.store();
+ mUimaConfigFolder.store();
+ mEditorLineLengthHint.store();
+
+ try
+ {
+ mDotCorpusPropertyStore.save();
+ }
+ catch (IOException e)
+ {
+ // TODO: show error message with save error
+ e.printStackTrace();
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ protected void performDefaults()
+ {
+ mTypeSystemFile.loadDefault();
+ mCorpusFolders.loadDefault();
+ mUimaConfigFolder.loadDefault();
+ mEditorLineLengthHint.loadDefault();
+ }
+}
\ No newline at end of file
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/package.html
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/package.html?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/package.html (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/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 property page classes.</p>
+ </body>
+</html>
\ No newline at end of file
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/wizards/DocumentImportStructureProvider.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/wizards/DocumentImportStructureProvider.java?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/wizards/DocumentImportStructureProvider.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/wizards/DocumentImportStructureProvider.java Wed Feb 14 06:35:40 2007
@@ -0,0 +1,251 @@
+/*
+ * 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.wizards;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+
+import javax.swing.text.BadLocationException;
+import javax.swing.text.DefaultStyledDocument;
+import javax.swing.text.StyledDocument;
+import javax.swing.text.rtf.RTFEditorKit;
+
+
+import org.apache.uima.caseditor.core.TaeCorePlugin;
+import org.apache.uima.caseditor.core.model.NlpProject;
+import org.apache.uima.caseditor.core.uima.DocumentUimaImpl;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.ui.wizards.datatransfer.IImportStructureProvider;
+
+
+
+/**
+ * TODO: add javadoc here
+ *
+ * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
+ * @version $Revision: 1.3.2.1 $, $Date: 2007/01/04 14:37:51 $
+ */
+final class DocumentImportStructureProvider implements IImportStructureProvider
+{
+ private IProject mProject;
+
+ /**
+ * Constructs a new DocumentImportStructureProvider object.
+ *
+ * @param containerFullPath
+ */
+ public DocumentImportStructureProvider(IPath containerFullPath)
+ {
+ // TODO: fix this ...
+ mProject = ResourcesPlugin.getWorkspace().getRoot().findMember(
+ containerFullPath).getProject();
+ }
+
+ public List getChildren(Object element)
+ {
+ return null;
+ }
+
+ public InputStream getContents(Object element)
+ {
+ File fileToImport = (File) element;
+
+ String fileName = fileToImport.getName();
+
+ if (fileName.endsWith(".rtf"))
+ {
+ InputStream in = null;
+
+ try
+ {
+ in = new FileInputStream((File) element);
+ String text = convert(in);
+
+ return getDocument(text);
+ }
+ catch (FileNotFoundException e)
+ {
+ return null;
+ }
+ catch (IOException e)
+ {
+ return null;
+ }
+ finally
+ {
+ try
+ {
+ if (in != null)
+ {
+ in.close();
+ }
+ }
+ catch (IOException e)
+ {
+ // sorry that this can happen
+ }
+ }
+
+ }
+ else if (fileName.endsWith(".txt"))
+ {
+ InputStream in = null;
+ try
+ {
+ in = new FileInputStream((File) element);
+
+ StringBuffer textStringBuffer = new StringBuffer();
+
+ byte[] readBuffer = new byte[2048];
+
+ while (in.available() > 0)
+ {
+ int length = in.read(readBuffer);
+
+ textStringBuffer.append(new String(readBuffer, 0, length,
+ "UTF-8"));
+ }
+
+ return getDocument(textStringBuffer.toString());
+ }
+ catch (FileNotFoundException e)
+ {
+ return null;
+ }
+ catch (IOException e)
+ {
+ return null;
+ }
+ finally
+ {
+ if (in != null)
+ {
+ try
+ {
+ in.close();
+ }
+ catch (IOException e)
+ {
+ // sorry that this can fail
+ }
+ }
+ }
+ }
+ else
+ {
+ try
+ {
+ return new FileInputStream((File) element);
+ }
+ catch (FileNotFoundException e)
+ {
+ return null;
+ }
+ }
+ }
+
+ private String convert(InputStream rtfDocumentInputStream)
+ throws IOException
+ {
+ RTFEditorKit aRtfEditorkit = new RTFEditorKit();
+
+ StyledDocument styledDoc = new DefaultStyledDocument();
+
+ String textDocument;
+
+ try
+ {
+ aRtfEditorkit.read(rtfDocumentInputStream, styledDoc, 0);
+
+ textDocument = styledDoc.getText(0, styledDoc.getLength());
+ }
+ catch (BadLocationException e)
+ {
+ throw new IOException("Error during parsing");
+ }
+
+ return textDocument;
+ }
+
+ public String getFullPath(Object element)
+ {
+ return ((File) element).getPath();
+ }
+
+ public String getLabel(Object element)
+ {
+ File fileToImport = (File) element;
+
+ String fileName = fileToImport.getName();
+
+ if (fileName.endsWith(".rtf") || fileName.endsWith(".txt"))
+ {
+ int nameWithouEndingLength = fileName.lastIndexOf(".");
+ String nameWithouEnding = fileName.substring(0,
+ nameWithouEndingLength);
+
+ return nameWithouEnding + ".xcas";
+ }
+ else
+ {
+ return fileName;
+ }
+ }
+
+ public boolean isFolder(Object element)
+ {
+ return ((File) element).isDirectory();
+ }
+
+ private InputStream getDocument(String text)
+ {
+ NlpProject nlpProject = (NlpProject) TaeCorePlugin.getNlpModel()
+ .findMember(mProject);
+
+ DocumentUimaImpl gateDocument = new DocumentUimaImpl(nlpProject);
+
+ gateDocument.getCAS().setDocumentText(text);
+
+ ByteArrayOutputStream outStream = new ByteArrayOutputStream(40000);
+ try
+ {
+ gateDocument.serialize(outStream);
+ }
+ catch (CoreException e)
+ {
+ // TODO handle this exception
+ e.printStackTrace();
+ return null;
+ }
+
+ InputStream stream = new ByteArrayInputStream(outStream.toByteArray());
+
+ return stream;
+ }
+}
\ No newline at end of file
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/wizards/ImportDocumentWizard.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/wizards/ImportDocumentWizard.java?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/wizards/ImportDocumentWizard.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/wizards/ImportDocumentWizard.java Wed Feb 14 06:35:40 2007
@@ -0,0 +1,62 @@
+/*
+ * 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.wizards;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IImportWizard;
+import org.eclipse.ui.IWorkbench;
+
+/**
+ * read files, convert them and save them in the folder select project select
+ * dst folder select src
+ *
+ * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
+ * @version $Revision: 1.1.2.1 $, $Date: 2007/01/04 14:37:51 $
+ */
+public final class ImportDocumentWizard extends Wizard implements IImportWizard
+{
+ private ImportDocumentWizardPage mMainPage;
+
+ private IStructuredSelection mCurrentResourceSelection;
+
+ private IWorkbench mWorkbench = null;
+
+ public void init(IWorkbench workbench, IStructuredSelection selection)
+ {
+ mWorkbench = workbench;
+ mCurrentResourceSelection = selection;
+ }
+
+ @Override
+ public void addPages()
+ {
+ mMainPage = new ImportDocumentWizardPage(mWorkbench,
+ mCurrentResourceSelection);
+
+ addPage(mMainPage);
+ }
+
+ @Override
+ public boolean performFinish()
+ {
+ return mMainPage.finish();
+ }
+}
\ No newline at end of file
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/wizards/ImportDocumentWizard2.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/wizards/ImportDocumentWizard2.java?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/wizards/ImportDocumentWizard2.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/wizards/ImportDocumentWizard2.java Wed Feb 14 06:35:40 2007
@@ -0,0 +1,67 @@
+/*
+ * 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.wizards;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IImportWizard;
+import org.eclipse.ui.IWorkbench;
+
+/**
+ * The {@link ImportDocumentWizard} can import text files in different formats
+ * into a corpus folder. The imported files are automatically converted to the
+ * xcas file format.
+ *
+ * Notes:
+ * If two files have the same name but a differnt file extension. The
+ * second file gets a number attached.
+ *
+ * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
+ * @version $Revision: 1.1.2.1 $, $Date: 2007/01/04 14:37:51 $
+ */
+public class ImportDocumentWizard2 extends Wizard implements IImportWizard
+{
+ private ImportDocumentWizardPage mMainPage;
+
+ private IStructuredSelection mCurrentResourceSelection;
+
+ private IWorkbench mWorkbench = null;
+
+ public void init(IWorkbench workbench, IStructuredSelection selection)
+ {
+ mWorkbench = workbench;
+ mCurrentResourceSelection = selection;
+ }
+
+ @Override
+ public void addPages()
+ {
+ mMainPage = new ImportDocumentWizardPage(mWorkbench,
+ mCurrentResourceSelection);
+
+ addPage(mMainPage);
+ }
+
+ @Override
+ public boolean performFinish()
+ {
+ return false;
+ }
+}
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/wizards/ImportDocumentWizardMainPage.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/wizards/ImportDocumentWizardMainPage.java?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/wizards/ImportDocumentWizardMainPage.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/wizards/ImportDocumentWizardMainPage.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.wizards;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.dialogs.WizardResourceImportPage;
+
+/**
+ * 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 $
+ */
+public class ImportDocumentWizardMainPage extends WizardResourceImportPage
+{
+
+ protected ImportDocumentWizardMainPage(String name, IStructuredSelection selection)
+ {
+ super(name, selection);
+ }
+
+ @Override
+ protected void createSourceGroup(Composite parent)
+ {
+ }
+
+ @Override
+ protected ITreeContentProvider getFileProvider()
+ {
+ return null;
+ }
+
+ @Override
+ protected ITreeContentProvider getFolderProvider()
+ {
+ return null;
+ }
+
+}
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/wizards/ImportDocumentWizardPage.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/wizards/ImportDocumentWizardPage.java?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/wizards/ImportDocumentWizardPage.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/wizards/ImportDocumentWizardPage.java Wed Feb 14 06:35:40 2007
@@ -0,0 +1,69 @@
+/*
+ * 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.wizards;
+
+import java.util.List;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.internal.wizards.datatransfer.WizardFileSystemResourceImportPage1;
+import org.eclipse.ui.wizards.datatransfer.IImportStructureProvider;
+import org.eclipse.ui.wizards.datatransfer.ImportOperation;
+
+
+/**
+ * The main page of the ImportDocumentWizard.
+ *
+ * @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 ImportDocumentWizardPage extends
+ WizardFileSystemResourceImportPage1
+{
+
+ @Override
+ protected void createSourceGroup(Composite parent)
+ {
+ createRootDirectoryGroup(parent);
+ createFileSelectionGroup(parent);
+ createButtonsGroup(parent);
+ }
+
+ public ImportDocumentWizardPage(IWorkbench workbench,
+ IStructuredSelection selection)
+ {
+ super(workbench, selection);
+ }
+
+ @Override
+ protected boolean importResources(List fileSystemObjects)
+ {
+ IImportStructureProvider importProvider = new DocumentImportStructureProvider(
+ getContainerFullPath());
+
+ ImportOperation operation = new ImportOperation(getContainerFullPath(),
+ getSourceDirectory(), importProvider, this, fileSystemObjects);
+
+ operation.setContext(getShell());
+
+ return executeImportOperation(operation);
+ }
+}
\ No newline at end of file
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/wizards/NewCorpusWizard.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/wizards/NewCorpusWizard.java?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/wizards/NewCorpusWizard.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/wizards/NewCorpusWizard.java Wed Feb 14 06:35:40 2007
@@ -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.ui.wizards;
+
+
+import org.apache.uima.caseditor.core.model.NlpProject;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.dialogs.WizardNewFolderMainPage;
+
+/**
+ * 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 $
+ */
+public final class NewCorpusWizard extends Wizard implements INewWizard
+{
+ public static String ID = "net.sf.tae.wizards.NewDocumentWizard";
+
+ private WizardNewFolderMainPage mMainPage;
+
+ private IStructuredSelection mCurrentResourceSelection;
+
+ // private NewCorpusWizardPage mCorpusWizardPage;
+
+ public void init(IWorkbench workbench, IStructuredSelection selection)
+ {
+ mCurrentResourceSelection = selection;
+ }
+
+ @Override
+ public void addPages()
+ {
+ mMainPage = new WizardNewFolderMainPage("New corpus wizard",
+ mCurrentResourceSelection);
+
+ addPage(mMainPage);
+
+ // mCorpusWizardPage = new NewCorpusWizardPage();
+ // mCorpusWizardPage.setDescription("description");
+
+ // addPage(mCorpusWizardPage);
+ }
+
+ @Override
+ public boolean performFinish()
+ {
+ IFolder newFolder = mMainPage.createNewFolder();
+
+ IProject project = newFolder.getProject();
+
+ NlpProject nlpProject;
+ try
+ {
+ if (!project.hasNature("Annotator.NLPProject"))
+ {
+ return false;
+ }
+
+ nlpProject = (NlpProject) project.getNature("Annotator.NLPProject");
+ }
+ catch (CoreException e)
+ {
+ return false;
+ }
+
+ nlpProject.getDotCorpus().addCorpusFolder(
+ newFolder.getFullPath().toString());
+
+ return true;
+ }
+}
\ No newline at end of file
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/wizards/NewCorpusWizardPage.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/wizards/NewCorpusWizardPage.java?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/wizards/NewCorpusWizardPage.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/wizards/NewCorpusWizardPage.java Wed Feb 14 06:35:40 2007
@@ -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.ui.wizards;
+
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * 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 NewCorpusWizardPage extends WizardPage
+{
+ private Text mProjectText;
+
+ private Text mCorpusText;
+
+ NewCorpusWizardPage()
+ {
+ super("pagename2");
+ }
+
+ public void createControl(Composite parent)
+ {
+ // initializeDialogUnits(parent);
+
+ Composite composite = new Composite(parent, SWT.NONE);
+
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ layout.numColumns = 3;
+ composite.setLayout(layout);
+
+ // Project
+ Label projectLabel = new Label(composite, SWT.NONE);
+ projectLabel.setText("Project");
+
+ mProjectText = new Text(composite, SWT.NONE);
+
+ Button browseProjectButton = new Button(composite, SWT.NONE);
+ browseProjectButton.setText("Browse");
+
+ // Corpus
+ Label corpusLabel = new Label(composite, SWT.NONE);
+ corpusLabel.setText("Corpus");
+
+ mCorpusText = new Text(composite, SWT.NONE);
+
+ Button browseFodlerButton = new Button(composite, SWT.NONE);
+ browseFodlerButton.setText("Browse");
+
+ setControl(composite);
+ }
+
+ String getProject()
+ {
+ return mProjectText.getText();
+ }
+
+ String getCorpus()
+ {
+ return mCorpusText.getText();
+ }
+
+}
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/wizards/NlpProjectWizard.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/wizards/NlpProjectWizard.java?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/wizards/NlpProjectWizard.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/wizards/NlpProjectWizard.java Wed Feb 14 06:35:40 2007
@@ -0,0 +1,136 @@
+/*
+ * 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.wizards;
+
+
+import org.apache.uima.caseditor.core.model.NlpProject;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
+
+/**
+ * New wizard for nlp projects. TODO: exception handling TODO: refactor this
+ * wizard
+ *
+ * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
+ * @version $Revision: 1.2.2.1 $, $Date: 2007/01/04 14:37:51 $
+ */
+final public class NlpProjectWizard extends Wizard implements INewWizard
+{
+ /**
+ * The ID of the new nlp porject wizard.
+ */
+ public static final String ID = "net.sf.tae.wizards.NLPProjectWizard";
+
+ private WizardNewProjectCreationPage mMainPage;
+
+ /**
+ * Initializes the <code>NLPProjectWizard</code>.
+ */
+ public void init(IWorkbench workbench, IStructuredSelection selection)
+ {
+ // setForcePreviousAndNextButtons(false); // remove comment later
+ setWindowTitle("New NLP project");
+ }
+
+ /**
+ * Adds the project wizard page to the wizard.
+ */
+ @Override
+ public void addPages()
+ {
+ mMainPage = new WizardNewProjectCreationPage("NLPProject");
+ mMainPage.setTitle("Create a NLP project");
+ mMainPage.setDescription("Create a NLP project in the workspace");
+ addPage(mMainPage);
+ }
+
+ /**
+ * Creates the nlp project.
+ */
+ @Override
+ public boolean performFinish()
+ {
+ // TODO: only return true if everyting goes well
+ IProject newNLPProject = mMainPage.getProjectHandle();
+
+ createProject(newNLPProject, mMainPage.getLocationPath());
+
+
+ try
+ {
+ NlpProject.addNLPNature(newNLPProject);
+ }
+ catch (CoreException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return true;
+ }
+
+ private static void createProject(IProject project, IPath location)
+ {
+ if (!project.exists())
+ {
+ IProjectDescription projectDescribtion = project.getWorkspace()
+ .newProjectDescription(project.getName());
+
+ if (Platform.getLocation().equals(location))
+ {
+ location = null;
+ }
+
+ projectDescribtion.setLocation(location);
+
+ try
+ {
+ project.create(projectDescribtion, null);
+ }
+ catch (CoreException e)
+ {
+ // TODO: show error message
+ e.printStackTrace();
+ }
+
+ }
+
+ if (!project.isOpen())
+ {
+ try
+ {
+ project.open(null);
+ }
+ catch (CoreException e)
+ {
+ // TODO: show error message
+ e.printStackTrace();
+ }
+ }
+ }
+}
\ No newline at end of file
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/wizards/package.html
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/wizards/package.html?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/wizards/package.html (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/wizards/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 wizards classes.</p>
+ </body>
+</html>
\ No newline at end of file
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/uima/CorporaCollectionReader.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/uima/CorporaCollectionReader.java?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/uima/CorporaCollectionReader.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/uima/CorporaCollectionReader.java Wed Feb 14 06:35:40 2007
@@ -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.uima;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedList;
+
+
+import org.apache.uima.cas.CAS;
+import org.apache.uima.cas_data.CasData;
+import org.apache.uima.caseditor.core.model.CorpusElement;
+import org.apache.uima.caseditor.core.model.DocumentElement;
+import org.apache.uima.collection.CollectionException;
+import org.apache.uima.collection.CollectionReader_ImplBase;
+import org.apache.uima.collection.impl.CasConverter;
+import org.apache.uima.util.Progress;
+
+/**
+ * This is a collection reader which reads the documents from
+ * a {@link Collection} of {@link CorpusElement}s.
+ *
+ * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
+ * @version $Revision: 1.4.2.2 $, $Date: 2007/01/04 15:01:27 $
+ */
+public class CorporaCollectionReader extends CollectionReader_ImplBase {
+ private Iterator mDocumentIterator;
+
+ /**
+ * Sets the <code>CorpusElement</code>s to be read.
+ *
+ * @param corpora
+ */
+ public void setCorpora(Collection<CorpusElement> corpora) {
+ if (corpora != null) {
+ LinkedList<DocumentElement> documents = new LinkedList<DocumentElement>();
+
+ for (CorpusElement element : corpora) {
+ documents.addAll(element.getDocuments());
+ }
+
+ mDocumentIterator = documents.iterator();
+ }
+ }
+
+ /**
+ * Copies the next text with all annotation to the given cas object.
+ *
+ * @throws CollectionException -
+ */
+ public void getNext(CAS cas) throws CollectionException {
+ DocumentElement document = (DocumentElement) mDocumentIterator.next();
+
+ CAS documentCas = document.getCAS();
+
+ CasConverter converter = new CasConverter();
+
+ CasData documentData = converter.casContainerToCasData(documentCas);
+
+ converter.casDataToCasContainer(documentData, cas, true);
+ }
+
+ /**
+ * Checks if there is one more cas available.
+ */
+ public boolean hasNext() {
+ if (mDocumentIterator != null) {
+ return mDocumentIterator.hasNext();
+ }
+ else {
+ return false;
+ }
+ }
+
+ /**
+ * Currently not implemented
+ *
+ * @return Progress[] - just returns null
+ */
+ public Progress[] getProgress() {
+ return new Progress[] {};
+ }
+
+ /**
+ * Currently not implemented
+ */
+ public void close() {
+ // currently not implemented
+ }
+}
\ No newline at end of file
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/uima/DummyAnnotator.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/uima/DummyAnnotator.java?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/uima/DummyAnnotator.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/uima/DummyAnnotator.java Wed Feb 14 06:35:40 2007
@@ -0,0 +1,76 @@
+/*
+ * 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.uima;
+
+import org.apache.uima.analysis_engine.ResultSpecification;
+import org.apache.uima.analysis_engine.annotator.AnnotatorConfigurationException;
+import org.apache.uima.analysis_engine.annotator.AnnotatorContext;
+import org.apache.uima.analysis_engine.annotator.AnnotatorInitializationException;
+import org.apache.uima.analysis_engine.annotator.AnnotatorProcessException;
+import org.apache.uima.analysis_engine.annotator.TextAnnotator;
+import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.TypeSystem;
+
+/**
+ * This Annotator does nothing. You can use it when you need to supply a valid TextAnnotator
+ * implementation, but not need a TextAnnotator.
+ *
+ * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
+ * @version $Revision: 1.1.2.2 $, $Date: 2007/01/04 15:01:27 $
+ */
+public class DummyAnnotator implements TextAnnotator {
+ /**
+ * Dummy process method, does nothing.
+ */
+ public void process(CAS arg0, ResultSpecification arg1) throws AnnotatorProcessException {
+ // just a dummy method, no implementation
+ }
+
+ /**
+ * Dummy initialize method, does nothing;
+ */
+ public void initialize(AnnotatorContext arg0) throws AnnotatorInitializationException,
+ AnnotatorConfigurationException {
+ // just a dummy method, no implementation
+ }
+
+ /**
+ * Dummy typeSystemInit method, does nothing.
+ */
+ public void typeSystemInit(TypeSystem arg0) throws AnnotatorInitializationException,
+ AnnotatorConfigurationException {
+ // just a dummy method, no implementation
+ }
+
+ /**
+ * Dummy reconfigure method, does nothing.
+ */
+ public void reconfigure() throws AnnotatorConfigurationException,
+ AnnotatorInitializationException {
+ // just a dummy method, no implementation
+ }
+
+ /**
+ * Dummy destroy method, does nothing.
+ */
+ public void destroy() {
+ // just a dummy method, no implementation
+ }
+}
\ No newline at end of file
Added: incubator/uima/sandbox/trunk/CasEditor/src/test/java/org/apache/uima/caseditor/core/model/dotcorpus/AnnotationStyleTest.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/test/java/org/apache/uima/caseditor/core/model/dotcorpus/AnnotationStyleTest.java?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/test/java/org/apache/uima/caseditor/core/model/dotcorpus/AnnotationStyleTest.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/test/java/org/apache/uima/caseditor/core/model/dotcorpus/AnnotationStyleTest.java Wed Feb 14 06:35:40 2007
@@ -0,0 +1,56 @@
+/*
+ * 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.core.model.dotcorpus;
+
+import java.awt.Color;
+
+import org.apache.uima.caseditor.core.model.dotcorpus.AnnotationStyle;
+
+/**
+ * Unit test for the {@link AnnotationStyle} class.
+ *
+ * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
+ * @version $Revision: 1.4.2.2 $, $Date: 2007/01/04 14:56:25 $
+ */
+public class AnnotationStyleTest {
+ /**
+ * Tests the {@link AnnotationStyle#equals(Object)} method.
+ */
+ @Test
+ public void testEquals() {
+ AnnotationStyle a = new AnnotationStyle("testType", AnnotationStyle.Style.BRACKET, Color.BLACK);
+
+ AnnotationStyle b = new AnnotationStyle("testType", AnnotationStyle.Style.BRACKET, Color.BLACK);
+
+ assertEquals(a, b);
+ }
+
+ /**
+ * Test the {@link AnnotationStyle#hashCode()} method.
+ *
+ */
+ public void testHashCode() {
+ AnnotationStyle a = new AnnotationStyle("testType", AnnotationStyle.Style.BRACKET, Color.BLACK);
+
+ AnnotationStyle b = new AnnotationStyle("testType", AnnotationStyle.Style.BRACKET, Color.BLACK);
+
+ assertEquals(a.hashCode(), b.hashCode());
+ }
+}
\ No newline at end of file
Added: incubator/uima/sandbox/trunk/CasEditor/src/test/java/org/apache/uima/caseditor/core/model/dotcorpus/DotCorpusSerializerTest.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/test/java/org/apache/uima/caseditor/core/model/dotcorpus/DotCorpusSerializerTest.java?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/test/java/org/apache/uima/caseditor/core/model/dotcorpus/DotCorpusSerializerTest.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/test/java/org/apache/uima/caseditor/core/model/dotcorpus/DotCorpusSerializerTest.java Wed Feb 14 06:35:40 2007
@@ -0,0 +1,61 @@
+/*
+ * 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.core.model.dotcorpus;
+
+import java.awt.Color;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+import org.apache.uima.caseditor.core.model.dotcorpus.AnnotationStyle;
+import org.apache.uima.caseditor.core.model.dotcorpus.DotCorpus;
+import org.apache.uima.caseditor.core.model.dotcorpus.DotCorpusSerializer;
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * TODO: add javadoc here
+ *
+ * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
+ * @version $Revision: 1.4.2.2 $, $Date: 2007/01/04 14:56:25 $
+ */
+public class DotCorpusSerializerTest {
+ /**
+ * Tests if serialization and recreations creates and object that is equal to the original.
+ *
+ * @throws CoreException
+ */
+ @Test
+ public void testSerializeAndCreate() throws CoreException {
+ DotCorpus original = new DotCorpus();
+ original.setTypeSystemFilename("typesystem");
+ original.setUimaConfigFolderName("uima config folder");
+ original.setStyle(new AnnotationStyle("test", Style.BRACKET, Color.GRAY));
+ original.addCorpusFolder("corpus");
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ DotCorpusSerializer.serialize(original, out);
+
+ InputStream in = new ByteArrayInputStream(out.toByteArray());
+
+ DotCorpus recreated = DotCorpusSerializer.parseDotCorpus(in);
+
+ assertEquals(original, recreated);
+ }
+}
Added: incubator/uima/sandbox/trunk/CasEditor/src/test/java/org/apache/uima/caseditor/core/test/Annotator.ann
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/test/java/org/apache/uima/caseditor/core/test/Annotator.ann?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/test/java/org/apache/uima/caseditor/core/test/Annotator.ann (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/test/java/org/apache/uima/caseditor/core/test/Annotator.ann Wed Feb 14 06:35:40 2007
@@ -0,0 +1,34 @@
+<?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>none</annotatorImplementationName>
+<analysisEngineMetaData>
+<name>TestAnnotator</name>
+<description></description>
+<version>1.0</version>
+<vendor>net.sf.tae</vendor>
+
+<configurationParameters>
+</configurationParameters>
+
+<configurationParameterSettings>
+</configurationParameterSettings>
+
+<typeSystemDescription/>
+<capabilities>
+<capability>
+<inputs/>
+<outputs/>
+<languagesSupported>
+<language>en</language>
+</languagesSupported>
+</capability>
+</capabilities>
+<operationalProperties>
+<modifiesCas>true</modifiesCas>
+<multipleDeploymentAllowed>true</multipleDeploymentAllowed>
+</operationalProperties>
+</analysisEngineMetaData>
+<resourceManagerConfiguration/>
+</taeDescription>
Added: incubator/uima/sandbox/trunk/CasEditor/src/test/java/org/apache/uima/caseditor/core/test/Consumer.con
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/test/java/org/apache/uima/caseditor/core/test/Consumer.con?view=auto&rev=507542
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/test/java/org/apache/uima/caseditor/core/test/Consumer.con (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/test/java/org/apache/uima/caseditor/core/test/Consumer.con Wed Feb 14 06:35:40 2007
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<casConsumerDescription xmlns="http://uima.watson.ibm.com/resourceSpecifier">
+<frameworkImplementation>com.ibm.uima.java</frameworkImplementation>
+<implementationName>none</implementationName>
+<processingResourceMetaData>
+<name>TokenizerTrainer</name>
+<description></description>
+<version>1.0</version>
+<vendor>net.sf.tae</vendor>
+
+<configurationParameters>
+</configurationParameters>
+
+<configurationParameterSettings>
+</configurationParameterSettings>
+
+<typeSystemDescription/>
+<typePriorities/>
+<fsIndexCollection/>
+<capabilities/>
+<operationalProperties>
+<modifiesCas>false</modifiesCas>
+<multipleDeploymentAllowed>false</multipleDeploymentAllowed>
+</operationalProperties>
+</processingResourceMetaData>
+</casConsumerDescription>
\ No newline at end of file