Refine search
private static Color getHighlight(String name, int defaultRGB) { FontColorSettings fcs = MimeLookup.getLookup(MimePath.EMPTY).lookup(FontColorSettings.class); AttributeSet as = (fcs != null) ? fcs.getFontColors(name) : null; if (as != null) { return (Color) as.getAttribute(StyleConstants.Background); } else { return new Color(defaultRGB); } }
private static Color getColoring(FontColorSettings fcs, String tokenName) { AttributeSet as = fcs.getTokenFontColors(tokenName); if (as != null) { return (Color) as.getAttribute(StyleConstants.Background); //NOI18N } return null; }
public HeadersHighlighting(Document document) { this.document = document; this.document.putProperty(PROP_HIGLIGHT_HEADER_LAYER, this); FontColorSettings settings = MimeLookup.getLookup("text/x-java-preprocessor").lookup(FontColorSettings.class); //NOI18N commandHighlight = settings.getTokenFontColors("pp-command"); //NOI18N if (commandHighlight != null) { headersBag = new OffsetsBag(document); headersBag.addHighlightsChangeListener(new HighlightsChangeListener() { public void highlightChanged(HighlightsChangeEvent event) { fireHighlightsChange(event.getStartOffset(), event.getEndOffset()); } }); updateBags(); } else { headersBag = null; } }
private static AttributeSet getHighlightAS () { FontColorSettings fcs = MimeLookup.getLookup(MimePath.EMPTY).lookup(FontColorSettings.class); AttributeSet as = fcs.getFontColors("synchronized-text-blocks"); //NOI18N return as == null ? defaultSyncedTextBlocksHighlight : as; }
Lookup lookup = MimeLookup.getLookup(mimePath); FontColorSettings fcs = lookup.lookup(FontColorSettings.class); AttributeSet attribs = fcs.getTokenFontColors("default"); // NOI18N Color fg = (Color)attribs.getAttribute(StyleConstants.Foreground); if (fg != null) { sb.append("color:"); // NOI18N sb.append(";"); // NOI18N Color bg = (Color)attribs.getAttribute(StyleConstants.Background); AttributeSet attribs = fcs.getTokenFontColors(category); String escapedText = tokenText; try { attribs = fcs.getTokenFontColors(category); Color fg = null; if (attribs != null) { bg = (Color)attribs.getAttribute(StyleConstants.Background); fg = (Color)attribs.getAttribute(StyleConstants.Foreground); if (fg != null || bg != null) {
private Coloring getColoring() { if (attribs == null) { if (fcsLookupResult == null) { fcsLookupResult = MimeLookup.getLookup(org.netbeans.lib.editor.util.swing.DocumentUtilities.getMimeType(component)) .lookupResult(FontColorSettings.class); fcsLookupResult.addLookupListener(WeakListeners.create(LookupListener.class, fcsTracker, fcsLookupResult)); } FontColorSettings fcs = fcsLookupResult.allInstances().iterator().next(); AttributeSet attr = fcs.getFontColors(FontColorNames.CODE_FOLDING_BAR_COLORING); if (attr == null) { attr = fcs.getFontColors(FontColorNames.DEFAULT_COLORING); } else { attr = AttributesUtilities.createComposite(attr, fcs.getFontColors(FontColorNames.DEFAULT_COLORING)); } attribs = attr; } return Coloring.fromAttributeSet(attribs); }
@Override public AttributeSet getColor(Entity color) { synchronized(lock) { final AttributeSet tokenFontColors = fcs.getTokenFontColors(color.getResourceName()); assert tokenFontColors != null : "There is no color for "+color.getResourceName(); return tokenFontColors; } }
public FoldView(JTextComponent textComponent, Fold fold, FontColorSettings colorSettings, int options) { super(null); int offset = fold.getStartOffset(); int len = fold.getEndOffset() - offset; assert (len > 0) : "length=" + len + " <= 0"; // NOI18N this.length = len; this.textComponent = textComponent; this.fold = fold; this.foldingColors = colorSettings.getFontColors(FontColorNames.CODE_FOLDING_COLORING); this.selectedColors = colorSettings.getFontColors(FontColorNames.SELECTION_COLORING); this.options = options; }
public AttributeSet getColoringImpl(Coloring colorings) { FontColorSettings fcs = MimeLookup.getLookup(MimePath.get(mimeType)).lookup(FontColorSettings.class); AttributeSet colors = fcs.getTokenFontColors(key);
private static AttributeSet getSyncedTextBlocksHighlight(String name) { FontColorSettings fcs = MimeLookup.getLookup(MimePath.EMPTY).lookup(FontColorSettings.class); AttributeSet as = fcs != null ? fcs.getFontColors(name) : null; return as == null ? defaultSyncedTextBlocksHighlight : as; }
private AttributeSet findFontAndColors(FontColorSettings fcs, TokenId tokenId, Language lang) { // First try the token's name String name = tokenId.name(); AttributeSet attribs = fcs.getTokenFontColors(updateColoringName(name)); // Then try the primary category if (attribs == null) { String primary = tokenId.primaryCategory(); if (primary != null) { attribs = fcs.getTokenFontColors(updateColoringName(primary)); } } // Then try all the other categories if (attribs == null) { @SuppressWarnings("unchecked") //NOI18N List<String> categories = ((Language<TokenId>)lang).nonPrimaryTokenCategories(tokenId); for(String c : categories) { attribs = fcs.getTokenFontColors(updateColoringName(c)); if (attribs != null) { break; } } } return attribs; }
/** * Get the colour for drawing text. */ public static Color getTextColor(JTextComponent jtc) { String mimeType = NbEditorUtilities.getMimeType(jtc); FontColorSettings fcs = MimeLookup.getLookup(mimeType).lookup(FontColorSettings.class); AttributeSet fontColors = fcs.getFontColors("default"); Color fg = (Color) fontColors.getAttribute(StyleConstants.Foreground); return fg; // JTextComponent host = (JTextComponent) getContainer(); // return (host.isEnabled()) ? host.getForeground() : host.getDisabledTextColor(); }
HighlightsContainer.ATTR_EXTENDS_EMPTY_LINE, Boolean.TRUE); FontColorSettings settings = MimeLookup.getLookup("text/x-java-preprocessor").lookup(FontColorSettings.class); //NOI18N AttributeSet as = settings.getTokenFontColors("pp-active-block"); //NOI18N if (as != null) { activeBlockHighlight = AttributesUtilities.createImmutable(as, extendsEolEmptyLine); activeBlockHighlight = null; as = settings.getTokenFontColors("pp-inactive-block"); //NOI18N if (as != null) { inactiveBlockHighlight = AttributesUtilities.createImmutable(as, extendsEolEmptyLine);
private Map<?, ?> getRenderingHints() { Map<?, ?> renderingHints = null; // init hints if any Lookup lookup = MimeLookup.getLookup("text/plain"); // NOI18N if (lookup != null) { FontColorSettings fcs = lookup.lookup(FontColorSettings.class); if (fcs != null) { AttributeSet attributes = fcs.getFontColors(FontColorNames.DEFAULT_COLORING); if (attributes != null) { renderingHints = (Map<?, ?>) attributes.getAttribute(EditorStyleConstants.RenderingHints); } } } return renderingHints; }
public static String getHtml(String text) { StringBuffer buf = new StringBuffer(); // TODO - check whether we need Js highlighting or rhtml highlighting TokenHierarchy tokenH = TokenHierarchy.create(text, JsTokenId.language()); Lookup lookup = MimeLookup.getLookup(MimePath.get(JsTokenId.JAVASCRIPT_MIME_TYPE)); FontColorSettings settings = lookup.lookup(FontColorSettings.class); @SuppressWarnings("unchecked") TokenSequence<? extends TokenId> tok = tokenH.tokenSequence(); while (tok.moveNext()) { Token<? extends TokenId> token = tok.token(); String category = token.id().name(); AttributeSet set = settings.getTokenFontColors(category); if (set == null) { category = token.id().primaryCategory(); if (category == null) { category = "whitespace"; //NOI18N } set = settings.getTokenFontColors(category); } String tokenText = htmlize(token.text().toString()); buf.append(color(tokenText, set)); } return buf.toString(); }
public static Color getBackgroundColor(JTextComponent jtc) { String mimeType = NbEditorUtilities.getMimeType(jtc); FontColorSettings fcs = MimeLookup.getLookup(mimeType).lookup(FontColorSettings.class); AttributeSet fontColors = fcs.getFontColors("default"); Color bg = (Color) fontColors.getAttribute(StyleConstants.Background); return bg; }
while (!SKIP_COLORING && languagePath != null && settings == null) { String mime = languagePath.mimePath(); Lookup lookup = MimeLookup.getLookup(mime); settings = lookup.lookup(FontColorSettings.class); AttributeSet set = settings.getTokenFontColors(category); buf.append(addHTMLColor(htmlize(text), set)); } else {
public static Font getFont(JTextComponent jtc) { String defaultFontName = "Monospaced"; String mimeType = NbEditorUtilities.getMimeType(jtc); FontColorSettings fcs = MimeLookup.getLookup(mimeType).lookup(FontColorSettings.class); String fontName = (String) fcs.getFontColors("default").getAttribute(StyleConstants.FontFamily); Font smallFont = new Font(fontName != null ? fontName : defaultFontName, Font.PLAIN, Options.getFontSize()); return smallFont; } }
/** * Creates new instance initializing final fields. */ public AnnotationBar(JTextComponent target) { this.textComponent = target; this.editorUI = Utilities.getEditorUI(target); this.foldHierarchy = FoldHierarchy.get(editorUI.getComponent()); this.doc = editorUI.getDocument(); this.caret = textComponent.getCaret(); setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE)); elementAnnotationsSubstitute = ""; //NOI18N if (textComponent instanceof JEditorPane) { String mimeType = org.netbeans.lib.editor.util.swing.DocumentUtilities.getMimeType(textComponent); FontColorSettings fcs = MimeLookup.getLookup(mimeType).lookup(FontColorSettings.class); renderingHints = (Map) fcs.getFontColors(FontColorNames.DEFAULT_COLORING).getAttribute(EditorStyleConstants.RenderingHints); } else { renderingHints = null; } }
private void initProperties() { AttributeSet searchHiliteAttrs = ((FontColorSettings) MimeLookup.getLookup(MimePath.get("text/x-java")).lookup(FontColorSettings.class)).getFontColors("highlight-search"); //NOI18N Color c = (Color) searchHiliteAttrs.getAttribute(StyleConstants.Background); if (c != null) { bgColor = getColorString(c); } c = (Color) searchHiliteAttrs.getAttribute(StyleConstants.Foreground); if (c != null) { fgColor = getColorString(c); } Sheet sheet = Sheet.createDefault(); Sheet.Set ps = Sheet.createPropertiesSet(); ps.put(new PathProperty()); ps.put(new DateProperty()); ps.put(new UsernameProperty()); ps.put(new MessageProperty()); sheet.put(ps); setSheet(sheet); }