diff options
author | dstadnik | 2006-05-12 13:35:17 +0000 |
---|---|---|
committer | dstadnik | 2006-05-12 13:35:17 +0000 |
commit | fc1a2c0f17e31389f46c38d3eadee1f3c46bb78a (patch) | |
tree | e949e2a4c08f0185ee1c7a6e361ee631627ee9cd /devtools/org.eclipse.gmf.dev.runtime | |
parent | 4d9d08c81b98868487e2b28b90db6bc397995d40 (diff) | |
download | org.eclipse.gmf-tooling-fc1a2c0f17e31389f46c38d3eadee1f3c46bb78a.tar.gz org.eclipse.gmf-tooling-fc1a2c0f17e31389f46c38d3eadee1f3c46bb78a.tar.xz org.eclipse.gmf-tooling-fc1a2c0f17e31389f46c38d3eadee1f3c46bb78a.zip |
initial
Diffstat (limited to 'devtools/org.eclipse.gmf.dev.runtime')
8 files changed, 278 insertions, 0 deletions
diff --git a/devtools/org.eclipse.gmf.dev.runtime/.classpath b/devtools/org.eclipse.gmf.dev.runtime/.classpath new file mode 100644 index 000000000..751c8f2e5 --- /dev/null +++ b/devtools/org.eclipse.gmf.dev.runtime/.classpath @@ -0,0 +1,7 @@ +<?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 new file mode 100644 index 000000000..ba077a403 --- /dev/null +++ b/devtools/org.eclipse.gmf.dev.runtime/.cvsignore @@ -0,0 +1 @@ +bin diff --git a/devtools/org.eclipse.gmf.dev.runtime/.project b/devtools/org.eclipse.gmf.dev.runtime/.project new file mode 100644 index 000000000..fecbfa142 --- /dev/null +++ b/devtools/org.eclipse.gmf.dev.runtime/.project @@ -0,0 +1,28 @@ +<?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 new file mode 100644 index 000000000..355610e06 --- /dev/null +++ b/devtools/org.eclipse.gmf.dev.runtime/META-INF/MANIFEST.MF @@ -0,0 +1,9 @@ +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 new file mode 100644 index 000000000..34d2e4d2d --- /dev/null +++ b/devtools/org.eclipse.gmf.dev.runtime/build.properties @@ -0,0 +1,4 @@ +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 new file mode 100644 index 000000000..43e84ab47 --- /dev/null +++ b/devtools/org.eclipse.gmf.dev.runtime/plugin.xml @@ -0,0 +1,20 @@ +<?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 new file mode 100644 index 000000000..1aacc0b0c --- /dev/null +++ b/devtools/org.eclipse.gmf.dev.runtime/src/org/eclipse/gmf/dev/runtime/ExtEditPartRequestFiltersProvider.java @@ -0,0 +1,24 @@ +/* + * 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 new file mode 100644 index 000000000..609e2647d --- /dev/null +++ b/devtools/org.eclipse.gmf.dev.runtime/src/org/eclipse/gmf/dev/runtime/ExtEditPartTraceContributor.java @@ -0,0 +1,185 @@ +/* + * 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.CompositeCommand; +import org.eclipse.gmf.runtime.common.core.command.ICommand; +import org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy; +import org.eclipse.gmf.runtime.diagram.ui.commands.EtoolsProxyCommand; +import org.eclipse.gmf.runtime.diagram.ui.commands.SemanticCreateCommand; +import org.eclipse.gmf.runtime.diagram.ui.requests.EditCommandRequestWrapper; +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)); + } + } + } + + public static EditPartTraceRecord createRequestNode(IEditCommandRequest request) { + List<EditPartTraceRecord> kids = new ArrayList<EditPartTraceRecord>(); + // kids.add(new EditPartTraceRecord("edit helper context " + request.getEditHelperContext())); + 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()) { + if ("org.eclipse.gmf.dev.sources".equals(key)) { + continue; + } + 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 EtoolsProxyCommand) { + ICommand realCommand = ((EtoolsProxyCommand) 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 CompositeCommand) { + Iterator subCommands = ((CompositeCommand) 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 |