@Override
 public void renderStringValue(
     @NotNull String value, @Nullable String additionalSpecialCharsToHighlight, int maxLength) {
   TextAttributes textAttributes =
       DebuggerUIUtil.getColorScheme().getAttributes(DefaultLanguageHighlighterColors.STRING);
   SimpleTextAttributes attributes = SimpleTextAttributes.fromTextAttributes(textAttributes);
   myText.append("\"", attributes);
   XValuePresentationUtil.renderValue(
       value, myText, attributes, maxLength, additionalSpecialCharsToHighlight);
   myText.append("\"", attributes);
 }
Beispiel #2
0
 @Override
 @Nullable
 public Object getData(@NonNls final String dataId) {
   if (XDEBUGGER_TREE_KEY.is(dataId)) {
     return this;
   }
   if (PlatformDataKeys.PREDEFINED_TEXT.is(dataId)) {
     XValueNodeImpl[] selectedNodes = getSelectedNodes(XValueNodeImpl.class, null);
     if (selectedNodes.length == 1 && selectedNodes[0].getFullValueEvaluator() == null) {
       return DebuggerUIUtil.getNodeRawValue(selectedNodes[0]);
     }
   }
   return null;
 }
  public static void editNew(@NotNull XValueNodeImpl parentNode) {
    ValueDescriptorImpl descriptor = ((JavaValue) parentNode.getValueContainer()).getDescriptor();
    EnumerationChildrenRenderer renderer = EnumerationChildrenRenderer.getCurrent(descriptor);
    XDebuggerTreeNode newNode = parentNode.addTemporaryEditorNode();
    DebuggerUIUtil.invokeLater(
        () ->
            new CustomFieldInplaceEditor(newNode, null, renderer) {
              @Override
              public void cancelEditing() {
                super.cancelEditing();
                parentNode.removeTemporaryEditorNode(newNode);
              }

              @Override
              protected List<Pair<String, TextWithImports>> getRendererChildren() {
                if (myRenderer != null) {
                  return myRenderer.getChildren();
                }
                String name = getTypeName(descriptor);
                EnumerationChildrenRenderer enumerationChildrenRenderer =
                    new EnumerationChildrenRenderer();
                enumerationChildrenRenderer.setAppendDefaultChildren(true);

                Renderer lastRenderer = descriptor.getLastRenderer();
                if (lastRenderer instanceof CompoundNodeRenderer
                    && !(((CompoundNodeRenderer) lastRenderer).getChildrenRenderer()
                        instanceof ExpressionChildrenRenderer)) {
                  ((CompoundNodeRenderer) lastRenderer)
                      .setChildrenRenderer(enumerationChildrenRenderer);
                } else {
                  NodeRenderer renderer =
                      NodeRendererSettings.getInstance()
                          .createCompoundTypeRenderer(
                              name, name, null, enumerationChildrenRenderer);
                  renderer.setEnabled(true);
                  NodeRendererSettings.getInstance().getCustomRenderers().addRenderer(renderer);
                  NodeRendererSettings.getInstance().fireRenderersChanged();
                }
                return enumerationChildrenRenderer.getChildren();
              }
            }.show());
  }
 @Override
 protected void renderRawValue(@NotNull String value, @NotNull TextAttributesKey key) {
   TextAttributes textAttributes = DebuggerUIUtil.getColorScheme().getAttributes(key);
   SimpleTextAttributes attributes = SimpleTextAttributes.fromTextAttributes(textAttributes);
   myText.append(value, attributes);
 }
  @Override
  protected void doShowPopup(
      final Project project,
      final JComponent component,
      final Point whereToShow,
      final Object breakpoint) {
    if (!(breakpoint instanceof BreakpointWithHighlighter)) return;

    final BreakpointWithHighlighter javaBreakpoint = (BreakpointWithHighlighter) breakpoint;
    Key<? extends BreakpointWithHighlighter> category = javaBreakpoint.getCategory();

    final BreakpointFactory[] allFactories =
        ApplicationManager.getApplication().getExtensions(BreakpointFactory.EXTENSION_POINT_NAME);
    BreakpointFactory breakpointFactory = null;
    for (BreakpointFactory factory : allFactories) {
      if (factory.getBreakpointCategory().equals(category)) {
        breakpointFactory = factory;
      }
    }
    assert breakpointFactory != null : "can't find factory for breakpoint " + javaBreakpoint;

    final BreakpointPropertiesPanel propertiesPanel =
        breakpointFactory.createBreakpointPropertiesPanel(project, true);
    propertiesPanel.initFrom(javaBreakpoint, false);

    final JComponent mainPanel = propertiesPanel.getPanel();
    final String displayName = javaBreakpoint.getDisplayName();

    final JBPopupListener saveOnClose =
        new JBPopupListener() {
          @Override
          public void beforeShown(LightweightWindowEvent event) {}

          @Override
          public void onClosed(LightweightWindowEvent event) {
            propertiesPanel.saveTo(
                javaBreakpoint,
                new Runnable() {
                  @Override
                  public void run() {}
                });
          }
        };

    final Runnable showMoreOptions =
        new Runnable() {
          @Override
          public void run() {
            UIUtil.invokeLaterIfNeeded(
                new Runnable() {
                  @Override
                  public void run() {
                    final JBPopup popup =
                        BreakpointsMasterDetailPopupFactory.getInstance(project)
                            .createPopup(javaBreakpoint);
                    if (popup != null) {
                      popup.showCenteredInCurrentWindow(project);
                    }
                  }
                });
          }
        };
    final Balloon balloon =
        DebuggerUIUtil.showBreakpointEditor(
            project, mainPanel, displayName, whereToShow, component, showMoreOptions, breakpoint);
    balloon.addListener(saveOnClose);

    propertiesPanel.setDelegate(
        new BreakpointPropertiesPanel.Delegate() {
          @Override
          public void showActionsPanel() {
            propertiesPanel.setActionsPanelVisible(true);
            balloon.hide();
            final Balloon newBalloon =
                DebuggerUIUtil.showBreakpointEditor(
                    project,
                    mainPanel,
                    displayName,
                    whereToShow,
                    component,
                    showMoreOptions,
                    breakpoint);
            newBalloon.addListener(saveOnClose);
          }
        });

    ApplicationManager.getApplication()
        .invokeLater(
            new Runnable() {
              @Override
              public void run() {
                IdeFocusManager.findInstance().requestFocus(mainPanel, true);
              }
            });
  }