diff --git a/cnd.completion/nbproject/project.xml b/cnd.completion/nbproject/project.xml --- a/cnd.completion/nbproject/project.xml +++ b/cnd.completion/nbproject/project.xml @@ -173,6 +173,14 @@ + org.netbeans.swing.plaf + + + + 1.27 + + + org.openide.awt diff --git a/cnd.completion/src/org/netbeans/modules/cnd/completion/cplusplus/ext/CsmResultItem.java b/cnd.completion/src/org/netbeans/modules/cnd/completion/cplusplus/ext/CsmResultItem.java --- a/cnd.completion/src/org/netbeans/modules/cnd/completion/cplusplus/ext/CsmResultItem.java +++ b/cnd.completion/src/org/netbeans/modules/cnd/completion/cplusplus/ext/CsmResultItem.java @@ -103,7 +103,7 @@ import org.netbeans.spi.editor.completion.CompletionItem; import org.netbeans.spi.editor.completion.CompletionTask; import org.openide.util.Lookup; - +import org.netbeans.swing.plaf.LFCustoms; /** * * @author Vladimir Voskresensky @@ -116,14 +116,13 @@ DOT_TO_ARROW, ARROW_TO_DOT, } - + private static boolean enableInstantSubstitution = true; protected int selectionStartOffset = -1; protected int selectionEndOffset = -1; protected int substituteOffset = -1; CsmObject associatedObject; - private static final Color KEYWORD_COLOR = Color.gray; - private static final Color TYPE_COLOR = Color.black; + private static final Color KEYWORD_COLOR = Color.lightGray; private int priority; private SubstitutionHint hint; @@ -141,13 +140,13 @@ void setHint(SubstitutionHint hint) { this.hint = hint; } - + protected SubstitutionHint getHint() { return this.hint; } - + protected static Color getTypeColor(CsmType type) { - return type.isBuiltInBased(false) ? KEYWORD_COLOR : TYPE_COLOR; + return type.isBuiltInBased(false) ? LFCustoms.shiftColor(KEYWORD_COLOR) : LFCustoms.getTextFgColor(); } public void setSubstituteOffset(int substituteOffset) { @@ -271,7 +270,7 @@ Component comp = getPaintComponent(false); return comp != null ? comp.toString() : ""; //NOI18N } - + protected int convertCsmModifiers(CsmObject obj) { return CsmUtilities.getModifiers(obj); } @@ -981,11 +980,11 @@ if (type == null) { // only var args parameters could have null types assert (((CsmParameter) prm).isVarArgs()) : " non var arg " + prm + " of class " + prm.getClass().getName(); - params.add(new ParamStr("", "", ((CsmParameter) prm).getName().toString(), prm.getText().toString(), true, KEYWORD_COLOR)); //NOI18N + params.add(new ParamStr("", "", ((CsmParameter) prm).getName().toString(), prm.getText().toString(), true, LFCustoms.shiftColor(KEYWORD_COLOR))); //NOI18N varArgIndex = i; } else { String typeName = getTypeName(type, instantiateTypes); - params.add(new ParamStr(typeName, typeName, ((CsmParameter) prm).getName().toString(), prm.getText().toString(), false, TYPE_COLOR /*getTypeColor(type.getClassifier())*/)); + params.add(new ParamStr(typeName, typeName, ((CsmParameter) prm).getName().toString(), prm.getText().toString(), false, LFCustoms.getTextFgColor() /*getTypeColor(type.getClassifier())*/)); } i++; } @@ -1048,7 +1047,7 @@ List ret = new ArrayList(); for (Iterator it = getParams().iterator(); it.hasNext();) { StringBuilder sb = new StringBuilder(); - ParamStr ps = it.next(); + ParamStr ps = it.next(); if (ps.isVarArg()) { sb.append(ps.getSimpleTypeName()); sb.append("..."); // NOI18N @@ -1765,19 +1764,19 @@ // this.prm = prm; // this.typeColor = typeColor; // } -// +// // public String getTypeName() { // return type; // } -// +// // public String getSimpleTypeName() { // return simpleType; // } -// +// // public String getName() { // return prm; // } -// +// // public Color getTypeColor() { // return typeColor; // } @@ -1789,11 +1788,11 @@ // this.name = name; // this.typeColor = typeColor; // } -// +// // public String getName() { // return name; // } -// +// // public Color getTypeColor() { // return typeColor; // } diff --git a/cnd.modelutil/nbproject/project.xml b/cnd.modelutil/nbproject/project.xml --- a/cnd.modelutil/nbproject/project.xml +++ b/cnd.modelutil/nbproject/project.xml @@ -86,6 +86,14 @@ + org.netbeans.swing.plaf + + + + 1.27 + + + org.openide.awt diff --git a/cnd.modelutil/src/org/netbeans/modules/cnd/modelutil/CsmDisplayUtilities.java b/cnd.modelutil/src/org/netbeans/modules/cnd/modelutil/CsmDisplayUtilities.java --- a/cnd.modelutil/src/org/netbeans/modules/cnd/modelutil/CsmDisplayUtilities.java +++ b/cnd.modelutil/src/org/netbeans/modules/cnd/modelutil/CsmDisplayUtilities.java @@ -89,6 +89,7 @@ import org.openide.text.CloneableEditorSupport; import org.openide.util.Lookup; import org.openide.util.NbBundle; +import org.netbeans.swing.plaf.LFCustoms; /** * @@ -138,7 +139,7 @@ } return displayText; } - + public static String getLineHtml(int startLine, int endLine, final int stToken, final int endToken, BaseDocument doc) throws BadLocationException { int startBold = stToken - startLine; int endBold = endToken - startLine; @@ -327,16 +328,16 @@ private static String getString(String key, CharSequence value) { return NbBundle.getMessage(CsmDisplayUtilities.class, key, value); - } - + } + private static String getString(String key, CharSequence value1, CharSequence value2) { return NbBundle.getMessage(CsmDisplayUtilities.class, key, value1, value2); - } - + } + private static String getString(String key, CharSequence value1, CharSequence value2, CharSequence value3, CharSequence value4) { return NbBundle.getMessage(CsmDisplayUtilities.class, key, new Object[] {value1, value2, value3, value4}); - } - + } + private final static boolean SKIP_COLORING = Boolean.getBoolean("cnd.test.skip.coloring");// NOI18N private static void appendHtml(StringBuilder buf, TokenSequence ts) { @@ -405,7 +406,7 @@ buf.insert(0, ""); // NOI18N buf.append(""); // NOI18N } - buf.insert(0, ""); //NOI18N + buf.insert(0, ""); //NOI18N buf.append(""); //NOI18N return buf.toString(); } @@ -420,7 +421,7 @@ String html_color = "#" + colorR + colorG + colorB; //NOI18N return html_color; } - + private static String trimStart(String s) { for (int x = 0; x < s.length(); x++) { if (Character.isWhitespace(s.charAt(x))) { diff --git a/cnd.modelutil/src/org/netbeans/modules/cnd/modelutil/CsmPaintComponent.java b/cnd.modelutil/src/org/netbeans/modules/cnd/modelutil/CsmPaintComponent.java --- a/cnd.modelutil/src/org/netbeans/modules/cnd/modelutil/CsmPaintComponent.java +++ b/cnd.modelutil/src/org/netbeans/modules/cnd/modelutil/CsmPaintComponent.java @@ -63,7 +63,7 @@ import javax.swing.BorderFactory; import javax.swing.Icon; import javax.swing.JPanel; - +import org.netbeans.swing.plaf.LFCustoms; /** * @@ -72,113 +72,113 @@ */ public abstract class CsmPaintComponent extends JPanel { - + DrawState drawState = new DrawState(); - + protected Font drawFont; - + private static final int ICON_WIDTH = 16; private static final int ICON_TEXT_GAP = 5; - + private int fontHeight; - + private int ascent; - + private Map widths; - + private FontMetrics fontMetrics; - + protected boolean isSelected; - + // private String text; - + private ArrayList postfixes; - + private static final String THROWS = " throws "; // NOI18N - - + + private static final String[] frequentWords = new String[] { "", " ", "[]", "(", ")", ", ", "String", THROWS // NOI18N }; - - private static final Color KEYWORD_COLOR = Color.darkGray; - private static final Color TYPE_COLOR = Color.black; - private static final Color POSTFIX_COLOR = Color.gray; - + + private final static Color KEYWORD_COLOR = Color.gray; + private final static Color POSTFIX_COLOR = Color.lightGray; + private Icon icon; - + protected int modifiers = 0; - + private static Border BORDER = BorderFactory.createEmptyBorder(0, 3, 0, 3); private static LayoutManager layout = new FlowLayout(); public CsmPaintComponent(){ - super(layout, true); + super(layout, true); setBorder(BORDER); - postfixes = new ArrayList(); + postfixes = new ArrayList(); } - + public void setSelected(boolean isSelected){ this.isSelected = isSelected; } - + protected boolean isSelected(){ return isSelected; } - + @Override public void paintComponent(Graphics g) { // clear background + Color postfixColor = LFCustoms.shiftColor(POSTFIX_COLOR); g.setColor(getBackground()); java.awt.Rectangle r = g.getClipBounds(); g.fillRect(r.x, r.y, r.width, r.height); draw(g); - + if(!postfixes.isEmpty()) { - drawString(g, " (", POSTFIX_COLOR); // NOI18N + drawString(g, " (", postfixColor); // NOI18N Iterator iter = postfixes.iterator(); while(iter.hasNext()) { ((PostfixString) iter.next()).Draw(g); if(iter.hasNext()) { - drawString(g, ", ", POSTFIX_COLOR); // NOI18N + drawString(g, ", ", postfixColor); // NOI18N } - } - drawString(g, ")", POSTFIX_COLOR); // NOI18N - } + } + drawString(g, ")", postfixColor); // NOI18N + } } - + public void appendPostfix(String text, Color c, int font) { postfixes.add(new PostfixString(text, c, font)); } - + public void removePostfixes() { postfixes.clear(); } - + public boolean hasPostfixes() { return !postfixes.isEmpty(); } - + /** IMPORTANT: * when implemented => have to update toString! */ abstract protected void draw(Graphics g); - + /** * returns string representation of paint item * IMPORTANT: have to be in sync with draw() method - */ + */ @Override abstract public String toString(); - + protected void setIcon(Icon icon){ this.icon = icon; } - + protected Icon getIcon(){ return icon; } - - + + /** Draw the icon if it is valid for the given type. * Here the initial drawing assignments are also done. */ @@ -191,7 +191,7 @@ drawState.drawX = 0; drawState.drawY = 0; } - + if (icon != null) { if (g != null) { icon.paintIcon(this, g, drawState.drawX, drawState.drawY); @@ -207,11 +207,11 @@ drawState.drawHeight += drawState.drawY; drawState.drawY += ascent; } - + protected void drawString(Graphics g, CharSequence s){ drawString(g, s, false); } - + /** Draw string using the foreground color */ protected void drawString(Graphics g, CharSequence s, boolean strike) { if (g != null) { @@ -219,8 +219,8 @@ } drawStringToGraphics(g, s, null, strike); } - - + + /** Draw string with given color which is first possibly modified * by calling getColor() method to care about selection etc. */ @@ -230,7 +230,7 @@ } drawStringToGraphics(g, s); } - + protected void drawString(Graphics g, CharSequence s, Color c, Font font, boolean strike) { if (g != null) { g.setColor(getColor(s, c)); @@ -240,9 +240,9 @@ if (g != null) { g.setFont(drawFont); } - + } - + protected void drawTypeName(Graphics g, String s, Color c) { if (g == null) { drawString(g, " "); // NOI18N @@ -261,11 +261,11 @@ drawString(g, s, c); } } - + protected void drawStringToGraphics(Graphics g, CharSequence s) { drawStringToGraphics(g, s, null, false); } - + protected void drawStringToGraphics(Graphics g, CharSequence s, Font font, boolean strike) { String str = s != null ? s.toString() : ""; if (g != null) { @@ -281,7 +281,7 @@ } drawState.drawX += getWidth(str, font); } - + protected int getWidth(String s) { Integer i = (Integer)widths.get(s); if (i != null) { @@ -290,27 +290,27 @@ return fontMetrics.stringWidth(s); } } - + protected int getWidth(String s, Font font) { if (font == null) { return getWidth(s); } return getFontMetrics(font).stringWidth(s); } - + protected Color getColor(CharSequence s, Color defaultColor) { return isSelected ? getForeground() : defaultColor; } - + private void storeWidth(String s) { fontMetrics.stringWidth(s); } - + @Override public void setFont(Font font) { super.setFont(font); - + fontMetrics = this.getFontMetrics(font); fontHeight = fontMetrics.getHeight(); ascent = fontMetrics.getAscent(); @@ -324,11 +324,11 @@ } drawFont = font; } - + protected Font getDrawFont(){ return drawFont; } - + @Override public Dimension getPreferredSize() { draw(null); @@ -341,7 +341,7 @@ } return new Dimension(drawState.drawX, drawState.drawHeight); } - + public void setModifiers(int modifiers){ this.modifiers = modifiers; } @@ -349,68 +349,68 @@ public int getModifiers(){ return modifiers; } - + DrawState getDrawState() { return drawState; } - + void setDrawState(DrawState drawState) { this.drawState = drawState; } - + //.................. INNER CLASSES ....................... - + private class PostfixString { private String text; private Color c; private int fontStyle; - + public PostfixString(String text, Color c, int fontStyle) { this.text = text; this.c = c; this.fontStyle = fontStyle; } - + public PostfixString(String text, int fontStyle) { - this(text, CsmPaintComponent.POSTFIX_COLOR, fontStyle); + this(text, LFCustoms.shiftColor(CsmPaintComponent.POSTFIX_COLOR), fontStyle); } - - void Draw(Graphics g) { - CsmPaintComponent.this.drawString(g, text, c, new Font(getDrawFont().getName(), - getDrawFont().getStyle() | fontStyle, + + void Draw(Graphics g) { + CsmPaintComponent.this.drawString(g, text, c, new Font(getDrawFont().getName(), + getDrawFont().getStyle() | fontStyle, getDrawFont().getSize()), false); - - } + + } } - + private static class DrawState { int drawX, drawY; - int drawHeight; - + int drawHeight; + public DrawState() { drawX = drawY = drawHeight = 0; - } + } } - + public static class NamespacePaintComponent extends CsmPaintComponent{ private String pkgName; private boolean displayFullNamespacePath; - private Color NAMESPACE_COLOR = Color.green.darker().darker().darker(); - + private Color NAMESPACE_COLOR = LFCustoms.shiftColor(new Color(64,255,64)); + public NamespacePaintComponent(){ super(); } - + public void setNamespaceName(String pkgName){ this.pkgName = pkgName; } - + public void setDisplayFullNamespacePath(boolean displayFullNamespacePath){ this.displayFullNamespacePath = displayFullNamespacePath; } - + @Override protected void draw(Graphics g) { // IMPORTANT: @@ -422,7 +422,7 @@ } drawString(g, name, NAMESPACE_COLOR); } - + /** * returns string representation of paint item * IMPORTANT: have to be in sync with draw() method @@ -432,20 +432,20 @@ return pkgName; } } - + public static class NamespaceAliasPaintComponent extends CsmPaintComponent{ private String aliasName; - private Color NAMESPACE_COLOR = Color.green.darker().darker().darker(); - + private Color NAMESPACE_COLOR = LFCustoms.shiftColor(new Color(64,255,64)); + public NamespaceAliasPaintComponent(){ super(); } - + public void setAliasName(String aliasName){ this.aliasName = aliasName; } - + @Override protected void draw(Graphics g) { // IMPORTANT: @@ -453,7 +453,7 @@ drawIcon(g, getIcon()); drawString(g, aliasName, NAMESPACE_COLOR); } - + /** * returns string representation of paint item * IMPORTANT: have to be in sync with draw() method @@ -465,19 +465,19 @@ } public static class EnumPaintComponent extends CsmPaintComponent { - + String formatEnumName; - private Color ENUM_COLOR = Color.red.darker().darker().darker().darker(); + private Color ENUM_COLOR = LFCustoms.shiftColor(new Color(255,64,64)); private boolean displayFQN; - + public void EnumPaintComponent(String formatEnumName){ this.formatEnumName = formatEnumName; } - + protected Color getColor(){ return ENUM_COLOR; } - + @Override protected void draw(Graphics g){ // IMPORTANT: @@ -486,7 +486,7 @@ drawIcon(g, getIcon()); drawString(g, formatEnumName, getColor(), null, strike); } - + public void setFormatEnumName(String formatEnumName){ this.formatEnumName = formatEnumName; } @@ -500,21 +500,21 @@ return formatEnumName; } } - + public static class EnumeratorPaintComponent extends CsmPaintComponent { - + String formatEnumeratorName; - private Color ENUMERATOR_COLOR = Color.blue.darker().darker().darker().darker(); + private Color ENUMERATOR_COLOR = LFCustoms.shiftColor(new Color(64,64,255)); private boolean displayFQN; - + public void EnumeratorPaintComponent(String formatEnumeratorName){ this.formatEnumeratorName = formatEnumeratorName; } - + protected Color getColor(){ return ENUMERATOR_COLOR; } - + @Override protected void draw(Graphics g){ // IMPORTANT: @@ -523,7 +523,7 @@ drawIcon(g, getIcon()); drawString(g, formatEnumeratorName, getColor(), null, strike); } - + public void setFormatEnumeratorName(String formatEnumeratorName){ assert(formatEnumeratorName != null); this.formatEnumeratorName = formatEnumeratorName; @@ -538,21 +538,21 @@ return formatEnumeratorName; } } - + public static class ClassPaintComponent extends CsmPaintComponent{ - + String formatClassName; - private Color CLASS_COLOR = Color.red.darker().darker().darker(); + private Color CLASS_COLOR = LFCustoms.shiftColor(new Color(255,64,64)); private boolean displayFQN; - + public void setFormatClassName(String formatClassName){ this.formatClassName = formatClassName; } - + protected Color getColor(){ return CLASS_COLOR; } - + @Override protected void draw(Graphics g){ // IMPORTANT: @@ -561,7 +561,7 @@ drawIcon(g, getIcon()); drawString(g, formatClassName, getColor(), null, strike); } - + /** * returns string representation of paint item * IMPORTANT: have to be in sync with draw() method @@ -569,25 +569,25 @@ @Override public String toString() { return formatClassName; - } + } } - + public static class TypedefPaintComponent extends CsmPaintComponent{ - + String formatTypedefName; - private final Color TYPEDEF_COLOR = CsmFontColorManager.instance().getColor(FontColorProvider.Entity.TYPEDEF); //Color.blue.darker().darker().darker(); + private final Color TYPEDEF_COLOR = CsmFontColorManager.instance().getColor(FontColorProvider.Entity.TYPEDEF); //new Color(64,64,255).darker().darker().darker(); //private boolean displayFQN; - + public void setFormatTypedefName(String formatTypedefName){ this.formatTypedefName = formatTypedefName; - + } - + protected Color getColor(){ return TYPEDEF_COLOR; } - + @Override protected void draw(Graphics g){ // IMPORTANT: @@ -596,7 +596,7 @@ drawIcon(g, getIcon()); drawString(g, formatTypedefName, getColor(), null, strike); } - + /** * returns string representation of paint item * IMPORTANT: have to be in sync with draw() method @@ -604,78 +604,78 @@ @Override public String toString() { return formatTypedefName; - } + } } public static class StructPaintComponent extends ClassPaintComponent{ - - private Color STRUCT_COLOR = Color.red.darker().darker(); - + + private Color STRUCT_COLOR = LFCustoms.shiftColor(new Color(255,64,64)); + @Override protected Color getColor(){ return STRUCT_COLOR; } - + public StructPaintComponent(){ super(); } } - + public static class UnionPaintComponent extends ClassPaintComponent{ - - private Color UNION_COLOR = Color.red.darker(); - + + private Color UNION_COLOR = LFCustoms.shiftColor(new Color(255,64,64)); + @Override protected Color getColor(){ return UNION_COLOR; } - + public UnionPaintComponent(){ super(); } } - + public static class FieldPaintComponent extends CsmPaintComponent{ - private Color FIELD_COLOR = CsmFontColorManager.instance().getColor(FontColorProvider.Entity.CLASS_FIELD);//Color.blue.darker(); + private Color FIELD_COLOR = CsmFontColorManager.instance().getColor(FontColorProvider.Entity.CLASS_FIELD);//new Color(64,64,255).darker(); protected String typeName; protected Color typeColor; protected String fldName; - + private boolean drawTypeAsPrefix = false; - + public FieldPaintComponent() { super(); } - + public Color getNameColor() { return FIELD_COLOR; } - + @Override public void setName(String fldName){ this.fldName= fldName; } - + public void setTypeColor(Color typeColor){ this.typeColor = typeColor; } - + public void setTypeName(String typeName){ this.typeName = typeName; } - + public Color getTypeColor(){ return this.typeColor; } - + public String getTypeName(){ return this.typeName; } - + public void setDrawTypeAsPrefix(boolean asPrefix) { this.drawTypeAsPrefix = asPrefix; } - + @Override protected void draw(Graphics g){ // IMPORTANT: @@ -683,10 +683,10 @@ boolean strike = false; //int level = CsmUtilities.getLevel(modifiers); drawIcon(g, getIcon()); - + if (drawTypeAsPrefix) { drawString(g, getTypeName(), getTypeColor(), null, strike); - drawString(g, " ", strike); // NOI18N + drawString(g, " ", strike); // NOI18N } if ((modifiers & CsmUtilities.LOCAL_MEMBER_BIT) != 0){ // it is local field, draw as bold @@ -716,17 +716,17 @@ buf.append(typeName); } return buf.toString(); - } + } } - + public static class LocalVariablePaintComponent extends FieldPaintComponent { - private Color VARIABLE_COLOR = Color.red.darker().darker().darker(); - + private Color VARIABLE_COLOR = LFCustoms.shiftColor(new Color(255,64,64)); + public LocalVariablePaintComponent(){ super(); this.modifiers |= CsmUtilities.LOCAL_MEMBER_BIT | this.modifiers; } - + @Override public Color getNameColor() { return VARIABLE_COLOR; @@ -737,36 +737,36 @@ super.setModifiers(modifiers | CsmUtilities.LOCAL_MEMBER_BIT); } } - + public static class FileLocalVariablePaintComponent extends FieldPaintComponent { - private Color VARIABLE_COLOR = Color.blue.darker().darker().darker(); - + private Color VARIABLE_COLOR = LFCustoms.shiftColor(new Color(64,64,255)); + public FileLocalVariablePaintComponent(){ super(); } - + @Override public Color getNameColor() { return VARIABLE_COLOR; } } - + public static class GlobalVariablePaintComponent extends FieldPaintComponent { - private Color VARIABLE_COLOR = Color.blue.darker().darker().darker(); - + private Color VARIABLE_COLOR = LFCustoms.shiftColor(new Color(64,64,255)); + public GlobalVariablePaintComponent(){ super(); } - + @Override public Color getNameColor() { return VARIABLE_COLOR; } } - + public static class MacroPaintComponent extends CsmPaintComponent{ - private Color MACRO_NAME_COLOR = CsmFontColorManager.instance().getColor(FontColorProvider.Entity.DEFINED_MACRO);//Color.green.darker().darker(); - private Color MACRO_PARAMETER_NAME_COLOR = new Color(163, 102, 10);//Color.magenta.darker(); + private Color MACRO_NAME_COLOR = CsmFontColorManager.instance().getColor(FontColorProvider.Entity.DEFINED_MACRO);//new Color(64,255,64).darker().darker(); + private Color MACRO_PARAMETER_NAME_COLOR = LFCustoms.shiftColor(new Color(227, 166, 74));//Color.magenta.darker(); private List params = null; private String name; @@ -778,16 +778,16 @@ public String getName(){ return name; } - + @Override public void setName(String name){ this.name = name; } - + public void setParams(List params){ this.params = params; } - + protected List getParamList(){ return params; } @@ -844,11 +844,11 @@ //macro params buf.append(toStringParameterList(getParamList())); return buf.toString(); - } + } } - + public static class TemplateParameterPaintComponent extends CsmPaintComponent{ - private Color PARAMETER_NAME_COLOR = Color.BLACK.darker().darker(); + private Color PARAMETER_NAME_COLOR = LFCustoms.getTextFgColor(); private List params = null; private String name; @@ -860,16 +860,16 @@ public String getName(){ return name; } - + @Override public void setName(String name){ this.name = name; } - + public void setParams(List params){ this.params = params; } - + protected List getParamList(){ return params; } @@ -893,11 +893,11 @@ //macro name buf.append(getName()); return buf.toString(); - } + } } public static class LabelPaintComponent extends CsmPaintComponent { - private Color LABEL_NAME_COLOR = Color.BLACK.darker().darker(); + private Color LABEL_NAME_COLOR = LFCustoms.getTextFgColor(); private List params = null; private String name; @@ -909,16 +909,16 @@ public String getName(){ return name; } - + @Override public void setName(String name){ this.name = name; } - + public void setParams(List params){ this.params = params; } - + protected List getParamList(){ return params; } @@ -942,55 +942,55 @@ //macro name buf.append(getName()); return buf.toString(); - } + } } - + public static class ConstructorPaintComponent extends CsmPaintComponent{ - - private Color CONSTRUCTOR_COLOR = Color.orange.darker().darker(); - private Color PARAMETER_NAME_COLOR = new Color(163, 102, 10);//Color.magenta.darker(); + + private Color CONSTRUCTOR_COLOR = LFCustoms.shiftColor(Color.orange); + private Color PARAMETER_NAME_COLOR = LFCustoms.shiftColor(new Color(227, 166, 74));//Color.magenta.darker(); private List params = new ArrayList(); private List excs = new ArrayList(); private String name; - + public ConstructorPaintComponent(){ super(); } - + public int getMethodModifiers(){ return modifiers; } - + @Override public String getName(){ return name; } - + @Override public void setName(String name){ this.name = name; } - + public void setParams(List params){ this.params = params; } - + public void setExceptions(List excs){ this.excs = excs; } - + protected List getParamList(){ return params; } - + protected List getExceptionList(){ return excs; } - + protected void drawParameter(Graphics g, ParamStr prm) { drawParameter(g, prm, false); } - + protected void drawParameter(Graphics g, ParamStr prm, boolean strike) { String parmName = prm.getName(); String simpleTypeName = prm.getSimpleTypeName(); @@ -1010,11 +1010,11 @@ drawString(g, simpleTypeName.substring(indexOfSqr), prm.getTypeColor(), null, strike); } } - + protected void drawParameterList(Graphics g, List prmList) { drawParameterList(g, prmList, false); } - + protected void drawParameterList(Graphics g, List prmList, boolean strike) { drawString(g, "(", strike); // NOI18N for (Iterator it = prmList.iterator(); it.hasNext();) { @@ -1025,21 +1025,21 @@ } drawString(g, ")", strike); // NOI18N } - + protected void drawExceptions(Graphics g, List exc, boolean strike) { if (exc.size() > 0) { - drawString(g, THROWS, KEYWORD_COLOR, null, strike); + drawString(g, THROWS, LFCustoms.shiftColor(KEYWORD_COLOR), null, strike); for (Iterator it = exc.iterator(); it.hasNext();) { ExceptionStr ex = (ExceptionStr) it.next(); drawString(g, ex.getName(), ex.getTypeColor(), null, strike); if (it.hasNext()) { drawString(g, ", ", strike); // NOI18N } - + } } } - + @Override protected void draw(Graphics g){ // IMPORTANT: @@ -1066,12 +1066,12 @@ //constructor exceptions buf.append(toStringExceptions(getExceptionList())); return buf.toString(); - } - + } + protected String toStringParameter(ParamStr prm) { return prm.getText(); } - + protected String toStringParameterList(List prmList) { StringBuilder buf = new StringBuilder(); buf.append('('); // NOI18N @@ -1084,7 +1084,7 @@ buf.append(')'); // NOI18N return buf.toString(); } - + protected String toStringExceptions(List exc) { StringBuilder buf = new StringBuilder(); if (exc.size() > 0) { @@ -1095,49 +1095,49 @@ if (it.hasNext()) { buf.append(", "); // NOI18N } - + } } return buf.toString(); } } - + public static class MethodPaintComponent extends ConstructorPaintComponent { - + //private Color PARAMETER_NAME_COLOR = Color.magenta.darker(); - private Color METHOD_COLOR = Color.black;//red.darker().darker(); + private Color METHOD_COLOR = LFCustoms.getTextFgColor(); private String typeName; private Color typeColor; private boolean drawTypeAsPrefix = false; - + public MethodPaintComponent(){ super(); } - + public Color getNameColor() { return METHOD_COLOR; } - + public String getTypeName(){ return typeName; } - + public Color getTypeColor(){ return typeColor; } - + public void setTypeName(String typeName){ this.typeName = typeName; } - + public void setTypeColor(Color typeColor){ this.typeColor = typeColor; } - + public void setDrawTypeAsPrefix(boolean asPrefix) { this.drawTypeAsPrefix = asPrefix; } - + @Override protected void draw(Graphics g){ // IMPORTANT: @@ -1145,11 +1145,11 @@ boolean strike = false; //int level = CsmUtilities.getLevel(getModifiers()); drawIcon(g, getIcon()); - + if (drawTypeAsPrefix) { drawString(g, getTypeName(), getTypeColor(), null, strike); - drawString(g, " ", strike); // NOI18N - } + drawString(g, " ", strike); // NOI18N + } if ((getModifiers() & CsmUtilities.LOCAL_MEMBER_BIT) != 0){ drawString(g, getName(), getNameColor() , new Font(getDrawFont().getName(), getDrawFont().getStyle() | Font.BOLD, getDrawFont().getSize()), strike); }else{ @@ -1171,7 +1171,7 @@ StringBuilder buf = new StringBuilder(); if (drawTypeAsPrefix) { //return type - buf.append(getTypeName()); + buf.append(getTypeName()); buf.append(' '); // NOI18N } //method name @@ -1183,47 +1183,47 @@ if (!drawTypeAsPrefix) { //return type buf.append(' '); // NOI18N - buf.append(getTypeName()); + buf.append(getTypeName()); } - return buf.toString(); - } + return buf.toString(); + } } public static class FileLocalFunctionPaintComponent extends MethodPaintComponent { - private Color FUN_COLOR = Color.black;//red.darker().darker(); - + private Color FUN_COLOR = LFCustoms.getTextFgColor(); + public FileLocalFunctionPaintComponent(){ super(); } - + @Override public Color getNameColor() { return FUN_COLOR; } } - + public static class GlobalFunctionPaintComponent extends MethodPaintComponent { - private Color FUN_COLOR = Color.black;//.red.darker().darker(); - + private Color FUN_COLOR = LFCustoms.getTextFgColor(); + public GlobalFunctionPaintComponent(){ super(); } - + @Override public Color getNameColor() { return FUN_COLOR; } } - - public static class CsmPaintComponentWrapper extends CsmPaintComponent { + + public static class CsmPaintComponentWrapper extends CsmPaintComponent { private CsmPaintComponent comp; private boolean drawTypeAsPrefix = true; - + public CsmPaintComponentWrapper() { - super(); + super(); } - - public void setCsmComponent(CsmPaintComponent comp) { + + public void setCsmComponent(CsmPaintComponent comp) { this.comp = comp; } @@ -1235,20 +1235,20 @@ ((CsmPaintComponent.FieldPaintComponent)comp).setDrawTypeAsPrefix(true); } else if (comp instanceof CsmPaintComponent.MethodPaintComponent) { ((CsmPaintComponent.MethodPaintComponent)comp).setDrawTypeAsPrefix(true); - } + } } - comp.draw(g); + comp.draw(g); if (drawTypeAsPrefix) { if (comp instanceof CsmPaintComponent.FieldPaintComponent) { ((CsmPaintComponent.FieldPaintComponent)comp).setDrawTypeAsPrefix(false); } else if (comp instanceof CsmPaintComponent.MethodPaintComponent) { ((CsmPaintComponent.MethodPaintComponent)comp).setDrawTypeAsPrefix(false); - } + } } setDrawState(comp.getDrawState()); } } - + @Override public void setFont(Font font) { super.setFont(font); @@ -1256,33 +1256,33 @@ comp.setFont(font); } } - + @Override public String toString() { if (comp != null) { return comp.toString(); } return ""; - } - } - + } + } + public static class StringPaintComponent extends CsmPaintComponent { private String str; public void setString(String str){ - this.str = str; + this.str = str; } - + @Override protected void draw(Graphics g){ drawIcon(g, null); - drawString(g, str, TYPE_COLOR); + drawString(g, str, LFCustoms.getTextFgColor()); } @Override public String toString() { return str; } - } + } } diff --git a/core.output2/nbproject/project.xml b/core.output2/nbproject/project.xml --- a/core.output2/nbproject/project.xml +++ b/core.output2/nbproject/project.xml @@ -50,6 +50,14 @@ org.netbeans.core.output2 + org.netbeans.swing.plaf + + + + 1.27 + + + org.openide.actions diff --git a/core.output2/src/org/netbeans/core/output2/AbstractLines.java b/core.output2/src/org/netbeans/core/output2/AbstractLines.java --- a/core.output2/src/org/netbeans/core/output2/AbstractLines.java +++ b/core.output2/src/org/netbeans/core/output2/AbstractLines.java @@ -67,7 +67,7 @@ import org.openide.util.Mutex; import org.openide.windows.IOColors; import org.openide.windows.OutputListener; - +import org.netbeans.swing.plaf.LFCustoms; /** * Abstract Lines implementation with handling for getLine wrap calculations, etc. */ @@ -313,7 +313,7 @@ longestLineLen = 0; listener = null; dirty = false; - curDefColors = DEF_COLORS.clone(); + curDefColors = getDefColors().clone(); } private boolean dirty; @@ -827,12 +827,15 @@ } /** initial default colors */ - static final Color[] DEF_COLORS; + private static Color[] DEF_COLORS = null; /** current default colors */ Color[] curDefColors; - static { + static Color[] getDefColors() { + if (DEF_COLORS != null) { + return DEF_COLORS; + } Color out = UIManager.getColor("nb.output.foreground"); //NOI18N if (out == null) { out = UIManager.getColor("textText"); @@ -843,12 +846,12 @@ Color err = UIManager.getColor("nb.output.err.foreground"); //NOI18N if (err == null) { - err = new Color(164, 0, 0); + err = LFCustoms.shiftColor(Color.red); } Color hyperlink = UIManager.getColor("nb.output.link.foreground"); //NOI18N if (hyperlink == null) { - hyperlink = Color.BLUE.darker(); + hyperlink = LFCustoms.shiftColor(Color.blue); } Color hyperlinkImp = UIManager.getColor("nb.output.link.foreground.important"); //NOI18N @@ -856,7 +859,7 @@ hyperlinkImp = hyperlink; } - DEF_COLORS = new Color[]{out, err, hyperlink, hyperlinkImp}; + return DEF_COLORS = new Color[]{out, err, hyperlink, hyperlinkImp}; } public void setDefColor(IOColors.OutputType type, Color color) { diff --git a/core.output2/src/org/netbeans/core/output2/NbIO.java b/core.output2/src/org/netbeans/core/output2/NbIO.java --- a/core.output2/src/org/netbeans/core/output2/NbIO.java +++ b/core.output2/src/org/netbeans/core/output2/NbIO.java @@ -75,7 +75,7 @@ private Boolean focusTaken = null; private boolean closed = false; private final String name; - + private Action[] actions; private NbWriter out = null; @@ -84,7 +84,7 @@ private IOTabImpl ioTab; private IOColorsImpl ioColors; - /** Creates a new instance of NbIO + /** Creates a new instance of NbIO * @param name The name of the IO * @param toolbarActions an optional set of toolbar actions * @param iowin parent container accessor (null for default) @@ -94,12 +94,12 @@ this.actions = toolbarActions; this.ioContainer = ioContainer != null ? ioContainer : IOContainer.getDefault(); } - + /** Package private constructor for unit tests */ NbIO (String name) { this.name = name; } - + public void closeInputOutput() { if (Controller.LOG) Controller.log("CLOSE INPUT OUTPUT CALLED FOR " + this); if (out != null) { @@ -108,7 +108,7 @@ } post (this, IOEvent.CMD_CLOSE, true); } - + String getName() { return name; } @@ -139,7 +139,7 @@ } NbIOProvider.dispose(this); } - + public OutputWriter getOut() { synchronized (this) { if (out == null) { @@ -149,7 +149,7 @@ } return out; } - + /** Called by the view when polling */ OutWriter out() { return out == null ? null : out.out(); @@ -166,38 +166,38 @@ public boolean isErrSeparated() { return false; } - + public boolean isFocusTaken() { return Boolean.TRUE.equals(focusTaken); } - + boolean isStreamClosed() { return out == null ? true : streamClosed; } - + public void select() { if (Controller.LOG) Controller.log (this + ": select"); post (this, IOEvent.CMD_SELECT, true); } - + public void setErrSeparated(boolean value) { //do nothing } - + public void setErrVisible(boolean value) { //do nothing } - + public void setFocusTaken(boolean value) { focusTaken = value ? Boolean.TRUE : Boolean.FALSE; post (this, IOEvent.CMD_FOCUS_TAKEN, value); } - + public void setInputVisible(boolean value) { if (Controller.LOG) Controller.log(NbIO.this + ": SetInputVisible"); post (this, IOEvent.CMD_INPUT_VISIBLE, value); } - + public void setOutputVisible(boolean value) { //do nothing } @@ -218,7 +218,7 @@ Action[] getToolbarActions() { return actions; } - + public void reset() { if (Controller.LOG) Controller.log (this + ": reset"); closed = false; @@ -230,7 +230,7 @@ } post (this, IOEvent.CMD_RESET, true); } - + private static void post (NbIO io, int command, boolean val) { IOEvent evt = new IOEvent (io, command, val); post (evt); @@ -251,7 +251,7 @@ eq.postEvent(evt); } } - + @Override public String toString() { return "NbIO@" + System.identityHashCode(this) + " " + getName(); } @@ -296,7 +296,7 @@ private StringBuffer buffer() { return (StringBuffer) lock; } - + public void pushText (String txt) { if (Controller.LOG) Controller.log (NbIO.this + ": Input text: " + txt); synchronized (lock) { @@ -304,7 +304,7 @@ lock.notifyAll(); } } - + private boolean inputClosed = false; public void eof() { synchronized (lock) { @@ -315,7 +315,7 @@ } } } - + private void checkPristine() throws IOException { if (SwingUtilities.isEventDispatchThread()) { throw new IOException ("Cannot call read() from the event thread, it will deadlock"); @@ -325,7 +325,7 @@ pristine = false; } } - + public int read(char cbuf[], int off, int len) throws IOException { if (Controller.LOG) Controller.log (NbIO.this + ":Input read: " + off + " len " + len); checkPristine(); @@ -348,7 +348,7 @@ return realLen; } } - + @Override public int read() throws IOException { if (Controller.LOG) Controller.log (NbIO.this + ": Input read one char"); @@ -382,7 +382,7 @@ return buffer().length() > 0; } } - + @Override public long skip(long n) throws IOException { if (Controller.LOG) Controller.log (NbIO.this + ": Input skip " + n); @@ -415,7 +415,7 @@ lock.notifyAll(); } } - + public boolean isClosed() { return inputClosed; } @@ -430,7 +430,7 @@ } Color getColor(IOColors.OutputType type) { - return ioColors != null ? ioColors.getColor(type) : AbstractLines.DEF_COLORS[type.ordinal()]; + return ioColors != null ? ioColors.getColor(type) : AbstractLines.getDefColors()[type.ordinal()]; } private class IOTabImpl extends IOTab { @@ -521,7 +521,7 @@ @Override protected Color getColor(OutputType type) { - return clrs[type.ordinal()] != null ? clrs[type.ordinal()] : AbstractLines.DEF_COLORS[type.ordinal()]; + return clrs[type.ordinal()] != null ? clrs[type.ordinal()] : AbstractLines.getDefColors()[type.ordinal()]; } @Override diff --git a/java.editor/nbproject/project.xml b/java.editor/nbproject/project.xml --- a/java.editor/nbproject/project.xml +++ b/java.editor/nbproject/project.xml @@ -337,6 +337,14 @@ + org.netbeans.swing.plaf + + + + 1.27 + + + org.openide.awt diff --git a/java.editor/src/org/netbeans/modules/editor/java/JavaCompletionItem.java b/java.editor/src/org/netbeans/modules/editor/java/JavaCompletionItem.java --- a/java.editor/src/org/netbeans/modules/editor/java/JavaCompletionItem.java +++ b/java.editor/src/org/netbeans/modules/editor/java/JavaCompletionItem.java @@ -97,13 +97,14 @@ import org.openide.util.ImageUtilities; import org.openide.util.NbBundle; import org.openide.xml.XMLUtil; +import org.netbeans.swing.plaf.LFCustoms; /** * * @author Dusan Balek */ public abstract class JavaCompletionItem implements CompletionItem { - + protected static int SMART_TYPE = 1000; private static final String GENERATE_TEXT = NbBundle.getMessage(JavaCompletionItem.class, "generate_Lbl"); private static final Logger LOGGER = Logger.getLogger(JavaCompletionItem.class.getName()); @@ -111,7 +112,7 @@ public static final JavaCompletionItem createKeywordItem(String kwd, String postfix, int substitutionOffset, boolean smartType) { return new KeywordItem(kwd, 0, postfix, substitutionOffset, smartType); } - + public static final JavaCompletionItem createPackageItem(String pkgFQN, int substitutionOffset, boolean inPackageStatement) { return new PackageItem(pkgFQN, substitutionOffset, inPackageStatement); } @@ -130,7 +131,7 @@ throw new IllegalArgumentException("kind=" + elem.getKind()); } } - + public static final JavaCompletionItem createArrayItem(CompilationInfo info, ArrayType type, int substitutionOffset, ReferencesCount referencesCount, Elements elements, WhiteListQuery.WhiteList whiteList) { int dim = 0; TypeMirror tm = type; @@ -156,7 +157,7 @@ } throw new IllegalArgumentException("array element kind=" + tm.getKind()); } - + public static final JavaCompletionItem createTypeParameterItem(TypeParameterElement elem, int substitutionOffset) { return new TypeParameterItem(elem, substitutionOffset); } @@ -175,7 +176,7 @@ throw new IllegalArgumentException("kind=" + elem.getKind()); } } - + public static final JavaCompletionItem createVariableItem(CompilationInfo info, String varName, int substitutionOffset, boolean newVarName, boolean smartType) { return new VariableItem(info, null, varName, substitutionOffset, newVarName, smartType, -1); } @@ -190,7 +191,7 @@ throw new IllegalArgumentException("kind=" + elem.getKind()); } } - + public static final JavaCompletionItem createThisOrSuperConstructorItem(CompilationInfo info, ExecutableElement elem, ExecutableType type, int substitutionOffset, boolean isDeprecated, String name, WhiteListQuery.WhiteList whiteList) { if (elem.getKind() == ElementKind.CONSTRUCTOR) return new ConstructorItem(info, elem, type, substitutionOffset, isDeprecated, false, name, whiteList); @@ -219,7 +220,7 @@ public static final JavaCompletionItem createDefaultConstructorItem(TypeElement elem, int substitutionOffset, boolean smartType) { return new DefaultConstructorItem(elem, substitutionOffset, smartType); } - + public static final JavaCompletionItem createParametersItem(CompilationInfo info, ExecutableElement elem, ExecutableType type, int substitutionOffset, boolean isDeprecated, int activeParamIndex, String name) { return new ParametersItem(info, elem, type, substitutionOffset, isDeprecated, activeParamIndex, name); } @@ -227,11 +228,11 @@ public static final JavaCompletionItem createAnnotationItem(CompilationInfo info, TypeElement elem, DeclaredType type, int substitutionOffset, ReferencesCount referencesCount, boolean isDeprecated, WhiteListQuery.WhiteList whiteList) { return new AnnotationItem(info, elem, type, substitutionOffset, referencesCount, isDeprecated, true, whiteList); } - + public static final JavaCompletionItem createAttributeItem(CompilationInfo info, ExecutableElement elem, ExecutableType type, int substitutionOffset, boolean isDeprecated) { return new AttributeItem(info, elem, type, substitutionOffset, isDeprecated); } - + public static final JavaCompletionItem createAttributeValueItem(CompilationInfo info, String value, String documentation, TypeElement element, int substitutionOffset, ReferencesCount referencesCount, WhiteListQuery.WhiteList whiteList) { return new AttributeValueItem(info, value, documentation, element, substitutionOffset, referencesCount, whiteList); } @@ -337,19 +338,19 @@ defaultAction(component); return true; } - + public CompletionTask createDocumentationTask() { return null; } - + public CompletionTask createToolTipTask() { return null; } - + public int getPreferredWidth(Graphics g, Font defaultFont) { return CompletionUtilities.getPreferredWidth(getLeftHtmlText(), getRightHtmlText(), g, defaultFont); } - + public void render(Graphics g, Font defaultFont, Color defaultColor, Color backgroundColor, int width, int height, boolean selected) { CompletionUtilities.renderHtml(getIcon(), getLeftHtmlText(), getRightHtmlText(), g, defaultFont, defaultColor, width, height, selected); } @@ -357,11 +358,11 @@ protected ImageIcon getIcon() { return null; } - + protected String getLeftHtmlText() { return null; } - + protected String getRightHtmlText() { return null; } @@ -431,7 +432,7 @@ } }); } - + static abstract class WhiteListJavaCompletionItem extends JavaCompletionItem { private static final String WARNING = "org/netbeans/modules/java/editor/resources/warning_badge.gif"; //NOI18N @@ -486,13 +487,13 @@ return super.getIcon(); } } - + static class KeywordItem extends JavaCompletionItem { - + private static final String JAVA_KEYWORD = "org/netbeans/modules/java/editor/resources/javakw_16.png"; //NOI18N private static final String KEYWORD_COLOR = ""; //NOI18N private static ImageIcon icon; - + private String kwd; private int dim; private String postfix; @@ -506,24 +507,24 @@ this.postfix = postfix; this.smartType = smartType; } - + public int getSortPriority() { return smartType ? 600 - SMART_TYPE : 600; } - + public CharSequence getSortText() { return kwd; } - + public CharSequence getInsertPrefix() { return kwd; } - + protected ImageIcon getIcon(){ if (icon == null) icon = ImageUtilities.loadImageIcon(JAVA_KEYWORD, false); - return icon; + return icon; } - + protected String getLeftHtmlText() { if (leftText == null) { StringBuilder sb = new StringBuilder(); @@ -538,7 +539,7 @@ } return leftText; } - + @Override protected void substituteText (final JTextComponent c, final int offset, int len, String toAdd, final boolean assignToVar) { if (dim == 0) { @@ -587,7 +588,7 @@ for(int i = 0; i < dim; i++) { sb.append("[${PAR"); //NOI18N sb.append(cnt++); - sb.append(" instanceof=\"int\" default=\"\"}]"); //NOI18N + sb.append(" instanceof=\"int\" default=\"\"}]"); //NOI18N } final int length = len; doc.runAtomic (new Runnable () { @@ -608,18 +609,18 @@ ctm.createTemporary(sb.append(text).toString()).insert(c); } } - + public String toString() { return kwd; - } + } } - + static class PackageItem extends JavaCompletionItem { - + private static final String PACKAGE = "org/netbeans/modules/java/editor/resources/package.gif"; // NOI18N private static final String PACKAGE_COLOR = ""; //NOI18N private static ImageIcon icon; - + private boolean inPackageStatement; private String simpleName; private String sortText; @@ -632,24 +633,24 @@ this.simpleName = idx < 0 ? pkgFQN : pkgFQN.substring(idx + 1); this.sortText = this.simpleName + "#" + pkgFQN; //NOI18N } - + public int getSortPriority() { return 900; } - + public CharSequence getSortText() { return sortText; } - + public CharSequence getInsertPrefix() { return simpleName; } - + protected ImageIcon getIcon(){ if (icon == null) icon = ImageUtilities.loadImageIcon(PACKAGE, false); - return icon; + return icon; } - + protected String getLeftHtmlText() { if (leftText == null) { StringBuilder sb = new StringBuilder(); @@ -675,19 +676,19 @@ protected void substituteText(JTextComponent c, int offset, int len, String toAdd, final boolean assingToVar) { super.substituteText(c, offset, len, inPackageStatement || toAdd != null ? toAdd : ".", assingToVar); //NOI18N } - + public String toString() { return simpleName; - } + } } static class ClassItem extends WhiteListJavaCompletionItem { - + private static final String CLASS = "org/netbeans/modules/editor/resources/completion/class_16.png"; //NOI18N private static final String CLASS_COLOR = ""; //NOI18N private static final String PKG_COLOR = ""; //NOI18N private static ImageIcon icon; - + protected TypeMirrorHandle typeHandle; private int dim; private boolean isDeprecated; @@ -701,7 +702,7 @@ private CharSequence sortText; private String leftText; private boolean autoImport; - + private ClassItem(CompilationInfo info, TypeElement elem, DeclaredType type, int dim, int substitutionOffset, ReferencesCount referencesCount, boolean isDeprecated, boolean insideNew, boolean addTypeVars, boolean addSimpleName, boolean smartType, boolean autoImport, WhiteListQuery.WhiteList whiteList) { super(substitutionOffset, ElementHandle.create(elem), whiteList); this.typeHandle = TypeMirrorHandle.create(type); @@ -722,15 +723,15 @@ } this.autoImport = autoImport; } - + public int getSortPriority() { return smartType ? 800 - SMART_TYPE : 800; } - + public CharSequence getSortText() { return sortText; } - + public CharSequence getInsertPrefix() { return simpleName; } @@ -738,7 +739,7 @@ public boolean instantSubstitution(JTextComponent component) { return false; } - + public CompletionTask createDocumentationTask() { return typeHandle.getKind() == TypeKind.DECLARED ? JavaCompletionProvider.createDocTask(ElementHandle.from(typeHandle)) : null; } @@ -771,7 +772,7 @@ } return leftText; } - + protected String getColor() { return CLASS_COLOR; } @@ -857,7 +858,7 @@ Iterator tas = type != null ? type.getTypeArguments().iterator() : null; if (tas != null && tas.hasNext()) { sb.append('<'); //NOI18N - if (!insideNew || elem.getModifiers().contains(Modifier.ABSTRACT) + if (!insideNew || elem.getModifiers().contains(Modifier.ABSTRACT) || controller.getSourceVersion().compareTo(SourceVersion.RELEASE_7) < 0) { while (tas.hasNext()) { TypeMirror ta = tas.next(); @@ -1012,65 +1013,64 @@ } }, NbBundle.getMessage(JavaCompletionItem.class, "JCI-import_resolve"), cancel, false); //NOI18N } - + public String toString() { return simpleName; } } - + static class InterfaceItem extends ClassItem { - + private static final String INTERFACE = "org/netbeans/modules/editor/resources/completion/interface.png"; // NOI18N private static final String INTERFACE_COLOR = ""; //NOI18N private static ImageIcon icon; - + private InterfaceItem(CompilationInfo info, TypeElement elem, DeclaredType type, int dim, int substitutionOffset, ReferencesCount referencesCount, boolean isDeprecated, boolean insideNew, boolean addTypeVars, boolean addSimpleName, boolean smartType, boolean autoImport, WhiteListQuery.WhiteList whiteList) { super(info, elem, type, dim, substitutionOffset, referencesCount, isDeprecated, insideNew, addTypeVars, addSimpleName, smartType, autoImport, whiteList); } protected ImageIcon getBaseIcon(){ if (icon == null) icon = ImageUtilities.loadImageIcon(INTERFACE, false); - return icon; + return icon; } - + protected String getColor() { return INTERFACE_COLOR; } } static class EnumItem extends ClassItem { - + private static final String ENUM = "org/netbeans/modules/editor/resources/completion/enum.png"; // NOI18N private static ImageIcon icon; - + private EnumItem(CompilationInfo info, TypeElement elem, DeclaredType type, int dim, int substitutionOffset, ReferencesCount referencesCount, boolean isDeprecated, boolean insideNew, boolean addSimpleName, boolean smartType, boolean autoImport, WhiteListQuery.WhiteList whiteList) { super(info, elem, type, dim, substitutionOffset, referencesCount, isDeprecated, insideNew, false, addSimpleName, smartType, autoImport, whiteList); } protected ImageIcon getBaseIcon(){ if (icon == null) icon = ImageUtilities.loadImageIcon(ENUM, false); - return icon; + return icon; } } - + static class AnnotationTypeItem extends ClassItem { - + private static final String ANNOTATION = "org/netbeans/modules/editor/resources/completion/annotation_type.png"; // NOI18N private static ImageIcon icon; - + private AnnotationTypeItem(CompilationInfo info, TypeElement elem, DeclaredType type, int dim, int substitutionOffset, ReferencesCount referencesCount, boolean isDeprecated, boolean insideNew, boolean addSimpleName, boolean smartType, boolean autoImport, WhiteListQuery.WhiteList whiteList) { super(info, elem, type, dim, substitutionOffset, referencesCount, isDeprecated, insideNew, false, addSimpleName, smartType, autoImport, whiteList); } protected ImageIcon getBaseIcon(){ if (icon == null) icon = ImageUtilities.loadImageIcon(ANNOTATION, false); - return icon; + return icon; } } - + static class TypeParameterItem extends JavaCompletionItem { - - private static final String TYPE_PARAMETER_COLOR = ""; //NOI18N + private String simpleName; private String leftText; @@ -1079,32 +1079,32 @@ super(substitutionOffset); this.simpleName = elem.getSimpleName().toString(); } - + public int getSortPriority() { return 700; } - + public CharSequence getSortText() { return simpleName; } - + public CharSequence getInsertPrefix() { return simpleName; } - + protected String getLeftHtmlText() { if (leftText == null) - leftText = TYPE_PARAMETER_COLOR + simpleName + COLOR_END; + leftText = LFCustoms.getTextFgColorHTML() + simpleName + COLOR_END; return leftText; } - + public String toString() { return simpleName; - } + } } static class VariableItem extends JavaCompletionItem { - + private static final String LOCAL_VARIABLE = "org/netbeans/modules/editor/resources/completion/localVariable.gif"; //NOI18N private static final String PARAMETER_COLOR = ""; //NOI18N private static ImageIcon icon; @@ -1117,7 +1117,7 @@ private String rightText; private int assignToVarPos; private String assignToVarText; - + private VariableItem(CompilationInfo info, TypeMirror type, String varName, int substitutionOffset, boolean newVarName, boolean smartType, int assignToVarPos) { super(substitutionOffset); this.varName = varName; @@ -1127,15 +1127,15 @@ this.assignToVarPos = assignToVarPos; this.assignToVarText = assignToVarPos < 0 ? null : getAssignToVarText(info, type, varName); } - + public int getSortPriority() { return smartType ? 200 - SMART_TYPE : 200; } - + public CharSequence getSortText() { return varName; } - + public CharSequence getInsertPrefix() { return varName; } @@ -1145,16 +1145,16 @@ leftText = PARAMETER_COLOR + BOLD + varName + BOLD_END + COLOR_END; return leftText; } - + protected String getRightHtmlText() { if (rightText == null) rightText = escape(typeName); return rightText; } - + protected ImageIcon getIcon(){ if (icon == null) icon = ImageUtilities.loadImageIcon(LOCAL_VARIABLE, false); - return icon; + return icon; } @Override @@ -1193,18 +1193,18 @@ } static class FieldItem extends WhiteListJavaCompletionItem { - + private static final String FIELD_PUBLIC = "org/netbeans/modules/editor/resources/completion/field_16.png"; //NOI18N private static final String FIELD_PROTECTED = "org/netbeans/modules/editor/resources/completion/field_protected_16.png"; //NOI18N private static final String FIELD_PACKAGE = "org/netbeans/modules/editor/resources/completion/field_package_private_16.png"; //NOI18N - private static final String FIELD_PRIVATE = "org/netbeans/modules/editor/resources/completion/field_private_16.png"; //NOI18N + private static final String FIELD_PRIVATE = "org/netbeans/modules/editor/resources/completion/field_private_16.png"; //NOI18N private static final String FIELD_ST_PUBLIC = "org/netbeans/modules/editor/resources/completion/field_static_16.png"; //NOI18N private static final String FIELD_ST_PROTECTED = "org/netbeans/modules/editor/resources/completion/field_static_protected_16.png"; //NOI18N private static final String FIELD_ST_PACKAGE = "org/netbeans/modules/editor/resources/completion/field_static_package_private_16.png"; //NOI18N private static final String FIELD_ST_PRIVATE = "org/netbeans/modules/editor/resources/completion/field_static_private_16.png"; //NOI18N private static final String FIELD_COLOR = ""; //NOI18N private static ImageIcon icon[][] = new ImageIcon[2][4]; - + private boolean isInherited; private boolean isDeprecated; private boolean smartType; @@ -1217,7 +1217,7 @@ private CharSequence enclSortText; private int assignToVarPos; private String assignToVarText; - + private FieldItem(CompilationInfo info, VariableElement elem, TypeMirror type, int substitutionOffset, ReferencesCount referencesCount, boolean isInherited, boolean isDeprecated, boolean smartType, int assignToVarPos, WhiteListQuery.WhiteList whiteList) { super(substitutionOffset, ElementHandle.create(elem), whiteList); this.isInherited = isInherited; @@ -1235,15 +1235,15 @@ this.assignToVarPos = assignToVarPos; this.assignToVarText = assignToVarPos < 0 ? null : getAssignToVarText(info, type, this.simpleName); } - + public int getSortPriority() { return smartType ? 300 - SMART_TYPE : 300; } - + public CharSequence getSortText() { return simpleName + "#" + enclSortText; //NOI18N } - + public CharSequence getInsertPrefix() { return simpleName; } @@ -1276,13 +1276,13 @@ rightText = escape(typeName); return rightText; } - + protected ImageIcon getBaseIcon(){ int level = getProtectionLevel(modifiers); boolean isStatic = modifiers.contains(Modifier.STATIC); ImageIcon cachedIcon = icon[isStatic?1:0][level]; if (cachedIcon != null) - return cachedIcon; + return cachedIcon; String iconPath = FIELD_PUBLIC; if (isStatic) { @@ -1324,7 +1324,7 @@ } ImageIcon newIcon = ImageUtilities.loadImageIcon(iconPath, false); icon[isStatic?1:0][level] = newIcon; - return newIcon; + return newIcon; } @Override @@ -1379,7 +1379,7 @@ tmp.insert(c); } } - } catch (BadLocationException ble) { + } catch (BadLocationException ble) { } } @@ -1395,18 +1395,17 @@ return sb.toString(); } } - + static class MethodItem extends WhiteListJavaCompletionItem { - + private static final String METHOD_PUBLIC = "org/netbeans/modules/editor/resources/completion/method_16.png"; //NOI18N private static final String METHOD_PROTECTED = "org/netbeans/modules/editor/resources/completion/method_protected_16.png"; //NOI18N private static final String METHOD_PACKAGE = "org/netbeans/modules/editor/resources/completion/method_package_private_16.png"; //NOI18N - private static final String METHOD_PRIVATE = "org/netbeans/modules/editor/resources/completion/method_private_16.png"; //NOI18N + private static final String METHOD_PRIVATE = "org/netbeans/modules/editor/resources/completion/method_private_16.png"; //NOI18N private static final String METHOD_ST_PUBLIC = "org/netbeans/modules/editor/resources/completion/method_static_16.png"; //NOI18N private static final String METHOD_ST_PROTECTED = "org/netbeans/modules/editor/resources/completion/method_static_protected_16.png"; //NOI18N private static final String METHOD_ST_PRIVATE = "org/netbeans/modules/editor/resources/completion/method_static_private_16.png"; //NOI18N private static final String METHOD_ST_PACKAGE = "org/netbeans/modules/editor/resources/completion/method_static_package_private_16.png"; //NOI18N - private static final String METHOD_COLOR = ""; //NOI18N private static final String PARAMETER_NAME_COLOR = ""; //NOI18N private static ImageIcon icon[][] = new ImageIcon[2][4]; @@ -1426,7 +1425,7 @@ private CharSequence enclSortText; private int assignToVarPos; private String assignToVarText; - + private MethodItem(CompilationInfo info, ExecutableElement elem, ExecutableType type, int substitutionOffset, ReferencesCount referencesCount, boolean isInherited, boolean isDeprecated, boolean inImport, boolean addSemicolon, boolean smartType, int assignToVarPos, WhiteListQuery.WhiteList whiteList) { super(substitutionOffset, ElementHandle.create(elem), whiteList); this.isInherited = isInherited; @@ -1456,11 +1455,11 @@ this.assignToVarPos = type.getReturnType().getKind() == TypeKind.VOID ? -1 : assignToVarPos; this.assignToVarText = this.assignToVarPos < 0 ? null : getAssignToVarText(info, type.getReturnType(), this.simpleName); } - + public int getSortPriority() { return smartType ? 500 - SMART_TYPE : 500; } - + public CharSequence getSortText() { if (sortText == null) { StringBuilder sortParams = new StringBuilder(); @@ -1479,15 +1478,15 @@ } return sortText; } - + public CharSequence getInsertPrefix() { return simpleName; } - + protected String getLeftHtmlText() { if (leftText == null) { StringBuilder lText = new StringBuilder(); - lText.append(METHOD_COLOR); + lText.append(LFCustoms.getTextFgColorHTML()); if (!isInherited) lText.append(BOLD); if (isDeprecated || isBlackListed()) @@ -1521,7 +1520,7 @@ rightText = escape(typeName); return rightText; } - + public CompletionTask createDocumentationTask() { return JavaCompletionProvider.createDocTask(getElementHandle()); } @@ -1532,8 +1531,8 @@ ImageIcon cachedIcon = icon[isStatic?1:0][level]; if (cachedIcon != null) return cachedIcon; - - String iconPath = METHOD_PUBLIC; + + String iconPath = METHOD_PUBLIC; if (isStatic) { switch (level) { case PRIVATE_LEVEL: @@ -1573,9 +1572,9 @@ } ImageIcon newIcon = ImageUtilities.loadImageIcon(iconPath, false); icon[isStatic?1:0][level] = newIcon; - return newIcon; + return newIcon; } - + @Override protected void substituteText(final JTextComponent c, final int offset, int len, String toAdd, final boolean assignToVar) { try { @@ -1613,7 +1612,7 @@ AutoImport.resolveImport(controller, controller.getTreeUtilities().pathFor(embeddedOffset), ee.getEnclosingElement().asType()); } }); - } catch (ParseException pe) { + } catch (ParseException pe) { } } }, NbBundle.getMessage(JavaCompletionItem.class, "JCI-import_resolve"), cancel, false); //NOI18N @@ -1686,7 +1685,7 @@ Position semiPosition = semiPos > -1 ? doc.createPosition(semiPos) : null; String textToReplace = doc.getText(pos.getOffset(), length); if (textToReplace.contentEquals(getInsertPrefix() + sb.toString())) { - c.setCaretPosition(c.getCaretPosition() + sb.length()); + c.setCaretPosition(c.getCaretPosition() + sb.length()); sb.delete(0, sb.length()); } else { if (length > 0) @@ -1724,7 +1723,7 @@ AutoImport.resolveImport(controller, controller.getTreeUtilities().pathFor(embeddedOffset), ee.getEnclosingElement().asType()); } }); - } catch (ParseException pe) { + } catch (ParseException pe) { } } }, NbBundle.getMessage(JavaCompletionItem.class, "JCI-import_resolve"), cancel, false); //NOI18N @@ -1770,7 +1769,7 @@ } } catch (BadLocationException ex) { } - } + } public String toString() { StringBuilder sb = new StringBuilder(); @@ -1794,29 +1793,29 @@ sb.append(')'); return sb.toString(); } - } + } static class OverrideMethodItem extends MethodItem { - + private static final String IMPL_BADGE_PATH = "org/netbeans/modules/java/editor/resources/implement_badge.png"; private static final String OVRD_BADGE_PATH = "org/netbeans/modules/java/editor/resources/override_badge.png"; - + private static final String OVERRIDE_TEXT = NbBundle.getMessage(JavaCompletionItem.class, "override_Lbl"); private static final String IMPLEMENT_TEXT = NbBundle.getMessage(JavaCompletionItem.class, "implement_Lbl"); - + private static ImageIcon implementBadge = ImageUtilities.loadImageIcon(IMPL_BADGE_PATH, false); private static ImageIcon overrideBadge = ImageUtilities.loadImageIcon(OVRD_BADGE_PATH, false); private static ImageIcon merged_icon[][] = new ImageIcon[2][4]; - - + + private boolean implement; private String leftText; - + private OverrideMethodItem(CompilationInfo info, ExecutableElement elem, ExecutableType type, int substitutionOffset, boolean implement, WhiteListQuery.WhiteList whiteList) { super(info, elem, type, substitutionOffset, null, false, false, false, false, false, -1, whiteList); this.implement = implement; } - + protected String getLeftHtmlText() { if (leftText == null) { leftText = super.getLeftHtmlText() + " - "; @@ -1824,7 +1823,7 @@ } return leftText; } - + @Override protected ImageIcon getBaseIcon() { int level = getProtectionLevel(modifiers); @@ -1832,18 +1831,18 @@ if ( merged != null ) { return merged; } - ImageIcon superIcon = super.getBaseIcon(); + ImageIcon superIcon = super.getBaseIcon(); merged = new ImageIcon( ImageUtilities.mergeImages( - superIcon.getImage(), - implement ? implementBadge.getImage() : overrideBadge.getImage(), - 16 - 8, + superIcon.getImage(), + implement ? implementBadge.getImage() : overrideBadge.getImage(), + 16 - 8, 16 - 8) ); - + merged_icon[implement? 0 : 1][level] = merged; return merged; } - + @Override protected void substituteText(final JTextComponent c, final int offset, final int len, String toAdd, final boolean assignToVar) { final BaseDocument doc = (BaseDocument)c.getDocument(); @@ -1912,16 +1911,15 @@ } static class GetterSetterMethodItem extends JavaCompletionItem { - + private static final String METHOD_PUBLIC = "org/netbeans/modules/editor/resources/completion/method_16.png"; //NOI18N private static final String GETTER_BADGE_PATH = "org/netbeans/modules/java/editor/resources/getter_badge.png"; //NOI18N private static final String SETTER_BADGE_PATH = "org/netbeans/modules/java/editor/resources/setter_badge.png"; //NOI18N - private static final String METHOD_COLOR = ""; //NOI18N private static final String PARAMETER_NAME_COLOR = ""; //NOI18N - + private static ImageIcon superIcon; private static ImageIcon[] merged_icons = new ImageIcon[2]; - + protected ElementHandle elementHandle; private boolean setter; private String simpleName; @@ -1930,10 +1928,10 @@ private String sortText; private String leftText; private String rightText; - + private GetterSetterMethodItem(CompilationInfo info, VariableElement elem, TypeMirror type, int substitutionOffset, boolean setter) { super(substitutionOffset); - this.elementHandle = ElementHandle.create(elem); + this.elementHandle = ElementHandle.create(elem); this.setter = setter; this.simpleName = elem.getSimpleName().toString(); if (setter) @@ -1942,11 +1940,11 @@ this.name = (elem.asType().getKind() == TypeKind.BOOLEAN ? "is" : "get") + GeneratorUtils.getCapitalizedName(simpleName); //NOI18N this.typeName = Utilities.getTypeName(info, type, false).toString(); } - + public int getSortPriority() { return 500; } - + public CharSequence getSortText() { if (sortText == null) { StringBuilder sortParams = new StringBuilder(); @@ -1958,16 +1956,16 @@ } return sortText; } - + public CharSequence getInsertPrefix() { return name; } - + @Override protected String getLeftHtmlText() { if (leftText == null) { StringBuilder lText = new StringBuilder(); - lText.append(METHOD_COLOR); + lText.append(LFCustoms.getTextFgColorHTML()); lText.append(BOLD); lText.append(name); lText.append(BOLD_END); @@ -1986,14 +1984,14 @@ } return leftText; } - + @Override protected String getRightHtmlText() { if (rightText == null) rightText = setter ? "void" : escape(typeName); return rightText; } - + @Override protected ImageIcon getIcon() { if (merged_icons[setter ? 1 : 0] == null) { @@ -2011,7 +2009,7 @@ } return merged_icons[setter ? 1 : 0]; } - + @Override protected void substituteText(final JTextComponent c, final int offset, final int len, String toAdd, final boolean assignToVar) { final BaseDocument doc = (BaseDocument)c.getDocument(); @@ -2038,7 +2036,7 @@ public void run(ResultIterator resultIterator) throws Exception { WorkingCopy copy = WorkingCopy.get(resultIterator.getParserResult()); copy.toPhase(Phase.ELEMENTS_RESOLVED); - VariableElement ve = elementHandle.resolve(copy); + VariableElement ve = elementHandle.resolve(copy); if (ve == null) return; final int embeddedOffset = copy.getSnapshot().getEmbeddedOffset(pos.getOffset()); @@ -2094,7 +2092,7 @@ } static class ConstructorItem extends WhiteListJavaCompletionItem { - + private static final String CONSTRUCTOR_PUBLIC = "org/netbeans/modules/editor/resources/completion/constructor_16.png"; //NOI18N private static final String CONSTRUCTOR_PROTECTED = "org/netbeans/modules/editor/resources/completion/constructor_protected_16.png"; //NOI18N private static final String CONSTRUCTOR_PACKAGE = "org/netbeans/modules/editor/resources/completion/constructor_package_private_16.png"; //NOI18N @@ -2112,7 +2110,7 @@ private boolean insertName; private String sortText; private String leftText; - + private ConstructorItem(CompilationInfo info, ExecutableElement elem, ExecutableType type, int substitutionOffset, boolean isDeprecated, boolean smartType, String name, WhiteListQuery.WhiteList whiteList) { super(substitutionOffset, ElementHandle.create(elem), whiteList); this.isDeprecated = isDeprecated; @@ -2131,11 +2129,11 @@ } this.isAbstract = !insertName && elem.getEnclosingElement().getModifiers().contains(Modifier.ABSTRACT); } - + public int getSortPriority() { return insertName ? 550 : smartType ? 650 - SMART_TYPE : 650; } - + public CharSequence getSortText() { if (sortText == null) { StringBuilder sortParams = new StringBuilder(); @@ -2154,11 +2152,11 @@ } return sortText; } - + public CharSequence getInsertPrefix() { return simpleName; - } - + } + protected String getLeftHtmlText() { if (leftText == null) { StringBuilder lText = new StringBuilder(); @@ -2199,8 +2197,8 @@ ImageIcon cachedIcon = icon[level]; if (cachedIcon != null) return cachedIcon; - - String iconPath = CONSTRUCTOR_PUBLIC; + + String iconPath = CONSTRUCTOR_PUBLIC; switch (level) { case PRIVATE_LEVEL: iconPath = CONSTRUCTOR_PRIVATE; @@ -2220,9 +2218,9 @@ } ImageIcon newIcon = ImageUtilities.loadImageIcon(iconPath, false); icon[level] = newIcon; - return newIcon; + return newIcon; } - + @Override protected void substituteText(final JTextComponent c, int offset, int len, String toAdd, final boolean assignToVar) { if (!insertName) { @@ -2315,11 +2313,11 @@ TreePath path = copy.getTreeUtilities().pathFor(embeddedOffset); while (path.getLeaf() != path.getCompilationUnit()) { Tree tree = path.getLeaf(); - Tree parentTree = path.getParentPath().getLeaf(); + Tree parentTree = path.getParentPath().getLeaf(); if (parentTree.getKind() == Tree.Kind.NEW_CLASS && TreeUtilities.CLASS_TREE_KINDS.contains(tree.getKind())) { GeneratorUtils.generateAllAbstractMethodImplementations(copy, path); break; - } + } path = path.getParentPath(); } } @@ -2364,7 +2362,7 @@ Completion.get().showToolTip(); } } - } + } public String toString() { StringBuilder sb = new StringBuilder(); @@ -2387,13 +2385,13 @@ return sb.toString(); } } - + static class DefaultConstructorItem extends JavaCompletionItem { - + private static final String CONSTRUCTOR = "org/netbeans/modules/java/editor/resources/new_constructor_16.png"; //NOI18N private static final String CONSTRUCTOR_COLOR = ""; //NOI18N - private static ImageIcon icon; - + private static ImageIcon icon; + private boolean smartType; private String simpleName; private boolean isAbstract; @@ -2420,16 +2418,16 @@ sortText = simpleName + "#0#"; //NOI18N return sortText; } - + protected String getLeftHtmlText() { if (leftText == null) leftText = CONSTRUCTOR_COLOR + simpleName + "()" + COLOR_END; //NOI18N return leftText; - } + } protected ImageIcon getIcon() { if (icon == null) icon = ImageUtilities.loadImageIcon(CONSTRUCTOR, false); - return icon; + return icon; } @Override @@ -2517,11 +2515,11 @@ TreePath path = copy.getTreeUtilities().pathFor(embeddedOffset); while (path.getLeaf() != path.getCompilationUnit()) { Tree tree = path.getLeaf(); - Tree parentTree = path.getParentPath().getLeaf(); + Tree parentTree = path.getParentPath().getLeaf(); if (parentTree.getKind() == Tree.Kind.NEW_CLASS && TreeUtilities.CLASS_TREE_KINDS.contains(tree.getKind())) { GeneratorUtils.generateAllAbstractMethodImplementations(copy, path); break; - } + } path = path.getParentPath(); } } @@ -2532,16 +2530,15 @@ } } } - + public String toString() { return simpleName + "()"; - } + } } - + static class ParametersItem extends JavaCompletionItem { - + private static final String PARAMETERS_COLOR = ""; //NOI18N - private static final String ACTIVE_PARAMETER_COLOR = ""; //NOI18N protected ElementHandle elementHandle; private boolean isDeprecated; @@ -2598,7 +2595,7 @@ public CharSequence getInsertPrefix() { return ""; //NOI18N } - + protected String getLeftHtmlText() { if (leftText == null) { StringBuilder lText = new StringBuilder(); @@ -2612,14 +2609,14 @@ for (int i = 0; i < params.size(); i++) { ParamDesc paramDesc = params.get(i); if (i == activeParamsIndex) - lText.append(COLOR_END).append(ACTIVE_PARAMETER_COLOR).append(BOLD); + lText.append(COLOR_END).append(LFCustoms.getTextFgColorHTML()).append(BOLD); lText.append(escape(paramDesc.typeName)); lText.append(' '); lText.append(paramDesc.name); if (i < params.size() - 1) lText.append(", "); //NOI18N else - lText.append(BOLD_END).append(COLOR_END).append(PARAMETERS_COLOR); + lText.append(BOLD_END).append(COLOR_END).append(PARAMETERS_COLOR); } lText.append(')'); lText.append(COLOR_END); @@ -2627,13 +2624,13 @@ } return leftText; } - + protected String getRightHtmlText() { if (rightText == null) rightText = PARAMETERS_COLOR + escape(typeName) + COLOR_END; return rightText; } - + public CompletionTask createDocumentationTask() { return JavaCompletionProvider.createDocTask(elementHandle); } @@ -2641,14 +2638,14 @@ public boolean instantSubstitution(JTextComponent component) { return false; } - + protected void substituteText(final JTextComponent c, final int offset, int len, String toAdd, final boolean assignToVar) { String add = ")"; //NOI18N if (toAdd != null && !add.startsWith(toAdd)) add += toAdd; if (params.isEmpty()) { super.substituteText(c, offset, len, add, assignToVar); - } else { + } else { final BaseDocument doc = (BaseDocument)c.getDocument(); String text = ""; //NOI18N final int semiPos = add.endsWith(";") ? findPositionForSemicolon(c) : -2; //NOI18N @@ -2719,7 +2716,7 @@ Completion.get().showToolTip(); } } - } + } public String toString() { StringBuilder sb = new StringBuilder(); @@ -2740,9 +2737,9 @@ return sb.toString(); } } - + static class AnnotationItem extends AnnotationTypeItem { - + private AnnotationItem(CompilationInfo info, TypeElement elem, DeclaredType type, int substitutionOffset, ReferencesCount referencesCount, boolean isDeprecated, boolean smartType, WhiteListQuery.WhiteList whiteList) { super(info, elem, type, 0, substitutionOffset, referencesCount, isDeprecated, false, false, smartType, false, whiteList); } @@ -2832,13 +2829,13 @@ }, NbBundle.getMessage(JavaCompletionItem.class, "JCI-import_resolve"), cancel, false); //NOI18N } } - + static class AttributeItem extends JavaCompletionItem { - + private static final String ATTRIBUTE = "org/netbeans/modules/java/editor/resources/attribute_16.png"; // NOI18N private static final String ATTRIBUTE_COLOR = ""; //NOI18N private static ImageIcon icon; - + private ElementHandle elementHandle; private boolean isDeprecated; private String simpleName; @@ -2856,15 +2853,15 @@ AnnotationValue value = elem.getDefaultValue(); this.defaultValue = value != null ? value.toString() : null; } - + public int getSortPriority() { return 100; } - + public CharSequence getSortText() { return simpleName; } - + public CharSequence getInsertPrefix() { return simpleName; } @@ -2875,9 +2872,9 @@ protected ImageIcon getIcon(){ if (icon == null) icon = ImageUtilities.loadImageIcon(ATTRIBUTE, false); - return icon; + return icon; } - + protected String getLeftHtmlText() { if (leftText == null) { StringBuilder sb = new StringBuilder(); @@ -2900,13 +2897,13 @@ } return leftText; } - + protected String getRightHtmlText() { if (rightText == null) rightText = escape(typeName); return rightText; } - + @Override protected void substituteText(JTextComponent c, int offset, int len, String toAdd, boolean assignToVar) { super.substituteText(c, offset, len, toAdd != null ? toAdd : "=", assignToVar); //NOI18N @@ -2914,7 +2911,7 @@ public String toString() { return simpleName; - } + } } static class AttributeValueItem extends WhiteListJavaCompletionItem { @@ -2955,7 +2952,7 @@ return delegate != null ? delegate.getInsertPrefix() : value; //NOI18N } - public CompletionTask createDocumentationTask() { + public CompletionTask createDocumentationTask() { return documentation == null ? null : new CompletionTask() { private CompletionDocumentation cd = new CompletionDocumentation() { @@ -2980,7 +2977,7 @@ return null; } }; - + @Override public void query(CompletionResultSet resultSet) { resultSet.setDocumentation(cd); @@ -3050,7 +3047,7 @@ } static class StaticMemberItem extends WhiteListJavaCompletionItem { - + private static final String FIELD_ST_PUBLIC = "org/netbeans/modules/editor/resources/completion/field_static_16.png"; //NOI18N private static final String FIELD_ST_PROTECTED = "org/netbeans/modules/editor/resources/completion/field_static_protected_16.png"; //NOI18N private static final String FIELD_ST_PACKAGE = "org/netbeans/modules/editor/resources/completion/field_static_package_private_16.png"; //NOI18N @@ -3063,7 +3060,7 @@ private static final String METHOD_COLOR = ""; //NOI18N private static final String PARAMETER_NAME_COLOR = ""; //NOI18N private static ImageIcon icon[][] = new ImageIcon[2][4]; - + private TypeMirrorHandle typeHandle; private boolean isDeprecated; private String typeName; @@ -3074,7 +3071,7 @@ private String sortText; private String leftText; private String rightText; - + private StaticMemberItem(CompilationInfo info, DeclaredType type, Element memberElem, TypeMirror memberType, int substitutionOffset, boolean isDeprecated, WhiteListQuery.WhiteList whiteList) { super(substitutionOffset, ElementHandle.create(memberElem), whiteList); type = (DeclaredType) info.getTypes().erasure(type); @@ -3094,11 +3091,11 @@ } } } - + public int getSortPriority() { return (params == null ? 700 : 750) - SMART_TYPE; } - + public CharSequence getSortText() { if (sortText == null) { if (params == null) { @@ -3121,7 +3118,7 @@ } return sortText; } - + public CharSequence getInsertPrefix() { return typeName + "." + memberName; //NOI18N } @@ -3167,13 +3164,13 @@ rightText = escape(memberTypeName); return rightText; } - + protected ImageIcon getBaseIcon(){ int level = getProtectionLevel(modifiers); boolean isField = getElementHandle().getKind().isField(); ImageIcon cachedIcon = icon[isField ? 0 : 1][level]; if (cachedIcon != null) - return cachedIcon; + return cachedIcon; String iconPath = null; if (isField) { @@ -3217,7 +3214,7 @@ return null; ImageIcon newIcon = ImageUtilities.loadImageIcon(iconPath, false); icon[isField ? 0 : 1][level] = newIcon; - return newIcon; + return newIcon; } @Override @@ -3394,14 +3391,14 @@ return sb.toString(); } } - + static class InitializeAllConstructorItem extends JavaCompletionItem { - + private static final String CONSTRUCTOR_PUBLIC = "org/netbeans/modules/java/editor/resources/new_constructor_16.png"; //NOI18N private static final String CONSTRUCTOR_COLOR = ""; //NOI18N private static final String PARAMETER_NAME_COLOR = ""; //NOI18N private static ImageIcon icon; - + private List> fieldHandles; private ElementHandle parentHandle; private ElementHandle superConstructorHandle; @@ -3409,7 +3406,7 @@ private List params; private String sortText; private String leftText; - + private InitializeAllConstructorItem(CompilationInfo info, Iterable fields, ExecutableElement superConstructor, TypeElement parent, int substitutionOffset) { super(substitutionOffset); this.fieldHandles = new ArrayList>(); @@ -3422,18 +3419,18 @@ if (superConstructor != null) { this.superConstructorHandle = ElementHandle.create(superConstructor); for (VariableElement ve : superConstructor.getParameters()) { - this.params.add(new ParamDesc(null, Utilities.getTypeName(info, ve.asType(), false).toString(), ve.getSimpleName().toString())); + this.params.add(new ParamDesc(null, Utilities.getTypeName(info, ve.asType(), false).toString(), ve.getSimpleName().toString())); } } else { this.superConstructorHandle = null; } this.simpleName = parent.getSimpleName().toString(); } - + public int getSortPriority() { return 400; } - + public CharSequence getSortText() { if (sortText == null) { StringBuilder sortParams = new StringBuilder(); @@ -3452,7 +3449,7 @@ } return sortText; } - + protected String getLeftHtmlText() { if (leftText == null) { StringBuilder lText = new StringBuilder(); @@ -3477,17 +3474,17 @@ } return leftText; } - + protected ImageIcon getIcon() { - if (icon == null) + if (icon == null) icon = ImageUtilities.loadImageIcon(CONSTRUCTOR_PUBLIC, false); - return icon; + return icon; } - + public CharSequence getInsertPrefix() { return simpleName; - } - + } + @Override protected void substituteText(final JTextComponent c, final int offset, final int len, String toAdd, final boolean assignToVar) { final BaseDocument doc = (BaseDocument)c.getDocument(); @@ -3523,12 +3520,12 @@ break; } ExecutableElement superConstructor = superConstructorHandle != null ? superConstructorHandle.resolve(copy) : null; - + TreeMaker make = copy.getTreeMaker(); ClassTree clazz = (ClassTree) tp.getLeaf(); GeneratorUtilities gu = GeneratorUtilities.get(copy); ClassTree decl = make.insertClassMember(clazz, idx, gu.createConstructor(parent, fieldElements, superConstructor)); //NOI18N - + copy.rewrite(clazz, decl); } } @@ -3558,7 +3555,7 @@ sb.append(GENERATE_TEXT); return sb.toString(); } - + public boolean instantSubstitution(JTextComponent component) { return false; //no instant substitution for create constructor item } @@ -3568,7 +3565,7 @@ private static final int PROTECTED_LEVEL = 2; private static final int PACKAGE_LEVEL = 1; private static final int PRIVATE_LEVEL = 0; - + private static int getProtectionLevel(Set modifiers) { if(modifiers.contains(Modifier.PUBLIC)) return PUBLIC_LEVEL; @@ -3578,7 +3575,7 @@ return PRIVATE_LEVEL; return PACKAGE_LEVEL; } - + private static String escape(String s) { if (s != null) { try { @@ -3587,7 +3584,7 @@ } return s; } - + private static int findPositionForSemicolon(JTextComponent c) { final int[] ret = new int[] {-2}; final int offset = c.getSelectionEnd(); @@ -3611,7 +3608,7 @@ while (t == null && tp != null) { switch(tp.getLeaf().getKind()) { case EXPRESSION_STATEMENT: - case IMPORT: + case IMPORT: t = tp.getLeaf(); break; case RETURN: @@ -3631,7 +3628,7 @@ if (ts.token().id() == JavaTokenId.SEMICOLON) { ret[0] = -1; } else if (ts.moveNext()) { - ret[0] = ts.token().id() == JavaTokenId.LINE_COMMENT || ts.token().id() == JavaTokenId.WHITESPACE && ts.token().text().toString().contains("\n") ? ts.offset() : offset; + ret[0] = ts.token().id() == JavaTokenId.LINE_COMMENT || ts.token().id() == JavaTokenId.WHITESPACE && ts.token().text().toString().contains("\n") ? ts.offset() : offset; } else { ret[0] = ts.offset() + ts.token().length(); } @@ -3650,7 +3647,7 @@ }, NbBundle.getMessage(JavaCompletionItem.class, "JCI-find_semicolon_pos"), cancel, false); //NOI18N return ret[0]; } - + private static TokenSequence findLastNonWhitespaceToken(CompilationInfo info, int startPos, int endPos) { TokenSequence ts = info.getTokenHierarchy().tokenSequence(JavaTokenId.language()); ts.move(endPos); @@ -3670,7 +3667,7 @@ } return null; } - + private static String getAssignToVarText(CompilationInfo info, TypeMirror type, String name) { name = adjustName(name); StringBuilder sb = new StringBuilder(); @@ -3686,32 +3683,32 @@ sb.append("\"} = "); //NOI18N return sb.toString(); } - + private static String adjustName(String name) { if (name == null) return null; - + String shortName = null; - + if (name.startsWith("get") && name.length() > 3) { //NOI18N shortName = name.substring(3); } - + if (name.startsWith("is") && name.length() > 2) { //NOI18N shortName = name.substring(2); } - + if (shortName != null) { return firstToLower(shortName); } - + if (SourceVersion.isKeyword(name)) { return "a" + Character.toUpperCase(name.charAt(0)) + name.substring(1); //NOI18N } else { return name; } } - + private static String firstToLower(String name) { if (name.length() == 0) return null; @@ -3732,19 +3729,19 @@ } result.append(last); - + if (SourceVersion.isKeyword(result)) { return "a" + name; //NOI18N } else { return result.toString(); } } - + static class ParamDesc { private String fullTypeName; private String typeName; private String name; - + public ParamDesc(String fullTypeName, String typeName, String name) { this.fullTypeName = fullTypeName; this.typeName = typeName; diff --git a/o.n.swing.plaf/apichanges.xml b/o.n.swing.plaf/apichanges.xml --- a/o.n.swing.plaf/apichanges.xml +++ b/o.n.swing.plaf/apichanges.xml @@ -49,6 +49,31 @@ Look And Feel Customization + + + New functions for getting foreground text color and color shifting + + + + + +

+ new functions:
+ + static String getHexString(int color)
+ static String getTextFgColorHTML()
+ static Color getTextFgColor()
+ static Color shiftColor(Color color)
+ static Color getForeground(AttributeSet a)
+
+

+
+ +
It is now possible to customize application-specific UIManager keys and values. diff --git a/o.n.swing.plaf/manifest.mf b/o.n.swing.plaf/manifest.mf --- a/o.n.swing.plaf/manifest.mf +++ b/o.n.swing.plaf/manifest.mf @@ -1,6 +1,6 @@ Manifest-Version: 1.0 OpenIDE-Module-Localizing-Bundle: org/netbeans/swing/plaf/Bundle.properties OpenIDE-Module: org.netbeans.swing.plaf -OpenIDE-Module-Specification-Version: 1.26 +OpenIDE-Module-Specification-Version: 1.27 AutoUpdate-Show-In-Client: false diff --git a/o.n.swing.plaf/src/org/netbeans/swing/plaf/LFCustoms.java b/o.n.swing.plaf/src/org/netbeans/swing/plaf/LFCustoms.java --- a/o.n.swing.plaf/src/org/netbeans/swing/plaf/LFCustoms.java +++ b/o.n.swing.plaf/src/org/netbeans/swing/plaf/LFCustoms.java @@ -44,6 +44,12 @@ package org.netbeans.swing.plaf; +import java.awt.Color; +import java.util.logging.Logger; +import javax.swing.UIManager; +import javax.swing.plaf.ColorUIResource; +import javax.swing.text.AttributeSet; + /** Look and feel customizations interface. * For various look and feels, there is a need to customize colors, * borders etc. to provide 'native-like' UI. @@ -78,6 +84,118 @@ private Object[] guaranteedKeysAndValues = null; protected static final String WORKPLACE_FILL = "nb_workplace_fill"; //NOI18N + /** convert color + * @return hexadecimal value + * @since 1.27 + */ + public static String getHexString(int color) { + String result = Integer.toHexString(color).toUpperCase(); + if (result.length() == 1) { + return '0'+result; + } + return result; + } + + /** cached window text foreground color as html code */ + private static String textFgColorHTML = ""; + + /** @return window text foreground color as html code + * @since 1.27 + */ + public static String getTextFgColorHTML() { + synchronized(LFCustoms.class) { + if (textFgColorHTML.isEmpty()) { + Object o = UIManager.getLookAndFeel().getDefaults().get("windowText"); + if (o instanceof ColorUIResource) { + ColorUIResource resource = (ColorUIResource)o; + textFgColorHTML = ""; + } else { + textFgColorHTML = ""; + Logger.getLogger(LFCustoms.class.getName()).warning("BUG: getTextFgColorHTML: color isn't available"); + } + } + return textFgColorHTML; + } + } + + /** cached window text foreground color */ + private static Color textFgColor = null; + + /** @return window text foreground color + * @since 1.27 + */ + public static Color getTextFgColor() { + synchronized(LFCustoms.class) { + if (textFgColor == null) { + Object o = UIManager.getLookAndFeel().getDefaults().get("windowText"); + if (o instanceof ColorUIResource) { + textFgColor = (Color) o; + } else { + textFgColor = Color.BLACK; + Logger.getLogger(LFCustoms.class.getName()).warning("BUG: getTextFgColor: color isn't available"); + } + } + return textFgColor; + } + } + + /** shift color value + * @since 1.27 + */ + private static final int shiftValue = 64; + + /** convert color component + * @return brighter color component + * @since 1.27 + */ + private static int brighter (int color) { + int result = color + shiftValue; + if (result > 255) { + return 255; + } else { + return result; + } + } + + /** convert color component + * @return darker color component + * @since 1.27 + */ + private static int darker(int color) { + int result = color - shiftValue; + if (result < 0) { + return 0; + } else { + return result; + } + } + + /** convert color to brighter one if window foreground text color is bright color + * or convert color to darker one if window foreground text color is dark color + * @return converted color + * @since 1.27 + */ + public static Color shiftColor(Color color) { + Color textFgColor = getTextFgColor(); + if ((textFgColor.getRed() > 127) || (textFgColor.getGreen() > 127) || (textFgColor.getBlue() > 127)) { + return new Color(brighter(color.getRed()), brighter(color.getGreen()), brighter(color.getBlue())); + } + return new Color(darker(color.getRed()), darker(color.getGreen()), darker(color.getBlue())); + } + + /** get foreground text color from AttributeSet + * or get window foreground text color if AttributeSet doesn't define foreground text color + * @return foreground text color + * @since 1.27 + */ + public static Color getForeground(AttributeSet a) { + Color fg = (Color) a.getAttribute(javax.swing.text.StyleConstants.Foreground); + if (fg == null) { + fg = getTextFgColor(); + } + return fg; + } + //TODO: A nice idea would be to replace these classes with XML files - minor rewrite of NbTheme to do it /** Fetch and cache keys and values */ @@ -108,7 +226,7 @@ } /** - * Get all keys this LFCustoms installs in UIManager. This is used to + * Get all keys this LFCustoms installs in UIManager. This is used to * delete unneeded elements from UIManager if the look and feel is changed * on the fly (for example, the user switches Windows from Classic to XP * look). @@ -151,7 +269,7 @@ } return result; } - + /** * LFCustoms implementations which use UIBootstrapValue.Lazy should return * any keys that it will install here, so they can be merged into the list @@ -223,7 +341,7 @@ * custom font size is specified, the core will put this into UIDefaults. * We then read it out if present and use it to set up a custom font size. */ protected static final String CUSTOM_FONT_SIZE = "customFontSize"; //NOI18N - + //Default font size - some classes use this to handle creating appropriate //custom fonts based on this value protected static final String DEFAULT_FONT_SIZE = "nbDefaultFontSize"; //NOI18N @@ -326,9 +444,9 @@ public static final String SUBFONT = "subFont"; //NOI18N public static final String LISTFONT = "List.font"; //NOI18N public static final String TREEFONT = "Tree.font"; //NOI18N - public static final String PANELFONT = "Panel.font"; //NOI18N - public static final String SPINNERFONT = "Spinner.font"; //NOI18N - + public static final String PANELFONT = "Panel.font"; //NOI18N + public static final String SPINNERFONT = "Spinner.font"; //NOI18N + // keys used by the progressbar api module. public static final String PROGRESS_CANCEL_BUTTON_ICON = "nb.progress.cancel.icon"; public static final String PROGRESS_CANCEL_BUTTON_ROLLOVER_ICON = "nb.progress.cancel.icon.mouseover"; diff --git a/refactoring.java/nbproject/project.xml b/refactoring.java/nbproject/project.xml --- a/refactoring.java/nbproject/project.xml +++ b/refactoring.java/nbproject/project.xml @@ -214,6 +214,14 @@
+ org.netbeans.swing.plaf + + + + 1.27 + + + org.openide.actions diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/UIUtilities.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/UIUtilities.java --- a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/UIUtilities.java +++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/UIUtilities.java @@ -66,6 +66,7 @@ import org.netbeans.api.lexer.TokenHierarchy; import org.netbeans.api.lexer.TokenSequence; import org.netbeans.modules.refactoring.java.api.MemberInfo; +import org.netbeans.swing.plaf.LFCustoms; import org.openide.util.Lookup; import org.openide.xml.XMLUtil; @@ -279,7 +280,7 @@ buf.insert(0, ""); // NOI18N buf.append(""); // NOI18N } - buf.insert(0, ""); //NOI18N + buf.insert(0, ""); //NOI18N buf.append(""); //NOI18N return buf.toString(); } @@ -300,11 +301,11 @@ temp = temp.replace(">", ">"); // NOI18N return temp; } - + static String format(Element element) { return format(element, false, false); } - + static String format(Element element, boolean forSignature, boolean FQNs) { StringBuilder stringBuilder = new StringBuilder(); format(element, stringBuilder, forSignature, FQNs); @@ -342,7 +343,7 @@ } } } - + if (forSignature) { switch (element.getKind()) { case CLASS: @@ -359,7 +360,7 @@ break; } } - + TypeElement typeElement = (TypeElement) element; stringBuilder.append(FQNs ? typeElement.getQualifiedName().toString() @@ -402,7 +403,7 @@ if (forSignature) { stringBuilder.append(toString(modifiers)); - + if (modifiers.size() > 0) { if (stringBuilder.length() > 0) { stringBuilder.append(" "); @@ -445,13 +446,13 @@ stringBuilder.append("\""); } else if (annotationValueValue instanceof Character) { stringBuilder.append("\'"); - } + } stringBuilder.append(String.valueOf(annotationValueValue)); if (annotationValueValue instanceof String) { stringBuilder.append("\""); } else if (annotationValueValue instanceof Character) { stringBuilder.append("\'"); - } + } } } } else { @@ -520,20 +521,20 @@ stringBuilder.append("\""); } else if (fieldValue instanceof Character) { stringBuilder.append("\'"); - } + } stringBuilder.append(String.valueOf(fieldValue)); if (fieldValue instanceof String) { stringBuilder.append("\""); } else if (fieldValue instanceof Character) { stringBuilder.append("\'"); - } + } } } else { stringBuilder.append(":"); formatTypeMirror(fieldElement.asType(), stringBuilder, FQNs); } - + break; case ENUM_CONSTANT: @@ -550,7 +551,7 @@ break; } } - + static void formatTypeMirror(TypeMirror typeMirror, StringBuilder stringBuilder, boolean FQNs) { if (typeMirror == null) { @@ -640,7 +641,7 @@ return; } - boolean first = true; + boolean first = true; if (typeParameters.size() > 0) { stringBuilder.append("<"); first = true; @@ -805,11 +806,11 @@ return modifiers; } - + static String getClassName(String className) { return getClassName(className, false); } - + static String getClassName(String className, boolean FQNs) { // Handle generic type names i.e. strip off parameters int firstLessThan = className.indexOf('<'); @@ -845,7 +846,7 @@ return className; } - + // Tree movement static void firstRow(JTree tree) { int rowCount = tree.getRowCount(); @@ -854,7 +855,7 @@ scrollTreeToSelectedRow(tree); } } - + static void previousRow(JTree tree) { int rowCount = tree.getRowCount(); if (rowCount > 0) { @@ -871,7 +872,7 @@ scrollTreeToSelectedRow(tree); } } - + static void nextRow(JTree tree) { int rowCount = tree.getRowCount(); if (rowCount > 0) { @@ -886,7 +887,7 @@ scrollTreeToSelectedRow(tree); } } - + static void lastRow(JTree tree) { int rowCount = tree.getRowCount(); if (rowCount > 0) { @@ -894,7 +895,7 @@ scrollTreeToSelectedRow(tree); } } - + static void scrollTreeToSelectedRow(final JTree tree) { final int selectedRow = tree.getLeadSelectionRow(); if (selectedRow >=0) { @@ -907,7 +908,7 @@ ); } } - + static String escape(String s) { if (s != null) { try { @@ -917,7 +918,7 @@ } return null; } - + private static final String TYPE_COLOR = "#707070"; private static final String INHERITED_COLOR = "#7D694A"; @@ -981,7 +982,7 @@ } sb.append(print(e.getReturnType(), html)); if (html) { - sb.append(""); // NOI18N + sb.append(""); // NOI18N } } } @@ -1168,7 +1169,7 @@ sb.append(" :: "); // NOI18N if (scName != null) { if (html) { - sb.append(""); // NOI18N + sb.append(""); // NOI18N } sb.append(scName); if (html) { @@ -1182,7 +1183,7 @@ for (Iterator it = ifaces.iterator(); it.hasNext();) { TypeMirror typeMirror = it.next(); if (html) { - sb.append(""); // NOI18N + sb.append(""); // NOI18N } sb.append(print(typeMirror, html)); if (html) {