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 2019/11/18 12:19:33 UTC
svn commit: r1869967 [8/12] - in /uima/uv3/ruta-v3/trunk: ./
example-projects/ExampleProject/descriptor/
example-projects/ExampleProject/descriptor/uima/ruta/example/
example-projects/ExtensionsExample/ example-projects/GermanNovels/
example-projects/M...
Modified: uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/apply/ApplyTreeLabelProvider.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/apply/ApplyTreeLabelProvider.java?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/apply/ApplyTreeLabelProvider.java (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/apply/ApplyTreeLabelProvider.java Mon Nov 18 12:19:31 2019
@@ -29,6 +29,7 @@ import org.apache.uima.cas.Type;
import org.apache.uima.cas.TypeSystem;
import org.apache.uima.ruta.explain.ExplainConstants;
import org.apache.uima.ruta.explain.tree.IExplainTreeNode;
+import org.apache.uima.ruta.type.ProfiledAnnotation;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
@@ -37,12 +38,12 @@ import org.eclipse.swt.graphics.Image;
public class ApplyTreeLabelProvider extends LabelProvider implements ILabelProvider {
private DecimalFormat dfTime = new DecimalFormat("###,###,##0.000",
- DecimalFormatSymbols.getInstance(Locale.ENGLISH));;
+ DecimalFormatSymbols.getInstance(Locale.ENGLISH));
private DecimalFormat dfPercentage = new DecimalFormat("##0.00",
- DecimalFormatSymbols.getInstance(Locale.ENGLISH));;
+ DecimalFormatSymbols.getInstance(Locale.ENGLISH));
- private ApplyViewPage owner;
+ protected ApplyViewPage owner;
ImageDescriptor blockApply;
@@ -111,9 +112,10 @@ public class ApplyTreeLabelProvider exte
IExplainTreeNode parentNode = debugNode.getParent();
if (parentNode != null) {
FeatureStructure parent = parentNode.getFeatureStructure();
- if (parent != null) {
- long parentTime = parent.getLongValue(f4);
- if(parentTime>0) {
+ if (parent instanceof ProfiledAnnotation) {
+ // TODO FSArray break in inlined by purpose?
+ long parentTime = ((ProfiledAnnotation) parent).getTime();
+ if (parentTime > 0) {
percent = (took / (parentTime / 1000.0)) * 100.0;
}
}
Modified: uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/apply/ApplyViewPage.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/apply/ApplyViewPage.java?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/apply/ApplyViewPage.java (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/apply/ApplyViewPage.java Mon Nov 18 12:19:31 2019
@@ -25,6 +25,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.apache.uima.cas.CASException;
import org.apache.uima.cas.Feature;
import org.apache.uima.cas.FeatureStructure;
import org.apache.uima.cas.Type;
@@ -32,6 +33,7 @@ import org.apache.uima.caseditor.editor.
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.jcas.JCas;
import org.apache.uima.ruta.addons.RutaAddonsPlugin;
import org.apache.uima.ruta.engine.RutaEngine;
import org.apache.uima.ruta.explain.ExplainConstants;
@@ -105,6 +107,23 @@ public class ApplyViewPage extends Page
image = desc.createImage();
name = ExplainConstants.RULE_APPLY_TYPE;
images.put(name, image);
+ images.put(ExplainConstants.INLINED_AS_ACTION, image);
+
+ desc = RutaAddonsPlugin.getImageDescriptor("/icons/arrow_left.png");
+ image = desc.createImage();
+ images.put(ExplainConstants.INLINED_AS_CONDITION, image);
+
+ desc = RutaAddonsPlugin.getImageDescriptor("/icons/chart_organisation.png");
+ image = desc.createImage();
+ images.put(ExplainConstants.INLINED_ACTION_BLOCK, image);
+
+ desc = RutaAddonsPlugin.getImageDescriptor("/icons/chart_organisation_add.png");
+ image = desc.createImage();
+ images.put(ExplainConstants.INLINED_CONDITION_BLOCK_MATCHED, image);
+
+ desc = RutaAddonsPlugin.getImageDescriptor("/icons/chart_organisation_delete.png");
+ image = desc.createImage();
+ images.put(ExplainConstants.INLINED_CONDITION_BLOCK_FAILED, image);
desc = RutaAddonsPlugin.getImageDescriptor("/icons/arrow_branch.png");
image = desc.createImage();
@@ -146,9 +165,12 @@ public class ApplyViewPage extends Page
document.addChangeListener(this);
- ExplainTree tree = new ExplainTree(document.getCAS());
+ ExplainTree tree = new ExplainTree(getJCas());
+
viewer.setAutoExpandLevel(2);
- viewer.setInput(tree.getRoot());
+ if (tree != null) {
+ viewer.setInput(tree.getRoot());
+ }
viewer.addDoubleClickListener(this);
getSite().setSelectionProvider(viewer);
getSite().getPage().addSelectionListener(this);
@@ -156,6 +178,16 @@ public class ApplyViewPage extends Page
viewer.refresh();
}
+ protected JCas getJCas() {
+ try {
+ return document.getCAS().getJCas();
+ } catch (CASException e) {
+ RutaAddonsPlugin.error(e);
+ }
+ return null;
+ }
+
+ @Override
public void doubleClick(DoubleClickEvent event) {
ISelection selection = event.getSelection();
if (!selection.isEmpty() && selection instanceof TreeSelection) {
@@ -203,7 +235,6 @@ public class ApplyViewPage extends Page
@Override
public void dispose() {
- super.dispose();
getSite().getPage().removeSelectionListener(this);
editor.removeCasEditorInputListener(this);
if (images != null) {
@@ -211,6 +242,7 @@ public class ApplyViewPage extends Page
each.dispose();
}
}
+ super.dispose();
}
public void mouseDown(final MouseEvent event) {
@@ -225,10 +257,12 @@ public class ApplyViewPage extends Page
}
+ @Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
}
+ @Override
public void casDocumentChanged(IEditorInput oldInput, ICasDocument oldDocument,
IEditorInput newInput, ICasDocument newDocument) {
// editor.removeCasEditorInputListener(this);
@@ -240,32 +274,40 @@ public class ApplyViewPage extends Page
}
+ @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() {
Display.getDefault().syncExec(new Runnable() {
+ @Override
public void run() {
reloadTree();
}
@@ -274,10 +316,11 @@ public class ApplyViewPage extends Page
}
private void reloadTree() {
- ExplainTree tree = new ExplainTree(document.getCAS());
+ ExplainTree tree = new ExplainTree(getJCas());
viewer.setInput(tree.getRoot());
}
+ @Override
public void viewChanged(String oldViewName, String newViewName) {
changed();
}
Modified: uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/createdBy/CreatedByViewPage.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/createdBy/CreatedByViewPage.java?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/createdBy/CreatedByViewPage.java (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/createdBy/CreatedByViewPage.java Mon Nov 18 12:19:31 2019
@@ -188,7 +188,6 @@ public class CreatedByViewPage extends P
@Override
public void dispose() {
- super.dispose();
getSite().getPage().removeSelectionListener(this);
editor.removeCasEditorInputListener(this);
if (images != null) {
@@ -196,6 +195,7 @@ public class CreatedByViewPage extends P
each.dispose();
}
}
+ super.dispose();
}
public void mouseDown(final MouseEvent event) {
Modified: uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/element/ElementTreeContentProvider.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/element/ElementTreeContentProvider.java?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/element/ElementTreeContentProvider.java (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/element/ElementTreeContentProvider.java Mon Nov 18 12:19:31 2019
@@ -19,21 +19,29 @@
package org.apache.uima.ruta.explain.element;
+import java.util.ArrayList;
+import java.util.List;
+
import org.apache.uima.ruta.explain.tree.IExplainTreeNode;
+import org.apache.uima.ruta.explain.tree.InlinedRootNode;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
-
public class ElementTreeContentProvider implements ITreeContentProvider {
+ @Override
public Object[] getChildren(Object parentElement) {
- if (parentElement instanceof IExplainTreeNode) {
- IExplainTreeNode debugNode = (IExplainTreeNode) parentElement;
- return debugNode.getChildren().toArray();
+ List<Object> result = new ArrayList<Object>();
+ IExplainTreeNode debugNode = (IExplainTreeNode) parentElement;
+ for (IExplainTreeNode each : debugNode.getChildren()) {
+ if (!(each instanceof InlinedRootNode)) {
+ result.add(each);
+ }
}
- return null;
+ return result.toArray();
}
+ @Override
public Object getParent(Object element) {
if (element instanceof IExplainTreeNode) {
return ((IExplainTreeNode) element).getParent();
@@ -42,10 +50,12 @@ public class ElementTreeContentProvider
}
+ @Override
public Object[] getElements(Object element) {
return getChildren(element);
}
+ @Override
public boolean hasChildren(Object parentElement) {
if (parentElement instanceof IExplainTreeNode) {
IExplainTreeNode debugNode = (IExplainTreeNode) parentElement;
@@ -54,9 +64,11 @@ public class ElementTreeContentProvider
return false;
}
+ @Override
public void dispose() {
}
+ @Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
Modified: uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/element/ElementViewPage.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/element/ElementViewPage.java?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/element/ElementViewPage.java (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/element/ElementViewPage.java Mon Nov 18 12:19:31 2019
@@ -23,7 +23,6 @@ import java.util.HashMap;
import java.util.Map;
import org.apache.uima.caseditor.editor.AnnotationEditor;
-import org.apache.uima.caseditor.editor.ICasDocument;
import org.apache.uima.ruta.addons.RutaAddonsPlugin;
import org.apache.uima.ruta.explain.ExplainConstants;
import org.apache.uima.ruta.explain.failed.FailedView;
@@ -48,25 +47,19 @@ public class ElementViewPage extends Pag
private Map<String, Image> images;
- private AnnotationEditor editor;
-
- private ICasDocument document;
-
public ElementViewPage(AnnotationEditor editor) {
super();
- this.editor = editor;
- this.document = editor.getDocument();
}
@Override
public void dispose() {
- super.dispose();
getSite().getPage().removeSelectionListener(this);
if (images != null) {
for (Image each : images.values()) {
each.dispose();
}
}
+ super.dispose();
}
private void initImages() {
@@ -159,6 +152,7 @@ public class ElementViewPage extends Pag
}
}
+ @Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
if (selection instanceof TreeSelection
&& (part instanceof MatchedView || part instanceof FailedView)) {
Modified: uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/failed/FailedViewPage.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/failed/FailedViewPage.java?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/failed/FailedViewPage.java (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/failed/FailedViewPage.java Mon Nov 18 12:19:31 2019
@@ -26,6 +26,7 @@ import org.apache.uima.caseditor.editor.
import org.apache.uima.ruta.addons.RutaAddonsPlugin;
import org.apache.uima.ruta.explain.ExplainConstants;
import org.apache.uima.ruta.explain.apply.ApplyView;
+import org.apache.uima.ruta.explain.inlined.InlinedView;
import org.apache.uima.ruta.explain.rulelist.RuleListView;
import org.apache.uima.ruta.explain.selection.ExplainSelectionView;
import org.apache.uima.ruta.explain.tree.BlockApplyNode;
@@ -55,13 +56,13 @@ public class FailedViewPage extends Page
@Override
public void dispose() {
- super.dispose();
getSite().getPage().removeSelectionListener(this);
if (images != null) {
for (Image each : images.values()) {
each.dispose();
}
}
+ super.dispose();
}
private void initImages() {
@@ -126,9 +127,11 @@ public class FailedViewPage extends Page
}
}
+ @Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
if (selection instanceof TreeSelection
- && (part instanceof ApplyView || part instanceof RuleListView || part instanceof ExplainSelectionView)) {
+ && (part instanceof ApplyView || part instanceof RuleListView
+ || part instanceof ExplainSelectionView || part instanceof InlinedView)) {
TreeSelection ts = (TreeSelection) selection;
Object firstElement = ts.getFirstElement();
Added: uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/inlined/InlinedTreeContentProvider.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/inlined/InlinedTreeContentProvider.java?rev=1869967&view=auto
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/inlined/InlinedTreeContentProvider.java (added)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/inlined/InlinedTreeContentProvider.java Mon Nov 18 12:19:31 2019
@@ -0,0 +1,26 @@
+/*
+ * 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.ruta.explain.inlined;
+
+import org.apache.uima.ruta.explain.apply.ApplyTreeContentProvider;
+
+public class InlinedTreeContentProvider extends ApplyTreeContentProvider {
+
+}
Added: uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/inlined/InlinedTreeLabelProvider.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/inlined/InlinedTreeLabelProvider.java?rev=1869967&view=auto
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/inlined/InlinedTreeLabelProvider.java (added)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/inlined/InlinedTreeLabelProvider.java Mon Nov 18 12:19:31 2019
@@ -0,0 +1,66 @@
+/*
+ * 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.ruta.explain.inlined;
+
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.ruta.explain.ExplainConstants;
+import org.apache.uima.ruta.explain.apply.ApplyTreeLabelProvider;
+import org.apache.uima.ruta.explain.apply.ApplyViewPage;
+import org.apache.uima.ruta.explain.tree.InlinedRuleBlockNode;
+import org.apache.uima.ruta.type.DebugInlinedBlock;
+import org.eclipse.swt.graphics.Image;
+
+public class InlinedTreeLabelProvider extends ApplyTreeLabelProvider {
+
+ public InlinedTreeLabelProvider(ApplyViewPage owner) {
+ super(owner);
+ }
+
+ @Override
+ public Image getImage(Object element) {
+ if (element instanceof InlinedRuleBlockNode) {
+ InlinedRuleBlockNode ruleBlockNode = (InlinedRuleBlockNode) element;
+ if (ruleBlockNode.isAsCondition()) {
+ if (ruleBlockNode.isMatched()) {
+ return owner.getImage(ExplainConstants.INLINED_CONDITION_BLOCK_MATCHED);
+ } else {
+ return owner.getImage(ExplainConstants.INLINED_CONDITION_BLOCK_FAILED);
+ }
+ } else {
+ return owner.getImage(ExplainConstants.INLINED_ACTION_BLOCK);
+ }
+ }
+
+ return super.getImage(element);
+ }
+
+ @Override
+ public String getText(Object element) {
+ if (element instanceof InlinedRuleBlockNode) {
+ InlinedRuleBlockNode node = (InlinedRuleBlockNode) element;
+ FeatureStructure fs = node.getFeatureStructure();
+ if (fs instanceof DebugInlinedBlock) {
+ return ((DebugInlinedBlock) fs).getElement();
+ }
+ }
+
+ return super.getText(element);
+ }
+}
Added: uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/inlined/InlinedView.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/inlined/InlinedView.java?rev=1869967&view=auto
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/inlined/InlinedView.java (added)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/inlined/InlinedView.java Mon Nov 18 12:19:31 2019
@@ -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.ruta.explain.inlined;
+
+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 InlinedView extends CasEditorView {
+
+ public static final String ID = "org.apache.uima.ruta.explain.inlined";
+
+ public InlinedView() {
+ super("The instance view is currently not available.");
+ }
+
+ @Override
+ protected IPageBookViewPage doCreatePage(ICasEditor editor) {
+ IPageBookViewPage result = null;
+ if (editor.getDocument() != null && editor instanceof AnnotationEditor) {
+ InlinedViewPage page = new InlinedViewPage((AnnotationEditor) editor);
+ result = page;
+ }
+ return result;
+ }
+
+}
Added: uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/inlined/InlinedViewPage.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/inlined/InlinedViewPage.java?rev=1869967&view=auto
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/inlined/InlinedViewPage.java (added)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/inlined/InlinedViewPage.java Mon Nov 18 12:19:31 2019
@@ -0,0 +1,82 @@
+/*
+ * 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.ruta.explain.inlined;
+
+import org.apache.uima.caseditor.editor.AnnotationEditor;
+import org.apache.uima.ruta.explain.apply.ApplyView;
+import org.apache.uima.ruta.explain.apply.ApplyViewPage;
+import org.apache.uima.ruta.explain.element.ElementView;
+import org.apache.uima.ruta.explain.failed.FailedView;
+import org.apache.uima.ruta.explain.matched.MatchedView;
+import org.apache.uima.ruta.explain.rulelist.RuleListView;
+import org.apache.uima.ruta.explain.selection.ExplainSelectionView;
+import org.apache.uima.ruta.explain.tree.ExplainAbstractTreeNode;
+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.widgets.Composite;
+import org.eclipse.ui.ISelectionListener;
+import org.eclipse.ui.IWorkbenchPart;
+
+public class InlinedViewPage extends ApplyViewPage implements ISelectionListener {
+
+ public InlinedViewPage(AnnotationEditor editor) {
+ super(editor);
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ viewer = new TreeViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
+ viewer.setContentProvider(new InlinedTreeContentProvider());
+ viewer.setLabelProvider(new InlinedTreeLabelProvider(this));
+
+ document.addChangeListener(this);
+
+ viewer.setAutoExpandLevel(2);
+ viewer.addDoubleClickListener(this);
+ getSite().setSelectionProvider(viewer);
+ getSite().getPage().addSelectionListener(this);
+ }
+
+ public void inputChange(Object newInput) {
+ if (newInput == null || viewer == null || newInput == viewer.getInput()) {
+ return;
+ }
+ this.viewer.setInput(newInput);
+ this.viewer.refresh();
+ }
+
+ @Override
+ public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+ if (selection instanceof TreeSelection
+ && (part instanceof ApplyView || part instanceof RuleListView
+ || part instanceof ExplainSelectionView || part instanceof MatchedView
+ || part instanceof FailedView || part instanceof ElementView)) {
+ TreeSelection ts = (TreeSelection) selection;
+ Object firstElement = ts.getFirstElement();
+
+ if (firstElement instanceof ExplainAbstractTreeNode) {
+ inputChange(((ExplainAbstractTreeNode) firstElement).getInlined());
+ }
+ }
+ }
+
+}
Modified: uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/matched/MatchedViewPage.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/matched/MatchedViewPage.java?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/matched/MatchedViewPage.java (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/matched/MatchedViewPage.java Mon Nov 18 12:19:31 2019
@@ -26,6 +26,7 @@ import org.apache.uima.caseditor.editor.
import org.apache.uima.ruta.addons.RutaAddonsPlugin;
import org.apache.uima.ruta.explain.ExplainConstants;
import org.apache.uima.ruta.explain.apply.ApplyView;
+import org.apache.uima.ruta.explain.inlined.InlinedView;
import org.apache.uima.ruta.explain.rulelist.RuleListView;
import org.apache.uima.ruta.explain.selection.ExplainSelectionView;
import org.apache.uima.ruta.explain.tree.BlockApplyNode;
@@ -55,13 +56,13 @@ public class MatchedViewPage extends Pag
@Override
public void dispose() {
- super.dispose();
getSite().getPage().removeSelectionListener(this);
if (images != null) {
for (Image each : images.values()) {
each.dispose();
}
}
+ super.dispose();
}
private void initImages() {
@@ -126,9 +127,11 @@ public class MatchedViewPage extends Pag
}
}
+ @Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
if (selection instanceof TreeSelection
- && (part instanceof ApplyView || part instanceof RuleListView || part instanceof ExplainSelectionView)) {
+ && (part instanceof ApplyView || part instanceof RuleListView
+ || part instanceof ExplainSelectionView || part instanceof InlinedView)) {
TreeSelection ts = (TreeSelection) selection;
Object firstElement = ts.getFirstElement();
Modified: uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/rulelist/RuleListViewPage.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/rulelist/RuleListViewPage.java?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/rulelist/RuleListViewPage.java (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/rulelist/RuleListViewPage.java Mon Nov 18 12:19:31 2019
@@ -114,6 +114,7 @@ public class RuleListViewPage extends Ap
}
}
+ @Override
public void handleEvent(Event event) {
if (event.widget == filterTextField && event.type == SWT.Modify) {
manualFilter = filterTextField.getText();
@@ -163,7 +164,7 @@ public class RuleListViewPage extends Ap
}
private void reloadTree() {
- ExplainTree tree = new ExplainTree(document.getCAS(), offset, true);
+ ExplainTree tree = new ExplainTree(getJCas(), offset, true);
filterTree(tree);
viewer.setInput(tree.getRoot());
viewer.refresh();
Modified: uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/selection/ExplainSelectionViewPage.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/selection/ExplainSelectionViewPage.java?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/selection/ExplainSelectionViewPage.java (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/selection/ExplainSelectionViewPage.java Mon Nov 18 12:19:31 2019
@@ -46,7 +46,7 @@ public class ExplainSelectionViewPage ex
viewer.setContentProvider(new ApplyTreeContentProvider());
viewer.setLabelProvider(new ApplyTreeLabelProvider(this));
- viewer.setInput(new ApplyRootNode(null, document.getCAS().getTypeSystem()));
+ viewer.setInput(new ApplyRootNode(null, getJCas().getTypeSystem()));
getSite().setSelectionProvider(viewer);
getSite().getPage().addSelectionListener(this);
@@ -57,7 +57,7 @@ public class ExplainSelectionViewPage ex
if (selection instanceof StructuredSelection && part instanceof AnnotationEditor) {
offset = editor.getCaretOffset();
if (offset >= 0) {
- ExplainTree tree = new ExplainTree(document.getCAS(), offset);
+ ExplainTree tree = new ExplainTree(getJCas(), offset);
viewer.setInput(tree.getRoot());
viewer.refresh();
}
Modified: uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/tree/ExplainAbstractTreeNode.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/tree/ExplainAbstractTreeNode.java?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/tree/ExplainAbstractTreeNode.java (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/tree/ExplainAbstractTreeNode.java Mon Nov 18 12:19:31 2019
@@ -31,6 +31,8 @@ public abstract class ExplainAbstractTre
private IExplainTreeNode parent;
+ private InlinedRootNode inlined;
+
private List<IExplainTreeNode> children;
private FeatureStructure fs;
@@ -44,14 +46,17 @@ public abstract class ExplainAbstractTre
this.ts = ts;
}
+ @Override
public IExplainTreeNode getParent() {
return parent;
}
+ @Override
public List<IExplainTreeNode> getChildren() {
return children;
}
+ @Override
public boolean hasChildren() {
if (children.size() > 0) {
return true;
@@ -59,18 +64,22 @@ public abstract class ExplainAbstractTre
return false;
}
+ @Override
public void addChild(IExplainTreeNode child) {
children.add(child);
}
+ @Override
public boolean removeChild(IExplainTreeNode child) {
return children.remove(child);
}
+ @Override
public FeatureStructure getFeatureStructure() {
return fs;
}
+ @Override
public TypeSystem getTypeSystem() {
return ts;
}
@@ -80,15 +89,26 @@ public abstract class ExplainAbstractTre
return fs.toString();
}
+ @Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public Object getAdapter(Class adapter) {
if (FeatureStructure.class.equals(adapter)) {
return getFeatureStructure();
- } else if (AnnotationFS.class.equals(adapter) && getFeatureStructure() instanceof AnnotationFS) {
+ } else if (AnnotationFS.class.equals(adapter)
+ && getFeatureStructure() instanceof AnnotationFS) {
return getFeatureStructure();
}
return null;
}
+
+ @Override
+ public InlinedRootNode getInlined() {
+ return inlined;
+ }
+
+ public void setInlined(InlinedRootNode inlined) {
+ this.inlined = inlined;
+ }
}
Modified: uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/tree/ExplainTree.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/tree/ExplainTree.java?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/tree/ExplainTree.java (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/tree/ExplainTree.java Mon Nov 18 12:19:31 2019
@@ -24,91 +24,61 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.List;
-import org.apache.uima.cas.ArrayFS;
-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.cas.TypeSystem;
-import org.apache.uima.cas.text.AnnotationFS;
-import org.apache.uima.fit.util.CasUtil;
-import org.apache.uima.ruta.explain.ExplainConstants;
+import org.apache.uima.fit.util.JCasUtil;
+import org.apache.uima.jcas.JCas;
+import org.apache.uima.jcas.cas.FSArray;
+import org.apache.uima.ruta.type.DebugBlockApply;
+import org.apache.uima.ruta.type.DebugEvaluatedCondition;
+import org.apache.uima.ruta.type.DebugInlinedBlock;
+import org.apache.uima.ruta.type.DebugRuleApply;
+import org.apache.uima.ruta.type.DebugRuleElementMatch;
+import org.apache.uima.ruta.type.DebugRuleElementMatches;
+import org.apache.uima.ruta.type.DebugRuleMatch;
+import org.apache.uima.ruta.type.DebugScriptApply;
public class ExplainTree {
private IExplainTreeNode root;
- private Type ruleMatchType;
-
- private Type blockApplyType;
-
- private Type ruleApplyType;
-
- private Type ruleElementMatchType;
-
- private Type ruleElementMatchesType;
-
- private Type evaluatedConditionType;
-
- private Type matchedRuleMatchType;
-
- private Type failedRuleMatchType;
-
- public ExplainTree(CAS cas) {
- this(cas, -1);
+ public ExplainTree(JCas jcas) {
+ this(jcas, -1);
}
- public ExplainTree(CAS cas, int offset) {
- this(cas, offset, false);
+ public ExplainTree(JCas jcas, int offset) {
+ this(jcas, offset, false);
if (offset >= 0) {
prune(root);
}
}
- public ExplainTree(CAS cas, int offset, boolean onlyRules) {
- createTree(cas, offset, onlyRules);
+ public ExplainTree(JCas jcas, int offset, boolean onlyRules) {
+ createTree(jcas, offset, onlyRules);
}
public IExplainTreeNode getRoot() {
return root;
}
- private void createTree(CAS cas, int offset, boolean onlyRules) {
- TypeSystem ts = cas.getTypeSystem();
- Type scriptApplyType = ts.getType(ExplainConstants.SCRIPT_APPLY_TYPE);
-
- blockApplyType = ts.getType(ExplainConstants.BLOCK_APPLY_TYPE);
- ruleApplyType = ts.getType(ExplainConstants.RULE_APPLY_TYPE);
- ruleMatchType = ts.getType(ExplainConstants.RULE_MATCH_TYPE);
- matchedRuleMatchType = ts.getType(ExplainConstants.MATCHED_RULE_MATCH_TYPE);
- failedRuleMatchType = ts.getType(ExplainConstants.FAILED_RULE_MATCH_TYPE);
- ruleElementMatchType = ts.getType(ExplainConstants.RULE_ELEMENT_MATCH_TYPE);
- ruleElementMatchesType = ts.getType(ExplainConstants.RULE_ELEMENT_MATCHES_TYPE);
- evaluatedConditionType = ts.getType(ExplainConstants.EVAL_CONDITION_TYPE);
-
- if (scriptApplyType == null) {
- return;
- }
-
- List<AnnotationFS> scriptApplies = new ArrayList<>(CasUtil.select(cas, scriptApplyType));
+ private void createTree(JCas jcas, int offset, boolean onlyRules) {
+ TypeSystem ts = jcas.getTypeSystem();
+ List<DebugScriptApply> scriptApplies = new ArrayList<>(
+ JCasUtil.select(jcas, DebugScriptApply.class));
// sort by creation time
- Collections.sort(scriptApplies, new Comparator<AnnotationFS>() {
+ Collections.sort(scriptApplies, new Comparator<DebugScriptApply>() {
@Override
- public int compare(AnnotationFS o1, AnnotationFS o2) {
- Feature feature = o1.getType().getFeatureByBaseName(ExplainConstants.TIME_STAMP);
- if (feature == null || !o1.getType().equals(o2.getType())) {
- return o1.getType().getName().compareTo(o2.getType().getName());
- }
- long l1 = o1.getLongValue(feature);
- long l2 = o2.getLongValue(feature);
+ public int compare(DebugScriptApply o1, DebugScriptApply o2) {
+ long l1 = o1.getTimestamp();
+ long l2 = o2.getTimestamp();
return Long.compare(l1, l2);
}
});
root = new ApplyRootNode(null, ts);
- for (AnnotationFS scriptApply : scriptApplies) {
+ for (DebugScriptApply scriptApply : scriptApplies) {
buildTree(scriptApply, root, ts, offset, onlyRules);
}
@@ -116,23 +86,36 @@ public class ExplainTree {
private void buildTree(FeatureStructure fs, IExplainTreeNode parent, TypeSystem ts, int offset,
boolean onlyRules) {
- if (blockApplyType != null && blockApplyType.equals(fs.getType())) {
- processBlockApply((AnnotationFS) fs, parent, ts, offset, onlyRules);
- } else if (ruleApplyType != null && ruleApplyType.equals(fs.getType())) {
- processRuleApply((AnnotationFS) fs, parent, ts, offset, onlyRules);
- } else if ((matchedRuleMatchType != null && matchedRuleMatchType.equals(fs.getType()))
- || (failedRuleMatchType != null && failedRuleMatchType.equals(fs.getType()))) {
- processRuleMatch((AnnotationFS) fs, parent, ts, offset, onlyRules);
- } else if (ruleElementMatchesType != null && ruleElementMatchesType.equals(fs.getType())) {
- processRuleElementMatches(fs, parent, ts, offset, onlyRules);
- } else if (ruleElementMatchType != null && ruleElementMatchType.equals(fs.getType())) {
- processRuleElementMatch((AnnotationFS) fs, parent, ts, offset, onlyRules);
- } else if (evaluatedConditionType != null && evaluatedConditionType.equals(fs.getType())) {
- processEvaluatedCondition(fs, parent, ts, offset, onlyRules);
+ if (fs instanceof DebugBlockApply) {
+ processBlockApply((DebugBlockApply) fs, parent, ts, offset, onlyRules);
+ } else if (fs instanceof DebugRuleApply) {
+ processRuleApply((DebugRuleApply) fs, parent, ts, offset, onlyRules);
+ } else if (fs instanceof DebugRuleMatch) {
+ processRuleMatch((DebugRuleMatch) fs, parent, ts, offset, onlyRules);
+ } else if (fs instanceof DebugRuleElementMatches) {
+ processRuleElementMatches((DebugRuleElementMatches) fs, parent, ts, offset, onlyRules);
+ } else if (fs instanceof DebugRuleElementMatch) {
+ processRuleElementMatch((DebugRuleElementMatch) fs, parent, ts, offset, onlyRules);
+ } else if (fs instanceof DebugEvaluatedCondition) {
+ processEvaluatedCondition((DebugEvaluatedCondition) fs, parent, ts, offset, onlyRules);
+ }
+ }
+
+ private void buildInlinedBlock(boolean asCondition, DebugInlinedBlock debugInlinedBlock,
+ IExplainTreeNode parent, TypeSystem ts, int offset, boolean onlyRules) {
+ InlinedRuleBlockNode inlinedBlockNode = new InlinedRuleBlockNode(parent, debugInlinedBlock,
+ debugInlinedBlock.getAsCondition(), debugInlinedBlock.getMatched(), ts);
+ parent.addChild(inlinedBlockNode);
+
+ FSArray inlinedRules = debugInlinedBlock.getInlinedRules();
+ if (inlinedRules != null) {
+ for (FeatureStructure each : inlinedRules) {
+ buildTree(each, inlinedBlockNode, ts, offset, onlyRules);
+ }
}
}
- private void processBlockApply(AnnotationFS fs, IExplainTreeNode parent, TypeSystem ts,
+ private void processBlockApply(DebugBlockApply fs, IExplainTreeNode parent, TypeSystem ts,
int offset, boolean onlyRules) {
if (offset >= 0 && (fs.getBegin() >= offset || fs.getEnd() <= offset)) {
return;
@@ -143,21 +126,19 @@ public class ExplainTree {
parent.addChild(blockNode);
processBlockRuleApply(fs, blockNode, ts, offset, onlyRules);
}
- Feature feature = blockApplyType.getFeatureByBaseName(ExplainConstants.INNER_APPLY);
- FeatureStructure featureValue = fs.getFeatureValue(feature);
- ArrayFS value = (ArrayFS) featureValue;
- FeatureStructure[] fsarray = value.toArray();
- for (FeatureStructure each : fsarray) {
- if (!onlyRules) {
- buildTree(each, blockNode, ts, offset, onlyRules);
- } else {
- buildTree(each, parent, ts, offset, onlyRules);
- }
+ if (fs.getInnerApply() != null) {
+ for (FeatureStructure each : fs.getInnerApply()) {
+ if (!onlyRules) {
+ buildTree(each, blockNode, ts, offset, onlyRules);
+ } else {
+ buildTree(each, parent, ts, offset, onlyRules);
+ }
+ }
}
}
- private void processBlockRuleApply(AnnotationFS fs, BlockApplyNode parent, TypeSystem ts,
+ private void processBlockRuleApply(DebugBlockApply fs, BlockApplyNode parent, TypeSystem ts,
int offset, boolean onlyRules) {
if (offset >= 0 && (fs.getBegin() >= offset || fs.getEnd() <= offset)) {
return;
@@ -165,82 +146,66 @@ public class ExplainTree {
RuleApplyNode ruleNode = new RuleApplyNode(parent, fs, ts);
parent.setBlockRuleApply(ruleNode);
- Feature feature = ruleApplyType.getFeatureByBaseName(ExplainConstants.RULES);
- ArrayFS value = (ArrayFS) fs.getFeatureValue(feature);
- if (value == null)
- return;
- FeatureStructure[] fsarray = value.toArray();
-
MatchedRootNode matched = new MatchedRootNode(ruleNode, ts);
FailedRootNode failed = new FailedRootNode(ruleNode, ts);
ruleNode.addChild(matched);
ruleNode.addChild(failed);
- for (FeatureStructure eachRuleMatch : fsarray) {
- Feature f = eachRuleMatch.getType().getFeatureByBaseName(ExplainConstants.MATCHED);
- boolean matchedValue = eachRuleMatch.getBooleanValue(f);
- if (matchedValue) {
- buildTree(eachRuleMatch, matched, ts, offset, onlyRules);
- } else {
- buildTree(eachRuleMatch, failed, ts, offset, onlyRules);
- }
-
- Feature df = eachRuleMatch.getType().getFeatureByBaseName(ExplainConstants.DELEGATES);
- if (df != null) {
- ArrayFS dv = (ArrayFS) eachRuleMatch.getFeatureValue(df);
- if (dv != null) {
- FeatureStructure[] da = dv.toArray();
- for (FeatureStructure delegateFS : da) {
+ if (fs.getRules() != null) {
+ for (FeatureStructure each : fs.getRules()) {
+ DebugRuleMatch eachRuleMatch = (DebugRuleMatch) each;
+ boolean matchedValue = eachRuleMatch.getMatched();
+ if (matchedValue) {
+ buildTree(eachRuleMatch, matched, ts, offset, onlyRules);
+ } else {
+ buildTree(eachRuleMatch, failed, ts, offset, onlyRules);
+ }
+ if (eachRuleMatch.getDelegates() != null) {
+ for (FeatureStructure delegateFS : eachRuleMatch.getDelegates()) {
buildTree(delegateFS, ruleNode, ts, offset, onlyRules);
}
}
}
-
}
+
}
- private void processRuleApply(AnnotationFS fs, IExplainTreeNode parent, TypeSystem ts, int offset,
- boolean onlyRules) {
+ private void processRuleApply(DebugRuleApply fs, IExplainTreeNode parent, TypeSystem ts,
+ int offset, boolean onlyRules) {
if (offset >= 0 && (fs.getBegin() >= offset || fs.getEnd() <= offset)) {
return;
}
RuleApplyNode ruleNode = new RuleApplyNode(parent, fs, ts);
parent.addChild(ruleNode);
- Feature feature = ruleApplyType.getFeatureByBaseName(ExplainConstants.RULES);
- ArrayFS value = (ArrayFS) fs.getFeatureValue(feature);
- FeatureStructure[] fsarray = value.toArray();
-
MatchedRootNode matched = new MatchedRootNode(ruleNode, ts);
FailedRootNode failed = new FailedRootNode(ruleNode, ts);
ruleNode.addChild(matched);
ruleNode.addChild(failed);
- for (FeatureStructure eachRuleMatch : fsarray) {
- Feature f = eachRuleMatch.getType().getFeatureByBaseName(ExplainConstants.MATCHED);
- boolean matchedValue = eachRuleMatch.getBooleanValue(f);
- if (matchedValue) {
- buildTree(eachRuleMatch, matched, ts, offset, onlyRules);
- } else {
- buildTree(eachRuleMatch, failed, ts, offset, onlyRules);
- }
-
- Feature df = eachRuleMatch.getType().getFeatureByBaseName(ExplainConstants.DELEGATES);
- if (df != null) {
- ArrayFS dv = (ArrayFS) eachRuleMatch.getFeatureValue(df);
- if (dv != null) {
- FeatureStructure[] da = dv.toArray();
- for (FeatureStructure delegateFS : da) {
+ if (fs.getRules() != null) {
+ for (FeatureStructure each : fs.getRules()) {
+ DebugRuleMatch eachRuleMatch = (DebugRuleMatch) each;
+ boolean matchedValue = eachRuleMatch.getMatched();
+ if (matchedValue) {
+ buildTree(eachRuleMatch, matched, ts, offset, onlyRules);
+ } else {
+ buildTree(eachRuleMatch, failed, ts, offset, onlyRules);
+ }
+ if (eachRuleMatch.getDelegates() != null) {
+ for (FeatureStructure delegateFS : eachRuleMatch.getDelegates()) {
buildTree(delegateFS, ruleNode, ts, offset, onlyRules);
}
}
}
-
+ if (fs.getRules().size() == 1) {
+ mergeInlinedRuleBlockNodesOfChildren(ruleNode);
+ }
}
}
- private void processRuleMatch(AnnotationFS fs, IExplainTreeNode parent, TypeSystem ts, int offset,
- boolean onlyRules) {
+ private void processRuleMatch(DebugRuleMatch fs, IExplainTreeNode parent, TypeSystem ts,
+ int offset, boolean onlyRules) {
if (offset >= 0 && (fs.getBegin() >= offset || fs.getEnd() <= offset)) {
return;
}
@@ -250,74 +215,120 @@ public class ExplainTree {
RuleElementRootNode remRoot = new RuleElementRootNode(matchNode, ts);
matchNode.addChild(remRoot);
- Feature feature = ruleMatchType.getFeatureByBaseName(ExplainConstants.ELEMENTS);
- ArrayFS value = (ArrayFS) fs.getFeatureValue(feature);
- if (value != null) {
- FeatureStructure[] fsarray = value.toArray();
- for (FeatureStructure each : fsarray) {
+ if (fs.getElements() != null) {
+ for (FeatureStructure each : fs.getElements()) {
buildTree(each, remRoot, ts, offset, onlyRules);
}
}
+ mergeInlinedRuleBlockNodesOfChildren(matchNode);
}
- private void processRuleElementMatches(FeatureStructure fs, IExplainTreeNode parent,
+ private void processRuleElementMatches(DebugRuleElementMatches fs, IExplainTreeNode parent,
TypeSystem ts, int offset, boolean onlyRules) {
RuleElementMatchesNode remsNode = new RuleElementMatchesNode(parent, fs, ts);
parent.addChild(remsNode);
- Feature feature = ruleElementMatchesType.getFeatureByBaseName(ExplainConstants.MATCHES);
- ArrayFS value = (ArrayFS) fs.getFeatureValue(feature);
- FeatureStructure[] fsarray = value.toArray();
- for (FeatureStructure each : fsarray) {
- buildTree(each, remsNode, ts, offset, onlyRules);
+ if (fs.getMatches() != null) {
+ for (FeatureStructure each : fs.getMatches()) {
+ buildTree(each, remsNode, ts, offset, onlyRules);
+ }
+ }
+
+ FSArray inlinedActionBlocks = fs.getInlinedActionBlocks();
+ if (inlinedActionBlocks != null) {
+ InlinedRootNode inlinedRootNode = new InlinedRootNode(remsNode, ts);
+ remsNode.setInlined(inlinedRootNode);
+ for (FeatureStructure each : inlinedActionBlocks) {
+ if (each instanceof DebugInlinedBlock) {
+ buildInlinedBlock(false, (DebugInlinedBlock) each, inlinedRootNode, ts, offset,
+ onlyRules);
+ }
+ }
}
+ mergeInlinedRuleBlockNodesOfChildren(remsNode);
}
- private void processRuleElementMatch(AnnotationFS fs, IExplainTreeNode parent, TypeSystem ts,
- int offset, boolean onlyRules) {
+ private void processRuleElementMatch(DebugRuleElementMatch fs, IExplainTreeNode parent,
+ TypeSystem ts, int offset, boolean onlyRules) {
if (offset >= 0 && (fs.getBegin() >= offset || fs.getEnd() <= offset)) {
return;
}
RuleElementMatchNode remNode = new RuleElementMatchNode(parent, fs, ts);
parent.addChild(remNode);
- Feature feature = ruleElementMatchType.getFeatureByBaseName(ExplainConstants.BASE_CONDITION);
- FeatureStructure base = fs.getFeatureValue(feature);
- buildTree(base, remNode, ts, offset, onlyRules);
-
- feature = ruleElementMatchType.getFeatureByBaseName(ExplainConstants.CONDITIONS);
- ArrayFS value = (ArrayFS) fs.getFeatureValue(feature);
- if (value != null) {
- FeatureStructure[] fsarray = value.toArray();
- for (FeatureStructure each : fsarray) {
+ DebugEvaluatedCondition baseCondition = fs.getBaseCondition();
+ buildTree(baseCondition, remNode, ts, offset, onlyRules);
+
+ if (fs.getConditions() != null) {
+ for (FeatureStructure each : fs.getConditions()) {
buildTree(each, remNode, ts, offset, onlyRules);
}
}
- feature = fs.getType().getFeatureByBaseName(ExplainConstants.ELEMENTS);
- value = (ArrayFS) fs.getFeatureValue(feature);
- if (value != null) {
- FeatureStructure[] fsarray = value.toArray();
- for (FeatureStructure each : fsarray) {
+ if (fs.getElements() != null) {
+ for (FeatureStructure each : fs.getElements()) {
buildTree(each, remNode, ts, offset, onlyRules);
}
}
+ FSArray inlinedConditionBlocks = fs.getInlinedConditionBlocks();
+ if (inlinedConditionBlocks != null) {
+ InlinedRootNode inlinedRootNode = new InlinedRootNode(remNode, ts);
+ remNode.setInlined(inlinedRootNode);
+ for (FeatureStructure each : inlinedConditionBlocks) {
+ if (each instanceof DebugInlinedBlock) {
+ buildInlinedBlock(true, (DebugInlinedBlock) each, inlinedRootNode, ts, offset, onlyRules);
+ }
+ }
+ }
+ mergeInlinedRuleBlockNodesOfChildren(remNode);
}
- private void processEvaluatedCondition(FeatureStructure fs, IExplainTreeNode parent,
+ private void processEvaluatedCondition(DebugEvaluatedCondition fs, IExplainTreeNode parent,
TypeSystem ts, int offset, boolean onlyRules) {
ConditionNode condNode = new ConditionNode(parent, fs, ts);
parent.addChild(condNode);
- Feature feature = evaluatedConditionType.getFeatureByBaseName(ExplainConstants.CONDITIONS);
- ArrayFS value = (ArrayFS) fs.getFeatureValue(feature);
- if (value != null) {
- FeatureStructure[] fsarray = value.toArray();
- for (FeatureStructure each : fsarray) {
+ if (fs.getConditions() != null) {
+ for (FeatureStructure each : fs.getConditions()) {
buildTree(each, condNode, ts, offset, onlyRules);
}
}
}
+ private void mergeInlinedRuleBlockNodesOfChildren(ExplainAbstractTreeNode parent) {
+
+ List<IExplainTreeNode> list = new ArrayList<>();
+
+ for (IExplainTreeNode each : parent.getChildren()) {
+ collectInlinedBlockNodes(each, list);
+ }
+ InlinedRootNode inlinedRootNode = parent.getInlined();
+ if (inlinedRootNode == null && !list.isEmpty()) {
+ inlinedRootNode = new InlinedRootNode(parent, parent.getTypeSystem());
+ parent.setInlined(inlinedRootNode);
+ }
+
+ if (inlinedRootNode != null) {
+ for (IExplainTreeNode each : list) {
+ if (!inlinedRootNode.getChildren().contains(each)) {
+ inlinedRootNode.addChild(each);
+ }
+ }
+ }
+ }
+
+ private void collectInlinedBlockNodes(IExplainTreeNode node, List<IExplainTreeNode> result) {
+ if (node.getInlined() != null && node.getInlined().hasChildren()) {
+ // already collected down to this level
+ result.addAll(node.getInlined().getChildren());
+ return;
+ }
+
+ List<IExplainTreeNode> children = node.getChildren();
+ for (IExplainTreeNode each : children) {
+ collectInlinedBlockNodes(each, result);
+ }
+ }
+
private void prune(IExplainTreeNode node) {
if (node == null) {
return;
Modified: uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/tree/IExplainTreeNode.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/tree/IExplainTreeNode.java?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/tree/IExplainTreeNode.java (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/tree/IExplainTreeNode.java Mon Nov 18 12:19:31 2019
@@ -39,4 +39,7 @@ public interface IExplainTreeNode {
FeatureStructure getFeatureStructure();
TypeSystem getTypeSystem();
+
+ ExplainAbstractTreeNode getInlined();
+
}
Added: uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/tree/InlinedRootNode.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/tree/InlinedRootNode.java?rev=1869967&view=auto
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/tree/InlinedRootNode.java (added)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/tree/InlinedRootNode.java Mon Nov 18 12:19:31 2019
@@ -0,0 +1,34 @@
+/*
+ * 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.ruta.explain.tree;
+
+import org.apache.uima.cas.TypeSystem;
+
+public class InlinedRootNode extends ExplainAbstractTreeNode implements ExplainRootNode {
+
+ public InlinedRootNode(IExplainTreeNode parent, TypeSystem ts) {
+ super(parent, null, ts);
+ }
+
+ @Override
+ public String toString() {
+ return "Inlined";
+ }
+}
Added: uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/tree/InlinedRuleBlockNode.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/tree/InlinedRuleBlockNode.java?rev=1869967&view=auto
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/tree/InlinedRuleBlockNode.java (added)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/explain/tree/InlinedRuleBlockNode.java Mon Nov 18 12:19:31 2019
@@ -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.ruta.explain.tree;
+
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.TypeSystem;
+
+public class InlinedRuleBlockNode extends ExplainAbstractTreeNode {
+
+ private final boolean asCondition;
+
+ private final boolean matched;
+
+ public InlinedRuleBlockNode(IExplainTreeNode parent, FeatureStructure fs, boolean asCondition,
+ boolean matched, TypeSystem ts) {
+ super(parent, fs, ts);
+ this.asCondition = asCondition;
+ this.matched = matched;
+ }
+
+ @Override
+ public void addChild(IExplainTreeNode node) {
+ super.addChild(node);
+ }
+
+ public boolean isAsCondition() {
+ return asCondition;
+ }
+
+ public boolean isMatched() {
+ return matched;
+ }
+
+}
Modified: uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/statistics/StatisticsViewPage.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/statistics/StatisticsViewPage.java?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/statistics/StatisticsViewPage.java (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/statistics/StatisticsViewPage.java Mon Nov 18 12:19:31 2019
@@ -74,12 +74,12 @@ public class StatisticsViewPage extends
@Override
public void dispose() {
- super.dispose();
if (images != null) {
for (Image each : images.values()) {
each.dispose();
}
}
+ super.dispose();
}
private void initImages() {
Modified: uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/views/evalDataTable/TypeTableSorter.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/views/evalDataTable/TypeTableSorter.java?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/views/evalDataTable/TypeTableSorter.java (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/views/evalDataTable/TypeTableSorter.java Mon Nov 18 12:19:31 2019
@@ -23,7 +23,7 @@ import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerSorter;
public class TypeTableSorter extends ViewerSorter {
-
+
private static final int ASCENDING = 0;
private static final int DESCENDING = 1;
@@ -32,13 +32,6 @@ public class TypeTableSorter extends Vie
private int direction;
- /**
- * Does the sort. If it's a different column from the previous sort, do an
- * ascending sort. If it's the same column as the last sort, toggle the sort
- * direction.
- *
- * @param column
- */
public void doSort(int column) {
if (column == this.column) {
// Same column as last sort; toggle the direction
@@ -50,19 +43,13 @@ public class TypeTableSorter extends Vie
}
}
- /**
- * Compares the object for sorting
- */
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
int rc = 0;
TypeEvalData td1 = (TypeEvalData) e1;
TypeEvalData td2 = (TypeEvalData) e2;
-
-
-
- switch(column) {
+ switch (column) {
case TypeEvalTableConst.COLUMN_TYPE_NAME:
rc = td1.getTypeName().compareTo(td2.getTypeName());
break;
@@ -76,50 +63,21 @@ public class TypeTableSorter extends Vie
rc = td1.getFalseNegatives() - td2.getFalseNegatives();
break;
case TypeEvalTableConst.COLUMN_PRECISION:
- rc = Double.compare(td1.getPrecision() , td2.getPrecision());
+ rc = Double.compare(td1.getPrecision(), td2.getPrecision());
break;
case TypeEvalTableConst.COLUMN_RECALL:
- rc = Double.compare(td1.getRecall() , td2.getRecall());
+ rc = Double.compare(td1.getRecall(), td2.getRecall());
break;
case TypeEvalTableConst.COLUMN_F1:
- rc = Double.compare(td1.getFOne() , td2.getFOne());;
+ rc = Double.compare(td1.getFOne(), td2.getFOne());
+ ;
break;
}
-
+
if (direction == DESCENDING)
rc = -rc;
- return rc;
-
-
-// int rc = 0;
-// Player p1 = (Player) e1;
-// Player p2 = (Player) e2;
-//
-// // Determine which column and do the appropriate sort
-// switch (column) {
-// case PlayerConst.COLUMN_FIRST_NAME:
-// rc = collator.compare(p1.getFirstName(), p2.getFirstName());
-// break;
-// case PlayerConst.COLUMN_LAST_NAME:
-// rc = collator.compare(p1.getLastName(), p2.getLastName());
-// break;
-// case PlayerConst.COLUMN_POINTS:
-// rc = p1.getPoints() > p2.getPoints() ? 1 : -1;
-// break;
-// case PlayerConst.COLUMN_REBOUNDS:
-// rc = p1.getRebounds() > p2.getRebounds() ? 1 : -1;
-// break;
-// case PlayerConst.COLUMN_ASSISTS:
-// rc = p1.getAssists() > p2.getAssists() ? 1 : -1;
-// break;
-// }
-//
-// // If descending order, flip the direction
-// if (direction == DESCENDING)
-// rc = -rc;
-//
-// return rc;
+ return rc;
}
}
Modified: uima/uv3/ruta-v3/trunk/ruta-ep-caseditor/pom.xml
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-caseditor/pom.xml?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-caseditor/pom.xml (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-caseditor/pom.xml Mon Nov 18 12:19:31 2019
@@ -134,6 +134,7 @@
<exclude>release.properties</exclude> <!-- release generated artifact -->
<exclude>src/test/resources/ManualTests/*</exclude> <!-- test data -->
<exclude>marker-file-identifying-*</exclude>
+ <exclude>META-INF/MANIFEST.MF</exclude>
<exclude>issuesFixed/**</exclude>
</excludes>
</configuration>
@@ -154,7 +155,7 @@
<instructions>
<Bundle-SymbolicName>org.apache.uima.ruta.caseditor;singleton:=true</Bundle-SymbolicName>
<Bundle-Activator>org.apache.uima.ruta.caseditor.RutaCasEditorPlugin</Bundle-Activator>
- <Bundle-RequiredExecutionEnvironment>JavaSE-1.7</Bundle-RequiredExecutionEnvironment>
+ <Bundle-RequiredExecutionEnvironment>JavaSE-1.8</Bundle-RequiredExecutionEnvironment>
<Bundle-ActivationPolicy>lazy</Bundle-ActivationPolicy>
<_nouses>true</_nouses>
<Export-Package>
Modified: uima/uv3/ruta-v3/trunk/ruta-ep-caseditor/src/main/java/org/apache/uima/ruta/caseditor/view/tree/AnnotationTreeViewPage.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-caseditor/src/main/java/org/apache/uima/ruta/caseditor/view/tree/AnnotationTreeViewPage.java?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-caseditor/src/main/java/org/apache/uima/ruta/caseditor/view/tree/AnnotationTreeViewPage.java (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-caseditor/src/main/java/org/apache/uima/ruta/caseditor/view/tree/AnnotationTreeViewPage.java Mon Nov 18 12:19:31 2019
@@ -380,7 +380,6 @@ public class AnnotationTreeViewPage exte
*/
@Override
public void dispose() {
- super.dispose();
getSite().getPage().removeSelectionListener(this);
editor.removeAnnotationListener(this);
editor.getCasDocumentProvider().getTypeSystemPreferenceStore(editor.getEditorInput())
@@ -391,6 +390,7 @@ public class AnnotationTreeViewPage exte
image.dispose();
}
rutaImage.dispose();
+ super.dispose();
}
/*
Modified: uima/uv3/ruta-v3/trunk/ruta-ep-caseditor/src/main/java/org/apache/uima/ruta/caseditor/view/tree/FSTreeNode.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-caseditor/src/main/java/org/apache/uima/ruta/caseditor/view/tree/FSTreeNode.java?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-caseditor/src/main/java/org/apache/uima/ruta/caseditor/view/tree/FSTreeNode.java (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-caseditor/src/main/java/org/apache/uima/ruta/caseditor/view/tree/FSTreeNode.java Mon Nov 18 12:19:31 2019
@@ -23,7 +23,6 @@ import java.util.Collections;
import java.util.List;
import java.util.Stack;
-import org.apache.commons.lang3.StringUtils;
import org.apache.uima.cas.ArrayFS;
import org.apache.uima.cas.CAS;
import org.apache.uima.cas.CommonArrayFS;
@@ -41,7 +40,8 @@ public class FSTreeNode extends Abstract
this(cas, parent, annotation, new Stack<Type>());
}
- public FSTreeNode(CAS cas, ITreeNode parent, FeatureStructure annotation, Stack<Type> parentTypes) {
+ public FSTreeNode(CAS cas, ITreeNode parent, FeatureStructure annotation,
+ Stack<Type> parentTypes) {
super(cas, parent);
this.fs = annotation;
parentTypes.push(fs.getType());
@@ -92,16 +92,22 @@ public class FSTreeNode extends Abstract
}
}
} else if (featureValue instanceof CommonArrayFS) {
- // handle all other kind of CommonArrayFS nodes (ArrayFS handled above)
+ // handle all other kind of CommonArrayFS nodes (ArrayFS handled above)
CommonArrayFS array = (CommonArrayFS) featureValue;
- String text = "[" + StringUtils.join(array.toStringArray(), ", ") + "]";
- parent.addChild(new ArrayFeatureTreeNode(this, f, text));
+ String text = "Array" + "[" + array.size() + "]";
+ PrimitiveFeatureTreeNode arrayNode = new PrimitiveFeatureTreeNode(this, f, text);
+ parent.addChild(arrayNode);
+ String[] stringArray = array.toStringArray();
+ for (String string : stringArray) {
+ PrimitiveTreeNode stringNode = new PrimitiveTreeNode(arrayNode, string);
+ arrayNode.addChild(stringNode);
+ }
}
} else if (f.getRange().isPrimitive()) {
if ("uima.cas.AnnotationBase:sofa".equals(f.getName())) {
} else {
- parent.addChild(new PrimitiveFeatureTreeNode(this, f, featureStructure
- .getFeatureValueAsString(f)));
+ parent.addChild(
+ new PrimitiveFeatureTreeNode(this, f, featureStructure.getFeatureValueAsString(f)));
}
} else if (f.getRange() instanceof Type) {
FeatureStructure featureValue = featureStructure.getFeatureValue(f);
Added: uima/uv3/ruta-v3/trunk/ruta-ep-caseditor/src/main/java/org/apache/uima/ruta/caseditor/view/tree/PrimitiveTreeNode.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-caseditor/src/main/java/org/apache/uima/ruta/caseditor/view/tree/PrimitiveTreeNode.java?rev=1869967&view=auto
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-caseditor/src/main/java/org/apache/uima/ruta/caseditor/view/tree/PrimitiveTreeNode.java (added)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-caseditor/src/main/java/org/apache/uima/ruta/caseditor/view/tree/PrimitiveTreeNode.java Mon Nov 18 12:19:31 2019
@@ -0,0 +1,85 @@
+/*
+ * 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.ruta.caseditor.view.tree;
+
+import java.util.Comparator;
+
+import org.apache.uima.cas.Type;
+
+public class PrimitiveTreeNode implements ITreeNode {
+
+ private static final ITreeNode[] EMPTY_NODES = new ITreeNode[0];
+
+ private ITreeNode parent;
+
+ private String value;
+
+ public PrimitiveTreeNode(ITreeNode parent, String value) {
+ this.parent = parent;
+ this.value = value;
+ }
+
+ @Override
+ public void addChild(ITreeNode child) {
+ // nothing to do
+ }
+
+ @Override
+ public ITreeNode[] getChildren() {
+ return EMPTY_NODES;
+ }
+
+ @Override
+ public String getName() {
+ return value;
+ }
+
+ @Override
+ public ITreeNode getParent() {
+ return parent;
+ }
+
+ @Override
+ public Type getType() {
+ return null;
+ }
+
+ @Override
+ public boolean hasChildren() {
+ return false;
+ }
+
+ @Override
+ public void sort(Comparator<ITreeNode> cp) {
+ // nothing to do
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
+
+ if (PrimitiveTreeNode.class.equals(adapter)) {
+ return this;
+ }
+
+ return null;
+ }
+
+}
Modified: uima/uv3/ruta-v3/trunk/ruta-ep-core-ext/pom.xml
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-core-ext/pom.xml?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-core-ext/pom.xml (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-core-ext/pom.xml Mon Nov 18 12:19:31 2019
@@ -104,6 +104,7 @@
<excludes>
<exclude>release.properties</exclude> <!-- release generated artifact -->
<exclude>marker-file-identifying-*</exclude>
+ <exclude>META-INF/MANIFEST.MF</exclude>
<exclude>issuesFixed/**</exclude>
</excludes>
</configuration>
@@ -136,7 +137,7 @@
<Import-Package>
</Import-Package>
<Bundle-SymbolicName>org.apache.uima.ruta.core.ext;singleton:=true</Bundle-SymbolicName>
- <Bundle-RequiredExecutionEnvironment>JavaSE-1.7</Bundle-RequiredExecutionEnvironment>
+ <Bundle-RequiredExecutionEnvironment>JavaSE-1.8</Bundle-RequiredExecutionEnvironment>
<Bundle-ActivationPolicy>lazy</Bundle-ActivationPolicy>
<Eclipse-ExtensibleAPI>true</Eclipse-ExtensibleAPI>
<Eclipse-BuddyPolicy>registered</Eclipse-BuddyPolicy>
Modified: uima/uv3/ruta-v3/trunk/ruta-ep-engine/pom.xml
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-engine/pom.xml?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-engine/pom.xml (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-engine/pom.xml Mon Nov 18 12:19:31 2019
@@ -81,6 +81,12 @@ licensed under the Common Public License
<scope>compile</scope>
</dependency>
<dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-text</artifactId>
+ <version>1.6</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
@@ -176,13 +182,6 @@ licensed under the Common Public License
<version>3.1.2.RELEASE</version>
<scope>compile</scope>
</dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>1.7.24</version>
- <scope>compile</scope>
- </dependency>
-
</dependencies>
<scm>
<url>http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-ep-engine</url>
@@ -210,6 +209,7 @@ licensed under the Common Public License
<excludes>
<exclude>release.properties</exclude> <!-- release generated artifact -->
<exclude>marker-file-identifying-*</exclude>
+ <exclude>META-INF/MANIFEST.MF</exclude>
<exclude>issuesFixed/**</exclude>
</excludes>
</configuration>
@@ -235,7 +235,9 @@ licensed under the Common Public License
org.apache.uima.ruta.descriptor,
org.apache.uima.ruta.engine,
org.apache.uima.ruta.expression,
+ org.apache.uima.ruta.expression.annotation,
org.apache.uima.ruta.expression.bool,
+ org.apache.uima.ruta.expression.feature,
org.apache.uima.ruta.expression.list,
org.apache.uima.ruta.expression.number,
org.apache.uima.ruta.expression.resource,
@@ -260,12 +262,13 @@ licensed under the Common Public License
org.antlr.runtime.tree,
org.htmlparser,
org.htmlparser.*,
+ org.apache.commons.text.*,
org.apache.commons.lang3.*,
+ org.apache.commons.logging,
org.apache.commons.io.*,
org.apache.uima.fit.*,
org.apache.commons.math3.*,
- org.springframework.*,
- org.slf4j.*
+ org.springframework.*
</_exportcontents>
<Import-Package>
@@ -287,7 +290,7 @@ licensed under the Common Public License
!javax.xml.stream.events, !javax.xml.stream.util,
!javax.xml.transform, !javax.xml.transform.sax,
!javax.xml.transform.stax,
- !javax.xml.ws, !joptsimple, !net.sf.cglib.*, !net.sf.ehcache.*,
+ !javax.xml.ws, !javax.xml.*, !joptsimple, !net.sf.cglib.*, !net.sf.ehcache.*,
!org.antlr.stringtemplate,
!org.apache.avalon.framework.logger,
!org.apache.log, !org.apache.log4j, !org.apache.log4j.xml,
@@ -295,7 +298,7 @@ licensed under the Common Public License
!org.joda.*, !org.jruby.*, !org.omg.CORBA,
!org.springframework.instrument,
!org.w3c.dom, !org.xml.sax, !org.xml.sax.ext, !org.xml.sax.helpers,
- !org.aopalliance.*, !org.springframework.aop.*, !org.slf4j.*
+ !org.aopalliance.*, !org.springframework.aop.*
</Import-Package>
<!-- -->
<Require-Bundle> org.apache.uima.runtime </Require-Bundle>
@@ -317,7 +320,7 @@ licensed under the Common Public License
<Embed-Dependency>*;scope=compile</Embed-Dependency>
<!-- <Embed-Transitive>true</Embed-Transitive> -->
<Bundle-SymbolicName>org.apache.uima.ruta.engine;singleton:=true</Bundle-SymbolicName>
- <Bundle-RequiredExecutionEnvironment>JavaSE-1.7</Bundle-RequiredExecutionEnvironment>
+ <Bundle-RequiredExecutionEnvironment>JavaSE-1.8</Bundle-RequiredExecutionEnvironment>
<Eclipse-ExtensibleAPI>true</Eclipse-ExtensibleAPI>
<!-- <Bundle-ActivationPolicy>lazy</Bundle-ActivationPolicy> -->
<Eclipse-BuddyPolicy>registered</Eclipse-BuddyPolicy>
Modified: uima/uv3/ruta-v3/trunk/ruta-ep-ide-ui/pom.xml
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-ide-ui/pom.xml?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-ide-ui/pom.xml (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-ide-ui/pom.xml Mon Nov 18 12:19:31 2019
@@ -239,6 +239,7 @@
<excludes>
<exclude>release.properties</exclude> <!-- release generated artifact -->
<exclude>marker-file-identifying-*</exclude>
+ <exclude>META-INF/MANIFEST.MF</exclude>
<exclude>src/main/resources/org/apache/uima/ruta/ide/formatter/*.ruta</exclude> <!-- preview file -->
<exclude>src/main/resources/org/apache/uima/ruta/ide/formatter/preferences/*.ruta</exclude> <!-- preview file -->
<exclude>src/main/resources/org/apache/uima/ruta/ide/launching/*.ruta</exclude> <!-- preview file -->
@@ -264,7 +265,7 @@
<instructions>
<Bundle-SymbolicName>org.apache.uima.ruta.ide.ui;singleton:=true</Bundle-SymbolicName>
<Bundle-Activator>org.apache.uima.ruta.ide.RutaIdeUIPlugin</Bundle-Activator>
- <Bundle-RequiredExecutionEnvironment>JavaSE-1.7</Bundle-RequiredExecutionEnvironment>
+ <Bundle-RequiredExecutionEnvironment>JavaSE-1.8</Bundle-RequiredExecutionEnvironment>
<Bundle-ActivationPolicy>lazy</Bundle-ActivationPolicy>
<_nouses>true</_nouses>
<Export-Package>