Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordstadnik2006-09-05 11:48:38 -0400
committerdstadnik2006-09-05 11:48:38 -0400
commitaf314f23c563ac43cc3db15391b21a3d437f3d6c (patch)
treed9c7dbc3db7a1f17e47b291760cee30c99abd98b /devtools
parent8e05a8784fced3c4c180f68bec1cecdfa99dd8f3 (diff)
downloadorg.eclipse.gmf-tooling-af314f23c563ac43cc3db15391b21a3d437f3d6c.tar.gz
org.eclipse.gmf-tooling-af314f23c563ac43cc3db15391b21a3d437f3d6c.tar.xz
org.eclipse.gmf-tooling-af314f23c563ac43cc3db15391b21a3d437f3d6c.zip
#117014 Add option to toggle between simple and qualified class names in edit part tracer view
Diffstat (limited to 'devtools')
-rw-r--r--devtools/org.eclipse.gmf.dev/src/org/eclipse/gmf/dev/DevUtils.java22
-rw-r--r--devtools/org.eclipse.gmf.dev/src/org/eclipse/gmf/dev/EditPartTraceRecord.java14
-rw-r--r--devtools/org.eclipse.gmf.dev/src/org/eclipse/gmf/dev/EditPartTraceView.java37
3 files changed, 70 insertions, 3 deletions
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
index ae0267954..be9317b72 100644
--- 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
@@ -12,13 +12,33 @@
package org.eclipse.gmf.dev;
import java.lang.reflect.Field;
+import java.util.StringTokenizer;
/**
* @author dstadnik
*/
public class DevUtils {
- private 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) {
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
index daf797f2c..305b93984 100644
--- 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
@@ -20,6 +20,7 @@ public class EditPartTraceRecord {
private transient EditPartTraceRecord parent;
private String label;
+ private String simpleLabel;
private String imageId;
private EditPartTraceRecord[] kids;
@@ -47,7 +48,20 @@ public class EditPartTraceRecord {
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;
}
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
index 7f1f83442..f5cf759d8 100644
--- 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
@@ -22,7 +22,10 @@ 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;
@@ -43,6 +46,8 @@ import org.eclipse.ui.part.ViewPart;
*/
public class EditPartTraceView extends ViewPart {
+ private static final String SCN_KEY = "simple_class_names"; //$NON-NLS-1$
+
private TreeViewer viewer;
private List<IAction> actions;
@@ -51,6 +56,8 @@ public class EditPartTraceView extends ViewPart {
private Stack<CommandCreatedEvent> history = new Stack<CommandCreatedEvent>();
+ private boolean simpleClassNames;
+
private List<EditPartTraceRecord> getRecords() {
return (List<EditPartTraceRecord>) viewer.getInput();
}
@@ -66,11 +73,15 @@ public class EditPartTraceView extends ViewPart {
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) {
@@ -108,12 +119,30 @@ public class EditPartTraceView extends ViewPart {
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 mgr = getViewSite().getActionBars().getToolBarManager();
+ IToolBarManager tmgr = getViewSite().getActionBars().getToolBarManager();
+ IMenuManager mmgr = getViewSite().getActionBars().getMenuManager();
for (IAction action : actions) {
- mgr.add(action);
+ if (action.getStyle() == Action.AS_CHECK_BOX) {
+ mmgr.add(action);
+ } else {
+ tmgr.add(action);
+ }
}
}
@@ -300,6 +329,10 @@ public class EditPartTraceView extends ViewPart {
this.requestType = requestType;
}
+ protected boolean isSimpleClassNames() {
+ return simpleClassNames;
+ }
+
public String getRequestType() {
return requestType;
}

Back to the top