This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 134281
Collapse All | Expand All

(-)a/cnd.completion/nbproject/project.xml (+8 lines)
Lines 173-178 Link Here
173
                    </run-dependency>
173
                    </run-dependency>
174
                </dependency>
174
                </dependency>
175
                <dependency>
175
                <dependency>
176
                    <code-name-base>org.netbeans.swing.plaf</code-name-base>
177
                    <build-prerequisite/>
178
                    <compile-dependency/>
179
                    <run-dependency>
180
                        <specification-version>1.27</specification-version>
181
                    </run-dependency>
182
                </dependency>
183
                <dependency>
176
                    <code-name-base>org.openide.awt</code-name-base>
184
                    <code-name-base>org.openide.awt</code-name-base>
177
                    <build-prerequisite/>
185
                    <build-prerequisite/>
178
                    <compile-dependency/>
186
                    <compile-dependency/>
(-)a/cnd.completion/src/org/netbeans/modules/cnd/completion/cplusplus/ext/CsmResultItem.java (-17 / +16 lines)
Lines 103-109 Link Here
103
import org.netbeans.spi.editor.completion.CompletionItem;
103
import org.netbeans.spi.editor.completion.CompletionItem;
104
import org.netbeans.spi.editor.completion.CompletionTask;
104
import org.netbeans.spi.editor.completion.CompletionTask;
105
import org.openide.util.Lookup;
105
import org.openide.util.Lookup;
106
106
import org.netbeans.swing.plaf.LFCustoms;
107
/**
107
/**
108
 *
108
 *
109
 * @author  Vladimir Voskresensky
109
 * @author  Vladimir Voskresensky
Lines 116-129 Link Here
116
        DOT_TO_ARROW,
116
        DOT_TO_ARROW,
117
        ARROW_TO_DOT,
117
        ARROW_TO_DOT,
118
    }
118
    }
119
    
119
120
    private static boolean enableInstantSubstitution = true;
120
    private static boolean enableInstantSubstitution = true;
121
    protected int selectionStartOffset = -1;
121
    protected int selectionStartOffset = -1;
122
    protected int selectionEndOffset = -1;
122
    protected int selectionEndOffset = -1;
123
    protected int substituteOffset = -1;
123
    protected int substituteOffset = -1;
124
    CsmObject associatedObject;
124
    CsmObject associatedObject;
125
    private static final Color KEYWORD_COLOR = Color.gray;
125
    private static final Color KEYWORD_COLOR = Color.lightGray;
126
    private static final Color TYPE_COLOR = Color.black;
127
    private int priority;
126
    private int priority;
128
    private SubstitutionHint hint;
127
    private SubstitutionHint hint;
129
128
Lines 141-153 Link Here
141
    void setHint(SubstitutionHint hint) {
140
    void setHint(SubstitutionHint hint) {
142
        this.hint = hint;
141
        this.hint = hint;
143
    }
142
    }
144
    
143
145
    protected SubstitutionHint getHint() {
144
    protected SubstitutionHint getHint() {
146
        return this.hint;
145
        return this.hint;
147
    }
146
    }
148
    
147
149
    protected static Color getTypeColor(CsmType type) {
148
    protected static Color getTypeColor(CsmType type) {
150
        return type.isBuiltInBased(false) ? KEYWORD_COLOR : TYPE_COLOR;
149
        return type.isBuiltInBased(false) ? LFCustoms.shiftColor(KEYWORD_COLOR) : LFCustoms.getTextFgColor();
151
    }
150
    }
152
151
153
    public void setSubstituteOffset(int substituteOffset) {
152
    public void setSubstituteOffset(int substituteOffset) {
Lines 271-277 Link Here
271
        Component comp = getPaintComponent(false);
270
        Component comp = getPaintComponent(false);
272
        return comp != null ? comp.toString() : ""; //NOI18N
271
        return comp != null ? comp.toString() : ""; //NOI18N
273
    }
272
    }
274
    
273
275
    protected int convertCsmModifiers(CsmObject obj) {
274
    protected int convertCsmModifiers(CsmObject obj) {
276
        return CsmUtilities.getModifiers(obj);
275
        return CsmUtilities.getModifiers(obj);
277
    }
276
    }
Lines 981-991 Link Here
981
                if (type == null) {
980
                if (type == null) {
982
                    // only var args parameters could have null types
981
                    // only var args parameters could have null types
983
                    assert (((CsmParameter) prm).isVarArgs()) : " non var arg " + prm + " of class " + prm.getClass().getName();
982
                    assert (((CsmParameter) prm).isVarArgs()) : " non var arg " + prm + " of class " + prm.getClass().getName();
984
                    params.add(new ParamStr("", "", ((CsmParameter) prm).getName().toString(), prm.getText().toString(), true, KEYWORD_COLOR)); //NOI18N
983
                    params.add(new ParamStr("", "", ((CsmParameter) prm).getName().toString(), prm.getText().toString(), true, LFCustoms.shiftColor(KEYWORD_COLOR))); //NOI18N
985
                    varArgIndex = i;
984
                    varArgIndex = i;
986
                } else {
985
                } else {
987
                    String typeName = getTypeName(type, instantiateTypes);
986
                    String typeName = getTypeName(type, instantiateTypes);
988
                    params.add(new ParamStr(typeName, typeName, ((CsmParameter) prm).getName().toString(), prm.getText().toString(), false, TYPE_COLOR /*getTypeColor(type.getClassifier())*/));
987
                    params.add(new ParamStr(typeName, typeName, ((CsmParameter) prm).getName().toString(), prm.getText().toString(), false, LFCustoms.getTextFgColor() /*getTypeColor(type.getClassifier())*/));
989
                }
988
                }
990
                i++;
989
                i++;
991
            }
990
            }
Lines 1048-1054 Link Here
1048
            List<String> ret = new ArrayList<String>();
1047
            List<String> ret = new ArrayList<String>();
1049
            for (Iterator<ParamStr> it = getParams().iterator(); it.hasNext();) {
1048
            for (Iterator<ParamStr> it = getParams().iterator(); it.hasNext();) {
1050
                StringBuilder sb = new StringBuilder();
1049
                StringBuilder sb = new StringBuilder();
1051
                ParamStr ps = it.next();                
1050
                ParamStr ps = it.next();
1052
                if (ps.isVarArg()) {
1051
                if (ps.isVarArg()) {
1053
                    sb.append(ps.getSimpleTypeName());
1052
                    sb.append(ps.getSimpleTypeName());
1054
                    sb.append("..."); // NOI18N
1053
                    sb.append("..."); // NOI18N
Lines 1765-1783 Link Here
1765
//            this.prm = prm;
1764
//            this.prm = prm;
1766
//            this.typeColor = typeColor;
1765
//            this.typeColor = typeColor;
1767
//        }
1766
//        }
1768
//        
1767
//
1769
//        public String getTypeName() {
1768
//        public String getTypeName() {
1770
//            return type;
1769
//            return type;
1771
//        }
1770
//        }
1772
//        
1771
//
1773
//        public String getSimpleTypeName() {
1772
//        public String getSimpleTypeName() {
1774
//            return simpleType;
1773
//            return simpleType;
1775
//        }
1774
//        }
1776
//        
1775
//
1777
//        public String getName() {
1776
//        public String getName() {
1778
//            return prm;
1777
//            return prm;
1779
//        }
1778
//        }
1780
//        
1779
//
1781
//        public Color getTypeColor() {
1780
//        public Color getTypeColor() {
1782
//            return typeColor;
1781
//            return typeColor;
1783
//        }
1782
//        }
Lines 1789-1799 Link Here
1789
//            this.name = name;
1788
//            this.name = name;
1790
//            this.typeColor = typeColor;
1789
//            this.typeColor = typeColor;
1791
//        }
1790
//        }
1792
//        
1791
//
1793
//        public String getName() {
1792
//        public String getName() {
1794
//            return name;
1793
//            return name;
1795
//        }
1794
//        }
1796
//        
1795
//
1797
//        public Color getTypeColor() {
1796
//        public Color getTypeColor() {
1798
//            return typeColor;
1797
//            return typeColor;
1799
//        }
1798
//        }
(-)a/cnd.modelutil/nbproject/project.xml (+8 lines)
Lines 86-91 Link Here
86
                    </run-dependency>
86
                    </run-dependency>
87
                </dependency>
87
                </dependency>
88
                <dependency>
88
                <dependency>
89
                    <code-name-base>org.netbeans.swing.plaf</code-name-base>
90
                    <build-prerequisite/>
91
                    <compile-dependency/>
92
                    <run-dependency>
93
                        <specification-version>1.27</specification-version>
94
                    </run-dependency>
95
                </dependency>
96
                <dependency>
89
                    <code-name-base>org.openide.awt</code-name-base>
97
                    <code-name-base>org.openide.awt</code-name-base>
90
                    <build-prerequisite/>
98
                    <build-prerequisite/>
91
                    <compile-dependency/>
99
                    <compile-dependency/>
(-)a/cnd.modelutil/src/org/netbeans/modules/cnd/modelutil/CsmDisplayUtilities.java (-9 / +10 lines)
Lines 89-94 Link Here
89
import org.openide.text.CloneableEditorSupport;
89
import org.openide.text.CloneableEditorSupport;
90
import org.openide.util.Lookup;
90
import org.openide.util.Lookup;
91
import org.openide.util.NbBundle;
91
import org.openide.util.NbBundle;
92
import org.netbeans.swing.plaf.LFCustoms;
92
93
93
/**
94
/**
94
 *
95
 *
Lines 138-144 Link Here
138
        }
139
        }
139
        return displayText;
140
        return displayText;
140
    }
141
    }
141
    
142
142
    public static String getLineHtml(int startLine, int endLine, final int stToken, final int endToken, BaseDocument doc) throws BadLocationException {
143
    public static String getLineHtml(int startLine, int endLine, final int stToken, final int endToken, BaseDocument doc) throws BadLocationException {
143
        int startBold = stToken - startLine;
144
        int startBold = stToken - startLine;
144
        int endBold = endToken - startLine;
145
        int endBold = endToken - startLine;
Lines 327-342 Link Here
327
328
328
    private static String getString(String key, CharSequence value) {
329
    private static String getString(String key, CharSequence value) {
329
        return NbBundle.getMessage(CsmDisplayUtilities.class, key, value);
330
        return NbBundle.getMessage(CsmDisplayUtilities.class, key, value);
330
    }    
331
    }
331
    
332
332
    private static String getString(String key, CharSequence value1, CharSequence value2) {
333
    private static String getString(String key, CharSequence value1, CharSequence value2) {
333
        return NbBundle.getMessage(CsmDisplayUtilities.class, key, value1, value2);
334
        return NbBundle.getMessage(CsmDisplayUtilities.class, key, value1, value2);
334
    } 
335
    }
335
    
336
336
    private static String getString(String key, CharSequence value1, CharSequence value2, CharSequence value3, CharSequence value4) {
337
    private static String getString(String key, CharSequence value1, CharSequence value2, CharSequence value3, CharSequence value4) {
337
        return NbBundle.getMessage(CsmDisplayUtilities.class, key, new Object[] {value1, value2, value3, value4});
338
        return NbBundle.getMessage(CsmDisplayUtilities.class, key, new Object[] {value1, value2, value3, value4});
338
    } 
339
    }
339
    
340
340
    private final static boolean SKIP_COLORING = Boolean.getBoolean("cnd.test.skip.coloring");// NOI18N
341
    private final static boolean SKIP_COLORING = Boolean.getBoolean("cnd.test.skip.coloring");// NOI18N
341
342
342
    private static void appendHtml(StringBuilder buf, TokenSequence<?> ts) {
343
    private static void appendHtml(StringBuilder buf, TokenSequence<?> ts) {
Lines 405-411 Link Here
405
            buf.insert(0, "<s>"); // NOI18N
406
            buf.insert(0, "<s>"); // NOI18N
406
            buf.append("</s>"); // NOI18N
407
            buf.append("</s>"); // NOI18N
407
        }
408
        }
408
        buf.insert(0, "<font color=" + getHTMLColor(StyleConstants.getForeground(set)) + ">"); //NOI18N
409
        buf.insert(0, "<font color=" + getHTMLColor(LFCustoms.getForeground(set)) + ">"); //NOI18N
409
        buf.append("</font>"); //NOI18N
410
        buf.append("</font>"); //NOI18N
410
        return buf.toString();
411
        return buf.toString();
411
    }
412
    }
Lines 420-426 Link Here
420
        String html_color = "#" + colorR + colorG + colorB; //NOI18N
421
        String html_color = "#" + colorR + colorG + colorB; //NOI18N
421
        return html_color;
422
        return html_color;
422
    }
423
    }
423
    
424
424
    private static String trimStart(String s) {
425
    private static String trimStart(String s) {
425
        for (int x = 0; x < s.length(); x++) {
426
        for (int x = 0; x < s.length(); x++) {
426
            if (Character.isWhitespace(s.charAt(x))) {
427
            if (Character.isWhitespace(s.charAt(x))) {
(-)a/cnd.modelutil/src/org/netbeans/modules/cnd/modelutil/CsmPaintComponent.java (-243 / +243 lines)
Lines 63-69 Link Here
63
import javax.swing.BorderFactory;
63
import javax.swing.BorderFactory;
64
import javax.swing.Icon;
64
import javax.swing.Icon;
65
import javax.swing.JPanel;
65
import javax.swing.JPanel;
66
66
import org.netbeans.swing.plaf.LFCustoms;
67
67
68
/**
68
/**
69
 *
69
 *
Lines 72-184 Link Here
72
 */
72
 */
73
73
74
public abstract class CsmPaintComponent extends JPanel {
74
public abstract class CsmPaintComponent extends JPanel {
75
            
75
76
    DrawState drawState = new DrawState();
76
    DrawState drawState = new DrawState();
77
    
77
78
    protected Font drawFont;
78
    protected Font drawFont;
79
           
79
80
    private static final int ICON_WIDTH = 16;
80
    private static final int ICON_WIDTH = 16;
81
    private static final int ICON_TEXT_GAP = 5;
81
    private static final int ICON_TEXT_GAP = 5;
82
            
82
83
    private int fontHeight;
83
    private int fontHeight;
84
    
84
85
    private int ascent;
85
    private int ascent;
86
    
86
87
    private Map widths;
87
    private Map widths;
88
    
88
89
    private FontMetrics fontMetrics;
89
    private FontMetrics fontMetrics;
90
    
90
91
    protected boolean isSelected;
91
    protected boolean isSelected;
92
    
92
93
   // private String text;
93
   // private String text;
94
    
94
95
    private ArrayList<PostfixString> postfixes;
95
    private ArrayList<PostfixString> postfixes;
96
    
96
97
    private static final String THROWS = " throws "; // NOI18N
97
    private static final String THROWS = " throws "; // NOI18N
98
    
98
99
    
99
100
    private static final String[] frequentWords = new String[] {
100
    private static final String[] frequentWords = new String[] {
101
        "", " ", "[]", "(", ")", ", ", "String", THROWS // NOI18N
101
        "", " ", "[]", "(", ")", ", ", "String", THROWS // NOI18N
102
    };
102
    };
103
    
103
104
    private static final Color KEYWORD_COLOR = Color.darkGray;
104
    private final static Color KEYWORD_COLOR = Color.gray;
105
    private static final Color TYPE_COLOR = Color.black;
105
    private final static Color POSTFIX_COLOR = Color.lightGray;
106
    private static final Color POSTFIX_COLOR = Color.gray;
106
107
    
108
    private Icon icon;
107
    private Icon icon;
109
    
108
110
    protected int modifiers = 0;
109
    protected int modifiers = 0;
111
    
110
112
    private static Border BORDER = BorderFactory.createEmptyBorder(0, 3, 0, 3);
111
    private static Border BORDER = BorderFactory.createEmptyBorder(0, 3, 0, 3);
113
    private static LayoutManager layout = new FlowLayout();
112
    private static LayoutManager layout = new FlowLayout();
114
    public CsmPaintComponent(){
113
    public CsmPaintComponent(){
115
        super(layout, true);        
114
        super(layout, true);
116
        setBorder(BORDER);
115
        setBorder(BORDER);
117
        postfixes = new ArrayList<PostfixString>();        
116
        postfixes = new ArrayList<PostfixString>();
118
    }
117
    }
119
    
118
120
    public void setSelected(boolean isSelected){
119
    public void setSelected(boolean isSelected){
121
        this.isSelected = isSelected;
120
        this.isSelected = isSelected;
122
    }
121
    }
123
    
122
124
    protected boolean isSelected(){
123
    protected boolean isSelected(){
125
        return isSelected;
124
        return isSelected;
126
    }
125
    }
127
    
126
128
    @Override
127
    @Override
129
    public void paintComponent(Graphics g) {
128
    public void paintComponent(Graphics g) {
130
        // clear background
129
        // clear background
130
        Color postfixColor = LFCustoms.shiftColor(POSTFIX_COLOR);
131
        g.setColor(getBackground());
131
        g.setColor(getBackground());
132
        java.awt.Rectangle r = g.getClipBounds();
132
        java.awt.Rectangle r = g.getClipBounds();
133
        g.fillRect(r.x, r.y, r.width, r.height);
133
        g.fillRect(r.x, r.y, r.width, r.height);
134
        draw(g);
134
        draw(g);
135
        
135
136
        if(!postfixes.isEmpty()) {
136
        if(!postfixes.isEmpty()) {
137
            drawString(g, " (", POSTFIX_COLOR); // NOI18N
137
            drawString(g, " (", postfixColor); // NOI18N
138
            Iterator iter = postfixes.iterator();
138
            Iterator iter = postfixes.iterator();
139
            while(iter.hasNext()) {
139
            while(iter.hasNext()) {
140
                ((PostfixString) iter.next()).Draw(g);
140
                ((PostfixString) iter.next()).Draw(g);
141
                if(iter.hasNext()) {
141
                if(iter.hasNext()) {
142
                    drawString(g, ",  ", POSTFIX_COLOR); // NOI18N
142
                    drawString(g, ",  ", postfixColor); // NOI18N
143
                }
143
                }
144
            } 
144
            }
145
            drawString(g, ")", POSTFIX_COLOR); // NOI18N
145
            drawString(g, ")", postfixColor); // NOI18N
146
        }        
146
        }
147
    }
147
    }
148
    
148
149
    public void appendPostfix(String text, Color c, int font) {
149
    public void appendPostfix(String text, Color c, int font) {
150
        postfixes.add(new PostfixString(text, c, font));
150
        postfixes.add(new PostfixString(text, c, font));
151
    }
151
    }
152
    
152
153
    public void removePostfixes() {
153
    public void removePostfixes() {
154
        postfixes.clear();
154
        postfixes.clear();
155
    }
155
    }
156
    
156
157
    public boolean hasPostfixes() {
157
    public boolean hasPostfixes() {
158
        return !postfixes.isEmpty();
158
        return !postfixes.isEmpty();
159
    }
159
    }
160
    
160
161
    /** IMPORTANT:
161
    /** IMPORTANT:
162
     * when implemented => have to update toString!
162
     * when implemented => have to update toString!
163
     */
163
     */
164
    abstract protected void draw(Graphics g);
164
    abstract protected void draw(Graphics g);
165
    
165
166
    /**
166
    /**
167
     * returns string representation of paint item
167
     * returns string representation of paint item
168
     * IMPORTANT: have to be in sync with draw() method
168
     * IMPORTANT: have to be in sync with draw() method
169
     */   
169
     */
170
    @Override
170
    @Override
171
    abstract public String toString();
171
    abstract public String toString();
172
    
172
173
    protected void setIcon(Icon icon){
173
    protected void setIcon(Icon icon){
174
        this.icon = icon;
174
        this.icon = icon;
175
    }
175
    }
176
    
176
177
    protected Icon getIcon(){
177
    protected Icon getIcon(){
178
        return icon;
178
        return icon;
179
    }
179
    }
180
    
180
181
    
181
182
    /** Draw the icon if it is valid for the given type.
182
    /** Draw the icon if it is valid for the given type.
183
     * Here the initial drawing assignments are also done.
183
     * Here the initial drawing assignments are also done.
184
     */
184
     */
Lines 191-197 Link Here
191
            drawState.drawX = 0;
191
            drawState.drawX = 0;
192
            drawState.drawY = 0;
192
            drawState.drawY = 0;
193
        }
193
        }
194
        
194
195
        if (icon != null) {
195
        if (icon != null) {
196
            if (g != null) {
196
            if (g != null) {
197
                icon.paintIcon(this, g, drawState.drawX, drawState.drawY);
197
                icon.paintIcon(this, g, drawState.drawX, drawState.drawY);
Lines 207-217 Link Here
207
        drawState.drawHeight += drawState.drawY;
207
        drawState.drawHeight += drawState.drawY;
208
        drawState.drawY += ascent;
208
        drawState.drawY += ascent;
209
    }
209
    }
210
    
210
211
    protected void drawString(Graphics g, CharSequence s){
211
    protected void drawString(Graphics g, CharSequence s){
212
        drawString(g, s, false);
212
        drawString(g, s, false);
213
    }
213
    }
214
    
214
215
    /** Draw string using the foreground color */
215
    /** Draw string using the foreground color */
216
    protected void drawString(Graphics g, CharSequence s, boolean strike) {
216
    protected void drawString(Graphics g, CharSequence s, boolean strike) {
217
        if (g != null) {
217
        if (g != null) {
Lines 219-226 Link Here
219
        }
219
        }
220
        drawStringToGraphics(g, s, null, strike);
220
        drawStringToGraphics(g, s, null, strike);
221
    }
221
    }
222
    
222
223
    
223
224
    /** Draw string with given color which is first possibly modified
224
    /** Draw string with given color which is first possibly modified
225
     * by calling getColor() method to care about selection etc.
225
     * by calling getColor() method to care about selection etc.
226
     */
226
     */
Lines 230-236 Link Here
230
        }
230
        }
231
        drawStringToGraphics(g, s);
231
        drawStringToGraphics(g, s);
232
    }
232
    }
233
    
233
234
    protected void drawString(Graphics g, CharSequence s, Color c, Font font, boolean strike) {
234
    protected void drawString(Graphics g, CharSequence s, Color c, Font font, boolean strike) {
235
        if (g != null) {
235
        if (g != null) {
236
            g.setColor(getColor(s, c));
236
            g.setColor(getColor(s, c));
Lines 240-248 Link Here
240
        if (g != null) {
240
        if (g != null) {
241
            g.setFont(drawFont);
241
            g.setFont(drawFont);
242
        }
242
        }
243
        
243
244
    }
244
    }
245
    
245
246
    protected void drawTypeName(Graphics g, String s, Color c) {
246
    protected void drawTypeName(Graphics g, String s, Color c) {
247
        if (g == null) {
247
        if (g == null) {
248
            drawString(g, "   "); // NOI18N
248
            drawString(g, "   "); // NOI18N
Lines 261-271 Link Here
261
            drawString(g, s, c);
261
            drawString(g, s, c);
262
        }
262
        }
263
    }
263
    }
264
    
264
265
    protected void drawStringToGraphics(Graphics g, CharSequence s) {
265
    protected void drawStringToGraphics(Graphics g, CharSequence s) {
266
        drawStringToGraphics(g, s, null, false);
266
        drawStringToGraphics(g, s, null, false);
267
    }
267
    }
268
    
268
269
    protected void drawStringToGraphics(Graphics g, CharSequence s, Font font, boolean strike) {
269
    protected void drawStringToGraphics(Graphics g, CharSequence s, Font font, boolean strike) {
270
        String str = s != null ? s.toString() : "";
270
        String str = s != null ? s.toString() : "";
271
        if (g != null) {
271
        if (g != null) {
Lines 281-287 Link Here
281
        }
281
        }
282
        drawState.drawX += getWidth(str, font);
282
        drawState.drawX += getWidth(str, font);
283
    }
283
    }
284
    
284
285
    protected int getWidth(String s) {
285
    protected int getWidth(String s) {
286
        Integer i = (Integer)widths.get(s);
286
        Integer i = (Integer)widths.get(s);
287
        if (i != null) {
287
        if (i != null) {
Lines 290-316 Link Here
290
            return fontMetrics.stringWidth(s);
290
            return fontMetrics.stringWidth(s);
291
        }
291
        }
292
    }
292
    }
293
    
293
294
    protected int getWidth(String s, Font font) {
294
    protected int getWidth(String s, Font font) {
295
        if (font == null) {
295
        if (font == null) {
296
            return getWidth(s);
296
            return getWidth(s);
297
        }
297
        }
298
        return getFontMetrics(font).stringWidth(s);
298
        return getFontMetrics(font).stringWidth(s);
299
    }
299
    }
300
    
300
301
    protected Color getColor(CharSequence s, Color defaultColor) {
301
    protected Color getColor(CharSequence s, Color defaultColor) {
302
        return isSelected ? getForeground()
302
        return isSelected ? getForeground()
303
        : defaultColor;
303
        : defaultColor;
304
    }
304
    }
305
    
305
306
    private void storeWidth(String s) {
306
    private void storeWidth(String s) {
307
        fontMetrics.stringWidth(s);
307
        fontMetrics.stringWidth(s);
308
    }
308
    }
309
    
309
310
    @Override
310
    @Override
311
    public void setFont(Font font) {
311
    public void setFont(Font font) {
312
        super.setFont(font);
312
        super.setFont(font);
313
        
313
314
        fontMetrics = this.getFontMetrics(font);
314
        fontMetrics = this.getFontMetrics(font);
315
        fontHeight = fontMetrics.getHeight();
315
        fontHeight = fontMetrics.getHeight();
316
        ascent = fontMetrics.getAscent();
316
        ascent = fontMetrics.getAscent();
Lines 324-334 Link Here
324
        }
324
        }
325
        drawFont = font;
325
        drawFont = font;
326
    }
326
    }
327
    
327
328
    protected Font getDrawFont(){
328
    protected Font getDrawFont(){
329
        return drawFont;
329
        return drawFont;
330
    }
330
    }
331
    
331
332
    @Override
332
    @Override
333
    public Dimension getPreferredSize() {
333
    public Dimension getPreferredSize() {
334
        draw(null);
334
        draw(null);
Lines 341-347 Link Here
341
        }
341
        }
342
        return new Dimension(drawState.drawX, drawState.drawHeight);
342
        return new Dimension(drawState.drawX, drawState.drawHeight);
343
    }
343
    }
344
    
344
345
    public void setModifiers(int modifiers){
345
    public void setModifiers(int modifiers){
346
        this.modifiers = modifiers;
346
        this.modifiers = modifiers;
347
    }
347
    }
Lines 349-416 Link Here
349
    public int getModifiers(){
349
    public int getModifiers(){
350
        return modifiers;
350
        return modifiers;
351
    }
351
    }
352
      
352
353
    DrawState getDrawState() {
353
    DrawState getDrawState() {
354
        return drawState;
354
        return drawState;
355
    }
355
    }
356
    
356
357
    void setDrawState(DrawState drawState) {
357
    void setDrawState(DrawState drawState) {
358
        this.drawState = drawState;
358
        this.drawState = drawState;
359
    }
359
    }
360
    
360
361
    //.................. INNER CLASSES .......................
361
    //.................. INNER CLASSES .......................
362
    
362
363
    private class PostfixString {
363
    private class PostfixString {
364
        private String text;
364
        private String text;
365
        private Color c;
365
        private Color c;
366
        private int fontStyle;
366
        private int fontStyle;
367
        
367
368
        public PostfixString(String text, Color c, int fontStyle) {
368
        public PostfixString(String text, Color c, int fontStyle) {
369
            this.text = text;
369
            this.text = text;
370
            this.c = c;
370
            this.c = c;
371
            this.fontStyle = fontStyle;
371
            this.fontStyle = fontStyle;
372
        }
372
        }
373
        
373
374
        public PostfixString(String text, int fontStyle) {
374
        public PostfixString(String text, int fontStyle) {
375
            this(text, CsmPaintComponent.POSTFIX_COLOR, fontStyle);            
375
            this(text, LFCustoms.shiftColor(CsmPaintComponent.POSTFIX_COLOR), fontStyle);
376
        }
376
        }
377
        
377
378
        void Draw(Graphics g) {            
378
        void Draw(Graphics g) {
379
            CsmPaintComponent.this.drawString(g, text, c, new Font(getDrawFont().getName(), 
379
            CsmPaintComponent.this.drawString(g, text, c, new Font(getDrawFont().getName(),
380
                                                                   getDrawFont().getStyle() | fontStyle, 
380
                                                                   getDrawFont().getStyle() | fontStyle,
381
                                                                   getDrawFont().getSize()),
381
                                                                   getDrawFont().getSize()),
382
                                               false);
382
                                               false);
383
                                        
383
384
        }        
384
        }
385
    }
385
    }
386
    
386
387
    private static class DrawState {
387
    private static class DrawState {
388
        int drawX, drawY;
388
        int drawX, drawY;
389
        int drawHeight;    
389
        int drawHeight;
390
               
390
391
        public DrawState() {
391
        public DrawState() {
392
            drawX = drawY = drawHeight = 0;
392
            drawX = drawY = drawHeight = 0;
393
        }        
393
        }
394
    }
394
    }
395
    
395
396
    public static class NamespacePaintComponent extends CsmPaintComponent{
396
    public static class NamespacePaintComponent extends CsmPaintComponent{
397
397
398
        private String pkgName;
398
        private String pkgName;
399
        private boolean displayFullNamespacePath;
399
        private boolean displayFullNamespacePath;
400
        private Color NAMESPACE_COLOR = Color.green.darker().darker().darker();
400
        private Color NAMESPACE_COLOR = LFCustoms.shiftColor(new Color(64,255,64));
401
        
401
402
        public NamespacePaintComponent(){
402
        public NamespacePaintComponent(){
403
            super();
403
            super();
404
        }
404
        }
405
        
405
406
        public void setNamespaceName(String pkgName){
406
        public void setNamespaceName(String pkgName){
407
            this.pkgName = pkgName;
407
            this.pkgName = pkgName;
408
        }
408
        }
409
        
409
410
        public void setDisplayFullNamespacePath(boolean displayFullNamespacePath){
410
        public void setDisplayFullNamespacePath(boolean displayFullNamespacePath){
411
            this.displayFullNamespacePath = displayFullNamespacePath;
411
            this.displayFullNamespacePath = displayFullNamespacePath;
412
        }
412
        }
413
        
413
414
        @Override
414
        @Override
415
        protected void draw(Graphics g) {
415
        protected void draw(Graphics g) {
416
            // IMPORTANT:
416
            // IMPORTANT:
Lines 422-428 Link Here
422
            }
422
            }
423
            drawString(g, name,	    NAMESPACE_COLOR);
423
            drawString(g, name,	    NAMESPACE_COLOR);
424
        }
424
        }
425
        
425
426
        /**
426
        /**
427
         * returns string representation of paint item
427
         * returns string representation of paint item
428
         * IMPORTANT: have to be in sync with draw() method
428
         * IMPORTANT: have to be in sync with draw() method
Lines 432-451 Link Here
432
            return pkgName;
432
            return pkgName;
433
        }
433
        }
434
    }
434
    }
435
    
435
436
    public static class NamespaceAliasPaintComponent extends CsmPaintComponent{
436
    public static class NamespaceAliasPaintComponent extends CsmPaintComponent{
437
437
438
        private String aliasName;
438
        private String aliasName;
439
        private Color NAMESPACE_COLOR = Color.green.darker().darker().darker();
439
        private Color NAMESPACE_COLOR = LFCustoms.shiftColor(new Color(64,255,64));
440
        
440
441
        public NamespaceAliasPaintComponent(){
441
        public NamespaceAliasPaintComponent(){
442
            super();
442
            super();
443
        }
443
        }
444
        
444
445
        public void setAliasName(String aliasName){
445
        public void setAliasName(String aliasName){
446
            this.aliasName = aliasName;
446
            this.aliasName = aliasName;
447
        }
447
        }
448
        
448
449
        @Override
449
        @Override
450
        protected void draw(Graphics g) {
450
        protected void draw(Graphics g) {
451
            // IMPORTANT:
451
            // IMPORTANT:
Lines 453-459 Link Here
453
            drawIcon(g, getIcon());
453
            drawIcon(g, getIcon());
454
            drawString(g, aliasName,	    NAMESPACE_COLOR);
454
            drawString(g, aliasName,	    NAMESPACE_COLOR);
455
        }
455
        }
456
        
456
457
        /**
457
        /**
458
         * returns string representation of paint item
458
         * returns string representation of paint item
459
         * IMPORTANT: have to be in sync with draw() method
459
         * IMPORTANT: have to be in sync with draw() method
Lines 465-483 Link Here
465
    }
465
    }
466
466
467
    public static class EnumPaintComponent extends CsmPaintComponent {
467
    public static class EnumPaintComponent extends CsmPaintComponent {
468
        
468
469
        String formatEnumName;
469
        String formatEnumName;
470
        private Color ENUM_COLOR = Color.red.darker().darker().darker().darker();
470
        private Color ENUM_COLOR = LFCustoms.shiftColor(new Color(255,64,64));
471
        private boolean displayFQN;
471
        private boolean displayFQN;
472
        
472
473
        public void EnumPaintComponent(String formatEnumName){
473
        public void EnumPaintComponent(String formatEnumName){
474
            this.formatEnumName = formatEnumName;
474
            this.formatEnumName = formatEnumName;
475
        }
475
        }
476
        
476
477
        protected Color getColor(){
477
        protected Color getColor(){
478
            return ENUM_COLOR;
478
            return ENUM_COLOR;
479
        }
479
        }
480
        
480
481
        @Override
481
        @Override
482
        protected void draw(Graphics g){
482
        protected void draw(Graphics g){
483
            // IMPORTANT:
483
            // IMPORTANT:
Lines 486-492 Link Here
486
            drawIcon(g, getIcon());
486
            drawIcon(g, getIcon());
487
            drawString(g, formatEnumName, getColor(), null, strike);
487
            drawString(g, formatEnumName, getColor(), null, strike);
488
        }
488
        }
489
        
489
490
        public void setFormatEnumName(String formatEnumName){
490
        public void setFormatEnumName(String formatEnumName){
491
            this.formatEnumName = formatEnumName;
491
            this.formatEnumName = formatEnumName;
492
        }
492
        }
Lines 500-520 Link Here
500
            return formatEnumName;
500
            return formatEnumName;
501
        }
501
        }
502
    }
502
    }
503
    
503
504
    public static class EnumeratorPaintComponent extends CsmPaintComponent {
504
    public static class EnumeratorPaintComponent extends CsmPaintComponent {
505
        
505
506
        String formatEnumeratorName;
506
        String formatEnumeratorName;
507
        private Color ENUMERATOR_COLOR = Color.blue.darker().darker().darker().darker();
507
        private Color ENUMERATOR_COLOR = LFCustoms.shiftColor(new Color(64,64,255));
508
        private boolean displayFQN;
508
        private boolean displayFQN;
509
        
509
510
        public void EnumeratorPaintComponent(String formatEnumeratorName){
510
        public void EnumeratorPaintComponent(String formatEnumeratorName){
511
            this.formatEnumeratorName = formatEnumeratorName;
511
            this.formatEnumeratorName = formatEnumeratorName;
512
        }
512
        }
513
        
513
514
        protected Color getColor(){
514
        protected Color getColor(){
515
            return ENUMERATOR_COLOR;
515
            return ENUMERATOR_COLOR;
516
        }
516
        }
517
        
517
518
        @Override
518
        @Override
519
        protected void draw(Graphics g){
519
        protected void draw(Graphics g){
520
            // IMPORTANT:
520
            // IMPORTANT:
Lines 523-529 Link Here
523
            drawIcon(g, getIcon());
523
            drawIcon(g, getIcon());
524
            drawString(g, formatEnumeratorName, getColor(), null, strike);
524
            drawString(g, formatEnumeratorName, getColor(), null, strike);
525
        }
525
        }
526
        
526
527
        public void setFormatEnumeratorName(String formatEnumeratorName){
527
        public void setFormatEnumeratorName(String formatEnumeratorName){
528
            assert(formatEnumeratorName != null);
528
            assert(formatEnumeratorName != null);
529
            this.formatEnumeratorName = formatEnumeratorName;
529
            this.formatEnumeratorName = formatEnumeratorName;
Lines 538-558 Link Here
538
            return formatEnumeratorName;
538
            return formatEnumeratorName;
539
        }
539
        }
540
    }
540
    }
541
    
541
542
    public static class ClassPaintComponent extends CsmPaintComponent{
542
    public static class ClassPaintComponent extends CsmPaintComponent{
543
        
543
544
        String formatClassName;
544
        String formatClassName;
545
        private Color CLASS_COLOR = Color.red.darker().darker().darker();
545
        private Color CLASS_COLOR = LFCustoms.shiftColor(new Color(255,64,64));
546
        private boolean displayFQN;
546
        private boolean displayFQN;
547
        
547
548
        public void setFormatClassName(String formatClassName){
548
        public void setFormatClassName(String formatClassName){
549
            this.formatClassName = formatClassName;
549
            this.formatClassName = formatClassName;
550
        }
550
        }
551
        
551
552
        protected Color getColor(){
552
        protected Color getColor(){
553
            return CLASS_COLOR;
553
            return CLASS_COLOR;
554
        }
554
        }
555
        
555
556
        @Override
556
        @Override
557
        protected void draw(Graphics g){
557
        protected void draw(Graphics g){
558
            // IMPORTANT:
558
            // IMPORTANT:
Lines 561-567 Link Here
561
            drawIcon(g, getIcon());
561
            drawIcon(g, getIcon());
562
            drawString(g, formatClassName, getColor(), null, strike);
562
            drawString(g, formatClassName, getColor(), null, strike);
563
        }
563
        }
564
      
564
565
        /**
565
        /**
566
         * returns string representation of paint item
566
         * returns string representation of paint item
567
         * IMPORTANT: have to be in sync with draw() method
567
         * IMPORTANT: have to be in sync with draw() method
Lines 569-593 Link Here
569
        @Override
569
        @Override
570
        public String toString() {
570
        public String toString() {
571
            return formatClassName;
571
            return formatClassName;
572
        }        
572
        }
573
    }
573
    }
574
574
575
    
575
576
    public static class TypedefPaintComponent extends CsmPaintComponent{
576
    public static class TypedefPaintComponent extends CsmPaintComponent{
577
        
577
578
        String formatTypedefName;
578
        String formatTypedefName;
579
        private final Color TYPEDEF_COLOR = CsmFontColorManager.instance().getColor(FontColorProvider.Entity.TYPEDEF); //Color.blue.darker().darker().darker();
579
        private final Color TYPEDEF_COLOR = CsmFontColorManager.instance().getColor(FontColorProvider.Entity.TYPEDEF); //new Color(64,64,255).darker().darker().darker();
580
        //private boolean displayFQN;
580
        //private boolean displayFQN;
581
        
581
582
        public void setFormatTypedefName(String formatTypedefName){
582
        public void setFormatTypedefName(String formatTypedefName){
583
            this.formatTypedefName = formatTypedefName;
583
            this.formatTypedefName = formatTypedefName;
584
            
584
585
        }
585
        }
586
        
586
587
        protected Color getColor(){
587
        protected Color getColor(){
588
            return TYPEDEF_COLOR;
588
            return TYPEDEF_COLOR;
589
        }
589
        }
590
        
590
591
        @Override
591
        @Override
592
        protected void draw(Graphics g){
592
        protected void draw(Graphics g){
593
            // IMPORTANT:
593
            // IMPORTANT:
Lines 596-602 Link Here
596
            drawIcon(g, getIcon());
596
            drawIcon(g, getIcon());
597
            drawString(g, formatTypedefName, getColor(), null, strike);
597
            drawString(g, formatTypedefName, getColor(), null, strike);
598
        }
598
        }
599
      
599
600
        /**
600
        /**
601
         * returns string representation of paint item
601
         * returns string representation of paint item
602
         * IMPORTANT: have to be in sync with draw() method
602
         * IMPORTANT: have to be in sync with draw() method
Lines 604-681 Link Here
604
        @Override
604
        @Override
605
        public String toString() {
605
        public String toString() {
606
            return formatTypedefName;
606
            return formatTypedefName;
607
        }        
607
        }
608
    }
608
    }
609
609
610
    public static class StructPaintComponent extends ClassPaintComponent{
610
    public static class StructPaintComponent extends ClassPaintComponent{
611
        
611
612
        private Color STRUCT_COLOR = Color.red.darker().darker();
612
        private Color STRUCT_COLOR = LFCustoms.shiftColor(new Color(255,64,64));
613
        
613
614
        @Override
614
        @Override
615
        protected Color getColor(){
615
        protected Color getColor(){
616
            return STRUCT_COLOR;
616
            return STRUCT_COLOR;
617
        }
617
        }
618
        
618
619
        public StructPaintComponent(){
619
        public StructPaintComponent(){
620
            super();
620
            super();
621
        }
621
        }
622
    }
622
    }
623
    
623
624
    public static class UnionPaintComponent extends ClassPaintComponent{
624
    public static class UnionPaintComponent extends ClassPaintComponent{
625
        
625
626
        private Color UNION_COLOR = Color.red.darker();
626
        private Color UNION_COLOR = LFCustoms.shiftColor(new Color(255,64,64));
627
        
627
628
        @Override
628
        @Override
629
        protected Color getColor(){
629
        protected Color getColor(){
630
            return UNION_COLOR;
630
            return UNION_COLOR;
631
        }
631
        }
632
        
632
633
        public UnionPaintComponent(){
633
        public UnionPaintComponent(){
634
            super();
634
            super();
635
        }
635
        }
636
    }
636
    }
637
    
637
638
    public static class FieldPaintComponent extends CsmPaintComponent{
638
    public static class FieldPaintComponent extends CsmPaintComponent{
639
        private Color FIELD_COLOR = CsmFontColorManager.instance().getColor(FontColorProvider.Entity.CLASS_FIELD);//Color.blue.darker();
639
        private Color FIELD_COLOR = CsmFontColorManager.instance().getColor(FontColorProvider.Entity.CLASS_FIELD);//new Color(64,64,255).darker();
640
        protected String typeName;
640
        protected String typeName;
641
        protected Color typeColor;
641
        protected Color typeColor;
642
        protected String fldName;
642
        protected String fldName;
643
        
643
644
        private boolean drawTypeAsPrefix = false;
644
        private boolean drawTypeAsPrefix = false;
645
        
645
646
        public FieldPaintComponent() {
646
        public FieldPaintComponent() {
647
            super();
647
            super();
648
        }
648
        }
649
        
649
650
        public Color getNameColor() {
650
        public Color getNameColor() {
651
            return FIELD_COLOR;
651
            return FIELD_COLOR;
652
        }
652
        }
653
        
653
654
        @Override
654
        @Override
655
        public void setName(String fldName){
655
        public void setName(String fldName){
656
            this.fldName= fldName;
656
            this.fldName= fldName;
657
        }
657
        }
658
        
658
659
        public void setTypeColor(Color typeColor){
659
        public void setTypeColor(Color typeColor){
660
            this.typeColor = typeColor;
660
            this.typeColor = typeColor;
661
        }
661
        }
662
        
662
663
        public void setTypeName(String typeName){
663
        public void setTypeName(String typeName){
664
            this.typeName = typeName;
664
            this.typeName = typeName;
665
        }
665
        }
666
        
666
667
        public Color getTypeColor(){
667
        public Color getTypeColor(){
668
            return this.typeColor;
668
            return this.typeColor;
669
        }
669
        }
670
        
670
671
        public String getTypeName(){
671
        public String getTypeName(){
672
            return this.typeName;
672
            return this.typeName;
673
        }
673
        }
674
        
674
675
        public void setDrawTypeAsPrefix(boolean asPrefix) {
675
        public void setDrawTypeAsPrefix(boolean asPrefix) {
676
            this.drawTypeAsPrefix = asPrefix;
676
            this.drawTypeAsPrefix = asPrefix;
677
        }
677
        }
678
        
678
679
        @Override
679
        @Override
680
        protected void draw(Graphics g){
680
        protected void draw(Graphics g){
681
            // IMPORTANT:
681
            // IMPORTANT:
Lines 683-692 Link Here
683
            boolean strike = false;
683
            boolean strike = false;
684
            //int level = CsmUtilities.getLevel(modifiers);
684
            //int level = CsmUtilities.getLevel(modifiers);
685
            drawIcon(g, getIcon());
685
            drawIcon(g, getIcon());
686
            
686
687
            if (drawTypeAsPrefix) {
687
            if (drawTypeAsPrefix) {
688
                drawString(g, getTypeName(), getTypeColor(), null, strike);
688
                drawString(g, getTypeName(), getTypeColor(), null, strike);
689
                drawString(g, " ", strike); // NOI18N                   
689
                drawString(g, " ", strike); // NOI18N
690
            }
690
            }
691
            if ((modifiers & CsmUtilities.LOCAL_MEMBER_BIT) != 0){
691
            if ((modifiers & CsmUtilities.LOCAL_MEMBER_BIT) != 0){
692
                // it is local field, draw as bold
692
                // it is local field, draw as bold
Lines 716-732 Link Here
716
                buf.append(typeName);
716
                buf.append(typeName);
717
            }
717
            }
718
            return buf.toString();
718
            return buf.toString();
719
        }        
719
        }
720
    }
720
    }
721
    
721
722
    public static class LocalVariablePaintComponent extends FieldPaintComponent {
722
    public static class LocalVariablePaintComponent extends FieldPaintComponent {
723
        private Color VARIABLE_COLOR = Color.red.darker().darker().darker();
723
        private Color VARIABLE_COLOR = LFCustoms.shiftColor(new Color(255,64,64));
724
        
724
725
        public LocalVariablePaintComponent(){
725
        public LocalVariablePaintComponent(){
726
            super();
726
            super();
727
            this.modifiers |= CsmUtilities.LOCAL_MEMBER_BIT | this.modifiers;
727
            this.modifiers |= CsmUtilities.LOCAL_MEMBER_BIT | this.modifiers;
728
        }
728
        }
729
        
729
730
        @Override
730
        @Override
731
        public Color getNameColor() {
731
        public Color getNameColor() {
732
            return VARIABLE_COLOR;
732
            return VARIABLE_COLOR;
Lines 737-772 Link Here
737
            super.setModifiers(modifiers | CsmUtilities.LOCAL_MEMBER_BIT);
737
            super.setModifiers(modifiers | CsmUtilities.LOCAL_MEMBER_BIT);
738
        }
738
        }
739
    }
739
    }
740
    
740
741
    public static class FileLocalVariablePaintComponent extends FieldPaintComponent {
741
    public static class FileLocalVariablePaintComponent extends FieldPaintComponent {
742
        private Color VARIABLE_COLOR = Color.blue.darker().darker().darker();
742
        private Color VARIABLE_COLOR = LFCustoms.shiftColor(new Color(64,64,255));
743
        
743
744
        public FileLocalVariablePaintComponent(){
744
        public FileLocalVariablePaintComponent(){
745
            super();
745
            super();
746
        }
746
        }
747
        
747
748
        @Override
748
        @Override
749
        public Color getNameColor() {
749
        public Color getNameColor() {
750
            return VARIABLE_COLOR;
750
            return VARIABLE_COLOR;
751
        }
751
        }
752
    }
752
    }
753
    
753
754
    public static class GlobalVariablePaintComponent extends FieldPaintComponent {
754
    public static class GlobalVariablePaintComponent extends FieldPaintComponent {
755
        private Color VARIABLE_COLOR = Color.blue.darker().darker().darker();
755
        private Color VARIABLE_COLOR = LFCustoms.shiftColor(new Color(64,64,255));
756
        
756
757
        public GlobalVariablePaintComponent(){
757
        public GlobalVariablePaintComponent(){
758
            super();
758
            super();
759
        }
759
        }
760
        
760
761
        @Override
761
        @Override
762
        public Color getNameColor() {
762
        public Color getNameColor() {
763
            return VARIABLE_COLOR;
763
            return VARIABLE_COLOR;
764
        }
764
        }
765
    }
765
    }
766
    
766
767
    public static class MacroPaintComponent extends CsmPaintComponent{
767
    public static class MacroPaintComponent extends CsmPaintComponent{
768
        private Color MACRO_NAME_COLOR = CsmFontColorManager.instance().getColor(FontColorProvider.Entity.DEFINED_MACRO);//Color.green.darker().darker();
768
        private Color MACRO_NAME_COLOR = CsmFontColorManager.instance().getColor(FontColorProvider.Entity.DEFINED_MACRO);//new Color(64,255,64).darker().darker();
769
        private Color MACRO_PARAMETER_NAME_COLOR = new Color(163, 102, 10);//Color.magenta.darker();
769
        private Color MACRO_PARAMETER_NAME_COLOR = LFCustoms.shiftColor(new Color(227, 166, 74));//Color.magenta.darker();
770
        private List params = null;
770
        private List params = null;
771
        private String name;
771
        private String name;
772
772
Lines 778-793 Link Here
778
        public String getName(){
778
        public String getName(){
779
            return name;
779
            return name;
780
        }
780
        }
781
        
781
782
        @Override
782
        @Override
783
        public void setName(String name){
783
        public void setName(String name){
784
            this.name = name;
784
            this.name = name;
785
        }
785
        }
786
        
786
787
        public void setParams(List params){
787
        public void setParams(List params){
788
            this.params = params;
788
            this.params = params;
789
        }
789
        }
790
        
790
791
        protected List getParamList(){
791
        protected List getParamList(){
792
            return params;
792
            return params;
793
        }
793
        }
Lines 844-854 Link Here
844
            //macro params
844
            //macro params
845
            buf.append(toStringParameterList(getParamList()));
845
            buf.append(toStringParameterList(getParamList()));
846
            return buf.toString();
846
            return buf.toString();
847
        }    
847
        }
848
    }
848
    }
849
    
849
850
    public static class TemplateParameterPaintComponent extends CsmPaintComponent{
850
    public static class TemplateParameterPaintComponent extends CsmPaintComponent{
851
        private Color PARAMETER_NAME_COLOR = Color.BLACK.darker().darker();
851
        private Color PARAMETER_NAME_COLOR = LFCustoms.getTextFgColor();
852
        private List params = null;
852
        private List params = null;
853
        private String name;
853
        private String name;
854
854
Lines 860-875 Link Here
860
        public String getName(){
860
        public String getName(){
861
            return name;
861
            return name;
862
        }
862
        }
863
        
863
864
        @Override
864
        @Override
865
        public void setName(String name){
865
        public void setName(String name){
866
            this.name = name;
866
            this.name = name;
867
        }
867
        }
868
        
868
869
        public void setParams(List params){
869
        public void setParams(List params){
870
            this.params = params;
870
            this.params = params;
871
        }
871
        }
872
        
872
873
        protected List getParamList(){
873
        protected List getParamList(){
874
            return params;
874
            return params;
875
        }
875
        }
Lines 893-903 Link Here
893
            //macro name
893
            //macro name
894
            buf.append(getName());
894
            buf.append(getName());
895
            return buf.toString();
895
            return buf.toString();
896
        }    
896
        }
897
    }
897
    }
898
898
899
    public static class LabelPaintComponent extends  CsmPaintComponent {
899
    public static class LabelPaintComponent extends  CsmPaintComponent {
900
        private Color LABEL_NAME_COLOR = Color.BLACK.darker().darker();
900
        private Color LABEL_NAME_COLOR = LFCustoms.getTextFgColor();
901
        private List params = null;
901
        private List params = null;
902
        private String name;
902
        private String name;
903
903
Lines 909-924 Link Here
909
        public String getName(){
909
        public String getName(){
910
            return name;
910
            return name;
911
        }
911
        }
912
        
912
913
        @Override
913
        @Override
914
        public void setName(String name){
914
        public void setName(String name){
915
            this.name = name;
915
            this.name = name;
916
        }
916
        }
917
        
917
918
        public void setParams(List params){
918
        public void setParams(List params){
919
            this.params = params;
919
            this.params = params;
920
        }
920
        }
921
        
921
922
        protected List getParamList(){
922
        protected List getParamList(){
923
            return params;
923
            return params;
924
        }
924
        }
Lines 942-996 Link Here
942
            //macro name
942
            //macro name
943
            buf.append(getName());
943
            buf.append(getName());
944
            return buf.toString();
944
            return buf.toString();
945
        }    
945
        }
946
    }
946
    }
947
    
947
948
    public static class ConstructorPaintComponent extends CsmPaintComponent{
948
    public static class ConstructorPaintComponent extends CsmPaintComponent{
949
        
949
950
        private Color CONSTRUCTOR_COLOR = Color.orange.darker().darker();
950
        private Color CONSTRUCTOR_COLOR = LFCustoms.shiftColor(Color.orange);
951
        private Color PARAMETER_NAME_COLOR = new Color(163, 102, 10);//Color.magenta.darker();
951
        private Color PARAMETER_NAME_COLOR = LFCustoms.shiftColor(new Color(227, 166, 74));//Color.magenta.darker();
952
        private List params = new ArrayList();
952
        private List params = new ArrayList();
953
        private List excs = new ArrayList();
953
        private List excs = new ArrayList();
954
        private String name;
954
        private String name;
955
        
955
956
        public ConstructorPaintComponent(){
956
        public ConstructorPaintComponent(){
957
            super();
957
            super();
958
        }
958
        }
959
        
959
960
        public int getMethodModifiers(){
960
        public int getMethodModifiers(){
961
            return modifiers;
961
            return modifiers;
962
        }
962
        }
963
        
963
964
        @Override
964
        @Override
965
        public String getName(){
965
        public String getName(){
966
            return name;
966
            return name;
967
        }
967
        }
968
        
968
969
        @Override
969
        @Override
970
        public void setName(String name){
970
        public void setName(String name){
971
            this.name = name;
971
            this.name = name;
972
        }
972
        }
973
        
973
974
        public void setParams(List params){
974
        public void setParams(List params){
975
            this.params = params;
975
            this.params = params;
976
        }
976
        }
977
        
977
978
        public void setExceptions(List excs){
978
        public void setExceptions(List excs){
979
            this.excs = excs;
979
            this.excs = excs;
980
        }
980
        }
981
        
981
982
        protected List getParamList(){
982
        protected List getParamList(){
983
            return params;
983
            return params;
984
        }
984
        }
985
        
985
986
        protected List getExceptionList(){
986
        protected List getExceptionList(){
987
            return excs;
987
            return excs;
988
        }
988
        }
989
        
989
990
        protected void drawParameter(Graphics g, ParamStr prm) {
990
        protected void drawParameter(Graphics g, ParamStr prm) {
991
            drawParameter(g, prm, false);
991
            drawParameter(g, prm, false);
992
        }
992
        }
993
        
993
994
        protected void drawParameter(Graphics g, ParamStr prm, boolean strike) {
994
        protected void drawParameter(Graphics g, ParamStr prm, boolean strike) {
995
            String parmName = prm.getName();
995
            String parmName = prm.getName();
996
            String simpleTypeName = prm.getSimpleTypeName();
996
            String simpleTypeName = prm.getSimpleTypeName();
Lines 1010-1020 Link Here
1010
                drawString(g, simpleTypeName.substring(indexOfSqr), prm.getTypeColor(), null, strike);
1010
                drawString(g, simpleTypeName.substring(indexOfSqr), prm.getTypeColor(), null, strike);
1011
            }
1011
            }
1012
        }
1012
        }
1013
        
1013
1014
        protected void drawParameterList(Graphics g, List prmList) {
1014
        protected void drawParameterList(Graphics g, List prmList) {
1015
            drawParameterList(g, prmList, false);
1015
            drawParameterList(g, prmList, false);
1016
        }
1016
        }
1017
        
1017
1018
        protected void drawParameterList(Graphics g, List prmList, boolean strike) {
1018
        protected void drawParameterList(Graphics g, List prmList, boolean strike) {
1019
            drawString(g, "(", strike); // NOI18N
1019
            drawString(g, "(", strike); // NOI18N
1020
            for (Iterator it = prmList.iterator(); it.hasNext();) {
1020
            for (Iterator it = prmList.iterator(); it.hasNext();) {
Lines 1025-1045 Link Here
1025
            }
1025
            }
1026
            drawString(g, ")", strike); // NOI18N
1026
            drawString(g, ")", strike); // NOI18N
1027
        }
1027
        }
1028
        
1028
1029
        protected void drawExceptions(Graphics g, List exc, boolean strike) {
1029
        protected void drawExceptions(Graphics g, List exc, boolean strike) {
1030
            if (exc.size() > 0) {
1030
            if (exc.size() > 0) {
1031
                drawString(g, THROWS, KEYWORD_COLOR, null, strike);
1031
                drawString(g, THROWS, LFCustoms.shiftColor(KEYWORD_COLOR), null, strike);
1032
                for (Iterator it = exc.iterator(); it.hasNext();) {
1032
                for (Iterator it = exc.iterator(); it.hasNext();) {
1033
                    ExceptionStr ex = (ExceptionStr) it.next();
1033
                    ExceptionStr ex = (ExceptionStr) it.next();
1034
                    drawString(g, ex.getName(), ex.getTypeColor(), null, strike);
1034
                    drawString(g, ex.getName(), ex.getTypeColor(), null, strike);
1035
                    if (it.hasNext()) {
1035
                    if (it.hasNext()) {
1036
                        drawString(g, ", ", strike); // NOI18N
1036
                        drawString(g, ", ", strike); // NOI18N
1037
                    }
1037
                    }
1038
                    
1038
1039
                }
1039
                }
1040
            }
1040
            }
1041
        }
1041
        }
1042
        
1042
1043
        @Override
1043
        @Override
1044
        protected void draw(Graphics g){
1044
        protected void draw(Graphics g){
1045
            // IMPORTANT:
1045
            // IMPORTANT:
Lines 1066-1077 Link Here
1066
            //constructor exceptions
1066
            //constructor exceptions
1067
            buf.append(toStringExceptions(getExceptionList()));
1067
            buf.append(toStringExceptions(getExceptionList()));
1068
            return buf.toString();
1068
            return buf.toString();
1069
        }    
1069
        }
1070
        
1070
1071
        protected String toStringParameter(ParamStr prm) {
1071
        protected String toStringParameter(ParamStr prm) {
1072
            return prm.getText();
1072
            return prm.getText();
1073
        }
1073
        }
1074
        
1074
1075
        protected String toStringParameterList(List prmList) {
1075
        protected String toStringParameterList(List prmList) {
1076
            StringBuilder buf = new StringBuilder();
1076
            StringBuilder buf = new StringBuilder();
1077
            buf.append('('); // NOI18N
1077
            buf.append('('); // NOI18N
Lines 1084-1090 Link Here
1084
            buf.append(')'); // NOI18N
1084
            buf.append(')'); // NOI18N
1085
            return buf.toString();
1085
            return buf.toString();
1086
        }
1086
        }
1087
        
1087
1088
        protected String toStringExceptions(List exc) {
1088
        protected String toStringExceptions(List exc) {
1089
            StringBuilder buf = new StringBuilder();
1089
            StringBuilder buf = new StringBuilder();
1090
            if (exc.size() > 0) {
1090
            if (exc.size() > 0) {
Lines 1095-1143 Link Here
1095
                    if (it.hasNext()) {
1095
                    if (it.hasNext()) {
1096
                        buf.append(", "); // NOI18N
1096
                        buf.append(", "); // NOI18N
1097
                    }
1097
                    }
1098
                    
1098
1099
                }
1099
                }
1100
            }
1100
            }
1101
            return buf.toString();
1101
            return buf.toString();
1102
        }
1102
        }
1103
    }
1103
    }
1104
    
1104
1105
    public static class MethodPaintComponent extends ConstructorPaintComponent {
1105
    public static class MethodPaintComponent extends ConstructorPaintComponent {
1106
        
1106
1107
        //private Color PARAMETER_NAME_COLOR = Color.magenta.darker();
1107
        //private Color PARAMETER_NAME_COLOR = Color.magenta.darker();
1108
        private Color METHOD_COLOR = Color.black;//red.darker().darker();
1108
        private Color METHOD_COLOR = LFCustoms.getTextFgColor();
1109
        private String typeName;
1109
        private String typeName;
1110
        private Color typeColor;
1110
        private Color typeColor;
1111
        private boolean drawTypeAsPrefix = false;
1111
        private boolean drawTypeAsPrefix = false;
1112
        
1112
1113
        public MethodPaintComponent(){
1113
        public MethodPaintComponent(){
1114
            super();
1114
            super();
1115
        }
1115
        }
1116
        
1116
1117
        public Color getNameColor() {
1117
        public Color getNameColor() {
1118
            return METHOD_COLOR;
1118
            return METHOD_COLOR;
1119
        }
1119
        }
1120
        
1120
1121
        public String getTypeName(){
1121
        public String getTypeName(){
1122
            return typeName;
1122
            return typeName;
1123
        }
1123
        }
1124
        
1124
1125
        public Color getTypeColor(){
1125
        public Color getTypeColor(){
1126
            return typeColor;
1126
            return typeColor;
1127
        }
1127
        }
1128
        
1128
1129
        public void setTypeName(String typeName){
1129
        public void setTypeName(String typeName){
1130
            this.typeName = typeName;
1130
            this.typeName = typeName;
1131
        }
1131
        }
1132
        
1132
1133
        public void setTypeColor(Color typeColor){
1133
        public void setTypeColor(Color typeColor){
1134
            this.typeColor = typeColor;
1134
            this.typeColor = typeColor;
1135
        }
1135
        }
1136
        
1136
1137
        public void setDrawTypeAsPrefix(boolean asPrefix) {
1137
        public void setDrawTypeAsPrefix(boolean asPrefix) {
1138
            this.drawTypeAsPrefix = asPrefix;
1138
            this.drawTypeAsPrefix = asPrefix;
1139
        }
1139
        }
1140
        
1140
1141
        @Override
1141
        @Override
1142
        protected void draw(Graphics g){
1142
        protected void draw(Graphics g){
1143
            // IMPORTANT:
1143
            // IMPORTANT:
Lines 1145-1155 Link Here
1145
            boolean strike = false;
1145
            boolean strike = false;
1146
            //int level = CsmUtilities.getLevel(getModifiers());
1146
            //int level = CsmUtilities.getLevel(getModifiers());
1147
            drawIcon(g, getIcon());
1147
            drawIcon(g, getIcon());
1148
            
1148
1149
            if (drawTypeAsPrefix) {
1149
            if (drawTypeAsPrefix) {
1150
                drawString(g, getTypeName(), getTypeColor(), null, strike);
1150
                drawString(g, getTypeName(), getTypeColor(), null, strike);
1151
                drawString(g, " ", strike); // NOI18N                
1151
                drawString(g, " ", strike); // NOI18N
1152
            }            
1152
            }
1153
            if ((getModifiers() & CsmUtilities.LOCAL_MEMBER_BIT) != 0){
1153
            if ((getModifiers() & CsmUtilities.LOCAL_MEMBER_BIT) != 0){
1154
                drawString(g, getName(), getNameColor() , new Font(getDrawFont().getName(), getDrawFont().getStyle() | Font.BOLD, getDrawFont().getSize()), strike);
1154
                drawString(g, getName(), getNameColor() , new Font(getDrawFont().getName(), getDrawFont().getStyle() | Font.BOLD, getDrawFont().getSize()), strike);
1155
            }else{
1155
            }else{
Lines 1171-1177 Link Here
1171
            StringBuilder buf = new StringBuilder();
1171
            StringBuilder buf = new StringBuilder();
1172
            if (drawTypeAsPrefix) {
1172
            if (drawTypeAsPrefix) {
1173
                //return type
1173
                //return type
1174
                buf.append(getTypeName());                
1174
                buf.append(getTypeName());
1175
                buf.append(' '); // NOI18N
1175
                buf.append(' '); // NOI18N
1176
            }
1176
            }
1177
            //method name
1177
            //method name
Lines 1183-1229 Link Here
1183
            if (!drawTypeAsPrefix) {
1183
            if (!drawTypeAsPrefix) {
1184
                //return type
1184
                //return type
1185
                buf.append(' '); // NOI18N
1185
                buf.append(' '); // NOI18N
1186
                buf.append(getTypeName());                
1186
                buf.append(getTypeName());
1187
            }
1187
            }
1188
            return buf.toString();            
1188
            return buf.toString();
1189
        }        
1189
        }
1190
    }
1190
    }
1191
1191
1192
    public static class FileLocalFunctionPaintComponent extends MethodPaintComponent {
1192
    public static class FileLocalFunctionPaintComponent extends MethodPaintComponent {
1193
        private Color FUN_COLOR = Color.black;//red.darker().darker();
1193
        private Color FUN_COLOR = LFCustoms.getTextFgColor();
1194
        
1194
1195
        public FileLocalFunctionPaintComponent(){
1195
        public FileLocalFunctionPaintComponent(){
1196
            super();
1196
            super();
1197
        }
1197
        }
1198
        
1198
1199
        @Override
1199
        @Override
1200
        public Color getNameColor() {
1200
        public Color getNameColor() {
1201
            return FUN_COLOR;
1201
            return FUN_COLOR;
1202
        }
1202
        }
1203
    }
1203
    }
1204
    
1204
1205
    public static class GlobalFunctionPaintComponent extends MethodPaintComponent {
1205
    public static class GlobalFunctionPaintComponent extends MethodPaintComponent {
1206
        private Color FUN_COLOR = Color.black;//.red.darker().darker();
1206
        private Color FUN_COLOR = LFCustoms.getTextFgColor();
1207
        
1207
1208
        public GlobalFunctionPaintComponent(){
1208
        public GlobalFunctionPaintComponent(){
1209
            super();
1209
            super();
1210
        }
1210
        }
1211
        
1211
1212
        @Override
1212
        @Override
1213
        public Color getNameColor() {
1213
        public Color getNameColor() {
1214
            return FUN_COLOR;
1214
            return FUN_COLOR;
1215
        }
1215
        }
1216
    }
1216
    }
1217
    
1217
1218
    public static class CsmPaintComponentWrapper extends CsmPaintComponent {    
1218
    public static class CsmPaintComponentWrapper extends CsmPaintComponent {
1219
        private CsmPaintComponent comp;
1219
        private CsmPaintComponent comp;
1220
        private boolean drawTypeAsPrefix = true;
1220
        private boolean drawTypeAsPrefix = true;
1221
        
1221
1222
        public CsmPaintComponentWrapper() {
1222
        public CsmPaintComponentWrapper() {
1223
            super();        
1223
            super();
1224
        }
1224
        }
1225
        
1225
1226
        public void setCsmComponent(CsmPaintComponent comp) {           
1226
        public void setCsmComponent(CsmPaintComponent comp) {
1227
            this.comp = comp;
1227
            this.comp = comp;
1228
        }
1228
        }
1229
1229
Lines 1235-1254 Link Here
1235
                        ((CsmPaintComponent.FieldPaintComponent)comp).setDrawTypeAsPrefix(true);
1235
                        ((CsmPaintComponent.FieldPaintComponent)comp).setDrawTypeAsPrefix(true);
1236
                    } else if (comp instanceof CsmPaintComponent.MethodPaintComponent) {
1236
                    } else if (comp instanceof CsmPaintComponent.MethodPaintComponent) {
1237
                        ((CsmPaintComponent.MethodPaintComponent)comp).setDrawTypeAsPrefix(true);
1237
                        ((CsmPaintComponent.MethodPaintComponent)comp).setDrawTypeAsPrefix(true);
1238
                    }                
1238
                    }
1239
                }
1239
                }
1240
                comp.draw(g);          
1240
                comp.draw(g);
1241
                if (drawTypeAsPrefix) {
1241
                if (drawTypeAsPrefix) {
1242
                    if (comp instanceof CsmPaintComponent.FieldPaintComponent) {
1242
                    if (comp instanceof CsmPaintComponent.FieldPaintComponent) {
1243
                        ((CsmPaintComponent.FieldPaintComponent)comp).setDrawTypeAsPrefix(false);
1243
                        ((CsmPaintComponent.FieldPaintComponent)comp).setDrawTypeAsPrefix(false);
1244
                    } else if (comp instanceof CsmPaintComponent.MethodPaintComponent) {
1244
                    } else if (comp instanceof CsmPaintComponent.MethodPaintComponent) {
1245
                        ((CsmPaintComponent.MethodPaintComponent)comp).setDrawTypeAsPrefix(false);
1245
                        ((CsmPaintComponent.MethodPaintComponent)comp).setDrawTypeAsPrefix(false);
1246
                    }                
1246
                    }
1247
                }
1247
                }
1248
                setDrawState(comp.getDrawState());
1248
                setDrawState(comp.getDrawState());
1249
            }
1249
            }
1250
        }
1250
        }
1251
        
1251
1252
        @Override
1252
        @Override
1253
        public void setFont(Font font) {
1253
        public void setFont(Font font) {
1254
            super.setFont(font);
1254
            super.setFont(font);
Lines 1256-1288 Link Here
1256
                comp.setFont(font);
1256
                comp.setFont(font);
1257
            }
1257
            }
1258
        }
1258
        }
1259
        
1259
1260
        @Override
1260
        @Override
1261
        public String toString() {
1261
        public String toString() {
1262
            if (comp != null) {
1262
            if (comp != null) {
1263
                return comp.toString();
1263
                return comp.toString();
1264
            }
1264
            }
1265
            return "";
1265
            return "";
1266
        }    
1266
        }
1267
    } 
1267
    }
1268
    
1268
1269
    public static class StringPaintComponent extends CsmPaintComponent {
1269
    public static class StringPaintComponent extends CsmPaintComponent {
1270
1270
1271
        private String str;
1271
        private String str;
1272
1272
1273
        public void setString(String str){
1273
        public void setString(String str){
1274
            this.str = str;            
1274
            this.str = str;
1275
        }
1275
        }
1276
        
1276
1277
        @Override
1277
        @Override
1278
        protected void draw(Graphics g){
1278
        protected void draw(Graphics g){
1279
            drawIcon(g, null);
1279
            drawIcon(g, null);
1280
            drawString(g, str, TYPE_COLOR);
1280
            drawString(g, str, LFCustoms.getTextFgColor());
1281
        }
1281
        }
1282
1282
1283
        @Override
1283
        @Override
1284
        public String toString() {
1284
        public String toString() {
1285
            return str;
1285
            return str;
1286
        }
1286
        }
1287
    }    
1287
    }
1288
}
1288
}
(-)a/core.output2/nbproject/project.xml (+8 lines)
Lines 50-55 Link Here
50
            <code-name-base>org.netbeans.core.output2</code-name-base>
50
            <code-name-base>org.netbeans.core.output2</code-name-base>
51
            <module-dependencies>
51
            <module-dependencies>
52
                <dependency>
52
                <dependency>
53
                    <code-name-base>org.netbeans.swing.plaf</code-name-base>
54
                    <build-prerequisite/>
55
                    <compile-dependency/>
56
                    <run-dependency>
57
                        <specification-version>1.27</specification-version>
58
                    </run-dependency>
59
                </dependency>
60
                <dependency>
53
                    <code-name-base>org.openide.actions</code-name-base>
61
                    <code-name-base>org.openide.actions</code-name-base>
54
                    <build-prerequisite/>
62
                    <build-prerequisite/>
55
                    <compile-dependency/>
63
                    <compile-dependency/>
(-)a/core.output2/src/org/netbeans/core/output2/AbstractLines.java (-7 / +10 lines)
Lines 67-73 Link Here
67
import org.openide.util.Mutex;
67
import org.openide.util.Mutex;
68
import org.openide.windows.IOColors;
68
import org.openide.windows.IOColors;
69
import org.openide.windows.OutputListener;
69
import org.openide.windows.OutputListener;
70
70
import org.netbeans.swing.plaf.LFCustoms;
71
/**
71
/**
72
 * Abstract Lines implementation with handling for getLine wrap calculations, etc.
72
 * Abstract Lines implementation with handling for getLine wrap calculations, etc.
73
 */
73
 */
Lines 313-319 Link Here
313
        longestLineLen = 0;
313
        longestLineLen = 0;
314
        listener = null;
314
        listener = null;
315
        dirty = false;
315
        dirty = false;
316
        curDefColors = DEF_COLORS.clone();
316
        curDefColors = getDefColors().clone();
317
    }
317
    }
318
318
319
    private boolean dirty;
319
    private boolean dirty;
Lines 827-838 Link Here
827
    }
827
    }
828
828
829
    /** initial default colors */
829
    /** initial default colors */
830
    static final Color[] DEF_COLORS;
830
    private static Color[] DEF_COLORS = null;
831
831
832
    /** current default colors */
832
    /** current default colors */
833
    Color[] curDefColors;
833
    Color[] curDefColors;
834
834
835
    static {
835
    static Color[] getDefColors() {
836
        if (DEF_COLORS != null) {
837
            return DEF_COLORS;
838
        }
836
        Color out = UIManager.getColor("nb.output.foreground"); //NOI18N
839
        Color out = UIManager.getColor("nb.output.foreground"); //NOI18N
837
        if (out == null) {
840
        if (out == null) {
838
            out = UIManager.getColor("textText");
841
            out = UIManager.getColor("textText");
Lines 843-854 Link Here
843
846
844
        Color err = UIManager.getColor("nb.output.err.foreground"); //NOI18N
847
        Color err = UIManager.getColor("nb.output.err.foreground"); //NOI18N
845
        if (err == null) {
848
        if (err == null) {
846
            err = new Color(164, 0, 0);
849
            err = LFCustoms.shiftColor(Color.red);
847
        }
850
        }
848
851
849
        Color hyperlink = UIManager.getColor("nb.output.link.foreground"); //NOI18N
852
        Color hyperlink = UIManager.getColor("nb.output.link.foreground"); //NOI18N
850
        if (hyperlink == null) {
853
        if (hyperlink == null) {
851
            hyperlink = Color.BLUE.darker();
854
            hyperlink = LFCustoms.shiftColor(Color.blue);
852
        }
855
        }
853
856
854
        Color hyperlinkImp = UIManager.getColor("nb.output.link.foreground.important"); //NOI18N
857
        Color hyperlinkImp = UIManager.getColor("nb.output.link.foreground.important"); //NOI18N
Lines 856-862 Link Here
856
            hyperlinkImp = hyperlink;
859
            hyperlinkImp = hyperlink;
857
        }
860
        }
858
861
859
        DEF_COLORS = new Color[]{out, err, hyperlink, hyperlinkImp};
862
        return DEF_COLORS = new Color[]{out, err, hyperlink, hyperlinkImp};
860
    }
863
    }
861
864
862
    public void setDefColor(IOColors.OutputType type, Color color) {
865
    public void setDefColor(IOColors.OutputType type, Color color) {
(-)a/core.output2/src/org/netbeans/core/output2/NbIO.java (-27 / +27 lines)
Lines 75-81 Link Here
75
    private Boolean focusTaken = null;
75
    private Boolean focusTaken = null;
76
    private boolean closed = false;
76
    private boolean closed = false;
77
    private final String name;
77
    private final String name;
78
    
78
79
    private Action[] actions;
79
    private Action[] actions;
80
80
81
    private NbWriter out = null;
81
    private NbWriter out = null;
Lines 84-90 Link Here
84
    private IOTabImpl ioTab;
84
    private IOTabImpl ioTab;
85
    private IOColorsImpl ioColors;
85
    private IOColorsImpl ioColors;
86
86
87
    /** Creates a new instance of NbIO 
87
    /** Creates a new instance of NbIO
88
     * @param name The name of the IO
88
     * @param name The name of the IO
89
     * @param toolbarActions an optional set of toolbar actions
89
     * @param toolbarActions an optional set of toolbar actions
90
     * @param iowin parent container accessor (null for default)
90
     * @param iowin parent container accessor (null for default)
Lines 94-105 Link Here
94
        this.actions = toolbarActions;
94
        this.actions = toolbarActions;
95
        this.ioContainer = ioContainer != null ? ioContainer : IOContainer.getDefault();
95
        this.ioContainer = ioContainer != null ? ioContainer : IOContainer.getDefault();
96
    }
96
    }
97
    
97
98
    /** Package private constructor for unit tests */
98
    /** Package private constructor for unit tests */
99
    NbIO (String name) {
99
    NbIO (String name) {
100
        this.name = name;
100
        this.name = name;
101
    }
101
    }
102
    
102
103
    public void closeInputOutput() {
103
    public void closeInputOutput() {
104
        if (Controller.LOG) Controller.log("CLOSE INPUT OUTPUT CALLED FOR " + this);
104
        if (Controller.LOG) Controller.log("CLOSE INPUT OUTPUT CALLED FOR " + this);
105
        if (out != null) {
105
        if (out != null) {
Lines 108-114 Link Here
108
        }
108
        }
109
        post (this, IOEvent.CMD_CLOSE, true);
109
        post (this, IOEvent.CMD_CLOSE, true);
110
    }
110
    }
111
    
111
112
    String getName() {
112
    String getName() {
113
        return name;
113
        return name;
114
    }
114
    }
Lines 139-145 Link Here
139
        }
139
        }
140
        NbIOProvider.dispose(this);
140
        NbIOProvider.dispose(this);
141
    }
141
    }
142
        
142
143
    public OutputWriter getOut() {
143
    public OutputWriter getOut() {
144
        synchronized (this) {
144
        synchronized (this) {
145
            if (out == null) {
145
            if (out == null) {
Lines 149-155 Link Here
149
        }
149
        }
150
        return out;
150
        return out;
151
    }
151
    }
152
    
152
153
    /** Called by the view when polling */
153
    /** Called by the view when polling */
154
    OutWriter out() {
154
    OutWriter out() {
155
        return out == null ? null : out.out();
155
        return out == null ? null : out.out();
Lines 166-203 Link Here
166
    public boolean isErrSeparated() {
166
    public boolean isErrSeparated() {
167
        return false;
167
        return false;
168
    }
168
    }
169
    
169
170
    public boolean isFocusTaken() {
170
    public boolean isFocusTaken() {
171
        return Boolean.TRUE.equals(focusTaken);
171
        return Boolean.TRUE.equals(focusTaken);
172
    }
172
    }
173
    
173
174
    boolean isStreamClosed() {
174
    boolean isStreamClosed() {
175
        return out == null ? true : streamClosed;
175
        return out == null ? true : streamClosed;
176
    }
176
    }
177
    
177
178
    public void select() {
178
    public void select() {
179
        if (Controller.LOG) Controller.log (this + ": select");
179
        if (Controller.LOG) Controller.log (this + ": select");
180
        post (this, IOEvent.CMD_SELECT, true);
180
        post (this, IOEvent.CMD_SELECT, true);
181
    }
181
    }
182
    
182
183
    public void setErrSeparated(boolean value) {
183
    public void setErrSeparated(boolean value) {
184
        //do nothing
184
        //do nothing
185
    }
185
    }
186
    
186
187
    public void setErrVisible(boolean value) {
187
    public void setErrVisible(boolean value) {
188
        //do nothing
188
        //do nothing
189
    }
189
    }
190
    
190
191
    public void setFocusTaken(boolean value) {
191
    public void setFocusTaken(boolean value) {
192
        focusTaken = value ? Boolean.TRUE : Boolean.FALSE;
192
        focusTaken = value ? Boolean.TRUE : Boolean.FALSE;
193
        post (this, IOEvent.CMD_FOCUS_TAKEN, value);
193
        post (this, IOEvent.CMD_FOCUS_TAKEN, value);
194
    }
194
    }
195
    
195
196
    public void setInputVisible(boolean value) {
196
    public void setInputVisible(boolean value) {
197
        if (Controller.LOG) Controller.log(NbIO.this + ": SetInputVisible");
197
        if (Controller.LOG) Controller.log(NbIO.this + ": SetInputVisible");
198
        post (this, IOEvent.CMD_INPUT_VISIBLE, value);
198
        post (this, IOEvent.CMD_INPUT_VISIBLE, value);
199
    }
199
    }
200
    
200
201
    public void setOutputVisible(boolean value) {
201
    public void setOutputVisible(boolean value) {
202
        //do nothing
202
        //do nothing
203
    }
203
    }
Lines 218-224 Link Here
218
    Action[] getToolbarActions() {
218
    Action[] getToolbarActions() {
219
        return actions;
219
        return actions;
220
    }
220
    }
221
    
221
222
    public void reset() {
222
    public void reset() {
223
        if (Controller.LOG) Controller.log (this + ": reset");
223
        if (Controller.LOG) Controller.log (this + ": reset");
224
        closed = false;
224
        closed = false;
Lines 230-236 Link Here
230
        }
230
        }
231
        post (this, IOEvent.CMD_RESET, true);
231
        post (this, IOEvent.CMD_RESET, true);
232
    }
232
    }
233
    
233
234
    private static void post (NbIO io, int command, boolean val) {
234
    private static void post (NbIO io, int command, boolean val) {
235
        IOEvent evt = new IOEvent (io, command, val);
235
        IOEvent evt = new IOEvent (io, command, val);
236
        post (evt);
236
        post (evt);
Lines 251-257 Link Here
251
            eq.postEvent(evt);
251
            eq.postEvent(evt);
252
        }
252
        }
253
    }
253
    }
254
    
254
255
    @Override public String toString() {
255
    @Override public String toString() {
256
        return "NbIO@" + System.identityHashCode(this) + " " + getName();
256
        return "NbIO@" + System.identityHashCode(this) + " " + getName();
257
    }
257
    }
Lines 296-302 Link Here
296
        private StringBuffer buffer() {
296
        private StringBuffer buffer() {
297
            return (StringBuffer) lock;
297
            return (StringBuffer) lock;
298
        }
298
        }
299
        
299
300
        public void pushText (String txt) {
300
        public void pushText (String txt) {
301
            if (Controller.LOG) Controller.log (NbIO.this + ": Input text: " + txt);
301
            if (Controller.LOG) Controller.log (NbIO.this + ": Input text: " + txt);
302
            synchronized (lock) {
302
            synchronized (lock) {
Lines 304-310 Link Here
304
                lock.notifyAll();
304
                lock.notifyAll();
305
            }
305
            }
306
        }
306
        }
307
        
307
308
        private boolean inputClosed = false;
308
        private boolean inputClosed = false;
309
        public void eof() {
309
        public void eof() {
310
            synchronized (lock) {
310
            synchronized (lock) {
Lines 315-321 Link Here
315
                }
315
                }
316
            }
316
            }
317
        }
317
        }
318
        
318
319
        private void checkPristine() throws IOException {
319
        private void checkPristine() throws IOException {
320
            if (SwingUtilities.isEventDispatchThread()) {
320
            if (SwingUtilities.isEventDispatchThread()) {
321
                throw new IOException ("Cannot call read() from the event thread, it will deadlock");
321
                throw new IOException ("Cannot call read() from the event thread, it will deadlock");
Lines 325-331 Link Here
325
                pristine = false;
325
                pristine = false;
326
            }
326
            }
327
        }
327
        }
328
       
328
329
        public int read(char cbuf[], int off, int len) throws IOException {
329
        public int read(char cbuf[], int off, int len) throws IOException {
330
             if (Controller.LOG) Controller.log  (NbIO.this + ":Input read: " + off + " len " + len);
330
             if (Controller.LOG) Controller.log  (NbIO.this + ":Input read: " + off + " len " + len);
331
            checkPristine();
331
            checkPristine();
Lines 348-354 Link Here
348
                return realLen;
348
                return realLen;
349
            }
349
            }
350
        }
350
        }
351
        
351
352
        @Override
352
        @Override
353
        public int read() throws IOException {
353
        public int read() throws IOException {
354
            if (Controller.LOG) Controller.log (NbIO.this + ": Input read one char");
354
            if (Controller.LOG) Controller.log (NbIO.this + ": Input read one char");
Lines 382-388 Link Here
382
                return buffer().length() > 0;
382
                return buffer().length() > 0;
383
            }
383
            }
384
        }
384
        }
385
        
385
386
        @Override
386
        @Override
387
        public long skip(long n) throws IOException {
387
        public long skip(long n) throws IOException {
388
            if (Controller.LOG) Controller.log (NbIO.this + ": Input skip " + n);
388
            if (Controller.LOG) Controller.log (NbIO.this + ": Input skip " + n);
Lines 415-421 Link Here
415
                lock.notifyAll();
415
                lock.notifyAll();
416
            }
416
            }
417
        }
417
        }
418
        
418
419
        public boolean isClosed() {
419
        public boolean isClosed() {
420
            return inputClosed;
420
            return inputClosed;
421
        }
421
        }
Lines 430-436 Link Here
430
    }
430
    }
431
431
432
    Color getColor(IOColors.OutputType type) {
432
    Color getColor(IOColors.OutputType type) {
433
        return ioColors != null ? ioColors.getColor(type) : AbstractLines.DEF_COLORS[type.ordinal()];
433
        return ioColors != null ? ioColors.getColor(type) : AbstractLines.getDefColors()[type.ordinal()];
434
    }
434
    }
435
435
436
    private class IOTabImpl extends IOTab {
436
    private class IOTabImpl extends IOTab {
Lines 521-527 Link Here
521
521
522
        @Override
522
        @Override
523
        protected Color getColor(OutputType type) {
523
        protected Color getColor(OutputType type) {
524
            return clrs[type.ordinal()] != null ? clrs[type.ordinal()] : AbstractLines.DEF_COLORS[type.ordinal()];
524
            return clrs[type.ordinal()] != null ? clrs[type.ordinal()] : AbstractLines.getDefColors()[type.ordinal()];
525
        }
525
        }
526
526
527
        @Override
527
        @Override
(-)a/java.editor/nbproject/project.xml (+8 lines)
Lines 337-342 Link Here
337
                    </run-dependency>
337
                    </run-dependency>
338
                </dependency>
338
                </dependency>
339
                <dependency>
339
                <dependency>
340
                    <code-name-base>org.netbeans.swing.plaf</code-name-base>
341
                    <build-prerequisite/>
342
                    <compile-dependency/>
343
                    <run-dependency>
344
                        <specification-version>1.27</specification-version>
345
                    </run-dependency>
346
                </dependency>
347
                <dependency>
340
                    <code-name-base>org.openide.awt</code-name-base>
348
                    <code-name-base>org.openide.awt</code-name-base>
341
                    <build-prerequisite/>
349
                    <build-prerequisite/>
342
                    <compile-dependency/>
350
                    <compile-dependency/>
(-)a/java.editor/src/org/netbeans/modules/editor/java/JavaCompletionItem.java (-234 / +231 lines)
Lines 97-109 Link Here
97
import org.openide.util.ImageUtilities;
97
import org.openide.util.ImageUtilities;
98
import org.openide.util.NbBundle;
98
import org.openide.util.NbBundle;
99
import org.openide.xml.XMLUtil;
99
import org.openide.xml.XMLUtil;
100
import org.netbeans.swing.plaf.LFCustoms;
100
101
101
/**
102
/**
102
 *
103
 *
103
 * @author Dusan Balek
104
 * @author Dusan Balek
104
 */
105
 */
105
public abstract class JavaCompletionItem implements CompletionItem {
106
public abstract class JavaCompletionItem implements CompletionItem {
106
    
107
107
    protected static int SMART_TYPE = 1000;
108
    protected static int SMART_TYPE = 1000;
108
    private static final String GENERATE_TEXT = NbBundle.getMessage(JavaCompletionItem.class, "generate_Lbl");
109
    private static final String GENERATE_TEXT = NbBundle.getMessage(JavaCompletionItem.class, "generate_Lbl");
109
    private static final Logger LOGGER = Logger.getLogger(JavaCompletionItem.class.getName());
110
    private static final Logger LOGGER = Logger.getLogger(JavaCompletionItem.class.getName());
Lines 111-117 Link Here
111
    public static final JavaCompletionItem createKeywordItem(String kwd, String postfix, int substitutionOffset, boolean smartType) {
112
    public static final JavaCompletionItem createKeywordItem(String kwd, String postfix, int substitutionOffset, boolean smartType) {
112
        return new KeywordItem(kwd, 0, postfix, substitutionOffset, smartType);
113
        return new KeywordItem(kwd, 0, postfix, substitutionOffset, smartType);
113
    }
114
    }
114
    
115
115
    public static final JavaCompletionItem createPackageItem(String pkgFQN, int substitutionOffset, boolean inPackageStatement) {
116
    public static final JavaCompletionItem createPackageItem(String pkgFQN, int substitutionOffset, boolean inPackageStatement) {
116
        return new PackageItem(pkgFQN, substitutionOffset, inPackageStatement);
117
        return new PackageItem(pkgFQN, substitutionOffset, inPackageStatement);
117
    }
118
    }
Lines 130-136 Link Here
130
                throw new IllegalArgumentException("kind=" + elem.getKind());
131
                throw new IllegalArgumentException("kind=" + elem.getKind());
131
        }
132
        }
132
    }
133
    }
133
    
134
134
    public static final JavaCompletionItem createArrayItem(CompilationInfo info, ArrayType type, int substitutionOffset, ReferencesCount referencesCount, Elements elements, WhiteListQuery.WhiteList whiteList) {
135
    public static final JavaCompletionItem createArrayItem(CompilationInfo info, ArrayType type, int substitutionOffset, ReferencesCount referencesCount, Elements elements, WhiteListQuery.WhiteList whiteList) {
135
        int dim = 0;
136
        int dim = 0;
136
        TypeMirror tm = type;
137
        TypeMirror tm = type;
Lines 156-162 Link Here
156
        }
157
        }
157
        throw new IllegalArgumentException("array element kind=" + tm.getKind());
158
        throw new IllegalArgumentException("array element kind=" + tm.getKind());
158
    }
159
    }
159
    
160
160
    public static final JavaCompletionItem createTypeParameterItem(TypeParameterElement elem, int substitutionOffset) {
161
    public static final JavaCompletionItem createTypeParameterItem(TypeParameterElement elem, int substitutionOffset) {
161
        return new TypeParameterItem(elem, substitutionOffset);
162
        return new TypeParameterItem(elem, substitutionOffset);
162
    }
163
    }
Lines 175-181 Link Here
175
                throw new IllegalArgumentException("kind=" + elem.getKind());
176
                throw new IllegalArgumentException("kind=" + elem.getKind());
176
        }
177
        }
177
    }
178
    }
178
    
179
179
    public static final JavaCompletionItem createVariableItem(CompilationInfo info, String varName, int substitutionOffset, boolean newVarName, boolean smartType) {
180
    public static final JavaCompletionItem createVariableItem(CompilationInfo info, String varName, int substitutionOffset, boolean newVarName, boolean smartType) {
180
        return new VariableItem(info, null, varName, substitutionOffset, newVarName, smartType, -1);
181
        return new VariableItem(info, null, varName, substitutionOffset, newVarName, smartType, -1);
181
    }
182
    }
Lines 190-196 Link Here
190
                throw new IllegalArgumentException("kind=" + elem.getKind());
191
                throw new IllegalArgumentException("kind=" + elem.getKind());
191
        }
192
        }
192
    }
193
    }
193
    
194
194
    public static final JavaCompletionItem createThisOrSuperConstructorItem(CompilationInfo info, ExecutableElement elem, ExecutableType type, int substitutionOffset, boolean isDeprecated, String name, WhiteListQuery.WhiteList whiteList) {
195
    public static final JavaCompletionItem createThisOrSuperConstructorItem(CompilationInfo info, ExecutableElement elem, ExecutableType type, int substitutionOffset, boolean isDeprecated, String name, WhiteListQuery.WhiteList whiteList) {
195
        if (elem.getKind() == ElementKind.CONSTRUCTOR)
196
        if (elem.getKind() == ElementKind.CONSTRUCTOR)
196
            return new ConstructorItem(info, elem, type, substitutionOffset, isDeprecated, false, name, whiteList);
197
            return new ConstructorItem(info, elem, type, substitutionOffset, isDeprecated, false, name, whiteList);
Lines 219-225 Link Here
219
    public static final JavaCompletionItem createDefaultConstructorItem(TypeElement elem, int substitutionOffset, boolean smartType) {
220
    public static final JavaCompletionItem createDefaultConstructorItem(TypeElement elem, int substitutionOffset, boolean smartType) {
220
        return new DefaultConstructorItem(elem, substitutionOffset, smartType);
221
        return new DefaultConstructorItem(elem, substitutionOffset, smartType);
221
    }
222
    }
222
    
223
223
    public static final JavaCompletionItem createParametersItem(CompilationInfo info, ExecutableElement elem, ExecutableType type, int substitutionOffset, boolean isDeprecated, int activeParamIndex, String name) {
224
    public static final JavaCompletionItem createParametersItem(CompilationInfo info, ExecutableElement elem, ExecutableType type, int substitutionOffset, boolean isDeprecated, int activeParamIndex, String name) {
224
        return new ParametersItem(info, elem, type, substitutionOffset, isDeprecated, activeParamIndex, name);
225
        return new ParametersItem(info, elem, type, substitutionOffset, isDeprecated, activeParamIndex, name);
225
    }
226
    }
Lines 227-237 Link Here
227
    public static final JavaCompletionItem createAnnotationItem(CompilationInfo info, TypeElement elem, DeclaredType type, int substitutionOffset, ReferencesCount referencesCount, boolean isDeprecated, WhiteListQuery.WhiteList whiteList) {
228
    public static final JavaCompletionItem createAnnotationItem(CompilationInfo info, TypeElement elem, DeclaredType type, int substitutionOffset, ReferencesCount referencesCount, boolean isDeprecated, WhiteListQuery.WhiteList whiteList) {
228
        return new AnnotationItem(info, elem, type, substitutionOffset, referencesCount, isDeprecated, true, whiteList);
229
        return new AnnotationItem(info, elem, type, substitutionOffset, referencesCount, isDeprecated, true, whiteList);
229
    }
230
    }
230
    
231
231
    public static final JavaCompletionItem createAttributeItem(CompilationInfo info, ExecutableElement elem, ExecutableType type, int substitutionOffset, boolean isDeprecated) {
232
    public static final JavaCompletionItem createAttributeItem(CompilationInfo info, ExecutableElement elem, ExecutableType type, int substitutionOffset, boolean isDeprecated) {
232
        return new AttributeItem(info, elem, type, substitutionOffset, isDeprecated);
233
        return new AttributeItem(info, elem, type, substitutionOffset, isDeprecated);
233
    }
234
    }
234
    
235
235
    public static final JavaCompletionItem createAttributeValueItem(CompilationInfo info, String value, String documentation, TypeElement element, int substitutionOffset, ReferencesCount referencesCount, WhiteListQuery.WhiteList whiteList) {
236
    public static final JavaCompletionItem createAttributeValueItem(CompilationInfo info, String value, String documentation, TypeElement element, int substitutionOffset, ReferencesCount referencesCount, WhiteListQuery.WhiteList whiteList) {
236
        return new AttributeValueItem(info, value, documentation, element, substitutionOffset, referencesCount, whiteList);
237
        return new AttributeValueItem(info, value, documentation, element, substitutionOffset, referencesCount, whiteList);
237
    }
238
    }
Lines 337-355 Link Here
337
        defaultAction(component);
338
        defaultAction(component);
338
        return true;
339
        return true;
339
    }
340
    }
340
    
341
341
    public CompletionTask createDocumentationTask() {
342
    public CompletionTask createDocumentationTask() {
342
        return null;
343
        return null;
343
    }
344
    }
344
    
345
345
    public CompletionTask createToolTipTask() {
346
    public CompletionTask createToolTipTask() {
346
        return null;
347
        return null;
347
    }
348
    }
348
    
349
349
    public int getPreferredWidth(Graphics g, Font defaultFont) {
350
    public int getPreferredWidth(Graphics g, Font defaultFont) {
350
        return CompletionUtilities.getPreferredWidth(getLeftHtmlText(), getRightHtmlText(), g, defaultFont);
351
        return CompletionUtilities.getPreferredWidth(getLeftHtmlText(), getRightHtmlText(), g, defaultFont);
351
    }
352
    }
352
    
353
353
    public void render(Graphics g, Font defaultFont, Color defaultColor, Color backgroundColor, int width, int height, boolean selected) {
354
    public void render(Graphics g, Font defaultFont, Color defaultColor, Color backgroundColor, int width, int height, boolean selected) {
354
        CompletionUtilities.renderHtml(getIcon(), getLeftHtmlText(), getRightHtmlText(), g, defaultFont, defaultColor, width, height, selected);
355
        CompletionUtilities.renderHtml(getIcon(), getLeftHtmlText(), getRightHtmlText(), g, defaultFont, defaultColor, width, height, selected);
355
    }
356
    }
Lines 357-367 Link Here
357
    protected ImageIcon getIcon() {
358
    protected ImageIcon getIcon() {
358
        return null;
359
        return null;
359
    }
360
    }
360
    
361
361
    protected String getLeftHtmlText() {
362
    protected String getLeftHtmlText() {
362
        return null;
363
        return null;
363
    }
364
    }
364
    
365
365
    protected String getRightHtmlText() {
366
    protected String getRightHtmlText() {
366
        return null;
367
        return null;
367
    }
368
    }
Lines 431-437 Link Here
431
            }
432
            }
432
        });
433
        });
433
    }
434
    }
434
    
435
435
    static abstract class WhiteListJavaCompletionItem<T extends Element> extends JavaCompletionItem {
436
    static abstract class WhiteListJavaCompletionItem<T extends Element> extends JavaCompletionItem {
436
437
437
        private static final String WARNING = "org/netbeans/modules/java/editor/resources/warning_badge.gif";   //NOI18N
438
        private static final String WARNING = "org/netbeans/modules/java/editor/resources/warning_badge.gif";   //NOI18N
Lines 486-498 Link Here
486
            return super.getIcon();
487
            return super.getIcon();
487
        }
488
        }
488
    }
489
    }
489
    
490
490
    static class KeywordItem extends JavaCompletionItem {
491
    static class KeywordItem extends JavaCompletionItem {
491
        
492
492
        private static final String JAVA_KEYWORD = "org/netbeans/modules/java/editor/resources/javakw_16.png"; //NOI18N
493
        private static final String JAVA_KEYWORD = "org/netbeans/modules/java/editor/resources/javakw_16.png"; //NOI18N
493
        private static final String KEYWORD_COLOR = "<font color=#000099>"; //NOI18N
494
        private static final String KEYWORD_COLOR = "<font color=#000099>"; //NOI18N
494
        private static ImageIcon icon;
495
        private static ImageIcon icon;
495
        
496
496
        private String kwd;
497
        private String kwd;
497
        private int dim;
498
        private int dim;
498
        private String postfix;
499
        private String postfix;
Lines 506-529 Link Here
506
            this.postfix = postfix;
507
            this.postfix = postfix;
507
            this.smartType = smartType;
508
            this.smartType = smartType;
508
        }
509
        }
509
        
510
510
        public int getSortPriority() {
511
        public int getSortPriority() {
511
            return smartType ? 600 - SMART_TYPE : 600;
512
            return smartType ? 600 - SMART_TYPE : 600;
512
        }
513
        }
513
        
514
514
        public CharSequence getSortText() {
515
        public CharSequence getSortText() {
515
            return kwd;
516
            return kwd;
516
        }
517
        }
517
        
518
518
        public CharSequence getInsertPrefix() {
519
        public CharSequence getInsertPrefix() {
519
            return kwd;
520
            return kwd;
520
        }
521
        }
521
        
522
522
        protected ImageIcon getIcon(){
523
        protected ImageIcon getIcon(){
523
            if (icon == null) icon = ImageUtilities.loadImageIcon(JAVA_KEYWORD, false);
524
            if (icon == null) icon = ImageUtilities.loadImageIcon(JAVA_KEYWORD, false);
524
            return icon;            
525
            return icon;
525
        }
526
        }
526
        
527
527
        protected String getLeftHtmlText() {
528
        protected String getLeftHtmlText() {
528
            if (leftText == null) {
529
            if (leftText == null) {
529
                StringBuilder sb = new StringBuilder();
530
                StringBuilder sb = new StringBuilder();
Lines 538-544 Link Here
538
            }
539
            }
539
            return leftText;
540
            return leftText;
540
        }
541
        }
541
        
542
542
        @Override
543
        @Override
543
        protected void substituteText (final JTextComponent c, final int offset, int len, String toAdd, final boolean assignToVar) {
544
        protected void substituteText (final JTextComponent c, final int offset, int len, String toAdd, final boolean assignToVar) {
544
            if (dim == 0) {
545
            if (dim == 0) {
Lines 587-593 Link Here
587
            for(int i = 0; i < dim; i++) {
588
            for(int i = 0; i < dim; i++) {
588
                sb.append("[${PAR"); //NOI18N
589
                sb.append("[${PAR"); //NOI18N
589
                sb.append(cnt++);
590
                sb.append(cnt++);
590
                sb.append(" instanceof=\"int\" default=\"\"}]"); //NOI18N                
591
                sb.append(" instanceof=\"int\" default=\"\"}]"); //NOI18N
591
            }
592
            }
592
            final int length = len;
593
            final int length = len;
593
            doc.runAtomic (new Runnable () {
594
            doc.runAtomic (new Runnable () {
Lines 608-625 Link Here
608
                ctm.createTemporary(sb.append(text).toString()).insert(c);
609
                ctm.createTemporary(sb.append(text).toString()).insert(c);
609
            }
610
            }
610
        }
611
        }
611
    
612
612
        public String toString() {
613
        public String toString() {
613
            return kwd;
614
            return kwd;
614
        }        
615
        }
615
    }
616
    }
616
    
617
617
    static class PackageItem extends JavaCompletionItem {
618
    static class PackageItem extends JavaCompletionItem {
618
        
619
619
        private static final String PACKAGE = "org/netbeans/modules/java/editor/resources/package.gif"; // NOI18N
620
        private static final String PACKAGE = "org/netbeans/modules/java/editor/resources/package.gif"; // NOI18N
620
        private static final String PACKAGE_COLOR = "<font color=#005600>"; //NOI18N
621
        private static final String PACKAGE_COLOR = "<font color=#005600>"; //NOI18N
621
        private static ImageIcon icon;
622
        private static ImageIcon icon;
622
        
623
623
        private boolean inPackageStatement;
624
        private boolean inPackageStatement;
624
        private String simpleName;
625
        private String simpleName;
625
        private String sortText;
626
        private String sortText;
Lines 632-655 Link Here
632
            this.simpleName = idx < 0 ? pkgFQN : pkgFQN.substring(idx + 1);
633
            this.simpleName = idx < 0 ? pkgFQN : pkgFQN.substring(idx + 1);
633
            this.sortText = this.simpleName + "#" + pkgFQN; //NOI18N
634
            this.sortText = this.simpleName + "#" + pkgFQN; //NOI18N
634
        }
635
        }
635
        
636
636
        public int getSortPriority() {
637
        public int getSortPriority() {
637
            return 900;
638
            return 900;
638
        }
639
        }
639
        
640
640
        public CharSequence getSortText() {
641
        public CharSequence getSortText() {
641
            return sortText;
642
            return sortText;
642
        }
643
        }
643
        
644
644
        public CharSequence getInsertPrefix() {
645
        public CharSequence getInsertPrefix() {
645
            return simpleName;
646
            return simpleName;
646
        }
647
        }
647
        
648
648
        protected ImageIcon getIcon(){
649
        protected ImageIcon getIcon(){
649
            if (icon == null) icon = ImageUtilities.loadImageIcon(PACKAGE, false);
650
            if (icon == null) icon = ImageUtilities.loadImageIcon(PACKAGE, false);
650
            return icon;            
651
            return icon;
651
        }
652
        }
652
        
653
653
        protected String getLeftHtmlText() {
654
        protected String getLeftHtmlText() {
654
            if (leftText == null) {
655
            if (leftText == null) {
655
                StringBuilder sb = new StringBuilder();
656
                StringBuilder sb = new StringBuilder();
Lines 675-693 Link Here
675
        protected void substituteText(JTextComponent c, int offset, int len, String toAdd, final boolean assingToVar) {
676
        protected void substituteText(JTextComponent c, int offset, int len, String toAdd, final boolean assingToVar) {
676
            super.substituteText(c, offset, len, inPackageStatement || toAdd != null ? toAdd : ".", assingToVar); //NOI18N
677
            super.substituteText(c, offset, len, inPackageStatement || toAdd != null ? toAdd : ".", assingToVar); //NOI18N
677
        }
678
        }
678
        
679
679
        public String toString() {
680
        public String toString() {
680
            return simpleName;
681
            return simpleName;
681
        }        
682
        }
682
    }
683
    }
683
684
684
    static class ClassItem extends WhiteListJavaCompletionItem<TypeElement> {
685
    static class ClassItem extends WhiteListJavaCompletionItem<TypeElement> {
685
        
686
686
        private static final String CLASS = "org/netbeans/modules/editor/resources/completion/class_16.png"; //NOI18N
687
        private static final String CLASS = "org/netbeans/modules/editor/resources/completion/class_16.png"; //NOI18N
687
        private static final String CLASS_COLOR = "<font color=#560000>"; //NOI18N
688
        private static final String CLASS_COLOR = "<font color=#560000>"; //NOI18N
688
        private static final String PKG_COLOR = "<font color=#808080>"; //NOI18N
689
        private static final String PKG_COLOR = "<font color=#808080>"; //NOI18N
689
        private static ImageIcon icon;
690
        private static ImageIcon icon;
690
        
691
691
        protected TypeMirrorHandle<DeclaredType> typeHandle;
692
        protected TypeMirrorHandle<DeclaredType> typeHandle;
692
        private int dim;
693
        private int dim;
693
        private boolean isDeprecated;
694
        private boolean isDeprecated;
Lines 701-707 Link Here
701
        private CharSequence sortText;
702
        private CharSequence sortText;
702
        private String leftText;
703
        private String leftText;
703
        private boolean autoImport;
704
        private boolean autoImport;
704
        
705
705
        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) {
706
        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) {
706
            super(substitutionOffset, ElementHandle.create(elem), whiteList);
707
            super(substitutionOffset, ElementHandle.create(elem), whiteList);
707
            this.typeHandle = TypeMirrorHandle.create(type);
708
            this.typeHandle = TypeMirrorHandle.create(type);
Lines 722-736 Link Here
722
            }
723
            }
723
            this.autoImport = autoImport;
724
            this.autoImport = autoImport;
724
        }
725
        }
725
        
726
726
        public int getSortPriority() {
727
        public int getSortPriority() {
727
            return smartType ? 800 - SMART_TYPE : 800;
728
            return smartType ? 800 - SMART_TYPE : 800;
728
        }
729
        }
729
        
730
730
        public CharSequence getSortText() {
731
        public CharSequence getSortText() {
731
            return sortText;
732
            return sortText;
732
        }
733
        }
733
        
734
734
        public CharSequence getInsertPrefix() {
735
        public CharSequence getInsertPrefix() {
735
            return simpleName;
736
            return simpleName;
736
        }
737
        }
Lines 738-744 Link Here
738
        public boolean instantSubstitution(JTextComponent component) {
739
        public boolean instantSubstitution(JTextComponent component) {
739
            return false;
740
            return false;
740
        }
741
        }
741
    
742
742
        public CompletionTask createDocumentationTask() {
743
        public CompletionTask createDocumentationTask() {
743
            return typeHandle.getKind() == TypeKind.DECLARED ? JavaCompletionProvider.createDocTask(ElementHandle.from(typeHandle)) : null;
744
            return typeHandle.getKind() == TypeKind.DECLARED ? JavaCompletionProvider.createDocTask(ElementHandle.from(typeHandle)) : null;
744
        }
745
        }
Lines 771-777 Link Here
771
            }
772
            }
772
            return leftText;
773
            return leftText;
773
        }
774
        }
774
        
775
775
        protected String getColor() {
776
        protected String getColor() {
776
            return CLASS_COLOR;
777
            return CLASS_COLOR;
777
        }
778
        }
Lines 857-863 Link Here
857
                                    Iterator<? extends TypeMirror> tas = type != null ? type.getTypeArguments().iterator() : null;
858
                                    Iterator<? extends TypeMirror> tas = type != null ? type.getTypeArguments().iterator() : null;
858
                                    if (tas != null && tas.hasNext()) {
859
                                    if (tas != null && tas.hasNext()) {
859
                                        sb.append('<'); //NOI18N
860
                                        sb.append('<'); //NOI18N
860
                                        if (!insideNew || elem.getModifiers().contains(Modifier.ABSTRACT) 
861
                                        if (!insideNew || elem.getModifiers().contains(Modifier.ABSTRACT)
861
                                            || controller.getSourceVersion().compareTo(SourceVersion.RELEASE_7) < 0) {
862
                                            || controller.getSourceVersion().compareTo(SourceVersion.RELEASE_7) < 0) {
862
                                            while (tas.hasNext()) {
863
                                            while (tas.hasNext()) {
863
                                                TypeMirror ta = tas.next();
864
                                                TypeMirror ta = tas.next();
Lines 1012-1076 Link Here
1012
                }
1013
                }
1013
            }, NbBundle.getMessage(JavaCompletionItem.class, "JCI-import_resolve"), cancel, false); //NOI18N
1014
            }, NbBundle.getMessage(JavaCompletionItem.class, "JCI-import_resolve"), cancel, false); //NOI18N
1014
        }
1015
        }
1015
        
1016
1016
        public String toString() {
1017
        public String toString() {
1017
            return simpleName;
1018
            return simpleName;
1018
        }
1019
        }
1019
    }
1020
    }
1020
    
1021
1021
    static class InterfaceItem extends ClassItem {
1022
    static class InterfaceItem extends ClassItem {
1022
        
1023
1023
        private static final String INTERFACE = "org/netbeans/modules/editor/resources/completion/interface.png"; // NOI18N
1024
        private static final String INTERFACE = "org/netbeans/modules/editor/resources/completion/interface.png"; // NOI18N
1024
        private static final String INTERFACE_COLOR = "<font color=#404040>"; //NOI18N
1025
        private static final String INTERFACE_COLOR = "<font color=#404040>"; //NOI18N
1025
        private static ImageIcon icon;
1026
        private static ImageIcon icon;
1026
        
1027
1027
        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) {
1028
        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) {
1028
            super(info, elem, type, dim, substitutionOffset, referencesCount, isDeprecated, insideNew, addTypeVars, addSimpleName, smartType, autoImport, whiteList);
1029
            super(info, elem, type, dim, substitutionOffset, referencesCount, isDeprecated, insideNew, addTypeVars, addSimpleName, smartType, autoImport, whiteList);
1029
        }
1030
        }
1030
1031
1031
        protected ImageIcon getBaseIcon(){
1032
        protected ImageIcon getBaseIcon(){
1032
            if (icon == null) icon = ImageUtilities.loadImageIcon(INTERFACE, false);
1033
            if (icon == null) icon = ImageUtilities.loadImageIcon(INTERFACE, false);
1033
            return icon;            
1034
            return icon;
1034
        }
1035
        }
1035
        
1036
1036
        protected String getColor() {
1037
        protected String getColor() {
1037
            return INTERFACE_COLOR;
1038
            return INTERFACE_COLOR;
1038
        }
1039
        }
1039
    }
1040
    }
1040
1041
1041
    static class EnumItem extends ClassItem {
1042
    static class EnumItem extends ClassItem {
1042
        
1043
1043
        private static final String ENUM = "org/netbeans/modules/editor/resources/completion/enum.png"; // NOI18N
1044
        private static final String ENUM = "org/netbeans/modules/editor/resources/completion/enum.png"; // NOI18N
1044
        private static ImageIcon icon;
1045
        private static ImageIcon icon;
1045
        
1046
1046
        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) {
1047
        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) {
1047
            super(info, elem, type, dim, substitutionOffset, referencesCount, isDeprecated, insideNew, false, addSimpleName, smartType, autoImport, whiteList);
1048
            super(info, elem, type, dim, substitutionOffset, referencesCount, isDeprecated, insideNew, false, addSimpleName, smartType, autoImport, whiteList);
1048
        }
1049
        }
1049
1050
1050
        protected ImageIcon getBaseIcon(){
1051
        protected ImageIcon getBaseIcon(){
1051
            if (icon == null) icon = ImageUtilities.loadImageIcon(ENUM, false);
1052
            if (icon == null) icon = ImageUtilities.loadImageIcon(ENUM, false);
1052
            return icon;            
1053
            return icon;
1053
        }
1054
        }
1054
    }
1055
    }
1055
    
1056
1056
    static class AnnotationTypeItem extends ClassItem {
1057
    static class AnnotationTypeItem extends ClassItem {
1057
        
1058
1058
        private static final String ANNOTATION = "org/netbeans/modules/editor/resources/completion/annotation_type.png"; // NOI18N
1059
        private static final String ANNOTATION = "org/netbeans/modules/editor/resources/completion/annotation_type.png"; // NOI18N
1059
        private static ImageIcon icon;
1060
        private static ImageIcon icon;
1060
        
1061
1061
        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) {
1062
        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) {
1062
            super(info, elem, type, dim, substitutionOffset, referencesCount, isDeprecated, insideNew, false, addSimpleName, smartType, autoImport, whiteList);
1063
            super(info, elem, type, dim, substitutionOffset, referencesCount, isDeprecated, insideNew, false, addSimpleName, smartType, autoImport, whiteList);
1063
        }
1064
        }
1064
1065
1065
        protected ImageIcon getBaseIcon(){
1066
        protected ImageIcon getBaseIcon(){
1066
            if (icon == null) icon = ImageUtilities.loadImageIcon(ANNOTATION, false);
1067
            if (icon == null) icon = ImageUtilities.loadImageIcon(ANNOTATION, false);
1067
            return icon;            
1068
            return icon;
1068
        }
1069
        }
1069
    }
1070
    }
1070
    
1071
1071
    static class TypeParameterItem extends JavaCompletionItem {
1072
    static class TypeParameterItem extends JavaCompletionItem {
1072
        
1073
1073
        private static final String TYPE_PARAMETER_COLOR = "<font color=#000000>"; //NOI18N
1074
1074
1075
        private String simpleName;
1075
        private String simpleName;
1076
        private String leftText;
1076
        private String leftText;
Lines 1079-1110 Link Here
1079
            super(substitutionOffset);
1079
            super(substitutionOffset);
1080
            this.simpleName = elem.getSimpleName().toString();
1080
            this.simpleName = elem.getSimpleName().toString();
1081
        }
1081
        }
1082
        
1082
1083
        public int getSortPriority() {
1083
        public int getSortPriority() {
1084
            return 700;
1084
            return 700;
1085
        }
1085
        }
1086
        
1086
1087
        public CharSequence getSortText() {
1087
        public CharSequence getSortText() {
1088
            return simpleName;
1088
            return simpleName;
1089
        }
1089
        }
1090
        
1090
1091
        public CharSequence getInsertPrefix() {
1091
        public CharSequence getInsertPrefix() {
1092
            return simpleName;
1092
            return simpleName;
1093
        }
1093
        }
1094
        
1094
1095
        protected String getLeftHtmlText() {
1095
        protected String getLeftHtmlText() {
1096
            if (leftText == null)
1096
            if (leftText == null)
1097
                leftText = TYPE_PARAMETER_COLOR + simpleName + COLOR_END;
1097
                leftText = LFCustoms.getTextFgColorHTML() + simpleName + COLOR_END;
1098
            return leftText;
1098
            return leftText;
1099
        }
1099
        }
1100
        
1100
1101
        public String toString() {
1101
        public String toString() {
1102
            return simpleName;
1102
            return simpleName;
1103
        }        
1103
        }
1104
    }
1104
    }
1105
1105
1106
    static class VariableItem extends JavaCompletionItem {
1106
    static class VariableItem extends JavaCompletionItem {
1107
        
1107
1108
        private static final String LOCAL_VARIABLE = "org/netbeans/modules/editor/resources/completion/localVariable.gif"; //NOI18N
1108
        private static final String LOCAL_VARIABLE = "org/netbeans/modules/editor/resources/completion/localVariable.gif"; //NOI18N
1109
        private static final String PARAMETER_COLOR = "<font color=#00007c>"; //NOI18N
1109
        private static final String PARAMETER_COLOR = "<font color=#00007c>"; //NOI18N
1110
        private static ImageIcon icon;
1110
        private static ImageIcon icon;
Lines 1117-1123 Link Here
1117
        private String rightText;
1117
        private String rightText;
1118
        private int assignToVarPos;
1118
        private int assignToVarPos;
1119
        private String assignToVarText;
1119
        private String assignToVarText;
1120
        
1120
1121
        private VariableItem(CompilationInfo info, TypeMirror type, String varName, int substitutionOffset, boolean newVarName, boolean smartType, int assignToVarPos) {
1121
        private VariableItem(CompilationInfo info, TypeMirror type, String varName, int substitutionOffset, boolean newVarName, boolean smartType, int assignToVarPos) {
1122
            super(substitutionOffset);
1122
            super(substitutionOffset);
1123
            this.varName = varName;
1123
            this.varName = varName;
Lines 1127-1141 Link Here
1127
            this.assignToVarPos = assignToVarPos;
1127
            this.assignToVarPos = assignToVarPos;
1128
            this.assignToVarText = assignToVarPos < 0 ? null : getAssignToVarText(info, type, varName);
1128
            this.assignToVarText = assignToVarPos < 0 ? null : getAssignToVarText(info, type, varName);
1129
        }
1129
        }
1130
        
1130
1131
        public int getSortPriority() {
1131
        public int getSortPriority() {
1132
            return smartType ? 200 - SMART_TYPE : 200;
1132
            return smartType ? 200 - SMART_TYPE : 200;
1133
        }
1133
        }
1134
        
1134
1135
        public CharSequence getSortText() {
1135
        public CharSequence getSortText() {
1136
            return varName;
1136
            return varName;
1137
        }
1137
        }
1138
        
1138
1139
        public CharSequence getInsertPrefix() {
1139
        public CharSequence getInsertPrefix() {
1140
            return varName;
1140
            return varName;
1141
        }
1141
        }
Lines 1145-1160 Link Here
1145
                leftText = PARAMETER_COLOR + BOLD + varName + BOLD_END + COLOR_END;
1145
                leftText = PARAMETER_COLOR + BOLD + varName + BOLD_END + COLOR_END;
1146
            return leftText;
1146
            return leftText;
1147
        }
1147
        }
1148
        
1148
1149
        protected String getRightHtmlText() {
1149
        protected String getRightHtmlText() {
1150
            if (rightText == null)
1150
            if (rightText == null)
1151
                rightText = escape(typeName);
1151
                rightText = escape(typeName);
1152
            return rightText;
1152
            return rightText;
1153
        }
1153
        }
1154
        
1154
1155
        protected ImageIcon getIcon(){
1155
        protected ImageIcon getIcon(){
1156
            if (icon == null) icon = ImageUtilities.loadImageIcon(LOCAL_VARIABLE, false);
1156
            if (icon == null) icon = ImageUtilities.loadImageIcon(LOCAL_VARIABLE, false);
1157
            return icon;            
1157
            return icon;
1158
        }
1158
        }
1159
1159
1160
        @Override
1160
        @Override
Lines 1193-1210 Link Here
1193
   }
1193
   }
1194
1194
1195
    static class FieldItem extends WhiteListJavaCompletionItem<VariableElement> {
1195
    static class FieldItem extends WhiteListJavaCompletionItem<VariableElement> {
1196
        
1196
1197
        private static final String FIELD_PUBLIC = "org/netbeans/modules/editor/resources/completion/field_16.png"; //NOI18N
1197
        private static final String FIELD_PUBLIC = "org/netbeans/modules/editor/resources/completion/field_16.png"; //NOI18N
1198
        private static final String FIELD_PROTECTED = "org/netbeans/modules/editor/resources/completion/field_protected_16.png"; //NOI18N
1198
        private static final String FIELD_PROTECTED = "org/netbeans/modules/editor/resources/completion/field_protected_16.png"; //NOI18N
1199
        private static final String FIELD_PACKAGE = "org/netbeans/modules/editor/resources/completion/field_package_private_16.png"; //NOI18N
1199
        private static final String FIELD_PACKAGE = "org/netbeans/modules/editor/resources/completion/field_package_private_16.png"; //NOI18N
1200
        private static final String FIELD_PRIVATE = "org/netbeans/modules/editor/resources/completion/field_private_16.png"; //NOI18N        
1200
        private static final String FIELD_PRIVATE = "org/netbeans/modules/editor/resources/completion/field_private_16.png"; //NOI18N
1201
        private static final String FIELD_ST_PUBLIC = "org/netbeans/modules/editor/resources/completion/field_static_16.png"; //NOI18N
1201
        private static final String FIELD_ST_PUBLIC = "org/netbeans/modules/editor/resources/completion/field_static_16.png"; //NOI18N
1202
        private static final String FIELD_ST_PROTECTED = "org/netbeans/modules/editor/resources/completion/field_static_protected_16.png"; //NOI18N
1202
        private static final String FIELD_ST_PROTECTED = "org/netbeans/modules/editor/resources/completion/field_static_protected_16.png"; //NOI18N
1203
        private static final String FIELD_ST_PACKAGE = "org/netbeans/modules/editor/resources/completion/field_static_package_private_16.png"; //NOI18N
1203
        private static final String FIELD_ST_PACKAGE = "org/netbeans/modules/editor/resources/completion/field_static_package_private_16.png"; //NOI18N
1204
        private static final String FIELD_ST_PRIVATE = "org/netbeans/modules/editor/resources/completion/field_static_private_16.png"; //NOI18N
1204
        private static final String FIELD_ST_PRIVATE = "org/netbeans/modules/editor/resources/completion/field_static_private_16.png"; //NOI18N
1205
        private static final String FIELD_COLOR = "<font color=#008618>"; //NOI18N
1205
        private static final String FIELD_COLOR = "<font color=#008618>"; //NOI18N
1206
        private static ImageIcon icon[][] = new ImageIcon[2][4];
1206
        private static ImageIcon icon[][] = new ImageIcon[2][4];
1207
        
1207
1208
        private boolean isInherited;
1208
        private boolean isInherited;
1209
        private boolean isDeprecated;
1209
        private boolean isDeprecated;
1210
        private boolean smartType;
1210
        private boolean smartType;
Lines 1217-1223 Link Here
1217
        private CharSequence enclSortText;
1217
        private CharSequence enclSortText;
1218
        private int assignToVarPos;
1218
        private int assignToVarPos;
1219
        private String assignToVarText;
1219
        private String assignToVarText;
1220
        
1220
1221
        private FieldItem(CompilationInfo info, VariableElement elem, TypeMirror type, int substitutionOffset, ReferencesCount referencesCount, boolean isInherited, boolean isDeprecated, boolean smartType, int assignToVarPos, WhiteListQuery.WhiteList whiteList) {
1221
        private FieldItem(CompilationInfo info, VariableElement elem, TypeMirror type, int substitutionOffset, ReferencesCount referencesCount, boolean isInherited, boolean isDeprecated, boolean smartType, int assignToVarPos, WhiteListQuery.WhiteList whiteList) {
1222
            super(substitutionOffset, ElementHandle.create(elem), whiteList);
1222
            super(substitutionOffset, ElementHandle.create(elem), whiteList);
1223
            this.isInherited = isInherited;
1223
            this.isInherited = isInherited;
Lines 1235-1249 Link Here
1235
            this.assignToVarPos = assignToVarPos;
1235
            this.assignToVarPos = assignToVarPos;
1236
            this.assignToVarText = assignToVarPos < 0 ? null : getAssignToVarText(info, type, this.simpleName);
1236
            this.assignToVarText = assignToVarPos < 0 ? null : getAssignToVarText(info, type, this.simpleName);
1237
        }
1237
        }
1238
        
1238
1239
        public int getSortPriority() {
1239
        public int getSortPriority() {
1240
            return smartType ? 300 - SMART_TYPE : 300;
1240
            return smartType ? 300 - SMART_TYPE : 300;
1241
        }
1241
        }
1242
        
1242
1243
        public CharSequence getSortText() {
1243
        public CharSequence getSortText() {
1244
            return simpleName + "#" + enclSortText; //NOI18N
1244
            return simpleName + "#" + enclSortText; //NOI18N
1245
        }
1245
        }
1246
        
1246
1247
        public CharSequence getInsertPrefix() {
1247
        public CharSequence getInsertPrefix() {
1248
            return simpleName;
1248
            return simpleName;
1249
        }
1249
        }
Lines 1276-1288 Link Here
1276
                rightText = escape(typeName);
1276
                rightText = escape(typeName);
1277
            return rightText;
1277
            return rightText;
1278
        }
1278
        }
1279
        
1279
1280
        protected ImageIcon getBaseIcon(){
1280
        protected ImageIcon getBaseIcon(){
1281
            int level = getProtectionLevel(modifiers);
1281
            int level = getProtectionLevel(modifiers);
1282
            boolean isStatic = modifiers.contains(Modifier.STATIC);
1282
            boolean isStatic = modifiers.contains(Modifier.STATIC);
1283
            ImageIcon cachedIcon = icon[isStatic?1:0][level];
1283
            ImageIcon cachedIcon = icon[isStatic?1:0][level];
1284
            if (cachedIcon != null)
1284
            if (cachedIcon != null)
1285
                return cachedIcon;            
1285
                return cachedIcon;
1286
1286
1287
            String iconPath = FIELD_PUBLIC;
1287
            String iconPath = FIELD_PUBLIC;
1288
            if (isStatic) {
1288
            if (isStatic) {
Lines 1324-1330 Link Here
1324
            }
1324
            }
1325
            ImageIcon newIcon = ImageUtilities.loadImageIcon(iconPath, false);
1325
            ImageIcon newIcon = ImageUtilities.loadImageIcon(iconPath, false);
1326
            icon[isStatic?1:0][level] = newIcon;
1326
            icon[isStatic?1:0][level] = newIcon;
1327
            return newIcon;            
1327
            return newIcon;
1328
        }
1328
        }
1329
1329
1330
        @Override
1330
        @Override
Lines 1379-1385 Link Here
1379
                        tmp.insert(c);
1379
                        tmp.insert(c);
1380
                    }
1380
                    }
1381
                }
1381
                }
1382
            } catch (BadLocationException ble) {                
1382
            } catch (BadLocationException ble) {
1383
            }
1383
            }
1384
        }
1384
        }
1385
1385
Lines 1395-1412 Link Here
1395
            return sb.toString();
1395
            return sb.toString();
1396
        }
1396
        }
1397
    }
1397
    }
1398
    
1398
1399
    static class MethodItem extends WhiteListJavaCompletionItem<ExecutableElement> {
1399
    static class MethodItem extends WhiteListJavaCompletionItem<ExecutableElement> {
1400
        
1400
1401
        private static final String METHOD_PUBLIC = "org/netbeans/modules/editor/resources/completion/method_16.png"; //NOI18N
1401
        private static final String METHOD_PUBLIC = "org/netbeans/modules/editor/resources/completion/method_16.png"; //NOI18N
1402
        private static final String METHOD_PROTECTED = "org/netbeans/modules/editor/resources/completion/method_protected_16.png"; //NOI18N
1402
        private static final String METHOD_PROTECTED = "org/netbeans/modules/editor/resources/completion/method_protected_16.png"; //NOI18N
1403
        private static final String METHOD_PACKAGE = "org/netbeans/modules/editor/resources/completion/method_package_private_16.png"; //NOI18N
1403
        private static final String METHOD_PACKAGE = "org/netbeans/modules/editor/resources/completion/method_package_private_16.png"; //NOI18N
1404
        private static final String METHOD_PRIVATE = "org/netbeans/modules/editor/resources/completion/method_private_16.png"; //NOI18N        
1404
        private static final String METHOD_PRIVATE = "org/netbeans/modules/editor/resources/completion/method_private_16.png"; //NOI18N
1405
        private static final String METHOD_ST_PUBLIC = "org/netbeans/modules/editor/resources/completion/method_static_16.png"; //NOI18N
1405
        private static final String METHOD_ST_PUBLIC = "org/netbeans/modules/editor/resources/completion/method_static_16.png"; //NOI18N
1406
        private static final String METHOD_ST_PROTECTED = "org/netbeans/modules/editor/resources/completion/method_static_protected_16.png"; //NOI18N
1406
        private static final String METHOD_ST_PROTECTED = "org/netbeans/modules/editor/resources/completion/method_static_protected_16.png"; //NOI18N
1407
        private static final String METHOD_ST_PRIVATE = "org/netbeans/modules/editor/resources/completion/method_static_private_16.png"; //NOI18N
1407
        private static final String METHOD_ST_PRIVATE = "org/netbeans/modules/editor/resources/completion/method_static_private_16.png"; //NOI18N
1408
        private static final String METHOD_ST_PACKAGE = "org/netbeans/modules/editor/resources/completion/method_static_package_private_16.png"; //NOI18N
1408
        private static final String METHOD_ST_PACKAGE = "org/netbeans/modules/editor/resources/completion/method_static_package_private_16.png"; //NOI18N
1409
        private static final String METHOD_COLOR = "<font color=#000000>"; //NOI18N
1410
        private static final String PARAMETER_NAME_COLOR = "<font color=#a06001>"; //NOI18N
1409
        private static final String PARAMETER_NAME_COLOR = "<font color=#a06001>"; //NOI18N
1411
        private static ImageIcon icon[][] = new ImageIcon[2][4];
1410
        private static ImageIcon icon[][] = new ImageIcon[2][4];
1412
1411
Lines 1426-1432 Link Here
1426
        private CharSequence enclSortText;
1425
        private CharSequence enclSortText;
1427
        private int assignToVarPos;
1426
        private int assignToVarPos;
1428
        private String assignToVarText;
1427
        private String assignToVarText;
1429
        
1428
1430
        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) {
1429
        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) {
1431
            super(substitutionOffset, ElementHandle.create(elem), whiteList);
1430
            super(substitutionOffset, ElementHandle.create(elem), whiteList);
1432
            this.isInherited = isInherited;
1431
            this.isInherited = isInherited;
Lines 1456-1466 Link Here
1456
            this.assignToVarPos = type.getReturnType().getKind() == TypeKind.VOID ? -1 : assignToVarPos;
1455
            this.assignToVarPos = type.getReturnType().getKind() == TypeKind.VOID ? -1 : assignToVarPos;
1457
            this.assignToVarText = this.assignToVarPos < 0 ? null : getAssignToVarText(info, type.getReturnType(), this.simpleName);
1456
            this.assignToVarText = this.assignToVarPos < 0 ? null : getAssignToVarText(info, type.getReturnType(), this.simpleName);
1458
        }
1457
        }
1459
        
1458
1460
        public int getSortPriority() {
1459
        public int getSortPriority() {
1461
            return smartType ? 500 - SMART_TYPE : 500;
1460
            return smartType ? 500 - SMART_TYPE : 500;
1462
        }
1461
        }
1463
        
1462
1464
        public CharSequence getSortText() {
1463
        public CharSequence getSortText() {
1465
            if (sortText == null) {
1464
            if (sortText == null) {
1466
                StringBuilder sortParams = new StringBuilder();
1465
                StringBuilder sortParams = new StringBuilder();
Lines 1479-1493 Link Here
1479
            }
1478
            }
1480
            return sortText;
1479
            return sortText;
1481
        }
1480
        }
1482
        
1481
1483
        public CharSequence getInsertPrefix() {
1482
        public CharSequence getInsertPrefix() {
1484
            return simpleName;
1483
            return simpleName;
1485
        }
1484
        }
1486
        
1485
1487
        protected String getLeftHtmlText() {
1486
        protected String getLeftHtmlText() {
1488
            if (leftText == null) {
1487
            if (leftText == null) {
1489
                StringBuilder lText = new StringBuilder();
1488
                StringBuilder lText = new StringBuilder();
1490
                lText.append(METHOD_COLOR);
1489
                lText.append(LFCustoms.getTextFgColorHTML());
1491
                if (!isInherited)
1490
                if (!isInherited)
1492
                    lText.append(BOLD);
1491
                    lText.append(BOLD);
1493
                if (isDeprecated || isBlackListed())
1492
                if (isDeprecated || isBlackListed())
Lines 1521-1527 Link Here
1521
                rightText = escape(typeName);
1520
                rightText = escape(typeName);
1522
            return rightText;
1521
            return rightText;
1523
        }
1522
        }
1524
        
1523
1525
        public CompletionTask createDocumentationTask() {
1524
        public CompletionTask createDocumentationTask() {
1526
            return JavaCompletionProvider.createDocTask(getElementHandle());
1525
            return JavaCompletionProvider.createDocTask(getElementHandle());
1527
        }
1526
        }
Lines 1532-1539 Link Here
1532
            ImageIcon cachedIcon = icon[isStatic?1:0][level];
1531
            ImageIcon cachedIcon = icon[isStatic?1:0][level];
1533
            if (cachedIcon != null)
1532
            if (cachedIcon != null)
1534
                return cachedIcon;
1533
                return cachedIcon;
1535
            
1534
1536
            String iconPath = METHOD_PUBLIC;            
1535
            String iconPath = METHOD_PUBLIC;
1537
            if (isStatic) {
1536
            if (isStatic) {
1538
                switch (level) {
1537
                switch (level) {
1539
                    case PRIVATE_LEVEL:
1538
                    case PRIVATE_LEVEL:
Lines 1573-1581 Link Here
1573
            }
1572
            }
1574
            ImageIcon newIcon = ImageUtilities.loadImageIcon(iconPath, false);
1573
            ImageIcon newIcon = ImageUtilities.loadImageIcon(iconPath, false);
1575
            icon[isStatic?1:0][level] = newIcon;
1574
            icon[isStatic?1:0][level] = newIcon;
1576
            return newIcon;            
1575
            return newIcon;
1577
        }
1576
        }
1578
        
1577
1579
        @Override
1578
        @Override
1580
        protected void substituteText(final JTextComponent c, final int offset, int len, String toAdd, final boolean assignToVar) {
1579
        protected void substituteText(final JTextComponent c, final int offset, int len, String toAdd, final boolean assignToVar) {
1581
            try {
1580
            try {
Lines 1613-1619 Link Here
1613
                                                AutoImport.resolveImport(controller, controller.getTreeUtilities().pathFor(embeddedOffset), ee.getEnclosingElement().asType());
1612
                                                AutoImport.resolveImport(controller, controller.getTreeUtilities().pathFor(embeddedOffset), ee.getEnclosingElement().asType());
1614
                                        }
1613
                                        }
1615
                                    });
1614
                                    });
1616
                                } catch (ParseException pe) {                    
1615
                                } catch (ParseException pe) {
1617
                                }
1616
                                }
1618
                            }
1617
                            }
1619
                        }, NbBundle.getMessage(JavaCompletionItem.class, "JCI-import_resolve"), cancel, false); //NOI18N
1618
                        }, NbBundle.getMessage(JavaCompletionItem.class, "JCI-import_resolve"), cancel, false); //NOI18N
Lines 1686-1692 Link Here
1686
                            Position semiPosition = semiPos > -1 ? doc.createPosition(semiPos) : null;
1685
                            Position semiPosition = semiPos > -1 ? doc.createPosition(semiPos) : null;
1687
                            String textToReplace = doc.getText(pos.getOffset(), length);
1686
                            String textToReplace = doc.getText(pos.getOffset(), length);
1688
                            if (textToReplace.contentEquals(getInsertPrefix() + sb.toString())) {
1687
                            if (textToReplace.contentEquals(getInsertPrefix() + sb.toString())) {
1689
                                c.setCaretPosition(c.getCaretPosition() + sb.length());                            
1688
                                c.setCaretPosition(c.getCaretPosition() + sb.length());
1690
                                sb.delete(0, sb.length());
1689
                                sb.delete(0, sb.length());
1691
                            } else {
1690
                            } else {
1692
                                if (length > 0)
1691
                                if (length > 0)
Lines 1724-1730 Link Here
1724
                                                AutoImport.resolveImport(controller, controller.getTreeUtilities().pathFor(embeddedOffset), ee.getEnclosingElement().asType());
1723
                                                AutoImport.resolveImport(controller, controller.getTreeUtilities().pathFor(embeddedOffset), ee.getEnclosingElement().asType());
1725
                                        }
1724
                                        }
1726
                                    });
1725
                                    });
1727
                                } catch (ParseException pe) {                    
1726
                                } catch (ParseException pe) {
1728
                                }
1727
                                }
1729
                            }
1728
                            }
1730
                        }, NbBundle.getMessage(JavaCompletionItem.class, "JCI-import_resolve"), cancel, false); //NOI18N
1729
                        }, NbBundle.getMessage(JavaCompletionItem.class, "JCI-import_resolve"), cancel, false); //NOI18N
Lines 1770-1776 Link Here
1770
                }
1769
                }
1771
            } catch (BadLocationException ex) {
1770
            } catch (BadLocationException ex) {
1772
            }
1771
            }
1773
        }        
1772
        }
1774
1773
1775
        public String toString() {
1774
        public String toString() {
1776
            StringBuilder sb = new StringBuilder();
1775
            StringBuilder sb = new StringBuilder();
Lines 1794-1822 Link Here
1794
            sb.append(')');
1793
            sb.append(')');
1795
            return sb.toString();
1794
            return sb.toString();
1796
        }
1795
        }
1797
    }    
1796
    }
1798
1797
1799
    static class OverrideMethodItem extends MethodItem {
1798
    static class OverrideMethodItem extends MethodItem {
1800
        
1799
1801
        private static final String IMPL_BADGE_PATH = "org/netbeans/modules/java/editor/resources/implement_badge.png";
1800
        private static final String IMPL_BADGE_PATH = "org/netbeans/modules/java/editor/resources/implement_badge.png";
1802
        private static final String OVRD_BADGE_PATH = "org/netbeans/modules/java/editor/resources/override_badge.png";
1801
        private static final String OVRD_BADGE_PATH = "org/netbeans/modules/java/editor/resources/override_badge.png";
1803
        
1802
1804
        private static final String OVERRIDE_TEXT = NbBundle.getMessage(JavaCompletionItem.class, "override_Lbl");
1803
        private static final String OVERRIDE_TEXT = NbBundle.getMessage(JavaCompletionItem.class, "override_Lbl");
1805
        private static final String IMPLEMENT_TEXT = NbBundle.getMessage(JavaCompletionItem.class, "implement_Lbl");
1804
        private static final String IMPLEMENT_TEXT = NbBundle.getMessage(JavaCompletionItem.class, "implement_Lbl");
1806
        
1805
1807
        private static ImageIcon implementBadge = ImageUtilities.loadImageIcon(IMPL_BADGE_PATH, false);
1806
        private static ImageIcon implementBadge = ImageUtilities.loadImageIcon(IMPL_BADGE_PATH, false);
1808
        private static ImageIcon overrideBadge = ImageUtilities.loadImageIcon(OVRD_BADGE_PATH, false);
1807
        private static ImageIcon overrideBadge = ImageUtilities.loadImageIcon(OVRD_BADGE_PATH, false);
1809
        private static ImageIcon merged_icon[][] = new ImageIcon[2][4];
1808
        private static ImageIcon merged_icon[][] = new ImageIcon[2][4];
1810
        
1809
1811
        
1810
1812
        private boolean implement;
1811
        private boolean implement;
1813
        private String leftText;
1812
        private String leftText;
1814
        
1813
1815
        private OverrideMethodItem(CompilationInfo info, ExecutableElement elem, ExecutableType type, int substitutionOffset, boolean implement, WhiteListQuery.WhiteList whiteList) {
1814
        private OverrideMethodItem(CompilationInfo info, ExecutableElement elem, ExecutableType type, int substitutionOffset, boolean implement, WhiteListQuery.WhiteList whiteList) {
1816
            super(info, elem, type, substitutionOffset, null, false, false, false, false, false, -1, whiteList);
1815
            super(info, elem, type, substitutionOffset, null, false, false, false, false, false, -1, whiteList);
1817
            this.implement = implement;
1816
            this.implement = implement;
1818
        }
1817
        }
1819
        
1818
1820
        protected String getLeftHtmlText() {
1819
        protected String getLeftHtmlText() {
1821
            if (leftText == null) {
1820
            if (leftText == null) {
1822
                leftText = super.getLeftHtmlText() + " - ";
1821
                leftText = super.getLeftHtmlText() + " - ";
Lines 1824-1830 Link Here
1824
            }
1823
            }
1825
            return leftText;
1824
            return leftText;
1826
        }
1825
        }
1827
        
1826
1828
        @Override
1827
        @Override
1829
        protected ImageIcon getBaseIcon() {
1828
        protected ImageIcon getBaseIcon() {
1830
            int level = getProtectionLevel(modifiers);
1829
            int level = getProtectionLevel(modifiers);
Lines 1832-1849 Link Here
1832
            if ( merged != null ) {
1831
            if ( merged != null ) {
1833
                return merged;
1832
                return merged;
1834
            }
1833
            }
1835
            ImageIcon superIcon = super.getBaseIcon();                        
1834
            ImageIcon superIcon = super.getBaseIcon();
1836
            merged = new ImageIcon( ImageUtilities.mergeImages(
1835
            merged = new ImageIcon( ImageUtilities.mergeImages(
1837
                superIcon.getImage(), 
1836
                superIcon.getImage(),
1838
                implement ? implementBadge.getImage() : overrideBadge.getImage(), 
1837
                implement ? implementBadge.getImage() : overrideBadge.getImage(),
1839
                16 - 8, 
1838
                16 - 8,
1840
                16 - 8) );
1839
                16 - 8) );
1841
            
1840
1842
            merged_icon[implement? 0 : 1][level] = merged;
1841
            merged_icon[implement? 0 : 1][level] = merged;
1843
            return merged;
1842
            return merged;
1844
        }
1843
        }
1845
1844
1846
        
1845
1847
        @Override
1846
        @Override
1848
        protected void substituteText(final JTextComponent c, final int offset, final int len, String toAdd, final boolean assignToVar) {
1847
        protected void substituteText(final JTextComponent c, final int offset, final int len, String toAdd, final boolean assignToVar) {
1849
            final BaseDocument doc = (BaseDocument)c.getDocument();
1848
            final BaseDocument doc = (BaseDocument)c.getDocument();
Lines 1912-1927 Link Here
1912
    }
1911
    }
1913
1912
1914
    static class GetterSetterMethodItem extends JavaCompletionItem {
1913
    static class GetterSetterMethodItem extends JavaCompletionItem {
1915
        
1914
1916
        private static final String METHOD_PUBLIC = "org/netbeans/modules/editor/resources/completion/method_16.png"; //NOI18N
1915
        private static final String METHOD_PUBLIC = "org/netbeans/modules/editor/resources/completion/method_16.png"; //NOI18N
1917
        private static final String GETTER_BADGE_PATH = "org/netbeans/modules/java/editor/resources/getter_badge.png"; //NOI18N
1916
        private static final String GETTER_BADGE_PATH = "org/netbeans/modules/java/editor/resources/getter_badge.png"; //NOI18N
1918
        private static final String SETTER_BADGE_PATH = "org/netbeans/modules/java/editor/resources/setter_badge.png"; //NOI18N
1917
        private static final String SETTER_BADGE_PATH = "org/netbeans/modules/java/editor/resources/setter_badge.png"; //NOI18N
1919
        private static final String METHOD_COLOR = "<font color=#000000>"; //NOI18N
1920
        private static final String PARAMETER_NAME_COLOR = "<font color=#a06001>"; //NOI18N
1918
        private static final String PARAMETER_NAME_COLOR = "<font color=#a06001>"; //NOI18N
1921
        
1919
1922
        private static ImageIcon superIcon;
1920
        private static ImageIcon superIcon;
1923
        private static ImageIcon[] merged_icons = new ImageIcon[2];
1921
        private static ImageIcon[] merged_icons = new ImageIcon[2];
1924
        
1922
1925
        protected ElementHandle<VariableElement> elementHandle;
1923
        protected ElementHandle<VariableElement> elementHandle;
1926
        private boolean setter;
1924
        private boolean setter;
1927
        private String simpleName;
1925
        private String simpleName;
Lines 1930-1939 Link Here
1930
        private String sortText;
1928
        private String sortText;
1931
        private String leftText;
1929
        private String leftText;
1932
        private String rightText;
1930
        private String rightText;
1933
        
1931
1934
        private GetterSetterMethodItem(CompilationInfo info, VariableElement elem, TypeMirror type, int substitutionOffset, boolean setter) {
1932
        private GetterSetterMethodItem(CompilationInfo info, VariableElement elem, TypeMirror type, int substitutionOffset, boolean setter) {
1935
            super(substitutionOffset);
1933
            super(substitutionOffset);
1936
            this.elementHandle = ElementHandle.create(elem);            
1934
            this.elementHandle = ElementHandle.create(elem);
1937
            this.setter = setter;
1935
            this.setter = setter;
1938
            this.simpleName = elem.getSimpleName().toString();
1936
            this.simpleName = elem.getSimpleName().toString();
1939
            if (setter)
1937
            if (setter)
Lines 1942-1952 Link Here
1942
                this.name = (elem.asType().getKind() == TypeKind.BOOLEAN ? "is" : "get") + GeneratorUtils.getCapitalizedName(simpleName); //NOI18N
1940
                this.name = (elem.asType().getKind() == TypeKind.BOOLEAN ? "is" : "get") + GeneratorUtils.getCapitalizedName(simpleName); //NOI18N
1943
            this.typeName = Utilities.getTypeName(info, type, false).toString();
1941
            this.typeName = Utilities.getTypeName(info, type, false).toString();
1944
        }
1942
        }
1945
        
1943
1946
        public int getSortPriority() {
1944
        public int getSortPriority() {
1947
            return 500;
1945
            return 500;
1948
        }
1946
        }
1949
        
1947
1950
        public CharSequence getSortText() {
1948
        public CharSequence getSortText() {
1951
            if (sortText == null) {
1949
            if (sortText == null) {
1952
                StringBuilder sortParams = new StringBuilder();
1950
                StringBuilder sortParams = new StringBuilder();
Lines 1958-1973 Link Here
1958
            }
1956
            }
1959
            return sortText;
1957
            return sortText;
1960
        }
1958
        }
1961
        
1959
1962
        public CharSequence getInsertPrefix() {
1960
        public CharSequence getInsertPrefix() {
1963
            return name;
1961
            return name;
1964
        }
1962
        }
1965
        
1963
1966
        @Override
1964
        @Override
1967
        protected String getLeftHtmlText() {
1965
        protected String getLeftHtmlText() {
1968
            if (leftText == null) {
1966
            if (leftText == null) {
1969
                StringBuilder lText = new StringBuilder();
1967
                StringBuilder lText = new StringBuilder();
1970
                lText.append(METHOD_COLOR);
1968
                lText.append(LFCustoms.getTextFgColorHTML());
1971
                lText.append(BOLD);
1969
                lText.append(BOLD);
1972
                lText.append(name);
1970
                lText.append(name);
1973
                lText.append(BOLD_END);
1971
                lText.append(BOLD_END);
Lines 1986-1999 Link Here
1986
            }
1984
            }
1987
            return leftText;
1985
            return leftText;
1988
        }
1986
        }
1989
        
1987
1990
        @Override
1988
        @Override
1991
        protected String getRightHtmlText() {
1989
        protected String getRightHtmlText() {
1992
            if (rightText == null)
1990
            if (rightText == null)
1993
                rightText = setter ? "void" : escape(typeName);
1991
                rightText = setter ? "void" : escape(typeName);
1994
            return rightText;
1992
            return rightText;
1995
        }
1993
        }
1996
        
1994
1997
        @Override
1995
        @Override
1998
        protected ImageIcon getIcon() {
1996
        protected ImageIcon getIcon() {
1999
            if (merged_icons[setter ? 1 : 0] == null) {
1997
            if (merged_icons[setter ? 1 : 0] == null) {
Lines 2011-2017 Link Here
2011
            }
2009
            }
2012
            return merged_icons[setter ? 1 : 0];
2010
            return merged_icons[setter ? 1 : 0];
2013
        }
2011
        }
2014
        
2012
2015
        @Override
2013
        @Override
2016
        protected void substituteText(final JTextComponent c, final int offset, final int len, String toAdd, final boolean assignToVar) {
2014
        protected void substituteText(final JTextComponent c, final int offset, final int len, String toAdd, final boolean assignToVar) {
2017
            final BaseDocument doc = (BaseDocument)c.getDocument();
2015
            final BaseDocument doc = (BaseDocument)c.getDocument();
Lines 2038-2044 Link Here
2038
                    public void run(ResultIterator resultIterator) throws Exception {
2036
                    public void run(ResultIterator resultIterator) throws Exception {
2039
                        WorkingCopy copy = WorkingCopy.get(resultIterator.getParserResult());
2037
                        WorkingCopy copy = WorkingCopy.get(resultIterator.getParserResult());
2040
                        copy.toPhase(Phase.ELEMENTS_RESOLVED);
2038
                        copy.toPhase(Phase.ELEMENTS_RESOLVED);
2041
                        VariableElement ve = elementHandle.resolve(copy);                        
2039
                        VariableElement ve = elementHandle.resolve(copy);
2042
                        if (ve == null)
2040
                        if (ve == null)
2043
                            return;
2041
                            return;
2044
                        final int embeddedOffset = copy.getSnapshot().getEmbeddedOffset(pos.getOffset());
2042
                        final int embeddedOffset = copy.getSnapshot().getEmbeddedOffset(pos.getOffset());
Lines 2094-2100 Link Here
2094
    }
2092
    }
2095
2093
2096
    static class ConstructorItem extends WhiteListJavaCompletionItem<ExecutableElement> {
2094
    static class ConstructorItem extends WhiteListJavaCompletionItem<ExecutableElement> {
2097
        
2095
2098
        private static final String CONSTRUCTOR_PUBLIC = "org/netbeans/modules/editor/resources/completion/constructor_16.png"; //NOI18N
2096
        private static final String CONSTRUCTOR_PUBLIC = "org/netbeans/modules/editor/resources/completion/constructor_16.png"; //NOI18N
2099
        private static final String CONSTRUCTOR_PROTECTED = "org/netbeans/modules/editor/resources/completion/constructor_protected_16.png"; //NOI18N
2097
        private static final String CONSTRUCTOR_PROTECTED = "org/netbeans/modules/editor/resources/completion/constructor_protected_16.png"; //NOI18N
2100
        private static final String CONSTRUCTOR_PACKAGE = "org/netbeans/modules/editor/resources/completion/constructor_package_private_16.png"; //NOI18N
2098
        private static final String CONSTRUCTOR_PACKAGE = "org/netbeans/modules/editor/resources/completion/constructor_package_private_16.png"; //NOI18N
Lines 2112-2118 Link Here
2112
        private boolean insertName;
2110
        private boolean insertName;
2113
        private String sortText;
2111
        private String sortText;
2114
        private String leftText;
2112
        private String leftText;
2115
        
2113
2116
        private ConstructorItem(CompilationInfo info, ExecutableElement elem, ExecutableType type, int substitutionOffset, boolean isDeprecated, boolean smartType, String name, WhiteListQuery.WhiteList whiteList) {
2114
        private ConstructorItem(CompilationInfo info, ExecutableElement elem, ExecutableType type, int substitutionOffset, boolean isDeprecated, boolean smartType, String name, WhiteListQuery.WhiteList whiteList) {
2117
            super(substitutionOffset, ElementHandle.create(elem), whiteList);
2115
            super(substitutionOffset, ElementHandle.create(elem), whiteList);
2118
            this.isDeprecated = isDeprecated;
2116
            this.isDeprecated = isDeprecated;
Lines 2131-2141 Link Here
2131
            }
2129
            }
2132
            this.isAbstract = !insertName && elem.getEnclosingElement().getModifiers().contains(Modifier.ABSTRACT);
2130
            this.isAbstract = !insertName && elem.getEnclosingElement().getModifiers().contains(Modifier.ABSTRACT);
2133
        }
2131
        }
2134
        
2132
2135
        public int getSortPriority() {
2133
        public int getSortPriority() {
2136
            return insertName ? 550 : smartType ? 650 - SMART_TYPE : 650;
2134
            return insertName ? 550 : smartType ? 650 - SMART_TYPE : 650;
2137
        }
2135
        }
2138
        
2136
2139
        public CharSequence getSortText() {
2137
        public CharSequence getSortText() {
2140
            if (sortText == null) {
2138
            if (sortText == null) {
2141
                StringBuilder sortParams = new StringBuilder();
2139
                StringBuilder sortParams = new StringBuilder();
Lines 2154-2164 Link Here
2154
            }
2152
            }
2155
            return sortText;
2153
            return sortText;
2156
        }
2154
        }
2157
        
2155
2158
        public CharSequence getInsertPrefix() {
2156
        public CharSequence getInsertPrefix() {
2159
            return simpleName;
2157
            return simpleName;
2160
        }        
2158
        }
2161
        
2159
2162
        protected String getLeftHtmlText() {
2160
        protected String getLeftHtmlText() {
2163
            if (leftText == null) {
2161
            if (leftText == null) {
2164
                StringBuilder lText = new StringBuilder();
2162
                StringBuilder lText = new StringBuilder();
Lines 2199-2206 Link Here
2199
            ImageIcon cachedIcon = icon[level];
2197
            ImageIcon cachedIcon = icon[level];
2200
            if (cachedIcon != null)
2198
            if (cachedIcon != null)
2201
                return cachedIcon;
2199
                return cachedIcon;
2202
            
2200
2203
            String iconPath = CONSTRUCTOR_PUBLIC;            
2201
            String iconPath = CONSTRUCTOR_PUBLIC;
2204
            switch (level) {
2202
            switch (level) {
2205
                case PRIVATE_LEVEL:
2203
                case PRIVATE_LEVEL:
2206
                    iconPath = CONSTRUCTOR_PRIVATE;
2204
                    iconPath = CONSTRUCTOR_PRIVATE;
Lines 2220-2228 Link Here
2220
            }
2218
            }
2221
            ImageIcon newIcon = ImageUtilities.loadImageIcon(iconPath, false);
2219
            ImageIcon newIcon = ImageUtilities.loadImageIcon(iconPath, false);
2222
            icon[level] = newIcon;
2220
            icon[level] = newIcon;
2223
            return newIcon;            
2221
            return newIcon;
2224
        }
2222
        }
2225
        
2223
2226
        @Override
2224
        @Override
2227
        protected void substituteText(final JTextComponent c, int offset, int len, String toAdd, final boolean assignToVar) {
2225
        protected void substituteText(final JTextComponent c, int offset, int len, String toAdd, final boolean assignToVar) {
2228
            if (!insertName) {
2226
            if (!insertName) {
Lines 2315-2325 Link Here
2315
                            TreePath path = copy.getTreeUtilities().pathFor(embeddedOffset);
2313
                            TreePath path = copy.getTreeUtilities().pathFor(embeddedOffset);
2316
                            while (path.getLeaf() != path.getCompilationUnit()) {
2314
                            while (path.getLeaf() != path.getCompilationUnit()) {
2317
                                Tree tree = path.getLeaf();
2315
                                Tree tree = path.getLeaf();
2318
                                Tree parentTree = path.getParentPath().getLeaf();                                
2316
                                Tree parentTree = path.getParentPath().getLeaf();
2319
                                if (parentTree.getKind() == Tree.Kind.NEW_CLASS && TreeUtilities.CLASS_TREE_KINDS.contains(tree.getKind())) {
2317
                                if (parentTree.getKind() == Tree.Kind.NEW_CLASS && TreeUtilities.CLASS_TREE_KINDS.contains(tree.getKind())) {
2320
                                    GeneratorUtils.generateAllAbstractMethodImplementations(copy, path);
2318
                                    GeneratorUtils.generateAllAbstractMethodImplementations(copy, path);
2321
                                    break;
2319
                                    break;
2322
                                }                                
2320
                                }
2323
                                path = path.getParentPath();
2321
                                path = path.getParentPath();
2324
                            }
2322
                            }
2325
                        }
2323
                        }
Lines 2364-2370 Link Here
2364
                    Completion.get().showToolTip();
2362
                    Completion.get().showToolTip();
2365
                }
2363
                }
2366
            }
2364
            }
2367
        }        
2365
        }
2368
2366
2369
        public String toString() {
2367
        public String toString() {
2370
            StringBuilder sb = new StringBuilder();
2368
            StringBuilder sb = new StringBuilder();
Lines 2387-2399 Link Here
2387
            return sb.toString();
2385
            return sb.toString();
2388
        }
2386
        }
2389
    }
2387
    }
2390
    
2388
2391
    static class DefaultConstructorItem extends JavaCompletionItem {
2389
    static class DefaultConstructorItem extends JavaCompletionItem {
2392
        
2390
2393
        private static final String CONSTRUCTOR = "org/netbeans/modules/java/editor/resources/new_constructor_16.png"; //NOI18N
2391
        private static final String CONSTRUCTOR = "org/netbeans/modules/java/editor/resources/new_constructor_16.png"; //NOI18N
2394
        private static final String CONSTRUCTOR_COLOR = "<font color=#b28b00>"; //NOI18N
2392
        private static final String CONSTRUCTOR_COLOR = "<font color=#b28b00>"; //NOI18N
2395
        private static ImageIcon icon;        
2393
        private static ImageIcon icon;
2396
        
2394
2397
        private boolean smartType;
2395
        private boolean smartType;
2398
        private String simpleName;
2396
        private String simpleName;
2399
        private boolean isAbstract;
2397
        private boolean isAbstract;
Lines 2420-2435 Link Here
2420
                sortText = simpleName + "#0#"; //NOI18N
2418
                sortText = simpleName + "#0#"; //NOI18N
2421
            return sortText;
2419
            return sortText;
2422
        }
2420
        }
2423
        
2421
2424
        protected String getLeftHtmlText() {
2422
        protected String getLeftHtmlText() {
2425
            if (leftText == null)
2423
            if (leftText == null)
2426
                leftText = CONSTRUCTOR_COLOR + simpleName + "()" + COLOR_END; //NOI18N
2424
                leftText = CONSTRUCTOR_COLOR + simpleName + "()" + COLOR_END; //NOI18N
2427
            return leftText;
2425
            return leftText;
2428
        }        
2426
        }
2429
2427
2430
        protected ImageIcon getIcon() {
2428
        protected ImageIcon getIcon() {
2431
            if (icon == null) icon = ImageUtilities.loadImageIcon(CONSTRUCTOR, false);
2429
            if (icon == null) icon = ImageUtilities.loadImageIcon(CONSTRUCTOR, false);
2432
            return icon;            
2430
            return icon;
2433
        }
2431
        }
2434
2432
2435
        @Override
2433
        @Override
Lines 2517-2527 Link Here
2517
                            TreePath path = copy.getTreeUtilities().pathFor(embeddedOffset);
2515
                            TreePath path = copy.getTreeUtilities().pathFor(embeddedOffset);
2518
                            while (path.getLeaf() != path.getCompilationUnit()) {
2516
                            while (path.getLeaf() != path.getCompilationUnit()) {
2519
                                Tree tree = path.getLeaf();
2517
                                Tree tree = path.getLeaf();
2520
                                Tree parentTree = path.getParentPath().getLeaf();                                
2518
                                Tree parentTree = path.getParentPath().getLeaf();
2521
                                if (parentTree.getKind() == Tree.Kind.NEW_CLASS && TreeUtilities.CLASS_TREE_KINDS.contains(tree.getKind())) {
2519
                                if (parentTree.getKind() == Tree.Kind.NEW_CLASS && TreeUtilities.CLASS_TREE_KINDS.contains(tree.getKind())) {
2522
                                    GeneratorUtils.generateAllAbstractMethodImplementations(copy, path);
2520
                                    GeneratorUtils.generateAllAbstractMethodImplementations(copy, path);
2523
                                    break;
2521
                                    break;
2524
                                }                                
2522
                                }
2525
                                path = path.getParentPath();
2523
                                path = path.getParentPath();
2526
                            }
2524
                            }
2527
                        }
2525
                        }
Lines 2532-2547 Link Here
2532
                }
2530
                }
2533
            }
2531
            }
2534
        }
2532
        }
2535
        
2533
2536
        public String toString() {
2534
        public String toString() {
2537
            return simpleName + "()";
2535
            return simpleName + "()";
2538
        }        
2536
        }
2539
    }
2537
    }
2540
    
2538
2541
    static class ParametersItem extends JavaCompletionItem {
2539
    static class ParametersItem extends JavaCompletionItem {
2542
        
2540
2543
        private static final String PARAMETERS_COLOR = "<font color=#808080>"; //NOI18N
2541
        private static final String PARAMETERS_COLOR = "<font color=#808080>"; //NOI18N
2544
        private static final String ACTIVE_PARAMETER_COLOR = "<font color=#000000>"; //NOI18N
2545
2542
2546
        protected ElementHandle<ExecutableElement> elementHandle;
2543
        protected ElementHandle<ExecutableElement> elementHandle;
2547
        private boolean isDeprecated;
2544
        private boolean isDeprecated;
Lines 2598-2604 Link Here
2598
        public CharSequence getInsertPrefix() {
2595
        public CharSequence getInsertPrefix() {
2599
            return ""; //NOI18N
2596
            return ""; //NOI18N
2600
        }
2597
        }
2601
        
2598
2602
        protected String getLeftHtmlText() {
2599
        protected String getLeftHtmlText() {
2603
            if (leftText == null) {
2600
            if (leftText == null) {
2604
                StringBuilder lText = new StringBuilder();
2601
                StringBuilder lText = new StringBuilder();
Lines 2612-2625 Link Here
2612
                for (int i = 0; i < params.size(); i++) {
2609
                for (int i = 0; i < params.size(); i++) {
2613
                    ParamDesc paramDesc = params.get(i);
2610
                    ParamDesc paramDesc = params.get(i);
2614
                    if (i == activeParamsIndex)
2611
                    if (i == activeParamsIndex)
2615
                        lText.append(COLOR_END).append(ACTIVE_PARAMETER_COLOR).append(BOLD);
2612
                        lText.append(COLOR_END).append(LFCustoms.getTextFgColorHTML()).append(BOLD);
2616
                    lText.append(escape(paramDesc.typeName));
2613
                    lText.append(escape(paramDesc.typeName));
2617
                    lText.append(' ');
2614
                    lText.append(' ');
2618
                    lText.append(paramDesc.name);
2615
                    lText.append(paramDesc.name);
2619
                    if (i < params.size() - 1)
2616
                    if (i < params.size() - 1)
2620
                        lText.append(", "); //NOI18N
2617
                        lText.append(", "); //NOI18N
2621
                    else
2618
                    else
2622
                        lText.append(BOLD_END).append(COLOR_END).append(PARAMETERS_COLOR);                        
2619
                        lText.append(BOLD_END).append(COLOR_END).append(PARAMETERS_COLOR);
2623
                }
2620
                }
2624
                lText.append(')');
2621
                lText.append(')');
2625
                lText.append(COLOR_END);
2622
                lText.append(COLOR_END);
Lines 2627-2639 Link Here
2627
            }
2624
            }
2628
            return leftText;
2625
            return leftText;
2629
        }
2626
        }
2630
        
2627
2631
        protected String getRightHtmlText() {
2628
        protected String getRightHtmlText() {
2632
            if (rightText == null)
2629
            if (rightText == null)
2633
                rightText = PARAMETERS_COLOR + escape(typeName) + COLOR_END;
2630
                rightText = PARAMETERS_COLOR + escape(typeName) + COLOR_END;
2634
            return rightText;
2631
            return rightText;
2635
        }
2632
        }
2636
        
2633
2637
        public CompletionTask createDocumentationTask() {
2634
        public CompletionTask createDocumentationTask() {
2638
            return JavaCompletionProvider.createDocTask(elementHandle);
2635
            return JavaCompletionProvider.createDocTask(elementHandle);
2639
        }
2636
        }
Lines 2641-2654 Link Here
2641
        public boolean instantSubstitution(JTextComponent component) {
2638
        public boolean instantSubstitution(JTextComponent component) {
2642
            return false;
2639
            return false;
2643
        }
2640
        }
2644
        
2641
2645
        protected void substituteText(final JTextComponent c, final int offset, int len, String toAdd, final boolean assignToVar) {
2642
        protected void substituteText(final JTextComponent c, final int offset, int len, String toAdd, final boolean assignToVar) {
2646
            String add = ")"; //NOI18N
2643
            String add = ")"; //NOI18N
2647
            if (toAdd != null && !add.startsWith(toAdd))
2644
            if (toAdd != null && !add.startsWith(toAdd))
2648
                add += toAdd;
2645
                add += toAdd;
2649
            if (params.isEmpty()) {
2646
            if (params.isEmpty()) {
2650
                super.substituteText(c, offset, len, add, assignToVar);
2647
                super.substituteText(c, offset, len, add, assignToVar);
2651
            } else {                
2648
            } else {
2652
                final BaseDocument doc = (BaseDocument)c.getDocument();
2649
                final BaseDocument doc = (BaseDocument)c.getDocument();
2653
                String text = ""; //NOI18N
2650
                String text = ""; //NOI18N
2654
                final int semiPos = add.endsWith(";") ? findPositionForSemicolon(c) : -2; //NOI18N
2651
                final int semiPos = add.endsWith(";") ? findPositionForSemicolon(c) : -2; //NOI18N
Lines 2719-2725 Link Here
2719
                    Completion.get().showToolTip();
2716
                    Completion.get().showToolTip();
2720
                }
2717
                }
2721
            }
2718
            }
2722
        }        
2719
        }
2723
2720
2724
        public String toString() {
2721
        public String toString() {
2725
            StringBuilder sb = new StringBuilder();
2722
            StringBuilder sb = new StringBuilder();
Lines 2740-2748 Link Here
2740
            return sb.toString();
2737
            return sb.toString();
2741
        }
2738
        }
2742
    }
2739
    }
2743
    
2740
2744
    static class AnnotationItem extends AnnotationTypeItem {
2741
    static class AnnotationItem extends AnnotationTypeItem {
2745
        
2742
2746
        private AnnotationItem(CompilationInfo info, TypeElement elem, DeclaredType type, int substitutionOffset, ReferencesCount referencesCount, boolean isDeprecated, boolean smartType, WhiteListQuery.WhiteList whiteList) {
2743
        private AnnotationItem(CompilationInfo info, TypeElement elem, DeclaredType type, int substitutionOffset, ReferencesCount referencesCount, boolean isDeprecated, boolean smartType, WhiteListQuery.WhiteList whiteList) {
2747
            super(info, elem, type, 0, substitutionOffset, referencesCount, isDeprecated, false, false, smartType, false, whiteList);
2744
            super(info, elem, type, 0, substitutionOffset, referencesCount, isDeprecated, false, false, smartType, false, whiteList);
2748
        }
2745
        }
Lines 2832-2844 Link Here
2832
            }, NbBundle.getMessage(JavaCompletionItem.class, "JCI-import_resolve"), cancel, false); //NOI18N
2829
            }, NbBundle.getMessage(JavaCompletionItem.class, "JCI-import_resolve"), cancel, false); //NOI18N
2833
        }
2830
        }
2834
    }
2831
    }
2835
    
2832
2836
    static class AttributeItem extends JavaCompletionItem {
2833
    static class AttributeItem extends JavaCompletionItem {
2837
        
2834
2838
        private static final String ATTRIBUTE = "org/netbeans/modules/java/editor/resources/attribute_16.png"; // NOI18N
2835
        private static final String ATTRIBUTE = "org/netbeans/modules/java/editor/resources/attribute_16.png"; // NOI18N
2839
        private static final String ATTRIBUTE_COLOR = "<font color=#404040>"; //NOI18N
2836
        private static final String ATTRIBUTE_COLOR = "<font color=#404040>"; //NOI18N
2840
        private static ImageIcon icon;
2837
        private static ImageIcon icon;
2841
        
2838
2842
        private ElementHandle<ExecutableElement> elementHandle;
2839
        private ElementHandle<ExecutableElement> elementHandle;
2843
        private boolean isDeprecated;
2840
        private boolean isDeprecated;
2844
        private String simpleName;
2841
        private String simpleName;
Lines 2856-2870 Link Here
2856
            AnnotationValue value = elem.getDefaultValue();
2853
            AnnotationValue value = elem.getDefaultValue();
2857
            this.defaultValue = value != null ? value.toString() : null;
2854
            this.defaultValue = value != null ? value.toString() : null;
2858
        }
2855
        }
2859
        
2856
2860
        public int getSortPriority() {
2857
        public int getSortPriority() {
2861
            return 100;
2858
            return 100;
2862
        }
2859
        }
2863
        
2860
2864
        public CharSequence getSortText() {
2861
        public CharSequence getSortText() {
2865
            return simpleName;
2862
            return simpleName;
2866
        }
2863
        }
2867
        
2864
2868
        public CharSequence getInsertPrefix() {
2865
        public CharSequence getInsertPrefix() {
2869
            return simpleName;
2866
            return simpleName;
2870
        }
2867
        }
Lines 2875-2883 Link Here
2875
2872
2876
        protected ImageIcon getIcon(){
2873
        protected ImageIcon getIcon(){
2877
            if (icon == null) icon = ImageUtilities.loadImageIcon(ATTRIBUTE, false);
2874
            if (icon == null) icon = ImageUtilities.loadImageIcon(ATTRIBUTE, false);
2878
            return icon;            
2875
            return icon;
2879
        }
2876
        }
2880
        
2877
2881
        protected String getLeftHtmlText() {
2878
        protected String getLeftHtmlText() {
2882
            if (leftText == null) {
2879
            if (leftText == null) {
2883
                StringBuilder sb = new StringBuilder();
2880
                StringBuilder sb = new StringBuilder();
Lines 2900-2912 Link Here
2900
            }
2897
            }
2901
            return leftText;
2898
            return leftText;
2902
        }
2899
        }
2903
        
2900
2904
        protected String getRightHtmlText() {
2901
        protected String getRightHtmlText() {
2905
            if (rightText == null)
2902
            if (rightText == null)
2906
                rightText = escape(typeName);
2903
                rightText = escape(typeName);
2907
            return rightText;
2904
            return rightText;
2908
        }
2905
        }
2909
        
2906
2910
        @Override
2907
        @Override
2911
        protected void substituteText(JTextComponent c, int offset, int len, String toAdd, boolean assignToVar) {
2908
        protected void substituteText(JTextComponent c, int offset, int len, String toAdd, boolean assignToVar) {
2912
            super.substituteText(c, offset, len, toAdd != null ? toAdd : "=", assignToVar); //NOI18N
2909
            super.substituteText(c, offset, len, toAdd != null ? toAdd : "=", assignToVar); //NOI18N
Lines 2914-2920 Link Here
2914
2911
2915
        public String toString() {
2912
        public String toString() {
2916
            return simpleName;
2913
            return simpleName;
2917
        }        
2914
        }
2918
    }
2915
    }
2919
2916
2920
    static class AttributeValueItem extends WhiteListJavaCompletionItem<TypeElement> {
2917
    static class AttributeValueItem extends WhiteListJavaCompletionItem<TypeElement> {
Lines 2955-2961 Link Here
2955
            return delegate != null ? delegate.getInsertPrefix() : value; //NOI18N
2952
            return delegate != null ? delegate.getInsertPrefix() : value; //NOI18N
2956
        }
2953
        }
2957
2954
2958
        public CompletionTask createDocumentationTask() {            
2955
        public CompletionTask createDocumentationTask() {
2959
            return documentation == null ? null : new CompletionTask() {
2956
            return documentation == null ? null : new CompletionTask() {
2960
2957
2961
                private CompletionDocumentation cd = new CompletionDocumentation() {
2958
                private CompletionDocumentation cd = new CompletionDocumentation() {
Lines 2980-2986 Link Here
2980
                        return null;
2977
                        return null;
2981
                    }
2978
                    }
2982
                };
2979
                };
2983
                
2980
2984
                @Override
2981
                @Override
2985
                public void query(CompletionResultSet resultSet) {
2982
                public void query(CompletionResultSet resultSet) {
2986
                    resultSet.setDocumentation(cd);
2983
                    resultSet.setDocumentation(cd);
Lines 3050-3056 Link Here
3050
    }
3047
    }
3051
3048
3052
    static class StaticMemberItem extends WhiteListJavaCompletionItem<Element> {
3049
    static class StaticMemberItem extends WhiteListJavaCompletionItem<Element> {
3053
        
3050
3054
        private static final String FIELD_ST_PUBLIC = "org/netbeans/modules/editor/resources/completion/field_static_16.png"; //NOI18N
3051
        private static final String FIELD_ST_PUBLIC = "org/netbeans/modules/editor/resources/completion/field_static_16.png"; //NOI18N
3055
        private static final String FIELD_ST_PROTECTED = "org/netbeans/modules/editor/resources/completion/field_static_protected_16.png"; //NOI18N
3052
        private static final String FIELD_ST_PROTECTED = "org/netbeans/modules/editor/resources/completion/field_static_protected_16.png"; //NOI18N
3056
        private static final String FIELD_ST_PACKAGE = "org/netbeans/modules/editor/resources/completion/field_static_package_private_16.png"; //NOI18N
3053
        private static final String FIELD_ST_PACKAGE = "org/netbeans/modules/editor/resources/completion/field_static_package_private_16.png"; //NOI18N
Lines 3063-3069 Link Here
3063
        private static final String METHOD_COLOR = "<font color=#7c0000>"; //NOI18N
3060
        private static final String METHOD_COLOR = "<font color=#7c0000>"; //NOI18N
3064
        private static final String PARAMETER_NAME_COLOR = "<font color=#b200b2>"; //NOI18N
3061
        private static final String PARAMETER_NAME_COLOR = "<font color=#b200b2>"; //NOI18N
3065
        private static ImageIcon icon[][] = new ImageIcon[2][4];
3062
        private static ImageIcon icon[][] = new ImageIcon[2][4];
3066
        
3063
3067
        private TypeMirrorHandle<DeclaredType> typeHandle;
3064
        private TypeMirrorHandle<DeclaredType> typeHandle;
3068
        private boolean isDeprecated;
3065
        private boolean isDeprecated;
3069
        private String typeName;
3066
        private String typeName;
Lines 3074-3080 Link Here
3074
        private String sortText;
3071
        private String sortText;
3075
        private String leftText;
3072
        private String leftText;
3076
        private String rightText;
3073
        private String rightText;
3077
        
3074
3078
        private StaticMemberItem(CompilationInfo info, DeclaredType type, Element memberElem, TypeMirror memberType, int substitutionOffset, boolean isDeprecated, WhiteListQuery.WhiteList whiteList) {
3075
        private StaticMemberItem(CompilationInfo info, DeclaredType type, Element memberElem, TypeMirror memberType, int substitutionOffset, boolean isDeprecated, WhiteListQuery.WhiteList whiteList) {
3079
            super(substitutionOffset, ElementHandle.create(memberElem), whiteList);
3076
            super(substitutionOffset, ElementHandle.create(memberElem), whiteList);
3080
            type = (DeclaredType) info.getTypes().erasure(type);
3077
            type = (DeclaredType) info.getTypes().erasure(type);
Lines 3094-3104 Link Here
3094
                }
3091
                }
3095
            }
3092
            }
3096
        }
3093
        }
3097
        
3094
3098
        public int getSortPriority() {
3095
        public int getSortPriority() {
3099
            return (params == null ? 700 : 750) - SMART_TYPE;
3096
            return (params == null ? 700 : 750) - SMART_TYPE;
3100
        }
3097
        }
3101
        
3098
3102
        public CharSequence getSortText() {
3099
        public CharSequence getSortText() {
3103
            if (sortText == null) {
3100
            if (sortText == null) {
3104
                if (params == null) {
3101
                if (params == null) {
Lines 3121-3127 Link Here
3121
            }
3118
            }
3122
            return sortText;
3119
            return sortText;
3123
        }
3120
        }
3124
        
3121
3125
        public CharSequence getInsertPrefix() {
3122
        public CharSequence getInsertPrefix() {
3126
            return typeName + "." + memberName; //NOI18N
3123
            return typeName + "." + memberName; //NOI18N
3127
        }
3124
        }
Lines 3167-3179 Link Here
3167
                rightText = escape(memberTypeName);
3164
                rightText = escape(memberTypeName);
3168
            return rightText;
3165
            return rightText;
3169
        }
3166
        }
3170
        
3167
3171
        protected ImageIcon getBaseIcon(){
3168
        protected ImageIcon getBaseIcon(){
3172
            int level = getProtectionLevel(modifiers);
3169
            int level = getProtectionLevel(modifiers);
3173
            boolean isField = getElementHandle().getKind().isField();
3170
            boolean isField = getElementHandle().getKind().isField();
3174
            ImageIcon cachedIcon = icon[isField ? 0 : 1][level];
3171
            ImageIcon cachedIcon = icon[isField ? 0 : 1][level];
3175
            if (cachedIcon != null)
3172
            if (cachedIcon != null)
3176
                return cachedIcon;            
3173
                return cachedIcon;
3177
3174
3178
            String iconPath = null;
3175
            String iconPath = null;
3179
            if (isField) {
3176
            if (isField) {
Lines 3217-3223 Link Here
3217
                return null;
3214
                return null;
3218
            ImageIcon newIcon = ImageUtilities.loadImageIcon(iconPath, false);
3215
            ImageIcon newIcon = ImageUtilities.loadImageIcon(iconPath, false);
3219
            icon[isField ? 0 : 1][level] = newIcon;
3216
            icon[isField ? 0 : 1][level] = newIcon;
3220
            return newIcon;            
3217
            return newIcon;
3221
        }
3218
        }
3222
3219
3223
        @Override
3220
        @Override
Lines 3394-3407 Link Here
3394
            return sb.toString();
3391
            return sb.toString();
3395
        }
3392
        }
3396
    }
3393
    }
3397
    
3394
3398
    static class InitializeAllConstructorItem extends JavaCompletionItem {
3395
    static class InitializeAllConstructorItem extends JavaCompletionItem {
3399
        
3396
3400
        private static final String CONSTRUCTOR_PUBLIC = "org/netbeans/modules/java/editor/resources/new_constructor_16.png"; //NOI18N
3397
        private static final String CONSTRUCTOR_PUBLIC = "org/netbeans/modules/java/editor/resources/new_constructor_16.png"; //NOI18N
3401
        private static final String CONSTRUCTOR_COLOR = "<font color=#b28b00>"; //NOI18N
3398
        private static final String CONSTRUCTOR_COLOR = "<font color=#b28b00>"; //NOI18N
3402
        private static final String PARAMETER_NAME_COLOR = "<font color=#b200b2>"; //NOI18N
3399
        private static final String PARAMETER_NAME_COLOR = "<font color=#b200b2>"; //NOI18N
3403
        private static ImageIcon icon;
3400
        private static ImageIcon icon;
3404
        
3401
3405
        private List<ElementHandle<VariableElement>> fieldHandles;
3402
        private List<ElementHandle<VariableElement>> fieldHandles;
3406
        private ElementHandle<TypeElement> parentHandle;
3403
        private ElementHandle<TypeElement> parentHandle;
3407
        private ElementHandle<ExecutableElement> superConstructorHandle;
3404
        private ElementHandle<ExecutableElement> superConstructorHandle;
Lines 3409-3415 Link Here
3409
        private List<ParamDesc> params;
3406
        private List<ParamDesc> params;
3410
        private String sortText;
3407
        private String sortText;
3411
        private String leftText;
3408
        private String leftText;
3412
        
3409
3413
        private InitializeAllConstructorItem(CompilationInfo info, Iterable<? extends VariableElement> fields, ExecutableElement superConstructor, TypeElement parent, int substitutionOffset) {
3410
        private InitializeAllConstructorItem(CompilationInfo info, Iterable<? extends VariableElement> fields, ExecutableElement superConstructor, TypeElement parent, int substitutionOffset) {
3414
            super(substitutionOffset);
3411
            super(substitutionOffset);
3415
            this.fieldHandles = new ArrayList<ElementHandle<VariableElement>>();
3412
            this.fieldHandles = new ArrayList<ElementHandle<VariableElement>>();
Lines 3422-3439 Link Here
3422
            if (superConstructor != null) {
3419
            if (superConstructor != null) {
3423
                this.superConstructorHandle = ElementHandle.create(superConstructor);
3420
                this.superConstructorHandle = ElementHandle.create(superConstructor);
3424
                for (VariableElement ve : superConstructor.getParameters()) {
3421
                for (VariableElement ve : superConstructor.getParameters()) {
3425
                    this.params.add(new ParamDesc(null, Utilities.getTypeName(info, ve.asType(), false).toString(), ve.getSimpleName().toString()));                
3422
                    this.params.add(new ParamDesc(null, Utilities.getTypeName(info, ve.asType(), false).toString(), ve.getSimpleName().toString()));
3426
                }
3423
                }
3427
            } else {
3424
            } else {
3428
                this.superConstructorHandle = null;
3425
                this.superConstructorHandle = null;
3429
            }
3426
            }
3430
            this.simpleName = parent.getSimpleName().toString();
3427
            this.simpleName = parent.getSimpleName().toString();
3431
        }
3428
        }
3432
        
3429
3433
        public int getSortPriority() {
3430
        public int getSortPriority() {
3434
            return 400;
3431
            return 400;
3435
        }
3432
        }
3436
        
3433
3437
        public CharSequence getSortText() {
3434
        public CharSequence getSortText() {
3438
            if (sortText == null) {
3435
            if (sortText == null) {
3439
                StringBuilder sortParams = new StringBuilder();
3436
                StringBuilder sortParams = new StringBuilder();
Lines 3452-3458 Link Here
3452
            }
3449
            }
3453
            return sortText;
3450
            return sortText;
3454
        }
3451
        }
3455
        
3452
3456
        protected String getLeftHtmlText() {
3453
        protected String getLeftHtmlText() {
3457
            if (leftText == null) {
3454
            if (leftText == null) {
3458
                StringBuilder lText = new StringBuilder();
3455
                StringBuilder lText = new StringBuilder();
Lines 3477-3493 Link Here
3477
            }
3474
            }
3478
            return leftText;
3475
            return leftText;
3479
        }
3476
        }
3480
        
3477
3481
        protected ImageIcon getIcon() {
3478
        protected ImageIcon getIcon() {
3482
            if (icon == null) 
3479
            if (icon == null)
3483
                icon = ImageUtilities.loadImageIcon(CONSTRUCTOR_PUBLIC, false);
3480
                icon = ImageUtilities.loadImageIcon(CONSTRUCTOR_PUBLIC, false);
3484
            return icon;            
3481
            return icon;
3485
        }
3482
        }
3486
        
3483
3487
        public CharSequence getInsertPrefix() {
3484
        public CharSequence getInsertPrefix() {
3488
            return simpleName;
3485
            return simpleName;
3489
        }        
3486
        }
3490
        
3487
3491
        @Override
3488
        @Override
3492
        protected void substituteText(final JTextComponent c, final int offset, final int len, String toAdd, final boolean assignToVar) {
3489
        protected void substituteText(final JTextComponent c, final int offset, final int len, String toAdd, final boolean assignToVar) {
3493
            final BaseDocument doc = (BaseDocument)c.getDocument();
3490
            final BaseDocument doc = (BaseDocument)c.getDocument();
Lines 3523-3534 Link Here
3523
                                    break;
3520
                                    break;
3524
                            }
3521
                            }
3525
                            ExecutableElement superConstructor = superConstructorHandle != null ? superConstructorHandle.resolve(copy) : null;
3522
                            ExecutableElement superConstructor = superConstructorHandle != null ? superConstructorHandle.resolve(copy) : null;
3526
                            
3523
3527
                            TreeMaker make = copy.getTreeMaker();
3524
                            TreeMaker make = copy.getTreeMaker();
3528
                            ClassTree clazz = (ClassTree) tp.getLeaf();
3525
                            ClassTree clazz = (ClassTree) tp.getLeaf();
3529
                            GeneratorUtilities gu = GeneratorUtilities.get(copy);
3526
                            GeneratorUtilities gu = GeneratorUtilities.get(copy);
3530
                            ClassTree decl = make.insertClassMember(clazz, idx, gu.createConstructor(parent, fieldElements, superConstructor)); //NOI18N
3527
                            ClassTree decl = make.insertClassMember(clazz, idx, gu.createConstructor(parent, fieldElements, superConstructor)); //NOI18N
3531
                            
3528
3532
                            copy.rewrite(clazz, decl);
3529
                            copy.rewrite(clazz, decl);
3533
                        }
3530
                        }
3534
                    }
3531
                    }
Lines 3558-3564 Link Here
3558
            sb.append(GENERATE_TEXT);
3555
            sb.append(GENERATE_TEXT);
3559
            return sb.toString();
3556
            return sb.toString();
3560
        }
3557
        }
3561
        
3558
3562
        public boolean instantSubstitution(JTextComponent component) {
3559
        public boolean instantSubstitution(JTextComponent component) {
3563
            return false; //no instant substitution for create constructor item
3560
            return false; //no instant substitution for create constructor item
3564
        }
3561
        }
Lines 3568-3574 Link Here
3568
    private static final int PROTECTED_LEVEL = 2;
3565
    private static final int PROTECTED_LEVEL = 2;
3569
    private static final int PACKAGE_LEVEL = 1;
3566
    private static final int PACKAGE_LEVEL = 1;
3570
    private static final int PRIVATE_LEVEL = 0;
3567
    private static final int PRIVATE_LEVEL = 0;
3571
    
3568
3572
    private static int getProtectionLevel(Set<Modifier> modifiers) {
3569
    private static int getProtectionLevel(Set<Modifier> modifiers) {
3573
        if(modifiers.contains(Modifier.PUBLIC))
3570
        if(modifiers.contains(Modifier.PUBLIC))
3574
            return PUBLIC_LEVEL;
3571
            return PUBLIC_LEVEL;
Lines 3578-3584 Link Here
3578
            return PRIVATE_LEVEL;
3575
            return PRIVATE_LEVEL;
3579
        return PACKAGE_LEVEL;
3576
        return PACKAGE_LEVEL;
3580
    }
3577
    }
3581
    
3578
3582
    private static String escape(String s) {
3579
    private static String escape(String s) {
3583
        if (s != null) {
3580
        if (s != null) {
3584
            try {
3581
            try {
Lines 3587-3593 Link Here
3587
        }
3584
        }
3588
        return s;
3585
        return s;
3589
    }
3586
    }
3590
    
3587
3591
    private static int findPositionForSemicolon(JTextComponent c) {
3588
    private static int findPositionForSemicolon(JTextComponent c) {
3592
        final int[] ret = new int[] {-2};
3589
        final int[] ret = new int[] {-2};
3593
        final int offset = c.getSelectionEnd();
3590
        final int offset = c.getSelectionEnd();
Lines 3611-3617 Link Here
3611
                            while (t == null && tp != null) {
3608
                            while (t == null && tp != null) {
3612
                                switch(tp.getLeaf().getKind()) {
3609
                                switch(tp.getLeaf().getKind()) {
3613
                                    case EXPRESSION_STATEMENT:
3610
                                    case EXPRESSION_STATEMENT:
3614
                                    case IMPORT:                                
3611
                                    case IMPORT:
3615
                                        t = tp.getLeaf();
3612
                                        t = tp.getLeaf();
3616
                                        break;
3613
                                        break;
3617
                                    case RETURN:
3614
                                    case RETURN:
Lines 3631-3637 Link Here
3631
                                    if (ts.token().id() == JavaTokenId.SEMICOLON) {
3628
                                    if (ts.token().id() == JavaTokenId.SEMICOLON) {
3632
                                        ret[0] = -1;
3629
                                        ret[0] = -1;
3633
                                    } else if (ts.moveNext()) {
3630
                                    } else if (ts.moveNext()) {
3634
                                        ret[0] = ts.token().id() == JavaTokenId.LINE_COMMENT || ts.token().id() == JavaTokenId.WHITESPACE && ts.token().text().toString().contains("\n") ? ts.offset() : offset;                                
3631
                                        ret[0] = ts.token().id() == JavaTokenId.LINE_COMMENT || ts.token().id() == JavaTokenId.WHITESPACE && ts.token().text().toString().contains("\n") ? ts.offset() : offset;
3635
                                    } else {
3632
                                    } else {
3636
                                        ret[0] = ts.offset() + ts.token().length();
3633
                                        ret[0] = ts.offset() + ts.token().length();
3637
                                    }
3634
                                    }
Lines 3650-3656 Link Here
3650
        }, NbBundle.getMessage(JavaCompletionItem.class, "JCI-find_semicolon_pos"), cancel, false); //NOI18N
3647
        }, NbBundle.getMessage(JavaCompletionItem.class, "JCI-find_semicolon_pos"), cancel, false); //NOI18N
3651
        return ret[0];
3648
        return ret[0];
3652
    }
3649
    }
3653
    
3650
3654
    private static TokenSequence<JavaTokenId> findLastNonWhitespaceToken(CompilationInfo info, int startPos, int endPos) {
3651
    private static TokenSequence<JavaTokenId> findLastNonWhitespaceToken(CompilationInfo info, int startPos, int endPos) {
3655
        TokenSequence<JavaTokenId> ts = info.getTokenHierarchy().tokenSequence(JavaTokenId.language());
3652
        TokenSequence<JavaTokenId> ts = info.getTokenHierarchy().tokenSequence(JavaTokenId.language());
3656
        ts.move(endPos);
3653
        ts.move(endPos);
Lines 3670-3676 Link Here
3670
        }
3667
        }
3671
        return null;
3668
        return null;
3672
    }
3669
    }
3673
    
3670
3674
    private static String getAssignToVarText(CompilationInfo info, TypeMirror type, String name) {
3671
    private static String getAssignToVarText(CompilationInfo info, TypeMirror type, String name) {
3675
        name = adjustName(name);
3672
        name = adjustName(name);
3676
        StringBuilder sb = new StringBuilder();
3673
        StringBuilder sb = new StringBuilder();
Lines 3686-3717 Link Here
3686
        sb.append("\"} = "); //NOI18N
3683
        sb.append("\"} = "); //NOI18N
3687
        return sb.toString();
3684
        return sb.toString();
3688
    }
3685
    }
3689
    
3686
3690
    private static String adjustName(String name) {
3687
    private static String adjustName(String name) {
3691
        if (name == null)
3688
        if (name == null)
3692
            return null;
3689
            return null;
3693
        
3690
3694
        String shortName = null;
3691
        String shortName = null;
3695
        
3692
3696
        if (name.startsWith("get") && name.length() > 3) { //NOI18N
3693
        if (name.startsWith("get") && name.length() > 3) { //NOI18N
3697
            shortName = name.substring(3);
3694
            shortName = name.substring(3);
3698
        }
3695
        }
3699
        
3696
3700
        if (name.startsWith("is") && name.length() > 2) { //NOI18N
3697
        if (name.startsWith("is") && name.length() > 2) { //NOI18N
3701
            shortName = name.substring(2);
3698
            shortName = name.substring(2);
3702
        }
3699
        }
3703
        
3700
3704
        if (shortName != null) {
3701
        if (shortName != null) {
3705
            return firstToLower(shortName);
3702
            return firstToLower(shortName);
3706
        }
3703
        }
3707
        
3704
3708
        if (SourceVersion.isKeyword(name)) {
3705
        if (SourceVersion.isKeyword(name)) {
3709
            return "a" + Character.toUpperCase(name.charAt(0)) + name.substring(1); //NOI18N
3706
            return "a" + Character.toUpperCase(name.charAt(0)) + name.substring(1); //NOI18N
3710
        } else {
3707
        } else {
3711
            return name;
3708
            return name;
3712
        }
3709
        }
3713
    }
3710
    }
3714
    
3711
3715
    private static String firstToLower(String name) {
3712
    private static String firstToLower(String name) {
3716
        if (name.length() == 0)
3713
        if (name.length() == 0)
3717
            return null;
3714
            return null;
Lines 3732-3750 Link Here
3732
        }
3729
        }
3733
3730
3734
        result.append(last);
3731
        result.append(last);
3735
        
3732
3736
        if (SourceVersion.isKeyword(result)) {
3733
        if (SourceVersion.isKeyword(result)) {
3737
            return "a" + name; //NOI18N
3734
            return "a" + name; //NOI18N
3738
        } else {
3735
        } else {
3739
            return result.toString();
3736
            return result.toString();
3740
        }
3737
        }
3741
    }
3738
    }
3742
    
3739
3743
    static class ParamDesc {
3740
    static class ParamDesc {
3744
        private String fullTypeName;
3741
        private String fullTypeName;
3745
        private String typeName;
3742
        private String typeName;
3746
        private String name;
3743
        private String name;
3747
    
3744
3748
        public ParamDesc(String fullTypeName, String typeName, String name) {
3745
        public ParamDesc(String fullTypeName, String typeName, String name) {
3749
            this.fullTypeName = fullTypeName;
3746
            this.fullTypeName = fullTypeName;
3750
            this.typeName = typeName;
3747
            this.typeName = typeName;
(-)a/o.n.swing.plaf/apichanges.xml (+25 lines)
Lines 49-54 Link Here
49
    <apidef name="plaf">Look And Feel Customization</apidef>
49
    <apidef name="plaf">Look And Feel Customization</apidef>
50
</apidefs>
50
</apidefs>
51
<changes>
51
<changes>
52
    <change id="lfcustoms-color-functions">
53
        <api name="plaf"/>
54
        <summary>New functions for getting foreground text color and color shifting</summary>
55
        <version major="1" minor="27"/>
56
        <date day="14" month="6" year="2012"/>
57
        <author login="wbrana"/>
58
        <compatibility
59
            addition="yes"
60
            binary="compatible" deletion="no" deprecation="no"
61
            modification="no" semantic="compatible" source="compatible"
62
        />
63
        <description>
64
            <p>
65
                new functions:<br/>
66
                <code>
67
                    static String getHexString(int color)<br/>
68
                    static String getTextFgColorHTML()<br/>
69
                    static Color getTextFgColor()<br/>
70
                    static Color shiftColor(Color color)<br/>
71
                    static Color getForeground(AttributeSet a)<br/>
72
                </code>
73
            </p>
74
        </description>
75
        <class package="org.netbeans.swing.plaf" name="LFCustoms"/>
76
    </change>
52
    <change id="branding.of.lfcustoms">
77
    <change id="branding.of.lfcustoms">
53
        <api name="plaf"/>
78
        <api name="plaf"/>
54
        <summary>It is now possible to customize application-specific UIManager keys and values.</summary>
79
        <summary>It is now possible to customize application-specific UIManager keys and values.</summary>
(-)a/o.n.swing.plaf/manifest.mf (-1 / +1 lines)
Lines 1-6 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module-Localizing-Bundle: org/netbeans/swing/plaf/Bundle.properties
2
OpenIDE-Module-Localizing-Bundle: org/netbeans/swing/plaf/Bundle.properties
3
OpenIDE-Module: org.netbeans.swing.plaf
3
OpenIDE-Module: org.netbeans.swing.plaf
4
OpenIDE-Module-Specification-Version: 1.26
4
OpenIDE-Module-Specification-Version: 1.27
5
AutoUpdate-Show-In-Client: false
5
AutoUpdate-Show-In-Client: false
6
6
(-)a/o.n.swing.plaf/src/org/netbeans/swing/plaf/LFCustoms.java (-6 / +124 lines)
Lines 44-49 Link Here
44
44
45
package org.netbeans.swing.plaf;
45
package org.netbeans.swing.plaf;
46
46
47
import java.awt.Color;
48
import java.util.logging.Logger;
49
import javax.swing.UIManager;
50
import javax.swing.plaf.ColorUIResource;
51
import javax.swing.text.AttributeSet;
52
47
/** Look and feel customizations interface.
53
/** Look and feel customizations interface.
48
 * For various look and feels, there is a need to customize colors,
54
 * For various look and feels, there is a need to customize colors,
49
 * borders etc. to provide 'native-like' UI.
55
 * borders etc. to provide 'native-like' UI.
Lines 78-83 Link Here
78
    private Object[] guaranteedKeysAndValues = null;
84
    private Object[] guaranteedKeysAndValues = null;
79
    protected static final String WORKPLACE_FILL = "nb_workplace_fill"; //NOI18N
85
    protected static final String WORKPLACE_FILL = "nb_workplace_fill"; //NOI18N
80
86
87
    /** convert color
88
     *  @return hexadecimal value
89
     * @since 1.27
90
     */
91
    public static String getHexString(int color) {
92
            String result = Integer.toHexString(color).toUpperCase();
93
            if (result.length() == 1) {
94
                    return '0'+result;
95
            }
96
            return result;
97
    }
98
99
    /** cached window text  foreground color as html code */
100
    private static String textFgColorHTML = "";
101
102
    /** @return  window text foreground color as html code
103
     * @since 1.27
104
     */
105
    public static String getTextFgColorHTML() {
106
        synchronized(LFCustoms.class) {
107
            if (textFgColorHTML.isEmpty()) {
108
                    Object o = UIManager.getLookAndFeel().getDefaults().get("windowText");
109
                    if (o instanceof ColorUIResource) {
110
                            ColorUIResource resource = (ColorUIResource)o;
111
                            textFgColorHTML = "<font color=#" + getHexString(resource.getRed()) + getHexString(resource.getGreen()) + getHexString(resource.getBlue())+">";
112
                    } else {
113
                            textFgColorHTML = "<font color=#000000>";
114
                            Logger.getLogger(LFCustoms.class.getName()).warning("BUG: getTextFgColorHTML: color isn't available");
115
                    }
116
            }
117
            return textFgColorHTML;
118
        }
119
    }
120
121
    /** cached window text foreground color */
122
    private static Color textFgColor = null;
123
124
    /** @return window text foreground color
125
     * @since 1.27
126
     */
127
    public static Color getTextFgColor() {
128
        synchronized(LFCustoms.class) {
129
            if (textFgColor == null) {
130
                Object o = UIManager.getLookAndFeel().getDefaults().get("windowText");
131
                if (o instanceof ColorUIResource) {
132
                    textFgColor = (Color) o;
133
                } else {
134
                    textFgColor = Color.BLACK;
135
                    Logger.getLogger(LFCustoms.class.getName()).warning("BUG: getTextFgColor: color isn't available");
136
                }
137
            }
138
            return textFgColor;
139
        }
140
    }
141
142
    /** shift color value
143
     * @since 1.27
144
     */
145
    private static final int shiftValue = 64;
146
147
    /** convert color component
148
     * @return brighter  color component
149
     * @since 1.27
150
     */
151
    private static int brighter (int color) {
152
            int result = color + shiftValue;
153
            if (result > 255) {
154
                    return 255;
155
            } else {
156
                    return result;
157
            }
158
    }
159
160
    /** convert color component
161
     *  @return  darker  color component
162
     * @since 1.27
163
     */
164
    private static int darker(int color) {
165
            int result = color - shiftValue;
166
            if (result < 0) {
167
                    return 0;
168
            } else {
169
                    return result;
170
            }
171
    }
172
173
    /** convert color to brighter one if window foreground text color is bright color
174
     * or convert color to darker one if window foreground text color is dark color
175
     * @return converted color
176
     * @since 1.27
177
     */
178
    public static Color shiftColor(Color color) {
179
        Color textFgColor = getTextFgColor();
180
        if ((textFgColor.getRed() > 127) || (textFgColor.getGreen() > 127) || (textFgColor.getBlue() > 127)) {
181
            return new Color(brighter(color.getRed()), brighter(color.getGreen()), brighter(color.getBlue()));
182
        }
183
        return new Color(darker(color.getRed()), darker(color.getGreen()), darker(color.getBlue()));
184
    }
185
186
    /** get foreground text color from AttributeSet
187
     *  or get window foreground text color if AttributeSet doesn't define foreground text color
188
     * @return  foreground text color
189
     * @since 1.27
190
     */
191
    public static Color getForeground(AttributeSet a) {
192
        Color fg = (Color) a.getAttribute(javax.swing.text.StyleConstants.Foreground);
193
        if (fg == null) {
194
            fg = getTextFgColor();
195
        }
196
        return fg;
197
    }
198
81
    //TODO: A nice idea would be to replace these classes with XML files - minor rewrite of NbTheme to do it
199
    //TODO: A nice idea would be to replace these classes with XML files - minor rewrite of NbTheme to do it
82
200
83
    /** Fetch and cache keys and values */
201
    /** Fetch and cache keys and values */
Lines 108-114 Link Here
108
    }
226
    }
109
227
110
    /**
228
    /**
111
     * Get all keys this LFCustoms installs in UIManager.  This is used to 
229
     * Get all keys this LFCustoms installs in UIManager.  This is used to
112
     * delete unneeded elements from UIManager if the look and feel is changed
230
     * delete unneeded elements from UIManager if the look and feel is changed
113
     * on the fly (for example, the user switches Windows from Classic to XP
231
     * on the fly (for example, the user switches Windows from Classic to XP
114
     * look).
232
     * look).
Lines 151-157 Link Here
151
        }
269
        }
152
        return result;
270
        return result;
153
    }
271
    }
154
    
272
155
    /**
273
    /**
156
     * LFCustoms implementations which use UIBootstrapValue.Lazy should return
274
     * LFCustoms implementations which use UIBootstrapValue.Lazy should return
157
     * any keys that it will install here, so they can be merged into the list
275
     * any keys that it will install here, so they can be merged into the list
Lines 223-229 Link Here
223
     * custom font size is specified, the core will put this into UIDefaults.
341
     * custom font size is specified, the core will put this into UIDefaults.
224
     * We then read it out if present and use it to set up a custom font size. */
342
     * We then read it out if present and use it to set up a custom font size. */
225
    protected static final String CUSTOM_FONT_SIZE = "customFontSize"; //NOI18N
343
    protected static final String CUSTOM_FONT_SIZE = "customFontSize"; //NOI18N
226
    
344
227
    //Default font size - some classes use this to handle creating appropriate
345
    //Default font size - some classes use this to handle creating appropriate
228
    //custom fonts based on this value
346
    //custom fonts based on this value
229
    protected static final String DEFAULT_FONT_SIZE = "nbDefaultFontSize"; //NOI18N
347
    protected static final String DEFAULT_FONT_SIZE = "nbDefaultFontSize"; //NOI18N
Lines 326-334 Link Here
326
    public static final String SUBFONT = "subFont"; //NOI18N
444
    public static final String SUBFONT = "subFont"; //NOI18N
327
    public static final String LISTFONT = "List.font"; //NOI18N
445
    public static final String LISTFONT = "List.font"; //NOI18N
328
    public static final String TREEFONT = "Tree.font"; //NOI18N
446
    public static final String TREEFONT = "Tree.font"; //NOI18N
329
    public static final String PANELFONT = "Panel.font"; //NOI18N  
447
    public static final String PANELFONT = "Panel.font"; //NOI18N
330
    public static final String SPINNERFONT = "Spinner.font"; //NOI18N  
448
    public static final String SPINNERFONT = "Spinner.font"; //NOI18N
331
    
449
332
    // keys used by the progressbar api module.
450
    // keys used by the progressbar api module.
333
    public static final String PROGRESS_CANCEL_BUTTON_ICON = "nb.progress.cancel.icon";
451
    public static final String PROGRESS_CANCEL_BUTTON_ICON = "nb.progress.cancel.icon";
334
    public static final String PROGRESS_CANCEL_BUTTON_ROLLOVER_ICON = "nb.progress.cancel.icon.mouseover";
452
    public static final String PROGRESS_CANCEL_BUTTON_ROLLOVER_ICON = "nb.progress.cancel.icon.mouseover";
(-)a/refactoring.java/nbproject/project.xml (+8 lines)
Lines 214-219 Link Here
214
                    </run-dependency>
214
                    </run-dependency>
215
                </dependency>
215
                </dependency>
216
                <dependency>
216
                <dependency>
217
                    <code-name-base>org.netbeans.swing.plaf</code-name-base>
218
                    <build-prerequisite/>
219
                    <compile-dependency/>
220
                    <run-dependency>
221
                        <specification-version>1.27</specification-version>
222
                    </run-dependency>
223
                </dependency>
224
                <dependency>
217
                    <code-name-base>org.openide.actions</code-name-base>
225
                    <code-name-base>org.openide.actions</code-name-base>
218
                    <build-prerequisite/>
226
                    <build-prerequisite/>
219
                    <compile-dependency/>
227
                    <compile-dependency/>
(-)a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/UIUtilities.java (-25 / +26 lines)
Lines 66-71 Link Here
66
import org.netbeans.api.lexer.TokenHierarchy;
66
import org.netbeans.api.lexer.TokenHierarchy;
67
import org.netbeans.api.lexer.TokenSequence;
67
import org.netbeans.api.lexer.TokenSequence;
68
import org.netbeans.modules.refactoring.java.api.MemberInfo;
68
import org.netbeans.modules.refactoring.java.api.MemberInfo;
69
import org.netbeans.swing.plaf.LFCustoms;
69
import org.openide.util.Lookup;
70
import org.openide.util.Lookup;
70
import org.openide.xml.XMLUtil;
71
import org.openide.xml.XMLUtil;
71
72
Lines 279-285 Link Here
279
            buf.insert(0, "<s>"); // NOI18N
280
            buf.insert(0, "<s>"); // NOI18N
280
            buf.append("</s>"); // NOI18N
281
            buf.append("</s>"); // NOI18N
281
        }
282
        }
282
        buf.insert(0, "<font color=" + getHTMLColor(StyleConstants.getForeground(set)) + ">"); //NOI18N
283
        buf.insert(0, "<font color=" + getHTMLColor(LFCustoms.getForeground(set)) + ">"); //NOI18N
283
        buf.append("</font>"); //NOI18N
284
        buf.append("</font>"); //NOI18N
284
        return buf.toString();
285
        return buf.toString();
285
    }
286
    }
Lines 300-310 Link Here
300
        temp = temp.replace(">", "&gt;"); // NOI18N
301
        temp = temp.replace(">", "&gt;"); // NOI18N
301
        return temp;
302
        return temp;
302
    }
303
    }
303
    
304
304
    static String format(Element element) {
305
    static String format(Element element) {
305
        return format(element, false, false);
306
        return format(element, false, false);
306
    }
307
    }
307
    
308
308
    static String format(Element element, boolean forSignature, boolean FQNs) {
309
    static String format(Element element, boolean forSignature, boolean FQNs) {
309
        StringBuilder stringBuilder = new StringBuilder();
310
        StringBuilder stringBuilder = new StringBuilder();
310
        format(element, stringBuilder, forSignature, FQNs);
311
        format(element, stringBuilder, forSignature, FQNs);
Lines 342-348 Link Here
342
                    }
343
                    }
343
                }
344
                }
344
            }
345
            }
345
            
346
346
            if (forSignature) {
347
            if (forSignature) {
347
                switch (element.getKind()) {
348
                switch (element.getKind()) {
348
                    case CLASS:
349
                    case CLASS:
Lines 359-365 Link Here
359
                        break;
360
                        break;
360
                }
361
                }
361
            }
362
            }
362
            
363
363
            TypeElement typeElement = (TypeElement) element;
364
            TypeElement typeElement = (TypeElement) element;
364
            stringBuilder.append(FQNs
365
            stringBuilder.append(FQNs
365
                ? typeElement.getQualifiedName().toString()
366
                ? typeElement.getQualifiedName().toString()
Lines 402-408 Link Here
402
403
403
            if (forSignature) {
404
            if (forSignature) {
404
                stringBuilder.append(toString(modifiers));
405
                stringBuilder.append(toString(modifiers));
405
                
406
406
                if (modifiers.size() > 0) {
407
                if (modifiers.size() > 0) {
407
                    if (stringBuilder.length() > 0) {
408
                    if (stringBuilder.length() > 0) {
408
                        stringBuilder.append(" ");
409
                        stringBuilder.append(" ");
Lines 445-457 Link Here
445
                            stringBuilder.append("\"");
446
                            stringBuilder.append("\"");
446
                        } else if (annotationValueValue instanceof Character) {
447
                        } else if (annotationValueValue instanceof Character) {
447
                            stringBuilder.append("\'");
448
                            stringBuilder.append("\'");
448
                        } 
449
                        }
449
                        stringBuilder.append(String.valueOf(annotationValueValue));
450
                        stringBuilder.append(String.valueOf(annotationValueValue));
450
                        if (annotationValueValue instanceof String) {
451
                        if (annotationValueValue instanceof String) {
451
                            stringBuilder.append("\"");
452
                            stringBuilder.append("\"");
452
                        } else if (annotationValueValue instanceof Character) {
453
                        } else if (annotationValueValue instanceof Character) {
453
                            stringBuilder.append("\'");
454
                            stringBuilder.append("\'");
454
                        }                    
455
                        }
455
                    }
456
                    }
456
                }
457
                }
457
            } else {
458
            } else {
Lines 520-539 Link Here
520
                        stringBuilder.append("\"");
521
                        stringBuilder.append("\"");
521
                    } else if (fieldValue instanceof Character) {
522
                    } else if (fieldValue instanceof Character) {
522
                        stringBuilder.append("\'");
523
                        stringBuilder.append("\'");
523
                    } 
524
                    }
524
                    stringBuilder.append(String.valueOf(fieldValue));
525
                    stringBuilder.append(String.valueOf(fieldValue));
525
                    if (fieldValue instanceof String) {
526
                    if (fieldValue instanceof String) {
526
                        stringBuilder.append("\"");
527
                        stringBuilder.append("\"");
527
                    } else if (fieldValue instanceof Character) {
528
                    } else if (fieldValue instanceof Character) {
528
                        stringBuilder.append("\'");
529
                        stringBuilder.append("\'");
529
                    }                    
530
                    }
530
                }
531
                }
531
            } else {
532
            } else {
532
                stringBuilder.append(":");
533
                stringBuilder.append(":");
533
534
534
                formatTypeMirror(fieldElement.asType(), stringBuilder, FQNs);
535
                formatTypeMirror(fieldElement.asType(), stringBuilder, FQNs);
535
            }
536
            }
536
            
537
537
            break;
538
            break;
538
539
539
        case ENUM_CONSTANT:
540
        case ENUM_CONSTANT:
Lines 550-556 Link Here
550
            break;
551
            break;
551
        }
552
        }
552
    }
553
    }
553
    
554
554
    static void formatTypeMirror(TypeMirror typeMirror,
555
    static void formatTypeMirror(TypeMirror typeMirror,
555
        StringBuilder stringBuilder, boolean FQNs) {
556
        StringBuilder stringBuilder, boolean FQNs) {
556
        if (typeMirror == null) {
557
        if (typeMirror == null) {
Lines 640-646 Link Here
640
            return;
641
            return;
641
        }
642
        }
642
643
643
        boolean first = true;        
644
        boolean first = true;
644
        if (typeParameters.size() > 0) {
645
        if (typeParameters.size() > 0) {
645
            stringBuilder.append("<");
646
            stringBuilder.append("<");
646
            first = true;
647
            first = true;
Lines 805-815 Link Here
805
806
806
        return modifiers;
807
        return modifiers;
807
    }
808
    }
808
    
809
809
    static String getClassName(String className) {
810
    static String getClassName(String className) {
810
        return getClassName(className, false);
811
        return getClassName(className, false);
811
    }
812
    }
812
    
813
813
    static String getClassName(String className, boolean FQNs) {
814
    static String getClassName(String className, boolean FQNs) {
814
        // Handle generic type names i.e. strip off parameters
815
        // Handle generic type names i.e. strip off parameters
815
        int firstLessThan = className.indexOf('<');
816
        int firstLessThan = className.indexOf('<');
Lines 845-851 Link Here
845
846
846
        return className;
847
        return className;
847
    }
848
    }
848
    
849
849
    // Tree movement
850
    // Tree movement
850
    static void firstRow(JTree tree) {
851
    static void firstRow(JTree tree) {
851
        int rowCount = tree.getRowCount();
852
        int rowCount = tree.getRowCount();
Lines 854-860 Link Here
854
            scrollTreeToSelectedRow(tree);
855
            scrollTreeToSelectedRow(tree);
855
        }
856
        }
856
    }
857
    }
857
    
858
858
    static void previousRow(JTree tree) {
859
    static void previousRow(JTree tree) {
859
        int rowCount = tree.getRowCount();
860
        int rowCount = tree.getRowCount();
860
        if (rowCount > 0) {
861
        if (rowCount > 0) {
Lines 871-877 Link Here
871
            scrollTreeToSelectedRow(tree);
872
            scrollTreeToSelectedRow(tree);
872
        }
873
        }
873
    }
874
    }
874
    
875
875
    static void nextRow(JTree tree) {
876
    static void nextRow(JTree tree) {
876
        int rowCount = tree.getRowCount();
877
        int rowCount = tree.getRowCount();
877
        if (rowCount > 0) {
878
        if (rowCount > 0) {
Lines 886-892 Link Here
886
            scrollTreeToSelectedRow(tree);
887
            scrollTreeToSelectedRow(tree);
887
        }
888
        }
888
    }
889
    }
889
    
890
890
    static void lastRow(JTree tree) {
891
    static void lastRow(JTree tree) {
891
        int rowCount = tree.getRowCount();
892
        int rowCount = tree.getRowCount();
892
        if (rowCount > 0) {
893
        if (rowCount > 0) {
Lines 894-900 Link Here
894
            scrollTreeToSelectedRow(tree);
895
            scrollTreeToSelectedRow(tree);
895
        }
896
        }
896
    }
897
    }
897
    
898
898
    static void scrollTreeToSelectedRow(final JTree tree) {
899
    static void scrollTreeToSelectedRow(final JTree tree) {
899
        final int selectedRow = tree.getLeadSelectionRow();
900
        final int selectedRow = tree.getLeadSelectionRow();
900
        if (selectedRow >=0) {
901
        if (selectedRow >=0) {
Lines 907-913 Link Here
907
            );
908
            );
908
        }
909
        }
909
    }
910
    }
910
    
911
911
    static String escape(String s) {
912
    static String escape(String s) {
912
        if (s != null) {
913
        if (s != null) {
913
            try {
914
            try {
Lines 917-923 Link Here
917
        }
918
        }
918
        return null;
919
        return null;
919
    }
920
    }
920
    
921
921
    private static final String TYPE_COLOR = "#707070";
922
    private static final String TYPE_COLOR = "#707070";
922
    private static final String INHERITED_COLOR = "#7D694A";
923
    private static final String INHERITED_COLOR = "#7D694A";
923
924
Lines 981-987 Link Here
981
                }
982
                }
982
                sb.append(print(e.getReturnType(), html));
983
                sb.append(print(e.getReturnType(), html));
983
                if (html) {
984
                if (html) {
984
                    sb.append("</font>"); // NOI18N                    
985
                    sb.append("</font>"); // NOI18N
985
                }
986
                }
986
            }
987
            }
987
        }
988
        }
Lines 1168-1174 Link Here
1168
            sb.append(" :: "); // NOI18N
1169
            sb.append(" :: "); // NOI18N
1169
            if (scName != null) {
1170
            if (scName != null) {
1170
                if (html) {
1171
                if (html) {
1171
                    sb.append("<font color=" + TYPE_COLOR + ">"); // NOI18N                
1172
                    sb.append("<font color=" + TYPE_COLOR + ">"); // NOI18N
1172
                }
1173
                }
1173
                sb.append(scName);
1174
                sb.append(scName);
1174
                if (html) {
1175
                if (html) {
Lines 1182-1188 Link Here
1182
                for (Iterator<? extends TypeMirror> it = ifaces.iterator(); it.hasNext();) {
1183
                for (Iterator<? extends TypeMirror> it = ifaces.iterator(); it.hasNext();) {
1183
                    TypeMirror typeMirror = it.next();
1184
                    TypeMirror typeMirror = it.next();
1184
                    if (html) {
1185
                    if (html) {
1185
                        sb.append("<font color=" + TYPE_COLOR + ">"); // NOI18N                
1186
                        sb.append("<font color=" + TYPE_COLOR + ">"); // NOI18N
1186
                    }
1187
                    }
1187
                    sb.append(print(typeMirror, html));
1188
                    sb.append(print(typeMirror, html));
1188
                    if (html) {
1189
                    if (html) {

Return to bug 134281