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 198223
Collapse All | Expand All

(-)a/xml.text/src/org/netbeans/modules/xml/text/completion/AttributeResultItem.java (+9 lines)
Lines 48-53 Link Here
48
import javax.swing.text.JTextComponent;
48
import javax.swing.text.JTextComponent;
49
49
50
import org.netbeans.modules.xml.api.model.*;
50
import org.netbeans.modules.xml.api.model.*;
51
import org.netbeans.spi.editor.completion.CompletionTask;
51
52
52
/**
53
/**
53
 * It represents attribute name (or namespace prefix).
54
 * It represents attribute name (or namespace prefix).
Lines 59-67 Link Here
59
60
60
    // we are requested to avoid appending extra data
61
    // we are requested to avoid appending extra data
61
    private boolean inline = false;
62
    private boolean inline = false;
63
    
64
    private final GrammarResult res;
62
65
63
    public AttributeResultItem(GrammarResult res, boolean inline){
66
    public AttributeResultItem(GrammarResult res, boolean inline){
64
        super(res.getNodeName());
67
        super(res.getNodeName());
68
        this.res = res;
65
        selectionForeground = foreground = Color.green.darker().darker();        
69
        selectionForeground = foreground = Color.green.darker().darker();        
66
        this.inline = inline;
70
        this.inline = inline;
67
    }
71
    }
Lines 78-81 Link Here
78
    }
82
    }
79
    
83
    
80
    Color getPaintColor() { return Color.blue; }
84
    Color getPaintColor() { return Color.blue; }
85
86
    @Override
87
    public CompletionTask createDocumentationTask() {
88
        return doCreateDocumentationTask(res);
89
    }
81
}
90
}
(-)a/xml.text/src/org/netbeans/modules/xml/text/completion/ElementResultItem.java (-42 / +1 lines)
Lines 116-165 Link Here
116
    
116
    
117
    @Override
117
    @Override
118
    public CompletionTask createDocumentationTask() {
118
    public CompletionTask createDocumentationTask() {
119
        return new CompletionTask() {
119
        return doCreateDocumentationTask(res);
120
            public void query(CompletionResultSet resultSet) {
121
                if (res != null && res.getDescription() != null) {
122
                    resultSet.setDocumentation(new Docum(res.getDescription()));
123
    
124
                }
125
                resultSet.finish();
126
            }
127
            public void refresh(CompletionResultSet resultSet) {
128
                if (res != null && res.getDescription() != null) {
129
                    resultSet.setDocumentation(new Docum(res.getDescription()));
130
                }
131
                resultSet.finish();
132
            }
133
            public void cancel() {}
134
        };
135
    }
120
    }
136
121
137
    private class Docum implements CompletionDocumentation {
138
        private String doc;
139
140
        private Docum(String doc) {
141
            this.doc = doc;
142
        }
143
144
        public String getText() {
145
            return doc;
146
        }
147
148
        public URL getURL() {
149
            return null;
150
        }
151
152
        public CompletionDocumentation resolveLink(String link) {
153
            return null;
154
        }
155
156
        public Action getGotoSourceAction() {
157
            return null;
158
        }
159
160
    }
161
162
    
163
    /**
122
    /**
164
     * If called with <code>SHIFT_MASK</code> modified it createa a start tag and
123
     * If called with <code>SHIFT_MASK</code> modified it createa a start tag and
165
     * end tag pair and place caret between them.
124
     * end tag pair and place caret between them.
(-)a/xml.text/src/org/netbeans/modules/xml/text/completion/ValueResultItem.java (+8 lines)
Lines 47-52 Link Here
47
47
48
import java.beans.BeanInfo;
48
import java.beans.BeanInfo;
49
import org.netbeans.modules.xml.api.model.*;
49
import org.netbeans.modules.xml.api.model.*;
50
import org.netbeans.spi.editor.completion.CompletionTask;
50
51
51
52
52
/**
53
/**
Lines 66-73 Link Here
66
67
67
    private final String replacementText;
68
    private final String replacementText;
68
69
70
    private final GrammarResult res;
71
    
69
    public ValueResultItem(GrammarResult res) {
72
    public ValueResultItem(GrammarResult res) {
70
        super(res.getDisplayName(), res.getDisplayName());
73
        super(res.getDisplayName(), res.getDisplayName());
74
        this.res = res;
71
        foreground = Color.magenta;
75
        foreground = Color.magenta;
72
        selectionForeground = Color.magenta.darker();
76
        selectionForeground = Color.magenta.darker();
73
        replacementText = res.getNodeValue();
77
        replacementText = res.getNodeValue();
Lines 82-85 Link Here
82
    @Override
86
    @Override
83
    Color getPaintColor() { return Color.blue; }
87
    Color getPaintColor() { return Color.blue; }
84
88
89
    @Override
90
    public CompletionTask createDocumentationTask() {
91
        return doCreateDocumentationTask(res);
92
    }
85
}
93
}
(-)a/xml.text/src/org/netbeans/modules/xml/text/completion/XMLResultItem.java (+57 lines)
Lines 49-63 Link Here
49
import java.awt.Font;
49
import java.awt.Font;
50
import java.awt.Graphics;
50
import java.awt.Graphics;
51
import java.awt.event.KeyEvent;
51
import java.awt.event.KeyEvent;
52
import java.net.URL;
53
import javax.swing.Action;
52
import javax.swing.text.*;
54
import javax.swing.text.*;
53
import javax.swing.Icon;
55
import javax.swing.Icon;
54
56
55
import org.netbeans.editor.*;
57
import org.netbeans.editor.*;
56
import javax.swing.JLabel;
58
import javax.swing.JLabel;
57
import org.netbeans.api.editor.completion.Completion;
59
import org.netbeans.api.editor.completion.Completion;
60
import org.netbeans.modules.xml.api.model.GrammarResult;
58
import org.netbeans.modules.xml.text.api.XMLDefaultTokenContext;
61
import org.netbeans.modules.xml.text.api.XMLDefaultTokenContext;
59
import org.netbeans.modules.xml.text.syntax.XMLSyntaxSupport;
62
import org.netbeans.modules.xml.text.syntax.XMLSyntaxSupport;
63
import org.netbeans.spi.editor.completion.CompletionDocumentation;
60
import org.netbeans.spi.editor.completion.CompletionItem;
64
import org.netbeans.spi.editor.completion.CompletionItem;
65
import org.netbeans.spi.editor.completion.CompletionResultSet;
61
import org.netbeans.spi.editor.completion.CompletionTask;
66
import org.netbeans.spi.editor.completion.CompletionTask;
62
67
63
/**
68
/**
Lines 310-315 Link Here
310
        //return new AsyncCompletionTask(new DocQuery(this));
315
        //return new AsyncCompletionTask(new DocQuery(this));
311
    }
316
    }
312
    
317
    
318
    /**
319
     * Helper method for result items providing documentation.
320
     * @return 
321
     */
322
    protected CompletionTask doCreateDocumentationTask(final GrammarResult res) {
323
        return new CompletionTask() {
324
            public void query(CompletionResultSet resultSet) {
325
                if (res != null && res.getDescription() != null) {
326
                    resultSet.setDocumentation(new Docum(res.getDescription()));
327
    
328
                }
329
                resultSet.finish();
330
            }
331
            public void refresh(CompletionResultSet resultSet) {
332
                if (res != null && res.getDescription() != null) {
333
                    resultSet.setDocumentation(new Docum(res.getDescription()));
334
                }
335
                resultSet.finish();
336
            }
337
            public void cancel() {}
338
        };
339
    }
340
    
341
    private static class Docum implements CompletionDocumentation {
342
        private String doc;
343
344
        private Docum(String doc) {
345
            this.doc = doc;
346
        }
347
348
        @Override
349
        public String getText() {
350
            return doc;
351
        }
352
353
        @Override
354
        public URL getURL() {
355
            return null;
356
        }
357
358
        @Override
359
        public CompletionDocumentation resolveLink(String link) {
360
            return null;
361
        }
362
363
        @Override
364
        public Action getGotoSourceAction() {
365
            return null;
366
        }
367
368
    }
369
    
313
    public CompletionTask createToolTipTask() {
370
    public CompletionTask createToolTipTask() {
314
        return null;
371
        return null;
315
    }
372
    }

Return to bug 198223