You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by pk...@apache.org on 2011/10/19 16:48:24 UTC
svn commit: r1186245 [2/2] - in /uima/sandbox/trunk/TextMarker:
uimaj-ep-textmarker-addons/ uimaj-ep-textmarker-addons/META-INF/
uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/
uimaj-ep-textmarker-addons/src/main/java/org/a...
Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/tree/ConditionNode.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/tree/ConditionNode.java?rev=1186245&r1=1186244&r2=1186245&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/tree/ConditionNode.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/tree/ConditionNode.java Wed Oct 19 14:48:22 2011
@@ -15,13 +15,14 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-*/
+ */
package org.apache.uima.textmarker.explain.tree;
import org.apache.uima.cas.Feature;
import org.apache.uima.cas.FeatureStructure;
import org.apache.uima.cas.TypeSystem;
+import org.apache.uima.textmarker.explain.ExplainConstants;
public class ConditionNode extends ExplainAbstractTreeNode implements IEvaluatedNode {
@@ -29,7 +30,7 @@ public class ConditionNode extends Expla
public ConditionNode(IExplainTreeNode parent, FeatureStructure fs, TypeSystem ts) {
super(parent, fs, ts);
- Feature f = fs.getType().getFeatureByBaseName(ExplainTree.VALUE);
+ Feature f = fs.getType().getFeatureByBaseName(ExplainConstants.VALUE);
matched = fs.getBooleanValue(f);
}
Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/tree/ExplainAbstractTreeNode.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/tree/ExplainAbstractTreeNode.java?rev=1186245&r1=1186244&r2=1186245&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/tree/ExplainAbstractTreeNode.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/tree/ExplainAbstractTreeNode.java Wed Oct 19 14:48:22 2011
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-*/
+ */
package org.apache.uima.textmarker.explain.tree;
@@ -24,8 +24,10 @@ import java.util.List;
import org.apache.uima.cas.FeatureStructure;
import org.apache.uima.cas.TypeSystem;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.eclipse.core.runtime.IAdaptable;
-public abstract class ExplainAbstractTreeNode implements IExplainTreeNode {
+public abstract class ExplainAbstractTreeNode implements IExplainTreeNode, IAdaptable {
private IExplainTreeNode parent;
@@ -78,4 +80,14 @@ public abstract class ExplainAbstractTre
return fs.toString();
}
+ public Object getAdapter(Class adapter) {
+
+ if (FeatureStructure.class.equals(adapter)) {
+ return getFeatureStructure();
+ } else if (AnnotationFS.class.equals(adapter) && getFeatureStructure() instanceof AnnotationFS) {
+ return getFeatureStructure();
+ }
+
+ return null;
+ }
}
Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/tree/ExplainTree.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/tree/ExplainTree.java?rev=1186245&r1=1186244&r2=1186245&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/tree/ExplainTree.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/tree/ExplainTree.java Wed Oct 19 14:48:22 2011
@@ -23,45 +23,17 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.uima.cas.ArrayFS;
+import org.apache.uima.cas.CAS;
import org.apache.uima.cas.FSIterator;
import org.apache.uima.cas.Feature;
import org.apache.uima.cas.FeatureStructure;
import org.apache.uima.cas.Type;
import org.apache.uima.cas.TypeSystem;
import org.apache.uima.cas.text.AnnotationFS;
-import org.apache.uima.cev.data.CEVData;
import org.apache.uima.textmarker.explain.ExplainConstants;
public class ExplainTree {
- public static final String BASE_CONDITION = "baseCondition";
-
- public static final String MATCHES = "matches";
-
- public static final String ELEMENTS = "elements";
-
- public static final String MATCHED = "matched";
-
- public static final String DELEGATES = "delegates";
-
- public static final String RULES = "rules";
-
- public static final String INNER_APPLY = "innerApply";
-
- public static final String CONDITIONS = "conditions";
-
- public static final String VALUE = "value";
-
- public static final String APPLIED = "applied";
-
- public static final String TRIED = "tried";
-
- public static final String ELEMENT = "element";
-
- public static final String RULE_ANCHOR = "ruleAnchor";
-
- public static final String TIME = "time";
-
private IExplainTreeNode root;
private Type ruleMatchType;
@@ -80,27 +52,27 @@ public class ExplainTree {
private Type failedRuleMatchType;
- public ExplainTree(CEVData casData) {
- this(casData, -1);
+ public ExplainTree(CAS cas) {
+ this(cas, -1);
}
- public ExplainTree(CEVData casData, int offset) {
- this(casData, offset, false);
+ public ExplainTree(CAS cas, int offset) {
+ this(cas, offset, false);
if (offset >= 0) {
prune(root);
}
}
- public ExplainTree(CEVData casData, int offset, boolean onlyRules) {
- createTree(casData, offset, onlyRules);
+ public ExplainTree(CAS cas, int offset, boolean onlyRules) {
+ createTree(cas, offset, onlyRules);
}
public IExplainTreeNode getRoot() {
return root;
}
- private void createTree(CEVData casData, int offset, boolean onlyRules) {
- TypeSystem ts = casData.getCAS().getTypeSystem();
+ private void createTree(CAS cas, int offset, boolean onlyRules) {
+ TypeSystem ts = cas.getTypeSystem();
Type scriptApply = ts.getType(ExplainConstants.SCRIPT_APPLY_TYPE);
blockApplyType = ts.getType(ExplainConstants.BLOCK_APPLY_TYPE);
@@ -114,7 +86,7 @@ public class ExplainTree {
if (scriptApply == null)
return;
- FSIterator<AnnotationFS> it = casData.getCAS().getAnnotationIndex(scriptApply).iterator();
+ FSIterator<AnnotationFS> it = cas.getAnnotationIndex(scriptApply).iterator();
root = new ApplyRootNode(null, ts);
if (it.isValid()) {
@@ -157,7 +129,7 @@ public class ExplainTree {
parent.addChild(blockNode);
processBlockRuleApply(fs, blockNode, ts, offset, onlyRules);
}
- Feature feature = blockApplyType.getFeatureByBaseName(INNER_APPLY);
+ Feature feature = blockApplyType.getFeatureByBaseName(ExplainConstants.INNER_APPLY);
FeatureStructure featureValue = fs.getFeatureValue(feature);
ArrayFS value = (ArrayFS) featureValue;
FeatureStructure[] fsarray = value.toArray();
@@ -179,7 +151,7 @@ public class ExplainTree {
RuleApplyNode ruleNode = new RuleApplyNode(parent, fs, ts);
parent.setBlockRuleApply(ruleNode);
- Feature feature = ruleApplyType.getFeatureByBaseName(RULES);
+ Feature feature = ruleApplyType.getFeatureByBaseName(ExplainConstants.RULES);
ArrayFS value = (ArrayFS) fs.getFeatureValue(feature);
if (value == null)
return;
@@ -191,7 +163,7 @@ public class ExplainTree {
ruleNode.addChild(failed);
for (FeatureStructure eachRuleMatch : fsarray) {
- Feature f = eachRuleMatch.getType().getFeatureByBaseName(MATCHED);
+ Feature f = eachRuleMatch.getType().getFeatureByBaseName(ExplainConstants.MATCHED);
boolean matchedValue = eachRuleMatch.getBooleanValue(f);
if (matchedValue) {
buildTree(eachRuleMatch, matched, ts, offset, onlyRules);
@@ -199,7 +171,7 @@ public class ExplainTree {
buildTree(eachRuleMatch, failed, ts, offset, onlyRules);
}
- Feature df = eachRuleMatch.getType().getFeatureByBaseName(DELEGATES);
+ Feature df = eachRuleMatch.getType().getFeatureByBaseName(ExplainConstants.DELEGATES);
if (df != null) {
ArrayFS dv = (ArrayFS) eachRuleMatch.getFeatureValue(df);
if (dv != null) {
@@ -221,7 +193,7 @@ public class ExplainTree {
RuleApplyNode ruleNode = new RuleApplyNode(parent, fs, ts);
parent.addChild(ruleNode);
- Feature feature = ruleApplyType.getFeatureByBaseName(RULES);
+ Feature feature = ruleApplyType.getFeatureByBaseName(ExplainConstants.RULES);
ArrayFS value = (ArrayFS) fs.getFeatureValue(feature);
FeatureStructure[] fsarray = value.toArray();
@@ -231,7 +203,7 @@ public class ExplainTree {
ruleNode.addChild(failed);
for (FeatureStructure eachRuleMatch : fsarray) {
- Feature f = eachRuleMatch.getType().getFeatureByBaseName(MATCHED);
+ Feature f = eachRuleMatch.getType().getFeatureByBaseName(ExplainConstants.MATCHED);
boolean matchedValue = eachRuleMatch.getBooleanValue(f);
if (matchedValue) {
buildTree(eachRuleMatch, matched, ts, offset, onlyRules);
@@ -239,7 +211,7 @@ public class ExplainTree {
buildTree(eachRuleMatch, failed, ts, offset, onlyRules);
}
- Feature df = eachRuleMatch.getType().getFeatureByBaseName(DELEGATES);
+ Feature df = eachRuleMatch.getType().getFeatureByBaseName(ExplainConstants.DELEGATES);
if (df != null) {
ArrayFS dv = (ArrayFS) eachRuleMatch.getFeatureValue(df);
if (dv != null) {
@@ -264,7 +236,7 @@ public class ExplainTree {
RuleElementRootNode remRoot = new RuleElementRootNode(matchNode, ts);
matchNode.addChild(remRoot);
- Feature feature = ruleMatchType.getFeatureByBaseName(ELEMENTS);
+ Feature feature = ruleMatchType.getFeatureByBaseName(ExplainConstants.ELEMENTS);
ArrayFS value = (ArrayFS) fs.getFeatureValue(feature);
FeatureStructure[] fsarray = value.toArray();
for (FeatureStructure each : fsarray) {
@@ -277,7 +249,7 @@ public class ExplainTree {
RuleElementMatchesNode remsNode = new RuleElementMatchesNode(parent, fs, ts);
parent.addChild(remsNode);
- Feature feature = ruleElementMatchesType.getFeatureByBaseName(MATCHES);
+ Feature feature = ruleElementMatchesType.getFeatureByBaseName(ExplainConstants.MATCHES);
ArrayFS value = (ArrayFS) fs.getFeatureValue(feature);
FeatureStructure[] fsarray = value.toArray();
for (FeatureStructure each : fsarray) {
@@ -293,18 +265,18 @@ public class ExplainTree {
RuleElementMatchNode remNode = new RuleElementMatchNode(parent, fs, ts);
parent.addChild(remNode);
- Feature feature = ruleElementMatchType.getFeatureByBaseName(BASE_CONDITION);
+ Feature feature = ruleElementMatchType.getFeatureByBaseName(ExplainConstants.BASE_CONDITION);
FeatureStructure base = fs.getFeatureValue(feature);
buildTree(base, remNode, ts, offset, onlyRules);
- feature = ruleElementMatchType.getFeatureByBaseName(CONDITIONS);
+ feature = ruleElementMatchType.getFeatureByBaseName(ExplainConstants.CONDITIONS);
ArrayFS value = (ArrayFS) fs.getFeatureValue(feature);
FeatureStructure[] fsarray = value.toArray();
for (FeatureStructure each : fsarray) {
buildTree(each, remNode, ts, offset, onlyRules);
}
- feature = fs.getType().getFeatureByBaseName(ExplainTree.ELEMENTS);
+ feature = fs.getType().getFeatureByBaseName(ExplainConstants.ELEMENTS);
value = (ArrayFS) fs.getFeatureValue(feature);
if (value != null) {
fsarray = value.toArray();
@@ -319,7 +291,7 @@ public class ExplainTree {
ConditionNode condNode = new ConditionNode(parent, fs, ts);
parent.addChild(condNode);
- Feature feature = evaluatedConditionType.getFeatureByBaseName(CONDITIONS);
+ Feature feature = evaluatedConditionType.getFeatureByBaseName(ExplainConstants.CONDITIONS);
ArrayFS value = (ArrayFS) fs.getFeatureValue(feature);
if (value != null) {
FeatureStructure[] fsarray = value.toArray();
Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/tree/RuleElementMatchNode.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/tree/RuleElementMatchNode.java?rev=1186245&r1=1186244&r2=1186245&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/tree/RuleElementMatchNode.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/tree/RuleElementMatchNode.java Wed Oct 19 14:48:22 2011
@@ -24,25 +24,26 @@ import org.apache.uima.cas.Feature;
import org.apache.uima.cas.FeatureStructure;
import org.apache.uima.cas.TypeSystem;
import org.apache.uima.cas.text.AnnotationFS;
-import org.apache.uima.cev.data.tree.ICEVAnnotationNode;
+import org.apache.uima.textmarker.caseditor.view.tree.IAnnotationNode;
+import org.apache.uima.textmarker.explain.ExplainConstants;
public class RuleElementMatchNode extends ExplainAbstractTreeNode implements IEvaluatedNode,
- ICEVAnnotationNode {
+ IAnnotationNode {
private boolean matched;
public RuleElementMatchNode(IExplainTreeNode parent, FeatureStructure fs, TypeSystem ts) {
super(parent, fs, ts);
- Feature f = fs.getType().getFeatureByBaseName(ExplainTree.BASE_CONDITION);
+ Feature f = fs.getType().getFeatureByBaseName(ExplainConstants.BASE_CONDITION);
FeatureStructure baseFS = fs.getFeatureValue(f);
- Feature baseFeat = baseFS.getType().getFeatureByBaseName(ExplainTree.VALUE);
+ Feature baseFeat = baseFS.getType().getFeatureByBaseName(ExplainConstants.VALUE);
matched = baseFS.getBooleanValue(baseFeat);
- f = fs.getType().getFeatureByBaseName(ExplainTree.CONDITIONS);
+ f = fs.getType().getFeatureByBaseName(ExplainConstants.CONDITIONS);
ArrayFS value = (ArrayFS) fs.getFeatureValue(f);
FeatureStructure[] fsarray = value.toArray();
for (FeatureStructure each : fsarray) {
- Feature eachFeat = each.getType().getFeatureByBaseName(ExplainTree.VALUE);
+ Feature eachFeat = each.getType().getFeatureByBaseName(ExplainConstants.VALUE);
boolean eachValue = each.getBooleanValue(eachFeat);
matched &= eachValue;
}
Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/tree/RuleMatchNode.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/tree/RuleMatchNode.java?rev=1186245&r1=1186244&r2=1186245&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/tree/RuleMatchNode.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/tree/RuleMatchNode.java Wed Oct 19 14:48:22 2011
@@ -15,17 +15,16 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-*/
+ */
package org.apache.uima.textmarker.explain.tree;
import org.apache.uima.cas.FeatureStructure;
import org.apache.uima.cas.TypeSystem;
import org.apache.uima.cas.text.AnnotationFS;
-import org.apache.uima.cev.data.tree.ICEVAnnotationNode;
+import org.apache.uima.textmarker.caseditor.view.tree.IAnnotationNode;
-
-public class RuleMatchNode extends ExplainAbstractTreeNode implements ICEVAnnotationNode {
+public class RuleMatchNode extends ExplainAbstractTreeNode implements IAnnotationNode {
public RuleMatchNode(IExplainTreeNode parent, FeatureStructure fs, TypeSystem ts) {
super(parent, fs, ts);
Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/searchStrategy/DescriptorFolderSearchStrategy.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/searchStrategy/DescriptorFolderSearchStrategy.java?rev=1186245&r1=1186244&r2=1186245&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/searchStrategy/DescriptorFolderSearchStrategy.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/searchStrategy/DescriptorFolderSearchStrategy.java Wed Oct 19 14:48:22 2011
@@ -20,41 +20,74 @@
package org.apache.uima.textmarker.searchStrategy;
import java.util.ArrayList;
-import java.util.LinkedList;
+import java.util.Collection;
import java.util.List;
-import org.apache.uima.cev.extension.ICEVSearchStrategy;
-import org.apache.uima.cev.searchStrategy.CEVCollectionContentProvider;
+import org.apache.uima.caseditor.ide.searchstrategy.ITypeSystemSearchStrategy;
+import org.apache.uima.textmarker.ide.core.TextMarkerNature;
import org.apache.uima.textmarker.ide.core.builder.TextMarkerProjectUtils;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectNature;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.dialogs.ListDialog;
-public class DescriptorFolderSearchStrategy implements ICEVSearchStrategy {
+public class DescriptorFolderSearchStrategy implements ITypeSystemSearchStrategy {
- private int priority;
-
- public DescriptorFolderSearchStrategy(int priority) {
- super();
- this.priority = priority;
+ private List<IFile> collectTypeSystems(IFolder folder) throws CoreException {
+ List<IFile> result = new ArrayList<IFile>();
+ for (IResource each : folder.members()) {
+ if (each instanceof IFolder) {
+ result.addAll(collectTypeSystems((IFolder) each));
+ } else if (each instanceof IFile && each.getFileExtension() != null
+ && each.getFileExtension().equals("xml")) {
+ result.add((IFile) each);
+ }
+ }
+ return result;
}
- public int getPriority() {
- return priority;
- }
+ @Override
+ public IFile findTypeSystem(IFile casFile) {
+ IProject project = casFile.getProject();
+
+ try {
+ IProjectNature nature = project.getNature(TextMarkerNature.NATURE_ID);
+ if (!(nature instanceof TextMarkerNature)) {
+ return null;
+ }
+ } catch (CoreException e) {
+ return null;
+ }
- public IFile searchDescriptor(IFile file) {
- IProject project = file.getProject();
IFolder folder = project.getFolder(TextMarkerProjectUtils.getDefaultDescriptorLocation());
try {
List<IFile> list = collectTypeSystems(folder);
ListDialog ld = new ListDialog(Display.getCurrent().getActiveShell());
- ld.setContentProvider(new CEVCollectionContentProvider<LinkedList<IFile>>());
+ ld.setContentProvider(new IStructuredContentProvider() {
+
+ @Override
+ public void dispose() {
+
+ }
+
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+
+ }
+
+ @Override
+ public Object[] getElements(Object inputElement) {
+ return ((Collection<?>) inputElement).toArray();
+ }
+
+ });
ld.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
@@ -77,19 +110,5 @@ public class DescriptorFolderSearchStrat
} catch (Exception e) {
return null;
}
-
- }
-
- private List<IFile> collectTypeSystems(IFolder folder) throws CoreException {
- List<IFile> result = new ArrayList<IFile>();
- for (IResource each : folder.members()) {
- if (each instanceof IFolder) {
- result.addAll(collectTypeSystems((IFolder) each));
- } else if (each instanceof IFile && each.getFileExtension() != null
- && each.getFileExtension().equals("xml")) {
- result.add((IFile) each);
- }
- }
- return result;
}
}
Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/searchStrategy/LastLaunchSearchStrategy.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/searchStrategy/LastLaunchSearchStrategy.java?rev=1186245&r1=1186244&r2=1186245&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/searchStrategy/LastLaunchSearchStrategy.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/searchStrategy/LastLaunchSearchStrategy.java Wed Oct 19 14:48:22 2011
@@ -19,10 +19,13 @@
package org.apache.uima.textmarker.searchStrategy;
-import org.apache.uima.cev.extension.ICEVSearchStrategy;
+import org.apache.uima.caseditor.ide.searchstrategy.ITypeSystemSearchStrategy;
+import org.apache.uima.textmarker.ide.core.TextMarkerNature;
import org.apache.uima.textmarker.ide.core.builder.TextMarkerProjectUtils;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectNature;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.ILaunchConfiguration;
@@ -30,21 +33,19 @@ import org.eclipse.debug.ui.DebugUITools
import org.eclipse.dltk.internal.launching.LaunchConfigurationUtils;
import org.eclipse.dltk.launching.ScriptLaunchConfigurationConstants;
-public class LastLaunchSearchStrategy implements ICEVSearchStrategy {
+public class LastLaunchSearchStrategy implements ITypeSystemSearchStrategy {
- private int priority;
-
- public LastLaunchSearchStrategy(int priority) {
- super();
- this.priority = priority;
- }
-
- public int getPriority() {
- return priority;
- }
-
- public IFile searchDescriptor(IFile file) {
- IProject project = file.getProject();
+ @Override
+ public IFile findTypeSystem(IFile casFile) {
+ IProject project = casFile.getProject();
+ try {
+ IProjectNature nature = project.getNature(TextMarkerNature.NATURE_ID);
+ if (!(nature instanceof TextMarkerNature)) {
+ return null;
+ }
+ } catch (CoreException e) {
+ return null;
+ }
ILaunchConfiguration lastRun = DebugUITools
.getLastLaunch("org.eclipse.debug.ui.launchGroup.run");
String scriptName = LaunchConfigurationUtils.getString(lastRun,
Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsView.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsView.java?rev=1186245&r1=1186244&r2=1186245&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsView.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsView.java Wed Oct 19 14:48:22 2011
@@ -15,23 +15,31 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-*/
+ */
package org.apache.uima.textmarker.statistics;
-import org.apache.uima.cev.views.CEVPageBookView;
-import org.eclipse.ui.IWorkbenchPart;
+import org.apache.uima.caseditor.editor.AnnotationEditor;
+import org.apache.uima.caseditor.editor.AnnotationEditorView;
+import org.apache.uima.caseditor.editor.ICasEditor;
+public class StatisticsView extends AnnotationEditorView {
-public class StatisticsView extends CEVPageBookView {
+ public static final String ID = "org.apache.uima.textmarker.explain.apply";
public StatisticsView() {
- super();
+ super("The instance view is currently not available.");
}
@Override
- protected PageRec doCreatePage(IWorkbenchPart part) {
- return doCreatePage(part, IStatisticsViewPage.class);
+ protected PageRec doCreatePage(ICasEditor editor) {
+ PageRec result = null;
+ if (editor.getDocument() != null && editor instanceof AnnotationEditor) {
+ StatisticsViewPage page = new StatisticsViewPage((AnnotationEditor) editor);
+ initPage(page);
+ page.createControl(getPageBook());
+ result = new PageRec(editor, page);
+ }
+ return result;
}
-
}
Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsViewPage.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsViewPage.java?rev=1186245&r1=1186244&r2=1186245&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsViewPage.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsViewPage.java Wed Oct 19 14:48:22 2011
@@ -29,11 +29,8 @@ import org.apache.uima.cas.CAS;
import org.apache.uima.cas.FSIterator;
import org.apache.uima.cas.FeatureStructure;
import org.apache.uima.cas.Type;
-import org.apache.uima.cas.text.AnnotationFS;
-import org.apache.uima.cev.data.CEVData;
-import org.apache.uima.cev.data.CEVDocument;
-import org.apache.uima.cev.editor.CEVViewer;
-import org.apache.uima.cev.extension.ICEVView;
+import org.apache.uima.caseditor.editor.AnnotationEditor;
+import org.apache.uima.caseditor.editor.ICasDocument;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
@@ -51,26 +48,25 @@ import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.ui.part.Page;
-public class StatisticsViewPage extends Page implements IStatisticsViewPage, ICEVView,
- IDoubleClickListener, ISelectionChangedListener {
+public class StatisticsViewPage extends Page implements IDoubleClickListener,
+ ISelectionChangedListener {
private static final String TYPE = "org.apache.uima.textmarker.type.Statistics";
- private CEVDocument casDoc;
-
private int current;
- private CEVViewer casViewer;
-
private Map<String, Image> images;
private TableViewer viewer;
- public StatisticsViewPage(CEVViewer casViewer, CEVDocument casDoc, int index) {
+ private AnnotationEditor editor;
+
+ private ICasDocument document;
+
+ public StatisticsViewPage(AnnotationEditor editor) {
super();
- this.casViewer = casViewer;
- this.casDoc = casDoc;
- this.current = index;
+ this.editor = editor;
+ this.document = editor.getDocument();
}
@Override
@@ -105,57 +101,15 @@ public class StatisticsViewPage extends
@Override
public void createControl(Composite parent) {
createViewer(parent);
- viewChanged(current);
- //
- //
- //
- // public void handleEvent(Event e) {
- // TableItem item = (TableItem) e.item;
- // int index = table.indexOf(item);
- // // int[] datum = data[index];
- // // item.setText(new String[] { Integer.toString(datum[0]), Integer.toString(datum[1]) });
- // }
- // });
- // // Add sort indicator and sort data when column selected
- // Listener sortListener = new Listener() {
- // public void handleEvent(Event e) {
- // // determine new sort column and direction
- // TableColumn sortColumn = table.getSortColumn();
- // TableColumn currentColumn = (TableColumn) e.widget;
- // int dir = table.getSortDirection();
- // if (sortColumn == currentColumn) {
- // dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
- // } else {
- // table.setSortColumn(currentColumn);
- // dir = SWT.UP;
- // }
- // // sort the data based on column and direction
- // final int index = currentColumn == cname ? 0 : 1;
- // final int direction = dir;
- // // Object[] data = new ;
- // // Arrays.sort(data, new Comparator() {
- // // public int compare(Object arg0, Object arg1) {
- // // int[] a = (int[]) arg0;
- // // int[] b = (int[]) arg1;
- // // if (a[index] == b[index])
- // // return 0;
- // // if (direction == SWT.UP) {
- // // return a[index] < b[index] ? -1 : 1;
- // // }
- // // return a[index] < b[index] ? 1 : -1;
- // // }
- // // });
- // // update data displayed in table
- // table.setSortDirection(dir);
- // table.clearAll();
- // }
- // };
- // cname.addListener(SWT.Selection, sortListener);
- // ctotal.addListener(SWT.Selection, sortListener);
- // camount.addListener(SWT.Selection, sortListener);
- // cpart.addListener(SWT.Selection, sortListener);
- // table.setSortColumn(cname);
- // table.setSortDirection(SWT.UP);
+ CAS cas = document.getCAS();
+ Type type = cas.getTypeSystem().getType(TYPE);
+ if (type != null) {
+ FSIterator<FeatureStructure> allIndexedFS = cas.getIndexRepository().getAllIndexedFS(type);
+ if (allIndexedFS.isValid()) {
+ inputChange(allIndexedFS.get());
+ }
+ }
+ viewer.refresh();
}
@@ -224,10 +178,6 @@ public class StatisticsViewPage extends
return viewer.getControl();
}
- public CEVData getCurrentCEVData() {
- return casDoc.getCASData(current);
- }
-
public void doubleClick(DoubleClickEvent event) {
}
@@ -237,44 +187,9 @@ public class StatisticsViewPage extends
}
}
- public void viewChanged(int newIndex) {
- getCurrentCEVData().removeAnnotationListener(this);
- current = newIndex;
- getCurrentCEVData().addAnnotationListener(this);
- CAS cas = getCurrentCEVData().getCAS();
- Type type = cas.getTypeSystem().getType(TYPE);
- if (type != null) {
- FSIterator allIndexedFS = cas.getIndexRepository().getAllIndexedFS(type);
- if (allIndexedFS.isValid()) {
- inputChange(allIndexedFS.get());
- }
- }
- viewer.refresh();
- }
-
- public void annotationsAdded(List<AnnotationFS> annots) {
- }
-
- public void annotationsRemoved(List<AnnotationFS> annots) {
- }
-
- public void annotationStateChanged(Type type) {
- }
-
- public void annotationStateChanged(AnnotationFS annot) {
- }
-
- public void colorChanged(Type type) {
- }
-
- public void newSelection(int offset) {
- }
-
+ @Override
public void selectionChanged(SelectionChangedEvent event) {
- }
- public void casChanged(CEVDocument casDocument) {
- this.casDoc = casDocument;
}
}
Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/searchStrategy/TestingSearchStrategy.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/searchStrategy/TestingSearchStrategy.java?rev=1186245&r1=1186244&r2=1186245&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/searchStrategy/TestingSearchStrategy.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/searchStrategy/TestingSearchStrategy.java Wed Oct 19 14:48:22 2011
@@ -15,36 +15,36 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-*/
+ */
package org.apache.uima.textmarker.testing.searchStrategy;
-import org.apache.uima.cev.extension.ICEVSearchStrategy;
+import org.apache.uima.caseditor.ide.searchstrategy.ITypeSystemSearchStrategy;
+import org.apache.uima.textmarker.ide.core.TextMarkerNature;
import org.apache.uima.textmarker.ide.core.builder.TextMarkerProjectUtils;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectNature;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
-
-public class TestingSearchStrategy implements ICEVSearchStrategy {
-
- private int priority;
-
- public TestingSearchStrategy(int priority) {
- super();
- this.priority = priority;
- }
+public class TestingSearchStrategy implements ITypeSystemSearchStrategy {
@Override
- public int getPriority() {
- return priority;
- }
+ public IFile findTypeSystem(IFile casFile) {
+ IPath location = casFile.getLocation();
+ IProject project = casFile.getProject();
+
+ try {
+ IProjectNature nature = project.getNature(TextMarkerNature.NATURE_ID);
+ if (!(nature instanceof TextMarkerNature)) {
+ return null;
+ }
+ } catch (CoreException e) {
+ return null;
+ }
- @Override
- public IFile searchDescriptor(IFile file) {
- IPath location = file.getLocation();
- IProject project = file.getProject();
IFolder testFolder = project.getFolder(TextMarkerProjectUtils.getDefaultTestLocation());
IFolder descFolder = project.getFolder(TextMarkerProjectUtils.getDefaultDescriptorLocation());
IPath relativeTo = location.makeRelativeTo(testFolder.getLocation());
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/EvaluationContentProvider.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/EvaluationContentProvider.java?rev=1186245&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/EvaluationContentProvider.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/EvaluationContentProvider.java Wed Oct 19 14:48:22 2011
@@ -0,0 +1,102 @@
+/*
+ * 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.textmarker.testing.ui.views;
+
+import org.apache.uima.textmarker.caseditor.view.tree.AnnotationTreeNode;
+import org.apache.uima.textmarker.caseditor.view.tree.ITreeNode;
+import org.apache.uima.textmarker.caseditor.view.tree.TypeTreeNode;
+import org.apache.uima.textmarker.testing.ui.views.tree.TestEvaluationTree;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+public class EvaluationContentProvider implements ITreeContentProvider {
+
+ private Object[] empty = new Object[] {};
+
+ private String type;
+
+ public EvaluationContentProvider(String type) {
+ super();
+ this.type = type;
+ }
+
+ @Override
+ public Object[] getChildren(Object parentElement) {
+ if (parentElement instanceof TestEvaluationTree) {
+ TypeTreeNode root = (TypeTreeNode) ((TestEvaluationTree) parentElement).getRoot();
+ if (root == null) {
+ return empty;
+ }
+ for (ITreeNode node : root.getChildren()) {
+ if (node instanceof TypeTreeNode) {
+ if (((TypeTreeNode) node).getType().getName().equals(type)) {
+ return node.getChildren();
+ }
+ }
+ }
+ }
+ if (parentElement instanceof TypeTreeNode) {
+ TypeTreeNode node = (TypeTreeNode) parentElement;
+ return node.getChildren();
+ }
+ if (parentElement instanceof AnnotationTreeNode) {
+ AnnotationTreeNode node = (AnnotationTreeNode) parentElement;
+ return node.getChildren();
+ }
+ return empty;
+ }
+
+ @Override
+ public Object getParent(Object element) {
+ if (element instanceof ITreeNode) {
+ return ((ITreeNode) element).getParent();
+ }
+ return null;
+ }
+
+ @Override
+ public boolean hasChildren(Object element) {
+ if (element instanceof TestEvaluationTree) {
+ TypeTreeNode root = (TypeTreeNode) ((TestEvaluationTree) element).getRoot();
+ return root.hasChildren();
+
+ }
+ if (element instanceof ITreeNode) {
+ return ((ITreeNode) element).hasChildren();
+ }
+ return false;
+ }
+
+ @Override
+ public Object[] getElements(Object inputElement) {
+ return getChildren(inputElement);
+ }
+
+ @Override
+ public void dispose() {
+
+ }
+
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+
+ }
+
+}
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/EvaluationLabelProvider.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/EvaluationLabelProvider.java?rev=1186245&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/EvaluationLabelProvider.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/EvaluationLabelProvider.java Wed Oct 19 14:48:22 2011
@@ -0,0 +1,84 @@
+/*
+ * 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.textmarker.testing.ui.views;
+
+import org.apache.uima.textmarker.caseditor.view.tree.AnnotationTreeNode;
+import org.apache.uima.textmarker.caseditor.view.tree.FeatureTreeNode;
+import org.apache.uima.textmarker.caseditor.view.tree.TextUtils;
+import org.apache.uima.textmarker.caseditor.view.tree.TypeTreeNode;
+import org.apache.uima.textmarker.testing.evaluator.ICasEvaluator;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+
+public class EvaluationLabelProvider extends LabelProvider implements ILabelProvider {
+
+ private EvaluationViewPage owner;
+
+ public EvaluationLabelProvider() {
+ super();
+ }
+
+ public EvaluationLabelProvider(EvaluationViewPage owner) {
+ super();
+ this.owner = owner;
+ }
+
+ @Override
+ public String getText(Object element) {
+ if (element instanceof AnnotationTreeNode) {
+ AnnotationTreeNode fnNode = (AnnotationTreeNode) element;
+ if (fnNode.getAnnotation() != null) {
+ String typeName = fnNode.getAnnotation().getType().getName();
+ String coveredText = fnNode.getAnnotation().getCoveredText();
+ coveredText = coveredText.replaceAll("[\\n]", "").replaceAll("[\\r]", "");
+ if (typeName.equals(ICasEvaluator.FALSE_POSITIVE)
+ || typeName.equals(ICasEvaluator.FALSE_NEGATIVE)
+ || typeName.equals(ICasEvaluator.TRUE_POSITIVE)) {
+ return coveredText;
+ }
+ String name = TextUtils.shrinkNamespace(fnNode.getAnnotation().getType().getName());
+ return (name + ": " + coveredText);
+ }
+ }
+ if (element instanceof TypeTreeNode) {
+ TypeTreeNode testNode = (TypeTreeNode) element;
+ return TextUtils.shrinkNamespace(testNode.getType().getName());
+ }
+ if (element instanceof FeatureTreeNode) {
+ FeatureTreeNode fNode = (FeatureTreeNode) element;
+ return fNode.getName();
+ }
+
+ return "error";
+ }
+
+ @Override
+ public Image getImage(Object element) {
+ // if (element instanceof TypeTreeNode) {
+ // return owner.getCurrentData().getIcon(((TypeTreeNode) element).getType());
+ // }
+ // if (element instanceof AnnotationTreeNode) {
+ // return owner.getCurrentData().getIcon(
+ // ((AnnotationTreeNode) element).getAnnotation().getType());
+ // }
+ return null;
+ }
+}
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/EvaluationViewPage.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/EvaluationViewPage.java?rev=1186245&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/EvaluationViewPage.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/EvaluationViewPage.java Wed Oct 19 14:48:22 2011
@@ -0,0 +1,170 @@
+/*
+ * 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.textmarker.testing.ui.views;
+
+import java.util.Collection;
+import java.util.Map;
+
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.caseditor.editor.AnnotationEditor;
+import org.apache.uima.caseditor.editor.ICasDocument;
+import org.apache.uima.caseditor.editor.ICasDocumentListener;
+import org.apache.uima.textmarker.caseditor.view.tree.AnnotationTreeViewDragListener;
+import org.apache.uima.textmarker.testing.ui.views.tree.TestEvaluationTree;
+import org.eclipse.jface.viewers.CheckboxTreeViewer;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.ISelectionListener;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.part.IPageSite;
+import org.eclipse.ui.part.Page;
+
+public class EvaluationViewPage extends Page implements ICasDocumentListener, ISelectionListener {
+
+ private CheckboxTreeViewer viewer;
+
+ int current = 0;
+
+ private Map<String, Image> images;
+
+ private AnnotationEditor editor;
+
+ private ICasDocument document;
+
+ private String type;
+
+ public EvaluationViewPage(String type, AnnotationEditor editor) {
+ super();
+ this.type = type;
+ this.editor = editor;
+ this.document = editor.getDocument();
+ }
+
+ @Override
+ public Control getControl() {
+ return viewer.getControl();
+ }
+
+ @Override
+ public void setFocus() {
+ viewer.getControl().setFocus();
+ }
+
+ @Override
+ public void init(IPageSite pageSite) {
+ super.init(pageSite);
+ }
+
+ public TreeViewer getTreeViewer() {
+ return viewer;
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ viewer = new CheckboxTreeViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
+ viewer.setContentProvider(new EvaluationContentProvider(type));
+ viewer.setLabelProvider(new EvaluationLabelProvider(this));
+
+ int ops = DND.DROP_COPY | DND.DROP_MOVE;
+ Transfer[] transfers = new Transfer[] { TextTransfer.getInstance() };
+ viewer.addDragSupport(ops, transfers, new AnnotationTreeViewDragListener(viewer));
+
+ getSite().setSelectionProvider(viewer);
+ getSite().getPage().addSelectionListener(this);
+
+ document.addChangeListener(this);
+
+ reloadTree();
+ }
+
+ private void reloadTree() {
+ TestEvaluationTree tree = new TestEvaluationTree();
+ tree.createTree(document.getCAS());
+ viewer.setInput(tree);
+ viewer.refresh();
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ getSite().getPage().removeSelectionListener(this);
+ document.removeChangeListener(this);
+ if (images != null) {
+ for (Image each : images.values()) {
+ each.dispose();
+ }
+ }
+ }
+
+ @Override
+ public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void added(FeatureStructure newFeatureStructure) {
+
+ }
+
+ @Override
+ public void added(Collection<FeatureStructure> newFeatureStructure) {
+
+ }
+
+ @Override
+ public void removed(FeatureStructure deletedFeatureStructure) {
+
+ }
+
+ @Override
+ public void removed(Collection<FeatureStructure> deletedFeatureStructure) {
+
+ }
+
+ @Override
+ public void updated(FeatureStructure featureStructure) {
+
+ }
+
+ @Override
+ public void updated(Collection<FeatureStructure> featureStructure) {
+
+ }
+
+ @Override
+ public void changed() {
+ reloadTree();
+
+ }
+
+ @Override
+ public void viewChanged(String oldViewName, String newViewName) {
+ reloadTree();
+ }
+
+}
Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/TestViewPage.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/TestViewPage.java?rev=1186245&r1=1186244&r2=1186245&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/TestViewPage.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/TestViewPage.java Wed Oct 19 14:48:22 2011
@@ -32,6 +32,9 @@ import org.apache.uima.textmarker.testin
import org.apache.uima.textmarker.testing.ui.views.evalDataTable.EvalTableLabelProvider;
import org.apache.uima.textmarker.testing.ui.views.evalDataTable.TypeEvalTableConst;
import org.apache.uima.textmarker.testing.ui.views.evalDataTable.TypeTableSorter;
+import org.apache.uima.textmarker.testing.ui.views.fn.FalseNegativeView;
+import org.apache.uima.textmarker.testing.ui.views.fp.FalsePositiveView;
+import org.apache.uima.textmarker.testing.ui.views.tp.TruePositiveView;
import org.apache.uima.textmarker.testing.ui.views.util.CASLoader;
import org.apache.uima.textmarker.testing.ui.views.util.Caretaker;
import org.apache.uima.textmarker.testing.ui.views.util.EvalDataProcessor;
@@ -224,7 +227,7 @@ public class TestViewPage extends Page i
if (element instanceof TestCasData) {
TestCasData data = (TestCasData) element;
if (data.getResultPath() != null) {
- openInCEV(data.getResultPath());
+ openInCasEditor(data.getResultPath());
}
}
}
@@ -328,18 +331,26 @@ public class TestViewPage extends Page i
}
- protected void openInCEV(IPath resultPath) {
- IPath s = resultPath;
+ protected void openInCasEditor(IPath resultPath) {
if (resultPath == null) {
return;
}
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IFile file = workspace.getRoot().getFileForLocation(resultPath);
+
+ if (!file.isSynchronized(IResource.DEPTH_ZERO)) {
+ try {
+ file.refreshLocal(IResource.DEPTH_ZERO, new NullProgressMonitor());
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
try {
- page.openEditor(new FileEditorInput(file), "org.apache.uima.cev.editor.CEVViewer");
- page.showView("org.apache.uima.textmarker.testing.falsePositive");
- page.showView("org.apache.uima.textmarker.testing.falseNegative");
+ page.openEditor(new FileEditorInput(file), "org.apache.uima.caseditor.editor");
+ page.showView(TruePositiveView.ID);
+ page.showView(FalsePositiveView.ID);
+ page.showView(FalseNegativeView.ID);
} catch (PartInitException e) {
e.printStackTrace();
}
Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/fn/FalseNegativeView.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/fn/FalseNegativeView.java?rev=1186245&r1=1186244&r2=1186245&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/fn/FalseNegativeView.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/fn/FalseNegativeView.java Wed Oct 19 14:48:22 2011
@@ -15,23 +15,34 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-*/
+ */
package org.apache.uima.textmarker.testing.ui.views.fn;
-import org.apache.uima.cev.views.CEVPageBookView;
-import org.eclipse.ui.IWorkbenchPart;
+import org.apache.uima.caseditor.editor.AnnotationEditor;
+import org.apache.uima.caseditor.editor.AnnotationEditorView;
+import org.apache.uima.caseditor.editor.ICasEditor;
+import org.apache.uima.textmarker.testing.evaluator.ICasEvaluator;
+import org.apache.uima.textmarker.testing.ui.views.EvaluationViewPage;
+public class FalseNegativeView extends AnnotationEditorView {
-public class FalseNegativeView extends CEVPageBookView {
+ public static final String ID = "org.apache.uima.textmarker.testing.falseNegative";
public FalseNegativeView() {
- super();
+ super("The instance view is currently not available.");
}
@Override
- protected PageRec doCreatePage(IWorkbenchPart part) {
- return doCreatePage(part, IFalseNegativeViewPage.class);
+ protected PageRec doCreatePage(ICasEditor editor) {
+ PageRec result = null;
+ if (editor.getDocument() != null && editor instanceof AnnotationEditor) {
+ EvaluationViewPage page = new EvaluationViewPage(ICasEvaluator.FALSE_NEGATIVE,
+ (AnnotationEditor) editor);
+ initPage(page);
+ page.createControl(getPageBook());
+ result = new PageRec(editor, page);
+ }
+ return result;
}
-
}
Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/fp/FalsePositiveView.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/fp/FalsePositiveView.java?rev=1186245&r1=1186244&r2=1186245&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/fp/FalsePositiveView.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/fp/FalsePositiveView.java Wed Oct 19 14:48:22 2011
@@ -15,22 +15,34 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-*/
+ */
package org.apache.uima.textmarker.testing.ui.views.fp;
-import org.apache.uima.cev.views.CEVPageBookView;
-import org.eclipse.ui.IWorkbenchPart;
+import org.apache.uima.caseditor.editor.AnnotationEditor;
+import org.apache.uima.caseditor.editor.AnnotationEditorView;
+import org.apache.uima.caseditor.editor.ICasEditor;
+import org.apache.uima.textmarker.testing.evaluator.ICasEvaluator;
+import org.apache.uima.textmarker.testing.ui.views.EvaluationViewPage;
+public class FalsePositiveView extends AnnotationEditorView {
-public class FalsePositiveView extends CEVPageBookView {
+ public static final String ID = "org.apache.uima.textmarker.testing.falsePositive";
public FalsePositiveView() {
- super();
+ super("The instance view is currently not available.");
}
@Override
- protected PageRec doCreatePage(IWorkbenchPart part) {
- return doCreatePage(part, IFalsePositiveViewPage.class);
+ protected PageRec doCreatePage(ICasEditor editor) {
+ PageRec result = null;
+ if (editor.getDocument() != null && editor instanceof AnnotationEditor) {
+ EvaluationViewPage page = new EvaluationViewPage(ICasEvaluator.FALSE_POSITIVE,
+ (AnnotationEditor) editor);
+ initPage(page);
+ page.createControl(getPageBook());
+ result = new PageRec(editor, page);
+ }
+ return result;
}
}
Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tp/TruePositiveView.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tp/TruePositiveView.java?rev=1186245&r1=1186244&r2=1186245&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tp/TruePositiveView.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tp/TruePositiveView.java Wed Oct 19 14:48:22 2011
@@ -15,22 +15,34 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-*/
+ */
package org.apache.uima.textmarker.testing.ui.views.tp;
-import org.apache.uima.cev.views.CEVPageBookView;
-import org.eclipse.ui.IWorkbenchPart;
+import org.apache.uima.caseditor.editor.AnnotationEditor;
+import org.apache.uima.caseditor.editor.AnnotationEditorView;
+import org.apache.uima.caseditor.editor.ICasEditor;
+import org.apache.uima.textmarker.testing.evaluator.ICasEvaluator;
+import org.apache.uima.textmarker.testing.ui.views.EvaluationViewPage;
+public class TruePositiveView extends AnnotationEditorView {
-public class TruePositiveView extends CEVPageBookView {
+ public static final String ID = "org.apache.uima.textmarker.testing.truePositive";
public TruePositiveView() {
- super();
+ super("The instance view is currently not available.");
}
@Override
- protected PageRec doCreatePage(IWorkbenchPart part) {
- return doCreatePage(part, ITruePositiveViewPage.class);
+ protected PageRec doCreatePage(ICasEditor editor) {
+ PageRec result = null;
+ if (editor.getDocument() != null && editor instanceof AnnotationEditor) {
+ EvaluationViewPage page = new EvaluationViewPage(ICasEvaluator.TRUE_POSITIVE,
+ (AnnotationEditor) editor);
+ initPage(page);
+ page.createControl(getPageBook());
+ result = new PageRec(editor, page);
+ }
+ return result;
}
}
Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tree/TestEvaluationTree.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tree/TestEvaluationTree.java?rev=1186245&r1=1186244&r2=1186245&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tree/TestEvaluationTree.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tree/TestEvaluationTree.java Wed Oct 19 14:48:22 2011
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-*/
+ */
package org.apache.uima.textmarker.testing.ui.views.tree;
@@ -25,15 +25,14 @@ import org.apache.uima.cas.Feature;
import org.apache.uima.cas.FeatureStructure;
import org.apache.uima.cas.Type;
import org.apache.uima.cas.text.AnnotationFS;
-import org.apache.uima.cev.data.tree.CEVAnnotationTreeNode;
-import org.apache.uima.cev.data.tree.CEVTypeTreeNode;
-import org.apache.uima.cev.data.tree.ICEVTreeNode;
+import org.apache.uima.textmarker.caseditor.view.tree.AnnotationTreeNode;
+import org.apache.uima.textmarker.caseditor.view.tree.ITreeNode;
+import org.apache.uima.textmarker.caseditor.view.tree.TypeTreeNode;
import org.apache.uima.textmarker.testing.evaluator.ICasEvaluator;
-
public class TestEvaluationTree {
- private CEVTypeTreeNode root;
+ private TypeTreeNode root;
public TestEvaluationTree() {
@@ -49,12 +48,12 @@ public class TestEvaluationTree {
}
// Creating RootNode and children that function as root nodes
// for the FalsePositive /FalseNegative subtrees
- root = new CEVTypeTreeNode(null, cas.getAnnotationType());
+ root = new TypeTreeNode(null, cas.getAnnotationType());
boolean containsEvalInfos = false;
- CEVTypeTreeNode fproot = new CEVTypeTreeNode(root, falsePositiveType);
- CEVTypeTreeNode fnroot = new CEVTypeTreeNode(root, falseNegativeType);
- CEVTypeTreeNode tproot = new CEVTypeTreeNode(root, truePositiveType);
+ TypeTreeNode fproot = new TypeTreeNode(root, falsePositiveType);
+ TypeTreeNode fnroot = new TypeTreeNode(root, falseNegativeType);
+ TypeTreeNode tproot = new TypeTreeNode(root, truePositiveType);
// Iterating through CAS and adding nodes to according subtrees
@@ -69,7 +68,7 @@ public class TestEvaluationTree {
// }
}
- private void addEvalNodes(CAS cas, Type falsePositiveType, CEVTypeTreeNode fproot) {
+ private void addEvalNodes(CAS cas, Type falsePositiveType, TypeTreeNode fproot) {
FSIterator<AnnotationFS> iter = cas.getAnnotationIndex(falsePositiveType).iterator();
while (iter.isValid()) {
FeatureStructure fs = iter.get();
@@ -77,23 +76,23 @@ public class TestEvaluationTree {
AnnotationFS a = (AnnotationFS) fs;
Feature original = fs.getType().getFeatureByBaseName(ICasEvaluator.ORIGINAL);
FeatureStructure originalfs = fs.getFeatureValue(original);
- CEVTypeTreeNode parentTypeNode = containsTypeNode(fproot, originalfs);
+ TypeTreeNode parentTypeNode = containsTypeNode(fproot, originalfs);
if (parentTypeNode == null && originalfs != null) {
- parentTypeNode = new CEVTypeTreeNode(fproot, originalfs.getType());
+ parentTypeNode = new TypeTreeNode(fproot, originalfs.getType());
fproot.addChild(parentTypeNode);
}
- CEVAnnotationTreeNode newNode = new CEVAnnotationTreeNode(parentTypeNode, a);
+ AnnotationTreeNode newNode = new AnnotationTreeNode(parentTypeNode, a);
parentTypeNode.addChild(newNode);
}
iter.moveToNext();
}
}
- private CEVTypeTreeNode containsTypeNode(CEVTypeTreeNode fproot, FeatureStructure originalfs) {
- ICEVTreeNode[] children = fproot.getChildren();
- for (ICEVTreeNode each : children) {
- if (each instanceof CEVTypeTreeNode) {
- CEVTypeTreeNode node = (CEVTypeTreeNode) each;
+ private TypeTreeNode containsTypeNode(TypeTreeNode fproot, FeatureStructure originalfs) {
+ ITreeNode[] children = fproot.getChildren();
+ for (ITreeNode each : children) {
+ if (each instanceof TypeTreeNode) {
+ TypeTreeNode node = (TypeTreeNode) each;
if (node.getType().equals(originalfs.getType())) {
return node;
}
@@ -102,7 +101,7 @@ public class TestEvaluationTree {
return null;
}
- public ICEVTreeNode getRoot() {
+ public ITreeNode getRoot() {
return this.root;
}
Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/core/builder/TextMarkerBuilder.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/core/builder/TextMarkerBuilder.java?rev=1186245&r1=1186244&r2=1186245&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/core/builder/TextMarkerBuilder.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/core/builder/TextMarkerBuilder.java Wed Oct 19 14:48:22 2011
@@ -125,6 +125,7 @@ public class TextMarkerBuilder extends S
IResource findMember = folder.findMember(iPath);
if (findMember != null) {
findMember.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ findMember.getParent().refreshLocal(IResource.DEPTH_ONE, new NullProgressMonitor());
}
}