private ColoredFragment makeStatusFragment(boolean prefix) { int style = SimpleTextAttributes.STYLE_PLAIN; if (config.projectViewStatusBold) { style |= SimpleTextAttributes.STYLE_BOLD; } if (config.projectViewStatusItalic) { style |= SimpleTextAttributes.STYLE_ITALIC; } Color color = config.projectViewStatusCustomColor ? config.getProjectViewStatusColor() : Gray._128; SimpleTextAttributes attributes = new SimpleTextAttributes(style, color); StringBand status = getStatusText(); if (prefix) { String statusTemp = status.toString(); status.setIndex(0); status.append(FontUtil.spaceAndThinSpace()).append(statusTemp); } return new ColoredFragment(status.toString(), attributes); }
@Override public boolean apply(ProjectViewNode node, PresentationData data) { Optional<String> locationString = Optional.ofNullable(data.getLocationString()); if (config.showProjectViewLocationPath) { if (config.showProjectViewStatusBeforeLocation) { data.addText(makeStatusFragment(true)); locationString.ifPresent(l -> data.setLocationString("- " + l)); } else { if (locationString.isPresent()) { StringBand location = new StringBand(FontUtil.spaceAndThinSpace()); location.append(locationString.get()); location.append(" - "); data.addText(location.toString(), getLocationAttributes()); data.addText(makeStatusFragment(false)); data.setLocationString(""); } else { data.addText(makeStatusFragment(true)); } } } else { locationString.ifPresent(data::setTooltip); data.setLocationString(""); data.addText(makeStatusFragment(true)); } return true; }
@Override protected JComponent createItemComponent() { myTextLabel = new ErrorLabel(); myTextLabel.setOpaque(true); myTextLabel.setBorder(JBUI.Borders.empty(1)); myInfoLabel = new ErrorLabel(); myInfoLabel.setOpaque(true); myInfoLabel.setBorder(JBUI.Borders.empty(1, DEFAULT_HGAP, 1, 1)); myInfoLabel.setFont(FontUtil.minusOne(myInfoLabel.getFont())); JPanel compoundPanel = new OpaquePanel(new BorderLayout(), JBColor.WHITE); myIconLabel = new IconComponent(); myInfoLabel.setHorizontalAlignment(SwingConstants.RIGHT); JPanel compoundTextPanel = new OpaquePanel(new BorderLayout(), compoundPanel.getBackground()); JPanel textPanel = new OpaquePanel(new BorderLayout(), compoundPanel.getBackground()); compoundPanel.add(myIconLabel, BorderLayout.WEST); textPanel.add(myTextLabel, BorderLayout.WEST); textPanel.add(myInfoLabel, BorderLayout.CENTER); compoundTextPanel.add(textPanel, BorderLayout.CENTER); compoundPanel.add(compoundTextPanel, BorderLayout.CENTER); return layoutComponent(compoundPanel); }
private void setInheritanceInfo(ColorAndFontDescription description) { Pair<ColorSettingsPage, AttributesDescriptor> baseDescriptor = description.getBaseAttributeDescriptor(); if (baseDescriptor != null && baseDescriptor.second.getDisplayName() != null) { String attrName = baseDescriptor.second.getDisplayName(); String attrLabel = attrName.replaceAll(ColorOptionsTree.NAME_SEPARATOR, FontUtil.rightArrow(UIUtil.getLabelFont())); ColorSettingsPage settingsPage = baseDescriptor.first; String style = "<div style=\"text-align:right\" vertical-align=\"top\">"; String tooltipText; String labelText; if (settingsPage != null) { String pageName = settingsPage.getDisplayName(); tooltipText = "'" + attrLabel + "' from<br>'" + pageName + "' section"; labelText = style + "'" + attrLabel + "'<br>of <a href=\"" + attrName + "\">" + pageName; } else { tooltipText = attrLabel; labelText = style + attrLabel + "<br> "; } myInheritanceLabel.setVisible(true); myInheritanceLabel.setText(labelText); myInheritanceLabel.setToolTipText(tooltipText); myInheritanceLabel.setEnabled(true); myInheritAttributesBox.setVisible(true); myInheritAttributesBox.setEnabled(true); myInheritAttributesBox.setSelected(description.isInherited()); setEditEnabled(!description.isInherited(), description); } else { myInheritanceLabel.setVisible(false); myInheritAttributesBox.setSelected(false); myInheritAttributesBox.setVisible(false); setEditEnabled(true, description); } }
@NotNull public static String getRightArrow() { Font font = EditorColorsManager.getInstance().getGlobalScheme().getFont(EditorFontType.PLAIN); return FontUtil.rightArrow(font); }
@NotNull public static String spaceAndThinSpace() { return " " + FontUtil.canDisplay(UIUtil.getLabelFont(), '\u2009', " "); }