diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/BaseValueAction.java b/java/debugger/impl/src/com/intellij/debugger/actions/BaseValueAction.java
index 6b5984cc84ab..bd0373a5c439 100644
--- a/java/debugger/impl/src/com/intellij/debugger/actions/BaseValueAction.java
+++ b/java/debugger/impl/src/com/intellij/debugger/actions/BaseValueAction.java
@@ -27,7 +27,7 @@ import com.intellij.debugger.impl.DebuggerContextImpl;
import com.intellij.debugger.impl.DebuggerUtilsEx;
import com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl;
import com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl;
-import com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl;
+import com.intellij.debugger.ui.tree.ValueDescriptor;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
@@ -41,69 +41,73 @@ import org.jetbrains.annotations.Nullable;
* @author Jeka
*/
public abstract class BaseValueAction extends DebuggerAction {
+
public void actionPerformed(AnActionEvent e) {
final DataContext actionContext = e.getDataContext();
- final Project project = PlatformDataKeys.PROJECT.getData(actionContext);
- final Value value = getValue(actionContext);
+ final DebuggerTreeNodeImpl node = getSelectedNode(actionContext);
+ final Value value = getValue(node);
if (value == null) {
return;
}
-
- DebuggerManagerEx debuggerManager = DebuggerManagerEx.getInstanceEx(project);
- if(debuggerManager != null) {
- final DebuggerContextImpl debuggerContext = debuggerManager.getContext();
-
- if(debuggerContext != null && debuggerContext.getDebuggerSession() != null) {
- final ProgressWindowWithNotification progressWindow = new ProgressWindowWithNotification(true, project);
- SuspendContextCommandImpl copyValueAction = new SuspendContextCommandImpl(debuggerContext.getSuspendContext()) {
- public Priority getPriority() {
- return Priority.HIGH;
- }
-
- public void contextAction() throws Exception {
- //noinspection HardCodedStringLiteral
- progressWindow.setText(DebuggerBundle.message("progress.evaluating", "toString()"));
-
- final String valueAsString = DebuggerUtilsEx.getValueOrErrorAsString(debuggerContext.createEvaluationContext(), value);
-
- if (progressWindow.isCanceled()) return;
-
- DebuggerInvocationUtil.swingInvokeLater(project, new Runnable() {
- public void run() {
- String text = valueAsString;
-
- if (text == null) text = "";
-
- processText(project, text);
- }
- });
- }
- };
- progressWindow.setTitle(DebuggerBundle.message("title.evaluating"));
- debuggerContext.getDebugProcess().getManagerThread().startProgress(copyValueAction, progressWindow);
- }
+ final Project project = PlatformDataKeys.PROJECT.getData(actionContext);
+ final DebuggerManagerEx debuggerManager = DebuggerManagerEx.getInstanceEx(project);
+ if(debuggerManager == null) {
+ return;
}
+ final DebuggerContextImpl debuggerContext = debuggerManager.getContext();
+ if (debuggerContext == null || debuggerContext.getDebuggerSession() == null) {
+ return;
+ }
+
+ final ProgressWindowWithNotification progressWindow = new ProgressWindowWithNotification(true, project);
+ SuspendContextCommandImpl getTextCommand = new SuspendContextCommandImpl(debuggerContext.getSuspendContext()) {
+ public Priority getPriority() {
+ return Priority.HIGH;
+ }
+
+ public void contextAction() throws Exception {
+ //noinspection HardCodedStringLiteral
+ progressWindow.setText(DebuggerBundle.message("progress.evaluating", "toString()"));
+
+ final String valueAsString = DebuggerUtilsEx.getValueOrErrorAsString(debuggerContext.createEvaluationContext(), value);
+
+ if (progressWindow.isCanceled()) {
+ return;
+ }
+
+ DebuggerInvocationUtil.swingInvokeLater(project, new Runnable() {
+ public void run() {
+ String text = valueAsString;
+ if (text == null) {
+ text = "";
+ }
+ processText(project, text, node, debuggerContext);
+ }
+ });
+ }
+ };
+ progressWindow.setTitle(DebuggerBundle.message("title.evaluating"));
+ debuggerContext.getDebugProcess().getManagerThread().startProgress(getTextCommand, progressWindow);
}
- protected abstract void processText(final Project project, String text);
+ protected abstract void processText(final Project project, String text, DebuggerTreeNodeImpl node, DebuggerContextImpl debuggerContext);
public void update(AnActionEvent e) {
Presentation presentation = e.getPresentation();
- Value value = getValue(e.getDataContext());
+ Value value = getValue(getSelectedNode(e.getDataContext()));
presentation.setEnabled(value != null);
presentation.setVisible(value != null);
}
@Nullable
- public static Value getValue(DataContext context) {
- DebuggerTreeNodeImpl selectedNode = getSelectedNode(context);
- if (selectedNode == null) {
+ private static Value getValue(final DebuggerTreeNodeImpl node) {
+ if (node == null) {
return null;
}
- NodeDescriptorImpl descriptor = selectedNode.getDescriptor();
- if (!(descriptor instanceof ValueDescriptorImpl)) {
+ NodeDescriptorImpl descriptor = node.getDescriptor();
+ if (!(descriptor instanceof ValueDescriptor)) {
return null;
}
- return ((ValueDescriptorImpl)descriptor).getValue();
+ return ((ValueDescriptor)descriptor).getValue();
}
}
\ No newline at end of file
diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/CompareValueWithClipboardAction.java b/java/debugger/impl/src/com/intellij/debugger/actions/CompareValueWithClipboardAction.java
index 4f9f6cbdf741..24f5fa0fd12f 100644
--- a/java/debugger/impl/src/com/intellij/debugger/actions/CompareValueWithClipboardAction.java
+++ b/java/debugger/impl/src/com/intellij/debugger/actions/CompareValueWithClipboardAction.java
@@ -16,6 +16,8 @@
package com.intellij.debugger.actions;
import com.intellij.debugger.DebuggerBundle;
+import com.intellij.debugger.impl.DebuggerContextImpl;
+import com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl;
import com.intellij.openapi.diff.*;
import com.intellij.openapi.ide.CopyPasteManager;
import com.intellij.openapi.project.Project;
@@ -30,7 +32,7 @@ import java.awt.datatransfer.Transferable;
* @author Jeka
*/
public class CompareValueWithClipboardAction extends BaseValueAction {
- protected void processText(final Project project, final String text) {
+ protected void processText(final Project project, final String text, DebuggerTreeNodeImpl node, DebuggerContextImpl debuggerContext) {
DiffManager.getInstance().getDiffTool().show(new ClipboardSelectionContents(text, project));
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/CopyValueAction.java b/java/debugger/impl/src/com/intellij/debugger/actions/CopyValueAction.java
index 676061bf35b4..256566557ae1 100644
--- a/java/debugger/impl/src/com/intellij/debugger/actions/CopyValueAction.java
+++ b/java/debugger/impl/src/com/intellij/debugger/actions/CopyValueAction.java
@@ -15,6 +15,8 @@
*/
package com.intellij.debugger.actions;
+import com.intellij.debugger.impl.DebuggerContextImpl;
+import com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl;
import com.intellij.openapi.ide.CopyPasteManager;
import com.intellij.openapi.project.Project;
@@ -24,7 +26,7 @@ import java.awt.datatransfer.StringSelection;
* @author Jeka
*/
public class CopyValueAction extends BaseValueAction {
- protected void processText(final Project project, final String text) {
+ protected void processText(final Project project, final String text, DebuggerTreeNodeImpl node, DebuggerContextImpl debuggerContext) {
CopyPasteManager.getInstance().setContents(new StringSelection(text));
}
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/ViewTextAction.java b/java/debugger/impl/src/com/intellij/debugger/actions/ViewTextAction.java
new file mode 100644
index 000000000000..dafaacb3aba1
--- /dev/null
+++ b/java/debugger/impl/src/com/intellij/debugger/actions/ViewTextAction.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2000-2012 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.debugger.actions;
+
+import com.intellij.debugger.engine.evaluation.EvaluateException;
+import com.intellij.debugger.engine.evaluation.TextWithImports;
+import com.intellij.debugger.impl.DebuggerContextImpl;
+import com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeExpression;
+import com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl;
+import com.intellij.openapi.editor.EditorFactory;
+import com.intellij.openapi.editor.ex.EditorEx;
+import com.intellij.openapi.fileTypes.FileTypes;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.DialogWrapper;
+import com.intellij.openapi.ui.Messages;
+import com.intellij.ui.EditorTextField;
+
+import javax.swing.*;
+import java.awt.*;
+
+/*
+ * @author Jeka
+ */
+public class ViewTextAction extends BaseValueAction {
+ protected void processText(final Project project, final String text, DebuggerTreeNodeImpl node, DebuggerContextImpl debuggerContext) {
+ try {
+ final TextWithImports expressionText = DebuggerTreeNodeExpression.createEvaluationText(node, debuggerContext);
+ final MyDialog dialog = new MyDialog(project);
+ final String title = "View Text: \"" + expressionText.getText() + "\"";
+ dialog.setTitle(title);
+ dialog.setText(text);
+ dialog.show();
+ }
+ catch (EvaluateException e) {
+ Messages.showErrorDialog(project, e.getMessage(), "View Text");
+ }
+ }
+
+
+ private static class MyDialog extends DialogWrapper {
+
+ private EditorTextField myTextViewer;
+
+ private MyDialog(Project project) {
+ super(project, false);
+ setModal(false);
+ setCancelButtonText("Close");
+ setCrossClosesWindow(true);
+
+ myTextViewer = new TextViewer(project);
+ init();
+ }
+
+ public void setText(String text) {
+ myTextViewer.setText(text);
+ }
+
+ protected Action[] createActions() {
+ return new Action[] {getCancelAction()};
+ }
+
+ protected String getDimensionServiceKey() {
+ return "#com.intellij.debugger.actions.ViewTextAction";
+ }
+
+ protected JComponent createCenterPanel() {
+ final JPanel panel = new JPanel(new BorderLayout());
+ panel.add(myTextViewer, BorderLayout.CENTER);
+ panel.setPreferredSize(new Dimension(300, 200));
+ return panel;
+ }
+
+ }
+
+
+ private static class TextViewer extends EditorTextField {
+
+ private TextViewer(Project project) {
+ super(EditorFactory.getInstance().createDocument(""), project, FileTypes.PLAIN_TEXT, true, false);
+ }
+
+ protected EditorEx createEditor() {
+ final EditorEx editor = super.createEditor();
+ editor.setHorizontalScrollbarVisible(true);
+ editor.setVerticalScrollbarVisible(true);
+ editor.setEmbeddedIntoDialogWrapper(true);
+ editor.getComponent().setPreferredSize(null);
+ return editor;
+ }
+ }
+
+}
diff --git a/platform/platform-resources-en/src/messages/ActionsBundle.properties b/platform/platform-resources-en/src/messages/ActionsBundle.properties
index 389e75e26a1f..1bd07cf41aed 100644
--- a/platform/platform-resources-en/src/messages/ActionsBundle.properties
+++ b/platform/platform-resources-en/src/messages/ActionsBundle.properties
@@ -868,6 +868,8 @@ group.XDebugger.settings.text=Settings
action.Debugger.AdjustArrayRange.text=Adjust Range...
action.Debugger.Inspect.text=Inspect
action.Debugger.CopyValue.text=Copy Value
+action.Debugger.ViewText.text=View Text
+action.Debugger.ViewText.description=View text value of selected node in a separate pane
action.Debugger.CompareValueWithClipboard.text=Compare Value with Clipboard
action.Debugger.CustomizeContextView.text=Customize Data Views...
action.Debugger.CustomizeThreadsView.text=Customize Threads View...
diff --git a/resources/src/idea/JavaActions.xml b/resources/src/idea/JavaActions.xml
index d163c65f0ddb..b510b4d4ce76 100644
--- a/resources/src/idea/JavaActions.xml
+++ b/resources/src/idea/JavaActions.xml
@@ -128,6 +128,7 @@
+
@@ -210,6 +211,7 @@
+
@@ -230,6 +232,7 @@
+
@@ -250,6 +253,7 @@
+
@@ -290,6 +294,7 @@
+