@Nullable @Override public SimpleColoredText getItemName(final Object element, final DiagramState diagramState) { return element instanceof ModuleDepDiagramItem ? new SimpleColoredText(((ModuleDepDiagramItem) element).getName(), DEFAULT_TITLE_ATTR) : null; }
private void showHint(final SimpleColoredText text, final WatchItemDescriptor descriptor) { DebuggerInvocationUtil.invokeLater(getProject(), new Runnable() { @Override public void run() { if(!isHintHidden()) { JComponent component; if (!isActiveTooltipApplicable(descriptor.getValue())) { component = HintUtil.createInformationLabel(text); } else { component = createExpandableHintComponent(text, new Runnable() { @Override public void run() { final DebuggerContextImpl debuggerContext = DebuggerManagerEx.getInstanceEx(getProject()).getContext(); final DebugProcessImpl debugProcess = debuggerContext.getDebugProcess(); debugProcess.getManagerThread().schedule(new DebuggerContextCommandImpl(debuggerContext) { @Override public void threadAction() { descriptor.setRenderer(debugProcess.getAutoRenderer(descriptor)); final String expressionText = ApplicationManager.getApplication().runReadAction(new Computable<String>() { @Override public String compute() { return myCurrentExpression.getText(); } }); createAndShowTree(expressionText, descriptor); } }); } }); } if (!showHint(component)) return; if(getType() == ValueHintType.MOUSE_CLICK_HINT) { HintUtil.createInformationLabel(text).requestFocusInWindow(); } } } }); }
@Override public void propertyChange(PropertyChangeEvent evt) { final Object newValue = evt.getNewValue(); final Object oldValue = evt.getOldValue(); boolean affectsDebugger = false; if (newValue instanceof Component && isInsideDebuggerDialog((Component)newValue)) { affectsDebugger |= true; } if (oldValue instanceof Component && isInsideDebuggerDialog((Component)oldValue)) { affectsDebugger |= true; } final SimpleColoredText text = new SimpleColoredText(); text.append(evt.getPropertyName(), maybeGrayOut(new SimpleTextAttributes(SimpleTextAttributes.STYLE_UNDERLINE, null), affectsDebugger)); text.append(" newValue=", maybeGrayOut(SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES, affectsDebugger)); text.append(evt.getNewValue() + "", maybeGrayOut(SimpleTextAttributes.REGULAR_ATTRIBUTES, affectsDebugger)); text.append(" oldValue=" + evt.getOldValue(), maybeGrayOut(SimpleTextAttributes.REGULAR_ATTRIBUTES, affectsDebugger)); myLogModel.addElement(new FocusElement(text, new Throwable())); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { if (myLog != null && myLog.isShowing()) { final int h = myLog.getFixedCellHeight(); myLog.scrollRectToVisible(new Rectangle(0, myLog.getPreferredSize().height - h, myLog.getWidth(), h)); if (myLog.getModel().getSize() > 0) { myLog.setSelectedIndex(myLog.getModel().getSize() - 1); } } } }); }
@Override protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) { clear(); final FocusElement element = (FocusElement)value; final SimpleColoredText text = element.getText(); final ArrayList<String> strings = text.getTexts(); final ArrayList<SimpleTextAttributes> attributes = element.getText().getAttributes(); for (int i = 0; i < strings.size(); i++) { append(strings.get(i), attributes.get(i)); } }
public void testDeviceNameRendering1() throws Exception { String serial = "123"; IDevice d = createDevice(false, null, "google", "nexus 4", "4.2", "17", serial, IDevice.DeviceState.ONLINE); SimpleColoredText target = new SimpleColoredText(); DeviceRenderer.renderDeviceName(d, target); String name = target.toString(); assertTrue(StringUtil.containsIgnoreCase(name, "Nexus 4 Android 4.2 (API 17)")); // status should be shown only if !online assertFalse(StringUtil.containsIgnoreCase(name, IDevice.DeviceState.ONLINE.toString())); // serial should be shown only if !online assertFalse(StringUtil.containsIgnoreCase(name, serial)); }
public void testDeviceNameRendering2() throws Exception { String serial = "123"; IDevice d = createDevice(true, "Avdname", "google", "nexus 4", "4.2", "17", serial, IDevice.DeviceState.BOOTLOADER); SimpleColoredText target = new SimpleColoredText(); DeviceRenderer.renderDeviceName(d, target); String name = target.toString(); assertFalse(StringUtil.containsIgnoreCase(name, "Nexus 4")); assertTrue(StringUtil.containsIgnoreCase(name, "Avdname")); assertTrue(StringUtil.containsIgnoreCase(name, IDevice.DeviceState.BOOTLOADER.toString())); assertTrue(StringUtil.containsIgnoreCase(name, serial)); }
@Override public void setupPresentation(final BaseInjection injection, final SimpleColoredText presentation, final boolean isSelected) { final Matcher matcher = ourPresentationPattern.matcher(injection.getDisplayName()); if (matcher.matches()) { presentation.append(matcher.group(1), SimpleTextAttributes.REGULAR_ATTRIBUTES); presentation.append(matcher.group(2), isSelected ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.GRAY_ATTRIBUTES); } else { super.setupPresentation(injection, presentation, isSelected); } }
@Nullable @Override public SimpleColoredText getItemName(Object o, DiagramState diagramState) { if (o instanceof PsiNamedElement) { PsiNamedElement namedElement = (PsiNamedElement) o; final String itemName, itemType; if (namedElement instanceof SchemaFieldDecl) { SchemaFieldDecl fieldDecl = (SchemaFieldDecl) namedElement; itemName = fieldDecl.getQid().getCanonicalName(); SchemaValueTypeRef valueTypeRef = fieldDecl.getValueTypeRef(); itemType = valueTypeRef == null ? null : valueTypeRef.getTypeRef().getText(); } else if (namedElement instanceof SchemaEntityTagDecl) { SchemaEntityTagDecl tagDecl = (SchemaEntityTagDecl) namedElement; itemName = tagDecl.getQid().getCanonicalName(); SchemaTypeRef typeRef = tagDecl.getTypeRef(); itemType = typeRef == null ? null : typeRef.getText(); } else { itemName = namedElement.getName(); if (itemName == null) return null; itemType = null; } SimpleColoredText res = new SimpleColoredText(itemName, DEFAULT_TITLE_ATTR); if (itemType != null) res.append(" : " + itemType, DEFAULT_TEXT_ATTR); return res; } return null; }
@Nullable @Override public SimpleColoredText getItemName(Object o, DiagramState state) { if (o instanceof PsiElement) { return new SimpleColoredText(getElementTitle((PsiElement) o), DEFAULT_TEXT_ATTR); } else { return null; } }
private void showHint(final SimpleColoredText text, final WatchItemDescriptor descriptor) { DebuggerInvocationUtil.invokeLater(getProject(), new Runnable() { public void run() { if(!isHintHidden()) { JComponent component; if (!isActiveTooltipApplicable(descriptor.getValue())) { component = HintUtil.createInformationLabel(text); } else { component = createExpandableHintComponent(text, new Runnable() { public void run() { final DebuggerContextImpl debuggerContext = DebuggerManagerEx.getInstanceEx(getProject()).getContext(); final DebugProcessImpl debugProcess = debuggerContext.getDebugProcess(); debugProcess.getManagerThread().schedule(new DebuggerContextCommandImpl(debuggerContext) { public void threadAction() { descriptor.setRenderer(debugProcess.getAutoRenderer(descriptor)); final InspectDebuggerTree tree = getInspectTree(descriptor); final String expressionText = ApplicationManager.getApplication().runReadAction(new Computable<String>() { @Override public String compute() { return myCurrentExpression.getText(); } }); showTreePopup(tree, debuggerContext, expressionText, new ValueHintTreeComponent(ValueHint.this, tree, expressionText)); } }); } }); } if (!showHint(component)) return; if(getType() == ValueHintType.MOUSE_CLICK_HINT) { HintUtil.createInformationLabel(text).requestFocusInWindow(); } } } }); }
@Override public void append(String value, SimpleColoredText text, boolean changed) { SimpleTextAttributes attributes = SimpleTextAttributes.fromTextAttributes(EditorColorsManager.getInstance().getGlobalScheme().getAttributes(DefaultLanguageHighlighterColors.STRING)); text.append("\"", attributes); doAppend(value, text, attributes); text.append("\"", attributes); }
private void doShowHint(final XValue xValue, final String separator, final String value, String type, @NotNull XValuePresenter valuePresenter, final boolean hasChildren) { if (isHintHidden()) return; SimpleColoredText text = new SimpleColoredText(); text.append(myExpression, XDebuggerUIConstants.VALUE_NAME_ATTRIBUTES); text.append(separator, SimpleTextAttributes.REGULAR_ATTRIBUTES); if (type != null) { text.append("{" + type + "} ", XDebuggerUIConstants.TYPE_ATTRIBUTES); } valuePresenter.append(value, text, false); if (!hasChildren) { showHint(HintUtil.createInformationLabel(text)); } else if (getType() == ValueHintType.MOUSE_CLICK_HINT) { showTree(xValue, myExpression); } else { JComponent component = createExpandableHintComponent(text, new Runnable() { public void run() { showTree(xValue, myExpression); } }); showHint(component); } }
public void setText(final SimpleColoredText text) { myLabel.change(() -> { myLabel.clear(); if (text != null) { SimpleColoredText derive = myTabs.useBoldLabels() ? text.derive(SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES, true) : text; derive.appendToComponent(myLabel); } }, false); invalidateIfNeeded(); }
protected JComponent createExpandableHintComponent(final SimpleColoredText text, final Runnable expand) { final JComponent component = HintUtil.createInformationLabel(text, IconUtil.getAddIcon()); addClickListenerToHierarchy(component, new ClickListener() { @Override public boolean onClick(@Nonnull MouseEvent event, int clickCount) { if (myCurrentHint != null) { myCurrentHint.hide(); } expand.run(); return true; } }); return component; }
@Override public void customizeCellRenderer(@NotNull JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { final DebuggerTreeNodeImpl node = (DebuggerTreeNodeImpl) value; if(node != null) { final SimpleColoredText text = node.getText(); if(text != null) { text.appendToComponent(this); } setIcon(node.getIcon()); } }
@Nullable @Override public SimpleColoredText getItemName(final Object o, final DiagramState diagramState) { return null; }
public SimpleColoredText getText() { return myText; }
public SimpleColoredText getColoredText() { return myText; }
@NotNull public SimpleColoredText getText() { return myText; }
FocusElement(SimpleColoredText text, Throwable allocation) { myText = text; myAllocation = allocation; }
public void setupPresentation(final BaseInjection injection, final SimpleColoredText presentation, final boolean isSelected) { presentation.append(injection.getDisplayName(), SimpleTextAttributes.REGULAR_ATTRIBUTES); }
@Override public void append(String value, SimpleColoredText text, boolean changed) { text.append(value, SimpleTextAttributes.fromTextAttributes(EditorColorsManager.getInstance().getGlobalScheme().getAttributes(textAttributesKey))); }
protected void doAppend(String value, SimpleColoredText text, SimpleTextAttributes attributes) { SimpleTextAttributes escapeAttributes = null; int lastOffset = 0; int length = maxLength == -1 ? value.length() : Math.min(value.length(), maxLength); for (int i = 0; i < length; i++) { char ch = value.charAt(i); int additionalCharIndex = -1; if (ch == '\n' || ch == '\r' || ch == '\t' || ch == '\b' || ch == '\f' || (additionalChars != null && (additionalCharIndex = additionalChars.indexOf(ch)) != -1)) { if (i > lastOffset) { text.append(value.substring(lastOffset, i), attributes); } lastOffset = i + 1; if (escapeAttributes == null) { TextAttributes fromHighlighter = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(DefaultLanguageHighlighterColors.VALID_STRING_ESCAPE); if (fromHighlighter != null) { escapeAttributes = SimpleTextAttributes.fromTextAttributes(fromHighlighter); } else { escapeAttributes = new SimpleTextAttributes(SimpleTextAttributes.STYLE_BOLD, JBColor.GRAY); } } if (additionalCharIndex == -1) { text.append("\\", escapeAttributes); } String string; switch (ch) { case '"': string = "\""; break; case '\\': string = "\\"; break; case '\n': string = "n"; break; case '\r': string = "r"; break; case '\t': string = "t"; break; case '\b': string = "b"; break; case '\f': string = "f"; break; default: string = String.valueOf(ch); } text.append(string, escapeAttributes); } } if (lastOffset < length) { text.append(value.substring(lastOffset, length), attributes); } }
@Override public void append(String value, SimpleColoredText text, boolean changed) { text.append(valuePresenter.fun(value), changed ? XDebuggerUIConstants.CHANGED_VALUE_ATTRIBUTES : SimpleTextAttributes.REGULAR_ATTRIBUTES); }
@Override public void append(String value, SimpleColoredText text, boolean changed) { doAppend(value, text, changed ? XDebuggerUIConstants.CHANGED_VALUE_ATTRIBUTES : SimpleTextAttributes.REGULAR_ATTRIBUTES); }