highlighting for Papyrus added
diff --git a/org.eclipse.emf.refactor.metrics.papyrus/bin/org/eclipse/emf/refactor/metrics/papyrus/PapyrusStartup.class b/org.eclipse.emf.refactor.metrics.papyrus/bin/org/eclipse/emf/refactor/metrics/papyrus/PapyrusStartup.class
new file mode 100644
index 0000000..76e03c5
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.papyrus/bin/org/eclipse/emf/refactor/metrics/papyrus/PapyrusStartup.class
Binary files differ
diff --git a/org.eclipse.emf.refactor.metrics.papyrus/bin/org/eclipse/emf/refactor/metrics/papyrus/managers/HighlightManager.class b/org.eclipse.emf.refactor.metrics.papyrus/bin/org/eclipse/emf/refactor/metrics/papyrus/managers/HighlightManager.class
new file mode 100644
index 0000000..873e73e
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.papyrus/bin/org/eclipse/emf/refactor/metrics/papyrus/managers/HighlightManager.class
Binary files differ
diff --git a/org.eclipse.emf.refactor.metrics.papyrus/bin/org/eclipse/emf/refactor/metrics/papyrus/ui/PapyrusDecorationFigure.class b/org.eclipse.emf.refactor.metrics.papyrus/bin/org/eclipse/emf/refactor/metrics/papyrus/ui/PapyrusDecorationFigure.class
new file mode 100644
index 0000000..64bb262
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.papyrus/bin/org/eclipse/emf/refactor/metrics/papyrus/ui/PapyrusDecorationFigure.class
Binary files differ
diff --git a/org.eclipse.emf.refactor.metrics.papyrus/bin/org/eclipse/emf/refactor/metrics/papyrus/ui/PapyrusDecorator$1.class b/org.eclipse.emf.refactor.metrics.papyrus/bin/org/eclipse/emf/refactor/metrics/papyrus/ui/PapyrusDecorator$1.class
new file mode 100644
index 0000000..5d940f6
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.papyrus/bin/org/eclipse/emf/refactor/metrics/papyrus/ui/PapyrusDecorator$1.class
Binary files differ
diff --git a/org.eclipse.emf.refactor.metrics.papyrus/bin/org/eclipse/emf/refactor/metrics/papyrus/ui/PapyrusDecorator$2.class b/org.eclipse.emf.refactor.metrics.papyrus/bin/org/eclipse/emf/refactor/metrics/papyrus/ui/PapyrusDecorator$2.class
new file mode 100644
index 0000000..e576842
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.papyrus/bin/org/eclipse/emf/refactor/metrics/papyrus/ui/PapyrusDecorator$2.class
Binary files differ
diff --git a/org.eclipse.emf.refactor.metrics.papyrus/bin/org/eclipse/emf/refactor/metrics/papyrus/ui/PapyrusDecorator$Style.class b/org.eclipse.emf.refactor.metrics.papyrus/bin/org/eclipse/emf/refactor/metrics/papyrus/ui/PapyrusDecorator$Style.class
new file mode 100644
index 0000000..ba6c01d
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.papyrus/bin/org/eclipse/emf/refactor/metrics/papyrus/ui/PapyrusDecorator$Style.class
Binary files differ
diff --git a/org.eclipse.emf.refactor.metrics.papyrus/bin/org/eclipse/emf/refactor/metrics/papyrus/ui/PapyrusDecorator.class b/org.eclipse.emf.refactor.metrics.papyrus/bin/org/eclipse/emf/refactor/metrics/papyrus/ui/PapyrusDecorator.class
new file mode 100644
index 0000000..1950dee
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.papyrus/bin/org/eclipse/emf/refactor/metrics/papyrus/ui/PapyrusDecorator.class
Binary files differ
diff --git a/org.eclipse.emf.refactor.metrics.papyrus/bin/org/eclipse/emf/refactor/metrics/papyrus/ui/PapyrusDecoratorProvider.class b/org.eclipse.emf.refactor.metrics.papyrus/bin/org/eclipse/emf/refactor/metrics/papyrus/ui/PapyrusDecoratorProvider.class
new file mode 100644
index 0000000..d9f97ea
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.papyrus/bin/org/eclipse/emf/refactor/metrics/papyrus/ui/PapyrusDecoratorProvider.class
Binary files differ
diff --git a/org.eclipse.emf.refactor.metrics.papyrus/bin/org/eclipse/emf/refactor/metrics/papyrus/ui/PapyrusHighlighting.class b/org.eclipse.emf.refactor.metrics.papyrus/bin/org/eclipse/emf/refactor/metrics/papyrus/ui/PapyrusHighlighting.class
new file mode 100644
index 0000000..b53a28d
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.papyrus/bin/org/eclipse/emf/refactor/metrics/papyrus/ui/PapyrusHighlighting.class
Binary files differ
diff --git a/org.eclipse.emf.refactor.metrics.papyrus/plugin.xml b/org.eclipse.emf.refactor.metrics.papyrus/plugin.xml
index abc72c5..51be4ef 100644
--- a/org.eclipse.emf.refactor.metrics.papyrus/plugin.xml
+++ b/org.eclipse.emf.refactor.metrics.papyrus/plugin.xml
@@ -1,6 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
+
+ <extension
+ point="org.eclipse.ui.startup">
+ <startup
+ class="org.eclipse.emf.refactor.metrics.papyrus.PapyrusStartup">
+ </startup>
+ </extension>
+
<extension
id="org.eclipse.emf.refactor.papyrus.menu"
point="org.eclipse.ui.menus">
@@ -131,4 +139,21 @@
commandId="org.eclipse.emf.refactor.metrics.papyrus.generateNewMetricCompositeCommand">
</handler>
</extension>
+
+ <extension
+ point="org.eclipse.gmf.runtime.diagram.ui.decoratorProviders">
+ <decoratorProvider
+ class="org.eclipse.emf.refactor.metrics.papyrus.ui.PapyrusDecoratorProvider">
+ <Priority
+ name="Lowest">
+ </Priority>
+ <object
+ class="org.eclipse.gmf.runtime.notation.View(org.eclipse.gmf.runtime.notation)"
+ id="NODE">
+ </object>
+ <context
+ decoratorTargets="NODE">
+ </context>
+ </decoratorProvider>
+ </extension>
</plugin>
diff --git a/org.eclipse.emf.refactor.metrics.papyrus/src/org/eclipse/emf/refactor/metrics/papyrus/PapyrusStartup.java b/org.eclipse.emf.refactor.metrics.papyrus/src/org/eclipse/emf/refactor/metrics/papyrus/PapyrusStartup.java
new file mode 100644
index 0000000..ab2b1f4
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.papyrus/src/org/eclipse/emf/refactor/metrics/papyrus/PapyrusStartup.java
@@ -0,0 +1,15 @@
+package org.eclipse.emf.refactor.metrics.papyrus;
+
+import org.eclipse.emf.refactor.metrics.papyrus.ui.PapyrusHighlighting;
+import org.eclipse.emf.refactor.metrics.runtime.managers.RuntimeManager;
+import org.eclipse.ui.IStartup;
+
+public class PapyrusStartup implements IStartup {
+
+ @Override
+ public void earlyStartup() {
+ RuntimeManager.getInstance(new PapyrusHighlighting());
+ System.out.println("Started");
+ }
+
+}
diff --git a/org.eclipse.emf.refactor.metrics.papyrus/src/org/eclipse/emf/refactor/metrics/papyrus/managers/HighlightManager.java b/org.eclipse.emf.refactor.metrics.papyrus/src/org/eclipse/emf/refactor/metrics/papyrus/managers/HighlightManager.java
new file mode 100644
index 0000000..cc43d67
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.papyrus/src/org/eclipse/emf/refactor/metrics/papyrus/managers/HighlightManager.java
@@ -0,0 +1,84 @@
+package org.eclipse.emf.refactor.metrics.papyrus.managers;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.refactor.metrics.runtime.core.Result;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.DecorationEditPolicy.DecoratorTarget;
+import org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecorator;
+import org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecoratorTarget;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+
+
+public class HighlightManager {
+
+ private static HighlightManager instance = null;
+ private List<EObject> selected;
+ private List<IDecorator> decorators = null;
+ private Map<EObject, IDecoratorTarget> decoratorTargets = null;
+
+ private HighlightManager() {
+ selected = new ArrayList<EObject>();
+ decoratorTargets = new HashMap<EObject, IDecoratorTarget>();
+ decorators = new ArrayList<IDecorator>();
+ }
+
+ public static HighlightManager getInstance() {
+ if(instance == null) {
+ instance = new HighlightManager();
+ }
+ return instance;
+ }
+
+ public void highlight(Object selection) {
+ // clear former selected eObjects
+ selected.clear();
+ // set selected eObjects from selection
+ if (selection instanceof Result) {
+ selected.addAll(((Result) selection).getContext());
+ }
+ // refresh each corresponding decorator
+ for (IDecorator decorator : decorators) {
+ decorator.refresh();
+ }
+ }
+
+ public void registerDecorator(IDecorator decorator, DecoratorTarget decoratorTarget) {
+ View view = (View) decoratorTarget.getAdapter(View.class);
+ if(decoratorTargets.containsKey(view.getElement())){
+ View parent = view;
+ boolean topMost = false;
+ if(!(parent instanceof Diagram)){
+ while(!((parent = (View) parent.eContainer()) instanceof Diagram)){
+ if(parent == decoratorTargets.get(view.getElement()).getAdapter(View.class)){
+ topMost = true;
+ }
+ }
+ if(!topMost){
+ decoratorTargets.put(view.getElement(), decoratorTarget);
+ }
+ }
+ } else {
+ decoratorTargets.put(view.getElement(), decoratorTarget);
+ }
+
+ decorators.add(decorator);
+ }
+
+ public void unregisterDecorator(IDecorator decorator) {
+ decorators.remove(decorator);
+ }
+
+ public IDecoratorTarget getPrefferedDecoratorTarget(EObject element) {
+ return decoratorTargets.get(element);
+ }
+
+ public List<EObject> getSelected() {
+ return selected;
+ }
+
+}
diff --git a/org.eclipse.emf.refactor.metrics.papyrus/src/org/eclipse/emf/refactor/metrics/papyrus/ui/PapyrusDecorationFigure.java b/org.eclipse.emf.refactor.metrics.papyrus/src/org/eclipse/emf/refactor/metrics/papyrus/ui/PapyrusDecorationFigure.java
new file mode 100644
index 0000000..99aee93
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.papyrus/src/org/eclipse/emf/refactor/metrics/papyrus/ui/PapyrusDecorationFigure.java
@@ -0,0 +1,25 @@
+package org.eclipse.emf.refactor.metrics.papyrus.ui;
+
+import org.eclipse.draw2d.Figure;
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.ToolbarLayout;
+import org.eclipse.swt.graphics.Color;
+
+public class PapyrusDecorationFigure extends Figure {
+
+ private static final Color NICE_RED = new Color(null, 232, 72, 72);
+
+ public PapyrusDecorationFigure(){
+ setLayoutManager(new ToolbarLayout());
+ setOpaque(false);
+ }
+
+ @Override
+ public void paint(Graphics graphics) {
+ graphics.setForegroundColor(NICE_RED);
+ graphics.setLineWidth(4);
+ graphics.drawRectangle(getClientArea());
+ super.paint(graphics);
+ }
+
+}
diff --git a/org.eclipse.emf.refactor.metrics.papyrus/src/org/eclipse/emf/refactor/metrics/papyrus/ui/PapyrusDecorator.java b/org.eclipse.emf.refactor.metrics.papyrus/src/org/eclipse/emf/refactor/metrics/papyrus/ui/PapyrusDecorator.java
new file mode 100644
index 0000000..0735eb9
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.papyrus/src/org/eclipse/emf/refactor/metrics/papyrus/ui/PapyrusDecorator.java
@@ -0,0 +1,155 @@
+package org.eclipse.emf.refactor.metrics.papyrus.ui;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.FigureCanvas;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.LayoutListener;
+import org.eclipse.draw2d.PolylineConnection;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.refactor.metrics.papyrus.managers.HighlightManager;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBroker;
+import org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.services.decorator.AbstractDecorator;
+import org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecoratorTarget;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.swt.graphics.Color;
+//import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+
+public class PapyrusDecorator extends AbstractDecorator {
+
+ private HighlightManager manager = HighlightManager.getInstance();
+
+ private Map<PolylineConnection, Style> decoratedLines = null;
+
+ private LayoutListener layoutListener = new LayoutListener() {
+ @Override
+ public void setConstraint(IFigure child, Object constraint) {}
+
+ @Override
+ public void remove(IFigure child) {}
+
+ @Override
+ public void postLayout(IFigure container) {
+ refresh();
+ }
+
+ @Override
+ public boolean layout(IFigure container) { return false; }
+
+ @Override
+ public void invalidate(IFigure container) {}};
+
+ private NotificationListener notificationListener = new NotificationListener() {
+ public void notifyChanged(Notification notification) {
+ refresh();
+ }};
+
+
+ public PapyrusDecorator(IDecoratorTarget decoratorTarget) {
+ super(decoratorTarget);
+ decoratedLines = new HashMap<PolylineConnection, Style>();
+ }
+
+ @Override
+ public void activate() {
+ IGraphicalEditPart gep = (IGraphicalEditPart) getDecoratorTarget().getAdapter(IGraphicalEditPart.class);
+ assert gep != null;
+ DiagramEventBroker.getInstance(gep.getEditingDomain()).addNotificationListener(gep.getNotationView(),
+ NotationPackage.eINSTANCE.getDescriptionStyle_Description(), notificationListener);
+
+ GraphicalEditPart editPart = (GraphicalEditPart) getDecoratorTarget().getAdapter(GraphicalEditPart.class);
+ editPart.getFigure().addLayoutListener(layoutListener);
+
+ manager.registerDecorator(this, getDecoratorTarget());
+ }
+
+ @Override
+ public void deactivate() {
+ removeDecoration();
+
+ IGraphicalEditPart gep = (IGraphicalEditPart) getDecoratorTarget().getAdapter(IGraphicalEditPart.class);
+ assert gep != null;
+ DiagramEventBroker.getInstance(gep.getEditingDomain()).removeNotificationListener(gep.getNotationView(),
+ NotationPackage.eINSTANCE.getDescriptionStyle_Description(), notificationListener);
+
+ GraphicalEditPart editPart = (GraphicalEditPart) getDecoratorTarget().getAdapter(GraphicalEditPart.class);
+ editPart.getFigure().removeLayoutListener(layoutListener);
+
+ manager.unregisterDecorator(this);
+ }
+
+ @Override
+ protected void removeDecoration() {
+ super.removeDecoration();
+ for (PolylineConnection connection : decoratedLines.keySet()){
+ connection.setForegroundColor(decoratedLines.get(connection).color);
+ connection.setLineWidth(decoratedLines.get(connection).lineWidth);
+ }
+ }
+
+ @Override
+ public void refresh() {
+ System.out.println("Start REFRESH");
+ removeDecoration();
+ IGraphicalEditPart editPart = (IGraphicalEditPart) getDecoratorTarget().getAdapter(EditPart.class);
+
+ View view = (View) getDecoratorTarget().getAdapter(View.class);
+
+ if (manager.getPrefferedDecoratorTarget(view.getElement()) == getDecoratorTarget()){
+ if(selectionContains(view.getElement())) {
+ int x = editPart.getFigure().getBounds().x;
+ int y = editPart.getFigure().getBounds().y;
+ FigureCanvas canvas = (FigureCanvas) editPart.getViewer().getControl();
+ canvas.scrollSmoothTo(x, y);
+ if (view instanceof Node) {
+ IFigure figure = editPart.getFigure();
+ IFigure decoration = new PapyrusDecorationFigure();
+ decoration.setSize(figure.getSize());
+ setDecoration(getDecoratorTarget().addShapeDecoration(decoration, IDecoratorTarget.Direction.CENTER, 0, false));
+ }
+ if (view instanceof Edge) {
+ PolylineConnection connection = (PolylineConnection) editPart.getFigure();
+ decoratedLines.put(connection, new Style(connection.getForegroundColor(), connection.getLineWidth()));
+ connection.setForegroundColor(ColorConstants.red);
+ connection.setLineWidth(2);
+ }
+ }
+ }
+ System.out.println("End REFRESH");
+ }
+
+ private boolean selectionContains(EObject element){
+ boolean contained = false;
+ if (element != null) {
+ for(EObject selected : manager.getSelected()){
+ String fragmentA = EcoreUtil.getURI(selected).fragment();
+ String fragmentB = EcoreUtil.getURI(element).fragment();
+ contained |= fragmentA.equals(fragmentB);
+ }
+ }
+ return contained;
+ }
+
+ private static class Style {
+
+ public Color color = null;
+ public int lineWidth = 0;
+
+ public Style(Color c, int lw){
+ color = c;
+ lineWidth = lw;
+ }
+ }
+
+}
diff --git a/org.eclipse.emf.refactor.metrics.papyrus/src/org/eclipse/emf/refactor/metrics/papyrus/ui/PapyrusDecoratorProvider.java b/org.eclipse.emf.refactor.metrics.papyrus/src/org/eclipse/emf/refactor/metrics/papyrus/ui/PapyrusDecoratorProvider.java
new file mode 100644
index 0000000..3948899
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.papyrus/src/org/eclipse/emf/refactor/metrics/papyrus/ui/PapyrusDecoratorProvider.java
@@ -0,0 +1,23 @@
+package org.eclipse.emf.refactor.metrics.papyrus.ui;
+
+import org.eclipse.gmf.runtime.common.core.service.AbstractProvider;
+import org.eclipse.gmf.runtime.common.core.service.IOperation;
+import org.eclipse.gmf.runtime.diagram.ui.services.decorator.CreateDecoratorsOperation;
+import org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecoratorProvider;
+import org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecoratorTarget;
+
+public class PapyrusDecoratorProvider extends AbstractProvider implements IDecoratorProvider {
+
+ public static final String PAPYRUS_DECORATOR_KEY = "papyrus_decorator";
+
+ @Override
+ public boolean provides(IOperation operation) {
+ return (operation instanceof CreateDecoratorsOperation);
+ }
+
+ @Override
+ public void createDecorators(IDecoratorTarget decoratorTarget) {
+ decoratorTarget.installDecorator(PAPYRUS_DECORATOR_KEY, new PapyrusDecorator(decoratorTarget));
+ }
+
+}
diff --git a/org.eclipse.emf.refactor.metrics.papyrus/src/org/eclipse/emf/refactor/metrics/papyrus/ui/PapyrusHighlighting.java b/org.eclipse.emf.refactor.metrics.papyrus/src/org/eclipse/emf/refactor/metrics/papyrus/ui/PapyrusHighlighting.java
new file mode 100644
index 0000000..9902901
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.papyrus/src/org/eclipse/emf/refactor/metrics/papyrus/ui/PapyrusHighlighting.java
@@ -0,0 +1,13 @@
+package org.eclipse.emf.refactor.metrics.papyrus.ui;
+
+import org.eclipse.emf.refactor.metrics.interfaces.IHighlighting;
+import org.eclipse.emf.refactor.metrics.papyrus.managers.HighlightManager;
+
+public class PapyrusHighlighting implements IHighlighting {
+
+ @Override
+ public void highlight(Object selection) {
+ HighlightManager.getInstance().highlight(selection);
+ }
+
+}
diff --git a/org.eclipse.emf.refactor.metrics.runtime/META-INF/MANIFEST.MF b/org.eclipse.emf.refactor.metrics.runtime/META-INF/MANIFEST.MF
index 2350767..960e67c 100644
--- a/org.eclipse.emf.refactor.metrics.runtime/META-INF/MANIFEST.MF
+++ b/org.eclipse.emf.refactor.metrics.runtime/META-INF/MANIFEST.MF
@@ -16,3 +16,4 @@
Export-Package: org.eclipse.emf.refactor.metrics.runtime.core,
org.eclipse.emf.refactor.metrics.runtime.managers,
org.eclipse.emf.refactor.metrics.runtime.ui
+Import-Package: org.eclipse.emf.common.ui.viewer
diff --git a/org.eclipse.emf.refactor.metrics.runtime/bin/org/eclipse/emf/refactor/metrics/runtime/managers/RuntimeManager.class b/org.eclipse.emf.refactor.metrics.runtime/bin/org/eclipse/emf/refactor/metrics/runtime/managers/RuntimeManager.class
index 25a2a31..f70d75a 100644
--- a/org.eclipse.emf.refactor.metrics.runtime/bin/org/eclipse/emf/refactor/metrics/runtime/managers/RuntimeManager.class
+++ b/org.eclipse.emf.refactor.metrics.runtime/bin/org/eclipse/emf/refactor/metrics/runtime/managers/RuntimeManager.class
Binary files differ
diff --git a/org.eclipse.emf.refactor.metrics.runtime/bin/org/eclipse/emf/refactor/metrics/runtime/ui/MetricResultsView$1.class b/org.eclipse.emf.refactor.metrics.runtime/bin/org/eclipse/emf/refactor/metrics/runtime/ui/MetricResultsView$1.class
new file mode 100644
index 0000000..1c61f19
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.runtime/bin/org/eclipse/emf/refactor/metrics/runtime/ui/MetricResultsView$1.class
Binary files differ
diff --git a/org.eclipse.emf.refactor.metrics.runtime/bin/org/eclipse/emf/refactor/metrics/runtime/ui/MetricResultsView$ColumnSortListener.class b/org.eclipse.emf.refactor.metrics.runtime/bin/org/eclipse/emf/refactor/metrics/runtime/ui/MetricResultsView$ColumnSortListener.class
index 9a0becd..f5e9a6c 100644
--- a/org.eclipse.emf.refactor.metrics.runtime/bin/org/eclipse/emf/refactor/metrics/runtime/ui/MetricResultsView$ColumnSortListener.class
+++ b/org.eclipse.emf.refactor.metrics.runtime/bin/org/eclipse/emf/refactor/metrics/runtime/ui/MetricResultsView$ColumnSortListener.class
Binary files differ
diff --git a/org.eclipse.emf.refactor.metrics.runtime/bin/org/eclipse/emf/refactor/metrics/runtime/ui/MetricResultsView.class b/org.eclipse.emf.refactor.metrics.runtime/bin/org/eclipse/emf/refactor/metrics/runtime/ui/MetricResultsView.class
index f067fad..6950876 100644
--- a/org.eclipse.emf.refactor.metrics.runtime/bin/org/eclipse/emf/refactor/metrics/runtime/ui/MetricResultsView.class
+++ b/org.eclipse.emf.refactor.metrics.runtime/bin/org/eclipse/emf/refactor/metrics/runtime/ui/MetricResultsView.class
Binary files differ
diff --git a/org.eclipse.emf.refactor.metrics.runtime/bin/org/eclipse/emf/refactor/metrics/runtime/ui/MetricResultsViewLabelProvider.class b/org.eclipse.emf.refactor.metrics.runtime/bin/org/eclipse/emf/refactor/metrics/runtime/ui/MetricResultsViewLabelProvider.class
index 80c48d4..f17da95 100644
--- a/org.eclipse.emf.refactor.metrics.runtime/bin/org/eclipse/emf/refactor/metrics/runtime/ui/MetricResultsViewLabelProvider.class
+++ b/org.eclipse.emf.refactor.metrics.runtime/bin/org/eclipse/emf/refactor/metrics/runtime/ui/MetricResultsViewLabelProvider.class
Binary files differ
diff --git a/org.eclipse.emf.refactor.metrics.runtime/src/org/eclipse/emf/refactor/metrics/runtime/managers/RuntimeManager.java b/org.eclipse.emf.refactor.metrics.runtime/src/org/eclipse/emf/refactor/metrics/runtime/managers/RuntimeManager.java
index cd10803..6f9ef96 100644
--- a/org.eclipse.emf.refactor.metrics.runtime/src/org/eclipse/emf/refactor/metrics/runtime/managers/RuntimeManager.java
+++ b/org.eclipse.emf.refactor.metrics.runtime/src/org/eclipse/emf/refactor/metrics/runtime/managers/RuntimeManager.java
@@ -4,20 +4,21 @@
import java.util.LinkedList;
import java.util.List;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
import org.eclipse.core.resources.IProject;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.refactor.metrics.configuration.core.Configuration;
import org.eclipse.emf.refactor.metrics.configuration.managers.ConfigurationManager;
+import org.eclipse.emf.refactor.metrics.interfaces.IHighlighting;
import org.eclipse.emf.refactor.metrics.runtime.core.MetricCalculator;
import org.eclipse.emf.refactor.metrics.runtime.core.Result;
import org.eclipse.emf.refactor.metrics.runtime.ui.MetricResultsView;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
public class RuntimeManager {
@@ -25,6 +26,7 @@
private static LinkedList<Result> resultsViewInput;
private static TableViewer resultsViewer = null;
private static List<Action> additionalActions = new ArrayList<Action>();
+ private static List<IHighlighting> additionalHighlightings = new ArrayList<IHighlighting>();
private static RuntimeManager instance;
@@ -51,6 +53,16 @@
return instance;
}
+ public static RuntimeManager getInstance(IHighlighting highlighting) {
+ if (instance == null) {
+ instance = new RuntimeManager();
+ additionalHighlightings.add(highlighting);
+ } else {
+ additionalHighlightings.add(highlighting);
+ }
+ return instance;
+ }
+
public static void setResultsViewer(TableViewer viewer){
resultsViewer = viewer;
}
@@ -115,6 +127,7 @@
try{
page.showView(MetricResultsView.ID);
setAdditionalActionsToView(getMetricsView());
+ setAdditionalHightightingsToView(getMetricsView());
} catch (PartInitException e) {
e.printStackTrace();
}
@@ -136,6 +149,7 @@
MetricResultsView view = getMetricsView();
if (view != null) {
setAdditionalActionsToView(view);
+ setAdditionalHightightingsToView(getMetricsView());
return true;
}
return false;
@@ -148,4 +162,11 @@
}
view.addActionsToMenu();
}
+
+ private static void setAdditionalHightightingsToView(MetricResultsView view) {
+ for (IHighlighting highlighting : additionalHighlightings) {
+ System.out.println("RuntimeManager: add highlighting '" + highlighting + "' to view!");
+ view.addHighlighting(highlighting);
+ }
+ }
}
diff --git a/org.eclipse.emf.refactor.metrics.runtime/src/org/eclipse/emf/refactor/metrics/runtime/ui/MetricResultsView.java b/org.eclipse.emf.refactor.metrics.runtime/src/org/eclipse/emf/refactor/metrics/runtime/ui/MetricResultsView.java
index 307bca0..cc4a6bb 100644
--- a/org.eclipse.emf.refactor.metrics.runtime/src/org/eclipse/emf/refactor/metrics/runtime/ui/MetricResultsView.java
+++ b/org.eclipse.emf.refactor.metrics.runtime/src/org/eclipse/emf/refactor/metrics/runtime/ui/MetricResultsView.java
@@ -3,6 +3,13 @@
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.emf.common.ui.viewer.IViewerProvider;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.refactor.metrics.interfaces.IHighlighting;
+import org.eclipse.emf.refactor.metrics.runtime.core.Result;
import org.eclipse.emf.refactor.metrics.runtime.managers.RuntimeManager;
import org.eclipse.emf.refactor.metrics.runtime.ui.actions.ClearAction;
import org.eclipse.emf.refactor.metrics.runtime.ui.actions.SaveAction;
@@ -10,14 +17,24 @@
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.ViewPart;
@@ -45,6 +62,7 @@
private SaveAction saveAction;
private Action clearAction;
private List<Action> additionalActions = new ArrayList<Action>();
+ private List<IHighlighting> additionalHighlightings = new ArrayList<IHighlighting>();
public MetricResultsView() { }
@@ -66,31 +84,84 @@
| SWT.V_SCROLL);
final Table table = viewer.getTable();
RuntimeManager.setResultsViewer(viewer);
- column = new TableColumn(table, SWT.LEFT);
- column.setText(TIME_COLUMN_LABEL);
- column.setWidth(150);
- column.addListener(SWT.Selection, new ColumnSortListener(column));
+
column = new TableColumn(table, SWT.LEFT);
column.setText(CONTEXT_COLUMN_LABEL);
column.setWidth(200);
column.addListener(SWT.Selection, new ColumnSortListener(column));
+
column = new TableColumn(table, SWT.LEFT);
column.setText(METRIC_COLUMN_LABEL);
- column.setWidth(200);
+ column.setWidth(120);
column.addListener(SWT.Selection, new ColumnSortListener(column));
+
column = new TableColumn(table, SWT.LEFT);
column.setText(DESCRIPTION_COLUMN_LABEL);
- column.setWidth(300);
+ column.setWidth(360);
column.addListener(SWT.Selection, new ColumnSortListener(column));
+
column = new TableColumn(table, SWT.LEFT);
column.setText(RESULT_COLUMN_LABEL);
- column.setWidth(50);
+ column.setWidth(70);
column.addListener(SWT.Selection, new ColumnSortListener(column));
+
+ column = new TableColumn(table, SWT.LEFT);
+ column.setText(TIME_COLUMN_LABEL);
+ column.setWidth(150);
+ column.addListener(SWT.Selection, new ColumnSortListener(column));
+
table.setHeaderVisible(true);
table.setLinesVisible(true);
+
viewer.setContentProvider(new MetricResultsViewContentProvider());
viewer.setLabelProvider(new MetricResultsViewLabelProvider());
viewer.setInput(RuntimeManager.getResultsViewInput());
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ if(event.getSelection().isEmpty()) {
+ return;
+ }
+ IWorkbenchWindow workbenchWindow= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ IEditorPart editorPart = workbenchWindow.getActivePage().getActiveEditor();
+ if (event.getSelection() instanceof IStructuredSelection) {
+ StructuredSelection ss = (StructuredSelection) event.getSelection();
+ Object selection = ss.getFirstElement();
+ doAdditionalHighlightings(selection);
+ }
+ System.out.println("editorPart: " + editorPart);
+ System.out.println("editorPart.class: " + editorPart.getClass());
+ if(editorPart != null && editorPart instanceof IViewerProvider) {
+ setSelectionInModel((IViewerProvider)editorPart, (IStructuredSelection)event.getSelection());
+ }
+ }
+
+ private void setSelectionInModel(IViewerProvider provider, IStructuredSelection selection){
+ ArrayList<EObject> eObjectList = new ArrayList<EObject>();
+ for(Object selectedObject : selection.toList()){
+ if(selectedObject instanceof Result){
+ for(EObject currentEObject : ((Result) selectedObject).getContext()) {
+ EObject modelInstanceObject = getModelObjectInstance(provider, currentEObject);
+ eObjectList.add(modelInstanceObject);
+ }
+ }
+ }
+ provider.getViewer().setSelection(new StructuredSelection(eObjectList));
+ }
+
+ private EObject getModelObjectInstance(IViewerProvider provider, EObject eObject) {
+ Viewer viewer = provider.getViewer();
+ TreeViewer treeViewer = (TreeViewer)viewer;
+ Tree tree = treeViewer.getTree();
+ TreeItem treeItem = tree.getItem(0);
+ Resource o = (Resource)treeItem.getData();
+ ResourceSet set = o.getResourceSet();
+ EObject ob = set.getEObject(EcoreUtil.getURI(eObject), true);
+ return ob;
+ }
+
+ });
PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(),"EMFMetrics.viewer");
makeActions();
// hookContextMenu();
@@ -184,4 +255,14 @@
}
}
+ public void addHighlighting(IHighlighting highlighting) {
+ additionalHighlightings.add(highlighting);
+ }
+
+ protected void doAdditionalHighlightings(Object selection) {
+ for (IHighlighting highlighting : additionalHighlightings) {
+ highlighting.highlight(selection);
+ }
+ }
+
}
diff --git a/org.eclipse.emf.refactor.metrics.runtime/src/org/eclipse/emf/refactor/metrics/runtime/ui/MetricResultsViewLabelProvider.java b/org.eclipse.emf.refactor.metrics.runtime/src/org/eclipse/emf/refactor/metrics/runtime/ui/MetricResultsViewLabelProvider.java
index 896a085..8ffaa9e 100644
--- a/org.eclipse.emf.refactor.metrics.runtime/src/org/eclipse/emf/refactor/metrics/runtime/ui/MetricResultsViewLabelProvider.java
+++ b/org.eclipse.emf.refactor.metrics.runtime/src/org/eclipse/emf/refactor/metrics/runtime/ui/MetricResultsViewLabelProvider.java
@@ -18,9 +18,9 @@
public String getColumnText(Object obj, int index) {
switch(index){
- case 0:
+ case 4:
return ((Result)obj).getTimeStamp();
- case 1:
+ case 0:
EObject contextElement = ((Result)obj).getContext().get(0);
String name = getEObjectLabel(contextElement);
String contextString = ((Result)obj).getMetric().getContext();
@@ -30,11 +30,11 @@
return s[s.length -1] + " " + name;
else
return name;
- case 2:
+ case 1:
return ((Result)obj).getMetric().getName();
- case 3:
+ case 2:
return ((Result)obj).getMetric().getDescription();
- case 4:
+ case 3:
Double value = ((Result)obj).getResultValue();
if (value.isNaN()) return "NaN";
BigDecimal myDec = new BigDecimal(value);