register PyDebugger.ViewArray action
authorAlexander Marchuk <Alexander.Marchuk@jetbrains.com>
Thu, 14 Aug 2014 14:18:18 +0000 (18:18 +0400)
committerAlexander Marchuk <Alexander.Marchuk@jetbrains.com>
Thu, 14 Aug 2014 14:18:18 +0000 (18:18 +0400)
platform/platform-resources-en/src/messages/ActionsBundle.properties
python/src/META-INF/python-core.xml
python/src/com/jetbrains/python/actions/PyViewArrayAction.java [new file with mode: 0644]

index 47c4cef9220719e667794ba4f24f967b4905d9a2..947ac60d074a0aca896f70e1801ca4aa59c3caf6 100644 (file)
@@ -965,6 +965,7 @@ action.Debugger.AddToWatch.text=Add to Watches
 action.Debugger.EvaluateInConsole.text=Evaluate in Console
 action.Debugger.UnmuteOnStop.text=Unmute breakpoints on session finish
 action.Debugger.AutoRenderer.text=Auto
 action.Debugger.EvaluateInConsole.text=Evaluate in Console
 action.Debugger.UnmuteOnStop.text=Unmute breakpoints on session finish
 action.Debugger.AutoRenderer.text=Auto
+action.PyDebugger.ViewArray.text = View as array
 group.EditorPopupMenu.text=Editor Popup Menu
 group.EditorPopupMenu.description=Editor Popup Menu
 action.Add\ to\ migration\ roots.text=_Add to migration roots
 group.EditorPopupMenu.text=Editor Popup Menu
 group.EditorPopupMenu.description=Editor Popup Menu
 action.Add\ to\ migration\ roots.text=_Add to migration roots
index 292237aac6acbff0f051792aac7c355367761d37..84900a275db98a3cb496f9dd69d0458211516f66 100644 (file)
     <action id="PyInvertBooleanAction" class="com.jetbrains.python.refactoring.invertBoolean.PyInvertBooleanAction" text="Invert Boolean">
       <add-to-group group-id="RefactoringMenu" anchor="last" />
     </action>
     <action id="PyInvertBooleanAction" class="com.jetbrains.python.refactoring.invertBoolean.PyInvertBooleanAction" text="Invert Boolean">
       <add-to-group group-id="RefactoringMenu" anchor="last" />
     </action>
+
+    <action id="PyDebugger.ViewArray" class="com.jetbrains.python.actions.PyViewArrayAction">
+      <add-to-group group-id="XDebugger.ValueGroup" anchor="after" relative-to-action="Debugger.Tree.EvaluateInConsole"/>
+    </action>
+
   </actions>
 
   <extensions defaultExtensionNs="com.intellij.spellchecker">
   </actions>
 
   <extensions defaultExtensionNs="com.intellij.spellchecker">
diff --git a/python/src/com/jetbrains/python/actions/PyViewArrayAction.java b/python/src/com/jetbrains/python/actions/PyViewArrayAction.java
new file mode 100644 (file)
index 0000000..e50822e
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2000-2014 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.jetbrains.python.actions;
+
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.DialogWrapper;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.ui.EditorTextField;
+import com.intellij.xdebugger.impl.ui.TextViewer;
+import com.intellij.xdebugger.impl.ui.tree.actions.XFetchValueActionBase;
+import org.jetbrains.annotations.NotNull;
+
+import javax.swing.*;
+import java.awt.*;
+
+/**
+ * Created by Alexander.Marchuk
+ */
+
+public class PyViewArrayAction extends XFetchValueActionBase {
+  @Override
+  protected void handle(Project project, String value) {
+    final MyDialog dialog = new MyDialog(project);
+    dialog.setTitle("View Array");
+    dialog.setText(StringUtil.unquoteString(value));
+    dialog.show();
+  }
+
+  private static class MyDialog extends DialogWrapper {
+    private final EditorTextField myTextViewer;
+
+    private MyDialog(Project project) {
+      super(project, false);
+      setModal(false);
+      setCancelButtonText("Close");
+      setCrossClosesWindow(true);
+
+      myTextViewer = new TextViewer(project, true, true);
+      init();
+    }
+
+    public void setText(String text) {
+      myTextViewer.setText(text);
+    }
+
+    @Override
+    @NotNull
+    protected Action[] createActions() {
+      return new Action[] {getCancelAction()};
+    }
+
+    @Override
+    protected String getDimensionServiceKey() {
+      return "#com.jetbrains.python.actions.PyViewArrayAction";
+    }
+
+    @Override
+    protected JComponent createCenterPanel() {
+      final JPanel panel = new JPanel(new BorderLayout());
+      panel.add(myTextViewer, BorderLayout.CENTER);
+      panel.setPreferredSize(new Dimension(300, 200));
+      return panel;
+    }
+  }
+}