use of com.intellij.debugger.ui.tree.render.NodeRenderer in project intellij-community by JetBrains.
the class RendererConfiguration method clone.
public RendererConfiguration clone() {
RendererConfiguration result = null;
try {
result = (RendererConfiguration) super.clone();
} catch (CloneNotSupportedException e) {
LOG.error(e);
}
result.myRepresentationNodes = new CopyOnWriteArrayList<>();
final ArrayList<NodeRenderer> cloned = new ArrayList<>();
for (NodeRenderer renderer : myRepresentationNodes) {
cloned.add((NodeRenderer) renderer.clone());
}
result.setRenderers(cloned);
return result;
}
use of com.intellij.debugger.ui.tree.render.NodeRenderer in project intellij-community by JetBrains.
the class DebugProcessImpl method getAutoRenderer.
public NodeRenderer getAutoRenderer(ValueDescriptor descriptor) {
DebuggerManagerThreadImpl.assertIsManagerThread();
Type type = descriptor.getType();
// in case evaluation is not possible, force default renderer
if (!DebuggerManagerEx.getInstanceEx(getProject()).getContext().isEvaluationPossible()) {
return getDefaultRenderer(type);
}
try {
return myNodeRenderersMap.computeIfAbsent(type, t -> myRenderers.stream().filter(r -> DebuggerUtilsImpl.suppressExceptions(() -> r.isApplicable(type), false, true, ClassNotPreparedException.class)).findFirst().orElseGet(() -> getDefaultRenderer(type)));
} catch (ClassNotPreparedException e) {
LOG.info(e);
// use default, but do not cache
return getDefaultRenderer(type);
}
}
use of com.intellij.debugger.ui.tree.render.NodeRenderer in project intellij-community by JetBrains.
the class CreateRendererAction method actionPerformed.
public void actionPerformed(@NotNull final AnActionEvent event) {
final DebuggerContextImpl debuggerContext = DebuggerAction.getDebuggerContext(event.getDataContext());
final List<JavaValue> values = ViewAsGroup.getSelectedValues(event);
if (values.size() != 1) {
return;
}
final JavaValue javaValue = values.get(0);
final DebugProcessImpl process = debuggerContext.getDebugProcess();
if (process == null) {
return;
}
final Project project = event.getProject();
process.getManagerThread().schedule(new DebuggerContextCommandImpl(debuggerContext) {
public void threadAction() {
Type type = javaValue.getDescriptor().getType();
final String name = type != null ? type.name() : null;
DebuggerUIUtil.invokeLater(() -> {
final UserRenderersConfigurable ui = new UserRenderersConfigurable();
ConfigurableBase<UserRenderersConfigurable, NodeRendererSettings> configurable = new ConfigurableBase<UserRenderersConfigurable, NodeRendererSettings>("reference.idesettings.debugger.typerenderers", DebuggerBundle.message("user.renderers.configurable.display.name"), "reference.idesettings.debugger.typerenderers") {
@NotNull
@Override
protected NodeRendererSettings getSettings() {
return NodeRendererSettings.getInstance();
}
@Override
protected UserRenderersConfigurable createUi() {
return ui;
}
};
SingleConfigurableEditor editor = new SingleConfigurableEditor(project, configurable);
if (name != null) {
NodeRenderer renderer = NodeRendererSettings.getInstance().createCompoundTypeRenderer(name, name, null, null);
renderer.setEnabled(true);
ui.addRenderer(renderer);
}
editor.show();
});
}
});
}
use of com.intellij.debugger.ui.tree.render.NodeRenderer in project intellij-community by JetBrains.
the class ViewAsGroup method calcChildren.
private static AnAction[] calcChildren(List<JavaValue> values) {
List<AnAction> renderers = new ArrayList<>();
List<NodeRenderer> allRenderers = NodeRendererSettings.getInstance().getAllRenderers();
boolean anyValueDescriptor = false;
for (NodeRenderer nodeRenderer : allRenderers) {
boolean allApp = true;
for (JavaValue value : values) {
if (value instanceof JavaReferringObjectsValue) {
// disable for any referrers at all
return AnAction.EMPTY_ARRAY;
}
ValueDescriptorImpl valueDescriptor = value.getDescriptor();
anyValueDescriptor = true;
if (!valueDescriptor.isValueValid() || !nodeRenderer.isApplicable(valueDescriptor.getType())) {
allApp = false;
break;
}
}
if (!anyValueDescriptor) {
return AnAction.EMPTY_ARRAY;
}
if (allApp) {
renderers.add(new RendererAction(nodeRenderer));
}
}
List<AnAction> children = new ArrayList<>();
AnAction[] viewAsActions = ((DefaultActionGroup) ActionManager.getInstance().getAction(DebuggerActions.REPRESENTATION_LIST)).getChildren(null);
for (AnAction viewAsAction : viewAsActions) {
if (viewAsAction instanceof AutoRendererAction) {
if (renderers.size() > 1) {
viewAsAction.getTemplatePresentation().setVisible(true);
children.add(viewAsAction);
}
} else {
children.add(viewAsAction);
}
}
if (!children.isEmpty()) {
children.add(Separator.getInstance());
}
children.addAll(renderers);
return children.toArray(new AnAction[children.size()]);
}
use of com.intellij.debugger.ui.tree.render.NodeRenderer in project intellij-community by JetBrains.
the class RendererConfiguration method readExternal.
@SuppressWarnings({ "HardCodedStringLiteral" })
public void readExternal(final Element root) {
String versionAttrib = root.getAttributeValue("VERSION");
int configurationVersion = -1;
if (versionAttrib != null) {
try {
configurationVersion = Integer.parseInt(versionAttrib);
} catch (NumberFormatException e) {
configurationVersion = -1;
}
}
if (configurationVersion != VERSION) {
return;
}
final List<Element> children = root.getChildren(NodeRendererSettings.RENDERER_TAG);
final List<NodeRenderer> renderers = new ArrayList<>(children.size());
for (Element nodeElement : children) {
try {
renderers.add((NodeRenderer) myRendererSettings.readRenderer(nodeElement));
} catch (Exception e) {
LOG.debug(e);
}
}
setRenderers(renderers);
}
Aggregations