diff options
Diffstat (limited to 'devtools')
84 files changed, 0 insertions, 5000 deletions
diff --git a/devtools/org.eclipse.gmf.dev.insider/.classpath b/devtools/org.eclipse.gmf.dev.insider/.classpath deleted file mode 100644 index 065ac06e1..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/.classpath +++ /dev/null @@ -1,7 +0,0 @@ -<?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 deleted file mode 100644 index ba077a403..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -bin diff --git a/devtools/org.eclipse.gmf.dev.insider/.project b/devtools/org.eclipse.gmf.dev.insider/.project deleted file mode 100644 index c6012637b..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/.project +++ /dev/null @@ -1,28 +0,0 @@ -<?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 deleted file mode 100644 index 6f1bf802b..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/build.properties +++ /dev/null @@ -1,5 +0,0 @@ -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 Binary files differdeleted file mode 100644 index 9dbb67d2b..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/icons/insider.gif +++ /dev/null diff --git a/devtools/org.eclipse.gmf.dev.insider/icons/link.gif b/devtools/org.eclipse.gmf.dev.insider/icons/link.gif Binary files differdeleted file mode 100644 index 29a37c791..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/icons/link.gif +++ /dev/null diff --git a/devtools/org.eclipse.gmf.dev.insider/icons/node.gif b/devtools/org.eclipse.gmf.dev.insider/icons/node.gif Binary files differdeleted file mode 100644 index 02cd0eb9a..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/icons/node.gif +++ /dev/null diff --git a/devtools/org.eclipse.gmf.dev.insider/plugin.xml b/devtools/org.eclipse.gmf.dev.insider/plugin.xml deleted file mode 100644 index 7c37e5341..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/plugin.xml +++ /dev/null @@ -1,66 +0,0 @@ -<?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 deleted file mode 100644 index 703415d20..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/schema/contentBuilders.exsd +++ /dev/null @@ -1,126 +0,0 @@ -<?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 deleted file mode 100644 index a608c9752..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/AbstractContentBuilder.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * 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 deleted file mode 100644 index fcd9a6d9e..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/ContentBuilder.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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 deleted file mode 100644 index 1947bd081..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/ElementMetaInfo.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * 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 deleted file mode 100644 index aba55c623..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/ElementUtil.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * 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 deleted file mode 100644 index 4600d9230..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/InsiderContext.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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 deleted file mode 100644 index d1b0e027c..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/InsiderFacade.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * 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 deleted file mode 100644 index 50bfd42e1..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/ReferenceUtil.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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 deleted file mode 100644 index ef5d2ac9f..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/ReflectionUtil.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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 deleted file mode 100644 index a07695d2c..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ContentBuilderManager.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * 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 deleted file mode 100644 index 42da93e4c..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ContextEditPartContentBuilder.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 deleted file mode 100644 index 8df8be66e..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ContextFigureContentBuilder.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 deleted file mode 100644 index 3edd0727e..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/EditPartContentBuilder.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 policiesObject = ReflectionUtil.getFieldValue(editPart, "policies", AbstractEditPart.class); - if (policiesObject instanceof Object[]) { - Object[] policies = (Object[]) policiesObject; - for (int i = 0; i < policies.length; i += 2) { - EditPolicy editPolicy = (EditPolicy) policies[i + 1]; - 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 deleted file mode 100644 index 518674f8c..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/FigureContentBuilder.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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 deleted file mode 100644 index 04651edd8..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/InsiderAccess.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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 deleted file mode 100644 index 0ab3282bc..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/InsiderPlugin.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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 deleted file mode 100644 index acd61d149..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/PresentationFactory.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * 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 deleted file mode 100644 index 283a07c83..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/PresentationFigure.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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 deleted file mode 100644 index 63593190b..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/PresentationLink.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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 deleted file mode 100644 index c0aca57a2..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/PresentationNode.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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 deleted file mode 100644 index 42e2978b4..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/View.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * 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 deleted file mode 100644 index 61dbe82aa..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ViewFactory.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 deleted file mode 100644 index 25e4b97ed..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ViewManager.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * 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 deleted file mode 100644 index 65f8b26aa..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/resources.properties +++ /dev/null @@ -1,2 +0,0 @@ -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 deleted file mode 100644 index 98f1885a7..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/InsiderActionGroup.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * 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.ShowBoundsAction; -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()); - myShowBoundsAction = new ShowBoundsAction(view); - view.setShowBounds(myShowBoundsAction.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(myShowBoundsAction); - 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(myShowBoundsAction); - 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 ShowBoundsAction myShowBoundsAction; - 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 deleted file mode 100644 index 049a2056c..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/InsiderContentProvider.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * 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 deleted file mode 100644 index 0ceb88a98..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/InsiderLabelProvider.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * 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; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -/** - * @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; - } - } - if (isShowBounds()) { - NodeList children = element.getChildNodes(); - for (int i = 0; i < children.getLength(); i++) { - Node child = children.item(i); - if (child instanceof Element && ElementMetaInfo.BOUNDS_ELEMENT.equals(child.getNodeName())) { - Element boundsElement = (Element) child; - StringBuffer sb = new StringBuffer(); - sb.append(" / ["); - sb.append(boundsElement.getAttribute(ElementMetaInfo.X_ATTRIBUTE)); - sb.append(','); - sb.append(boundsElement.getAttribute(ElementMetaInfo.Y_ATTRIBUTE)); - sb.append(','); - sb.append(boundsElement.getAttribute(ElementMetaInfo.WIDTH_ATTRIBUTE)); - sb.append(','); - sb.append(boundsElement.getAttribute(ElementMetaInfo.HEIGHT_ATTRIBUTE)); - sb.append("]"); - type += sb; - } - } - } - 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; - } - - public final boolean isShowBounds() { - return myShowBounds; - } - - public void setShowBounds(boolean showBounds) { - myShowBounds = showBounds; - } - - private boolean myShowSimpleTypes; - private boolean myShowIds; - private boolean myShowBounds; -} 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 deleted file mode 100644 index 7e573911c..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/InsiderView.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * 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); - } - - public final boolean isShowBounds() { - return getLabelProvider().isShowBounds(); - } - - public void setShowBounds(boolean showBounds) { - if (getLabelProvider().isShowBounds() == showBounds) { - return; - } - getLabelProvider().setShowBounds(showBounds); - 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 deleted file mode 100644 index f21fd2f65..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/PresentationController.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * 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 deleted file mode 100644 index 7bc90a9ce..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/PresentationView.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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 deleted file mode 100644 index 6b0f5c733..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/ReferenceOpener.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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 deleted file mode 100644 index 6578c8b17..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/actions/MemorizeActiveEditorAction.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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 deleted file mode 100644 index ba02218d0..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/actions/OpenPresentationAction.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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/ShowBoundsAction.java b/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/actions/ShowBoundsAction.java deleted file mode 100644 index 729e9c75d..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/actions/ShowBoundsAction.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2007 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: - * Dmitry 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 ShowBoundsAction extends StatefulAction { - - public ShowBoundsAction(InsiderView view) { - super("Bounds"); - myView = view; - } - - protected String getKey() { - return "bounds"; - } - - protected void saveState() { - super.saveState(); - myView.setShowBounds(isChecked()); - } - - private InsiderView myView; -} 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 deleted file mode 100644 index 2605dad21..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/actions/ShowIdsAction.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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 deleted file mode 100644 index 0459f8403..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/actions/ShowSimpleTypesAction.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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 deleted file mode 100644 index 31a8bca0c..000000000 --- a/devtools/org.eclipse.gmf.dev.insider/src/org/eclipse/gmf/dev/insider/internal/ui/actions/StatefulAction.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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(); - } -} diff --git a/devtools/org.eclipse.gmf.dev.runtime/.classpath b/devtools/org.eclipse.gmf.dev.runtime/.classpath deleted file mode 100644 index 751c8f2e5..000000000 --- a/devtools/org.eclipse.gmf.dev.runtime/.classpath +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" path="src"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> - <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> - <classpathentry kind="output" path="bin"/> -</classpath> diff --git a/devtools/org.eclipse.gmf.dev.runtime/.cvsignore b/devtools/org.eclipse.gmf.dev.runtime/.cvsignore deleted file mode 100644 index ba077a403..000000000 --- a/devtools/org.eclipse.gmf.dev.runtime/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -bin diff --git a/devtools/org.eclipse.gmf.dev.runtime/.project b/devtools/org.eclipse.gmf.dev.runtime/.project deleted file mode 100644 index fecbfa142..000000000 --- a/devtools/org.eclipse.gmf.dev.runtime/.project +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>org.eclipse.gmf.dev.runtime</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.runtime/META-INF/MANIFEST.MF b/devtools/org.eclipse.gmf.dev.runtime/META-INF/MANIFEST.MF deleted file mode 100644 index 355610e06..000000000 --- a/devtools/org.eclipse.gmf.dev.runtime/META-INF/MANIFEST.MF +++ /dev/null @@ -1,9 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: GMF Runtime Dev Extension -Bundle-SymbolicName: org.eclipse.gmf.dev.runtime;singleton:=true -Bundle-Version: 1.0.0 -Bundle-Localization: plugin -Require-Bundle: org.eclipse.gmf.dev, - org.eclipse.gmf.runtime.diagram.ui -Bundle-Vendor: eclipse.org diff --git a/devtools/org.eclipse.gmf.dev.runtime/build.properties b/devtools/org.eclipse.gmf.dev.runtime/build.properties deleted file mode 100644 index 34d2e4d2d..000000000 --- a/devtools/org.eclipse.gmf.dev.runtime/build.properties +++ /dev/null @@ -1,4 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - . diff --git a/devtools/org.eclipse.gmf.dev.runtime/plugin.xml b/devtools/org.eclipse.gmf.dev.runtime/plugin.xml deleted file mode 100644 index 43e84ab47..000000000 --- a/devtools/org.eclipse.gmf.dev.runtime/plugin.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<?eclipse version="3.0"?> - -<plugin> - - <extension - point="org.eclipse.gmf.dev.editPartRequestFilters"> - <category - name="GMF" - class="org.eclipse.gmf.dev.runtime.ExtEditPartRequestFiltersProvider"> - </category> - </extension> - <extension - point="org.eclipse.gmf.dev.editPartTraceContributors"> - <contributor - class="org.eclipse.gmf.dev.runtime.ExtEditPartTraceContributor"> - </contributor> - </extension> - -</plugin> diff --git a/devtools/org.eclipse.gmf.dev.runtime/src/org/eclipse/gmf/dev/runtime/ExtEditPartRequestFiltersProvider.java b/devtools/org.eclipse.gmf.dev.runtime/src/org/eclipse/gmf/dev/runtime/ExtEditPartRequestFiltersProvider.java deleted file mode 100644 index 1aacc0b0c..000000000 --- a/devtools/org.eclipse.gmf.dev.runtime/src/org/eclipse/gmf/dev/runtime/ExtEditPartRequestFiltersProvider.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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.runtime; - -import org.eclipse.gmf.dev.EditPartRequestFiltersProvider; - -/** - * @author dstadnik - */ -public class ExtEditPartRequestFiltersProvider implements EditPartRequestFiltersProvider { - - public Class getConstants() { - return org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants.class; - } -} diff --git a/devtools/org.eclipse.gmf.dev.runtime/src/org/eclipse/gmf/dev/runtime/ExtEditPartTraceContributor.java b/devtools/org.eclipse.gmf.dev.runtime/src/org/eclipse/gmf/dev/runtime/ExtEditPartTraceContributor.java deleted file mode 100644 index b7d57ee99..000000000 --- a/devtools/org.eclipse.gmf.dev.runtime/src/org/eclipse/gmf/dev/runtime/ExtEditPartTraceContributor.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * 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.runtime; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.Request; -import org.eclipse.gef.commands.Command; -import org.eclipse.gmf.dev.CommandCreatedEvent; -import org.eclipse.gmf.dev.DevPlugin; -import org.eclipse.gmf.dev.DevUtils; -import org.eclipse.gmf.dev.EditPartTraceConstructor; -import org.eclipse.gmf.dev.EditPartTraceContributor; -import org.eclipse.gmf.dev.EditPartTraceRecord; -import org.eclipse.gmf.runtime.common.core.command.ICommand; -import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand; -import org.eclipse.gmf.runtime.diagram.core.edithelpers.CreateElementRequestAdapter; -import org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy; -import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy; -import org.eclipse.gmf.runtime.diagram.ui.commands.SemanticCreateCommand; -import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest; -import org.eclipse.gmf.runtime.diagram.ui.requests.EditCommandRequestWrapper; -import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; -import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest; - -/** - * @author dstadnik - */ -public class ExtEditPartTraceContributor implements EditPartTraceContributor { - - public void contribute(List<EditPartTraceRecord> kids, EditPart editPart) { - } - - public void contribute(List<EditPartTraceRecord> kids, Request request) { - if (request instanceof EditCommandRequestWrapper) { - IEditCommandRequest realRequest = ((EditCommandRequestWrapper) request).getEditCommandRequest(); - if (realRequest != null) { - kids.add(createRequestNode(realRequest)); - } - } - if (request instanceof CreateViewAndElementRequest) { - CreateViewAndElementRequest cveRequest = (CreateViewAndElementRequest) request; - CreateElementRequestAdapter ceAdapter = cveRequest.getViewAndElementDescriptor().getCreateElementRequestAdapter(); - if (ceAdapter != null) { - CreateElementRequest ceRequest = (CreateElementRequest) ceAdapter.getAdapter(CreateElementRequest.class); - if (ceRequest != null) { - kids.add(createRequestNode(ceRequest)); - } - } - } - } - - public static EditPartTraceRecord createRequestNode(IEditCommandRequest request) { - List<EditPartTraceRecord> kids = new ArrayList<EditPartTraceRecord>(); - // kids.add(new EditPartTraceRecord("edit helper context " + request.getEditHelperContext())); - if (request instanceof CreateElementRequest) { - kids.add(new EditPartTraceRecord("element type " + ((CreateElementRequest) request).getElementType(), DevPlugin.INFO_IMAGE)); - } - List elementsToEdit = request.getElementsToEdit(); - if (elementsToEdit != null) { - for (Object elementToEdit : elementsToEdit) { - kids.add(new EditPartTraceRecord("element to edit " + elementToEdit)); - } - } - Map parameters = request.getParameters(); - if (parameters != null) { - for (Object key : parameters.keySet()) { - kids.add(new EditPartTraceRecord(String.valueOf(key) + '=' + parameters.get(key), DevPlugin.PARAMETER_IMAGE)); - } - } - return new EditPartTraceRecord(getLabel(request), DevPlugin.REQUEST_IMAGE, kids.toArray(new EditPartTraceRecord[kids.size()])); - } - - private static String getLabel(IEditCommandRequest request) { - String label = DevUtils.getFullClassName(request); - if (request.getLabel() != null) { - label += '<' + request.getLabel() + '>'; - } - return label; - } - - public void contribute(List<EditPartTraceRecord> kids, Command command, CommandCreatedEvent event) { - if (command instanceof ICommandProxy) { - ICommand realCommand = ((ICommandProxy) command).getICommand(); - if (realCommand != null) { - kids.add(createCommandNode(realCommand, event)); - } - } - if (command instanceof IAdaptable) { - org.eclipse.emf.common.command.Command delegate = (org.eclipse.emf.common.command.Command) ((IAdaptable) command).getAdapter(org.eclipse.emf.common.command.Command.class); - if (delegate != null) { - kids.add(createCommandNode(delegate, event)); - } - } - } - - public static EditPartTraceRecord createCommandNode(ICommand command, CommandCreatedEvent event) { - List<EditPartTraceRecord> kids = new ArrayList<EditPartTraceRecord>(); - Object source = event.getSource(command); - if (source != null) { - kids.add(new EditPartTraceRecord("from " + DevUtils.getFullClassName(source))); - } - if (command instanceof ICompositeCommand) { - Iterator subCommands = ((ICompositeCommand) command).iterator(); - while (subCommands.hasNext()) { - kids.add(createCommandNode((ICommand) subCommands.next(), event)); - } - } - if (command instanceof CommandProxy) { - Command realCommand = ((CommandProxy) command).getCommand(); - if (realCommand != null) { - kids.add(EditPartTraceConstructor.createCommandNode(realCommand, event)); - } - } - if (command instanceof SemanticCreateCommand) { - ICommand realCommand = (ICommand) DevUtils.getFieldValue(command, "realSemanticCommand"); - if (realCommand != null) { - kids.add(createCommandNode(realCommand, event)); - } - } - if (command instanceof IAdaptable) { - org.eclipse.emf.common.command.Command delegate = (org.eclipse.emf.common.command.Command) ((IAdaptable) command).getAdapter(org.eclipse.emf.common.command.Command.class); - if (delegate != null) { - kids.add(createCommandNode(delegate, event)); - } - } - return new EditPartTraceRecord(getLabel(command), getImage(command), kids.toArray(new EditPartTraceRecord[kids.size()])); - } - - private static String getLabel(ICommand command) { - String label = DevUtils.getFullClassName(command); - if (command.getLabel() != null) { - label += '<' + command.getLabel() + '>'; - } - return label; - } - - private static String getImage(ICommand command) { - String id = DevPlugin.COMMANDX_IMAGE; - try { - if (command.canExecute()) { - id = DevPlugin.COMMAND_IMAGE; - } - } catch (Exception e) { - // ignore - } - return id; - } - - public static EditPartTraceRecord createCommandNode(org.eclipse.emf.common.command.Command command, CommandCreatedEvent event) { - List<EditPartTraceRecord> kids = new ArrayList<EditPartTraceRecord>(); - Object source = event.getSource(command); - if (source != null) { - kids.add(new EditPartTraceRecord("from " + DevUtils.getFullClassName(source))); - } - if (command instanceof org.eclipse.emf.common.command.CompoundCommand) { - for (org.eclipse.emf.common.command.Command subCommand : (List<? extends org.eclipse.emf.common.command.Command>) ((org.eclipse.emf.common.command.CompoundCommand) command) - .getCommandList()) { - kids.add(createCommandNode(subCommand, event)); - } - } - return new EditPartTraceRecord(getLabel(command), getImage(command), kids.toArray(new EditPartTraceRecord[kids.size()])); - } - - private static String getLabel(org.eclipse.emf.common.command.Command command) { - String label = DevUtils.getFullClassName(command); - if (command.getLabel() != null) { - label += '<' + command.getLabel() + '>'; - } - return label; - } - - private static String getImage(org.eclipse.emf.common.command.Command command) { - String id = DevPlugin.COMMANDX_IMAGE; - try { - if (command.canExecute()) { - id = DevPlugin.COMMAND_IMAGE; - } - } catch (Exception e) { - // ignore - } - return id; - } -}
\ No newline at end of file diff --git a/devtools/org.eclipse.gmf.dev/.classpath b/devtools/org.eclipse.gmf.dev/.classpath deleted file mode 100644 index 751c8f2e5..000000000 --- a/devtools/org.eclipse.gmf.dev/.classpath +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" path="src"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> - <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> - <classpathentry kind="output" path="bin"/> -</classpath> diff --git a/devtools/org.eclipse.gmf.dev/.cvsignore b/devtools/org.eclipse.gmf.dev/.cvsignore deleted file mode 100644 index ba077a403..000000000 --- a/devtools/org.eclipse.gmf.dev/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -bin diff --git a/devtools/org.eclipse.gmf.dev/.options b/devtools/org.eclipse.gmf.dev/.options deleted file mode 100644 index f845caaeb..000000000 --- a/devtools/org.eclipse.gmf.dev/.options +++ /dev/null @@ -1,2 +0,0 @@ -org.eclipse.gmf.dev/debug=false -org.eclipse.gmf.dev/debug/trace=false diff --git a/devtools/org.eclipse.gmf.dev/.project b/devtools/org.eclipse.gmf.dev/.project deleted file mode 100644 index e6432bb07..000000000 --- a/devtools/org.eclipse.gmf.dev/.project +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>org.eclipse.gmf.dev</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.ajdt.core.ajbuilder</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.ajdt.ui.ajnature</nature> - <nature>org.eclipse.pde.PluginNature</nature> - <nature>org.eclipse.jdt.core.javanature</nature> - </natures> -</projectDescription> diff --git a/devtools/org.eclipse.gmf.dev/ExtEditPartTracer.aj b/devtools/org.eclipse.gmf.dev/ExtEditPartTracer.aj deleted file mode 100644 index ea330f61d..000000000 --- a/devtools/org.eclipse.gmf.dev/ExtEditPartTracer.aj +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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.runtime.emf.type.core; - -import org.eclipse.gmf.dev.EditPartTraceUtil; -import org.eclipse.gmf.runtime.common.core.command.ICommand; -import org.eclipse.gmf.runtime.emf.type.core.edithelper.IEditHelper; -import org.eclipse.gmf.runtime.emf.type.core.edithelper.IEditHelperAdvice; -import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest; - -/** - * @author dstadnik - */ -public aspect ExtEditPartTracer { - - pointcut makingCommandInEditHelper(IEditHelper editHelper, IEditCommandRequest request) : execution(ICommand IEditHelper.getEditCommand(IEditCommandRequest)) && target(editHelper) && args(request); - - ICommand around(IEditHelper editHelper, IEditCommandRequest request) : makingCommandInEditHelper(editHelper, request) { - ICommand command = proceed(editHelper, request); - if (command != null) { - EditPartTraceUtil.addSource(command, editHelper); - } - return command; - } - - pointcut makingCommandInEditHelperAdvice(IEditHelperAdvice advice, IEditCommandRequest request) : (execution(ICommand IEditHelperAdvice.getBeforeEditCommand(IEditCommandRequest)) || execution(ICommand IEditHelperAdvice.getAfterEditCommand(IEditCommandRequest))) && target(advice) && args(request); - - ICommand around(IEditHelperAdvice advice, IEditCommandRequest request) : makingCommandInEditHelperAdvice(advice, request) { - ICommand command = proceed(advice, request); - if (command != null) { - EditPartTraceUtil.addSource(command, advice); - } - return command; - } -} diff --git a/devtools/org.eclipse.gmf.dev/META-INF/MANIFEST.MF b/devtools/org.eclipse.gmf.dev/META-INF/MANIFEST.MF deleted file mode 100644 index 9440755bc..000000000 --- a/devtools/org.eclipse.gmf.dev/META-INF/MANIFEST.MF +++ /dev/null @@ -1,15 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: GMF Dev -Bundle-SymbolicName: org.eclipse.gmf.dev; singleton:=true -Bundle-Version: 1.0.0 -Bundle-Activator: org.eclipse.gmf.dev.DevPlugin -Bundle-Vendor: eclipse.org -Bundle-Localization: plugin -Require-Bundle: org.eclipse.core.runtime, - org.eclipse.ui, - org.eclipse.draw2d, - org.eclipse.gef, - org.aspectj.runtime -Eclipse-LazyStart: true -Export-Package: org.eclipse.gmf.dev diff --git a/devtools/org.eclipse.gmf.dev/build.properties b/devtools/org.eclipse.gmf.dev/build.properties deleted file mode 100644 index 34d2e4d2d..000000000 --- a/devtools/org.eclipse.gmf.dev/build.properties +++ /dev/null @@ -1,4 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - . diff --git a/devtools/org.eclipse.gmf.dev/icons/command.gif b/devtools/org.eclipse.gmf.dev/icons/command.gif Binary files differdeleted file mode 100644 index 57f410224..000000000 --- a/devtools/org.eclipse.gmf.dev/icons/command.gif +++ /dev/null diff --git a/devtools/org.eclipse.gmf.dev/icons/commandx.gif b/devtools/org.eclipse.gmf.dev/icons/commandx.gif Binary files differdeleted file mode 100644 index 50db6946d..000000000 --- a/devtools/org.eclipse.gmf.dev/icons/commandx.gif +++ /dev/null diff --git a/devtools/org.eclipse.gmf.dev/icons/editpart.gif b/devtools/org.eclipse.gmf.dev/icons/editpart.gif Binary files differdeleted file mode 100644 index 6514f7bb7..000000000 --- a/devtools/org.eclipse.gmf.dev/icons/editpart.gif +++ /dev/null diff --git a/devtools/org.eclipse.gmf.dev/icons/event.gif b/devtools/org.eclipse.gmf.dev/icons/event.gif Binary files differdeleted file mode 100644 index dd45f08fb..000000000 --- a/devtools/org.eclipse.gmf.dev/icons/event.gif +++ /dev/null diff --git a/devtools/org.eclipse.gmf.dev/icons/info.gif b/devtools/org.eclipse.gmf.dev/icons/info.gif Binary files differdeleted file mode 100644 index 2da001e3e..000000000 --- a/devtools/org.eclipse.gmf.dev/icons/info.gif +++ /dev/null diff --git a/devtools/org.eclipse.gmf.dev/icons/model.gif b/devtools/org.eclipse.gmf.dev/icons/model.gif Binary files differdeleted file mode 100644 index 049cac696..000000000 --- a/devtools/org.eclipse.gmf.dev/icons/model.gif +++ /dev/null diff --git a/devtools/org.eclipse.gmf.dev/icons/parameter.gif b/devtools/org.eclipse.gmf.dev/icons/parameter.gif Binary files differdeleted file mode 100644 index a16ac8314..000000000 --- a/devtools/org.eclipse.gmf.dev/icons/parameter.gif +++ /dev/null diff --git a/devtools/org.eclipse.gmf.dev/icons/request.gif b/devtools/org.eclipse.gmf.dev/icons/request.gif Binary files differdeleted file mode 100644 index 86550fe9f..000000000 --- a/devtools/org.eclipse.gmf.dev/icons/request.gif +++ /dev/null diff --git a/devtools/org.eclipse.gmf.dev/plugin.xml b/devtools/org.eclipse.gmf.dev/plugin.xml deleted file mode 100644 index b9b12a3c9..000000000 --- a/devtools/org.eclipse.gmf.dev/plugin.xml +++ /dev/null @@ -1,41 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<?eclipse version="3.0"?> - -<plugin> - - <extension-point id="editPartRequestFilters" name="Edit Part Request Filters" schema="schema/editPartRequestFilters.exsd"/> - <extension-point id="editPartTraceContributors" name="Edit Part Trace Contributors" schema="schema/editPartTraceContributors.exsd"/> - - <extension - point="org.eclipse.ui.views"> - <category - name="GMF Dev" - id="org.eclipse.gmf.dev"> - </category> - <view - name="GEF Console" - category="org.eclipse.gmf.dev" - class="org.eclipse.gef.ui.console.DebugGEF" - id="org.eclipse.gmf.dev.DebugGEF"> - </view> - <view - name="Command Stack" - category="org.eclipse.gmf.dev" - class="org.eclipse.gef.ui.stackview.CommandStackInspector" - id="org.eclipse.gmf.dev.CommandStackInspector"> - </view> - <view - name="Edit Parts Tracer" - category="org.eclipse.gmf.dev" - class="org.eclipse.gmf.dev.EditPartTraceView" - id="org.eclipse.gmf.dev.EditPartTraceView"> - </view> - <view - name="Workbench Parts Tracker" - category="org.eclipse.gmf.dev" - class="org.eclipse.gmf.dev.PartTrackerView" - id="org.eclipse.gmf.dev.PartTrackerView"> - </view> - </extension> - -</plugin> diff --git a/devtools/org.eclipse.gmf.dev/readme.txt b/devtools/org.eclipse.gmf.dev/readme.txt deleted file mode 100644 index 9ea8eaa55..000000000 --- a/devtools/org.eclipse.gmf.dev/readme.txt +++ /dev/null @@ -1,8 +0,0 @@ -How to enable tracing for the plugin X: - -1. Convert X to aspectj project (project context menu -> AspectJ Tools -> Convert...) -2. Add to X dependency to this plugin (org.eclipse.gmf.dev) -3. Add compiled aspect to aspectpath of X (org.eclipse.gmf.dev/bin to project properties -> AspectJ Aspect Path -> Libraries -> Add Class Folder...) - -Checkout org.eclipse.gmf.dev.runtime to enable GMF runtime detailed tracing. -ExtEditPartTracer.aj is a tracing aspect for element types.
\ No newline at end of file diff --git a/devtools/org.eclipse.gmf.dev/schema/editPartRequestFilters.exsd b/devtools/org.eclipse.gmf.dev/schema/editPartRequestFilters.exsd deleted file mode 100644 index 58e7f8956..000000000 --- a/devtools/org.eclipse.gmf.dev/schema/editPartRequestFilters.exsd +++ /dev/null @@ -1,115 +0,0 @@ -<?xml version='1.0' encoding='UTF-8'?> -<!-- Schema file written by PDE --> -<schema targetNamespace="org.eclipse.gmf.dev"> -<annotation> - <appInfo> - <meta.schema plugin="org.eclipse.gmf.dev" id="editPartRequestFilters" name="Edit Part Request Filters"/> - </appInfo> - <documentation> - [Enter description of this extension point.] - </documentation> - </annotation> - - <element name="extension"> - <complexType> - <sequence> - <element ref="category" minOccurs="1" maxOccurs="unbounded"/> - </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> - <appInfo> - <meta.attribute translatable="true"/> - </appInfo> - </annotation> - </attribute> - </complexType> - </element> - - <element name="category"> - <complexType> - <attribute name="name" type="string" use="required"> - <annotation> - <documentation> - - </documentation> - <appInfo> - <meta.attribute translatable="true"/> - </appInfo> - </annotation> - </attribute> - <attribute name="class" type="string" use="required"> - <annotation> - <documentation> - - </documentation> - <appInfo> - <meta.attribute kind="java" basedOn="org.eclipse.gmf.dev.EditPartRequestFiltersProvider"/> - </appInfo> - </annotation> - </attribute> - </complexType> - </element> - - <annotation> - <appInfo> - <meta.section type="since"/> - </appInfo> - <documentation> - [Enter the first release in which this extension point appears.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="examples"/> - </appInfo> - <documentation> - [Enter extension point usage example here.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="apiInfo"/> - </appInfo> - <documentation> - [Enter API information here.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="implementation"/> - </appInfo> - <documentation> - [Enter information about supplied implementation of this extension point.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="copyright"/> - </appInfo> - <documentation> - - </documentation> - </annotation> - -</schema> diff --git a/devtools/org.eclipse.gmf.dev/schema/editPartTraceContributors.exsd b/devtools/org.eclipse.gmf.dev/schema/editPartTraceContributors.exsd deleted file mode 100644 index 37bdebf95..000000000 --- a/devtools/org.eclipse.gmf.dev/schema/editPartTraceContributors.exsd +++ /dev/null @@ -1,105 +0,0 @@ -<?xml version='1.0' encoding='UTF-8'?> -<!-- Schema file written by PDE --> -<schema targetNamespace="org.eclipse.gmf.dev"> -<annotation> - <appInfo> - <meta.schema plugin="org.eclipse.gmf.dev" id="editPartTraceContributors" name="Edit Part Trace Contributors"/> - </appInfo> - <documentation> - [Enter description of this extension point.] - </documentation> - </annotation> - - <element name="extension"> - <complexType> - <sequence> - <element ref="contributor" minOccurs="1" maxOccurs="unbounded"/> - </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> - <appInfo> - <meta.attribute translatable="true"/> - </appInfo> - </annotation> - </attribute> - </complexType> - </element> - - <element name="contributor"> - <complexType> - <attribute name="class" type="string"> - <annotation> - <documentation> - - </documentation> - <appInfo> - <meta.attribute kind="java" basedOn="org.eclipse.gmf.dev.EditPartTraceContributor"/> - </appInfo> - </annotation> - </attribute> - </complexType> - </element> - - <annotation> - <appInfo> - <meta.section type="since"/> - </appInfo> - <documentation> - [Enter the first release in which this extension point appears.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="examples"/> - </appInfo> - <documentation> - [Enter extension point usage example here.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="apiInfo"/> - </appInfo> - <documentation> - [Enter API information here.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="implementation"/> - </appInfo> - <documentation> - [Enter information about supplied implementation of this extension point.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="copyright"/> - </appInfo> - <documentation> - - </documentation> - </annotation> - -</schema> diff --git a/devtools/org.eclipse.gmf.dev/src/org/eclipse/gmf/dev/CommandCreatedEvent.java b/devtools/org.eclipse.gmf.dev/src/org/eclipse/gmf/dev/CommandCreatedEvent.java deleted file mode 100644 index 4df020bc5..000000000 --- a/devtools/org.eclipse.gmf.dev/src/org/eclipse/gmf/dev/CommandCreatedEvent.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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; - -import java.util.List; -import java.util.Map; - -import org.eclipse.gef.EditPart; -import org.eclipse.gef.Request; -import org.eclipse.gef.commands.Command; - -/** - * @author dstadnik - */ -public class CommandCreatedEvent { - - EditPart editPart; - Request request; - Command command; - Map sources; - List<CommandCreatedEvent> siblings; - - public Object getSource(Object object) { - Object source = null; - if (sources != null) { - source = sources.get(object); - } - if (source == null && siblings != null) { - for (CommandCreatedEvent sibling : siblings) { - source = sibling.getSource(object); - if (source != null) { - break; - } - } - } - return source; - } -} diff --git a/devtools/org.eclipse.gmf.dev/src/org/eclipse/gmf/dev/DevPlugin.java b/devtools/org.eclipse.gmf.dev/src/org/eclipse/gmf/dev/DevPlugin.java deleted file mode 100644 index 0033872ce..000000000 --- a/devtools/org.eclipse.gmf.dev/src/org/eclipse/gmf/dev/DevPlugin.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * 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; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; - -/** - * @author dstadnik - */ -public class DevPlugin extends AbstractUIPlugin { - - public static final String TRACE_OPTION = "/debug/trace"; - - public static final String COMMAND_IMAGE = "/icons/command.gif"; - public static final String COMMANDX_IMAGE = "/icons/commandx.gif"; - public static final String EDITPART_IMAGE = "/icons/editpart.gif"; - public static final String EVENT_IMAGE = "/icons/event.gif"; - public static final String INFO_IMAGE = "/icons/info.gif"; - public static final String MODEL_IMAGE = "/icons/model.gif"; - public static final String PARAMETER_IMAGE = "/icons/parameter.gif"; - public static final String REQUEST_IMAGE = "/icons/request.gif"; - - private static DevPlugin instance; - - public DevPlugin() { - instance = this; - } - - public void start(BundleContext context) throws Exception { - super.start(context); - getImageRegistry().put(COMMAND_IMAGE, getImageDescriptor(COMMAND_IMAGE)); - getImageRegistry().put(COMMANDX_IMAGE, getImageDescriptor(COMMANDX_IMAGE)); - getImageRegistry().put(EDITPART_IMAGE, getImageDescriptor(EDITPART_IMAGE)); - getImageRegistry().put(EVENT_IMAGE, getImageDescriptor(EVENT_IMAGE)); - getImageRegistry().put(INFO_IMAGE, getImageDescriptor(INFO_IMAGE)); - getImageRegistry().put(MODEL_IMAGE, getImageDescriptor(MODEL_IMAGE)); - getImageRegistry().put(PARAMETER_IMAGE, getImageDescriptor(PARAMETER_IMAGE)); - getImageRegistry().put(REQUEST_IMAGE, getImageDescriptor(REQUEST_IMAGE)); - } - - public void stop(BundleContext context) throws Exception { - super.stop(context); - instance = null; - } - - public static DevPlugin getInstance() { - return instance; - } - - /** - * Returns an image descriptor for the image file at the given - * plug-in relative path. - * - * @param path the path - * @return the image descriptor - */ - public static ImageDescriptor getImageDescriptor(String path) { - return AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.gmf.dev", path); - } - - public static Image getImage(String name) { - return instance.getImageRegistry().get(name); - } - - public static String getOption(String name) { - if (instance == null) { - return null; - } - String key = instance.getBundle().getSymbolicName() + name; - return Platform.getDebugOption(key); - } - - public static boolean isOptionEnabled(String name) { - return Boolean.valueOf(getOption(name)).booleanValue(); - } - - public boolean isTracing() { - return isOptionEnabled(TRACE_OPTION); - } - - public static void logInfo(String text) { - DevPlugin instance = getInstance(); - if (instance == null) { - return; - } - if (!instance.isDebugging()) { - return; - } - log(IStatus.INFO, text); - } - - public static void logError(String text) { - log(IStatus.ERROR, text); - } - - public static void logError(String text, Throwable cause) { - log(IStatus.ERROR, text, cause); - } - - public static void logWarning(String text) { - log(IStatus.WARNING, text); - } - - public static void logWarning(String text, Throwable cause) { - log(IStatus.WARNING, text, cause); - } - - protected static void log(int type, String text) { - if (instance != null && instance.isTracing()) { - log(type, text, new Throwable()); - } else { - log(type, text, null); - } - } - - protected static void log(int type, String text, Throwable cause) { - if (instance == null) { - System.err.println(text); - if (cause != null) { - cause.printStackTrace(System.err); - } - } else { - String id = instance.getBundle().getSymbolicName(); - IStatus status = new Status(type, id, 0, text, cause); - instance.getLog().log(status); - } - } -} diff --git a/devtools/org.eclipse.gmf.dev/src/org/eclipse/gmf/dev/DevUtils.java b/devtools/org.eclipse.gmf.dev/src/org/eclipse/gmf/dev/DevUtils.java deleted file mode 100644 index be9317b72..000000000 --- a/devtools/org.eclipse.gmf.dev/src/org/eclipse/gmf/dev/DevUtils.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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; - -import java.lang.reflect.Field; -import java.util.StringTokenizer; - -/** - * @author dstadnik - */ -public class DevUtils { - - private DevUtils() { - } - - /** - * Replaces all fully qualified class names with simple names. - */ - public static String replaceWithSimpleNames(String s) { - StringBuffer sb = new StringBuffer(); - StringTokenizer st = new StringTokenizer(s, " \t\n\r\f", true); //$NON-NLS-1$ - while (st.hasMoreTokens()) { - String token = st.nextToken(); - int pos = token.lastIndexOf('.'); - if (pos > 0 && pos < token.length() - 1 && !Character.isDigit(token.charAt(pos + 1))) { - sb.append(token.substring(pos + 1)); - } else { - sb.append(token); - } - } - return sb.toString(); - } - - public static String getFullClassName(Object obj) { - if (obj == null) { - return null; - } - return obj.getClass().getName(); - } - - public static String getSimpleClassName(Object obj) { - if (obj == null) { - return null; - } - return getSimpleName(obj.getClass().getName()); - } - - public static String getSimpleName(String fqn) { - return fqn.substring(fqn.lastIndexOf('.') + 1); - } - - /** - * Returns <code>null</code> if field does not exist. - */ - public static Object getFieldValue(Object obj, String name) { - try { - Field f = obj.getClass().getDeclaredField(name); - f.setAccessible(true); - return f.get(obj); - } catch (Throwable t) { - DevPlugin.logError("Unable to retrieve field value : " + name, t); - } - return null; - } - - /** - * Returns <code>null</code> if field does not exist. - */ - public static Object getStaticFieldValue(Class clazz, String name) { - try { - Field f = clazz.getDeclaredField(name); - f.setAccessible(true); - return f.get(null); - } catch (Throwable t) { - DevPlugin.logError("Unable to retrieve static field value : " + name, t); - } - return null; - } -} diff --git a/devtools/org.eclipse.gmf.dev/src/org/eclipse/gmf/dev/EditPartRequestFiltersProvider.java b/devtools/org.eclipse.gmf.dev/src/org/eclipse/gmf/dev/EditPartRequestFiltersProvider.java deleted file mode 100644 index e446b6446..000000000 --- a/devtools/org.eclipse.gmf.dev/src/org/eclipse/gmf/dev/EditPartRequestFiltersProvider.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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; - -/** - * @author dstadnik - */ -public interface EditPartRequestFiltersProvider { - - /** - * @return type that defines request constants - */ - public Class getConstants(); -} diff --git a/devtools/org.eclipse.gmf.dev/src/org/eclipse/gmf/dev/EditPartTraceConstructor.java b/devtools/org.eclipse.gmf.dev/src/org/eclipse/gmf/dev/EditPartTraceConstructor.java deleted file mode 100644 index 204bd735e..000000000 --- a/devtools/org.eclipse.gmf.dev/src/org/eclipse/gmf/dev/EditPartTraceConstructor.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * 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; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.Platform; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.GraphicalEditPart; -import org.eclipse.gef.Request; -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.commands.CompoundCommand; -import org.eclipse.gef.requests.ChangeBoundsRequest; -import org.eclipse.gef.requests.GroupRequest; - -/** - * @author dstadnik - */ -public class EditPartTraceConstructor { - - private static List<EditPartTraceContributor> contributors; - - private EditPartTraceConstructor() { - } - - private static void loadContributors() { - if (contributors != null) { - return; - } - String id = DevPlugin.getInstance().getBundle().getSymbolicName(); - IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(id, "editPartTraceContributors"); - contributors = new ArrayList<EditPartTraceContributor>(elements.length); - for (int i = 0; i < elements.length; i++) { - if (!"contributor".equals(elements[i].getName())) { - continue; - } - try { - contributors.add((EditPartTraceContributor) elements[i].createExecutableExtension("class")); - } catch (Exception e) { - e.printStackTrace(); - } - } - } - - public static EditPartTraceRecord createEditPartNode(EditPart editPart) { - List<EditPartTraceRecord> kids = new ArrayList<EditPartTraceRecord>(); - kids.add(new EditPartTraceRecord(String.valueOf(editPart.getModel()), DevPlugin.MODEL_IMAGE)); - if (editPart instanceof GraphicalEditPart) { - GraphicalEditPart gEditPart = (GraphicalEditPart) editPart; - kids.add(new EditPartTraceRecord("figure bounds " + gEditPart.getFigure().getBounds())); - } - loadContributors(); - for (EditPartTraceContributor contributor : contributors) { - contributor.contribute(kids, editPart); - } - return new EditPartTraceRecord(DevUtils.getFullClassName(editPart), DevPlugin.EDITPART_IMAGE, kids.toArray(new EditPartTraceRecord[kids.size()])); - } - - public static EditPartTraceRecord createRequestNode(Request request) { - List<EditPartTraceRecord> kids = new ArrayList<EditPartTraceRecord>(); - if (request instanceof ChangeBoundsRequest) { - ChangeBoundsRequest cbRequest = (ChangeBoundsRequest) request; - kids.add(new EditPartTraceRecord("location " + cbRequest.getLocation())); - kids.add(new EditPartTraceRecord("move delta " + cbRequest.getMoveDelta())); - kids.add(new EditPartTraceRecord("resize delta " + cbRequest.getSizeDelta())); - kids.add(new EditPartTraceRecord("resize direction " + cbRequest.getResizeDirection())); - } - if (request instanceof GroupRequest) { - List<? extends EditPart> editParts = ((GroupRequest) request).getEditParts(); - if (editParts != null) { - for (EditPart editPart : editParts) { - kids.add(createEditPartNode(editPart)); - } - } - } - loadContributors(); - for (EditPartTraceContributor contributor : contributors) { - contributor.contribute(kids, request); - } - return new EditPartTraceRecord(DevUtils.getFullClassName(request), DevPlugin.REQUEST_IMAGE, kids.toArray(new EditPartTraceRecord[kids.size()])); - } - - public static EditPartTraceRecord createCommandNode(Command command, CommandCreatedEvent event) { - List<EditPartTraceRecord> kids = new ArrayList<EditPartTraceRecord>(); - Object source = event.getSource(command); - if (source != null) { - kids.add(new EditPartTraceRecord("from " + DevUtils.getFullClassName(source))); - } - if (command instanceof CompoundCommand) { - Iterator commands = ((CompoundCommand) command).getCommands().iterator(); - while (commands.hasNext()) { - kids.add(createCommandNode((Command) commands.next(), event)); - } - } - loadContributors(); - for (EditPartTraceContributor contributor : contributors) { - contributor.contribute(kids, command, event); - } - return new EditPartTraceRecord(getLabel(command), getImage(command), kids.toArray(new EditPartTraceRecord[kids.size()])); - } - - private static String getLabel(Command command) { - String label = DevUtils.getFullClassName(command); - if (command.getDebugLabel() != null) { - label += '<' + command.getDebugLabel() + '>'; - } - return label; - } - - private static String getImage(Command command) { - String id = DevPlugin.COMMANDX_IMAGE; - try { - if (command.canExecute()) { - id = DevPlugin.COMMAND_IMAGE; - } - } catch (Exception e) { - // ignore - } - return id; - } -} diff --git a/devtools/org.eclipse.gmf.dev/src/org/eclipse/gmf/dev/EditPartTraceContributor.java b/devtools/org.eclipse.gmf.dev/src/org/eclipse/gmf/dev/EditPartTraceContributor.java deleted file mode 100644 index f6542b74b..000000000 --- a/devtools/org.eclipse.gmf.dev/src/org/eclipse/gmf/dev/EditPartTraceContributor.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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; - -import java.util.List; - -import org.eclipse.gef.EditPart; -import org.eclipse.gef.Request; -import org.eclipse.gef.commands.Command; - -/** - * @author dstadnik - */ -public interface EditPartTraceContributor { - - public void contribute(List<EditPartTraceRecord> kids, EditPart editPart); - - public void contribute(List<EditPartTraceRecord> kids, Request request); - - public void contribute(List<EditPartTraceRecord> kids, Command command, CommandCreatedEvent event); -} diff --git a/devtools/org.eclipse.gmf.dev/src/org/eclipse/gmf/dev/EditPartTraceRecord.java b/devtools/org.eclipse.gmf.dev/src/org/eclipse/gmf/dev/EditPartTraceRecord.java deleted file mode 100644 index 305b93984..000000000 --- a/devtools/org.eclipse.gmf.dev/src/org/eclipse/gmf/dev/EditPartTraceRecord.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * 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; - -/** - * @author dstadnik - */ -public class EditPartTraceRecord { - - public static final EditPartTraceRecord[] NO_KIDS = new EditPartTraceRecord[0]; - - private transient EditPartTraceRecord parent; - private String label; - private String simpleLabel; - private String imageId; - private EditPartTraceRecord[] kids; - - public EditPartTraceRecord(String label) { - this(label, null, NO_KIDS); - } - - public EditPartTraceRecord(String label, String imageId) { - this(label, imageId, NO_KIDS); - } - - public EditPartTraceRecord(String label, String imageId, EditPartTraceRecord[] kids) { - this.label = label; - this.imageId = imageId; - this.kids = kids; - if (this.kids == null) { - this.kids = NO_KIDS; - } - for (EditPartTraceRecord kid : this.kids) { - kid.parent = this; - } - } - - public EditPartTraceRecord getParent() { - return parent; - } - - protected boolean isSimpleClassNames() { - if (getParent() != null) { - return getParent().isSimpleClassNames(); - } - return false; - } - - public String getLabel() { - if (label != null && isSimpleClassNames()) { - if (simpleLabel == null) { - simpleLabel = DevUtils.replaceWithSimpleNames(label); - } - return simpleLabel; - } - return label; - } - - public String getImageId() { - return imageId; - } - - public EditPartTraceRecord[] getKids() { - return kids; - } - - public boolean equalTree(EditPartTraceRecord another) { - if (another == null) { - return false; - } - if (another == this) { - return true; - } - if (label == null ? another.label != null : !label.equals(another.label)) { - return false; - } - if (imageId == null ? another.imageId != null : !imageId.equals(another.imageId)) { - return false; - } - if (kids.length != another.kids.length) { - return false; - } - for (int i = 0; i < kids.length; i++) { - if (kids[i] == null ? another.kids[i] != null : !kids[i].equalTree(another.kids[i])) { - return false; - } - } - return true; - } -} diff --git a/devtools/org.eclipse.gmf.dev/src/org/eclipse/gmf/dev/EditPartTraceRequestFilters.java b/devtools/org.eclipse.gmf.dev/src/org/eclipse/gmf/dev/EditPartTraceRequestFilters.java deleted file mode 100644 index 50d3238fd..000000000 --- a/devtools/org.eclipse.gmf.dev/src/org/eclipse/gmf/dev/EditPartTraceRequestFilters.java +++ /dev/null @@ -1,304 +0,0 @@ -/* - * 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; - -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerSorter; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IMemento; -import org.eclipse.ui.dialogs.CheckedTreeSelectionDialog; - -/** - * @author dstadnik - */ -public class EditPartTraceRequestFilters { - - private static final Object[] NONE = new Object[0]; - - private static final String REQUEST_FILTERS_TAG = "request_filters"; //$NON-NLS-1$ - - private static final String CATEGORY_TAG = "category"; //$NON-NLS-1$ - - private static final String CATEGORY_NAME_ATTR = "name"; //$NON-NLS-1$ - - private static final String FILTER_TAG = "filter"; //$NON-NLS-1$ - - private static final String REQUEST_TYPE_ATTR = "request_type"; //$NON-NLS-1$ - - private static final String ENABLED_ATTR = "enabled"; //$NON-NLS-1$ - - private List<Category> categories; - - public EditPartTraceRequestFilters() { - categories = new ArrayList<Category>(); - categories.add(new Category("GEF", getRequestFilters(org.eclipse.gef.RequestConstants.class))); - readExtensions(); - } - - protected void readExtensions() { - String id = DevPlugin.getInstance().getBundle().getSymbolicName(); - IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(id, "editPartRequestFilters"); - for (int i = 0; i < elements.length; i++) { - if (!"category".equals(elements[i].getName())) { - continue; - } - try { - String name = elements[i].getAttribute("name"); - EditPartRequestFiltersProvider provider = (EditPartRequestFiltersProvider) elements[i].createExecutableExtension("class"); - categories.add(new Category(name, getRequestFilters(provider.getConstants()))); - } catch (Exception e) { - e.printStackTrace(); - } - } - } - - public boolean isEnabled(String requestType) { - for (Category category : categories) { - Filter filter = category.filters.get(requestType); - if (filter != null && filter.enabled) { - return true; - } - } - return false; - } - - public void readState(IMemento memento) { - if (memento == null) { - return; - } - IMemento requestFiltersMemento = memento.getChild(REQUEST_FILTERS_TAG); - if (requestFiltersMemento == null) { - return; - } - for (IMemento categoryMemento : requestFiltersMemento.getChildren(CATEGORY_TAG)) { - String categoryName = categoryMemento.getString(CATEGORY_NAME_ATTR); - if (categoryName == null) { - continue; - } - for (Category category : categories) { - if (!categoryName.equals(category.name)) { - continue; - } - for (IMemento filterMemento : categoryMemento.getChildren(FILTER_TAG)) { - String requestType = filterMemento.getString(REQUEST_TYPE_ATTR); - if (requestType == null) { - continue; - } - String enabled = filterMemento.getString(ENABLED_ATTR); - if (!Boolean.parseBoolean(enabled)) { - continue; - } - Filter filter = category.filters.get(requestType); - if (filter != null) { - filter.enabled = true; - } - } - } - } - } - - public void writeState(IMemento memento) { - if (memento == null) { - return; - } - IMemento requestFiltersMemento = memento.getChild(REQUEST_FILTERS_TAG); - if (requestFiltersMemento == null) { - requestFiltersMemento = memento.createChild(REQUEST_FILTERS_TAG); - } - for (Category category : categories) { - IMemento categoryMemento = null; - for (IMemento existingCategoryMemento : requestFiltersMemento.getChildren(CATEGORY_TAG)) { - String categoryName = existingCategoryMemento.getString(CATEGORY_NAME_ATTR); - if (category.name.equals(categoryName)) { - categoryMemento = existingCategoryMemento; - break; - } - } - if (categoryMemento == null) { - categoryMemento = requestFiltersMemento.createChild(CATEGORY_TAG); - categoryMemento.putString(CATEGORY_NAME_ATTR, category.name); - } - for (Filter filter : category.filters.values()) { - IMemento filterMemento = null; - for (IMemento existingFilterMemento : categoryMemento.getChildren(FILTER_TAG)) { - String requestType = existingFilterMemento.getString(REQUEST_TYPE_ATTR); - if (filter.type.equals(requestType)) { - filterMemento = existingFilterMemento; - break; - } - } - if (filterMemento == null) { - if (!filter.enabled) { - continue; - } - filterMemento = categoryMemento.createChild(FILTER_TAG); - filterMemento.putString(REQUEST_TYPE_ATTR, filter.type); - } - filterMemento.putString(ENABLED_ATTR, String.valueOf(filter.enabled)); - } - } - } - - public void edit(Shell shell) { - CheckedTreeSelectionDialog dialog = new CheckedTreeSelectionDialog(shell, new RequestFiltersLabelProvider(), new RequestFiltersContentProvider()); - dialog.setContainerMode(true); - dialog.setInput(categories); - // dialog.setExpandedElements(categories.toArray(new Category[categories.size()])); - dialog.setInitialElementSelections(getEnabledRequestFilters()); - dialog.setSorter(new ViewerSorter()); - dialog.setTitle("Filtered Requests"); - dialog.setMessage("Select requests that should be filtered out:"); - if (dialog.open() == Window.OK) { - setEnabledRequestFilters(dialog.getResult()); - } - } - - private List<Filter> getEnabledRequestFilters() { - List<Filter> filters = new ArrayList<Filter>(); - for (Category category : categories) { - for (Filter filter : category.filters.values()) { - if (filter.enabled) { - filters.add(filter); - } - } - } - return filters; - } - - private void setEnabledRequestFilters(Object[] selection) { - for (Category category : categories) { - for (Filter filter : category.filters.values()) { - boolean enabled = false; - for (Object selected : selection) { - if (selected == filter) { - enabled = true; - break; - } - } - filter.enabled = enabled; - } - } - } - - protected Map<String, Filter> getRequestFilters(Class clazz) { - Map<String, Filter> filters = new HashMap<String, Filter>(); - try { - for (Field field : clazz.getDeclaredFields()) { - if (Modifier.isStatic(field.getModifiers()) && Modifier.isFinal(field.getModifiers()) && String.class.equals(field.getType()) && !field.isSynthetic()) { - // possibly name should start with 'REQ_' - String requestType = (String) field.get(null); - if (requestType != null) { - filters.put(requestType, new Filter(requestType, false)); - } - } - } - } catch (Exception e) { - e.printStackTrace(); - } - return filters; - } - - private static class Filter { - - public Category category; - - public String type; - - public boolean enabled; - - public Filter(String type, boolean enabled) { - this.type = type; - this.enabled = enabled; - } - } - - private static class Category { - - public String name; - - private Map<String, Filter> filters; // request type -> filter - - public Category(String name, Map<String, Filter> filters) { - this.name = name; - this.filters = filters; - for (Filter filter : filters.values()) { - filter.category = this; - } - } - } - - private static class RequestFiltersLabelProvider extends LabelProvider { - - public String getText(Object element) { - if (element instanceof Filter) { - return ((Filter) element).type; - } else if (element instanceof Category) { - return ((Category) element).name; - } - return super.getText(element); - } - } - - private class RequestFiltersContentProvider implements ITreeContentProvider { - - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - } - - public Object getParent(Object element) { - if (element instanceof Filter) { - return ((Filter) element).category; - } else if (element instanceof Category) { - return categories; - } - return null; - } - - public boolean hasChildren(Object element) { - if (element instanceof Category) { - return !((Category) element).filters.isEmpty(); - } else if (element == categories) { - return !categories.isEmpty(); - } - return false; - } - - public Object[] getChildren(Object parentElement) { - if (parentElement instanceof Category) { - Collection<Filter> filters = ((Category) parentElement).filters.values(); - return filters.toArray(new Filter[filters.size()]); - } else if (parentElement == categories) { - return categories.toArray(new Category[categories.size()]); - } - return NONE; - } - - public Object[] getElements(Object inputElement) { - return getChildren(inputElement); - } - - public void dispose() { - } - } -} diff --git a/devtools/org.eclipse.gmf.dev/src/org/eclipse/gmf/dev/EditPartTraceUtil.java b/devtools/org.eclipse.gmf.dev/src/org/eclipse/gmf/dev/EditPartTraceUtil.java deleted file mode 100644 index 145c0a974..000000000 --- a/devtools/org.eclipse.gmf.dev/src/org/eclipse/gmf/dev/EditPartTraceUtil.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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; - -import java.util.IdentityHashMap; - -import org.eclipse.gef.EditPart; -import org.eclipse.gef.Request; -import org.eclipse.gef.commands.Command; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; - -/** - * @author dstadnik - */ -public class EditPartTraceUtil { - - private EditPartTraceUtil() { - } - - public static EditPartTraceView getTraceView() { - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (window == null) { - return null; - } - IWorkbenchPage page = window.getActivePage(); - if (page == null) { - return null; - } - return (EditPartTraceView) page.findView("org.eclipse.gmf.dev.EditPartTraceView"); - } - - public static void fireCommandRequested(EditPart editPart, Request request) { - EditPartTraceView view = getTraceView(); - if (view == null) { - return; - } - try { - view.traceCommandRequested(editPart, request); - } catch (Throwable t) { - t.printStackTrace(); - } - } - - public static void fireCommandCreated(EditPart editPart, Request request, Command command) { - EditPartTraceView view = getTraceView(); - if (view == null) { - return; - } - try { - view.traceCommandCreated(editPart, request, command); - } catch (Throwable t) { - t.printStackTrace(); - } - } - - public static void addSource(Object command, Object source) { - EditPartTraceView view = getTraceView(); - if (view == null) { - return; - } - CommandCreatedEvent event = view.getCurrentEvent(); - if (event == null) { - return; - } - if (event.sources == null) { - event.sources = new IdentityHashMap(); - } - event.sources.put(command, source); - } -} diff --git a/devtools/org.eclipse.gmf.dev/src/org/eclipse/gmf/dev/EditPartTraceView.java b/devtools/org.eclipse.gmf.dev/src/org/eclipse/gmf/dev/EditPartTraceView.java deleted file mode 100644 index f5cf759d8..000000000 --- a/devtools/org.eclipse.gmf.dev/src/org/eclipse/gmf/dev/EditPartTraceView.java +++ /dev/null @@ -1,348 +0,0 @@ -/* - * 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; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.Stack; - -import org.eclipse.gef.EditPart; -import org.eclipse.gef.Request; -import org.eclipse.gef.commands.Command; -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.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.jface.viewers.AbstractTreeViewer; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.IMemento; -import org.eclipse.ui.IViewSite; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.part.ViewPart; - -/** - * @author dstadnik - */ -public class EditPartTraceView extends ViewPart { - - private static final String SCN_KEY = "simple_class_names"; //$NON-NLS-1$ - - private TreeViewer viewer; - - private List<IAction> actions; - - private EditPartTraceRequestFilters requestFilters = new EditPartTraceRequestFilters(); - - private Stack<CommandCreatedEvent> history = new Stack<CommandCreatedEvent>(); - - private boolean simpleClassNames; - - private List<EditPartTraceRecord> getRecords() { - return (List<EditPartTraceRecord>) viewer.getInput(); - } - - private TopEditPartTraceRecord getLastRecord() { - List<EditPartTraceRecord> records = getRecords(); - if (records.isEmpty()) { - return null; - } - return (TopEditPartTraceRecord) records.get(records.size() - 1); - } - - public void init(IViewSite site, IMemento memento) throws PartInitException { - super.init(site, memento); - requestFilters.readState(memento); - if (memento != null) { - simpleClassNames = Boolean.parseBoolean(memento.getString(SCN_KEY)); - } - } - - public void saveState(IMemento memento) { - super.saveState(memento); - requestFilters.writeState(memento); - memento.putString(SCN_KEY, String.valueOf(simpleClassNames)); - } - - public void createPartControl(Composite parent) { - viewer = new TreeViewer(parent); - viewer.addFilter(new TraceViewerFilter()); - viewer.setLabelProvider(new TraceLabelProvider()); - viewer.setContentProvider(new TraceContentProvider()); - viewer.setInput(new ArrayList()); - makeActions(); - fillActions(); - } - - protected void makeActions() { - actions = new ArrayList<IAction>(); - actions.add(new Action("Flush") { - - public void run() { - getRecords().clear(); - viewer.refresh(true); - } - }); - actions.add(new Action("Expand") { - - public void run() { - Iterator selection = ((IStructuredSelection) viewer.getSelection()).iterator(); - while (selection.hasNext()) { - viewer.expandToLevel(selection.next(), AbstractTreeViewer.ALL_LEVELS); - } - } - }); - actions.add(new Action("Filters") { - - public void run() { - requestFilters.edit(getSite().getShell()); - viewer.refresh(true); - } - }); - Action action = new Action("Simple Class Names", Action.AS_CHECK_BOX) { - }; - actions.add(action); - action.setChecked(simpleClassNames); - action.addPropertyChangeListener(new IPropertyChangeListener() { - - public void propertyChange(PropertyChangeEvent event) { - if (Action.CHECKED.equals(event.getProperty())) { - simpleClassNames = ((Boolean) event.getNewValue()).booleanValue(); - viewer.refresh(true); - } - } - }); - } - - protected void fillActions() { - IToolBarManager tmgr = getViewSite().getActionBars().getToolBarManager(); - IMenuManager mmgr = getViewSite().getActionBars().getMenuManager(); - for (IAction action : actions) { - if (action.getStyle() == Action.AS_CHECK_BOX) { - mmgr.add(action); - } else { - tmgr.add(action); - } - } - } - - public void setFocus() { - if (viewer == null) { - return; - } - Control control = viewer.getControl(); - if (control != null && !control.isDisposed()) { - control.setFocus(); - } - } - - public void traceCommandRequested(EditPart editPart, Request request) { - CommandCreatedEvent event = new CommandCreatedEvent(); - event.editPart = editPart; - event.request = request; - history.push(event); - } - - public void traceCommandCreated(EditPart editPart, Request request, Command command) { - if (history.isEmpty()) { - throw new IllegalStateException("Command requested event was not received."); - } - CommandCreatedEvent event = history.pop(); - event.editPart = editPart; - event.request = request; - event.command = command; - if (history.isEmpty()) { - EditPartTraceRecord record = trace(event, true); - if (record != null) { - TopEditPartTraceRecord lastRecord = getLastRecord(); - if (lastRecord != null && lastRecord.equalTree(record)) { - lastRecord.requested(); - viewer.refresh(lastRecord, true); - } else { - getRecords().add(record); - viewer.add(getRecords(), record); - } - } - } else { - CommandCreatedEvent parent = history.peek(); - if (parent.siblings == null) { - parent.siblings = new ArrayList<CommandCreatedEvent>(); - } - parent.siblings.add(event); - } - } - - protected EditPartTraceRecord trace(CommandCreatedEvent event, boolean top) { - StringBuffer text = new StringBuffer(); - text.append(DevUtils.getSimpleClassName(event.editPart)); - text.append(" : "); - String requestType; - if (event.request != null) { - requestType = String.valueOf(event.request.getType()); - text.append(requestType); - } else { - requestType = null; - } - text.append(" -> "); - text.append(DevUtils.getSimpleClassName(event.command)); - List<EditPartTraceRecord> kids = new ArrayList<EditPartTraceRecord>(); - if (event.editPart != null) { - kids.add(EditPartTraceConstructor.createEditPartNode(event.editPart)); - } - if (event.request != null) { - kids.add(EditPartTraceConstructor.createRequestNode(event.request)); - } - if (event.command != null) { - kids.add(EditPartTraceConstructor.createCommandNode(event.command, event)); - } - if (event.siblings != null) { - for (CommandCreatedEvent sibling : event.siblings) { - EditPartTraceRecord kid = trace(sibling, false); - if (kid != null) { - kids.add(kid); - } - } - } - EditPartTraceRecord[] akids = kids.toArray(new EditPartTraceRecord[kids.size()]); - return top ? new TopEditPartTraceRecord(text.toString(), DevPlugin.EVENT_IMAGE, akids, requestType) : new EditPartTraceRecord(text.toString(), DevPlugin.EVENT_IMAGE, akids); - } - - public CommandCreatedEvent getCurrentEvent() { - if (history.isEmpty()) { - return null; - } - return history.peek(); - } - - private class TraceContentProvider implements ITreeContentProvider { - - public void dispose() { - } - - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - } - - public Object getParent(Object element) { - if (element instanceof TopEditPartTraceRecord) { - return getRecords(); - } else if (element instanceof EditPartTraceRecord) { - return ((EditPartTraceRecord) element).getParent(); - } - return null; - } - - public boolean hasChildren(Object element) { - if (element instanceof Collection) { - return !((Collection) element).isEmpty(); - } else if (element instanceof EditPartTraceRecord) { - return ((EditPartTraceRecord) element).getKids().length > 0; - } - return false; - } - - public Object[] getChildren(Object parentElement) { - if (parentElement instanceof Collection) { - return ((Collection) parentElement).toArray(); - } else if (parentElement instanceof EditPartTraceRecord) { - return ((EditPartTraceRecord) parentElement).getKids(); - } - return null; - } - - public Object[] getElements(Object inputElement) { - return getChildren(inputElement); - } - } - - private static class TraceLabelProvider extends LabelProvider { - - public String getText(Object element) { - String text = null; - if (element instanceof EditPartTraceRecord) { - text = ((EditPartTraceRecord) element).getLabel(); - } - if (text == null) { - return "<unspecified>"; - } - if (element instanceof TopEditPartTraceRecord) { - text += " (" + ((TopEditPartTraceRecord) element).getTimesRequested() + ")"; - } - return text; - } - - public Image getImage(Object element) { - String imageId = null; - if (element instanceof EditPartTraceRecord) { - imageId = ((EditPartTraceRecord) element).getImageId(); - } - if (imageId == null) { - imageId = DevPlugin.INFO_IMAGE; - } - return DevPlugin.getImage(imageId); - } - } - - private class TraceViewerFilter extends ViewerFilter { - - public TraceViewerFilter() { - } - - public boolean select(Viewer viewer, Object parentElement, Object element) { - if (element instanceof TopEditPartTraceRecord) { - String requestType = ((TopEditPartTraceRecord) element).getRequestType(); - if (requestType != null) { - return !requestFilters.isEnabled(requestType); - } - } - return true; - } - } - - private class TopEditPartTraceRecord extends EditPartTraceRecord { - - private String requestType; - - private int timesRequested = 1; - - public TopEditPartTraceRecord(String label, String imageId, EditPartTraceRecord[] kids, String requestType) { - super(label, imageId, kids); - this.requestType = requestType; - } - - protected boolean isSimpleClassNames() { - return simpleClassNames; - } - - public String getRequestType() { - return requestType; - } - - public int getTimesRequested() { - return timesRequested; - } - - public void requested() { - timesRequested++; - } - } -} diff --git a/devtools/org.eclipse.gmf.dev/src/org/eclipse/gmf/dev/EditPartTracer.aj b/devtools/org.eclipse.gmf.dev/src/org/eclipse/gmf/dev/EditPartTracer.aj deleted file mode 100644 index 8c23e636b..000000000 --- a/devtools/org.eclipse.gmf.dev/src/org/eclipse/gmf/dev/EditPartTracer.aj +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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; - -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.Request; -import org.eclipse.gef.commands.Command; - -/** - * @author dstadnik - */ -public aspect EditPartTracer { - - pointcut makingCommandInEditPart(EditPart editPart, Request request) : execution(Command EditPart.getCommand(Request)) && target(editPart) && args(request); - - Command around(EditPart editPart, Request request) : makingCommandInEditPart(editPart, request) { - EditPartTraceUtil.fireCommandRequested(editPart, request); - Command command = null; - try { - command = proceed(editPart, request); - } finally { - EditPartTraceUtil.fireCommandCreated(editPart, request, command); - } - return command; - } - - pointcut makingCommandInEditPolicy(EditPolicy editPolicy, Request request) : execution(Command EditPolicy.getCommand(Request)) && target(editPolicy) && args(request); - - Command around(EditPolicy editPolicy, Request request) : makingCommandInEditPolicy(editPolicy, request) { - Command command = proceed(editPolicy, request); - if (command != null) { - EditPartTraceUtil.addSource(command, editPolicy); - } - return command; - } -} diff --git a/devtools/org.eclipse.gmf.dev/src/org/eclipse/gmf/dev/PartTrackerView.java b/devtools/org.eclipse.gmf.dev/src/org/eclipse/gmf/dev/PartTrackerView.java deleted file mode 100644 index d14a9056e..000000000 --- a/devtools/org.eclipse.gmf.dev/src/org/eclipse/gmf/dev/PartTrackerView.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * 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; - -import java.util.Iterator; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Tree; -import org.eclipse.swt.widgets.TreeItem; -import org.eclipse.ui.IPartListener; -import org.eclipse.ui.ISelectionListener; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.part.ViewPart; - -/** - * @author dstadnik - */ -public class PartTrackerView extends ViewPart { - - private Tree control; - private PartTracker tracker; - - public void createPartControl(Composite parent) { - control = new Tree(parent, SWT.SINGLE); - tracker = new PartTracker(getViewSite().getPage()); - - IAction clearAction = new Action("Clear") { //$NON-NLS-1$ - - public void run() { - if (control != null && !control.isDisposed()) { - control.removeAll(); - } - } - }; - getViewSite().getActionBars().getToolBarManager().add(clearAction); - } - - public void setFocus() { - if (control != null && !control.isDisposed()) { - control.setFocus(); - } - } - - public void dispose() { - if (tracker != null) { - tracker.dispose(); - tracker = null; - } - } - - public TreeItem addItem(String text) { - TreeItem item = new TreeItem(control, SWT.NONE); - if (text != null) { - item.setText(text); - } - scrollDown(item); - return item; - } - - public TreeItem addItem(String text, IWorkbenchPart part) { - if (part == this) { - return null; - } - TreeItem item = new TreeItem(control, SWT.NONE); - Image image = part.getTitleImage(); - if (image != null && !image.isDisposed()) { - item.setImage(image); - } - if (text != null) { - text = text + ' ' + part.getTitle(); - } else { - text = part.getTitle(); - } - item.setText(text); - scrollDown(item); - return item; - } - - public TreeItem addItem(String text, ISelection selection) { - TreeItem item = new TreeItem(control, SWT.NONE); - addItem(item, text, selection); - scrollDown(item); - return item; - } - - private TreeItem addItem(TreeItem item, String text, ISelection selection) { - if (selection == null) { - if (text != null) { - item.setText(text); - } - return null; - } - String value; - if (selection instanceof IStructuredSelection) { - value = "structured selection"; //$NON-NLS-1$ - IStructuredSelection elements = (IStructuredSelection) selection; - if (elements.isEmpty()) { - value += " : empty"; //$NON-NLS-1$ - } else { - Iterator i = elements.iterator(); - while (i.hasNext()) { - Object element = i.next(); - TreeItem elementItem = new TreeItem(item, SWT.NONE); - elementItem.setText(getClassName(element, false) + ':' + String.valueOf(element)); - } - } - } else { - value = selection.toString(); - } - if (text != null) { - value = text + ' ' + value; - } - item.setText(value); - item.setExpanded(true); - return item; - } - - private void scrollDown(TreeItem item) { - control.showItem(item); - } - - public Object getAdapter(Class adapter) { - if (Control.class.isAssignableFrom(adapter)) { - return control; - } - return super.getAdapter(adapter); - } - - public static String getClassName(Object obj, boolean fqn) { - if (obj == null) { - return null; - } - String name = obj.getClass().getName(); - return fqn ? name : name.substring(name.lastIndexOf('.') + 1); - } - - private class PartTracker implements IPartListener, ISelectionListener { - - private IWorkbenchPage page; - - public PartTracker(IWorkbenchPage page) { - this.page = page; - page.addPartListener(this); - page.addSelectionListener(this); - } - - public void partActivated(IWorkbenchPart part) { - addItem("[actv]", part); //$NON-NLS-1$ - } - - public void partDeactivated(IWorkbenchPart part) { - addItem("[deac]", part); //$NON-NLS-1$ - } - - public void partBroughtToTop(IWorkbenchPart part) { - addItem("[btop]", part); //$NON-NLS-1$ - } - - public void partOpened(IWorkbenchPart part) { - addItem("[opnd]", part); //$NON-NLS-1$ - } - - public void partClosed(IWorkbenchPart part) { - addItem("[clsd]", part); //$NON-NLS-1$ - } - - public void selectionChanged(IWorkbenchPart part, ISelection selection) { - addItem("[selc]", selection); //$NON-NLS-1$ - } - - public void dispose() { - page.removeSelectionListener(this); - page.removePartListener(this); - } - } -} |