Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClaudia Knobloch2011-06-07 11:50:22 +0000
committerClaudia Knobloch2011-06-07 11:50:22 +0000
commit8405c59555b75fa9dbafc2340bc20c6e145cc5b4 (patch)
tree39d7ded01ad27d2fc5d87d985a16b21eefa8f3a0
parent73454f7f008d468d75fcf059f7cf9852428e845d (diff)
downloadorg.eclipse.ptp-8405c59555b75fa9dbafc2340bc20c6e145cc5b4.tar.gz
org.eclipse.ptp-8405c59555b75fa9dbafc2340bc20c6e145cc5b4.tar.xz
org.eclipse.ptp-8405c59555b75fa9dbafc2340bc20c6e145cc5b4.zip
Extension Nodedisplay
-rw-r--r--rms/org.eclipse.ptp.rm.lml.core/src/org/eclipse/ptp/rm/lml/core/events/INodedisplayZoomEvent.java18
-rw-r--r--rms/org.eclipse.ptp.rm.lml.core/src/org/eclipse/ptp/rm/lml/core/listeners/INodedisplayZoomListener.java21
-rw-r--r--rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/providers/BorderLayout.java354
-rw-r--r--rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/providers/INodedisplayView.java99
-rw-r--r--rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/providers/NodedisplayComp.java694
-rw-r--r--rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/providers/NodedisplayView.java379
-rw-r--r--rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/providers/NodedisplayViewAddition.java91
-rw-r--r--rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/providers/NodedisplayViewZoomable.java111
-rw-r--r--rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/providers/NodedisplayZoomEvent.java30
-rw-r--r--rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/providers/RectPaintListener.java343
-rw-r--r--rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/views/NodedisplayView.java318
-rw-r--r--rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/views/NodesView.java17
12 files changed, 1514 insertions, 961 deletions
diff --git a/rms/org.eclipse.ptp.rm.lml.core/src/org/eclipse/ptp/rm/lml/core/events/INodedisplayZoomEvent.java b/rms/org.eclipse.ptp.rm.lml.core/src/org/eclipse/ptp/rm/lml/core/events/INodedisplayZoomEvent.java
new file mode 100644
index 000000000..014b3fbf2
--- /dev/null
+++ b/rms/org.eclipse.ptp.rm.lml.core/src/org/eclipse/ptp/rm/lml/core/events/INodedisplayZoomEvent.java
@@ -0,0 +1,18 @@
+package org.eclipse.ptp.rm.lml.core.events;
+
+/**
+ * This is event is created for events of switching
+ * root-nodes in nodedisplays. If a more detailed view
+ * of one child-node is shown by zooming into the
+ * shown nodedisplay, this event is created. It provides
+ * information about the new node, which becomes root-
+ * node now.
+ */
+public interface INodedisplayZoomEvent {
+
+ /**
+ * @return name of the new root-node, which is shown now
+ */
+ public String getNewNodeName();
+
+}
diff --git a/rms/org.eclipse.ptp.rm.lml.core/src/org/eclipse/ptp/rm/lml/core/listeners/INodedisplayZoomListener.java b/rms/org.eclipse.ptp.rm.lml.core/src/org/eclipse/ptp/rm/lml/core/listeners/INodedisplayZoomListener.java
new file mode 100644
index 000000000..b85c63e7a
--- /dev/null
+++ b/rms/org.eclipse.ptp.rm.lml.core/src/org/eclipse/ptp/rm/lml/core/listeners/INodedisplayZoomListener.java
@@ -0,0 +1,21 @@
+package org.eclipse.ptp.rm.lml.core.listeners;
+
+import org.eclipse.ptp.rm.lml.core.events.INodedisplayZoomEvent;
+
+/**
+ * Listens for zooming events in nodedisplays.
+ * If a specific sub-child in a nodedisplay is
+ * set as root-element the handleEvent-function
+ * is called.
+ */
+public interface INodedisplayZoomListener {
+
+ /**
+ * This function is called for every zoom-event.
+ *
+ * @param event
+ * event containing information of the zoomed node
+ */
+ public void handleEvent(INodedisplayZoomEvent event);
+
+}
diff --git a/rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/providers/BorderLayout.java b/rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/providers/BorderLayout.java
index b3ed785a8..fd452c821 100644
--- a/rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/providers/BorderLayout.java
+++ b/rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/providers/BorderLayout.java
@@ -7,165 +7,199 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Layout;
-class BorderLayout extends Layout {
- public static final int NWFIELD = 0;
- public static final int NFIELD = 1;
- public static final int NEFIELD = 2;
- public static final int WFIELD = 3;
- public static final int MFIELD = 4;
- public static final int EFIELD = 5;
- public static final int SWFIELD = 6;
- public static final int SFIELD = 7;
- public static final int SEFIELD = 8;
-
- public static class BorderData {
- public int field;
-
- public BorderData() {
- this.field = MFIELD;
- }
-
- public BorderData(int field) {
- this.field = field;
- }
- }
-
- Point[] points;
- Control[] controls;
-
-
- int width;
- int height;
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.swt.widgets.Layout#computeSize(org.eclipse.swt.widgets.Composite,
- * int, int, boolean)
- */
- protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) {
- if (flushCache || points == null) {
- getControlsAndPoints(composite.getChildren(), flushCache);
- }
-
- width = max(
- points[NWFIELD].x + points[NFIELD].x + points[NEFIELD].x,
- points[WFIELD].x + points[MFIELD].x + points[EFIELD].x,
- points[SWFIELD].x + points[SFIELD].x + points[SEFIELD].x);
- height = max(
- points[NWFIELD].y + points[NFIELD].y + points[NEFIELD].y,
- points[WFIELD].y + points[MFIELD].y + points[EFIELD].y,
- points[SWFIELD].y + points[SFIELD].y + points[SEFIELD].y);
-
- return new Point(wHint == SWT.DEFAULT ? width : wHint, hHint == SWT.DEFAULT ? height : hHint);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.swt.widgets.Layout#layout(org.eclipse.swt.widgets.Composite,
- * boolean)
- */
- protected void layout(Composite composite, boolean flushCache) {
- if (flushCache || points == null) {
- getControlsAndPoints(composite.getChildren(), flushCache);
- }
- Rectangle clientArea = composite.getClientArea();
-
- if (controls[NWFIELD] != null) {
- controls[NWFIELD].setBounds(
- clientArea.x,
- clientArea.y,
- points[WFIELD].x,
- points[NFIELD].y);
- }
- if (controls[NFIELD] != null) {
- controls[NFIELD].setBounds(
- clientArea.x + points[WFIELD].x,
- clientArea.y,
- clientArea.width - points[WFIELD].x - points[EFIELD].x,
- points[NFIELD].y);
- }
- if (controls[NEFIELD] != null) {
- controls[NEFIELD].setBounds(
- clientArea.x + clientArea.width - points[EFIELD].x,
- clientArea.y,
- points[EFIELD].x,
- points[NFIELD].y);
- }
- if (controls[WFIELD] != null) {
- controls[WFIELD].setBounds(
- clientArea.x,
- clientArea.y + points[NFIELD].y,
- points[WFIELD].x,
- clientArea.height - points[NFIELD].y - points[SFIELD].y);
- }
- if (controls[MFIELD] != null) {
- controls[MFIELD].setBounds(
- clientArea.x + points[WFIELD].x,
- clientArea.y + points[NFIELD].y,
- clientArea.width - points[WFIELD].x - points[EFIELD].x,
- clientArea.height - points[NFIELD].y - points[SFIELD].y);
- }
- if (controls[EFIELD] != null) {
- controls[EFIELD].setBounds(
- clientArea.x + clientArea.width - points[EFIELD].x,
- clientArea.y + points[NFIELD].y,
- points[EFIELD].x,
- clientArea.height - points[NFIELD].y - points[SFIELD].y);
- }
- if (controls[SWFIELD] != null) {
- controls[SWFIELD].setBounds(
- clientArea.x,
- clientArea.y + clientArea.height - points[NFIELD].y,
- points[WFIELD].x,
- points[SFIELD].y);
- }
- if (controls[SFIELD] != null) {
- controls[SFIELD].setBounds(
- clientArea.x + points[WFIELD].x,
- clientArea.y + clientArea.height - points[SFIELD].y,
- clientArea.width - points[WFIELD].x - points[EFIELD].x,
- points[SFIELD].y);
- }
- if (controls[SEFIELD] != null) {
- controls[SEFIELD].setBounds(
- clientArea.x + clientArea.width - points[EFIELD].x,
- clientArea.y + clientArea.height - points[SFIELD].y,
- points[EFIELD].x,
- points[SFIELD].y);
- }
-
-
- }
-
- private int max(int i1, int i2, int i3) {
- int j = i1 >= i2 ? i1 : i2;
- return j >= i3 ? j : i3;
- }
-
- private void getControlsAndPoints(Control[] children, boolean flushCache) {
- controls = new Control[9];
- points = new Point[9];
- for (int i = 0; i < children.length; i++) {
-
- Object layoutData = children[i].getLayoutData();
- if (!(layoutData instanceof BorderData)) {
- continue;
- }
- BorderData borderData = (BorderData) layoutData;
- if (borderData != null || (borderData.field < 0 || borderData.field > 8)) {
- controls[borderData.field] = children[i];
- points[borderData.field] = children[i].computeSize(SWT.DEFAULT, SWT.DEFAULT, flushCache);
- }
- }
-
- for (int i = 0; i < controls.length; i++) {
- Control control = controls[i];
- if (control == null) {
- points[i] = new Point(0, 0);
- }
- }
- }
+public class BorderLayout extends Layout {
+ public static class BorderData {
+ public int field;
-}
+ public BorderData() {
+ this.field = MFIELD;
+ }
+
+ public BorderData(int field) {
+ this.field = field;
+ }
+ }
+
+ public static final int NWFIELD = 0;
+ public static final int NFIELD = 1;
+ public static final int NEFIELD = 2;
+ public static final int WFIELD = 3;
+ public static final int MFIELD = 4;
+ public static final int EFIELD = 5;
+ public static final int SWFIELD = 6;
+ public static final int SFIELD = 7;
+
+ public static final int SEFIELD = 8;
+
+ Point[] points;
+ Control[] controls;
+
+ int width;
+ int height;
+ // Maximum width and height of every column and row of this composite
+ private int westmax, centerwidthmax, eastmax, northmax, centerheightmax, southmax;
+
+ /**
+ * Compute the preferred size of this composite excluding
+ * the center-field.
+ *
+ * @param composite
+ * @return width and height in a Point-instance
+ */
+ public Point computeSizeWithoutCenter(Composite composite) {
+ getControlsAndPoints(composite.getChildren(), true);
+
+ width = westmax + eastmax;
+ height = northmax + southmax;
+
+ return new Point(width, height);
+ }
+
+ /**
+ * Sets private attributes westmax, centermax1 ...
+ * Computes maximum widths and heights in every row and column.
+ */
+ private void computeMaxima() {
+
+ westmax = max(points[NWFIELD].x, points[WFIELD].x, points[SWFIELD].x);
+ centerwidthmax = max(points[NFIELD].x, points[MFIELD].x, points[SFIELD].x);
+ eastmax = max(points[NEFIELD].x, points[EFIELD].x, points[SEFIELD].x);
+
+ northmax = max(points[NWFIELD].y, points[NFIELD].y, points[NEFIELD].y);
+ centerheightmax = max(points[WFIELD].y, points[MFIELD].y, points[EFIELD].y);
+ southmax = max(points[SWFIELD].y, points[SFIELD].y, points[SEFIELD].y);
+ }
+
+ private void getControlsAndPoints(Control[] children, boolean flushCache) {
+ controls = new Control[9];
+ points = new Point[9];
+ for (final Control element : children) {
+ final Object layoutData = element.getLayoutData();
+ if (!(layoutData instanceof BorderData)) {
+ continue;
+ }
+ final BorderData borderData = (BorderData) layoutData;
+ if (borderData != null && (borderData.field >= 0 && borderData.field <= 8)) {
+ controls[borderData.field] = element;
+ points[borderData.field] = element.computeSize(SWT.DEFAULT, SWT.DEFAULT, flushCache);
+ }
+ }
+
+ for (int i = 0; i < controls.length; i++) {
+ final Control control = controls[i];
+ if (control == null) {
+ points[i] = new Point(0, 0);
+ }
+ }
+
+ computeMaxima();
+ }
+
+ private int max(int i1, int i2, int i3) {
+ final int j = i1 >= i2 ? i1 : i2;
+ return j >= i3 ? j : i3;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.swt.widgets.Layout#computeSize(org.eclipse.swt.widgets.Composite,
+ * int, int, boolean)
+ */
+ @Override
+ protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) {
+ if (flushCache || points == null) {
+ getControlsAndPoints(composite.getChildren(), flushCache);
+ }
+
+ width = westmax + centerwidthmax + eastmax;
+ height = northmax + centerheightmax + southmax;
+
+ return new Point(wHint == SWT.DEFAULT ? width : wHint, hHint == SWT.DEFAULT ? height : hHint);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.swt.widgets.Layout#layout(org.eclipse.swt.widgets.Composite,
+ * boolean)
+ */
+ @Override
+ protected void layout(Composite composite, boolean flushCache) {
+ if (flushCache || points == null) {
+ getControlsAndPoints(composite.getChildren(), flushCache);
+ }
+ final Rectangle clientArea = composite.getClientArea();
+
+ // Put the rest of space to the center-field
+ centerwidthmax = clientArea.width - westmax - eastmax;
+ centerheightmax = clientArea.height - northmax - southmax;
+
+ if (controls[NWFIELD] != null) {
+ controls[NWFIELD].setBounds(
+ clientArea.x,
+ clientArea.y,
+ westmax,
+ northmax);
+ }
+ if (controls[NFIELD] != null) {
+ controls[NFIELD].setBounds(
+ clientArea.x + westmax,
+ clientArea.y,
+ centerwidthmax,
+ northmax);
+ }
+ if (controls[NEFIELD] != null) {
+ controls[NEFIELD].setBounds(
+ clientArea.x + westmax + centerwidthmax,
+ clientArea.y,
+ eastmax,
+ northmax);
+ }
+ if (controls[WFIELD] != null) {
+ controls[WFIELD].setBounds(
+ clientArea.x,
+ clientArea.y + northmax,
+ westmax,
+ centerheightmax);
+ }
+ if (controls[MFIELD] != null) {
+ controls[MFIELD].setBounds(
+ clientArea.x + westmax,
+ clientArea.y + northmax,
+ centerwidthmax,
+ centerheightmax);
+ }
+ if (controls[EFIELD] != null) {
+ controls[EFIELD].setBounds(
+ clientArea.x + westmax + centerwidthmax,
+ clientArea.y + northmax,
+ eastmax,
+ centerheightmax);
+ }
+ if (controls[SWFIELD] != null) {
+ controls[SWFIELD].setBounds(
+ clientArea.x,
+ clientArea.y + northmax + centerheightmax,
+ westmax,
+ southmax);
+ }
+ if (controls[SFIELD] != null) {
+ controls[SFIELD].setBounds(
+ clientArea.x + westmax,
+ clientArea.y + northmax + centerheightmax,
+ centerwidthmax,
+ southmax);
+ }
+ if (controls[SEFIELD] != null) {
+ controls[SEFIELD].setBounds(
+ clientArea.x + westmax + centerwidthmax,
+ clientArea.y + northmax + centerheightmax,
+ eastmax,
+ southmax);
+ }
+
+ }
+
+}
diff --git a/rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/providers/INodedisplayView.java b/rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/providers/INodedisplayView.java
new file mode 100644
index 000000000..de1a01775
--- /dev/null
+++ b/rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/providers/INodedisplayView.java
@@ -0,0 +1,99 @@
+package org.eclipse.ptp.rm.lml.ui.providers;
+
+import org.eclipse.ptp.rm.lml.core.model.ILguiItem;
+import org.eclipse.ptp.rm.lml.internal.core.elements.Nodedisplay;
+
+/**
+ * This interface defines functions, which must be provided
+ * by a view, which shows a nodedisplay. A nodedisplay is
+ * a graphical overview of a parallel system's state. It
+ * has functions to zoom into parts of the view and to
+ * update the output if LML-data changed.
+ */
+public interface INodedisplayView {
+
+ /**
+ * Decreases the size of painted rectangles.
+ */
+ public void decreaseRectangles();
+
+ /**
+ * @return minimal size of painted rectangles
+ */
+ public int getMinimalRectangleSize();
+
+ /**
+ * @return currently shown nodedisplaycomp
+ */
+ public NodedisplayComp getRootNodedisplay();
+
+ /**
+ * Set node with impname as implicit name as root-node within this nodedisplay-panel.
+ * Call this function only if model did not changed.
+ *
+ * @param impname
+ * implicit name of a node, which identifies every node within a nodedisplay
+ * @return true, if root was changed, otherwise false
+ */
+ public boolean goToImpname(String impname);
+
+ /**
+ * Increases the size of painted rectangles.
+ */
+ public void increaseRectangles();
+
+ /**
+ * The stack which saves the last zoom-levels is restarted
+ */
+ public void restartZoom();
+
+ /**
+ * Define the minimum size of rectangles painted
+ * within this nodedisplay
+ *
+ * @param size
+ * width and height of painted rectangles
+ */
+ public void setMinimalRectangleSize(int size);
+
+ /**
+ * Update view and repaint current data.
+ * This is done by creating a completely new nodedisplay.
+ * Tries to go to the implicit name, which was shown
+ * before.
+ */
+ public void update();
+
+ /**
+ * Call this update if lguiitem changes. This update
+ * is calles if another system is monitored.
+ *
+ * @param lgui
+ * new data-manager
+ */
+ public void update(ILguiItem lgui);
+
+ /**
+ * Main update function. Sets a new lgui-handler
+ * and a new nodedisplay-model.
+ *
+ * @param lgui
+ * lguihandler
+ * @param pmodel
+ * nodedisplay model
+ */
+ public void update(ILguiItem lgui, Nodedisplay pmodel);
+
+ /**
+ * Set a child-element as root-element. This causes
+ * going into a mor detailed view of this part of the
+ * nodedisplay.
+ */
+ public void zoomIn(String impname);
+
+ /**
+ * Go one level higher in zoomstack
+ */
+ public void zoomOut();
+
+}
diff --git a/rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/providers/NodedisplayComp.java b/rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/providers/NodedisplayComp.java
index 5a0368387..3beac04a4 100644
--- a/rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/providers/NodedisplayComp.java
+++ b/rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/providers/NodedisplayComp.java
@@ -40,7 +40,6 @@ import org.eclipse.ptp.rm.lml.internal.core.model.NodedisplayAccess;
import org.eclipse.ptp.rm.lml.internal.core.model.OIDToObject;
import org.eclipse.ptp.rm.lml.internal.core.model.ObjectStatus.Updatable;
import org.eclipse.ptp.rm.lml.ui.providers.BorderLayout.BorderData;
-import org.eclipse.ptp.rm.lml.ui.views.NodedisplayView;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.DisposeEvent;
@@ -55,6 +54,7 @@ import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.layout.RowData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
@@ -83,6 +83,9 @@ public class NodedisplayComp extends LguiWidget implements Updatable {
/**
* Class for comparing integer-values in ascending or descending way.
+ *
+ * @author karbach
+ *
*/
public static class NumberComparator implements Comparator<Integer> {
@@ -103,52 +106,6 @@ public class NodedisplayComp extends LguiWidget implements Updatable {
}
/**
- * Find maximum count of elements per level
- * Traverses the whole scheme
- *
- * @param scheme
- * lml-scheme
- * @param level
- * current level (first is 1)
- * @param maxcounts
- * array with length at least scheme.depth
- */
- private static void findMaximum(Object scheme, int level, int[] maxcounts) {
-
- final List subschemes = LMLCheck.getLowerSchemeElements(scheme);
-
- int sum = 0;
-
- for (final Object subscheme : subschemes) {
-
- final SchemeElement sub = (SchemeElement) subscheme;
-
- if (sub.getList() != null) {// list-attribute
- sum += LMLCheck.getNumbersFromNumberlist(sub.getList()).length;
- }
- else {// min- max-attributes
-
- final int min = sub.getMin().intValue();
- int max = min;
- if (sub.getMax() != null) {
- max = sub.getMax().intValue();
- }
-
- final int step = sub.getStep().intValue();
-
- sum += (max - min) / step + 1;
- }
- // Recursive call for lower level
- findMaximum(sub, level + 1, maxcounts);
- }
-
- if (sum > 0 && sum > maxcounts[level - 1]) {
- maxcounts[level - 1] = sum;
- }
-
- }
-
- /**
* Parses through scheme and generates suitable preferences
* for every level of the nodedisplay-tree
*
@@ -208,6 +165,51 @@ public class NodedisplayComp extends LguiWidget implements Updatable {
griddata.verticalAlignment = GridData.FILL;
return griddata;
+ }
+
+ /**
+ * Find maximum count of elements per level
+ * Traverses the whole scheme
+ *
+ * @param scheme
+ * lml-scheme
+ * @param level
+ * current level (first is 1)
+ * @param maxcounts
+ * array with length at least scheme.depth
+ */
+ private static void findMaximum(Object scheme, int level, int[] maxcounts) {
+
+ final List subschemes = LMLCheck.getLowerSchemeElements(scheme);
+
+ int sum = 0;
+
+ for (final Object subscheme : subschemes) {
+
+ final SchemeElement sub = (SchemeElement) subscheme;
+
+ if (sub.getList() != null) {// list-attribute
+ sum += LMLCheck.getNumbersFromNumberlist(sub.getList()).length;
+ }
+ else {// min- max-attributes
+
+ final int min = sub.getMin().intValue();
+ int max = min;
+ if (sub.getMax() != null) {
+ max = sub.getMax().intValue();
+ }
+
+ final int step = sub.getStep().intValue();
+
+ sum += (max - min) / step + 1;
+ }
+ // Recursive call for lower level
+ findMaximum(sub, level + 1, maxcounts);
+ }
+
+ if (sum > 0 && sum > maxcounts[level - 1]) {
+ maxcounts[level - 1] = sum;
+ }
}
@@ -253,7 +255,6 @@ public class NodedisplayComp extends LguiWidget implements Updatable {
private static final int httpsport = 4444;// Special port for https-access
private NodedisplayComp parentNodedisplay = null;// Reference to parent nodedisplay
-
private int minWidth = 0, minHeight = 0;// Minimal width and height of this nodedisplay
private int x = 0, y = 0;// Position of this nodedisplay within surrounding grid
@@ -264,6 +265,9 @@ public class NodedisplayComp extends LguiWidget implements Updatable {
// The name of the special empty job
private final String emptyJobName = "empty";
+ // assumes minimum size
+ private int minRectangleSize = 5;
+
/**
* Call this constructor for start, maxlevel is chosen from lml-file
*
@@ -302,6 +306,26 @@ public class NodedisplayComp extends LguiWidget implements Updatable {
}
/**
+ * easy constructor for a nodedisplay as root-node
+ *
+ * @param lgui
+ * wrapper instance around LguiType-instance -- provides easy access to lml-information
+ * @param pmodel
+ * lml-model for the nodedisplay, which should be shown in this panel
+ * @param lgui
+ * complete lml-model containing this nodedisplay
+ * @param parent
+ * parameter for calling super constructor
+ * @param style
+ * parameter for calling super constructor
+ */
+ public NodedisplayComp(ILguiItem lgui, Nodedisplay pmodel, NodedisplayView pnodeview, int style) {
+
+ this(lgui, pmodel, null, pnodeview, style);
+
+ }
+
+ /**
* Call this constructor for inner or lower elements, rellevel is counted to zero with every level
*
* @param lgui
@@ -349,23 +373,291 @@ public class NodedisplayComp extends LguiWidget implements Updatable {
}
/**
- * easy constructor for a nodedisplay as root-node
+ * Decrease minimal size of painted rectangles.
+ */
+ public void decreaseMinRectangleSize() {
+ setMinmalRectangleSize(minRectangleSize - 1);
+ }
+
+ /**
+ * Search for a layout-section for this nodedisplay-panel
*
- * @param lgui
- * wrapper instance around LguiType-instance -- provides easy access to lml-information
- * @param pmodel
- * lml-model for the nodedisplay, which should be shown in this panel
- * @param lgui
- * complete lml-model containing this nodedisplay
- * @param parent
- * parameter for calling super constructor
- * @param style
- * parameter for calling super constructor
+ * @return lml-Nodedisplay-layout-section for this displaynode, or default-layout if no layout is defined
*/
- public NodedisplayComp(ILguiItem lgui, Nodedisplay pmodel, NodedisplayView pnodeview, int style) {
+ public Nodedisplayelement findLayout() {
- this(lgui, pmodel, null, pnodeview, style);
+ final ArrayList<NodedisplaylayoutType> allnodedisplaylayouts = lgui.getNodedisplayAccess().getLayouts(model.getId());
+
+ // Is there any Layout for this nodedisplay?
+ if (allnodedisplaylayouts == null || allnodedisplaylayouts.size() == 0)
+ return NodedisplayAccess.getDefaultLayout();
+ // Later it should be possible to choose one of possibly multiple defined layouts
+ final NodedisplaylayoutType first = allnodedisplaylayouts.get(0);
+
+ if (node == null) {// Root-level => return el0-Nodedisplayelement
+ if (first.getEl0() != null) {
+ return first.getEl0();
+ }
+ else
+ return NodedisplayAccess.getDefaultLayout();
+ }
+
+ if (first.getEl0() == null)
+ return NodedisplayAccess.getDefaultLayout();
+
+ // Copy level-numbers
+ final ArrayList<Integer> levelnrs = LMLCheck.copyArrayList(node.getLevelNrs());
+
+ // deeper-level => traverse layout-tree
+ final Nodedisplayelement res = LMLCheck.getNodedisplayElementByLevels(levelnrs, first.getEl0());
+
+ if (res == null)
+ return NodedisplayAccess.getDefaultLayout();
+ else
+ return res;
+
+ }
+
+ /**
+ * Generates a hashmap, which connects DisplayNodes to their SWT-colors.
+ *
+ * @param dispnodes
+ * The DisplayNodes, which are keys from the resulting hashmap
+ * @return hashmap, which connects DisplayNodes to their SWT-colors
+ */
+ public HashMap<DisplayNode, Color> generateDisplayNodeToColorMap(ArrayList<DisplayNode> dispnodes) {
+
+ final OIDToObject oidtoobj = lgui.getOIDToObject();
+
+ final HashMap<DisplayNode, Color> dispnodetocolor = new HashMap<DisplayNode, Color>();
+ for (final DisplayNode dispnode : dispnodes) {
+ final String conOID = dispnode.getData().getOid();
+ dispnodetocolor.put(dispnode,
+ ColorConversion.getColor(oidtoobj.getColorById(conOID)));
+ }
+
+ return dispnodetocolor;
+ }
+
+ /**
+ * @return lml-data-access to data shown by this nodedisplay
+ */
+ public ILguiItem getLguiItem() {
+ return lgui;
+ }
+
+ /**
+ * Generates DisplayNodes for every visible component, which
+ * is a child of the element identified by the level-ids.
+ *
+ * @param ascheme
+ * current lml-scheme describing a node
+ * @param adata
+ * current lml-data for this node
+ * @param levels
+ * ids for every level to identify a node in the lml-tree (1,1,1) means first cpu in first nodecard in first row
+ * @param model
+ * full LML-Model for a nodedisplay
+ * @param highestRowfirst
+ * defines how the result will be sorted, true=> descending, false ascending
+ * @return list of DisplayNodes
+ */
+ public ArrayList<DisplayNode> getLowerDisplayNodes(Object ascheme, Object adata, ArrayList<Integer> levels, Nodedisplay model,
+ boolean highestRowfirst) {
+
+ final int alevel = levels.size();
+ final ArrayList<DisplayNode> res = new ArrayList<DisplayNode>();
+
+ final HashMap<Integer, SchemeElement> schemesForIds = new HashMap<Integer, SchemeElement>();
+
+ final ArrayList<Integer> numbers = new ArrayList<Integer>();// Indices within scheme of lower elements
+ final List lscheme = LMLCheck.getLowerSchemeElements(ascheme);
+ for (int i = 0; i < lscheme.size(); i++) {
+
+ // getNumbers
+ final SchemeElement lascheme = (SchemeElement) lscheme.get(i);
+ if (lascheme.getList() != null) {// get list-elements
+
+ final int[] anumbers = LMLCheck.getNumbersFromNumberlist(lascheme.getList());
+ for (final int anumber : anumbers) {
+ numbers.add(anumber);
+ schemesForIds.put(anumber, lascheme);
+ }
+
+ }
+ else {// min- max-attributes
+
+ final int min = lascheme.getMin().intValue();
+ int max = min;
+ if (lascheme.getMax() != null) {
+ max = lascheme.getMax().intValue();
+ }
+
+ final int step = lascheme.getStep().intValue();
+
+ for (int j = min; j <= max; j += step) {
+ numbers.add(j);
+ schemesForIds.put(j, lascheme);
+ }
+
+ }
+ }
+
+ Collections.sort(numbers, new NumberComparator(!highestRowfirst));
+
+ // Process numbers
+ for (int j = 0; j < numbers.size(); j++) {
+ final int aid = numbers.get(j);
+ // Get all information for new DisplayNode
+ final SchemeAndData schemedata = LMLCheck.getSchemeAndDataByLevels(aid, adata, ascheme);
+
+ DataElement lowdata = schemedata.data;
+
+ if (LMLCheck.getDataLevel(adata) < LMLCheck.getSchemeLevel(ascheme) // Was adata already not at the right level
+ // (inheritance of attributes) ?
+ && adata instanceof DataElement) {
+ lowdata = (DataElement) adata;// Then do not go deeper , makes no sense
+ }
+
+ levels.add(aid);
+
+ final DisplayNode dispnode = new DisplayNode(lgui, lgui.getNodedisplayAccess().getTagname(model.getId(), alevel + 1),
+ lowdata, schemesForIds.get(aid), levels, model);
+
+ levels.remove(levels.size() - 1);
+
+ res.add(dispnode);
+ }
+
+ return res;
+
+ }
+
+ /**
+ * @return minimal size of painted rectangles
+ */
+ public int getMinimalRectangleSize() {
+ return minRectangleSize;
+ }
+
+ /**
+ * @return implicit name of node within nodedisplay, which is shown by this NodedisplayPanel
+ */
+ public String getShownImpname() {
+ if (node == null)
+ return null;
+
+ return node.getFullImplicitName();
+ }
+
+ /**
+ * Hide title or name for this panel
+ */
+ public void hideTitle() {
+ titleLabel.setVisible(false);
+ apref.setShowtitle(false);
+ }
+
+ /**
+ * Increase minimal size of painted rectangles.
+ */
+ public void increaseMinRectangleSize() {
+ setMinmalRectangleSize(minRectangleSize + 1);
+ }
+
+ /**
+ * Set minimal size of painted rectangles in this nodedisplay.
+ *
+ * @param size
+ * size in pixels for painted rectangles, this parameter
+ * defines rectangles width as well ass rectangle height
+ */
+ public void setMinmalRectangleSize(int size) {
+ if (size > 0) {
+
+ minRectangleSize = size;
+
+ for (final NodedisplayComp icomp : innerComps) {
+ if (icomp.x == 0 || icomp.y == 0) {
+ icomp.setMinmalRectangleSize(size);
+ }
+ }
+ if (rectpaintlistener != null) {
+ rectpaintlistener.setMinRectSize(size);
+ }
+
+ if (parentNodedisplay == null)
+ showMinRectangleSizes();
+ }
+ }
+
+ /**
+ * Calculate minimum size of this nodedisplay, which
+ * is needed to show all painted rectangles in defined
+ * minimum size.
+ *
+ * @return true, if needed size changed
+ */
+ public boolean showMinRectangleSizes() {
+ final boolean res = callMinSizeCalculation();
+
+ final ScrolledComposite scrollpane = nodeview.getScrollPane();
+
+ scrollpane.setMinSize(minWidth, minHeight);
+
+ final Point nsize = nodeview.getSize();
+ int swidth = minWidth;
+ int sheight = minHeight;
+
+ if (swidth > nsize.x)
+ swidth = nsize.x;
+
+ if (sheight > nsize.y)
+ sheight = nsize.y;
+
+ scrollpane.setLayoutData(new RowData(swidth, sheight));
+
+ nodeview.layout();
+
+ return res;
+ }
+
+ /**
+ * Show title or name for this panel
+ */
+ public void showTitle() {
+ titleLabel.setVisible(true);
+ apref.setShowtitle(true);
+ }
+
+ public void updateStatus(ObjectType j, boolean mouseover, boolean mousedown) {
+
+ if (node == null) {
+ if (innerPanel != null) {
+ innerPanel.redraw();
+ }
+ return;
+ }
+
+ final ObjectType conobject = node.getConnectedObject();
+ if (currentLevel == maxLevel) {
+
+ if (lgui.getObjectStatus().isMouseover(conobject)) {
+ borderFrame.setBorderWidth(apref.getMouseborder().intValue());
+ }
+ else
+ borderFrame.setBorderWidth(apref.getBorder().intValue());
+
+ if (lgui.getObjectStatus().isAnyMousedown() && !lgui.getObjectStatus().isMousedown(conobject)) {// Change color
+ innerPanel.setBackground(ColorConversion.getColor(lgui.getOIDToObject().getColorById(null)));
+ }
+ else
+ innerPanel.setBackground(jobColor);
+ }
+ else if (currentLevel == maxLevel - 1) {// For rectangle-paint of lowest-level-elements
+ innerPanel.redraw();
+ }
}
/**
@@ -455,12 +747,13 @@ public class NodedisplayComp extends LguiWidget implements Updatable {
final Listener l = new Listener() {
public void handleEvent(Event event) {
- showMinRectangleSizes();
+ while (showMinRectangleSizes()) {
+ }
+ innerPanel.removeListener(SWT.Paint, this);
}
};
innerPanel.addListener(SWT.Paint, l);
-
}
/**
@@ -472,13 +765,11 @@ public class NodedisplayComp extends LguiWidget implements Updatable {
titleLabel.addMouseListener(new MouseListener() {
public void mouseDoubleClick(MouseEvent e) {
-
}
public void mouseDown(MouseEvent e) {
titleLabel.setBackground(titleBackgroundColor);
-
if (node == null)
return;
@@ -491,7 +782,6 @@ public class NodedisplayComp extends LguiWidget implements Updatable {
}
public void mouseUp(MouseEvent e) {
-
}
});
// Show different background if titlelabel is covered by the mouse
@@ -508,7 +798,6 @@ public class NodedisplayComp extends LguiWidget implements Updatable {
titleLabel.setBackground(titleBackgroundColor);
}
});
-
}
/**
@@ -528,8 +817,10 @@ public class NodedisplayComp extends LguiWidget implements Updatable {
* all inner components. If this nodedisplay paints rectangles
* itself, this method calls the calculateResize-function of
* the rectangle-painting-listener.
+ *
+ * @return true, if minimum size became bigger
*/
- private void callMinSizeCalculation() {
+ private boolean callMinSizeCalculation() {
final Point size = getSize();
setMinSize(size.x, size.y);
@@ -544,6 +835,7 @@ public class NodedisplayComp extends LguiWidget implements Updatable {
rectpaintlistener.calculateResize();
}
+ return size.x < minWidth || size.y < minHeight;
}
/**
@@ -616,66 +908,6 @@ public class NodedisplayComp extends LguiWidget implements Updatable {
}
/**
- * Search for a layout-section for this nodedisplay-panel
- *
- * @return lml-Nodedisplay-layout-section for this displaynode, or default-layout if no layout is defined
- */
- public Nodedisplayelement findLayout() {
-
- final ArrayList<NodedisplaylayoutType> allnodedisplaylayouts = lgui.getNodedisplayAccess().getLayouts(model.getId());
-
- // Is there any Layout for this nodedisplay?
- if (allnodedisplaylayouts == null || allnodedisplaylayouts.size() == 0)
- return NodedisplayAccess.getDefaultLayout();
- // Later it should be possible to choose one of possibly multiple defined layouts
- final NodedisplaylayoutType first = allnodedisplaylayouts.get(0);
-
- if (node == null) {// Root-level => return el0-Nodedisplayelement
- if (first.getEl0() != null) {
- return first.getEl0();
- }
- else
- return NodedisplayAccess.getDefaultLayout();
- }
-
- if (first.getEl0() == null)
- return NodedisplayAccess.getDefaultLayout();
-
- // Copy level-numbers
- final ArrayList<Integer> levelnrs = LMLCheck.copyArrayList(node.getLevelNrs());
-
- // deeper-level => traverse layout-tree
- final Nodedisplayelement res = LMLCheck.getNodedisplayElementByLevels(levelnrs, first.getEl0());
-
- if (res == null)
- return NodedisplayAccess.getDefaultLayout();
- else
- return res;
-
- }
-
- /**
- * Generates a hashmap, which connects DisplayNodes to their SWT-colors.
- *
- * @param dispnodes
- * The DisplayNodes, which are keys from the resulting hashmap
- * @return hashmap, which connects DisplayNodes to their SWT-colors
- */
- public HashMap<DisplayNode, Color> generateDisplayNodeToColorMap(ArrayList<DisplayNode> dispnodes) {
-
- final OIDToObject oidtoobj = lgui.getOIDToObject();
-
- final HashMap<DisplayNode, Color> dispnodetocolor = new HashMap<DisplayNode, Color>();
- for (final DisplayNode dispnode : dispnodes) {
- final String conOID = dispnode.getData().getOid();
- dispnodetocolor.put(dispnode,
- ColorConversion.getColor(oidtoobj.getColorById(conOID)));
- }
-
- return dispnodetocolor;
- }
-
- /**
* @return 1 if layout defines 0 for cols, otherwise the value set by the layout
*/
private int getCols() {
@@ -714,110 +946,6 @@ public class NodedisplayComp extends LguiWidget implements Updatable {
}
/**
- * @return lml-data-access to data shown by this nodedisplay
- */
- public ILguiItem getLguiItem() {
- return lgui;
- }
-
- /**
- * Generates DisplayNodes for every visible component, which
- * is a child of the element identified by the level-ids.
- *
- * @param ascheme
- * current lml-scheme describing a node
- * @param adata
- * current lml-data for this node
- * @param levels
- * ids for every level to identify a node in the lml-tree (1,1,1) means first cpu in first nodecard in first row
- * @param model
- * full LML-Model for a nodedisplay
- * @param highestRowfirst
- * defines how the result will be sorted, true=> descending, false ascending
- * @return list of DisplayNodes
- */
- public ArrayList<DisplayNode> getLowerDisplayNodes(Object ascheme, Object adata, ArrayList<Integer> levels, Nodedisplay model,
- boolean highestRowfirst) {
-
- final int alevel = levels.size();
- final ArrayList<DisplayNode> res = new ArrayList<DisplayNode>();
-
- final HashMap<Integer, SchemeElement> schemesForIds = new HashMap<Integer, SchemeElement>();
-
- final ArrayList<Integer> numbers = new ArrayList<Integer>();// Indices within scheme of lower elements
- final List lscheme = LMLCheck.getLowerSchemeElements(ascheme);
- for (int i = 0; i < lscheme.size(); i++) {
-
- // getNumbers
- final SchemeElement lascheme = (SchemeElement) lscheme.get(i);
- if (lascheme.getList() != null) {// get list-elements
-
- final int[] anumbers = LMLCheck.getNumbersFromNumberlist(lascheme.getList());
- for (final int anumber : anumbers) {
- numbers.add(anumber);
- schemesForIds.put(anumber, lascheme);
- }
-
- }
- else {// min- max-attributes
-
- final int min = lascheme.getMin().intValue();
- int max = min;
- if (lascheme.getMax() != null) {
- max = lascheme.getMax().intValue();
- }
-
- final int step = lascheme.getStep().intValue();
-
- for (int j = min; j <= max; j += step) {
- numbers.add(j);
- schemesForIds.put(j, lascheme);
- }
-
- }
- }
-
- Collections.sort(numbers, new NumberComparator(!highestRowfirst));
-
- // Process numbers
- for (int j = 0; j < numbers.size(); j++) {
- final int aid = numbers.get(j);
- // Get all information for new DisplayNode
- final SchemeAndData schemedata = LMLCheck.getSchemeAndDataByLevels(aid, adata, ascheme);
-
- DataElement lowdata = schemedata.data;
-
- if (LMLCheck.getDataLevel(adata) < LMLCheck.getSchemeLevel(ascheme) // Was adata already not at the right level
- // (inheritance of attributes) ?
- && adata instanceof DataElement) {
- lowdata = (DataElement) adata;// Then do not go deeper , makes no sense
- }
-
- levels.add(aid);
-
- final DisplayNode dispnode = new DisplayNode(lgui, lgui.getNodedisplayAccess().getTagname(model.getId(), alevel + 1),
- lowdata, schemesForIds.get(aid), levels, model);
-
- levels.remove(levels.size() - 1);
-
- res.add(dispnode);
- }
-
- return res;
-
- }
-
- /**
- * @return implicit name of node within nodedisplay, which is shown by this NodedisplayPanel
- */
- public String getShownImpname() {
- if (node == null)
- return null;
-
- return node.getFullImplicitName();
- }
-
- /**
* Generate the text shown for a displaynode, which is covered by mouse-cursor.
*
* @param focussed
@@ -835,46 +963,6 @@ public class NodedisplayComp extends LguiWidget implements Updatable {
}
/**
- * Hide title or name for this panel
- */
- public void hideTitle() {
- titleLabel.setVisible(false);
- apref.setShowtitle(false);
- }
-
- /**
- * Add height-parameter to minHeight
- *
- * @param height
- * difference to be added
- */
- public synchronized void increaseMinHeight(int height) {
- minHeight += height;
-
- if (parentNodedisplay != null) {
- // Only first column sends minheight-increases to parent composites
- if (x == 0)
- parentNodedisplay.increaseMinHeight(height);
- }
- }
-
- /**
- * Add width-parameter to minWidth
- *
- * @param width
- * difference to be added
- */
- public synchronized void increaseMinWidth(int width) {
- minWidth += width;
-
- if (parentNodedisplay != null) {
- // Only first row sends minwidth-increases to parent composites
- if (y == 0)
- parentNodedisplay.increaseMinWidth(width);
- }
- }
-
- /**
* Part of constructor, which is equal in two constructors
* therefore outsourced
*
@@ -944,6 +1032,8 @@ public class NodedisplayComp extends LguiWidget implements Updatable {
rectpaintlistener.bordercolor = bordercolor;
+ rectpaintlistener.setMinRectSize(minRectangleSize);
+
innerPanel.addListener(SWT.Paint, rectpaintlistener);
}
@@ -961,7 +1051,6 @@ public class NodedisplayComp extends LguiWidget implements Updatable {
// Bordercolor is defined by this parameter
final Color bordercolor = ColorConversion.getColor(LMLColor.stringToColor(apref.getBordercolor()));
-
createFramePanels(bordercolor);
// Generate all displaynodes for elements in lml-tree which are childs of the current node
@@ -971,7 +1060,6 @@ public class NodedisplayComp extends LguiWidget implements Updatable {
initRectPaintListener(dispnodes, bordercolor);
addMouseListenerToInnerPanel();
-
}
else { // insert lower nodedisplays, nest composites
@@ -1162,51 +1250,35 @@ public class NodedisplayComp extends LguiWidget implements Updatable {
}
/**
- * Calculate minimum size of this nodedisplay, which
- * is needed to show all painted rectangles in defined
- * minimum size.
+ * Add height-parameter to minHeight
*
+ * @param height
+ * difference to be added
*/
- public void showMinRectangleSizes() {
- callMinSizeCalculation();
+ protected synchronized void increaseMinHeight(int height) {
+ minHeight += height;
- nodeview.getScrollPane().setMinSize(minWidth, minHeight);
+ if (parentNodedisplay != null) {
+ // Only first column sends minheight-increases to parent composites
+ if (x == 0)
+ parentNodedisplay.increaseMinHeight(height);
+ }
}
/**
- * Show title or name for this panel
+ * Add width-parameter to minWidth
+ *
+ * @param width
+ * difference to be added
*/
- public void showTitle() {
- titleLabel.setVisible(true);
- apref.setShowtitle(true);
- }
-
- public void updateStatus(ObjectType j, boolean mouseover, boolean mousedown) {
-
- if (node == null) {
- if (innerPanel != null) {
- innerPanel.redraw();
- }
- return;
- }
-
- final ObjectType conobject = node.getConnectedObject();
- if (currentLevel == maxLevel) {
-
- if (lgui.getObjectStatus().isMouseover(conobject)) {
- borderFrame.setBorderWidth(apref.getMouseborder().intValue());
- }
- else
- borderFrame.setBorderWidth(apref.getBorder().intValue());
+ protected synchronized void increaseMinWidth(int width) {
+ minWidth += width;
- if (lgui.getObjectStatus().isAnyMousedown() && !lgui.getObjectStatus().isMousedown(conobject)) {// Change color
- innerPanel.setBackground(ColorConversion.getColor(lgui.getOIDToObject().getColorById(null)));
- }
- else
- innerPanel.setBackground(jobColor);
- }
- else if (currentLevel == maxLevel - 1) {// For rectangle-paint of lowest-level-elements
- innerPanel.redraw();
+ if (parentNodedisplay != null) {
+ // Only first row sends minwidth-increases to parent composites
+ if (y == 0)
+ parentNodedisplay.increaseMinWidth(width);
}
}
+
}
diff --git a/rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/providers/NodedisplayView.java b/rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/providers/NodedisplayView.java
new file mode 100644
index 000000000..9d7efd73d
--- /dev/null
+++ b/rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/providers/NodedisplayView.java
@@ -0,0 +1,379 @@
+package org.eclipse.ptp.rm.lml.ui.providers;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Stack;
+
+import org.eclipse.ptp.rm.lml.core.listeners.INodedisplayZoomListener;
+import org.eclipse.ptp.rm.lml.core.model.ILguiItem;
+import org.eclipse.ptp.rm.lml.internal.core.elements.Nodedisplay;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.ControlListener;
+import org.eclipse.swt.graphics.Cursor;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.ScrollBar;
+
+/**
+ * Parent composite of NodedisplayComp
+ * This class allows to zoom or switch the viewports of
+ * nodedisplaycomps. Every nodedisplaycomp is connected with
+ * one instance of this class. NodedisplayView represents one zoomable
+ * NodedisplayComp.
+ */
+public class NodedisplayView extends LguiWidget implements INodedisplayView {
+
+ protected Nodedisplay model;// LML-Data-model for this view
+
+ protected ScrolledComposite scrollpane;// creates scrollbars surrounding nodedisplay
+ protected NodedisplayComp root = null;// root nodedisplay which is currently shown
+
+ protected Stack<String> zoomstack = new Stack<String>();// Saves zoom-levels to zoom out later, saves full-implicit name of
+ // nodes to create Displaynodes from these ids
+
+ // Cursors for showing processing
+ protected Cursor waitcursor;// Cursor to show while processing
+ protected Cursor defaultcursor;// default cursor
+
+ // List of listeners for zooming-events
+ private final List<INodedisplayZoomListener> zoomlisteners;
+
+ /**
+ * Create a composite as surrounding component for NodedisplayComps.
+ * This class encapsulates zooming functionality. It saves a stack
+ *
+ * @param pmodel
+ * @param parent
+ */
+ public NodedisplayView(ILguiItem lgui, Nodedisplay pmodel, Composite parent) {
+
+ super(lgui, parent, SWT.None);
+
+ zoomlisteners = new LinkedList<INodedisplayZoomListener>();
+
+ model = pmodel;
+
+ final RowLayout layout = new RowLayout();
+ layout.pack = false;
+
+ setLayout(layout);
+
+ scrollpane = new ScrolledComposite(this, SWT.H_SCROLL | SWT.V_SCROLL);
+
+ if (lgui != null && model != null)
+ root = new NodedisplayComp(lgui, model, this, SWT.None);
+
+ // Create cursors
+ defaultcursor = this.getCursor();
+ waitcursor = new Cursor(this.getDisplay(), SWT.CURSOR_WAIT);
+
+ addResizeListenerForScrollPane();
+ addResizeListenerForNodedisplayView();
+ }
+
+ // Listener-access
+ /**
+ * Add a listener, which listens for zoom-events.
+ * Every time a new node is set as root a new event
+ * is send to the listeners.
+ *
+ * @param listener
+ */
+ public void addZoomListener(INodedisplayZoomListener listener) {
+ zoomlisteners.add(listener);
+ }
+
+ /**
+ * Decreases the size of painted rectangles.
+ */
+ public void decreaseRectangles() {
+ if (root == null)
+ return;
+
+ root.decreaseMinRectangleSize();
+ }
+
+ @Override
+ public void dispose() {
+ // Dispose created cursor
+ waitcursor.dispose();
+ }
+
+ public int getMinimalRectangleSize() {
+ if (root == null)
+ return 0;
+
+ return root.getMinimalRectangleSize();
+ }
+
+ public NodedisplayComp getRootNodedisplay() {
+ return root;
+ }
+
+ /**
+ * @return access to scrollpane, which contains the root-nodedisplay
+ */
+ public ScrolledComposite getScrollPane() {
+ return scrollpane;
+ }
+
+ public boolean goToImpname(String impname) {
+ return goToImpname(impname, false);
+ }
+
+ public void increaseRectangles() {
+ if (root == null)
+ return;
+
+ root.increaseMinRectangleSize();
+ }
+
+ /**
+ * @param listener
+ */
+ public void removeZoomListener(INodedisplayZoomListener listener) {
+ zoomlisteners.remove(listener);
+ }
+
+ public void restartZoom() {
+ zoomstack = new Stack<String>();
+ }
+
+ public void setMinimalRectangleSize(int size) {
+ if (root == null)
+ return;
+
+ root.setMinmalRectangleSize(size);
+ }
+
+ @Override
+ public void update() {
+ update(lgui, getNewModel());
+ }
+
+ public void update(ILguiItem lgui) {
+ this.lgui = lgui;
+ update(lgui, getNewModel());
+ }
+
+ public void update(ILguiItem lgui, Nodedisplay pmodel) {
+ super.update();
+
+ this.lgui = lgui;
+
+ restartZoom();
+ model = pmodel;
+
+ if (model != null)
+ goToImpname(null, true);
+ }
+
+ public void zoomIn(String impname) {
+ if (root == null)
+ return;
+
+ this.setCursor(waitcursor);
+
+ String oldshown = root.getShownImpname();
+
+ if (goToImpname(impname)) {
+ if (oldshown == null)// Not allowed to insert null-values into ArrayDeque
+ oldshown = "";
+ zoomstack.push(oldshown);
+ }
+
+ this.setCursor(defaultcursor);
+ }
+
+ public void zoomOut() {
+ this.setCursor(waitcursor);
+
+ if (!zoomstack.isEmpty()) {
+ String impname = zoomstack.pop();
+ // Get back null-values
+ if (impname.equals(""))
+ impname = null;
+
+ // Switch view to node with impname
+ goToImpname(impname);
+ }
+
+ this.setCursor(defaultcursor);
+ }
+
+ /**
+ * Notify all listeners, that a new node with
+ * implicit name impname is now root-node.
+ *
+ * @param impname
+ * full implicit name of new node or null for root-nodes
+ */
+ private void notifyZoom(String impname) {
+
+ final NodedisplayZoomEvent event = new NodedisplayZoomEvent(impname);
+ for (final INodedisplayZoomListener listener : zoomlisteners) {
+ listener.handleEvent(event);
+ }
+
+ }
+
+ /**
+ * Adds a listener, which adjusts rectangle-sizes everytime
+ * this view is resized.
+ */
+ protected void addResizeListenerForNodedisplayView() {
+ this.addControlListener(new ControlListener() {
+
+ public void controlMoved(ControlEvent e) {
+ }
+
+ public void controlResized(ControlEvent e) {
+ if (root != null) {
+ root.showMinRectangleSizes();
+ }
+ }
+ });
+ }
+
+ /**
+ * Adds a listener, which changes scrollbar-increments on
+ * every resize.
+ */
+ protected void addResizeListenerForScrollPane() {
+
+ scrollpane.addControlListener(new ControlListener() {
+
+ public void controlMoved(ControlEvent e) {
+ }
+
+ public void controlResized(ControlEvent e) {
+
+ checkSize();
+
+ final ScrollBar xbar = scrollpane.getHorizontalBar();
+ final ScrollBar ybar = scrollpane.getVerticalBar();
+ if (xbar != null) {
+ xbar.setPageIncrement(xbar.getThumb() / 2);
+ xbar.setIncrement(xbar.getThumb() / 5);
+ }
+ if (ybar != null) {
+ ybar.setPageIncrement(ybar.getThumb() / 2);
+ ybar.setIncrement(ybar.getThumb() / 5);
+ }
+ }
+
+ /**
+ * Checks that the scrollpane-size does not exceed the
+ * NodedisplayView-size.
+ */
+ private void checkSize() {
+
+ final Point s = scrollpane.getSize();
+ final Point ns = NodedisplayView.this.getSize();
+
+ if (s.x >= ns.x - 1) {
+ s.x = ns.x - 2;
+ }
+
+ if (s.y >= ns.y) {
+ s.y = ns.y - 1;
+ }
+
+ scrollpane.setSize(s);
+ }
+ });
+
+ }
+
+ /**
+ * Data has been updated. The new nodedisplay-model is needed.
+ * This function searches for the nodedisplay-instance, which
+ * is the successor of the last shown nodedisplay.
+ *
+ * @return new Nodedisplay-model
+ */
+ protected Nodedisplay getNewModel() {
+
+ if (lgui == null)
+ return null;
+
+ String nodedisplayId = "";
+ if (model != null)
+ nodedisplayId = model.getId();
+
+ Nodedisplay res = lgui.getNodedisplayAccess().getNodedisplayById(nodedisplayId);
+
+ if (res == null) {
+ final List<Nodedisplay> nodedisplays = lgui.getNodedisplayAccess().getNodedisplays();
+
+ if (nodedisplays.size() > 0) {
+ res = nodedisplays.get(0);
+ }
+ }
+
+ return res;
+ }
+
+ /**
+ * Set node with impname as implicit name as root-node within this nodedisplay-panel
+ *
+ * @param impname
+ * implicit name of a node, which identifies every node within a nodedisplay
+ * @param modelChanged
+ * if true a new nodedisplay is forced to be created, otherwise only
+ * if the new impname differs from currently shown impname
+ * @return true, if root was changed, otherwise false
+ */
+ protected boolean goToImpname(String impname, boolean modelChanged) {
+
+ if (lgui == null)
+ return false;
+
+ String shownimpname = null;
+ if (root != null)
+ shownimpname = root.getShownImpname();
+
+ // A new panel has to be created if the model is new
+ if (!modelChanged) {
+ // Do not create a new panel if panel is already on the right view
+ if (shownimpname == null) {
+ if (impname == null) {
+ return false;
+ }
+ }
+ else if (shownimpname.equals(impname)) {// Do not create new panel, if current viewport is the same to which this panel
+ // should be set
+ return false;
+ }
+ }
+
+ NodedisplayComp newcomp = null;
+
+ if (root != null) {
+ root.dispose();// Delete old root-element
+ System.gc();
+ }
+
+ if (impname != null) {
+ final DisplayNode newnode = DisplayNode.getDisplayNodeFromImpName(lgui, impname, model);
+
+ newcomp = new NodedisplayComp(lgui, model, newnode, this, SWT.None);
+ }
+ else
+ newcomp = new NodedisplayComp(lgui, model, this, SWT.None);// if impname is null => go up to root-level
+
+ root = newcomp;
+
+ this.layout();
+ root.layout();
+
+ // Send event to all zoomlisteners
+ notifyZoom(impname);
+
+ return true;
+ }
+
+}
diff --git a/rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/providers/NodedisplayViewAddition.java b/rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/providers/NodedisplayViewAddition.java
new file mode 100644
index 000000000..c028cb6aa
--- /dev/null
+++ b/rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/providers/NodedisplayViewAddition.java
@@ -0,0 +1,91 @@
+package org.eclipse.ptp.rm.lml.ui.providers;
+
+import org.eclipse.ptp.rm.lml.core.model.ILguiItem;
+import org.eclipse.ptp.rm.lml.internal.core.elements.Nodedisplay;
+import org.eclipse.ptp.rm.lml.ui.providers.BorderLayout.BorderData;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * Extend this class to add one function to a NodedisplayView.
+ * All function calls from INodedisplayView are delegated to
+ * an inner NodedisplayView. This view is inserted as center-
+ * composite of a Borderlayout. If you want to add a composite
+ * around a nodedisplayview, you can extend this class and add
+ * the widgets.
+ */
+public class NodedisplayViewAddition extends LguiWidget implements INodedisplayView {
+
+ protected NodedisplayView nodedisplayview;// Inner NodedisplayView shown in center of this composite
+
+ /**
+ * Creates a wrapper composite, which acts like a NodedisplayView
+ * but has additional functions and widgets.
+ *
+ * @param lgui
+ * data-handler
+ * @param pmodel
+ * the nodedisplay, which should be shown
+ * @param parent
+ * parent composite
+ */
+ public NodedisplayViewAddition(ILguiItem lgui, Nodedisplay pmodel, Composite parent) {
+
+ super(lgui, parent, SWT.None);
+
+ setLayout(new BorderLayout());
+
+ nodedisplayview = new NodedisplayView(lgui, pmodel, this);
+ nodedisplayview.setLayoutData(new BorderData(BorderLayout.MFIELD));
+ }
+
+ public void decreaseRectangles() {
+ nodedisplayview.decreaseRectangles();
+ }
+
+ public int getMinimalRectangleSize() {
+ return nodedisplayview.getMinimalRectangleSize();
+ }
+
+ public NodedisplayComp getRootNodedisplay() {
+ return nodedisplayview.getRootNodedisplay();
+ }
+
+ public boolean goToImpname(String impname) {
+ return nodedisplayview.goToImpname(impname);
+ }
+
+ public void increaseRectangles() {
+ nodedisplayview.increaseRectangles();
+ }
+
+ public void restartZoom() {
+ nodedisplayview.restartZoom();
+ }
+
+ public void setMinimalRectangleSize(int size) {
+ nodedisplayview.setMinimalRectangleSize(size);
+ }
+
+ @Override
+ public void update() {
+ nodedisplayview.update();
+ }
+
+ public void update(ILguiItem lgui) {
+ nodedisplayview.update(lgui);
+ }
+
+ public void update(ILguiItem lgui, Nodedisplay pmodel) {
+ nodedisplayview.update(lgui, pmodel);
+ }
+
+ public void zoomIn(String impname) {
+ nodedisplayview.zoomIn(impname);
+ }
+
+ public void zoomOut() {
+ nodedisplayview.zoomOut();
+ }
+
+}
diff --git a/rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/providers/NodedisplayViewZoomable.java b/rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/providers/NodedisplayViewZoomable.java
new file mode 100644
index 000000000..ba4468915
--- /dev/null
+++ b/rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/providers/NodedisplayViewZoomable.java
@@ -0,0 +1,111 @@
+package org.eclipse.ptp.rm.lml.ui.providers;
+
+import org.eclipse.ptp.rm.lml.core.events.INodedisplayZoomEvent;
+import org.eclipse.ptp.rm.lml.core.listeners.INodedisplayZoomListener;
+import org.eclipse.ptp.rm.lml.core.model.ILguiItem;
+import org.eclipse.ptp.rm.lml.internal.core.elements.Nodedisplay;
+import org.eclipse.ptp.rm.lml.ui.providers.BorderLayout.BorderData;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Slider;
+
+/**
+ * Adds a slider to the top of a nodedisplayview. This
+ * slider allows to set the painted rectangle-size.
+ *
+ */
+public class NodedisplayViewZoomable extends NodedisplayViewAddition {
+
+ private final Slider slider;
+
+ /**
+ * Create a nodedisplay with slider on top to resize painted
+ * rectangles.
+ *
+ * @param lgui
+ * lguihandler
+ * @param pmodel
+ * the nodedisplay shown by this view
+ * @param parent
+ * parent composite
+ */
+ public NodedisplayViewZoomable(ILguiItem lgui, Nodedisplay pmodel, Composite parent) {
+
+ super(lgui, pmodel, parent);
+
+ this.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+
+ slider = new Slider(this, SWT.HORIZONTAL);
+ slider.setLayoutData(new BorderData(BorderLayout.NFIELD));
+ slider.setMinimum(1);
+ slider.setMaximum(30);
+ slider.setIncrement(1);
+ slider.setSelection(5);
+ slider.setToolTipText("Rectangle size");
+
+ slider.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event event) {
+ nodedisplayview.setMinimalRectangleSize(slider.getSelection());
+ }
+ });
+
+ addZoomListener();
+
+ checkEmptyScreen();
+ }
+
+ @Override
+ public void update() {
+ super.update();
+ nodedisplayview.setMinimalRectangleSize(slider.getSelection());
+ }
+
+ @Override
+ public void update(ILguiItem lgui) {
+ super.update(lgui);
+ this.lgui = lgui;
+ nodedisplayview.setMinimalRectangleSize(slider.getSelection());
+ checkEmptyScreen();
+ }
+
+ @Override
+ public void update(ILguiItem lgui, Nodedisplay pmodel) {
+ super.update(lgui, pmodel);
+ this.lgui = lgui;
+ nodedisplayview.setMinimalRectangleSize(slider.getSelection());
+ checkEmptyScreen();
+ }
+
+ /**
+ * Add a listener for zooming-events. On every zoom
+ * the rectangle size is adjusted to the slider-selection.
+ */
+ private void addZoomListener() {
+
+ nodedisplayview.addZoomListener(new INodedisplayZoomListener() {
+
+ public void handleEvent(INodedisplayZoomEvent event) {
+ nodedisplayview.setMinimalRectangleSize(slider.getSelection());
+ }
+ });
+
+ }
+
+ /**
+ * Sets visibility depending on available data for showing a nodedisplay.
+ */
+ private void checkEmptyScreen() {
+ if (lgui == null) {
+ slider.setVisible(false);
+ nodedisplayview.setVisible(false);
+ }
+ else {
+ slider.setVisible(true);
+ nodedisplayview.setVisible(true);
+ }
+ }
+
+}
diff --git a/rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/providers/NodedisplayZoomEvent.java b/rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/providers/NodedisplayZoomEvent.java
new file mode 100644
index 000000000..4fa9f2163
--- /dev/null
+++ b/rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/providers/NodedisplayZoomEvent.java
@@ -0,0 +1,30 @@
+package org.eclipse.ptp.rm.lml.ui.providers;
+
+import org.eclipse.ptp.rm.lml.core.events.INodedisplayZoomEvent;
+
+/**
+ * This implementation only saves the implicit name of
+ * the node, which is shown in detail after this event
+ * is send.
+ *
+ */
+public class NodedisplayZoomEvent implements INodedisplayZoomEvent {
+
+ // Implicit name of new node
+ private final String impname;
+
+ /**
+ * Create a new event with implicit name of zoomed root-node.
+ *
+ * @param impname
+ * full name of shown node
+ */
+ public NodedisplayZoomEvent(String impname) {
+ this.impname = impname;
+ }
+
+ public String getNewNodeName() {
+ return impname;
+ }
+
+}
diff --git a/rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/providers/RectPaintListener.java b/rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/providers/RectPaintListener.java
index 3b08bb0e7..9d6d5649a 100644
--- a/rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/providers/RectPaintListener.java
+++ b/rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/providers/RectPaintListener.java
@@ -16,200 +16,221 @@ import org.eclipse.swt.widgets.Listener;
/**
* A listener, which paints DisplayNode-instances within a panel. This is used for the lowest level
* rectangles in a nodedisplay. It is faster to paint rectangles than using a gridlayout and inserting nodedisplay-
- * composites for every rectangle. As a result this implementation causes less general layouts
- * (for example: it is more difficult to react for cursor-focus on these rectangles,
+ * composites for every rectangle. As a result this implementation causes less general layouts
+ * (for example: it is more difficult to react for cursor-focus on these rectangles,
* texts as titles have to be painted
* and can not be inserted by using a layout-manager)
- *
- *
- * @author karbach
- *
*/
-public class RectPaintListener implements Listener{
-
- private ArrayList<DisplayNode> dispnodes;//nodes which are painted in the composite
- private HashMap<DisplayNode, Color> dispnodetocolor;//map for fast access to displaynode-colors
- private HashMap<DisplayNode, Rectangle> dispnodetorectangle;//map containing positions of dispnodes, they might change in every paint
- private int COLUMNCOUNT;//count of columns in the grid
- private NodedisplayComp nodecomp;//The composite which is painted by this listener
-
- public Color bordercolor=Display.getCurrent().getSystemColor(SWT.COLOR_BLACK);
-
- public int marginWidth=1;//space around the grid in x-direction
- public int marginHeight=1;//space around the grid in y-direction
- public int horizontalSpacing=1;//space between two rectangles in x
- public int verticalSpacing=1;//space between two rectangles in y
-
- public int normalborder=0;//Border shown if displaynodes are not focussed
- public int mouseborder=1;//Border shown if displaynodes are focussed
-
- //Minimal size of drawed rectangles
- public int minRectWidth=5;
- public int minRectHeight=5;
-
- private int rowcount,rectwidth,rectheight;//Parameters, which are changed when painting, they can be used by getDisplayNodeAtPos
-
- private ObjectStatus objstatus;
-
- private Composite usingListener;
-
+public class RectPaintListener implements Listener {
+
+ private final ArrayList<DisplayNode> dispnodes;// nodes which are painted in the composite
+ private final HashMap<DisplayNode, Color> dispnodetocolor;// map for fast access to displaynode-colors
+ private final HashMap<DisplayNode, Rectangle> dispnodetorectangle;// map containing positions of dispnodes, they might change in
+ // every paint
+ private int COLUMNCOUNT;// count of columns in the grid
+ private final NodedisplayComp nodecomp;// The composite which is painted by this listener
+
+ public Color bordercolor = Display.getCurrent().getSystemColor(SWT.COLOR_BLACK);
+
+ public int marginWidth = 1;// space around the grid in x-direction
+ public int marginHeight = 1;// space around the grid in y-direction
+ public int horizontalSpacing = 1;// space between two rectangles in x
+ public int verticalSpacing = 1;// space between two rectangles in y
+
+ public int normalborder = 0;// Border shown if displaynodes are not focussed
+ public int mouseborder = 1;// Border shown if displaynodes are focussed
+
+ // Minimal size of drawed rectangles
+ public int minRectWidth = 5;
+ public int minRectHeight = 5;
+
+ private int rowcount, rectwidth, rectheight;// Parameters, which are changed when painting, they can be used by
+ // getDisplayNodeAtPos
+
+ private final ObjectStatus objstatus;
+
+ private final Composite usingListener;
+
/**
* Create the listener, initialize attributes and generate dispnodetocolor-map
- * @param pdispnodes nodes, which should be painted
- * @param pcolumncount count of columns in the grid
- * @param pnodecomp NodedisplayComp, in which this listener is used
- * @param pusingListener Composite, which uses this listener
+ *
+ * @param pdispnodes
+ * nodes, which should be painted
+ * @param pcolumncount
+ * count of columns in the grid
+ * @param pnodecomp
+ * NodedisplayComp, in which this listener is used
+ * @param pusingListener
+ * Composite, which uses this listener
*/
- public RectPaintListener( ArrayList<DisplayNode> pdispnodes, int pcolumncount, NodedisplayComp pnodecomp, Composite pusingListener ){
- dispnodes=pdispnodes;
- COLUMNCOUNT=pcolumncount;
- nodecomp=pnodecomp;
-
- dispnodetocolor=nodecomp.generateDisplayNodeToColorMap(dispnodes);
-
- dispnodetorectangle=new HashMap<DisplayNode, Rectangle>();
-
- objstatus=nodecomp.getLguiItem().getObjectStatus();
-
- usingListener=pusingListener;
+ public RectPaintListener(ArrayList<DisplayNode> pdispnodes, int pcolumncount, NodedisplayComp pnodecomp,
+ Composite pusingListener) {
+ dispnodes = pdispnodes;
+ COLUMNCOUNT = pcolumncount;
+ nodecomp = pnodecomp;
+
+ dispnodetocolor = nodecomp.generateDisplayNodeToColorMap(dispnodes);
+
+ dispnodetorectangle = new HashMap<DisplayNode, Rectangle>();
+
+ objstatus = nodecomp.getLguiItem().getObjectStatus();
+
+ usingListener = pusingListener;
}
-
+
+ /**
+ * Calculate minimum needed size for this painting.
+ * Send to root-element to increase its minimum size.
+ */
+ public void calculateResize() {
+
+ updateRectSize();
+
+ increaseMinSize();
+ }
+
/**
* Pass a relative mouse-position on the composite, which uses this listener.
* Then the displaynode on focus will be returned. If no node is focussed
* null is returned.
- * @param px x-position of cursor within the composite
- * @param py y-position of cursor within the composite
+ *
+ * @param px
+ * x-position of cursor within the composite
+ * @param py
+ * y-position of cursor within the composite
* @return focussed DisplayNode or null, if nothing is focussed
*/
- public DisplayNode getDisplayNodeAtPos(int px, int py){
-
- int x=px-marginWidth;
- int y=py-marginHeight;
-
- if(x<0 || y<0) return null;//Outside grid, left or top
-
- if(rectwidth==0 || rectheight==0) return null;
-
- int col=x/rectwidth;
- int row=y/rectheight;
-
- if( col >= COLUMNCOUNT || row>=rowcount )//Outside grid, right or bottom
+ public DisplayNode getDisplayNodeAtPos(int px, int py) {
+
+ final int x = px - marginWidth;
+ final int y = py - marginHeight;
+
+ if (x < 0 || y < 0)
+ return null;// Outside grid, left or top
+
+ if (rectwidth == 0 || rectheight == 0)
return null;
-
- int index=row*COLUMNCOUNT+col;
-
- if(index>=dispnodes.size())
+
+ final int col = x / rectwidth;
+ final int row = y / rectheight;
+
+ if (col >= COLUMNCOUNT || row >= rowcount)// Outside grid, right or bottom
+ return null;
+
+ final int index = row * COLUMNCOUNT + col;
+
+ if (index >= dispnodes.size())
return null;
-
- return dispnodes.get(index);
+
+ return dispnodes.get(index);
}
-
- /**
- * Calculate minimum needed size for this painting.
- * Send to root-element to increase its minimum size.
- */
- public void calculateResize(){
-
+
+ public void handleEvent(Event event) {
+
updateRectSize();
-
- increaseMinSize();
+
+ for (int x = 0; x < COLUMNCOUNT; x++) {
+
+ for (int y = 0; y < rowcount; y++) {
+ // get index of displaynode
+ final int index = y * COLUMNCOUNT + x;
+ if (index >= dispnodes.size())
+ break;
+
+ // Rectangle frame
+ final Rectangle r = new Rectangle(marginWidth + rectwidth * x, marginHeight + rectheight * y,
+ rectwidth - horizontalSpacing, rectheight - verticalSpacing);
+
+ // Paint outer rectangle
+ event.gc.setBackground(bordercolor);
+ event.gc.fillRectangle(r.x, r.y, r.width, r.height);
+
+ final DisplayNode dispnode = dispnodes.get(index);
+ // Paint it
+ if (objstatus.isAnyMousedown()
+ && !objstatus.isMousedown(dispnode.getConnectedObject())) {
+ // Change color
+ event.gc.setBackground(
+ ColorConversion.getColor(nodecomp.getLguiItem().getOIDToObject().getColorById(null)));
+ }
+ else
+ event.gc.setBackground(dispnodetocolor.get(dispnode));
+
+ int border = normalborder;
+
+ if (objstatus.isMouseover(dispnode.getConnectedObject())) {
+ border = mouseborder;
+ }
+ event.gc.fillRectangle(r.x + border, r.y + border, r.width - 2 * border, r.height - 2 * border);
+
+ dispnodetorectangle.put(dispnode, r);// save the current rectangle
+ }
+
+ }
}
-
+
/**
- * Generate size of drawed rectangles.
+ * Set minimum rectangle size. Set min-width and
+ * min-height to size.
*
- * @return size of painted rectangles
+ * @param size
*/
- protected void updateRectSize(){
-
- int w,h;
-
- Point size=usingListener.getSize();
- //Generate available size
- w=size.x-marginWidth*2;
- h=size.y-marginHeight*2;
-
- if(COLUMNCOUNT<=0)
- COLUMNCOUNT=1;
-
- //Calculate how many rows have to be painted
- rowcount=dispnodes.size() / COLUMNCOUNT;
- if(dispnodes.size() % COLUMNCOUNT != 0)
- rowcount++;
-
- if(rowcount==0)
- return;
-
- rectwidth=w/COLUMNCOUNT;
-
- rectheight=h/rowcount;
+ public void setMinRectSize(int size) {
+ minRectWidth = size;
+ minRectHeight = size;
}
-
+
/**
* @return minimal composite-size to show rectangles with minRectWidth and minRectHeight
*/
- protected Point getMinimalSize(){
- return new Point( minRectWidth*COLUMNCOUNT+2*marginWidth,
- minRectHeight*rowcount+2*marginHeight);
+ protected Point getMinimalSize() {
+ return new Point(minRectWidth * COLUMNCOUNT + 2 * marginWidth,
+ minRectHeight * rowcount + 2 * marginHeight);
}
-
+
/**
* Increases surrounding composite-size if needed.
* Takes minRectWidth and minRectHeight to calculate
* minimal composite-size. Increases the size if needed
* by setting new minsize of this nodedisplay.
*/
- protected void increaseMinSize(){
-
- Point oldSize=usingListener.getSize();
- Point minSize=getMinimalSize();
-
- nodecomp.increaseMinWidth( minSize.x - oldSize.x );
+ protected void increaseMinSize() {
+
+ final Point oldSize = usingListener.getSize();
+ final Point minSize = getMinimalSize();
+
+ nodecomp.increaseMinWidth(minSize.x - oldSize.x);
nodecomp.increaseMinHeight(minSize.y - oldSize.y);
}
-
- public void handleEvent(Event event) {
-
- updateRectSize();
-
- for(int x=0; x<COLUMNCOUNT; x++){
-
- for(int y=0; y<rowcount; y++){
- //get index of displaynode
- int index=y*COLUMNCOUNT+x;
- if(index>=dispnodes.size())
- break;
-
- //Rectangle frame
- Rectangle r=new Rectangle(marginWidth+rectwidth*x , marginHeight+ rectheight*y,
- rectwidth-horizontalSpacing, rectheight-verticalSpacing);
-
- //Paint outer rectangle
- event.gc.setBackground( bordercolor);
- event.gc.fillRectangle( r.x, r.y, r.width, r.height );
-
- DisplayNode dispnode=dispnodes.get(index);
- //Paint it
- if(objstatus.isAnyMousedown()
- && !objstatus.isMousedown(dispnode.getConnectedObject())){
- //Change color
- event.gc.setBackground(
- ColorConversion.getColor( nodecomp.getLguiItem().getOIDToObject().getColorById(null) ) );
- }
- else event.gc.setBackground( dispnodetocolor.get(dispnode) );
-
- int border=normalborder;
-
- if( objstatus.isMouseover(dispnode.getConnectedObject()) ){
- border=mouseborder;
- }
- event.gc.fillRectangle( r.x+border, r.y+border, r.width-2*border, r.height-2*border );
-
- dispnodetorectangle.put(dispnode, r);//save the current rectangle
- }
-
- }
+
+ /**
+ * Generate size of drawed rectangles.
+ *
+ * @return size of painted rectangles
+ */
+ protected void updateRectSize() {
+
+ int w, h;
+
+ final Point size = usingListener.getSize();
+ // Generate available size
+ w = size.x - marginWidth * 2;
+ h = size.y - marginHeight * 2;
+
+ if (COLUMNCOUNT <= 0)
+ COLUMNCOUNT = 1;
+
+ // Calculate how many rows have to be painted
+ rowcount = dispnodes.size() / COLUMNCOUNT;
+ if (dispnodes.size() % COLUMNCOUNT != 0)
+ rowcount++;
+
+ if (rowcount == 0)
+ return;
+
+ rectwidth = w / COLUMNCOUNT;
+
+ rectheight = h / rowcount;
}
-
+
}
diff --git a/rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/views/NodedisplayView.java b/rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/views/NodedisplayView.java
deleted file mode 100644
index 6831eecac..000000000
--- a/rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/views/NodedisplayView.java
+++ /dev/null
@@ -1,318 +0,0 @@
-package org.eclipse.ptp.rm.lml.ui.views;
-
-import java.util.List;
-import java.util.Stack;
-
-import org.eclipse.ptp.rm.lml.core.model.ILguiItem;
-import org.eclipse.ptp.rm.lml.internal.core.elements.Nodedisplay;
-import org.eclipse.ptp.rm.lml.ui.providers.DisplayNode;
-import org.eclipse.ptp.rm.lml.ui.providers.LguiWidget;
-import org.eclipse.ptp.rm.lml.ui.providers.NodedisplayComp;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.ScrolledComposite;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.graphics.Cursor;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.ScrollBar;
-
-/**
- * Parent composite of NodedisplayComp This class allows to zoom or switch the
- * viewports of nodedisplaycomps. Every nodedisplaycomp is connected with one
- * instance of this class. NodedisplayView represents one zoomable
- * NodedisplayComp.
- */
-public class NodedisplayView extends LguiWidget {
- /*
- * LML-Data-model for this view
- */
- private Nodedisplay model;
- /*
- * creates scrollbars surrounding nodedisplay
- */
- private final ScrolledComposite scrollpane;
- /*
- * root nodedisplay which is currently shown
- */
- private NodedisplayComp root = null;
-
- /*
- * Saves zoom-levels to zoom out later, saves full-implicit name of nodes to
- * create Displaynodes from these ids
- */
- private Stack<String> zoomstack = new Stack<String>();
-
- /*
- * Cursor to show while processing
- */
- private final Cursor waitcursor;
- /*
- * default cursor
- */
- private final Cursor defaultcursor;
-
- /**
- * Create a composite as surrounding component for NodedisplayComps. This
- * class encapsulates zooming functionality. It saves a stack
- *
- * @param pmodel
- * @param parent
- */
- public NodedisplayView(ILguiItem lgui, Nodedisplay pmodel, Composite parent) {
-
- super(lgui, parent, SWT.None);
-
- model = pmodel;
-
- setLayout(new FillLayout());
-
- scrollpane = new ScrolledComposite(this, SWT.H_SCROLL | SWT.V_SCROLL);
-
- if (lgui != null && model != null) {
- root = new NodedisplayComp(lgui, model, this, SWT.None);
- }
-
- // Create cursors
- defaultcursor = this.getCursor();
- waitcursor = new Cursor(this.getDisplay(), SWT.CURSOR_WAIT);
-
- addResizeListenerForScrollPane();
- }
-
- @Override
- public void dispose() {
- // Dispose created cursor
- waitcursor.dispose();
- }
-
- /**
- * @return currently shown nodedisplaycomp
- */
- public NodedisplayComp getRootNodedisplay() {
- return root;
- }
-
- /**
- * @return access to scrollpane, which contains the root-nodedisplay
- */
- public ScrolledComposite getScrollPane() {
- return scrollpane;
- }
-
- /**
- * Set node with impname as implicit name as root-node within this
- * nodedisplay-panel. Call this function only if model did not changed.
- *
- * @param impname
- * implicit name of a node, which identifies every node within a
- * nodedisplay
- * @return true, if root was changed, otherwise false
- */
- public boolean goToImpname(String impname) {
- return goToImpname(impname, false);
- }
-
- /**
- * Set node with impname as implicit name as root-node within this
- * nodedisplay-panel
- *
- * @param impname
- * implicit name of a node, which identifies every node within a
- * nodedisplay
- * @param modelChanged
- * if true a new nodedisplay is forced to be created, otherwise
- * only if the new impname differs from currently shown impname
- * @return true, if root was changed, otherwise false
- */
- public boolean goToImpname(String impname, boolean modelChanged) {
-
- if (lgui == null) {
- return false;
- }
-
- String shownimpname = null;
- if (root != null) {
- shownimpname = root.getShownImpname();
- }
-
- // A new panel has to be created if the model is new
- if (!modelChanged) {
- // Do not create a new panel if panel is already on the right view
- if (shownimpname == null) {
- if (impname == null) {
- return false;
- }
- } else if (shownimpname.equals(impname)) {
- /*
- * Do not create new panel, if current viewport is the same to
- * which this panel should be set
- */
- return false;
- }
- }
-
- NodedisplayComp newcomp = null;
-
- if (root != null) {
- root.dispose();// Delete old root-element
- System.gc();
- }
-
- if (impname != null) {
- DisplayNode newnode = DisplayNode.getDisplayNodeFromImpName(lgui, impname, model);
-
- newcomp = new NodedisplayComp(lgui, model, newnode, this, SWT.None);
- } else {
- /*
- * if impname is null => go up to root-level
- */
- newcomp = new NodedisplayComp(lgui, model, this, SWT.None);
- }
-
- root = newcomp;
-
- this.layout();
- root.layout();
-
- return true;
- }
-
- /**
- * The stack which saves the last zoom-levels is restarted
- */
- public void restartZoom() {
- zoomstack = new Stack<String>();
- }
-
- /**
- * Update view and repaint current data. This is done by creating a
- * completely new nodedisplay. Tries to go to the implicitname, which was
- * shown before.
- */
- @Override
- public void update() {
- super.update();
-
- String shownImpName = null;
- /*
- * if(root!=null) shownImpName = root.getShownImpname();
- */
- restartZoom();
- model = getNewModel();
-
- if (model != null) {
- goToImpname(shownImpName, true);
- }
- }
-
- /**
- * Call this update if lguiitem changes. This update is calles if another
- * system is monitored.
- *
- * @param lgui
- * new data-manager
- */
- public void update(ILguiItem lgui) {
- this.lgui = lgui;
-
- update();
- }
-
- public void zoomIn(String impname) {
- if (root == null) {
- return;
- }
-
- this.setCursor(waitcursor);
-
- String oldshown = root.getShownImpname();
-
- if (goToImpname(impname)) {
- if (oldshown == null) {
- oldshown = ""; //$NON-NLS-1$
- }
- zoomstack.push(oldshown);
- }
-
- this.setCursor(defaultcursor);
- }
-
- /**
- * Go one level higher in zoomstack
- */
- public void zoomOut() {
- this.setCursor(waitcursor);
-
- if (!zoomstack.isEmpty()) {
- String impname = zoomstack.pop();
- // Get back null-values
- if (impname.equals("")) { //$NON-NLS-1$
- impname = null;
- }
-
- // Switch view to node with impname
- goToImpname(impname);
- }
-
- this.setCursor(defaultcursor);
- }
-
- /**
- * Adds a listener, which changes scrollbar-increments on every resize.
- */
- private void addResizeListenerForScrollPane() {
-
- scrollpane.addControlListener(new ControlListener() {
-
- public void controlMoved(ControlEvent e) {
- }
-
- public void controlResized(ControlEvent e) {
- ScrollBar xbar = scrollpane.getHorizontalBar();
- ScrollBar ybar = scrollpane.getVerticalBar();
- if (xbar != null) {
- xbar.setPageIncrement(xbar.getThumb() / 2);
- xbar.setIncrement(xbar.getThumb() / 5);
- }
- if (ybar != null) {
- ybar.setPageIncrement(ybar.getThumb() / 2);
- ybar.setIncrement(ybar.getThumb() / 5);
- }
- }
- });
-
- }
-
- /**
- * Data has been updated. The new nodedisplay-model is needed. This function
- * searches for the nodedisplay-instance, which is the successor of the last
- * shown nodedisplay.
- *
- * @return new Nodedisplay-model
- */
- private Nodedisplay getNewModel() {
-
- if (lgui == null) {
- return null;
- }
-
- String nodedisplayId = ""; //$NON-NLS-1$
- if (model != null) {
- nodedisplayId = model.getId();
- }
-
- Nodedisplay res = lgui.getNodedisplayAccess().getNodedisplayById(nodedisplayId);
-
- if (res == null) {
- List<Nodedisplay> nodedisplays = lgui.getNodedisplayAccess().getNodedisplays();
-
- if (nodedisplays.size() > 0) {
- res = nodedisplays.get(0);
- }
- }
-
- return res;
- }
-
-}
diff --git a/rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/views/NodesView.java b/rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/views/NodesView.java
index ba73ab085..ac72d1eb1 100644
--- a/rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/views/NodesView.java
+++ b/rms/org.eclipse.ptp.rm.lml.ui/src/org/eclipse/ptp/rm/lml/ui/views/NodesView.java
@@ -27,16 +27,15 @@ import org.eclipse.ptp.rm.lml.core.listeners.ILMLListener;
import org.eclipse.ptp.rm.lml.core.model.ILguiItem;
import org.eclipse.ptp.rm.lml.internal.core.elements.ObjectType;
import org.eclipse.ptp.rm.lml.ui.UIUtils;
+import org.eclipse.ptp.rm.lml.ui.providers.NodedisplayViewZoomable;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.part.ViewPart;
/**
- * @author Claudia Knobloch
- *
- * Based on original work by Greg Watson, Clement Chu and Daniel (JD)
- * Barboza
+ * Based on original work by Greg Watson, Clement Chu and Daniel (JD)
+ * Barboza
*
*/
public class NodesView extends ViewPart {
@@ -119,7 +118,7 @@ public class NodesView extends ViewPart {
}
private Composite composite = null;
- private NodedisplayView nodedisplayView = null;
+ private NodedisplayViewZoomable nodedisplayView = null;
public Viewer viewer;
public ILguiItem fLguiItem = null;
private final ILMLListener lguiListener = new LguiListener();
@@ -142,6 +141,7 @@ public class NodesView extends ViewPart {
fLguiItem = lmlManager.getSelectedLguiItem();
lmlManager.addListener(lguiListener, this.getClass().getName());
+
fLguiItem = lmlManager.getSelectedLguiItem();
createNodedisplayView();
}
@@ -151,11 +151,6 @@ public class NodesView extends ViewPart {
lmlManager.removeListener(lguiListener);
}
- public void generateNodesdisplay() {
- fLguiItem = lmlManager.getSelectedLguiItem();
- createNodedisplayView();
- }
-
/*
* Method required so the class can extends ViewPart
*
@@ -168,7 +163,7 @@ public class NodesView extends ViewPart {
private void createNodedisplayView() {
if (!composite.isDisposed()) {
- nodedisplayView = new NodedisplayView(null, null, composite);
+ nodedisplayView = new NodedisplayViewZoomable(null, null, composite);
if (fLguiItem != null) {
nodedisplayView.update(fLguiItem);
}

Back to the top