Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarin Swanson2001-08-16 10:11:48 +0000
committerDarin Swanson2001-08-16 10:11:48 +0000
commit6a1d050801c6719cf0a8bd6c840b6d9d7d42d616 (patch)
tree2713b4b0a9cea2042f52a56f763b6d4552e3d906
parent27fb7aa545d959d1e646701c6c247a8032462b11 (diff)
downloadeclipse.platform.debug-6a1d050801c6719cf0a8bd6c840b6d9d7d42d616.tar.gz
eclipse.platform.debug-6a1d050801c6719cf0a8bd6c840b6d9d7d42d616.tar.xz
eclipse.platform.debug-6a1d050801c6719cf0a8bd6c840b6d9d7d42d616.zip
1GDXWST: ITPDUI:WIN2000 - Feature: Copy value to clipboard
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/CopyToClipboardActionDelegate.java47
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/CopyVariablesToClipboardActionDelegate.java101
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIResources.properties5
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java1
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/InspectorView.java7
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/VariablesView.java4
6 files changed, 140 insertions, 25 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/CopyToClipboardActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/CopyToClipboardActionDelegate.java
index bcf50ddb9..e02f9709a 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/CopyToClipboardActionDelegate.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/CopyToClipboardActionDelegate.java
@@ -17,7 +17,7 @@ import org.eclipse.swt.widgets.Display;
public class CopyToClipboardActionDelegate extends ControlActionDelegate {
- private ContentViewer fViewer;
+ protected ContentViewer fViewer;
private static final String PREFIX= "copy_to_clipboard_action.";
@@ -47,8 +47,7 @@ public class CopyToClipboardActionDelegate extends ControlActionDelegate {
* @see ControlActionDelegate
*/
protected void doAction(Object element, StringBuffer buffer) {
- IDebugElement de= (IDebugElement) element;
- append(de, buffer, (ILabelProvider)fViewer.getLabelProvider(), 0);
+ append(element, buffer, (ILabelProvider)fViewer.getLabelProvider(), 0);
}
/**
@@ -71,20 +70,20 @@ public class CopyToClipboardActionDelegate extends ControlActionDelegate {
* to the buffer. For elements down to stack frames, children representations
* are append to the buffer as well.
*/
- protected void append(IDebugElement e, StringBuffer buffer, ILabelProvider lp, int indent) {
+ protected void append(Object e, StringBuffer buffer, ILabelProvider lp, int indent) {
for (int i= 0; i < indent; i++) {
buffer.append('\t');
}
buffer.append(lp.getText(e));
buffer.append(System.getProperty("line.separator"));
- if (e.getElementType() < IDebugElement.STACK_FRAME) {
- IDebugElement[] children= new IDebugElement[]{};
+ if (shouldAppendChildren(e)) {
+ Object[] children= new Object[0];
try {
- children= e.getChildren();
+ children= getChildren(e);
} catch (DebugException de) {
}
for (int i = 0;i < children.length; i++) {
- IDebugElement de= children[i];
+ Object de= children[i];
append(de, buffer, lp, indent + 1);
}
}
@@ -94,15 +93,14 @@ public class CopyToClipboardActionDelegate extends ControlActionDelegate {
return IDebugHelpContextIds.COPY_TO_CLIPBOARD_ACTION;
}
+ protected Object[] getChildren(Object e) throws DebugException {
+ return ((IDebugElement)e).getChildren();
+ }
/**
* Do the specific action using the current selection.
*/
public void run() {
- LaunchesView view= getLaunchesView(fMode);
- if (view == null) {
- return;
- }
- final Iterator iter= pruneSelection(view);
+ final Iterator iter= pruneSelection();
String pluginId= DebugUIPlugin.getDefault().getDescriptor().getUniqueIdentifier();
BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
public void run() {
@@ -125,17 +123,15 @@ public class CopyToClipboardActionDelegate extends ControlActionDelegate {
* That is, if both a parent and a child are in a selection
* remove the child.
*/
- protected Iterator pruneSelection(LaunchesView view) {
- IStructuredSelection selection= (IStructuredSelection)view.getSite().getSelectionProvider().getSelection();
+ protected Iterator pruneSelection() {
+ IStructuredSelection selection= (IStructuredSelection)fViewer.getSelection();
List elements= new ArrayList(selection.size());
Iterator iter= selection.iterator();
while (iter.hasNext()) {
Object element= iter.next();
if (isEnabledFor(element)) {
- IDebugElement de= (IDebugElement)element;
- IDebugElement parent= de.getParent();
- if(walkHierarchy(de, elements)) {
- elements.add(de);
+ if(walkHierarchy(element, elements)) {
+ elements.add(element);
}
}
}
@@ -144,10 +140,13 @@ public class CopyToClipboardActionDelegate extends ControlActionDelegate {
/**
* Returns whether the parent of the specified
- * debug element is already contained in the collection.
+ * element is already contained in the collection.
*/
- protected boolean walkHierarchy(IDebugElement de, List elements) {
- IDebugElement parent= de.getParent();
+ protected boolean walkHierarchy(Object element, List elements) {
+ Object parent= null;
+ if (element instanceof IDebugElement) {
+ parent= ((IDebugElement)element).getParent();
+ }
if (parent == null) {
return true;
}
@@ -163,4 +162,8 @@ public class CopyToClipboardActionDelegate extends ControlActionDelegate {
*/
protected void setActionImages(IAction action) {
}
+
+ protected boolean shouldAppendChildren(Object e) {
+ return e instanceof IDebugElement && ((IDebugElement)e).getElementType() < IDebugElement.STACK_FRAME;
+ }
} \ No newline at end of file
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/CopyVariablesToClipboardActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/CopyVariablesToClipboardActionDelegate.java
new file mode 100644
index 000000000..91115b4fa
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/CopyVariablesToClipboardActionDelegate.java
@@ -0,0 +1,101 @@
+package org.eclipse.debug.internal.ui;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+import java.util.Iterator;
+import java.util.List;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.*;
+import org.eclipse.jface.viewers.*;
+
+/**
+ * Used to copy the values of variables to the clipboard from
+ * the Variables and Inspector views.
+ */
+public class CopyVariablesToClipboardActionDelegate extends CopyToClipboardActionDelegate {
+
+ private static final String PREFIX= "copy_variables_to_clipboard_action.";
+
+ protected String getHelpContextId() {
+ return IDebugHelpContextIds.COPY_VARIABLES_TO_CLIPBOARD_ACTION;
+ }
+
+ /**
+ * Only append children that are visible in the tree viewer
+ */
+ protected boolean shouldAppendChildren(Object e) {
+ return((TreeViewer)fViewer).getExpandedState(e);
+ }
+
+ /**
+ * @see ControlActionDelegate
+ */
+ public void initializeForOwner(ControlAction controlAction) {
+ controlAction.setEnabled(!controlAction.getStructuredSelection().isEmpty());
+ fViewer = (ContentViewer)controlAction.getSelectionProvider();
+ }
+
+ /**
+ * @see ControlActionDelegate
+ */
+ protected String getPrefix() {
+ return PREFIX;
+ }
+
+ /**
+ * Returns the children of the parent after applying the filters
+ * that are present in the viewer.
+ */
+ protected Object[] getChildren(Object parent) {
+ Object[] children= ((BasicContentProvider)fViewer.getContentProvider()).getChildren(parent);
+ ViewerFilter[] filters= ((StructuredViewer)fViewer).getFilters();
+ if (filters != null) {
+ for (int i= 0; i < filters.length; i++) {
+ ViewerFilter f = filters[i];
+ children = f.filter(fViewer, parent, children);
+ }
+ }
+ return children;
+ }
+
+ /**
+ * @see ControlActionDelegate
+ */
+ public boolean isEnabledFor(Object element) {
+ return element instanceof IDebugElement || element instanceof InspectItem;
+ }
+
+ /**
+ * Returns whether the parent of the specified
+ * element is already contained in the collection.
+ */
+ protected boolean walkHierarchy(Object element, List elements) {
+ IDebugElement parent= null;
+ if (element instanceof IVariable) {
+ parent= ((IVariable)element).getParent();
+ }
+ if (parent == null || parent.getElementType() == IDebugElement.STACK_FRAME) {
+ return true;
+ }
+ Iterator i= elements.iterator();
+ while (i.hasNext()) {
+ Object o= i.next();
+ try {
+ if (o instanceof IVariable
+ && ((IVariable)o).getValue().equals(parent)) {
+ return false;
+ }
+ if (o instanceof InspectItem
+ && ((InspectItem)o).getValue().equals(parent)) {
+ return false;
+ }
+ } catch (DebugException e) {
+ }
+ }
+
+ return walkHierarchy(((IValue)parent).getVariable(), elements);
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIResources.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIResources.properties
index 88b00336d..05014f465 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIResources.properties
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIResources.properties
@@ -87,6 +87,11 @@ copy_to_clipboard_action.toolTipText=Copy to Clipboard
##only needed due to inheritance
copy_to_clipboard_action.status=
+copy_variables_to_clipboard_action.text=Copy &Variables
+copy_variables_to_clipboard_action.toolTipText=Copy to Clipboard
+##only needed due to inheritance
+copy_variables_to_clipboard_action.status=
+
cut_action.label=Cu&t@Ctrl+X
cut_action.tooltip=Cut
cut_action.description=Cut
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java
index 404562b58..dbb22490a 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java
@@ -25,6 +25,7 @@ public interface IDebugHelpContextIds {
public static final String CHANGE_VALUE_ACTION = PREFIX + "change_value_action_context";
public static final String CLEAR_CONSOLE_ACTION = PREFIX + "clear_console_action_context";
public static final String COPY_TO_CLIPBOARD_ACTION = PREFIX + "copy_to_clipboard_action_context";
+ public static final String COPY_VARIABLES_TO_CLIPBOARD_ACTION = PREFIX + "copy_variables_to_clipboard_action_context";
public static final String DISCONNECT_ACTION = PREFIX + "disconnect_action_context";
public static final String ENABLE_DISABLE_BREAKPOINT_ACTION = PREFIX + "enable_disable_breakpoint_action_context";
public static final String LAUNCH_SELECTION_ACTION = PREFIX + "launch_selection_action_context";
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/InspectorView.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/InspectorView.java
index 964479f7d..a11f20f7b 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/InspectorView.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/InspectorView.java
@@ -21,7 +21,7 @@ public class InspectorView extends AbstractDebugView {
protected RemoveFromInspectorAction fRemoveFromInspectorAction;
protected RemoveAllFromInspectorAction fRemoveAllFromInspectorAction;
protected ChangeVariableValueAction fChangeVariableAction;
-
+ protected ControlAction fCopyToClipboardAction;
/**
* @see IWorkbenchPart
*/
@@ -68,6 +68,8 @@ public class InspectorView extends AbstractDebugView {
fChangeVariableAction= new ChangeVariableValueAction(fViewer);
fChangeVariableAction.setEnabled(false);
+
+ fCopyToClipboardAction= new ControlAction(fViewer, new CopyVariablesToClipboardActionDelegate());
}
/**
@@ -86,12 +88,11 @@ public class InspectorView extends AbstractDebugView {
* Adds items to the context menu including any extension defined actions.
*/
protected void fillContextMenu(IMenuManager menu) {
-
- // Add the actions defined in this view
menu.add(new Separator(IDebugUIConstants.EMPTY_EXPRESSION_GROUP));
menu.add(new Separator(IDebugUIConstants.EXPRESSION_GROUP));
menu.add(fAddToInspectorAction);
menu.add(fChangeVariableAction);
+ menu.add(fCopyToClipboardAction);
menu.add(fRemoveFromInspectorAction);
menu.add(fRemoveAllFromInspectorAction);
menu.add(new Separator(IDebugUIConstants.EMPTY_RENDER_GROUP));
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/VariablesView.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/VariablesView.java
index 16d215afb..b47c7347e 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/VariablesView.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/VariablesView.java
@@ -18,6 +18,7 @@ public class VariablesView extends AbstractDebugView implements ISelectionListen
protected ShowTypesAction fShowTypesAction;
protected ChangeVariableValueAction fChangeVariableAction;
protected AddToInspectorAction fAddToInspectorAction;
+ protected ControlAction fCopyToClipboardAction;
/**
* Remove myself as a selection listener to the <code>LaunchesView</code> in this perspective.
@@ -129,6 +130,8 @@ public class VariablesView extends AbstractDebugView implements ISelectionListen
fChangeVariableAction= new ChangeVariableValueAction(fViewer);
fChangeVariableAction.setEnabled(false);
+
+ fCopyToClipboardAction= new ControlAction(fViewer, new CopyVariablesToClipboardActionDelegate());
}
/**
@@ -149,6 +152,7 @@ public class VariablesView extends AbstractDebugView implements ISelectionListen
menu.add(new Separator(IDebugUIConstants.VARIABLE_GROUP));
menu.add(fAddToInspectorAction);
menu.add(fChangeVariableAction);
+ menu.add(fCopyToClipboardAction);
menu.add(new Separator(IDebugUIConstants.EMPTY_RENDER_GROUP));
menu.add(new Separator(IDebugUIConstants.RENDER_GROUP));
menu.add(fShowTypesAction);

Back to the top