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 2012/07/12 10:58:07 UTC
svn commit: r1360586 [1/3] - in /uima/sandbox/trunk/TextMarker:
uimaj-ep-textmarker-addons/
uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/addons/
uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/
uimaj-e...
Author: pkluegl
Date: Thu Jul 12 08:58:05 2012
New Revision: 1360586
URL: http://svn.apache.org/viewvc?rev=1360586&view=rev
Log:
UIMA-2343
- added new debug fs for storing the creator of an annotation
- added new view for presenting the rule
- linked rule visualizations with the editor (double click)
- fixed some boundaries of ast elements
Added:
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/ExplainUtils.java
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/createdBy/
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/createdBy/CreatedByContentProvider.java
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/createdBy/CreatedByLabelProvider.java
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/createdBy/CreatedByView.java
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/createdBy/CreatedByViewPage.java
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/core/codeassist/TextMarkerRuleIdVisitor.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/type/DebugCreatedBy.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/type/DebugCreatedBy_Type.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/visitor/CreatedByVisitor.java
Modified:
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/plugin.xml
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/addons/TextMarkerAddonsPlugin.java
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/ExplainConstants.java
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/apply/ApplyViewPage.java
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/TestViewPage.java
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-caseditor/src/main/java/org/apache/uima/textmarker/caseditor/view/tree/AnnotationTreeNode.java
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/antlr3/org/apache/uima/textmarker/ide/core/parser/TextMarkerParser.g
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/formatter/TextMarkerFormattedPrinter.java
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/launching/TextMarkerInterpreterRunner.java
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/AbstractFactory.java
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/ScriptFactory.java
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerBlock.java
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerRule.java
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/ExplainPerspective.java
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/editor/TextMarkerEditor.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/TextMarkerModule.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/TextMarkerScriptFactory.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/TextMarkerStream.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/AbstractMarkAction.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/CallAction.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/CreateAction.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/ExecAction.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/ExpandAction.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/GatherAction.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/MarkAction.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/MarkFastAction.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/MarkLastAction.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/MarkTableAction.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/TransferAction.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/TrieAction.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/engine/BasicEngine.xml
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/engine/InternalTypeSystem.xml
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/engine/TextMarkerEngine.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/type/DebugBlockApply.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/type/DebugBlockApply_Type.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/type/DebugEvaluatedCondition.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/type/DebugEvaluatedCondition_Type.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/type/DebugFailedRuleMatch.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/type/DebugFailedRuleMatch_Type.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/type/DebugMatchedRuleMatch.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/type/DebugMatchedRuleMatch_Type.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/type/DebugRuleApply.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/type/DebugRuleApply_Type.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/type/DebugRuleElementMatch.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/type/DebugRuleElementMatch_Type.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/type/DebugRuleElementMatches.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/type/DebugRuleElementMatches_Type.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/type/DebugRuleMatch.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/type/DebugRuleMatch_Type.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/type/DebugScriptApply.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/type/DebugScriptApply_Type.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/type/EvalAnnotation.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/type/EvalAnnotation_Type.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/type/FalseNegative.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/type/FalseNegative_Type.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/type/FalsePositive.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/type/FalsePositive_Type.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/type/ProfiledAnnotation.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/type/ProfiledAnnotation_Type.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/type/Statistics.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/type/Statistics_Type.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/type/TextMarkerAnnotation.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/type/TextMarkerAnnotation_Type.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/type/TextMarkerBasic.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/type/TextMarkerBasic_Type.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/type/TextMarkerColoring.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/type/TextMarkerColoring_Type.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/type/TextMarkerFrame.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/type/TextMarkerFrame_Type.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/type/TruePositive.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/type/TruePositive_Type.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/visitor/DebugInfoCollectorVisitor.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/visitor/DebugInfoFactory.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/visitor/InferenceCrowd.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/visitor/StatisticsVisitor.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/visitor/TextMarkerInferenceVisitor.java
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/visitor/TimeProfilerVisitor.java
Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/plugin.xml
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/plugin.xml?rev=1360586&r1=1360585&r2=1360586&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/plugin.xml (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/plugin.xml Thu Jul 12 08:58:05 2012
@@ -554,6 +554,14 @@ under the License.
id="org.apache.uima.textmarker.explain.rulelist"
name="Rule List">
</view>
+ <view
+ category="org.apache.uima.textmarker.ide.ui"
+ class="org.apache.uima.textmarker.explain.createdBy.CreatedByView"
+ icon="icons/font_add.png"
+ id="org.apache.uima.textmarker.explain.createdBy"
+ name="Created By"
+ restorable="true">
+ </view>
</extension>
<extension
point="org.apache.uima.caseditor.ide.searchstrategy">
Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/addons/TextMarkerAddonsPlugin.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/addons/TextMarkerAddonsPlugin.java?rev=1360586&r1=1360585&r2=1360586&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/addons/TextMarkerAddonsPlugin.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/addons/TextMarkerAddonsPlugin.java Thu Jul 12 08:58:05 2012
@@ -1,3 +1,22 @@
+/*
+ * 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.addons;
import java.util.ArrayList;
Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/ExplainConstants.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/ExplainConstants.java?rev=1360586&r1=1360585&r2=1360586&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/ExplainConstants.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/ExplainConstants.java Thu Jul 12 08:58:05 2012
@@ -1,3 +1,22 @@
+/*
+ * 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.explain;
import org.apache.uima.textmarker.engine.TextMarkerEngine;
@@ -50,4 +69,8 @@ public class ExplainConstants {
public static final String RULE_ANCHOR = "ruleAnchor";
public static final String TIME = "time";
+
+ public static final String ID = "id";
+
+ public static final String SCRIPT = "script";
}
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/ExplainUtils.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/ExplainUtils.java?rev=1360586&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/ExplainUtils.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/ExplainUtils.java Thu Jul 12 08:58:05 2012
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.textmarker.explain;
+
+import org.apache.uima.textmarker.addons.TextMarkerAddonsPlugin;
+import org.apache.uima.textmarker.ide.ui.editor.TextMarkerEditor;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.FileEditorInput;
+
+public class ExplainUtils {
+
+ public static void openInTextMarkerEditor(IPath resultPath, int id) {
+ if (resultPath == null) {
+ return;
+ }
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ IFile file = workspace.getRoot().getFileForLocation(resultPath);
+ try {
+ IEditorPart openEditor = page.openEditor(new FileEditorInput(file), "org.apache.uima.textmarker.ide.ui.editor.TextMarkerEditor");
+ TextMarkerEditor tme = (TextMarkerEditor) openEditor;
+ tme.highlightElement(id);
+ } catch (PartInitException e) {
+ TextMarkerAddonsPlugin.error(e);
+ }
+ }
+
+}
Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/apply/ApplyViewPage.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/apply/ApplyViewPage.java?rev=1360586&r1=1360585&r2=1360586&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/apply/ApplyViewPage.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/apply/ApplyViewPage.java Thu Jul 12 08:58:05 2012
@@ -20,18 +20,41 @@
package org.apache.uima.textmarker.explain.apply;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
+import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.Feature;
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.Type;
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.caseditor.editor.ICasEditorInputListener;
import org.apache.uima.textmarker.addons.TextMarkerAddonsPlugin;
+import org.apache.uima.textmarker.engine.TextMarkerEngine;
import org.apache.uima.textmarker.explain.ExplainConstants;
+import org.apache.uima.textmarker.explain.ExplainUtils;
import org.apache.uima.textmarker.explain.tree.ExplainTree;
+import org.apache.uima.textmarker.explain.tree.RuleApplyNode;
+import org.apache.uima.textmarker.ide.core.builder.TextMarkerProjectUtils;
+import org.apache.uima.textmarker.visitor.CreatedByVisitor;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.dltk.core.DLTKCore;
+import org.eclipse.dltk.core.IScriptProject;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseEvent;
@@ -41,10 +64,12 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.part.IPageSite;
import org.eclipse.ui.part.Page;
-public class ApplyViewPage extends Page implements ISelectionListener, ICasEditorInputListener {
+public class ApplyViewPage extends Page implements ISelectionListener, ICasEditorInputListener,
+ IDoubleClickListener {
protected TreeViewer viewer;
@@ -120,6 +145,7 @@ public class ApplyViewPage extends Page
ExplainTree tree = new ExplainTree(document.getCAS());
viewer.setInput(tree.getRoot());
+ viewer.addDoubleClickListener(this);
getSite().setSelectionProvider(viewer);
getSite().getPage().addSelectionListener(this);
editor.addCasEditorInputListener(this);
@@ -127,7 +153,43 @@ public class ApplyViewPage extends Page
}
public void doubleClick(DoubleClickEvent event) {
-
+ ISelection selection = event.getSelection();
+ if (!selection.isEmpty() && selection instanceof TreeSelection) {
+ TreeSelection s = (TreeSelection) selection;
+ Object firstElement = s.getFirstElement();
+ if (firstElement instanceof RuleApplyNode) {
+ RuleApplyNode node = (RuleApplyNode) firstElement;
+ FeatureStructure fs = node.getFeatureStructure();
+ if (fs.getType().getName().equals(ExplainConstants.RULE_APPLY_TYPE)) {
+ Type t = fs.getType();
+ Feature featureId = t.getFeatureByBaseName(ExplainConstants.ID);
+ Feature featureScript = t.getFeatureByBaseName(ExplainConstants.SCRIPT);
+ int id = fs.getIntValue(featureId);
+ String script = fs.getStringValue(featureScript);
+ IEditorInput editorInput = editor.getEditorInput();
+ if (editorInput instanceof FileEditorInput) {
+ FileEditorInput fei = (FileEditorInput) editorInput;
+ IPath path = fei.getPath();
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ IWorkspaceRoot workspaceRoot = workspace.getRoot();
+ IFile iFile = workspaceRoot.getFileForLocation(path);
+ IProject project = iFile.getProject();
+ IScriptProject scriptProject = DLTKCore.create(project);
+ List<IFolder> allScriptFolders;
+ try {
+ allScriptFolders = TextMarkerProjectUtils.getAllScriptFolders(scriptProject);
+ List<String> folders = TextMarkerProjectUtils.getFolderLocations(allScriptFolders);
+ String locate = TextMarkerEngine
+ .locate(script, folders.toArray(new String[0]), ".tm");
+ IPath locatedPath = new Path(locate);
+ ExplainUtils.openInTextMarkerEditor(locatedPath, id);
+ } catch (CoreException e) {
+ TextMarkerAddonsPlugin.error(e);
+ }
+ }
+ }
+ }
+ }
}
@Override
@@ -158,15 +220,14 @@ public class ApplyViewPage extends Page
}
-
public void casDocumentChanged(IEditorInput oldInput, ICasDocument oldDocument,
IEditorInput newInput, ICasDocument newDocument) {
-// editor.removeCasEditorInputListener(this);
-// document = newDocument;
-// editor.addCasEditorInputListener(this);
-// ExplainTree tree = new ExplainTree(document.getCAS());
-// viewer.setInput(tree.getRoot());
-// viewer.refresh();
-
+ // editor.removeCasEditorInputListener(this);
+ // document = newDocument;
+ // editor.addCasEditorInputListener(this);
+ // ExplainTree tree = new ExplainTree(document.getCAS());
+ // viewer.setInput(tree.getRoot());
+ // viewer.refresh();
+
}
}
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/createdBy/CreatedByContentProvider.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/createdBy/CreatedByContentProvider.java?rev=1360586&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/createdBy/CreatedByContentProvider.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/createdBy/CreatedByContentProvider.java Thu Jul 12 08:58:05 2012
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.textmarker.explain.createdBy;
+
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+public class CreatedByContentProvider implements ITreeContentProvider {
+
+ public void dispose() {
+
+ }
+
+ public void inputChanged(Viewer arg0, Object arg1, Object arg2) {
+
+ }
+
+ public Object[] getChildren(Object arg0) {
+ return new Object[0];
+ }
+
+ public Object[] getElements(Object arg0) {
+ return new Object[]{arg0};
+ }
+
+ public Object getParent(Object arg0) {
+ return null;
+ }
+
+ public boolean hasChildren(Object arg0) {
+ return false;
+ }
+
+}
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/createdBy/CreatedByLabelProvider.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/createdBy/CreatedByLabelProvider.java?rev=1360586&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/createdBy/CreatedByLabelProvider.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/createdBy/CreatedByLabelProvider.java Thu Jul 12 08:58:05 2012
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.textmarker.explain.createdBy;
+
+import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.Feature;
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.Type;
+import org.apache.uima.textmarker.visitor.CreatedByVisitor;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+
+public class CreatedByLabelProvider extends LabelProvider implements ILabelProvider {
+
+ private CreatedByViewPage owner;
+
+ public CreatedByLabelProvider(CreatedByViewPage owner) {
+ super();
+ this.owner = owner;
+ }
+
+ @Override
+ public Image getImage(Object element) {
+ return owner.getImage(CreatedByViewPage.TM_RULE);
+ }
+
+ @Override
+ public String getText(Object element) {
+ if (element instanceof FeatureStructure) {
+ FeatureStructure fs = (FeatureStructure) element;
+ CAS cas = fs.getCAS();
+ Type t = cas.getTypeSystem().getType(CreatedByVisitor.TYPE);
+ Feature featureRule = t.getFeatureByBaseName(CreatedByVisitor.FEATURE_RULE);
+ Feature featureScript = t.getFeatureByBaseName(CreatedByVisitor.FEATURE_SCRIPT);
+ String rule = fs.getStringValue(featureRule);
+ String script = fs.getStringValue(featureScript);
+ String result = rule ;
+ if(!"".equals(script)){
+ result += " (in " + script + ")";
+ }
+ return result;
+ }
+ return element.toString();
+ }
+}
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/createdBy/CreatedByView.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/createdBy/CreatedByView.java?rev=1360586&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/createdBy/CreatedByView.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/createdBy/CreatedByView.java Thu Jul 12 08:58:05 2012
@@ -0,0 +1,45 @@
+/*
+ * 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.explain.createdBy;
+
+import org.apache.uima.caseditor.editor.AnnotationEditor;
+import org.apache.uima.caseditor.editor.CasEditorView;
+import org.apache.uima.caseditor.editor.ICasEditor;
+import org.eclipse.ui.part.IPageBookViewPage;
+
+public class CreatedByView extends CasEditorView {
+
+ public static final String ID = "org.apache.uima.textmarker.explain.createdBy";
+
+ public CreatedByView() {
+ super("The instance view is currently not available.");
+ }
+
+ @Override
+ protected IPageBookViewPage doCreatePage(ICasEditor editor) {
+ IPageBookViewPage result = null;
+ if (editor.getDocument() != null && editor instanceof AnnotationEditor) {
+ CreatedByViewPage page = new CreatedByViewPage((AnnotationEditor) editor);
+ result = page;
+ }
+ return result;
+ }
+
+}
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/createdBy/CreatedByViewPage.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/createdBy/CreatedByViewPage.java?rev=1360586&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/createdBy/CreatedByViewPage.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/createdBy/CreatedByViewPage.java Thu Jul 12 08:58:05 2012
@@ -0,0 +1,249 @@
+/*
+ * 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.explain.createdBy;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.FSIterator;
+import org.apache.uima.cas.Feature;
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.Type;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.cas.text.AnnotationIndex;
+import org.apache.uima.caseditor.editor.AnnotationEditor;
+import org.apache.uima.caseditor.editor.FeatureStructureSelection;
+import org.apache.uima.caseditor.editor.ICasDocument;
+import org.apache.uima.caseditor.editor.ICasDocumentListener;
+import org.apache.uima.caseditor.editor.ICasEditorInputListener;
+import org.apache.uima.textmarker.addons.TextMarkerAddonsPlugin;
+import org.apache.uima.textmarker.engine.TextMarkerEngine;
+import org.apache.uima.textmarker.explain.ExplainConstants;
+import org.apache.uima.textmarker.explain.ExplainUtils;
+import org.apache.uima.textmarker.explain.apply.ApplyView;
+import org.apache.uima.textmarker.explain.rulelist.RuleListView;
+import org.apache.uima.textmarker.explain.selection.ExplainSelectionView;
+import org.apache.uima.textmarker.explain.tree.ExplainTree;
+import org.apache.uima.textmarker.ide.core.builder.TextMarkerProjectUtils;
+import org.apache.uima.textmarker.ide.ui.editor.TextMarkerEditor;
+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.visitor.CreatedByVisitor;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.dltk.core.DLTKCore;
+import org.eclipse.dltk.core.IScriptProject;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.ISelectionListener;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.part.IPageSite;
+import org.eclipse.ui.part.Page;
+
+public class CreatedByViewPage extends Page implements ISelectionListener, ICasEditorInputListener, IDoubleClickListener {
+
+ public static final String TM_RULE = "TMRule";
+
+ protected TreeViewer viewer;
+
+ protected int current = 0;
+
+ protected Map<String, Image> images;
+
+ protected AnnotationEditor editor;
+
+ protected ICasDocument document;
+
+ public CreatedByViewPage(AnnotationEditor editor) {
+ super();
+ this.editor = editor;
+ this.document = editor.getDocument();
+ }
+
+ private void initImages() {
+ images = new HashMap<String, Image>();
+ ImageDescriptor desc;
+ Image image;
+ String name;
+
+ desc = TextMarkerAddonsPlugin.getImageDescriptor("/icons/tm_obj.png");
+ image = desc.createImage();
+ name = TM_RULE;
+ images.put(name, image);
+
+ }
+
+ public Image getImage(String name) {
+ if (images == null) {
+ initImages();
+ }
+ return images.get(name);
+ }
+
+ @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 TreeViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
+ viewer.setLabelProvider(new CreatedByLabelProvider(this));
+ viewer.setContentProvider(new CreatedByContentProvider());
+ viewer.setInput(null);
+ viewer.addDoubleClickListener(this);
+ getSite().setSelectionProvider(viewer);
+ getSite().getPage().addSelectionListener(this);
+ editor.addCasEditorInputListener(this);
+ viewer.refresh();
+ }
+
+ public void doubleClick(DoubleClickEvent event) {
+ ISelection selection = event.getSelection();
+ if(!selection.isEmpty() && selection instanceof TreeSelection) {
+ TreeSelection s = (TreeSelection) selection;
+ FeatureStructure fs = (FeatureStructure) s.getFirstElement();
+ Type t = fs.getType();
+ Feature featureId = t.getFeatureByBaseName(CreatedByVisitor.FEATURE_ID);
+ Feature featureScript = t.getFeatureByBaseName(CreatedByVisitor.FEATURE_SCRIPT);
+ int id = fs.getIntValue(featureId);
+ String script = fs.getStringValue(featureScript);
+ IEditorInput editorInput = editor.getEditorInput();
+ if(editorInput instanceof FileEditorInput) {
+ FileEditorInput fei = (FileEditorInput) editorInput;
+ IPath path = fei.getPath();
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ IWorkspaceRoot workspaceRoot = workspace.getRoot();
+ IFile iFile = workspaceRoot.getFileForLocation(path);
+ IProject project = iFile.getProject();
+ IScriptProject scriptProject = DLTKCore.create(project);
+ List<IFolder> allScriptFolders;
+ try {
+ allScriptFolders = TextMarkerProjectUtils.getAllScriptFolders(scriptProject);
+ List<String> folders = TextMarkerProjectUtils.getFolderLocations(allScriptFolders);
+ String locate = TextMarkerEngine.locate(script, folders.toArray(new String[0]), ".tm");
+ IPath locatedPath = new Path(locate);
+ ExplainUtils.openInTextMarkerEditor(locatedPath, id);
+ } catch (CoreException e) {
+ TextMarkerAddonsPlugin.error(e);
+ }
+ }
+ }
+ }
+
+
+
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ getSite().getPage().removeSelectionListener(this);
+ editor.removeCasEditorInputListener(this);
+ if (images != null) {
+ for (Image each : images.values()) {
+ each.dispose();
+ }
+ }
+ }
+
+ public void mouseDown(final MouseEvent event) {
+
+ }
+
+ public void mouseUp(final MouseEvent event) {
+
+ }
+
+ public void mouseDoubleClick(final MouseEvent event) {
+
+ }
+
+ public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+ if (selection instanceof IStructuredSelection) {
+ FeatureStructureSelection fsSelection = new FeatureStructureSelection(
+ (IStructuredSelection) selection);
+ if (fsSelection.isEmpty()) {
+ return;
+ }
+ FeatureStructure featureStructure = fsSelection.toList().get(0);
+ if (featureStructure instanceof AnnotationFS) {
+ CAS cas = document.getCAS();
+ Type t = cas.getTypeSystem().getType(CreatedByVisitor.TYPE);
+ Feature featureAnnotation = t.getFeatureByBaseName(CreatedByVisitor.FEATURE_ANNOTATION);
+ FSIterator<FeatureStructure> iterator = cas.getIndexRepository().getAllIndexedFS(t);
+ while (iterator.hasNext()) {
+ FeatureStructure fs = (FeatureStructure) iterator.next();
+ AnnotationFS afs = (AnnotationFS) fs.getFeatureValue(featureAnnotation);
+ if (afs.equals(featureStructure)) {
+ viewer.setInput(fs);
+ return;
+ }
+ }
+ viewer.setInput(null);
+ }
+ }
+ }
+
+ public void casDocumentChanged(IEditorInput oldInput, ICasDocument oldDocument,
+ IEditorInput newInput, ICasDocument newDocument) {
+ }
+}
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=1360586&r1=1360585&r2=1360586&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 Thu Jul 12 08:58:05 2012
@@ -349,7 +349,7 @@ public class TestViewPage extends Page i
try {
file.refreshLocal(IResource.DEPTH_ZERO, new NullProgressMonitor());
} catch (CoreException e) {
- e.printStackTrace();
+ TextMarkerAddonsPlugin.error(e);
}
}
try {
@@ -358,7 +358,7 @@ public class TestViewPage extends Page i
page.showView(FalsePositiveView.ID);
page.showView(FalseNegativeView.ID);
} catch (PartInitException e) {
- e.printStackTrace();
+ TextMarkerAddonsPlugin.error(e);
}
}
Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-caseditor/src/main/java/org/apache/uima/textmarker/caseditor/view/tree/AnnotationTreeNode.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-caseditor/src/main/java/org/apache/uima/textmarker/caseditor/view/tree/AnnotationTreeNode.java?rev=1360586&r1=1360585&r2=1360586&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-caseditor/src/main/java/org/apache/uima/textmarker/caseditor/view/tree/AnnotationTreeNode.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-caseditor/src/main/java/org/apache/uima/textmarker/caseditor/view/tree/AnnotationTreeNode.java Thu Jul 12 08:58:05 2012
@@ -19,9 +19,11 @@
package org.apache.uima.textmarker.caseditor.view.tree;
+import org.apache.uima.cas.FeatureStructure;
import org.apache.uima.cas.text.AnnotationFS;
+import org.eclipse.core.runtime.IAdaptable;
-public class AnnotationTreeNode extends FSTreeNode implements IAnnotationNode {
+public class AnnotationTreeNode extends FSTreeNode implements IAnnotationNode, IAdaptable {
public AnnotationTreeNode(AnnotationFS annotation) {
super(annotation);
@@ -44,7 +46,7 @@ public class AnnotationTreeNode extends
if (FSTreeNode.class.equals(adapter)) {
return this;
- } else if (AnnotationFS.class.equals(adapter)) {
+ } else if (AnnotationFS.class.equals(adapter) || FeatureStructure.class.equals(adapter)) {
return fs;
}
Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/antlr3/org/apache/uima/textmarker/ide/core/parser/TextMarkerParser.g
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/antlr3/org/apache/uima/textmarker/ide/core/parser/TextMarkerParser.g?rev=1360586&r1=1360585&r2=1360586&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/antlr3/org/apache/uima/textmarker/ide/core/parser/TextMarkerParser.g (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/antlr3/org/apache/uima/textmarker/ide/core/parser/TextMarkerParser.g Thu Jul 12 08:58:05 2012
@@ -94,6 +94,7 @@ import org.apache.uima.textmarker.ide.pa
private String module;
private String packageString;
+ private ScriptFactory scriptFactory = new ScriptFactory();
public List<String> getVariables() {
return vars;
@@ -236,7 +237,7 @@ List<Statement> stmts = new ArrayList<St
{
String packageName = "org.apache.uima.tm";
if(p != null) {packageName = p.getName();}
- rootBlock = ScriptFactory.createScriptBlock(0,0,0,0,module, null, null, packageName);
+ rootBlock = scriptFactory.createScriptBlock(0,0,0,0,module, null, null, packageName);
stmts.add(p);
this.module = module;
if(p != null) {
@@ -523,7 +524,7 @@ scope {
TextMarkerBlock env;
}
@init{
-TextMarkerRuleElement re = null;
+TextMarkerRule rule = null;
level++;
}
@after {
@@ -535,37 +536,40 @@ level--;
LPAREN
id = Identifier {addVariable(id.getText(), declareToken.getText());}
{
- block = ScriptFactory.createScriptBlock(id, declareToken, $blockDeclaration[level - 1]::env);
+ block = scriptFactory.createScriptBlock(id, declareToken, $blockDeclaration[level - 1]::env);
$blockDeclaration::env = block;
}
RPAREN
- re1 = ruleElementWithCA {re = re1;}
- {ScriptFactory.finalizeScriptBlock(block, rc, re, body);}
+ re1 = ruleElementWithCA
+ {
+ rule = scriptFactory.createRule(re1);
+ scriptFactory.finalizeScriptBlock(block, rc, rule, body);}
LCURLY body = statements rc = RCURLY
- {ScriptFactory.finalizeScriptBlock(block, rc, re, body);}
+ {scriptFactory.finalizeScriptBlock(block, rc, rule, body);}
;
ruleElementWithCA returns [TextMarkerRuleElement re = null]
:
- idRef=typeExpression quantifier = quantifierPart? {re = ScriptFactory.createRuleElement(idRef,quantifier,c,a, end);}
+ idRef=typeExpression quantifier = quantifierPart? {re = scriptFactory.createRuleElement(idRef,quantifier,c,a, end);}
LCURLY c = conditions? (THEN a = actions)? end = RCURLY
- {re = ScriptFactory.createRuleElement(idRef,quantifier,c,a, end);}
+ {re = scriptFactory.createRuleElement(idRef,quantifier,c,a, end);}
;
ruleElementWithoutCA returns [TextMarkerRuleElement re = null]
:
idRef=typeExpression quantifier = quantifierPart?
- {re = ScriptFactory.createRuleElement(idRef,quantifier,null,null, null);}
+ {re = scriptFactory.createRuleElement(idRef,quantifier,null,null, null);}
;
simpleStatement returns [TextMarkerRule stmt = null]
:
elements=ruleElements
- {stmt = ScriptFactory.createRule(elements);}
- SEMI
+ s = SEMI
+ {stmt = scriptFactory.createRule(elements, s);}
+
;
ruleElements returns [List<Expression> elements = new ArrayList<Expression>()]
@@ -590,7 +594,7 @@ ruleElementComposed returns [ComposedRul
boolean disjunctive = false;
}
:
- LPAREN
+ ft = LPAREN
(((ruleElementType | ruleElementLiteral) VBAR)=> (re11 =ruleElementType| re12 = ruleElementLiteral)
{disjunctive = true; res = new ArrayList<Expression>(); if(re11!=null) res.add(re11);if(re12!=null) res.add(re12);}
@@ -602,8 +606,8 @@ ruleElementComposed returns [ComposedRul
)*
|(ruleElements)=>res = ruleElements)
- RPAREN q = quantifierPart? (LCURLY c = conditions? (THEN a = actions)? RCURLY)?
- {re = ScriptFactory.createComposedRuleElement(res, q, c, a, disjunctive,$blockDeclaration::env);}
+ lt1 = RPAREN q = quantifierPart? (LCURLY c = conditions? (THEN a = actions)? lt2 = RCURLY)?
+ {re = scriptFactory.createComposedRuleElement(res, q, c, a, disjunctive,$blockDeclaration::env, ft, lt1, lt2);}
;
ruleElementType returns [TextMarkerRuleElement re = null]
@@ -626,7 +630,7 @@ List<TextMarkerCondition> dummyConds = n
(THEN a = actions)? end = RCURLY)?
{
// TODO handle quantifierPart.
- re = ScriptFactory.createRuleElement(idRef,quantifier,c,a,end);}
+ re = scriptFactory.createRuleElement(idRef,quantifier,c,a,end);}
//start, end, "", cp, ap, "", $blockDeclaration::env);}
;
@@ -640,7 +644,7 @@ ruleElementLiteral returns [TextMarkerRu
end = RCURLY)?
{
// TODO handle quantifierPart.
- re = ScriptFactory.createRuleElement(idRef,quantifier,c,a,end);}
+ re = scriptFactory.createRuleElement(idRef,quantifier,c,a,end);}
//start, end, "", cp, ap, "", $blockDeclaration::env);}
;
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/core/codeassist/TextMarkerRuleIdVisitor.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/core/codeassist/TextMarkerRuleIdVisitor.java?rev=1360586&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/core/codeassist/TextMarkerRuleIdVisitor.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/core/codeassist/TextMarkerRuleIdVisitor.java Thu Jul 12 08:58:05 2012
@@ -0,0 +1,38 @@
+package org.apache.uima.textmarker.ide.core.codeassist;
+
+import org.apache.uima.textmarker.ide.parser.ast.TextMarkerRule;
+import org.eclipse.dltk.ast.ASTVisitor;
+import org.eclipse.dltk.ast.expressions.Expression;
+import org.eclipse.dltk.ast.statements.Statement;
+
+public class TextMarkerRuleIdVisitor extends ASTVisitor {
+
+ private int id;
+
+ private TextMarkerRule result;
+
+ public TextMarkerRuleIdVisitor(int id) {
+ super();
+ this.id = id;
+ }
+
+ @Override
+ public boolean visit(Statement s) throws Exception {
+ if (result != null) {
+ return false;
+ }
+ if (s instanceof TextMarkerRule) {
+ TextMarkerRule rule = (TextMarkerRule) s;
+ if (id == rule.getId()) {
+ result = rule;
+ }
+ }
+ return true;
+ }
+
+
+ public TextMarkerRule getResult() {
+ return result;
+ }
+
+}
Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/formatter/TextMarkerFormattedPrinter.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/formatter/TextMarkerFormattedPrinter.java?rev=1360586&r1=1360585&r2=1360586&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/formatter/TextMarkerFormattedPrinter.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/formatter/TextMarkerFormattedPrinter.java Thu Jul 12 08:58:05 2012
@@ -675,8 +675,8 @@ public class TextMarkerFormattedPrinter
append(b.getName());
append(") ");
this.inBlockDeclaration = true;
- if (b.getRuleElement() != null) {
- b.getRuleElement().traverse(this);
+ if (b.getRule() != null) {
+ b.getRule().traverse(this);
}
this.inBlockDeclaration = false;
append(" {");
Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/launching/TextMarkerInterpreterRunner.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/launching/TextMarkerInterpreterRunner.java?rev=1360586&r1=1360585&r2=1360586&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/launching/TextMarkerInterpreterRunner.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/launching/TextMarkerInterpreterRunner.java Thu Jul 12 08:58:05 2012
@@ -218,6 +218,7 @@ public class TextMarkerInterpreterRunner
ae.setConfigParameterValue(TextMarkerEngine.CREATE_MATCH_DEBUG_INFO, true);
ae.setConfigParameterValue(TextMarkerEngine.CREATE_PROFILING_INFO, true);
ae.setConfigParameterValue(TextMarkerEngine.CREATE_STATISTIC_INFO, true);
+ ae.setConfigParameterValue(TextMarkerEngine.CREATE_CREATED_BY_INFO, true);
ae.reconfigure();
}
} catch (Exception e) {
Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/AbstractFactory.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/AbstractFactory.java?rev=1360586&r1=1360585&r2=1360586&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/AbstractFactory.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/AbstractFactory.java Thu Jul 12 08:58:05 2012
@@ -97,7 +97,7 @@ public abstract class AbstractFactory {
* @return
*/
protected static final int[] getSurroundingBounds(ASTNode head, List... astnodeListArray) {
- int bounds[] = { 0, 0 };
+ int bounds[] = { Integer.MAX_VALUE, -1 };
if (head != null) {
bounds[0] = head.sourceStart();
bounds[1] = head.sourceEnd();
@@ -108,9 +108,14 @@ public abstract class AbstractFactory {
if (list == null || list.isEmpty()) {
continue;
}
- ASTNode node = list.get(list.size() - 1);
- if (node != null) {
- bounds[1] = Math.max(bounds[0], node.sourceEnd());
+ ASTNode firstNode = list.get(0);
+ if (firstNode != null) {
+ bounds[0] = Math.min(bounds[0], firstNode.sourceStart());
+ }
+
+ ASTNode lastNode = list.get(list.size() - 1);
+ if (lastNode != null) {
+ bounds[1] = Math.max(bounds[0], lastNode.sourceEnd());
}
}
}
Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/ScriptFactory.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/ScriptFactory.java?rev=1360586&r1=1360585&r2=1360586&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/ScriptFactory.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/ScriptFactory.java Thu Jul 12 08:58:05 2012
@@ -19,6 +19,7 @@
package org.apache.uima.textmarker.ide.parser.ast;
+import java.util.ArrayList;
import java.util.List;
import org.antlr.runtime.Token;
@@ -29,13 +30,26 @@ import org.eclipse.dltk.ast.statements.S
public class ScriptFactory extends AbstractFactory {
- public static TextMarkerRule createRule(List<Expression> elements) {
- return new TextMarkerRule(elements);
+ private int idCounter;
+
+ public TextMarkerRule createRule(TextMarkerRuleElement element) {
+ List<Expression> elements = new ArrayList<Expression>();
+ elements.add(element);
+ return createRule(elements, null);
+ }
+
+ public TextMarkerRule createRule(List<Expression> elements, Token s) {
+ TextMarkerRule rule = new TextMarkerRule(elements, idCounter++);
+ if (s != null) {
+ int[] bounds = getBounds(s);
+ rule.setEnd(bounds[1]);
+ }
+ return rule;
}
- public static ComposedRuleElement createComposedRuleElement(List<Expression> res,
- List<Expression> q, List<TextMarkerCondition> c, List<TextMarkerAction> a,
- boolean disjunctive, TextMarkerBlock env) {
+ public ComposedRuleElement createComposedRuleElement(List<Expression> res, List<Expression> q,
+ List<TextMarkerCondition> c, List<TextMarkerAction> a, boolean disjunctive,
+ TextMarkerBlock env, Token... tokens) {
int bounds[] = getSurroundingBounds((ASTNode) null, res);
// taking care of null statements - errors should have been recognized
// in parser
@@ -57,10 +71,20 @@ public class ScriptFactory extends Abstr
bounds[1] = Math.max(bounds[1], a.get(a.size() - 1).sourceEnd());
}
+ if (tokens != null && tokens.length > 0) {
+ bounds[0] = Math.min(bounds[0], getBounds(tokens[0])[0]);
+ }
+ if (tokens != null && tokens.length == 2 && tokens[1] != null) {
+ bounds[1] = Math.max(bounds[1], getBounds(tokens[1])[1]);
+ }
+ if (tokens != null && tokens.length == 3 && tokens[2] != null) {
+ bounds[1] = Math.max(bounds[1], getBounds(tokens[2])[1]);
+ }
+
return new ComposedRuleElement(bounds[0], bounds[1], res, q, c, a, disjunctive);
}
- public static TextMarkerRuleElement createRuleElement(Expression head,
+ public TextMarkerRuleElement createRuleElement(Expression head,
List<Expression> quantifierPartExpressions, List<TextMarkerCondition> conditions,
List<TextMarkerAction> actions, Token end) {
int bounds[] = getSurroundingBounds(head, conditions, actions);
@@ -94,10 +118,10 @@ public class ScriptFactory extends Abstr
* @param packageString
* @return
*/
- public static TextMarkerScriptBlock createScriptBlock(int declStart, int declEnd, int nameStart,
+ public TextMarkerScriptBlock createScriptBlock(int declStart, int declEnd, int nameStart,
int nameEnd, String string, List<TextMarkerRuleElement> res, Block block,
String packageString) {
- // UNUSED parameter res unused
+ createRule(new ArrayList<Expression>(), null);
return new TextMarkerScriptBlock(string, packageString, nameStart, nameEnd, declStart, declEnd);
}
@@ -110,8 +134,7 @@ public class ScriptFactory extends Abstr
* @param textMarkerBlock
* @return
*/
- public static TextMarkerBlock createScriptBlock(Token id, Token type,
- TextMarkerBlock textMarkerBlock) {
+ public TextMarkerBlock createScriptBlock(Token id, Token type, TextMarkerBlock textMarkerBlock) {
int[] bounds = getBounds(type, id);
int[] nameBounds = getBounds(id);
if (textMarkerBlock == null) {
@@ -125,7 +148,7 @@ public class ScriptFactory extends Abstr
}
}
- public static void finalizeScriptBlock(TextMarkerBlock block, Token rc, TextMarkerRuleElement re,
+ public void finalizeScriptBlock(TextMarkerBlock block, Token rc, TextMarkerRule rule,
List<Statement> body) {
// taking care of null statements - errors should have been recognized
// in parser
@@ -138,14 +161,14 @@ public class ScriptFactory extends Abstr
}
Block inner = new Block(innerStart, innerEnd, body);
block.acceptBody(inner, false);
- block.setRuleElement(re);
- block.setEnd(rc != null ? getBounds(rc)[1] : re.sourceEnd());
+ block.setRule(rule);
+ block.setEnd(rc != null ? getBounds(rc)[1] : rule.sourceEnd());
}
/**
* @param body
*/
- private static void filterNullObjects(List<?> body) {
+ private void filterNullObjects(List<?> body) {
if (body == null) {
return;
}
Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerBlock.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerBlock.java?rev=1360586&r1=1360585&r2=1360586&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerBlock.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerBlock.java Thu Jul 12 08:58:05 2012
@@ -27,7 +27,7 @@ import org.eclipse.dltk.ast.statements.S
public class TextMarkerBlock extends MethodDeclaration {
- private TextMarkerRuleElement ruleElement;
+ private TextMarkerRule rule;
private String namespace;
@@ -47,8 +47,8 @@ public class TextMarkerBlock extends Met
@Override
public void traverse(ASTVisitor visitor) throws Exception {
if (visitor.visit(this)) {
- if (ruleElement != null) {
- ruleElement.traverse(visitor);
+ if (rule != null) {
+ rule.traverse(visitor);
}
traverseChildNodes(visitor);
visitor.endvisit(this);
@@ -59,15 +59,15 @@ public class TextMarkerBlock extends Met
* @param ruleElement
* the ruleElement to set
*/
- public void setRuleElement(TextMarkerRuleElement ruleElement) {
- this.ruleElement = ruleElement;
+ public void setRule(TextMarkerRule rule) {
+ this.rule = rule;
}
/**
* @return the ruleElement
*/
- public TextMarkerRuleElement getRuleElement() {
- return ruleElement;
+ public TextMarkerRule getRule() {
+ return rule;
}
public String toString() {
Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerRule.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerRule.java?rev=1360586&r1=1360585&r2=1360586&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerRule.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerRule.java Thu Jul 12 08:58:05 2012
@@ -25,11 +25,18 @@ import org.eclipse.dltk.ast.expressions.
public class TextMarkerRule extends TextMarkerStatement {
- public TextMarkerRule(List<Expression> expressions) {
+ private final int id;
+
+ public TextMarkerRule(List<Expression> expressions, int id) {
super(expressions);
+ this.id = id;
}
public String toString() {
return this.getClass().getSimpleName() + " : " + super.toString();
}
+
+ public int getId() {
+ return id;
+ }
}
Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/ExplainPerspective.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/ExplainPerspective.java?rev=1360586&r1=1360585&r2=1360586&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/ExplainPerspective.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/ExplainPerspective.java Thu Jul 12 08:58:05 2012
@@ -42,15 +42,13 @@ public class ExplainPerspective implemen
public static final String RULE_LIST = "org.apache.uima.textmarker.explain.rulelist";
- public static final String QUERY = "org.apache.uima.textmarker.query.ui.ScriptQueryView";
-
- public static final String PALETTE_VIEW = "org.apache.uima.cev.views.palette";
-
- public static final String TYPE_BROWSER = "org.apache.uima.cev.views.typeBrowser";
+ public static final String CREATED_BY = "org.apache.uima.caseditor.browser";
- public static final String SELECTION_VIEW = "org.apache.uima.cev.views.selection";
+ public static final String TYPE_BROWSER = "org.apache.uima.caseditor.browser";
- public static final String ANNOTATION_EDITOR = "org.apache.uima.cev.views.editor";
+ public static final String SELECTION_VIEW = "org.apache.uima.caseditor.selection";
+
+ public static final String QUERY = "org.apache.uima.textmarker.query.ui.ScriptQueryView";
public static final String SCRIPT_EXPLORER = "org.eclipse.dltk.ui.ScriptExplorer";
@@ -85,10 +83,9 @@ public class ExplainPerspective implemen
layout.addShowViewShortcut(IProgressConstants.PROGRESS_VIEW_ID);
layout.addShowViewShortcut(SCRIPT_EXPLORER);
- layout.addShowViewShortcut(PALETTE_VIEW);
layout.addShowViewShortcut(TYPE_BROWSER);
layout.addShowViewShortcut(SELECTION_VIEW);
- layout.addShowViewShortcut(ANNOTATION_EDITOR);
+ layout.addShowViewShortcut(CREATED_BY);
layout.addShowViewShortcut(QUERY);
}
@@ -101,11 +98,14 @@ public class ExplainPerspective implemen
rightFolder.addView(APPLIED_RULES);
rightFolder.addView(SELECTION_RULES);
rightFolder.addView(RULE_LIST);
-
+ rightFolder.addView(TYPE_BROWSER);
+ rightFolder.addView(SELECTION_VIEW);
+
IFolderLayout ruleFolder = layout.createFolder("ruleFolder", IPageLayout.BOTTOM, (float) 0.6,
"rightFolder");
ruleFolder.addView(RULE_ELEMENTS);
-
+ ruleFolder.addView(CREATED_BY);
+
IFolderLayout navigationFolder = layout.createFolder("left", IPageLayout.LEFT, (float) 0.2,
editorArea);
navigationFolder.addView(SCRIPT_EXPLORER);
Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/editor/TextMarkerEditor.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/editor/TextMarkerEditor.java?rev=1360586&r1=1360585&r2=1360586&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/editor/TextMarkerEditor.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/editor/TextMarkerEditor.java Thu Jul 12 08:58:05 2012
@@ -28,9 +28,11 @@ import org.apache.uima.textmarker.ide.Te
import org.apache.uima.textmarker.ide.core.TextMarkerLanguageToolkit;
import org.apache.uima.textmarker.ide.core.codeassist.TextMarkerReferenceDeclarationVisitor;
import org.apache.uima.textmarker.ide.core.codeassist.TextMarkerReferenceVisitor;
+import org.apache.uima.textmarker.ide.core.codeassist.TextMarkerRuleIdVisitor;
import org.apache.uima.textmarker.ide.core.codeassist.TextMarkerSelectionParser;
import org.apache.uima.textmarker.ide.parser.ast.TextMarkerAction;
import org.apache.uima.textmarker.ide.parser.ast.TextMarkerCondition;
+import org.apache.uima.textmarker.ide.parser.ast.TextMarkerRule;
import org.apache.uima.textmarker.ide.ui.TextMarkerPartitions;
import org.apache.uima.textmarker.ide.ui.TextMarkerPreferenceConstants;
import org.apache.uima.textmarker.ide.ui.actions.TextMarkerGenerateActionGroup;
@@ -419,6 +421,34 @@ public class TextMarkerEditor extends Sc
}
+ public void highlightElement(int id) {
+ if (myAnnotations != null && !myAnnotations.isEmpty()) {
+ removeAnnotations(myAnnotations.keySet());
+ }
+
+ TextMarkerSelectionParser parser = new TextMarkerSelectionParser();
+ ISourceModule unit = (ISourceModule) getInputModelElement();
+ ModuleDeclaration parsed = parser.parse(unit);
+ TextMarkerRuleIdVisitor visitor = new TextMarkerRuleIdVisitor(id);
+ try {
+ parsed.traverse(visitor);
+ } catch (Exception e) {
+ }
+ TextMarkerRule rule = visitor.getResult();
+ myAnnotations = new HashMap<Annotation, Position>();
+ if(rule != null) {
+ Annotation annotation = new Annotation(SearchPlugin.SEARCH_ANNOTATION_TYPE, true, null);
+ int sourceStart = rule.sourceStart();
+ int sourceEnd = rule.sourceEnd();
+ Position position = new Position(sourceStart, sourceEnd - sourceStart);
+ getSourceViewer().revealRange(sourceStart, sourceEnd - sourceStart);
+ myAnnotations.put(annotation, position);
+ }
+ addAnnotations(myAnnotations);
+ }
+
+
+
private void removeAnnotations(Collection<Annotation> annotations) {
IAnnotationModel model = getDocumentProvider().getAnnotationModel(getEditorInput());
for (Annotation annotation : annotations) {
@@ -523,4 +553,5 @@ public class TextMarkerEditor extends Sc
super.configureSourceViewerDecorationSupport(support);
}
+
}
Modified: uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/TextMarkerModule.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/TextMarkerModule.java?rev=1360586&r1=1360585&r2=1360586&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/TextMarkerModule.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/TextMarkerModule.java Thu Jul 12 08:58:05 2012
@@ -126,4 +126,8 @@ public class TextMarkerModule extends Te
return engines;
}
+ public TextMarkerBlock getRootBlock() {
+ return rootBlock;
+ }
+
}
Modified: uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/TextMarkerScriptFactory.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/TextMarkerScriptFactory.java?rev=1360586&r1=1360585&r2=1360586&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/TextMarkerScriptFactory.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/TextMarkerScriptFactory.java Thu Jul 12 08:58:05 2012
@@ -52,7 +52,7 @@ import org.apache.uima.textmarker.rule.q
public class TextMarkerScriptFactory {
- private static int idCounter = 0;
+ private int idCounter = 0;
public TextMarkerScriptFactory() {
super();
@@ -107,7 +107,6 @@ public class TextMarkerScriptFactory {
}
public TextMarkerRule createRule(List<RuleElement> elements, TextMarkerBlock parent) {
- // System.out.println("Rule: " + idCounter);
return new TextMarkerRule(elements, parent, idCounter++);
}
Modified: uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/TextMarkerStream.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/TextMarkerStream.java?rev=1360586&r1=1360585&r2=1360586&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/TextMarkerStream.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/TextMarkerStream.java Thu Jul 12 08:58:05 2012
@@ -45,8 +45,11 @@ import org.apache.uima.jcas.JCas;
import org.apache.uima.jcas.tcas.Annotation;
import org.apache.uima.jcas.tcas.DocumentAnnotation;
import org.apache.uima.textmarker.rule.RuleElementMatch;
+import org.apache.uima.textmarker.rule.RuleMatch;
import org.apache.uima.textmarker.type.TextMarkerAnnotation;
import org.apache.uima.textmarker.type.TextMarkerBasic;
+import org.apache.uima.textmarker.visitor.InferenceCrowd;
+import org.hamcrest.CoreMatchers;
public class TextMarkerStream extends FSIteratorImplBase<AnnotationFS> {
@@ -80,13 +83,16 @@ public class TextMarkerStream extends FS
private boolean lowMemoryProfile;
+ private InferenceCrowd crowd;
+
protected TextMarkerStream(CAS cas, FSIterator<AnnotationFS> current, Type basicType,
- FilterManager filter, boolean lowMemoryProfile) {
+ FilterManager filter, boolean lowMemoryProfile, InferenceCrowd crowd) {
super();
this.cas = cas;
this.filter = filter;
this.basicType = basicType;
this.lowMemoryProfile = lowMemoryProfile;
+ this.crowd = crowd;
AnnotationFS additionalWindow = filter.getWindowAnnotation();
updateIterators(cas, basicType, filter, additionalWindow);
// really an if? sub it of basic should fix this
@@ -130,8 +136,8 @@ public class TextMarkerStream extends FS
currentIt = filter.createFilteredIterator(cas, basicType);
}
- public TextMarkerStream(CAS cas, Type basicType, FilterManager filter, boolean lowMemoryProfile) {
- this(cas, null, basicType, filter, lowMemoryProfile);
+ public TextMarkerStream(CAS cas, Type basicType, FilterManager filter, boolean lowMemoryProfile, InferenceCrowd crowd) {
+ this(cas, null, basicType, filter, lowMemoryProfile, crowd);
}
public void initalizeBasics() {
@@ -156,17 +162,17 @@ public class TextMarkerStream extends FS
}
for (AnnotationFS a : annotationIndex) {
if (!a.getType().equals(basicType)) {
- addAnnotation(a, false);
+ addAnnotation(a, false, null);
}
}
updateIterators(documentAnnotation);
}
- public void addAnnotation(AnnotationFS annotation) {
- addAnnotation(annotation, false);
+ public void addAnnotation(AnnotationFS annotation, RuleMatch creator) {
+ addAnnotation(annotation, false, creator);
}
- public void addAnnotation(AnnotationFS annotation, boolean update) {
+ public void addAnnotation(AnnotationFS annotation, boolean update, RuleMatch creator) {
Type type = annotation.getType();
Type parent = type;
boolean modified = checkSpan(annotation);
@@ -181,6 +187,7 @@ public class TextMarkerStream extends FS
for (TextMarkerBasic basic : basicAnnotationsInWindow) {
basic.addPartOf(type);
}
+ crowd.annotationAdded(annotation, creator);
}
private boolean checkSpan(AnnotationFS annotation) {
@@ -256,12 +263,12 @@ public class TextMarkerStream extends FS
FilterManager filterManager = new FilterManager(filter.getDefaultFilterTypes(),
filter.getCurrentFilterTypes(), filter.getCurrentRetainTypes(), windowAnnotation,
windowType, cas);
- TextMarkerStream stream = new TextMarkerStream(cas, basicIt, basicType, filterManager, lowMemoryProfile);
+ TextMarkerStream stream = new TextMarkerStream(cas, basicIt, basicType, filterManager, lowMemoryProfile, crowd);
return stream;
}
public FSIterator<AnnotationFS> copy() {
- return new TextMarkerStream(cas, currentIt.copy(), basicType, filter, lowMemoryProfile);
+ return new TextMarkerStream(cas, currentIt.copy(), basicType, filter, lowMemoryProfile, crowd);
}
public AnnotationFS get() throws NoSuchElementException {
@@ -629,7 +636,7 @@ public class TextMarkerStream extends FS
public TextMarkerStream getCompleteStream() {
FilterManager defaultFilter = new FilterManager(filter.getDefaultFilterTypes(), getCas());
- return new TextMarkerStream(getCas(), basicIt, basicType, defaultFilter, lowMemoryProfile);
+ return new TextMarkerStream(getCas(), basicIt, basicType, defaultFilter, lowMemoryProfile, crowd);
}
public int getHistogram(Type type) {
Modified: uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/AbstractMarkAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/AbstractMarkAction.java?rev=1360586&r1=1360585&r2=1360586&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/AbstractMarkAction.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/AbstractMarkAction.java Thu Jul 12 08:58:05 2012
@@ -29,6 +29,7 @@ import org.apache.uima.textmarker.TextMa
import org.apache.uima.textmarker.expression.number.NumberExpression;
import org.apache.uima.textmarker.expression.type.TypeExpression;
import org.apache.uima.textmarker.rule.RuleElement;
+import org.apache.uima.textmarker.rule.RuleMatch;
import org.apache.uima.textmarker.type.TextMarkerBasic;
public abstract class AbstractMarkAction extends TypeSensitiveAction {
@@ -38,13 +39,13 @@ public abstract class AbstractMarkAction
}
protected void createAnnotation(AnnotationFS matchedAnnotation, RuleElement element,
- TextMarkerStream stream) {
+ TextMarkerStream stream, RuleMatch match) {
TextMarkerBasic first = stream.getFirstBasicInWindow(matchedAnnotation);
- createAnnotation(first, element, stream, matchedAnnotation);
+ createAnnotation(first, element, stream, matchedAnnotation, match);
}
protected Annotation createAnnotation(TextMarkerBasic anchor, RuleElement element,
- TextMarkerStream stream, AnnotationFS matchedAnnotation) {
+ TextMarkerStream stream, AnnotationFS matchedAnnotation, RuleMatch match) {
Type t = type.getType(element.getParent());
AnnotationFS newAnnotationFS = stream.getCas().createAnnotation(t,
matchedAnnotation.getBegin(), matchedAnnotation.getEnd());
@@ -55,7 +56,7 @@ public abstract class AbstractMarkAction
} else {
return null;
}
- stream.addAnnotation(newAnnotation);
+ stream.addAnnotation(newAnnotation, match);
return newAnnotation;
}
Modified: uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/CallAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/CallAction.java?rev=1360586&r1=1360585&r2=1360586&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/CallAction.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/CallAction.java Thu Jul 12 08:58:05 2012
@@ -203,7 +203,7 @@ public class CallAction extends Abstract
FSIterator<AnnotationFS> iterator = newCAS.getAnnotationIndex(type).iterator();
while (iterator.isValid()) {
AnnotationFS each = iterator.get();
- transform(each, new2oldBegin, new2oldEnd, fsToAdd, stream);
+ transform(each, new2oldBegin, new2oldEnd, fsToAdd, stream, match);
iterator.moveToNext();
}
}
@@ -212,7 +212,7 @@ public class CallAction extends Abstract
private void transform(FeatureStructure each, Map<Integer, Integer> new2oldBegin,
Map<Integer, Integer> new2oldEnd, Collection<AnnotationFS> fsToAdd,
- TextMarkerStream stream) {
+ TextMarkerStream stream, RuleMatch match) {
CAS cas = stream.getCas();
Type newType = cas.getTypeSystem().getType(each.getType().getName());
if (newType != null && !fsToAdd.contains(each)
@@ -221,10 +221,10 @@ public class CallAction extends Abstract
FeatureStructure newFS = null;
if (each instanceof AnnotationFS) {
- newFS = transformAnnotation((AnnotationFS) each, newType, new2oldBegin, new2oldEnd, stream);
+ newFS = transformAnnotation((AnnotationFS) each, newType, new2oldBegin, new2oldEnd, stream, match);
} else {
newFS = cas.createFS(newType);
- fillFeatures(each, newFS, newFS.getType(), new2oldBegin, new2oldEnd, stream);
+ fillFeatures(each, newFS, newFS.getType(), new2oldBegin, new2oldEnd, stream, match);
}
cas.addFsToIndexes(newFS);
}
@@ -232,12 +232,12 @@ public class CallAction extends Abstract
private FeatureStructure transformAnnotation(AnnotationFS annotation, Type newType,
Map<Integer, Integer> new2oldBegin, Map<Integer, Integer> new2oldEnd,
- TextMarkerStream stream) {
+ TextMarkerStream stream, RuleMatch match) {
CAS cas = stream.getCas();
Integer beginOld = annotation.getBegin();
Integer endOld = annotation.getEnd();
FeatureStructure newFS = cas.createFS(newType);
- fillFeatures(annotation, newFS, newType, new2oldBegin, new2oldEnd, stream);
+ fillFeatures(annotation, newFS, newType, new2oldBegin, new2oldEnd, stream, match);
Integer beginNew = new2oldBegin.get(beginOld);
Integer endNew = new2oldEnd.get(endOld);
@@ -271,27 +271,27 @@ public class CallAction extends Abstract
Annotation newA = (Annotation) newFS;
newA.setBegin(beginNew);
newA.setEnd(endNew);
- stream.addAnnotation(newA);
+ stream.addAnnotation(newA, match);
}
return newFS;
}
private void fillFeatures(FeatureStructure oldFS, FeatureStructure newFS, Type newType,
Map<Integer, Integer> new2oldBegin, Map<Integer, Integer> new2oldEnd,
- TextMarkerStream stream) {
+ TextMarkerStream stream, RuleMatch match) {
for (Object obj : newType.getFeatures()) {
Feature feature = (Feature) obj;
String sn = feature.getShortName();
if (!"sofa".equals(sn) && !"begin".equals(sn) && !"end".equals(sn)) {
Feature oldFeature = oldFS.getType().getFeatureByBaseName(sn);
- fillFeature(oldFS, oldFeature, newFS, feature, new2oldBegin, new2oldEnd, stream);
+ fillFeature(oldFS, oldFeature, newFS, feature, new2oldBegin, new2oldEnd, stream, match);
}
}
}
private void fillFeature(FeatureStructure oldFS, Feature oldFeature, FeatureStructure newFS,
Feature feature, Map<Integer, Integer> new2oldBegin, Map<Integer, Integer> new2oldEnd,
- TextMarkerStream stream) {
+ TextMarkerStream stream, RuleMatch match) {
CAS cas = stream.getCas();
Type oldRange = oldFeature.getRange();
if (oldRange.isPrimitive()) {
@@ -318,10 +318,10 @@ public class CallAction extends Abstract
}
if (newFeatureFS instanceof AnnotationFS) {
transformAnnotation((AnnotationFS) newFeatureFS, newFeatureFS.getType(), new2oldBegin,
- new2oldEnd, stream);
+ new2oldEnd, stream, match);
} else {
fillFeatures(oldFeatureFS, newFeatureFS, newFeatureFS.getType(), new2oldBegin, new2oldEnd,
- stream);
+ stream, match);
}
}
}
Modified: uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/CreateAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/CreateAction.java?rev=1360586&r1=1360585&r2=1360586&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/CreateAction.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/CreateAction.java Thu Jul 12 08:58:05 2012
@@ -72,7 +72,7 @@ public class CreateAction extends Abstra
Annotation a = (Annotation) newFS;
a.setBegin(matchedAnnotation.getBegin());
a.setEnd(matchedAnnotation.getEnd());
- stream.addAnnotation(a);
+ stream.addAnnotation(a, match);
}
TOP newStructure = null;
if (newFS instanceof TOP) {
Modified: uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/ExecAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/ExecAction.java?rev=1360586&r1=1360585&r2=1360586&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/ExecAction.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/ExecAction.java Thu Jul 12 08:58:05 2012
@@ -98,7 +98,7 @@ public class ExecAction extends CallActi
cas.removeFsFromIndexes(each);
stream.removeAnnotation(entry.getKey(), each.getType());
cas.addFsToIndexes(each);
- stream.addAnnotation(each);
+ stream.addAnnotation(each, match);
}
}
}
Modified: uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/ExpandAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/ExpandAction.java?rev=1360586&r1=1360585&r2=1360586&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/ExpandAction.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/ExpandAction.java Thu Jul 12 08:58:05 2012
@@ -47,7 +47,7 @@ public class ExpandAction extends MarkAc
if (matchedAnnotation.getBegin() >= annotationFS.getBegin()
&& matchedAnnotation.getEnd() <= annotationFS.getEnd()) {
stream.removeAnnotation(annotationFS, annotationFS.getType());
- createAnnotation(matchedAnnotation, element, stream);
+ createAnnotation(matchedAnnotation, element, stream, match);
}
}
}