Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordstadnik2006-05-11 10:10:16 -0400
committerdstadnik2006-05-11 10:10:16 -0400
commit30639952fb5595f16977d83028e54d7510107f50 (patch)
tree68d16555d2f60978d438e4bb178a899f795fca55 /devtools
parentc847ad033470b1e743d1ae31d9707a2f274ed92c (diff)
downloadorg.eclipse.gmf-tooling-30639952fb5595f16977d83028e54d7510107f50.tar.gz
org.eclipse.gmf-tooling-30639952fb5595f16977d83028e54d7510107f50.tar.xz
org.eclipse.gmf-tooling-30639952fb5595f16977d83028e54d7510107f50.zip
tracing aspect
Diffstat (limited to 'devtools')
-rw-r--r--devtools/org.eclipse.gmf.dev/EditPartTracer.aj80
1 files changed, 80 insertions, 0 deletions
diff --git a/devtools/org.eclipse.gmf.dev/EditPartTracer.aj b/devtools/org.eclipse.gmf.dev/EditPartTracer.aj
new file mode 100644
index 000000000..0587a51b1
--- /dev/null
+++ b/devtools/org.eclipse.gmf.dev/EditPartTracer.aj
@@ -0,0 +1,80 @@
+/*
+ * 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.diagram.ui;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * @author dstadnik
+ */
+public aspect EditPartTracer {
+
+ pointcut makingCommand(EditPart editPart, Request request) : (execution(Command ConnectionEditPart.getCommand(Request)) || execution(Command GraphicalEditPart.getCommand(Request))) && target(editPart) && args(request);
+
+ Command around(EditPart editPart, Request request) : makingCommand(editPart, request) {
+ fireCommandRequested(editPart, request);
+ Map sources = new HashMap();
+ Command command = null;
+ try {
+ command = proceed(editPart, request);
+ } finally {
+ fireCommandCreated(editPart, request, command, sources);
+ }
+ return command;
+ }
+
+ private static Object getTraceView() {
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (window == null) {
+ return null;
+ }
+ IWorkbenchPage page = window.getActivePage();
+ if (page == null) {
+ return null;
+ }
+ return page.findView("org.eclipse.gmf.dev.EditPartTraceView");
+ }
+
+ private void fireCommandRequested(EditPart editPart, Request request) {
+ Object view = getTraceView();
+ if (view == null) {
+ return;
+ }
+ try {
+ view.getClass().getDeclaredMethod("traceCommandRequested", EditPart.class, Request.class).invoke(view, editPart, request);
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ }
+
+ private void fireCommandCreated(EditPart editPart, Request request, Command command, Map sources) {
+ Object view = getTraceView();
+ if (view == null) {
+ return;
+ }
+ try {
+ view.getClass().getDeclaredMethod("traceCommandCreated", EditPart.class, Request.class, Command.class, Map.class).invoke(view, editPart, request, command, sources);
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ }
+}

Back to the top