Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordstadnik2005-11-17 07:16:07 -0500
committerdstadnik2005-11-17 07:16:07 -0500
commitf46ec7ddc358dc6c336a80ef06ac62c99aab98be (patch)
treed46bbf8936fae128ca08de350a08d2a5dc06c9c5 /devtools/org.eclipse.gmf.dev.insider
parent3d0d2da08ad0befa27d11e97ae54b4a42591f208 (diff)
downloadorg.eclipse.gmf-tooling-f46ec7ddc358dc6c336a80ef06ac62c99aab98be.tar.gz
org.eclipse.gmf-tooling-f46ec7ddc358dc6c336a80ef06ac62c99aab98be.tar.xz
org.eclipse.gmf-tooling-f46ec7ddc358dc6c336a80ef06ac62c99aab98be.zip
initial
Diffstat (limited to 'devtools/org.eclipse.gmf.dev.insider')
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/.classpath7
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/.cvsignore1
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/.project28
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/build.properties5
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/icons/insider.gifbin0 -> 130 bytes
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/icons/link.gifbin0 -> 118 bytes
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/icons/node.gifbin0 -> 124 bytes
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/plugin.xml66
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/schema/contentBuilders.exsd126
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/AbstractContentBuilder.java106
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/ContentBuilder.java45
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/ElementMetaInfo.java111
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/ElementUtil.java107
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/InsiderContext.java68
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/InsiderFacade.java143
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/ReferenceUtil.java66
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/ReflectionUtil.java37
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ContentBuilderManager.java177
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ContextEditPartContentBuilder.java42
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ContextFigureContentBuilder.java42
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/EditPartContentBuilder.java81
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/FigureContentBuilder.java76
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/InsiderAccess.java53
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/InsiderPlugin.java63
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/PresentationFactory.java126
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/PresentationFigure.java23
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/PresentationLink.java31
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/PresentationNode.java34
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/View.java91
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ViewFactory.java43
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ViewManager.java102
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/resources.properties2
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/InsiderActionGroup.java86
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/InsiderContentProvider.java97
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/InsiderLabelProvider.java110
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/InsiderView.java115
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/PresentationController.java109
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/PresentationView.java45
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/ReferenceOpener.java49
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/actions/MemorizeActiveEditorAction.java33
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/actions/OpenPresentationAction.java49
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/actions/ShowIdsAction.java36
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/actions/ShowSimpleTypesAction.java36
-rw-r--r--devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/actions/StatefulAction.java51
44 files changed, 2718 insertions, 0 deletions
diff --git a/devtools/org.eclipse.gmf.dev.insider/.classpath b/devtools/org.eclipse.gmf.dev.insider/.classpath
new file mode 100644
index 000000000..065ac06e1
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/devtools/org.eclipse.gmf.dev.insider/.cvsignore b/devtools/org.eclipse.gmf.dev.insider/.cvsignore
new file mode 100644
index 000000000..ba077a403
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/.cvsignore
@@ -0,0 +1 @@
+bin
diff --git a/devtools/org.eclipse.gmf.dev.insider/.project b/devtools/org.eclipse.gmf.dev.insider/.project
new file mode 100644
index 000000000..c6012637b
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.gmf.dev.insider</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/devtools/org.eclipse.gmf.dev.insider/build.properties b/devtools/org.eclipse.gmf.dev.insider/build.properties
new file mode 100644
index 000000000..6f1bf802b
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/build.properties
@@ -0,0 +1,5 @@
+source.insider.jar = src/
+output.insider.jar = bin/
+bin.includes = plugin.xml,\
+ insider.jar,\
+ icons/
diff --git a/devtools/org.eclipse.gmf.dev.insider/icons/insider.gif b/devtools/org.eclipse.gmf.dev.insider/icons/insider.gif
new file mode 100644
index 000000000..9dbb67d2b
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/icons/insider.gif
Binary files differ
diff --git a/devtools/org.eclipse.gmf.dev.insider/icons/link.gif b/devtools/org.eclipse.gmf.dev.insider/icons/link.gif
new file mode 100644
index 000000000..29a37c791
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/icons/link.gif
Binary files differ
diff --git a/devtools/org.eclipse.gmf.dev.insider/icons/node.gif b/devtools/org.eclipse.gmf.dev.insider/icons/node.gif
new file mode 100644
index 000000000..02cd0eb9a
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/icons/node.gif
Binary files differ
diff --git a/devtools/org.eclipse.gmf.dev.insider/plugin.xml b/devtools/org.eclipse.gmf.dev.insider/plugin.xml
new file mode 100644
index 000000000..7c37e5341
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/plugin.xml
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+<plugin
+ id="org.eclipse.gmf.dev.insider"
+ name="Insider"
+ version="1.0.0"
+ provider-name="Dmitri Stadnik"
+ class="org.eclipse.gmf.dev.insider.internal.InsiderPlugin">
+
+ <runtime>
+ <library name="insider.jar">
+ <export name="*"/>
+ </library>
+ </runtime>
+
+ <requires>
+ <import plugin="org.eclipse.core.runtime"/>
+ <import plugin="org.eclipse.ui"/>
+ <import plugin="org.eclipse.draw2d"/>
+ <import plugin="org.eclipse.gef"/>
+ </requires>
+
+ <extension-point id="contentBuilders" name="Content Builders" schema="schema/contentBuilders.exsd"/>
+
+ <extension
+ point="org.eclipse.gmf.dev.insider.contentBuilders">
+ <contentBuilder
+ id="context.figures"
+ description="Figure from context"
+ class="org.eclipse.gmf.dev.insider.internal.ContextFigureContentBuilder">
+ </contentBuilder>
+ <contentBuilder
+ id="figures"
+ description="Figures"
+ class="org.eclipse.gmf.dev.insider.internal.FigureContentBuilder">
+ </contentBuilder>
+ <contentBuilder
+ id="context.editParts"
+ description="Edit part from context"
+ class="org.eclipse.gmf.dev.insider.internal.ContextEditPartContentBuilder">
+ </contentBuilder>
+ <contentBuilder
+ id="editParts"
+ description="Edit parts"
+ class="org.eclipse.gmf.dev.insider.internal.EditPartContentBuilder">
+ </contentBuilder>
+ </extension>
+ <extension
+ point="org.eclipse.ui.views">
+ <view
+ name="Insider"
+ icon="icons/insider.gif"
+ category="org.eclipse.ui"
+ class="org.eclipse.gmf.dev.insider.internal.ui.InsiderView"
+ id="org.eclipse.gmf.dev.insider.InsiderView">
+ </view>
+ <view
+ name="Insider Presentation"
+ icon="icons/insider.gif"
+ category="org.eclipse.ui"
+ class="org.eclipse.gmf.dev.insider.internal.ui.PresentationView"
+ id="org.eclipse.gmf.dev.insider.PresentationView">
+ </view>
+ </extension>
+
+</plugin>
diff --git a/devtools/org.eclipse.gmf.dev.insider/schema/contentBuilders.exsd b/devtools/org.eclipse.gmf.dev.insider/schema/contentBuilders.exsd
new file mode 100644
index 000000000..703415d20
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/schema/contentBuilders.exsd
@@ -0,0 +1,126 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.gmf.dev.insider">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.gmf.dev.insider" id="contentBuilders" name="Content Builders"/>
+ </appInfo>
+ <documentation>
+ Content builders declared via this extension point will be used to construct Insider model.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <documentation>
+ Content builder contributions.
+ </documentation>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="0" maxOccurs="unbounded">
+ <element ref="contentBuilder"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="contentBuilder">
+ <annotation>
+ <documentation>
+ Content builder contribution.
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ Unique content builder id.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="description" type="string" use="required">
+ <annotation>
+ <documentation>
+ Description for the UI.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ Content builder class. Should implement ContentBuilder interface.
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ 1.0
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ See figure content builder contribution.
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/AbstractContentBuilder.java b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/AbstractContentBuilder.java
new file mode 100644
index 000000000..a608c9752
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/AbstractContentBuilder.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2005 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitri Stadnik (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.dev.insider;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.PointList;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.w3c.dom.Element;
+
+/**
+ * Base implementation with utility methods.
+ *
+ * @author dstadnik
+ */
+public abstract class AbstractContentBuilder implements ContentBuilder {
+
+ protected Element createObject(Element parent, Object object, String elementName) {
+ Element element = parent.getOwnerDocument().createElement(elementName);
+ parent.appendChild(element);
+ element.setAttribute(ElementMetaInfo.TYPE_ATTRIBUTE, object.getClass().getName());
+ createExtends(element, object.getClass());
+ return element;
+ }
+
+ protected void createBounds(Element parent, Rectangle bounds) {
+ Element element = parent.getOwnerDocument().createElement(ElementMetaInfo.BOUNDS_ELEMENT);
+ parent.appendChild(element);
+ element.setAttribute(ElementMetaInfo.X_ATTRIBUTE, String.valueOf(bounds.x));
+ element.setAttribute(ElementMetaInfo.Y_ATTRIBUTE, String.valueOf(bounds.y));
+ element.setAttribute(ElementMetaInfo.WIDTH_ATTRIBUTE, String.valueOf(bounds.width));
+ element.setAttribute(ElementMetaInfo.HEIGHT_ATTRIBUTE, String.valueOf(bounds.height));
+ }
+
+ protected void createPointList(Element parent, PointList pointList) {
+ Element element = parent.getOwnerDocument().createElement(ElementMetaInfo.POINT_LIST_ELEMENT);
+ parent.appendChild(element);
+ for (int i = 0; i < pointList.size(); i++) {
+ createPoint(element, pointList.getPoint(i));
+ }
+ }
+
+ protected void createPoint(Element parent, Point point) {
+ Element element = parent.getOwnerDocument().createElement(ElementMetaInfo.POINT_ELEMENT);
+ parent.appendChild(element);
+ element.setAttribute(ElementMetaInfo.X_ATTRIBUTE, String.valueOf(point.x));
+ element.setAttribute(ElementMetaInfo.Y_ATTRIBUTE, String.valueOf(point.y));
+ }
+
+ protected void createExtends(Element parent, Class clazz) {
+ Set ancestors = new HashSet();
+ addAncestors(clazz, ancestors);
+ Iterator i = ancestors.iterator();
+ while (i.hasNext()) {
+ String ancestor = (String) i.next();
+ if (isIgnoredAncestor(clazz, ancestor)) {
+ continue;
+ }
+ Element element = parent.getOwnerDocument().createElement(ElementMetaInfo.EXTENDS_ELEMENT);
+ parent.appendChild(element);
+ element.setAttribute(ElementMetaInfo.TYPE_ATTRIBUTE, ancestor);
+ }
+ }
+
+ protected boolean isIgnoredAncestor(Class clazz, String ancestor) {
+ return clazz.getName().equals(ancestor); // ignore self
+ }
+
+ protected void addAncestors(Class clazz, Set ancestors) {
+ if (clazz == null) {
+ return;
+ }
+ String name = clazz.getName();
+ if (Object.class.getName().equals(name)) {
+ return; // skip objects
+ }
+ ancestors.add(name);
+ addAncestors(clazz.getSuperclass(), ancestors);
+ Class[] interfaces = clazz.getInterfaces();
+ for (int i = 0; i < interfaces.length; i++) {
+ addAncestors(interfaces[i], ancestors);
+ }
+ }
+
+ public void setContext(InsiderContext context) {
+ myContext = context;
+ }
+
+ protected final InsiderContext getContext() {
+ return myContext;
+ }
+
+ private InsiderContext myContext;
+}
diff --git a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/ContentBuilder.java b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/ContentBuilder.java
new file mode 100644
index 000000000..fcd9a6d9e
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/ContentBuilder.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2005 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitri Stadnik (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.dev.insider;
+
+import java.util.List;
+
+import org.w3c.dom.Element;
+
+/**
+ * Content provider for Insider model.
+ * Insider model is a DOM tree.
+ *
+ * @author dstadnik
+ */
+public interface ContentBuilder {
+
+ public void setContext(InsiderContext context);
+
+ /**
+ * Contributes model data for the specified object.
+ * If this builder creates a child element then it should be
+ * returned so the further children may be contributed to it;
+ * return <code>null</code> otherwise.
+ */
+ public Element contribute(Element element, Object object);
+
+ /**
+ * Returns list of the object children in domain model.
+ * This list will never be modified.
+ *
+ * In most cases the first object asked for children
+ * is an InsiderContext. Content builder may cache it to
+ * acquire additional information later.
+ */
+ public List getChildren(Object object);
+}
diff --git a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/ElementMetaInfo.java b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/ElementMetaInfo.java
new file mode 100644
index 000000000..1947bd081
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/ElementMetaInfo.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2005 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitri Stadnik (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.dev.insider;
+
+/**
+ * @author dstadnik
+ */
+public class ElementMetaInfo {
+
+ private ElementMetaInfo() {}
+
+ /**
+ * Model root element.
+ */
+ public static final String VIEW_ELEMENT = "view"; //$NON-NLS-1$
+
+ /**
+ * Reference element. Poits to some other element in model.
+ * Id attribute is id of the referenced element.
+ */
+ public static final String REFERENCE_ELEMENT = "reference"; //$NON-NLS-1$
+
+ /**
+ * Edit part element. Represents all gef edit parts.
+ */
+ public static final String EDIT_PART_ELEMENT = "editPart"; //$NON-NLS-1$
+
+ /**
+ * Edit policy element. Represents all gef edit policies.
+ */
+ public static final String EDIT_POLICY_ELEMENT = "editPolicy"; //$NON-NLS-1$
+
+ /**
+ * Figure element. Represents all draw2d figures.
+ */
+ public static final String FIGURE_ELEMENT = "figure"; //$NON-NLS-1$
+
+ /**
+ * Specifies ancestor type. Used in figure and editPart.
+ */
+ public static final String EXTENDS_ELEMENT = "extends"; //$NON-NLS-1$
+
+ /**
+ * Bounds element. Used in figures that are not connections.
+ */
+ public static final String BOUNDS_ELEMENT = "bounds"; //$NON-NLS-1$
+
+ /**
+ * Represents PointList object. Contains a number of child
+ * point elements. Used in connection figures.
+ */
+ public static final String POINT_LIST_ELEMENT = "pointList"; //$NON-NLS-1$
+
+ /**
+ * Element that represents point.
+ */
+ public static final String POINT_ELEMENT = "point"; //$NON-NLS-1$
+
+ // attributes
+
+ /**
+ * View creation timestamp.
+ */
+ public static final String TIMESTAMP_ATTRIBUTE = "timestamp"; //$NON-NLS-1$
+
+ /**
+ * View description attribute.
+ */
+ public static final String DESCRIPTION_ATTRIBUTE = "description"; //$NON-NLS-1$
+
+ /**
+ * Unique id attribute. Corresponds to object hash code.
+ * Elements that have this attribute are tree nodes;
+ * other elements are complex node attributes.
+ */
+ public static final String ID_ATTRIBUTE = "id"; //$NON-NLS-1$
+
+ /**
+ * Fully qualified class name. Used in figure.
+ */
+ public static final String TYPE_ATTRIBUTE = "type"; //$NON-NLS-1$
+
+ /**
+ * X coordinate of bounds or a point.
+ */
+ public static final String X_ATTRIBUTE = "x"; //$NON-NLS-1$
+
+ /**
+ * Y coordinate of bounds or a point.
+ */
+ public static final String Y_ATTRIBUTE = "y"; //$NON-NLS-1$
+
+ /**
+ * Bounds width.
+ */
+ public static final String WIDTH_ATTRIBUTE = "width"; //$NON-NLS-1$
+
+ /**
+ * Bounds height.
+ */
+ public static final String HEIGHT_ATTRIBUTE = "height"; //$NON-NLS-1$
+}
diff --git a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/ElementUtil.java b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/ElementUtil.java
new file mode 100644
index 000000000..aba55c623
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/ElementUtil.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2005 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitri Stadnik (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.dev.insider;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * Utility methods to work with DOM.
+ *
+ * @author dstadnik
+ */
+public class ElementUtil {
+
+ public static final Element[] NO_ELEMENTS = new Element[0];
+
+ public static Element[] getChildren(Element element) {
+ if (element == null) {
+ return NO_ELEMENTS;
+ }
+ NodeList children = element.getChildNodes();
+ if (children.getLength() == 0) {
+ return NO_ELEMENTS;
+ }
+ List childElements = new ArrayList(children.getLength());
+ for (int i = 0; i < children.getLength(); i++) {
+ Node child = children.item(i);
+ if (child instanceof Element) {
+ childElements.add(child);
+ }
+ }
+ return (Element[]) childElements.toArray(new Element[childElements.size()]);
+ }
+
+ public static Element[] getChildren(Element element, String name) {
+ if (element == null) {
+ return NO_ELEMENTS;
+ }
+ NodeList children = element.getChildNodes();
+ if (children.getLength() == 0) {
+ return NO_ELEMENTS;
+ }
+ List childElements = new ArrayList(children.getLength());
+ for (int i = 0; i < children.getLength(); i++) {
+ Node child = children.item(i);
+ if (!(child instanceof Element)) {
+ continue;
+ }
+ Element childElement = (Element) child;
+ if (childElement.getNodeName().equals(name)) {
+ childElements.add(childElement);
+ }
+ }
+ return (Element[]) childElements.toArray(new Element[childElements.size()]);
+ }
+
+ public static boolean hasChildren(Element element) {
+ if (element == null) {
+ return false;
+ }
+ NodeList children = element.getChildNodes();
+ if (children.getLength() == 0) {
+ return false;
+ }
+ for (int i = 0; i < children.getLength(); i++) {
+ Node child = children.item(i);
+ if (child instanceof Element) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static boolean hasChildren(Element element, String name) {
+ if (element == null) {
+ return false;
+ }
+ NodeList children = element.getChildNodes();
+ if (children.getLength() == 0) {
+ return false;
+ }
+ for (int i = 0; i < children.getLength(); i++) {
+ Node child = children.item(i);
+ if (!(child instanceof Element)) {
+ continue;
+ }
+ Element childElement = (Element) child;
+ if (childElement.getNodeName().equals(name)) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
diff --git a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/InsiderContext.java b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/InsiderContext.java
new file mode 100644
index 000000000..4600d9230
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/InsiderContext.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2005 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitri Stadnik (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.dev.insider;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPartViewer;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * Context in which content builders work.
+ *
+ * @author dstadnik
+ */
+public class InsiderContext {
+
+ public InsiderContext() {}
+
+ public InsiderContext(IFigure figure) {
+ this();
+ myFigure = figure;
+ }
+
+ public InsiderContext(IFigure figure, EditPart editPart) {
+ this(figure);
+ myEditPart = editPart;
+ }
+
+ public InsiderContext(IFigure figure, EditPart editPart, EditPartViewer viewer) {
+ this(figure, editPart);
+ myViewer = viewer;
+ }
+
+ public InsiderContext(IFigure figure, EditPart editPart, EditPartViewer viewer, IWorkbenchPart workbenchPart) {
+ this(figure, editPart, viewer);
+ myWorkbenchPart = workbenchPart;
+ }
+
+ public IFigure getFigure() {
+ return myFigure;
+ }
+
+ public EditPart getEditPart() {
+ return myEditPart;
+ }
+
+ public EditPartViewer getViewer() {
+ return myViewer;
+ }
+
+ public IWorkbenchPart getWorkbenchPart() {
+ return myWorkbenchPart;
+ }
+
+ private IFigure myFigure;
+ private EditPart myEditPart;
+ private EditPartViewer myViewer;
+ private IWorkbenchPart myWorkbenchPart;
+}
diff --git a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/InsiderFacade.java b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/InsiderFacade.java
new file mode 100644
index 000000000..d1b0e027c
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/InsiderFacade.java
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2005 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitri Stadnik (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.dev.insider;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPartViewer;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.GraphicalViewer;
+import org.eclipse.gmf.dev.insider.internal.InsiderAccess;
+import org.eclipse.gmf.dev.insider.internal.View;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Entry point for the Insider clients.
+ *
+ * @author dstadnik
+ */
+public class InsiderFacade {
+
+ private InsiderFacade() {}
+
+ /**
+ * Create snapshot of the specified context.
+ * @return <code>true</code> if snapshot was made.
+ */
+ public static boolean memorize(InsiderContext context, String descrition) {
+ if (context == null) {
+ return false;
+ }
+ View view = InsiderAccess.getViewFactory().createView(context);
+ if (view == null) {
+ return false;
+ }
+ if (descrition != null) {
+ view.setDescription(descrition);
+ }
+ // trace {
+ //StringWriter writer = new StringWriter();
+ //view.serialize(writer);
+ //System.out.println(writer.getBuffer());
+ // }
+ InsiderAccess.getViewManager().add(view);
+ return true;
+ }
+
+ /**
+ * Create snapshot of the specified figure.
+ * @return <code>true</code> if snapshot was made.
+ */
+ public static boolean memorize(IFigure figure, String description) {
+ if (figure == null) {
+ return false;
+ }
+ InsiderContext context = new InsiderContext(figure);
+ return memorize(context, description);
+ }
+
+ /**
+ * Create snapshot of the specified edit part.
+ * @return <code>true</code> if snapshot was made.
+ */
+ public static boolean memorize(EditPart editPart, String description) {
+ if (editPart == null) {
+ return false;
+ }
+ IFigure figure = null;
+ if (editPart instanceof GraphicalEditPart) {
+ figure = ((GraphicalEditPart) editPart).getFigure();
+ }
+ InsiderContext context = new InsiderContext(figure, editPart);
+ return memorize(context, description);
+ }
+
+ /**
+ * Create snapshot of the GEF editor.
+ * @return <code>true</code> if snapshot was made.
+ */
+ public static boolean memorize(EditPartViewer viewer, String description) {
+ if (viewer == null) {
+ return false;
+ }
+ IFigure figure = null;
+ EditPart root = viewer.getRootEditPart();
+ if (root instanceof GraphicalEditPart) {
+ figure = ((GraphicalEditPart) root).getFigure();
+ while (figure.getParent() != null) {
+ figure = figure.getParent();
+ }
+ }
+ InsiderContext context = new InsiderContext(figure, root, viewer);
+ return memorize(context, description);
+ }
+
+ /**
+ * Create snapshot of the GEF editor
+ * hosted by the specified workbench part.
+ * @return <code>true</code> if snapshot was made.
+ */
+ public static boolean memorize(IWorkbenchPart part, String description) {
+ if (part == null) {
+ return false;
+ }
+ Object viewer = part.getAdapter(EditPartViewer.class);
+ if (viewer instanceof EditPartViewer) {
+ memorize((EditPartViewer) viewer, description);
+ }
+ viewer = part.getAdapter(GraphicalViewer.class);
+ if (viewer instanceof GraphicalViewer) {
+ memorize((GraphicalViewer) viewer, description);
+ }
+ return false;
+ }
+
+ /**
+ * Create snapshot of the GEF editor view
+ * hosted by the active editor part.
+ * @return <code>true</code> if snapshot was made.
+ */
+ public static boolean memorizeActiveEditor(String description) {
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (window == null) {
+ return false;
+ }
+ IWorkbenchPage page = window.getActivePage();
+ if (page == null) {
+ return false;
+ }
+ return memorize(page.getActiveEditor(), description);
+ }
+}
diff --git a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/ReferenceUtil.java b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/ReferenceUtil.java
new file mode 100644
index 000000000..50bfd42e1
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/ReferenceUtil.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2005 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitri Stadnik (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.dev.insider;
+
+import org.w3c.dom.Element;
+
+/**
+ * @author dstadnik
+ */
+public class ReferenceUtil {
+
+ private ReferenceUtil() {}
+
+ public static String getId(Object object) {
+ assert object != null;
+ return String.valueOf(object.hashCode());
+ }
+
+ public static boolean isReference(Element element) {
+ return ElementMetaInfo.REFERENCE_ELEMENT.equals(element.getNodeName());
+ }
+
+ public static String getReferencedId(Element element) {
+ if (!isReference(element)) {
+ return null;
+ }
+ return element.getAttribute(ElementMetaInfo.ID_ATTRIBUTE);
+ }
+
+ public static Element getReferencedElement(Element root, String targetId) {
+ if (!isReference(root)) {
+ String id = root.getAttribute(ElementMetaInfo.ID_ATTRIBUTE);
+ if (targetId.equals(id)) {
+ return root;
+ }
+ }
+ Element[] children = ElementUtil.getChildren(root);
+ for (int i = 0; i < children.length; i++) {
+ Element target = getReferencedElement(children[i], targetId);
+ if (target != null) {
+ return target;
+ }
+ }
+ return null;
+ }
+
+ public static void createReference(Element parent, Object target) {
+ String id = getId(target);
+ createReference(parent, id);
+ }
+
+ public static void createReference(Element parent, String id) {
+ Element element = parent.getOwnerDocument().createElement(ElementMetaInfo.REFERENCE_ELEMENT);
+ parent.appendChild(element);
+ element.setAttribute(ElementMetaInfo.ID_ATTRIBUTE, id);
+ }
+}
diff --git a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/ReflectionUtil.java b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/ReflectionUtil.java
new file mode 100644
index 000000000..ef5d2ac9f
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/ReflectionUtil.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2005 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitri Stadnik (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.dev.insider;
+
+import java.lang.reflect.Field;
+
+/**
+ * @author dstadnik
+ */
+public class ReflectionUtil {
+
+ private ReflectionUtil() {}
+
+ public static Object getFieldValue(Object object, String name, Class clazz) {
+ try {
+ if (clazz == null) {
+ clazz = object.getClass();
+ }
+ Field field = clazz.getDeclaredField(name);
+ field.setAccessible(true);
+ return field.get(object);
+ } catch (Throwable t) {
+ t.printStackTrace();
+ // ignore
+ }
+ return null;
+ }
+}
diff --git a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ContentBuilderManager.java b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ContentBuilderManager.java
new file mode 100644
index 000000000..a07695d2c
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ContentBuilderManager.java
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 2005 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitri Stadnik (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.dev.insider.internal;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Stack;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.gmf.dev.insider.ContentBuilder;
+import org.eclipse.gmf.dev.insider.ElementMetaInfo;
+import org.eclipse.gmf.dev.insider.InsiderContext;
+import org.eclipse.gmf.dev.insider.ReferenceUtil;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * @author dstadnik
+ */
+public class ContentBuilderManager {
+
+ // Further methods provide access to the model structure.
+ // Contributions are model nodes with id attribute.
+
+ public boolean isContribution(Element element) {
+ String id = element.getAttribute(ElementMetaInfo.ID_ATTRIBUTE);
+ return id != null && id.trim().length() > 0;
+ }
+
+ public Element getParentContribution(Element element) {
+ while (true) {
+ Node parent = element.getParentNode();
+ if (!(parent instanceof Element)) {
+ return null;
+ }
+ element = (Element) parent;
+ if (isContribution(element)) {
+ return element;
+ }
+ }
+ }
+
+ public Element[] getChildContributions(Element element) {
+ List contributions = new ArrayList();
+ addChildContributions(element, contributions);
+ return (Element[]) contributions.toArray(new Element[contributions.size()]);
+ }
+
+ private void addChildContributions(Element element, List contributions) {
+ NodeList children = element.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node child = children.item(i);
+ if (!(child instanceof Element)) {
+ continue;
+ }
+ Element childElement = (Element) child;
+ if (isContribution(childElement)) {
+ contributions.add(childElement);
+ } else {
+ addChildContributions(childElement, contributions);
+ }
+ }
+ }
+
+ public boolean hasChildContributions(Element element) {
+ NodeList children = element.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node child = children.item(i);
+ if (!(child instanceof Element)) {
+ continue;
+ }
+ Element childElement = (Element) child;
+ if (isContribution(childElement)) {
+ return true;
+ } else {
+ if (hasChildContributions(childElement)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Build model for the specified object using content builders.
+ */
+ public void contribute(Element element, Object object) {
+ if (object instanceof InsiderContext) {
+ setContext((InsiderContext) object);
+ }
+ contribute(element, object, new Stack());
+ setContext(null);
+ }
+
+ private void contribute(Element element, Object object, Stack parents) {
+ if (object == null) {
+ return;
+ }
+ String id = ReferenceUtil.getId(object);
+ if (parents.contains(id)) {
+ ReferenceUtil.createReference(element, id);
+ return;
+ }
+ for (int i = 0; i < getContentBuilders().size(); i++) {
+ ContentBuilder builder = (ContentBuilder) getContentBuilders().get(i);
+
+ if (object instanceof InsiderContext) {
+ contributeChildren(builder, element, object, parents);
+ continue;
+ }
+
+ Element contribution = builder.contribute(element, object);
+ if (contribution == null) {
+ contributeChildren(builder, element, object, parents);
+ } else {
+ contribution.setAttribute(ElementMetaInfo.ID_ATTRIBUTE, id);
+ parents.push(id);
+ contributeChildren(builder, contribution, object, parents);
+ parents.pop();
+ }
+ }
+ }
+
+ private void contributeChildren(ContentBuilder builder, Element element, Object object, Stack parents) {
+ List children = builder.getChildren(object);
+ if (children != null && !children.isEmpty()) {
+ for (int j = 0; j < children.size(); j++) {
+ contribute(element, children.get(j), parents);
+ }
+ }
+ }
+
+ private void setContext(InsiderContext context) {
+ for (int i = 0; i < getContentBuilders().size(); i++) {
+ ContentBuilder builder = (ContentBuilder) getContentBuilders().get(i);
+ builder.setContext(context);
+ }
+ }
+
+ private List getContentBuilders() {
+ if (myContentBuilders == null) {
+ myContentBuilders = new ArrayList();
+ addContentBuilders(myContentBuilders);
+ }
+ return myContentBuilders;
+ }
+
+ private void addContentBuilders(List list) {
+ String namespace = InsiderPlugin.getInstance().getBundle().getSymbolicName();
+ IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(namespace, "contentBuilders"); //$NON-NLS-1$
+ for (int i = 0; i < elements.length; i++) {
+ IConfigurationElement element = elements[i];
+ if (!"contentBuilder".equals(element.getName())) { //$NON-NLS-1$
+ continue;
+ }
+ try {
+ ContentBuilder contentBuilder = (ContentBuilder) element.createExecutableExtension("class"); //$NON-NLS-1$
+ list.add(contentBuilder);
+ } catch (Exception e) {
+ InsiderPlugin.logError(null, e);
+ }
+ }
+ }
+
+ private List myContentBuilders;
+}
diff --git a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ContextEditPartContentBuilder.java b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ContextEditPartContentBuilder.java
new file mode 100644
index 000000000..42da93e4c
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ContextEditPartContentBuilder.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2005 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitri Stadnik (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.dev.insider.internal;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.dev.insider.AbstractContentBuilder;
+import org.eclipse.gmf.dev.insider.InsiderContext;
+import org.w3c.dom.Element;
+
+/**
+ * @author dstadnik
+ */
+public class ContextEditPartContentBuilder extends AbstractContentBuilder {
+
+ public Element contribute(Element element, Object object) {
+ return null;
+ }
+
+ public List getChildren(Object object) {
+ if (object instanceof InsiderContext) {
+ InsiderContext context = (InsiderContext) object;
+ EditPart editPart = context.getEditPart();
+ if (editPart == null) {
+ return null;
+ }
+ return Collections.singletonList(editPart);
+ }
+ return null;
+ }
+}
diff --git a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ContextFigureContentBuilder.java b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ContextFigureContentBuilder.java
new file mode 100644
index 000000000..8df8be66e
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ContextFigureContentBuilder.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2005 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitri Stadnik (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.dev.insider.internal;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.gmf.dev.insider.AbstractContentBuilder;
+import org.eclipse.gmf.dev.insider.InsiderContext;
+import org.w3c.dom.Element;
+
+/**
+ * @author dstadnik
+ */
+public class ContextFigureContentBuilder extends AbstractContentBuilder {
+
+ public Element contribute(Element element, Object object) {
+ return null;
+ }
+
+ public List getChildren(Object object) {
+ if (object instanceof InsiderContext) {
+ InsiderContext context = (InsiderContext) object;
+ IFigure figure = context.getFigure();
+ if (figure == null) {
+ return null;
+ }
+ return Collections.singletonList(figure);
+ }
+ return null;
+ }
+}
diff --git a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/EditPartContentBuilder.java b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/EditPartContentBuilder.java
new file mode 100644
index 000000000..3e84ece91
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/EditPartContentBuilder.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2005 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitri Stadnik (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.dev.insider.internal;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.editparts.AbstractEditPart;
+import org.eclipse.gmf.dev.insider.AbstractContentBuilder;
+import org.eclipse.gmf.dev.insider.ElementMetaInfo;
+import org.eclipse.gmf.dev.insider.ReferenceUtil;
+import org.eclipse.gmf.dev.insider.ReflectionUtil;
+import org.w3c.dom.Element;
+
+/**
+ * @author dstadnik
+ */
+public class EditPartContentBuilder extends AbstractContentBuilder {
+
+ public Element contribute(Element element, Object object) {
+ if (object instanceof EditPart) {
+ EditPart editPart = (EditPart) object;
+ Element editPartElement = createObject(element, editPart, ElementMetaInfo.EDIT_PART_ELEMENT);
+ if (editPart instanceof GraphicalEditPart) {
+ IFigure figure = ((GraphicalEditPart) editPart).getFigure();
+ if (figure != null) {
+ ReferenceUtil.createReference(editPartElement, figure);
+ }
+ }
+ return editPartElement;
+ } else if (object instanceof EditPolicy) {
+ EditPolicy editPolicy = (EditPolicy) object;
+ return createObject(element, editPolicy, ElementMetaInfo.EDIT_POLICY_ELEMENT);
+ }
+ return null;
+ }
+
+ public List getChildren(Object object) {
+ if (object instanceof EditPart) {
+ EditPart editPart = (EditPart) object;
+ List allChildren = new ArrayList();
+ Object model = editPart.getModel();
+ if (model != null) {
+ allChildren.add(model);
+ }
+ allChildren.addAll(editPart.getChildren());
+ if (editPart instanceof GraphicalEditPart) {
+ GraphicalEditPart gEditPart = (GraphicalEditPart) editPart;
+ allChildren.addAll(gEditPart.getSourceConnections());
+ allChildren.addAll(gEditPart.getTargetConnections());
+ }
+ if (editPart instanceof AbstractEditPart) {
+ Object editPolicyKeysObject = ReflectionUtil.getFieldValue(editPart, "editPolicyKeys", AbstractEditPart.class);
+ if (editPolicyKeysObject instanceof List) {
+ List editPolicyKeys = (List) editPolicyKeysObject;
+ for (int i = 0; i < editPolicyKeys.size(); i++) {
+ EditPolicy editPolicy = editPart.getEditPolicy(editPolicyKeys.get(i));
+ if (editPolicy != null) {
+ allChildren.add(editPolicy);
+ }
+ }
+ }
+ }
+ return allChildren;
+ }
+ return null;
+ }
+}
diff --git a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/FigureContentBuilder.java b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/FigureContentBuilder.java
new file mode 100644
index 000000000..518674f8c
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/FigureContentBuilder.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2005 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitri Stadnik (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.dev.insider.internal;
+
+import java.util.List;
+
+import org.eclipse.draw2d.Connection;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPartViewer;
+import org.eclipse.gmf.dev.insider.AbstractContentBuilder;
+import org.eclipse.gmf.dev.insider.ElementMetaInfo;
+import org.eclipse.gmf.dev.insider.InsiderContext;
+import org.eclipse.gmf.dev.insider.ReferenceUtil;
+import org.w3c.dom.Element;
+
+/**
+ * @author dstadnik
+ */
+public class FigureContentBuilder extends AbstractContentBuilder {
+
+ public Element contribute(Element element, Object object) {
+ if (object instanceof IFigure) {
+ IFigure figure = (IFigure) object;
+ return createFigure(element, figure);
+ }
+ return null;
+ }
+
+ protected Element createFigure(Element parent, IFigure figure) {
+ Element element = createObject(parent, figure, ElementMetaInfo.FIGURE_ELEMENT);
+ if (figure instanceof Connection) {
+ Connection connection = (Connection) figure;
+ createPointList(element, connection.getPoints());
+ } else {
+ Rectangle bounds = figure.getBounds().getCopy();
+ figure.translateToAbsolute(bounds);
+ createBounds(element, bounds);
+ }
+ EditPart editPart = getController(figure);
+ if (editPart != null) {
+ ReferenceUtil.createReference(element, editPart);
+ }
+ return element;
+ }
+
+ public List getChildren(Object object) {
+ if (object instanceof IFigure) {
+ IFigure figure = (IFigure) object;
+ return figure.getChildren();
+ }
+ return null;
+ }
+
+ private EditPart getController(IFigure figure) {
+ InsiderContext context = getContext();
+ if (context == null) {
+ return null;
+ }
+ EditPartViewer viewer = context.getViewer();
+ if (viewer == null) {
+ return null;
+ }
+ return (EditPart) viewer.getVisualPartMap().get(figure);
+ }
+}
diff --git a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/InsiderAccess.java b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/InsiderAccess.java
new file mode 100644
index 000000000..04651edd8
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/InsiderAccess.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2005 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitri Stadnik (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.dev.insider.internal;
+
+/**
+ * @author dstadnik
+ */
+public class InsiderAccess {
+
+ private InsiderAccess() {}
+
+ public static ViewManager getViewManager() {
+ if (ourViewManager == null) {
+ ourViewManager = new ViewManager();
+ }
+ return ourViewManager;
+ }
+
+ public static ViewFactory getViewFactory() {
+ if (ourViewFactory == null) {
+ ourViewFactory = new ViewFactory();
+ }
+ return ourViewFactory;
+ }
+
+ public static ContentBuilderManager getContentBuilderManager() {
+ if (ourContentBuilderManager == null) {
+ ourContentBuilderManager = new ContentBuilderManager();
+ }
+ return ourContentBuilderManager;
+ }
+
+ public static PresentationFactory getPresentationFactory() {
+ if (ourPresentationFactory == null) {
+ ourPresentationFactory = new PresentationFactory();
+ }
+ return ourPresentationFactory;
+ }
+
+ private static ViewManager ourViewManager;
+ private static ViewFactory ourViewFactory;
+ private static ContentBuilderManager ourContentBuilderManager;
+ private static PresentationFactory ourPresentationFactory;
+}
diff --git a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/InsiderPlugin.java b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/InsiderPlugin.java
new file mode 100644
index 000000000..0ab3282bc
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/InsiderPlugin.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2005 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitri Stadnik (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.dev.insider.internal;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+public class InsiderPlugin extends AbstractUIPlugin {
+
+ public InsiderPlugin() {
+ ourInstance = this;
+ try {
+ myResourceBundle = ResourceBundle.getBundle("org.eclipse.gmf.dev.insider.internal.resources");
+ } catch (MissingResourceException x) {
+ myResourceBundle = null;
+ }
+ }
+
+ public static InsiderPlugin getInstance() {
+ return ourInstance;
+ }
+
+ public static String getResourceString(String key) {
+ ResourceBundle bundle = InsiderPlugin.getInstance().getResourceBundle();
+ try {
+ return bundle != null ? bundle.getString(key) : '!' + key + '!';
+ } catch (MissingResourceException e) {
+ return key;
+ }
+ }
+
+ public ResourceBundle getResourceBundle() {
+ return myResourceBundle;
+ }
+
+ public static void logError(String msg, Throwable exception) {
+ if (exception == null) {
+ exception = new Exception();
+ }
+ if (msg == null) {
+ msg = exception.toString();
+ }
+ String id = getInstance().getBundle().getSymbolicName();
+ IStatus status = new Status(IStatus.ERROR, id, 0, msg, exception);
+ getInstance().getLog().log(status);
+ }
+
+ private static InsiderPlugin ourInstance;
+ private ResourceBundle myResourceBundle;
+}
diff --git a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/PresentationFactory.java b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/PresentationFactory.java
new file mode 100644
index 000000000..acd61d149
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/PresentationFactory.java
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2005 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitri Stadnik (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.dev.insider.internal;
+
+import java.util.List;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.FreeformFigure;
+import org.eclipse.draw2d.FreeformLayer;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.geometry.PointList;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gmf.dev.insider.ElementMetaInfo;
+import org.eclipse.gmf.dev.insider.ElementUtil;
+import org.w3c.dom.Element;
+
+/**
+ * @author dstadnik
+ */
+public class PresentationFactory {
+
+ public FreeformFigure createPresentation(View view) {
+ FreeformLayer container = new FreeformLayer();
+ container.setOpaque(true);
+ container.setBackgroundColor(ColorConstants.white);
+ container.setForegroundColor(ColorConstants.gray);
+ addFigures(container, view.getElements());
+ return container;
+ }
+
+ private void addFigures(IFigure container, Element[] elements) {
+ for (int i = 0; i < elements.length; i++) {
+ Element element = elements[i];
+ if (!ElementMetaInfo.FIGURE_ELEMENT.equals(element.getNodeName())) {
+ continue;
+ }
+ PointList pointList = getPointList(element);
+ if (pointList != null) {
+ PresentationLink figure = new PresentationLink(element);
+ figure.setPoints(pointList);
+ container.add(figure);
+ addFigures(container, ElementUtil.getChildren(element, ElementMetaInfo.FIGURE_ELEMENT));
+ continue;
+ }
+ Rectangle bounds = getBounds(element);
+ if (bounds != null) {
+ PresentationNode figure = new PresentationNode(element);
+ figure.setBounds(bounds);
+ container.add(figure);
+ addFigures(container, ElementUtil.getChildren(element, ElementMetaInfo.FIGURE_ELEMENT));
+ continue;
+ }
+ }
+ }
+
+ private Rectangle getBounds(Element element) {
+ Element[] boundsElements = ElementUtil.getChildren(element, ElementMetaInfo.BOUNDS_ELEMENT);
+ if (boundsElements.length < 1) {
+ return null;
+ }
+ Element boundsElement = boundsElements[0];
+ try {
+ int x = Integer.parseInt(boundsElement.getAttribute(ElementMetaInfo.X_ATTRIBUTE));
+ int y = Integer.parseInt(boundsElement.getAttribute(ElementMetaInfo.Y_ATTRIBUTE));
+ int width = Integer.parseInt(boundsElement.getAttribute(ElementMetaInfo.WIDTH_ATTRIBUTE));
+ int height = Integer.parseInt(boundsElement.getAttribute(ElementMetaInfo.HEIGHT_ATTRIBUTE));
+ return new Rectangle(x, y, width, height);
+ } catch (NumberFormatException nfe) {
+ String msg = InsiderPlugin.getResourceString("error.invalidBounds"); //$NON-NLS-1$
+ InsiderPlugin.logError(msg, nfe);
+ }
+ return null;
+ }
+
+ private PointList getPointList(Element element) {
+ Element[] pointListElements = ElementUtil.getChildren(element, ElementMetaInfo.POINT_LIST_ELEMENT);
+ if (pointListElements.length < 1) {
+ return null;
+ }
+ Element pointListElement = pointListElements[0];
+ PointList pointList = new PointList();
+ Element[] pointElements = ElementUtil.getChildren(pointListElement, ElementMetaInfo.POINT_ELEMENT);
+ try {
+ for (int i = 0; i < pointElements.length; i++) {
+ Element pointElement = pointElements[i];
+ int x = Integer.parseInt(pointElement.getAttribute(ElementMetaInfo.X_ATTRIBUTE));
+ int y = Integer.parseInt(pointElement.getAttribute(ElementMetaInfo.Y_ATTRIBUTE));
+ pointList.addPoint(x, y);
+ }
+ return pointList;
+ } catch (NumberFormatException nfe) {
+ String msg = InsiderPlugin.getResourceString("error.invalidPoint"); //$NON-NLS-1$
+ InsiderPlugin.logError(msg, nfe);
+ }
+ return null;
+ }
+
+ public boolean traverse(IFigure figure, PresentationVisitor visitor) {
+ if (figure instanceof PresentationFigure) {
+ if (visitor.accept((PresentationFigure) figure)) {
+ return true;
+ }
+ }
+ List children = figure.getChildren();
+ for (int i = 0; i < children.size(); i++) {
+ if (traverse((IFigure) children.get(i), visitor)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public interface PresentationVisitor {
+
+ public boolean accept(PresentationFigure figure);
+ }
+}
diff --git a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/PresentationFigure.java b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/PresentationFigure.java
new file mode 100644
index 000000000..283a07c83
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/PresentationFigure.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2005 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitri Stadnik (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.dev.insider.internal;
+
+import org.eclipse.draw2d.IFigure;
+import org.w3c.dom.Element;
+
+/**
+ * @author dstadnik
+ */
+public interface PresentationFigure extends IFigure {
+
+ public Element getFigureElement();
+}
diff --git a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/PresentationLink.java b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/PresentationLink.java
new file mode 100644
index 000000000..63593190b
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/PresentationLink.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2005 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitri Stadnik (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.dev.insider.internal;
+
+import org.eclipse.draw2d.Polyline;
+import org.w3c.dom.Element;
+
+/**
+ * @author dstadnik
+ */
+public class PresentationLink extends Polyline implements PresentationFigure {
+
+ public PresentationLink(Element figureElement) {
+ myFigureElement = figureElement;
+ }
+
+ public Element getFigureElement() {
+ return myFigureElement;
+ }
+
+ private Element myFigureElement;
+}
diff --git a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/PresentationNode.java b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/PresentationNode.java
new file mode 100644
index 000000000..c0aca57a2
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/PresentationNode.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2005 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitri Stadnik (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.dev.insider.internal;
+
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.RectangleFigure;
+import org.w3c.dom.Element;
+
+/**
+ * @author dstadnik
+ */
+public class PresentationNode extends RectangleFigure implements PresentationFigure {
+
+ public PresentationNode(Element figureElement) {
+ myFigureElement = figureElement;
+ }
+
+ public Element getFigureElement() {
+ return myFigureElement;
+ }
+
+ protected void fillShape(Graphics graphics) {}
+
+ private Element myFigureElement;
+}
diff --git a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/View.java b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/View.java
new file mode 100644
index 000000000..42e2978b4
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/View.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2005 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitri Stadnik (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.dev.insider.internal;
+
+import java.io.Writer;
+
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.eclipse.gmf.dev.insider.ElementMetaInfo;
+import org.eclipse.gmf.dev.insider.ElementUtil;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * @author dstadnik
+ */
+public class View {
+
+ public View(Document document) {
+ assert document != null;
+ myDocument = document;
+ }
+
+ public String getTimestamp() {
+ Element element = getViewElement(false);
+ if (element == null) {
+ return null;
+ }
+ return element.getAttribute(ElementMetaInfo.TIMESTAMP_ATTRIBUTE);
+ }
+
+ public String getDescription() {
+ Element element = getViewElement(false);
+ if (element == null) {
+ return null;
+ }
+ return element.getAttribute(ElementMetaInfo.DESCRIPTION_ATTRIBUTE);
+ }
+
+ public void setDescription(String description) {
+ Element element = getViewElement(true);
+ element.setAttribute(ElementMetaInfo.DESCRIPTION_ATTRIBUTE, description);
+ }
+
+ public Element[] getElements() {
+ Element element = getViewElement(false);
+ return ElementUtil.getChildren(element);
+ }
+
+ public boolean hasElements() {
+ Element element = getViewElement(false);
+ return ElementUtil.hasChildren(element);
+ }
+
+ public void serialize(Writer writer) {
+ try {
+ TransformerFactory factory = TransformerFactory.newInstance();
+ Transformer transformer = factory.newTransformer();
+ transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
+ transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$
+ transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
+ transformer.transform(new DOMSource(myDocument), new StreamResult(writer));
+ } catch (Exception e) {
+ InsiderPlugin.logError(null, e);
+ }
+ }
+
+ protected Element getViewElement(boolean create) {
+ Element element = myDocument.getDocumentElement();
+ if (element == null && create) {
+ element = myDocument.createElement(ElementMetaInfo.VIEW_ELEMENT);
+ myDocument.appendChild(element);
+ }
+ return element;
+ }
+
+ private Document myDocument;
+}
diff --git a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ViewFactory.java b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ViewFactory.java
new file mode 100644
index 000000000..61dbe82aa
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ViewFactory.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2005 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitri Stadnik (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.dev.insider.internal;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.eclipse.gmf.dev.insider.ElementMetaInfo;
+import org.eclipse.gmf.dev.insider.InsiderContext;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * @author dstadnik
+ */
+public class ViewFactory {
+
+ public View createView(InsiderContext context) {
+ String timestamp = String.valueOf(System.currentTimeMillis());
+ try {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ Document document = builder.newDocument();
+ Element element = document.createElement(ElementMetaInfo.VIEW_ELEMENT);
+ element.setAttribute(ElementMetaInfo.TIMESTAMP_ATTRIBUTE, timestamp);
+ document.appendChild(element);
+ InsiderAccess.getContentBuilderManager().contribute(element, context);
+ return new View(document);
+ } catch (Exception e) {
+ InsiderPlugin.logError(null, e);
+ }
+ return null;
+ }
+}
diff --git a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ViewManager.java b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ViewManager.java
new file mode 100644
index 000000000..25e4b97ed
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ViewManager.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2005 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitri Stadnik (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.dev.insider.internal;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.w3c.dom.Element;
+
+/**
+ * @author dstadnik
+ */
+public class ViewManager {
+
+ public static final String CONTENTS_PROPERTY = "contents"; //$NON-NLS-1$
+
+ public int getViewCount() {
+ return myViews.size();
+ }
+
+ public View[] getViews() {
+ return (View[]) myViews.toArray(new View[myViews.size()]);
+ }
+
+ public View getView(int i) {
+ return (View) myViews.get(i);
+ }
+
+ public View getView(Element element) {
+ return (View) myViewElements.get(element);
+ }
+
+ public void add(View view) {
+ assert view != null;
+ View[] oldViews = getViews();
+ myViews.add(view);
+ Element[] elements = view.getElements();
+ for (int i = 0; i < elements.length; i++) {
+ myViewElements.put(elements[i], view);
+ }
+ View[] newViews = getViews();
+ myPropertyChangeListeners.firePropertyChange(CONTENTS_PROPERTY, oldViews, newViews);
+ }
+
+ public void remove(int i) {
+ View[] oldViews = getViews();
+ View view = (View) myViews.remove(i);
+ if (view != null) {
+ Element[] elements = view.getElements();
+ for (int j = 0; j < elements.length; j++) {
+ myViewElements.remove(elements[j]);
+ }
+ }
+ View[] newViews = getViews();
+ myPropertyChangeListeners.firePropertyChange(CONTENTS_PROPERTY, oldViews, newViews);
+ }
+
+ public void remove(View view) {
+ assert view != null;
+ View[] oldViews = getViews();
+ myViews.remove(view);
+ Element[] elements = view.getElements();
+ for (int j = 0; j < elements.length; j++) {
+ myViewElements.remove(elements[j]);
+ }
+ View[] newViews = getViews();
+ myPropertyChangeListeners.firePropertyChange(CONTENTS_PROPERTY, oldViews, newViews);
+ }
+
+ public void removeAll() {
+ View[] oldViews = getViews();
+ myViews.clear();
+ myViewElements.clear();
+ View[] newViews = getViews();
+ myPropertyChangeListeners.firePropertyChange(CONTENTS_PROPERTY, oldViews, newViews);
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ myPropertyChangeListeners.addPropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ myPropertyChangeListeners.removePropertyChangeListener(listener);
+ }
+
+ private List myViews = new ArrayList(); // : View
+ private Map myViewElements = new HashMap(); // root view element : Element -> view : View
+ private PropertyChangeSupport myPropertyChangeListeners = new PropertyChangeSupport(this);
+}
diff --git a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/resources.properties b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/resources.properties
new file mode 100644
index 000000000..65f8b26aa
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/resources.properties
@@ -0,0 +1,2 @@
+error.invalidBounds=Invalid bounds value
+error.invalidPoint=Invalid point value
diff --git a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/InsiderActionGroup.java b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/InsiderActionGroup.java
new file mode 100644
index 000000000..c9d4e7a5a
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/InsiderActionGroup.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2005 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitri Stadnik (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.dev.insider.internal.ui;
+
+import org.eclipse.gmf.dev.insider.internal.InsiderAccess;
+import org.eclipse.gmf.dev.insider.internal.ui.actions.MemorizeActiveEditorAction;
+import org.eclipse.gmf.dev.insider.internal.ui.actions.OpenPresentationAction;
+import org.eclipse.gmf.dev.insider.internal.ui.actions.ShowIdsAction;
+import org.eclipse.gmf.dev.insider.internal.ui.actions.ShowSimpleTypesAction;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.actions.ActionGroup;
+import org.eclipse.ui.part.DrillDownAdapter;
+
+/**
+ * @author dstadnik
+ */
+public class InsiderActionGroup extends ActionGroup {
+
+ public InsiderActionGroup(InsiderView view) {
+ TreeViewer viewer = view.getViewer();
+ myDrill = new DrillDownAdapter(viewer);
+ myMemorizeActiveEditorAction = new MemorizeActiveEditorAction();
+ myOpenPresentationAction = new OpenPresentationAction(view);
+ myShowSimpleTypesAction = new ShowSimpleTypesAction(view);
+ view.setShowSimpleTypes(myShowSimpleTypesAction.isChecked());
+ myShowIdsAction = new ShowIdsAction(view);
+ view.setShowIds(myShowIdsAction.isChecked());
+ myClearAction = new Action("Clear") {
+
+ public void run() {
+ InsiderAccess.getViewManager().removeAll();
+ }
+ };
+ }
+
+ public void fillContextMenu(IMenuManager manager) {
+ manager.add(myMemorizeActiveEditorAction);
+ manager.add(myOpenPresentationAction);
+ manager.add(myShowSimpleTypesAction);
+ manager.add(myShowIdsAction);
+ manager.add(new Separator());
+ myDrill.addNavigationActions(manager);
+ manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+ }
+
+ public void fillActionBars(IActionBars actionBars) {
+ fillLocalPullDown(actionBars.getMenuManager());
+ fillLocalToolBar(actionBars.getToolBarManager());
+ }
+
+ private void fillLocalPullDown(IMenuManager manager) {
+ manager.add(myShowSimpleTypesAction);
+ manager.add(myShowIdsAction);
+ manager.add(myClearAction);
+ manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+ }
+
+ private void fillLocalToolBar(IToolBarManager manager) {
+ manager.add(myMemorizeActiveEditorAction);
+ manager.add(new Separator());
+ myDrill.addNavigationActions(manager);
+ }
+
+ private ShowSimpleTypesAction myShowSimpleTypesAction;
+ private ShowIdsAction myShowIdsAction;
+ private OpenPresentationAction myOpenPresentationAction;
+ private MemorizeActiveEditorAction myMemorizeActiveEditorAction;
+ private IAction myClearAction;
+ private DrillDownAdapter myDrill;
+}
diff --git a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/InsiderContentProvider.java b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/InsiderContentProvider.java
new file mode 100644
index 000000000..049a2056c
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/InsiderContentProvider.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2005 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitri Stadnik (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.dev.insider.internal.ui;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import org.eclipse.gmf.dev.insider.internal.InsiderAccess;
+import org.eclipse.gmf.dev.insider.internal.View;
+import org.eclipse.gmf.dev.insider.internal.ViewManager;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.w3c.dom.Element;
+
+/**
+ * @author dstadnik
+ */
+public class InsiderContentProvider implements ITreeContentProvider {
+
+ public Object getParent(Object object) {
+ if (object instanceof Element) {
+ Element element = (Element) object;
+ View view = InsiderAccess.getViewManager().getView(element);
+ if (view != null) {
+ return view;
+ }
+ return InsiderAccess.getContentBuilderManager().getParentContribution(element);
+ } else if (object instanceof View) {
+ return InsiderAccess.getViewManager();
+ }
+ return null;
+ }
+
+ public Object[] getChildren(Object parentObject) {
+ if (parentObject instanceof Element) {
+ Element element = (Element) parentObject;
+ return InsiderAccess.getContentBuilderManager().getChildContributions(element);
+ } else if (parentObject instanceof View) {
+ View view = (View) parentObject;
+ return view.getElements();
+ } else if (parentObject instanceof ViewManager) {
+ ViewManager manager = (ViewManager) parentObject;
+ return manager.getViews();
+ }
+ return null;
+ }
+
+ public boolean hasChildren(Object parentObject) {
+ if (parentObject instanceof Element) {
+ Element element = (Element) parentObject;
+ return InsiderAccess.getContentBuilderManager().hasChildContributions(element);
+ } else if (parentObject instanceof View) {
+ View view = (View) parentObject;
+ return view.hasElements();
+ } else if (parentObject instanceof ViewManager) {
+ ViewManager manager = (ViewManager) parentObject;
+ return manager.getViewCount() > 0;
+ }
+ return false;
+ }
+
+ public Object[] getElements(Object inputObject) {
+ return getChildren(inputObject);
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ myViewer = viewer;
+ if (oldInput instanceof ViewManager) {
+ ((ViewManager) oldInput).removePropertyChangeListener(myViewManagerListener);
+ }
+ if (newInput instanceof ViewManager) {
+ ((ViewManager) newInput).addPropertyChangeListener(myViewManagerListener);
+ }
+ }
+
+ public void dispose() {}
+
+ private PropertyChangeListener myViewManagerListener = new PropertyChangeListener() {
+
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (ViewManager.CONTENTS_PROPERTY.equals(evt.getPropertyName()) && myViewer != null) {
+ myViewer.refresh();
+ }
+ }
+ };
+
+ private Viewer myViewer;
+}
diff --git a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/InsiderLabelProvider.java b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/InsiderLabelProvider.java
new file mode 100644
index 000000000..8525cc565
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/InsiderLabelProvider.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2005 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitri Stadnik (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.dev.insider.internal.ui;
+
+import java.net.URL;
+
+import org.eclipse.gmf.dev.insider.ElementMetaInfo;
+import org.eclipse.gmf.dev.insider.ElementUtil;
+import org.eclipse.gmf.dev.insider.ReferenceUtil;
+import org.eclipse.gmf.dev.insider.internal.InsiderPlugin;
+import org.eclipse.gmf.dev.insider.internal.View;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.w3c.dom.Element;
+
+/**
+ * @author dstadnik
+ */
+public class InsiderLabelProvider extends LabelProvider {
+
+ public String getText(Object object) {
+ if (object instanceof View) {
+ View view = (View) object;
+ StringBuffer buffer = new StringBuffer();
+ String description = view.getDescription();
+ if (description != null) {
+ buffer.append(description);
+ buffer.append(" / "); //$NON-NLS-1$
+ }
+ buffer.append(view.getTimestamp());
+ return buffer.toString();
+ } else if (object instanceof Element) {
+ Element element = (Element) object;
+ String targetId = ReferenceUtil.getReferencedId(element);
+ if (targetId != null) {
+ return "reference to " + targetId;
+ }
+ String type = element.getAttribute(ElementMetaInfo.TYPE_ATTRIBUTE);
+ if (isShowSimpleTypes()) {
+ type = type.substring(type.lastIndexOf('.') + 1);
+ }
+ if (isShowIds()) {
+ String id = element.getAttribute(ElementMetaInfo.ID_ATTRIBUTE);
+ if (id != null) {
+ type += ' ' + id;
+ }
+ }
+ return type;
+ }
+ return super.getText(object);
+ }
+
+ public Image getImage(Object object) {
+ if (object instanceof View) {
+ return getInsiderImage("icons/insider.gif");
+ } else if (object instanceof Element) {
+ Element element = (Element) object;
+ String name = element.getNodeName();
+ if (ElementMetaInfo.FIGURE_ELEMENT.equals(name)) {
+ if (ElementUtil.hasChildren(element, ElementMetaInfo.POINT_LIST_ELEMENT)) {
+ return getInsiderImage("icons/link.gif");
+ }
+ return getInsiderImage("icons/node.gif");
+ }
+ return null;
+ }
+ return super.getImage(object);
+ }
+
+ private Image getInsiderImage(String path) {
+ ImageRegistry registry = InsiderPlugin.getInstance().getImageRegistry();
+ Image image = registry.get(path);
+ if (image == null) {
+ URL url = InsiderPlugin.getInstance().getBundle().getEntry(path);
+ registry.put(path, ImageDescriptor.createFromURL(url));
+ image = registry.get(path);
+ }
+ return image;
+ }
+
+ public final boolean isShowSimpleTypes() {
+ return myShowSimpleTypes;
+ }
+
+ public void setShowSimpleTypes(boolean showSimpleTypes) {
+ myShowSimpleTypes = showSimpleTypes;
+ }
+
+ public final boolean isShowIds() {
+ return myShowIds;
+ }
+
+ public void setShowIds(boolean showIds) {
+ myShowIds = showIds;
+ }
+
+ private boolean myShowSimpleTypes;
+ private boolean myShowIds;
+}
diff --git a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/InsiderView.java b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/InsiderView.java
new file mode 100644
index 000000000..78de2b51e
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/InsiderView.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2005 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitri Stadnik (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.dev.insider.internal.ui;
+
+import org.eclipse.gmf.dev.insider.internal.InsiderAccess;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.ui.part.ViewPart;
+
+public class InsiderView extends ViewPart {
+
+ public void createPartControl(Composite parent) {
+ myViewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+ myViewer.setContentProvider(new InsiderContentProvider());
+ myViewer.setLabelProvider(new InsiderLabelProvider());
+ myViewer.setInput(InsiderAccess.getViewManager());
+ myPresentationController = new PresentationController(getViewSite());
+ myActionGroup = new InsiderActionGroup(this);
+ hookContextMenu();
+ myViewer.addOpenListener(new ReferenceOpener());
+ myViewer.addSelectionChangedListener(myPresentationController);
+ myViewer.addDoubleClickListener(new IDoubleClickListener() {
+
+ public void doubleClick(DoubleClickEvent event) {
+ IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+ if (selection.size() != 1) {
+ return;
+ }
+ Object selected = selection.getFirstElement();
+ TreeViewer viewer = (TreeViewer) event.getViewer();
+ if (viewer.getExpandedState(selected)) {
+ viewer.collapseToLevel(selected, 1);
+ } else {
+ viewer.expandToLevel(selected, 1);
+ }
+ }
+ });
+ myActionGroup.fillActionBars(getViewSite().getActionBars());
+ }
+
+ public void setFocus() {
+ myViewer.getControl().setFocus();
+ }
+
+ private void hookContextMenu() {
+ MenuManager menuMgr = new MenuManager(getViewSite().getId());
+ menuMgr.setRemoveAllWhenShown(true);
+ menuMgr.addMenuListener(new IMenuListener() {
+
+ public void menuAboutToShow(IMenuManager manager) {
+ myActionGroup.fillContextMenu(manager);
+ }
+ });
+ Menu menu = menuMgr.createContextMenu(myViewer.getControl());
+ myViewer.getControl().setMenu(menu);
+ getSite().registerContextMenu(menuMgr, myViewer);
+ }
+
+ public final boolean isShowSimpleTypes() {
+ return getLabelProvider().isShowSimpleTypes();
+ }
+
+ public void setShowSimpleTypes(boolean showSimpleTypes) {
+ if (getLabelProvider().isShowSimpleTypes() == showSimpleTypes) {
+ return;
+ }
+ getLabelProvider().setShowSimpleTypes(showSimpleTypes);
+ myViewer.refresh(true);
+ }
+
+ public final boolean isShowIds() {
+ return getLabelProvider().isShowIds();
+ }
+
+ public void setShowIds(boolean showIds) {
+ if (getLabelProvider().isShowIds() == showIds) {
+ return;
+ }
+ getLabelProvider().setShowIds(showIds);
+ myViewer.refresh(true);
+ }
+
+ private InsiderLabelProvider getLabelProvider() {
+ return (InsiderLabelProvider) myViewer.getLabelProvider();
+ }
+
+ public PresentationController getPresentationController() {
+ return myPresentationController;
+ }
+
+ public TreeViewer getViewer() {
+ return myViewer;
+ }
+
+ private TreeViewer myViewer;
+ private PresentationController myPresentationController;
+ private InsiderActionGroup myActionGroup;
+}
diff --git a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/PresentationController.java b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/PresentationController.java
new file mode 100644
index 000000000..f21fd2f65
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/PresentationController.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2005 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitri Stadnik (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.dev.insider.internal.ui;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.FreeformFigure;
+import org.eclipse.draw2d.FreeformLayer;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.gef.LayerConstants;
+import org.eclipse.gmf.dev.insider.internal.InsiderAccess;
+import org.eclipse.gmf.dev.insider.internal.InsiderPlugin;
+import org.eclipse.gmf.dev.insider.internal.PresentationFigure;
+import org.eclipse.gmf.dev.insider.internal.PresentationLink;
+import org.eclipse.gmf.dev.insider.internal.PresentationNode;
+import org.eclipse.gmf.dev.insider.internal.View;
+import org.eclipse.gmf.dev.insider.internal.PresentationFactory.PresentationVisitor;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.ui.IViewSite;
+
+/**
+ * @author dstadnik
+ */
+public class PresentationController implements ISelectionChangedListener {
+
+ public PresentationController(IViewSite viewSite) {
+ assert viewSite != null;
+ myViewSite = viewSite;
+ }
+
+ public void open(View view) {
+ FreeformFigure presentation = InsiderAccess.getPresentationFactory().createPresentation(view);
+ PresentationView presentationView = getPresentationView(true);
+ if (presentationView != null) {
+ if (presentationView.getContents().getLayer(LayerConstants.PRIMARY_LAYER) != null) {
+ presentationView.getContents().removeLayer(LayerConstants.PRIMARY_LAYER);
+ }
+ presentationView.getContents().add(presentation, LayerConstants.PRIMARY_LAYER);
+ }
+ }
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ PresentationView presentationView = getPresentationView(false);
+ if (presentationView == null) {
+ return;
+ }
+ final List elements = ((IStructuredSelection) event.getSelection()).toList();
+ final List figures = new ArrayList(elements.size());
+ InsiderAccess.getPresentationFactory().traverse(presentationView.getContents(), new PresentationVisitor() {
+
+ public boolean accept(PresentationFigure figure) {
+ if (elements.contains(figure.getFigureElement())) {
+ figures.add(figure);
+ }
+ return false;
+ }
+ });
+ if (presentationView.getContents().getLayer(LayerConstants.FEEDBACK_LAYER) != null) {
+ presentationView.getContents().removeLayer(LayerConstants.FEEDBACK_LAYER);
+ }
+ FreeformLayer feedbackLayer = new FreeformLayer();
+ for (int i = 0; i < figures.size(); i++) {
+ PresentationFigure figure = (PresentationFigure) figures.get(i);
+ IFigure feedbackFigure;
+ if (figure instanceof PresentationLink) {
+ feedbackFigure = new PresentationLink(null);
+ ((PresentationLink) feedbackFigure).setPoints(((PresentationLink) figure).getPoints());
+ } else {
+ feedbackFigure = new PresentationNode(null);
+ feedbackFigure.setBounds(figure.getBounds());
+ }
+ feedbackFigure.setForegroundColor(ColorConstants.blue);
+ feedbackLayer.add(feedbackFigure);
+ }
+ presentationView.getContents().addLayerAfter(feedbackLayer, LayerConstants.FEEDBACK_LAYER, LayerConstants.PRIMARY_LAYER);
+ }
+
+ private PresentationView getPresentationView(boolean create) {
+ try {
+ if (create) {
+ return (PresentationView) getViewSite().getPage().showView("org.eclipse.gmf.dev.insider.PresentationView"); //$NON-NLS-1$
+ } else {
+ return (PresentationView) getViewSite().getPage().findView("org.eclipse.gmf.dev.insider.PresentationView"); //$NON-NLS-1$
+ }
+ } catch (Exception e) {
+ InsiderPlugin.logError(null, e);
+ }
+ return null;
+ }
+
+ private IViewSite getViewSite() {
+ return myViewSite;
+ }
+
+ private IViewSite myViewSite;
+}
diff --git a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/PresentationView.java b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/PresentationView.java
new file mode 100644
index 000000000..7bc90a9ce
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/PresentationView.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2005 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitri Stadnik (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.dev.insider.internal.ui;
+
+import org.eclipse.draw2d.FigureCanvas;
+import org.eclipse.draw2d.FreeformLayeredPane;
+import org.eclipse.draw2d.FreeformViewport;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.part.ViewPart;
+
+/**
+ * @author dstadnik
+ */
+public class PresentationView extends ViewPart {
+
+ public void createPartControl(Composite parent) {
+ myContents = new FreeformLayeredPane();
+ FreeformViewport viewPort = new FreeformViewport();
+ viewPort.setContents(myContents);
+ myControl = new FigureCanvas(parent);
+ myControl.setContents(viewPort);
+ }
+
+ public void setFocus() {
+ if (myControl != null && !myControl.isDisposed()) {
+ myControl.setFocus();
+ }
+ }
+
+ public FreeformLayeredPane getContents() {
+ return myContents;
+ }
+
+ private FreeformLayeredPane myContents;
+ private FigureCanvas myControl;
+}
diff --git a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/ReferenceOpener.java b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/ReferenceOpener.java
new file mode 100644
index 000000000..6b0f5c733
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/ReferenceOpener.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2005 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitri Stadnik (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.dev.insider.internal.ui;
+
+import org.eclipse.gmf.dev.insider.ReferenceUtil;
+import org.eclipse.jface.viewers.IOpenListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.OpenEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.w3c.dom.Element;
+
+/**
+ * @author dstadnik
+ */
+public class ReferenceOpener implements IOpenListener {
+
+ public void open(OpenEvent event) {
+ IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+ if (selection.size() != 1) {
+ return;
+ }
+ Object selected = selection.getFirstElement();
+ if (!(selected instanceof Element)) {
+ return;
+ }
+ Element element = (Element) selected;
+ String targetId = ReferenceUtil.getReferencedId(element);
+ if (targetId == null) {
+ return;
+ }
+ Element root = element.getOwnerDocument().getDocumentElement();
+ Element target = ReferenceUtil.getReferencedElement(root, targetId);
+ if (target == null) {
+ return;
+ }
+ TreeViewer viewer = (TreeViewer) event.getViewer();
+ viewer.setSelection(new StructuredSelection(target), true);
+ }
+}
diff --git a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/actions/MemorizeActiveEditorAction.java b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/actions/MemorizeActiveEditorAction.java
new file mode 100644
index 000000000..6578c8b17
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/actions/MemorizeActiveEditorAction.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitri Stadnik (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.dev.insider.internal.ui.actions;
+
+import org.eclipse.gmf.dev.insider.InsiderFacade;
+import org.eclipse.jface.action.Action;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * @author dstadnik
+ */
+public class MemorizeActiveEditorAction extends Action {
+
+ public MemorizeActiveEditorAction() {
+ setText("Memorize");
+ setToolTipText("Memorize contents of the active GEF editor");
+ setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_NEW_WIZARD));
+ }
+
+ public void run() {
+ InsiderFacade.memorizeActiveEditor("interactive");
+ }
+}
diff --git a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/actions/OpenPresentationAction.java b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/actions/OpenPresentationAction.java
new file mode 100644
index 000000000..ba02218d0
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/actions/OpenPresentationAction.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2005 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitri Stadnik (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.dev.insider.internal.ui.actions;
+
+import org.eclipse.gmf.dev.insider.internal.View;
+import org.eclipse.gmf.dev.insider.internal.ui.InsiderView;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.w3c.dom.Element;
+
+/**
+ * @author dstadnik
+ */
+public class OpenPresentationAction extends Action {
+
+ public OpenPresentationAction(InsiderView insiderView) {
+ assert insiderView != null;
+ myInsiderView = insiderView;
+ setText("Open Presentation");
+ }
+
+ public void run() {
+ IStructuredSelection selection = (IStructuredSelection) myInsiderView.getViewer().getSelection();
+ if (selection.size() != 1) {
+ return;
+ }
+ Object selected = selection.getFirstElement();
+ View view = null;
+ if (selected instanceof View) {
+ view = (View) selected;
+ } else if (selected instanceof Element) {
+ // TODO : find view for the selected element
+ }
+ if (view != null) {
+ myInsiderView.getPresentationController().open(view);
+ }
+ }
+
+ private InsiderView myInsiderView;
+}
diff --git a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/actions/ShowIdsAction.java b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/actions/ShowIdsAction.java
new file mode 100644
index 000000000..2605dad21
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/actions/ShowIdsAction.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2005 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitri Stadnik (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.dev.insider.internal.ui.actions;
+
+import org.eclipse.gmf.dev.insider.internal.ui.InsiderView;
+
+/**
+ * @author dstadnik
+ */
+public class ShowIdsAction extends StatefulAction {
+
+ public ShowIdsAction(InsiderView view) {
+ super("Identifiers");
+ myView = view;
+ }
+
+ protected String getKey() {
+ return "ids";
+ }
+
+ protected void saveState() {
+ super.saveState();
+ myView.setShowIds(isChecked());
+ }
+
+ private InsiderView myView;
+}
diff --git a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/actions/ShowSimpleTypesAction.java b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/actions/ShowSimpleTypesAction.java
new file mode 100644
index 000000000..0459f8403
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/actions/ShowSimpleTypesAction.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2005 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitri Stadnik (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.dev.insider.internal.ui.actions;
+
+import org.eclipse.gmf.dev.insider.internal.ui.InsiderView;
+
+/**
+ * @author dstadnik
+ */
+public class ShowSimpleTypesAction extends StatefulAction {
+
+ public ShowSimpleTypesAction(InsiderView view) {
+ super("Simple Types");
+ myView = view;
+ }
+
+ protected String getKey() {
+ return "simpleTypes";
+ }
+
+ protected void saveState() {
+ super.saveState();
+ myView.setShowSimpleTypes(isChecked());
+ }
+
+ private InsiderView myView;
+}
diff --git a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/actions/StatefulAction.java b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/actions/StatefulAction.java
new file mode 100644
index 000000000..31a8bca0c
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/actions/StatefulAction.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2005 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitri Stadnik (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.dev.insider.internal.ui.actions;
+
+import org.eclipse.gmf.dev.insider.internal.InsiderPlugin;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+
+/**
+ * @author dstadnik
+ */
+abstract class StatefulAction extends Action {
+
+ public StatefulAction(String text) {
+ super(text, AS_CHECK_BOX);
+ restoreState();
+ addPropertyChangeListener(new IPropertyChangeListener() {
+
+ public void propertyChange(PropertyChangeEvent event) {
+ if (CHECKED.equals(event.getProperty())) {
+ saveState();
+ }
+ }
+ });
+ }
+
+ protected abstract String getKey();
+
+ protected void restoreState() {
+ setChecked(getStore().getBoolean(getKey()));
+ }
+
+ protected void saveState() {
+ getStore().setValue(getKey(), isChecked());
+ }
+
+ protected IPreferenceStore getStore() {
+ return InsiderPlugin.getInstance().getPreferenceStore();
+ }
+}

Back to the top