コード例 #1
0
 private ExpressionComboBoxPanel(
     Project project, String historyId, XSourcePosition sourcePosition) {
   myComboBox = new DebuggerExpressionComboBox(project, historyId);
   if (sourcePosition != null) {
     PsiElement element =
         getContextElement(sourcePosition.getFile(), sourcePosition.getOffset(), project);
     myComboBox.setContext(element);
   } else {
     myComboBox.setContext(null);
   }
 }
コード例 #2
0
  public void editNode(final DebuggerTreeNodeImpl node) {
    final DebuggerContextImpl context = getContext();
    final DebuggerExpressionComboBox comboBox =
        new DebuggerExpressionComboBox(
            getProject(),
            PositionUtil.getContextElement(context),
            "evaluation",
            DefaultCodeFragmentFactory.getInstance());
    comboBox.setText(((WatchItemDescriptor) node.getDescriptor()).getEvaluationText());
    comboBox.selectAll();

    DebuggerTreeInplaceEditor editor =
        new DebuggerTreeInplaceEditor(node) {
          public JComponent createInplaceEditorComponent() {
            return comboBox;
          }

          public JComponent getPreferredFocusedComponent() {
            return comboBox.getPreferredFocusedComponent();
          }

          public Editor getEditor() {
            return comboBox.getEditor();
          }

          public JComponent getEditorComponent() {
            return comboBox.getEditorComponent();
          }

          public void doOKAction() {
            if (comboBox.isPopupVisible()) {
              comboBox.selectPopupValue();
            }

            TextWithImports text = comboBox.getText();
            if (!text.isEmpty()) {
              WatchDebuggerTree.setWatchNodeText(node, text);
              comboBox.addRecent(text);
            } else {
              getWatchTree().removeWatch(node);
            }
            try {
              super.doOKAction();
            } finally {
              comboBox.dispose();
            }
          }

          public void cancelEditing() {
            comboBox.setPopupVisible(false);
            if (((WatchItemDescriptor) node.getDescriptor()).getEvaluationText().isEmpty()) {
              getWatchTree().removeWatch(node);
            }

            try {
              super.cancelEditing();
            } finally {
              comboBox.dispose();
            }
          }
        };
    editor.show();
  }
コード例 #3
0
 @Override
 public void dispose() {
   myComboBox.dispose();
 }