You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by jo...@apache.org on 2009/03/31 12:07:40 UTC
svn commit: r760385 - in
/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core:
model/delta/ uima/ util/
Author: joern
Date: Tue Mar 31 10:07:36 2009
New Revision: 760385
URL: http://svn.apache.org/viewvc?rev=760385&view=rev
Log:
UIMA-1178
Added:
incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/model/delta/
incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/model/delta/AbstractResourceDelta.java (with props)
incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/model/delta/INlpElementDelta.java (with props)
incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/model/delta/INlpModelChangeListener.java (with props)
incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/model/delta/INlpModelDeltaVisitor.java (with props)
incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/model/delta/Kind.java (with props)
incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/model/delta/NlpModelDeltaImpl.java (with props)
incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/uima/
incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/uima/AnnotatorConfiguration.java (with props)
incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/uima/CasConsumerConfiguration.java (with props)
incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/util/
incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/util/EventDispatcher.java (with props)
incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/util/IEventHandler.java (with props)
incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/util/MarkerUtil.java (with props)
Added: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/model/delta/AbstractResourceDelta.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/model/delta/AbstractResourceDelta.java?rev=760385&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/model/delta/AbstractResourceDelta.java (added)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/model/delta/AbstractResourceDelta.java Tue Mar 31 10:07:36 2009
@@ -0,0 +1,145 @@
+/*
+ * 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.delta;
+
+import org.eclipse.core.resources.IMarkerDelta;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.IResourceDeltaVisitor;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+
+/**
+ * Abstract base class, so clients must not implement all methods.
+ */
+public abstract class AbstractResourceDelta implements IResourceDelta {
+ /**
+ * Dummy method, does nothing.
+ */
+ public void accept(IResourceDeltaVisitor visitor) throws CoreException {
+ // not implemented
+ }
+
+ /**
+ * Dummy method, does nothing.
+ */
+ public void accept(IResourceDeltaVisitor visitor, boolean includePhantoms) throws CoreException {
+ // not implemented
+ }
+
+ /**
+ * Dummy method, does nothing.
+ */
+ public void accept(IResourceDeltaVisitor visitor, int memberFlags) throws CoreException {
+ // not implemented
+ }
+
+ /**
+ * Dummy method, does nothing.
+ */
+ public IResourceDelta findMember(IPath path) {
+ return null;
+ }
+
+ /**
+ * Dummy method, does nothing.
+ */
+ public IResourceDelta[] getAffectedChildren() {
+ return new IResourceDelta[] {};
+ }
+
+ /**
+ * Dummy method, does nothing.
+ */
+ public IResourceDelta[] getAffectedChildren(int kindMask) {
+ return new IResourceDelta[] {};
+ }
+
+ /**
+ * Dummy method, does nothing.
+ */
+ public IResourceDelta[] getAffectedChildren(int kindMask, int memberFlags) {
+ return new IResourceDelta[] {};
+ }
+
+ /**
+ * Dummy method, does nothing.
+ */
+ public int getFlags() {
+ return 0;
+ }
+
+ /**
+ * Dummy method, does nothing.
+ */
+ public IPath getFullPath() {
+ return null;
+ }
+
+ /**
+ * Dummy method, does nothing.
+ */
+ public int getKind() {
+ return 0;
+ }
+
+ /**
+ * Dummy method, does nothing.
+ */
+ public IMarkerDelta[] getMarkerDeltas() {
+ return new IMarkerDelta[] {};
+ }
+
+ /**
+ * Dummy method, does nothing.
+ */
+ public IPath getMovedFromPath() {
+ return null;
+ }
+
+ /**
+ * Dummy method, does nothing.
+ */
+ public IPath getMovedToPath() {
+ return null;
+ }
+
+ /**
+ * Dummy method, does nothing.
+ */
+ public IPath getProjectRelativePath() {
+ return null;
+ }
+
+ /**
+ * Dummy method, does nothing.
+ */
+ public IResource getResource() {
+ return null;
+ }
+
+ /**
+ * Dummy method, does nothing.
+ */
+ @SuppressWarnings("unchecked")
+ public Object getAdapter(Class adapter) {
+ return null;
+ }
+}
\ No newline at end of file
Propchange: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/model/delta/AbstractResourceDelta.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/model/delta/INlpElementDelta.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/model/delta/INlpElementDelta.java?rev=760385&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/model/delta/INlpElementDelta.java (added)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/model/delta/INlpElementDelta.java Tue Mar 31 10:07:36 2009
@@ -0,0 +1,97 @@
+/*
+ * 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.delta;
+
+import org.apache.uima.caseditor.core.model.INlpElement;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.runtime.IPath;
+
+/**
+ * A element delta represents changes in the state of a element tree between two discrete points in
+ * time.
+ *
+ * @see IResourceDelta
+ */
+public interface INlpElementDelta {
+ /**
+ * Accepts the given visitor. The only kinds of resource deltas visited are <code>ADDED</code>,
+ * <code>REMOVED</code>, and <code>CHANGED</code>.
+ *
+ * @param visotor
+ */
+ void accept(INlpModelDeltaVisitor visotor);
+
+ /**
+ * Returns resource deltas for all children of this resource which were added, removed, or
+ * changed. Returns an empty array if there are no affected children.
+ *
+ * @return - children or empty array
+ */
+ public INlpElementDelta[] getAffectedChildren();
+
+ /**
+ * Returns true if the given element is an nlp element.
+ *
+ * @return true if an nlp element otherwise false
+ */
+ boolean isNlpElement();
+
+ /**
+ * Retrieves the nlp element.
+ *
+ * @return the nlp element or if non null.
+ */
+ INlpElement getNlpElement();
+
+ /**
+ * Retrieves the resource belonging to this delta.
+ *
+ * @return the resource
+ */
+ IResource getResource();
+
+ /**
+ * Retrieves the kind.
+ *
+ * @return the kind
+ */
+ Kind getKind();
+
+ /**
+ * Retrieves the flags.
+ *
+ * @return the flags
+ */
+ int getFlags();
+
+ /**
+ * Retrieves the moved to path.
+ *
+ * @return
+ */
+ IPath getMovedToPath();
+
+ /**
+ * Retrieves the moved from path.
+ * @return
+ */
+ IPath getMovedFromPath();
+}
\ No newline at end of file
Propchange: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/model/delta/INlpElementDelta.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/model/delta/INlpModelChangeListener.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/model/delta/INlpModelChangeListener.java?rev=760385&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/model/delta/INlpModelChangeListener.java (added)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/model/delta/INlpModelChangeListener.java Tue Mar 31 10:07:36 2009
@@ -0,0 +1,42 @@
+/*
+ * 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.delta;
+
+import org.apache.uima.caseditor.core.model.INlpElement;
+
+/**
+ * This listener is notified when the nlp model changes.
+ */
+public interface INlpModelChangeListener {
+ /**
+ * Called if the nlp model changed.
+ *
+ * @param delta
+ * contains the change from one point in time to the next.
+ */
+ void resourceChanged(INlpElementDelta delta);
+
+ /**
+ * The given {@link INlpElement} was changed. Clients must refresh.
+ *
+ * @param element
+ */
+ void refresh(INlpElement element);
+}
Propchange: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/model/delta/INlpModelChangeListener.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/model/delta/INlpModelDeltaVisitor.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/model/delta/INlpModelDeltaVisitor.java?rev=760385&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/model/delta/INlpModelDeltaVisitor.java (added)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/model/delta/INlpModelDeltaVisitor.java Tue Mar 31 10:07:36 2009
@@ -0,0 +1,33 @@
+/*
+ * 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.delta;
+
+/**
+ * The listener is used to visit the given delta.
+ */
+public interface INlpModelDeltaVisitor {
+ /**
+ * Called to visit the given delta.
+ *
+ * @param delta
+ * @return true if the implementor wants to visit children.
+ */
+ public boolean visit(INlpElementDelta delta);
+}
\ No newline at end of file
Propchange: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/model/delta/INlpModelDeltaVisitor.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/model/delta/Kind.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/model/delta/Kind.java?rev=760385&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/model/delta/Kind.java (added)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/model/delta/Kind.java Tue Mar 31 10:07:36 2009
@@ -0,0 +1,40 @@
+/*
+ * 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.delta;
+
+/**
+ * The kind of the {@link INlpElementDelta}.
+ */
+public enum Kind {
+ /**
+ * Added a resource.
+ */
+ ADDED,
+
+ /**
+ * Removed a resource.
+ */
+ REMOVED,
+
+ /**
+ * Changed a resource or one of its children.
+ */
+ CHANGED;
+}
Propchange: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/model/delta/Kind.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/model/delta/NlpModelDeltaImpl.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/model/delta/NlpModelDeltaImpl.java?rev=760385&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/model/delta/NlpModelDeltaImpl.java (added)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/model/delta/NlpModelDeltaImpl.java Tue Mar 31 10:07:36 2009
@@ -0,0 +1,206 @@
+/*
+ * 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.delta;
+
+import java.util.Collection;
+import java.util.LinkedList;
+
+import org.apache.uima.caseditor.core.model.INlpElement;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.runtime.IPath;
+
+/**
+ * The internal implementation of the nlp model delta interface.
+ *
+ * TODO: Add a filter to avoid node with Kind.NOTHING.
+ */
+public final class NlpModelDeltaImpl implements INlpElementDelta {
+ private IResourceDelta mResourceDelta;
+
+ private Collection<INlpElementDelta> mChildren = new LinkedList<INlpElementDelta>();
+
+ private INlpElement mNlpElement;
+
+ /**
+ * The kind of the event. After an project was opened the old closed project (closed project does
+ * not have a natures) must be removed. Then the newly created NlpProject will be added. For this
+ * add the kind must be changed from changed to added. To have control about the kind the status
+ * is duplicated here.
+ */
+ private Kind mKind;
+
+ private NlpModelDeltaImpl mParent;
+
+ /**
+ * Initializes a new instance.
+ *
+ * @param parent
+ * @param resourceDelta
+ */
+ public NlpModelDeltaImpl(NlpModelDeltaImpl parent, IResourceDelta resourceDelta) {
+ mParent = parent;
+
+ mResourceDelta = resourceDelta;
+
+ mKind = getKind(resourceDelta);
+
+ IResourceDelta deltas[] = mResourceDelta.getAffectedChildren();
+
+ for (IResourceDelta element : deltas) {
+ if (element.getFlags() != IResourceDelta.MARKERS) {
+ mChildren.add(new NlpModelDeltaImpl(this, element));
+ }
+ }
+ }
+
+ /**
+ * Sets the nlp element Note: do not call this method from ouside code
+ *
+ * @param element
+ */
+ public void setNlpElement(INlpElement element) {
+ mNlpElement = element;
+ }
+
+ /**
+ * Retrieves the parent element or null if this is the root delta.
+ *
+ * @return parent element or null
+ */
+ public INlpElementDelta getParent() {
+ return mParent;
+ }
+
+ /**
+ * Adds a child to the current element instance.
+ *
+ * @param child
+ */
+ public void addChild(NlpModelDeltaImpl child) {
+ mChildren.add(child);
+ }
+
+ /**
+ * Accepts the given visitor.
+ */
+ public void accept(INlpModelDeltaVisitor visitor) {
+ boolean wantsToVisitChilds = visitor.visit(this);
+
+ if (wantsToVisitChilds) {
+ for (INlpElementDelta delta : getAffectedChildren()) {
+ delta.accept(visitor);
+ }
+ }
+ }
+
+ /**
+ * Retrieves the affected children.
+ */
+ public INlpElementDelta[] getAffectedChildren() {
+ return mChildren.toArray(new INlpElementDelta[mChildren.size()]);
+ }
+
+ /**
+ * Checks if the current instance is a nlp element.
+ */
+ public boolean isNlpElement() {
+ return mNlpElement != null;
+ }
+
+ /**
+ * Retrieves the nlp element.
+ */
+ public INlpElement getNlpElement() {
+ return mNlpElement;
+ }
+
+ /**
+ * Retrieves the resource.
+ */
+ public IResource getResource() {
+ return mResourceDelta.getResource();
+ }
+
+ /**
+ * Retrieves the kind
+ */
+ public Kind getKind() {
+ return mKind;
+ }
+
+ /**
+ * Sets the new kind. This method should only be called from the event handlers snd not by any
+ * client.
+ *
+ * @param kind
+ */
+ public void setKind(Kind kind) {
+ mKind = kind;
+ }
+
+ /**
+ * Retrieves the original flags of the {@link IResourceDelta} object.
+ */
+ public int getFlags() {
+ return mResourceDelta.getFlags();
+ }
+
+ /**
+ * Retrieves the resource delta.
+ *
+ * @return the resource delta
+ */
+ public IResourceDelta getResourceDelta() {
+ return mResourceDelta;
+ }
+
+ public IPath getMovedFromPath() {
+ return mResourceDelta.getMovedFromPath();
+ }
+
+ public IPath getMovedToPath() {
+ return mResourceDelta.getMovedToPath();
+ }
+
+ /**
+ * Retrieves a human-readable string of the current instance.
+ */
+ @Override
+ public String toString() {
+ return (isNlpElement() ? "Nlp: " : "") + mResourceDelta.toString();
+ }
+
+ private static Kind getKind(IResourceDelta delta) {
+ Kind kind;
+
+ if ((delta.getKind() & (IResourceDelta.ADDED | IResourceDelta.ADDED_PHANTOM)) != 0) {
+ kind = Kind.ADDED;
+ } else if ((delta.getKind() & (IResourceDelta.REMOVED | IResourceDelta.REMOVED_PHANTOM)) != 0) {
+ kind = Kind.REMOVED;
+ } else if ((delta.getKind() & IResourceDelta.CHANGED) != 0) {
+ kind = Kind.CHANGED;
+ } else {
+ kind = null;
+ }
+
+ return kind;
+ }
+}
\ No newline at end of file
Propchange: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/model/delta/NlpModelDeltaImpl.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/uima/AnnotatorConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/uima/AnnotatorConfiguration.java?rev=760385&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/uima/AnnotatorConfiguration.java (added)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/uima/AnnotatorConfiguration.java Tue Mar 31 10:07:36 2009
@@ -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.core.uima;
+
+import java.net.MalformedURLException;
+
+import org.apache.uima.UIMAFramework;
+import org.apache.uima.analysis_engine.AnalysisEngine;
+import org.apache.uima.caseditor.core.TaeError;
+import org.apache.uima.caseditor.core.model.AnnotatorElement;
+import org.apache.uima.resource.ResourceInitializationException;
+import org.apache.uima.resource.ResourceManager;
+import org.apache.uima.resource.ResourceSpecifier;
+import org.eclipse.core.resources.IFolder;
+
+/**
+ * TODO: add java doc here
+ */
+public class AnnotatorConfiguration {
+ private ResourceSpecifier mDescriptor;
+
+ private IFolder mResourceBasePath;
+
+ private final AnnotatorElement element;
+
+ /**
+ * Initializes the instance.
+ *
+ * @param descriptor
+ */
+ public AnnotatorConfiguration(AnnotatorElement element, ResourceSpecifier descriptor) {
+ this.element = element;
+ mDescriptor = descriptor;
+ }
+
+ public AnnotatorElement getAnnotatorElement() {
+ return element;
+ }
+
+ /**
+ * Only text analysis engines are supported.
+ *
+ * @return the text analysis engine
+ * @throws ResourceInitializationException
+ */
+ public AnalysisEngine createAnnotator() throws ResourceInitializationException {
+ ResourceManager resourceManager = UIMAFramework.newDefaultResourceManager();
+
+ if (mResourceBasePath.getLocation() != null) {
+ try {
+ resourceManager.setDataPath(mResourceBasePath.getLocation().toOSString());
+ } catch (MalformedURLException e) {
+ // this will not happen
+ throw new TaeError("Unexpexted exceptioon", e);
+ }
+ }
+
+ return UIMAFramework.produceAnalysisEngine(mDescriptor, resourceManager, null);
+ }
+
+ public IFolder getBaseFolder() {
+ return mResourceBasePath;
+ }
+
+ /**
+ * Sets the base folder
+ *
+ * @param baseFolder
+ */
+ public void setBaseFolder(IFolder baseFolder) {
+ mResourceBasePath = baseFolder;
+ }
+}
\ No newline at end of file
Propchange: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/uima/AnnotatorConfiguration.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/uima/CasConsumerConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/uima/CasConsumerConfiguration.java?rev=760385&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/uima/CasConsumerConfiguration.java (added)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/uima/CasConsumerConfiguration.java Tue Mar 31 10:07:36 2009
@@ -0,0 +1,118 @@
+/*
+ * 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.uima;
+
+import java.net.MalformedURLException;
+
+import org.apache.uima.UIMAFramework;
+import org.apache.uima.caseditor.core.TaeError;
+import org.apache.uima.caseditor.core.model.ConsumerElement;
+import org.apache.uima.collection.CasConsumer;
+import org.apache.uima.collection.CasConsumerDescription;
+import org.apache.uima.resource.ResourceInitializationException;
+import org.apache.uima.resource.ResourceManager;
+import org.apache.uima.resource.metadata.ProcessingResourceMetaData;
+import org.eclipse.core.resources.IFolder;
+
+/**
+ * TODO: add javadoc here
+ */
+public final class CasConsumerConfiguration {
+ private CasConsumerDescription casConsumerDescriptor;
+
+ private IFolder resourceBasePath;
+
+ private ConsumerElement consumerElement;
+
+ /**
+ * Initializes a new instance.
+ *
+ * @param element
+ *
+ * @param descriptor
+ */
+ public CasConsumerConfiguration(ConsumerElement element, CasConsumerDescription descriptor) {
+ casConsumerDescriptor = descriptor;
+ consumerElement = element;
+ }
+
+ /**
+ * Retrieves the name.
+ *
+ * @return the name
+ */
+ public String getName() {
+ ProcessingResourceMetaData trainerMetaData = casConsumerDescriptor.getCasConsumerMetaData();
+
+ return trainerMetaData.getName();
+ }
+
+ /**
+ * Sets the base folder.
+ *
+ * @param baseFolder
+ */
+ public void setBaseFolder(IFolder baseFolder) {
+ resourceBasePath = baseFolder;
+ }
+
+ public IFolder getBaseFolder() {
+ return resourceBasePath;
+ }
+
+ /**
+ * Creates the consumer.
+ *
+ * @return the consumer
+ */
+ public CasConsumer createConsumer() {
+ ResourceManager resourceManager = UIMAFramework.newDefaultResourceManager();
+
+ if (resourceBasePath.getLocation() != null) {
+ try {
+ resourceManager.setExtensionClassPath(resourceBasePath.getLocation().toOSString(), true);
+ resourceManager.setDataPath(resourceBasePath.getLocation().toOSString());
+ } catch (MalformedURLException e) {
+ // this should never happen
+ throw new TaeError("Unexpected exception", e);
+ }
+ }
+
+ try {
+ CasConsumer consumer = UIMAFramework.produceCasConsumer(casConsumerDescriptor,
+ resourceManager, null);
+
+ return consumer;
+ } catch (ResourceInitializationException e) {
+
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ /**
+ * Retrieves the {@link ConsumerElement}.
+ *
+ * @return the {@link ConsumerElement}
+ */
+ public ConsumerElement getConsumerElement() {
+ return consumerElement;
+ }
+}
\ No newline at end of file
Propchange: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/uima/CasConsumerConfiguration.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/util/EventDispatcher.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/util/EventDispatcher.java?rev=760385&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/util/EventDispatcher.java (added)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/util/EventDispatcher.java Tue Mar 31 10:07:36 2009
@@ -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.core.util;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * The EventDispatcher routes received events to the registered handler objects.
+ *
+ * @param <K>
+ * the key type
+ * @param <E>
+ * the event type
+ */
+public class EventDispatcher<K, E> {
+ private Map<K, IEventHandler<E>> mHandler = new HashMap<K, IEventHandler<E>>();
+
+ private IEventHandler<E> mDefaultHandler;
+
+ /**
+ * Initializes the current instance with a default handler.
+ *
+ * @param defaultHandler
+ * handles all unkown events, must not be null
+ */
+ public EventDispatcher(IEventHandler<E> defaultHandler) {
+ if (defaultHandler == null) {
+ throw new IllegalArgumentException("The defaultHandler must not be null!");
+ }
+
+ mDefaultHandler = defaultHandler;
+ }
+
+ /**
+ * Registers the given handler for the given key.
+ *
+ * @param key
+ * @param handler
+ */
+ public void register(K key, IEventHandler<E> handler) {
+ mHandler.put(key, handler);
+ }
+
+ /**
+ * Notifies the registered handler, if there is no handler registered for this key the default
+ * handler is notified.
+ *
+ * @param key
+ * the key type
+ * @param event
+ * the event type
+ */
+ public void notify(K key, E event) {
+ IEventHandler<E> handler = mHandler.get(key);
+
+ if (handler != null) {
+ handler.handle(event);
+ } else {
+ mDefaultHandler.handle(event);
+ }
+ }
+}
\ No newline at end of file
Propchange: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/util/EventDispatcher.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/util/IEventHandler.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/util/IEventHandler.java?rev=760385&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/util/IEventHandler.java (added)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/util/IEventHandler.java Tue Mar 31 10:07:36 2009
@@ -0,0 +1,37 @@
+/*
+ * 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.util;
+
+/**
+ * Clients which implement this interface can receive event notifications from the
+ * {@link EventDispatcher} after registering the handler for an specific event type.
+ *
+ * @param <E>
+ * the event object type
+ */
+public interface IEventHandler<E> {
+ /**
+ * This method is called to handle the given event.
+ *
+ * @param event
+ * the event to handle
+ */
+ void handle(E event);
+}
Propchange: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/util/IEventHandler.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/util/MarkerUtil.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/util/MarkerUtil.java?rev=760385&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/util/MarkerUtil.java (added)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/util/MarkerUtil.java Tue Mar 31 10:07:36 2009
@@ -0,0 +1,100 @@
+/*
+ * 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.util;
+
+import org.apache.uima.util.InvalidXMLException;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.xml.sax.SAXParseException;
+
+/**
+ * TODO: add javadoc here
+ */
+public final class MarkerUtil {
+ /**
+ * ID of the problem marker.
+ */
+ public static final String PROBLEM_MARKER = "org.apache.uima.caseditor.problem";
+
+ private MarkerUtil() {
+ // util class
+ }
+
+ /**
+ * Clears all markers of the given id for the given resource.
+ *
+ * @param resource
+ * @param markerId
+ * @throws CoreException
+ */
+ public static void clearMarkers(IResource resource, String markerId) throws CoreException {
+ if (resource.exists()) {
+ IMarker[] markers = resource.findMarkers(markerId, false, 0);
+
+ for (IMarker marker : markers) {
+ marker.delete();
+ }
+ }
+ }
+
+ /**
+ * Creates a new marker.
+ *
+ * @param resource
+ * @param errorMessage
+ * @throws CoreException
+ */
+ public static void createMarker(IResource resource, String errorMessage) throws CoreException {
+ IMarker marker = resource.createMarker(PROBLEM_MARKER);
+
+ marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
+ marker.setAttribute(IMarker.MARKER, IMarker.PROBLEM);
+
+ marker.setAttribute(IMarker.MESSAGE, errorMessage);
+ marker.setAttribute(IMarker.LINE_NUMBER, 1);
+ }
+
+ /**
+ * Creates a new marker.
+ *
+ * @param resource
+ * @param xmlException
+ * @throws CoreException
+ */
+ public static void createMarker(IResource resource, InvalidXMLException xmlException)
+ throws CoreException {
+ IMarker marker = resource.createMarker(PROBLEM_MARKER);
+
+ marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
+ marker.setAttribute(IMarker.MARKER, IMarker.PROBLEM);
+
+ Throwable causeException = xmlException.getCause();
+
+ if (causeException instanceof SAXParseException) {
+ SAXParseException parseException = (SAXParseException) causeException;
+
+ marker.setAttribute(IMarker.MESSAGE, parseException.getMessage());
+ marker.setAttribute(IMarker.LINE_NUMBER, parseException.getLineNumber());
+ } else {
+ marker.setAttribute(IMarker.MESSAGE, xmlException.getMessage());
+ }
+ }
+}
\ No newline at end of file
Propchange: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/util/MarkerUtil.java
------------------------------------------------------------------------------
svn:mime-type = text/plain