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

(-)a/editor.completion/apichanges.xml (+16 lines)
Lines 108-113 Link Here
108
    <!-- ACTUAL CHANGES BEGIN HERE: -->
108
    <!-- ACTUAL CHANGES BEGIN HERE: -->
109
109
110
    <changes>
110
    <changes>
111
        <change id="CompositeCompletionItem">
112
            <api name="completion"/>
113
            <summary>Addition of CompositeCompletionItem</summary>
114
            <version major="1" minor="38"/>
115
            <date day="24" month="9" year="2013"/>
116
            <author login="dbalek"/>
117
            <compatibility addition="yes"/>
118
            <description>
119
            <p>
120
                <code>CompositeCompletionItem</code> interface was added to allow for
121
                completion items containing possible sub-items.
122
            </p>
123
            </description>
124
            <issue number="236313"/>
125
        </change>
126
111
        <change id="CompletionResultSet.setHasAdditionalItemsText">
127
        <change id="CompletionResultSet.setHasAdditionalItemsText">
112
            <api name="completion"/>
128
            <api name="completion"/>
113
            <summary>Addition of CompletionResultSet.setHasAdditionalItemsText()</summary>
129
            <summary>Addition of CompletionResultSet.setHasAdditionalItemsText()</summary>
(-)a/editor.completion/nbproject/project.properties (-1 / +1 lines)
Lines 44-47 Link Here
44
javac.source=1.7
44
javac.source=1.7
45
javadoc.arch=${basedir}/arch.xml
45
javadoc.arch=${basedir}/arch.xml
46
javadoc.apichanges=${basedir}/apichanges.xml
46
javadoc.apichanges=${basedir}/apichanges.xml
47
spec.version.base=1.37.0
47
spec.version.base=1.38.0
(-)a/editor.completion/src/org/netbeans/modules/editor/completion/CompletionImpl.java (-14 / +34 lines)
Lines 637-643 Link Here
637
                        }
637
                        }
638
                    }
638
                    }
639
                    // Call default action if ENTER was pressed
639
                    // Call default action if ENTER was pressed
640
                    if (e.getKeyCode() == KeyEvent.VK_ENTER && e.getID() == KeyEvent.KEY_PRESSED) {
640
                    if (e.getKeyCode() == KeyEvent.VK_ENTER && e.getID() == KeyEvent.KEY_PRESSED
641
                            && (e.getModifiers() & InputEvent.ALT_MASK) == 0) {
641
                        e.consume();
642
                        e.consume();
642
                        if (guardedPos) {
643
                        if (guardedPos) {
643
                            Toolkit.getDefaultToolkit().beep();
644
                            Toolkit.getDefaultToolkit().beep();
Lines 1088-1101 Link Here
1088
        pleaseWaitTimer.stop();
1089
        pleaseWaitTimer.stop();
1089
        stopProfiling();
1090
        stopProfiling();
1090
        boolean hidePerformed = layout.hideCompletion();
1091
        boolean hidePerformed = layout.hideCompletion();
1091
        pleaseWaitDisplayed = false;
1092
        if (!layout.isCompletionVisible()) {
1092
        JTextComponent jtc = getActiveComponent();
1093
            pleaseWaitDisplayed = false;
1093
        if (!completionOnly && hidePerformed && CompletionSettings.getInstance(jtc).documentationAutoPopup()) {
1094
            JTextComponent jtc = getActiveComponent();
1094
            hideDocumentation(true);
1095
            if (!completionOnly && hidePerformed && CompletionSettings.getInstance(jtc).documentationAutoPopup()) {
1095
        }
1096
                hideDocumentation(true);
1096
        if (jtc != null) {
1097
            }
1097
            jtc.putClientProperty("completion-visible", Boolean.FALSE);
1098
            if (jtc != null) {
1098
            jtc.putClientProperty("completion-active", Boolean.FALSE);
1099
                jtc.putClientProperty("completion-visible", Boolean.FALSE);
1100
                jtc.putClientProperty("completion-active", Boolean.FALSE);
1101
            }
1099
        }
1102
        }
1100
        return hidePerformed;
1103
        return hidePerformed;
1101
    }
1104
    }
Lines 1103-1108 Link Here
1103
    /**
1106
    /**
1104
     * May be called from any thread but it will be rescheduled into AWT.
1107
     * May be called from any thread but it will be rescheduled into AWT.
1105
     */
1108
     */
1109
    public void showCompletionSubItems() {
1110
        if (!SwingUtilities.isEventDispatchThread()) {
1111
            // Re-call this method in AWT if necessary
1112
            SwingUtilities.invokeLater(new ParamRunnable(ParamRunnable.SHOW_COMPLETION_SUB_ITEMS));
1113
            return;
1114
        }
1115
        layout.showCompletionSubItems();
1116
    }
1117
    
1118
    /**
1119
     * May be called from any thread but it will be rescheduled into AWT.
1120
     */
1106
    public void showDocumentation() {
1121
    public void showDocumentation() {
1107
        if (!SwingUtilities.isEventDispatchThread()) {
1122
        if (!SwingUtilities.isEventDispatchThread()) {
1108
            // Re-call this method in AWT if necessary
1123
            // Re-call this method in AWT if necessary
Lines 1588-1598 Link Here
1588
    private final class ParamRunnable implements Runnable {
1603
    private final class ParamRunnable implements Runnable {
1589
        
1604
        
1590
        private static final int SHOW_COMPLETION = 0;
1605
        private static final int SHOW_COMPLETION = 0;
1591
        private static final int SHOW_DOCUMENTATION = 1;
1606
        private static final int SHOW_COMPLETION_SUB_ITEMS = 1;
1592
        private static final int SHOW_TOOL_TIP = 2;
1607
        private static final int SHOW_DOCUMENTATION = 2;
1593
        private static final int HIDE_COMPLETION_PANE = 3;
1608
        private static final int SHOW_TOOL_TIP = 3;
1594
        private static final int HIDE_DOCUMENTATION_PANE = 4;
1609
        private static final int HIDE_COMPLETION_PANE = 4;
1595
        private static final int HIDE_TOOL_TIP_PANE = 5;
1610
        private static final int HIDE_DOCUMENTATION_PANE = 5;
1611
        private static final int HIDE_TOOL_TIP_PANE = 6;
1596
        
1612
        
1597
        private final int opCode;
1613
        private final int opCode;
1598
        private final boolean explicit;
1614
        private final boolean explicit;
Lines 1620-1625 Link Here
1620
                    showCompletion(explicitQuery, false, delayQuery, type);
1636
                    showCompletion(explicitQuery, false, delayQuery, type);
1621
                    break;
1637
                    break;
1622
1638
1639
                case SHOW_COMPLETION_SUB_ITEMS:
1640
                    showCompletion(explicitQuery, false, delayQuery, type);
1641
                    break;
1642
1623
                case SHOW_DOCUMENTATION:
1643
                case SHOW_DOCUMENTATION:
1624
                    showDocumentation();
1644
                    showDocumentation();
1625
                    break;
1645
                    break;
(-)a/editor.completion/src/org/netbeans/modules/editor/completion/CompletionJList.java (-3 / +14 lines)
Lines 56-62 Link Here
56
56
57
import org.netbeans.editor.LocaleSupport;
57
import org.netbeans.editor.LocaleSupport;
58
import org.netbeans.spi.editor.completion.CompletionItem;
58
import org.netbeans.spi.editor.completion.CompletionItem;
59
import org.netbeans.spi.editor.completion.CompositeCompletionItem;
59
import org.netbeans.spi.editor.completion.LazyCompletionItem;
60
import org.netbeans.spi.editor.completion.LazyCompletionItem;
61
import org.openide.util.ImageUtilities;
60
import org.openide.util.Utilities;
62
import org.openide.util.Utilities;
61
63
62
/**
64
/**
Lines 67-77 Link Here
67
public class CompletionJList extends JList {
69
public class CompletionJList extends JList {
68
70
69
    private static final int DARKER_COLOR_COMPONENT = 5;
71
    private static final int DARKER_COLOR_COMPONENT = 5;
72
    private static final int SUB_MENU_ICON_GAP = 1;
73
    private static final ImageIcon subMenuIcon = ImageUtilities.loadImageIcon("org/netbeans/modules/editor/hints/resources/suggestion.gif", false); // NOI18N;
70
74
71
    private final RenderComponent renderComponent;
75
    private final RenderComponent renderComponent;
72
    
76
    
73
    private Graphics cellPreferredSizeGraphics;
77
    private Graphics cellPreferredSizeGraphics;
74
75
    private int fixedItemHeight;
78
    private int fixedItemHeight;
76
    private int maxVisibleRowCount;
79
    private int maxVisibleRowCount;
77
    private JTextComponent editorComponent;
80
    private JTextComponent editorComponent;
Lines 90-97 Link Here
90
        renderComponent = new RenderComponent();
93
        renderComponent = new RenderComponent();
91
        setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
94
        setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
92
        setCellRenderer(new ListCellRenderer() {
95
        setCellRenderer(new ListCellRenderer() {
93
            private ListCellRenderer defaultRenderer = new DefaultListCellRenderer();
96
            private final ListCellRenderer defaultRenderer = new DefaultListCellRenderer();
94
97
98
            @Override
95
            public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
99
            public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
96
                if( value instanceof CompletionItem ) {
100
                if( value instanceof CompletionItem ) {
97
                    CompletionItem item = (CompletionItem)value;
101
                    CompletionItem item = (CompletionItem)value;
Lines 315-324 Link Here
315
            this.data = data;
319
            this.data = data;
316
        }
320
        }
317
        
321
        
322
        @Override
318
        public int getSize() {
323
        public int getSize() {
319
            return data.size();
324
            return data.size();
320
        }
325
        }
321
326
327
        @Override
322
        public Object getElementAt(int index) {
328
        public Object getElementAt(int index) {
323
            return (index >= 0 && index < data.size()) ? data.get(index) : null;
329
            return (index >= 0 && index < data.size()) ? data.get(index) : null;
324
        }
330
        }
Lines 364-369 Link Here
364
            // Render the item
370
            // Render the item
365
            item.render(g, CompletionJList.this.getFont(), getForeground(), bgColor,
371
            item.render(g, CompletionJList.this.getFont(), getForeground(), bgColor,
366
                    itemRenderWidth, getHeight(), selected);
372
                    itemRenderWidth, getHeight(), selected);
373
            if (selected && item instanceof CompositeCompletionItem && !((CompositeCompletionItem)item).getSubItems().isEmpty()) {
374
                g.drawImage(subMenuIcon.getImage(), itemRenderWidth - subMenuIcon.getIconWidth() - SUB_MENU_ICON_GAP, (height - subMenuIcon.getIconHeight()) / 2, null);
375
            }
367
            
376
            
368
            if (separator) {
377
            if (separator) {
369
                g.setColor(Color.gray);
378
                g.setColor(Color.gray);
Lines 383-389 Link Here
383
            return new Dimension(item.getPreferredWidth(cellPreferredSizeGraphics, CompletionJList.this.getFont()),
392
            return new Dimension(item.getPreferredWidth(cellPreferredSizeGraphics, CompletionJList.this.getFont()),
384
                    fixedItemHeight);
393
                    fixedItemHeight);
385
        }
394
        }
386
387
    }
395
    }
388
396
397
    public static int arrowSpan() {
398
        return SUB_MENU_ICON_GAP + subMenuIcon.getIconWidth() + SUB_MENU_ICON_GAP;
399
    }
389
}
400
}
(-)a/editor.completion/src/org/netbeans/modules/editor/completion/CompletionLayout.java (-25 / +92 lines)
Lines 48-53 Link Here
48
import java.awt.Color;
48
import java.awt.Color;
49
import java.awt.Dimension;
49
import java.awt.Dimension;
50
import java.awt.EventQueue;
50
import java.awt.EventQueue;
51
import java.awt.Point;
51
import java.awt.Rectangle;
52
import java.awt.Rectangle;
52
import java.awt.Toolkit;
53
import java.awt.Toolkit;
53
import java.awt.event.ActionEvent;
54
import java.awt.event.ActionEvent;
Lines 56-63 Link Here
56
import java.awt.event.MouseEvent;
57
import java.awt.event.MouseEvent;
57
import java.lang.ref.Reference;
58
import java.lang.ref.Reference;
58
import java.lang.ref.WeakReference;
59
import java.lang.ref.WeakReference;
60
import java.util.LinkedList;
59
import java.util.List;
61
import java.util.List;
60
import java.util.Stack;
61
import java.util.logging.Level;
62
import java.util.logging.Level;
62
import java.util.logging.LogRecord;
63
import java.util.logging.LogRecord;
63
import javax.swing.Action;
64
import javax.swing.Action;
Lines 75-80 Link Here
75
import org.netbeans.editor.GuardedDocument;
76
import org.netbeans.editor.GuardedDocument;
76
import org.netbeans.spi.editor.completion.CompletionDocumentation;
77
import org.netbeans.spi.editor.completion.CompletionDocumentation;
77
import org.netbeans.spi.editor.completion.CompletionItem;
78
import org.netbeans.spi.editor.completion.CompletionItem;
79
import org.netbeans.spi.editor.completion.CompositeCompletionItem;
78
import org.openide.text.CloneableEditorSupport;
80
import org.openide.text.CloneableEditorSupport;
79
import org.openide.util.NbBundle;
81
import org.openide.util.NbBundle;
80
82
Lines 105-111 Link Here
105
    private final DocPopup docPopup;
107
    private final DocPopup docPopup;
106
    private final TipPopup tipPopup;
108
    private final TipPopup tipPopup;
107
    
109
    
108
    private Stack<CompletionLayoutPopup> visiblePopups;
110
    private LinkedList<CompletionLayoutPopup> visiblePopups;
109
    
111
    
110
    CompletionLayout() {
112
    CompletionLayout() {
111
        completionPopup = new CompletionPopup();
113
        completionPopup = new CompletionPopup();
Lines 117-123 Link Here
117
        tipPopup = new TipPopup();
119
        tipPopup = new TipPopup();
118
        tipPopup.setLayout(this);
120
        tipPopup.setLayout(this);
119
        tipPopup.setPreferDisplayAboveCaret(true);
121
        tipPopup.setPreferDisplayAboveCaret(true);
120
        visiblePopups = new Stack<CompletionLayoutPopup>();
122
        visiblePopups = new LinkedList<CompletionLayoutPopup>();
121
    }
123
    }
122
    
124
    
123
    public JTextComponent getEditorComponent() {
125
    public JTextComponent getEditorComponent() {
Lines 132-140 Link Here
132
    }
134
    }
133
135
134
    private void hideAll() {
136
    private void hideAll() {
135
        completionPopup.hide();
137
        for (CompletionLayoutPopup popup : visiblePopups) {
136
        docPopup.hide();
138
            popup.hide();
137
        tipPopup.hide();
139
        }
138
        visiblePopups.clear();
140
        visiblePopups.clear();
139
    }
141
    }
140
142
Lines 145-159 Link Here
145
            visiblePopups.push(completionPopup);
147
            visiblePopups.push(completionPopup);
146
    }
148
    }
147
    
149
    
150
    public void showCompletionSubItems() {
151
        CompletionItem item = getSelectedCompletionItem();
152
        List<? extends CompletionItem> subItems = item instanceof CompositeCompletionItem ? ((CompositeCompletionItem)item).getSubItems() : null;
153
        if (subItems != null && !subItems.isEmpty()) {
154
            Point p = getSelectedLocation();
155
            if (p != null) {
156
                CompletionPopup popup = new CompletionPopup();
157
                popup.setLayout(this);
158
                popup.show(subItems, p);
159
                if (!visiblePopups.contains(popup))
160
                    visiblePopups.push(popup);
161
            }
162
        }
163
    }
164
    
148
    public boolean hideCompletion() {
165
    public boolean hideCompletion() {
149
        if (completionPopup.isVisible()) {
166
        for (CompletionLayoutPopup popup : visiblePopups) {
150
            completionPopup.hide();
167
            if (popup instanceof CompletionPopup && popup.isVisible()) {
151
            completionPopup.completionScrollPane = null;
168
                popup.hide();
152
            visiblePopups.remove(completionPopup);
169
                ((CompletionPopup)popup).completionScrollPane = null;
153
            return true;
170
                visiblePopups.remove(popup);
154
        } else { // not visible
171
                return true;                
155
            return false;
172
            }            
156
        }
173
        }
174
        return false;
157
    }
175
    }
158
    
176
    
159
    public boolean isCompletionVisible() {
177
    public boolean isCompletionVisible() {
Lines 161-176 Link Here
161
    }
179
    }
162
    
180
    
163
    public CompletionItem getSelectedCompletionItem() {
181
    public CompletionItem getSelectedCompletionItem() {
164
        return completionPopup.getSelectedCompletionItem();
182
        for (CompletionLayoutPopup popup : visiblePopups) {
183
            if (popup instanceof CompletionPopup && popup.isVisible()) {
184
                return ((CompletionPopup)popup).getSelectedCompletionItem();
185
            }
186
        }
187
        return null;
165
    }
188
    }
166
    
189
    
167
    public int getSelectedIndex() {
190
    public int getSelectedIndex() {
168
        return completionPopup.getSelectedIndex();
191
        for (CompletionLayoutPopup popup : visiblePopups) {
192
            if (popup instanceof CompletionPopup && popup.isVisible()) {
193
                return ((CompletionPopup)popup).getSelectedIndex();
194
            }
195
        }
196
        return -1;
197
    }
198
    
199
    public Point getSelectedLocation() {
200
        for (CompletionLayoutPopup popup : visiblePopups) {
201
            if (popup instanceof CompletionPopup && popup.isVisible()) {
202
                return ((CompletionPopup)popup).getSelectedLocation();
203
            }
204
        }
205
        return null;
169
    }
206
    }
170
    
207
    
171
    public void processKeyEvent(KeyEvent evt) {
208
    public void processKeyEvent(KeyEvent evt) {
172
        for (int i = visiblePopups.size() - 1; i >= 0; i--) {
209
        for (CompletionLayoutPopup popup : visiblePopups) {
173
            CompletionLayoutPopup popup = visiblePopups.get(i);
174
            popup.processKeyEvent(evt);
210
            popup.processKeyEvent(evt);
175
            if (evt.isConsumed())
211
            if (evt.isConsumed())
176
                return;
212
                return;
Lines 271-277 Link Here
271
            ) {
307
            ) {
272
                updateLayout(docPopup);
308
                updateLayout(docPopup);
273
            }
309
            }
274
            
275
        } else if (popup == docPopup) { // documentation popup
310
        } else if (popup == docPopup) { // documentation popup
276
            if (isCompletionVisible()) {
311
            if (isCompletionVisible()) {
277
                // Documentation must sync anchoring with completion
312
                // Documentation must sync anchoring with completion
Lines 294-299 Link Here
294
                // docPopup layout will be handled as part of completion popup layout
329
                // docPopup layout will be handled as part of completion popup layout
295
                updateLayout(completionPopup);
330
                updateLayout(completionPopup);
296
            }
331
            }
332
        } else { // completion sub-items popup
333
            Rectangle occupiedBounds = popup.getAnchorOffsetBounds();
334
            popup.showAlongOrNextOccupiedBounds(occupiedBounds, occupiedBounds);
297
        }
335
        }
298
    }
336
    }
299
    
337
    
Lines 313-320 Link Here
313
        
351
        
314
        private CompletionScrollPane completionScrollPane;
352
        private CompletionScrollPane completionScrollPane;
315
        
353
        
354
        public void show(List data, Point location) {
355
            show(data, null, -1, location, null, null, null, 0);
356
        }
357
        
316
        public void show(List data, String title, int anchorOffset,
358
        public void show(List data, String title, int anchorOffset,
317
        ListSelectionListener listSelectionListener, String additionalItemsText, String shortcutHint, int selectedIndex) {
359
        ListSelectionListener listSelectionListener, String additionalItemsText, String shortcutHint, int selectedIndex) {
360
            show(data, title, anchorOffset, null, listSelectionListener, additionalItemsText, shortcutHint, selectedIndex);
361
        }
362
            
363
        private void show(List data, String title, int anchorOffset, Point location,
364
        ListSelectionListener listSelectionListener, String additionalItemsText, String shortcutHint, int selectedIndex) {
318
            
365
            
319
	    JTextComponent editorComponent = getEditorComponent();
366
	    JTextComponent editorComponent = getEditorComponent();
320
	    if (editorComponent == null) {
367
	    if (editorComponent == null) {
Lines 338-343 Link Here
338
                        public void mouseClicked(MouseEvent evt) {
385
                        public void mouseClicked(MouseEvent evt) {
339
			    JTextComponent c = getEditorComponent();
386
			    JTextComponent c = getEditorComponent();
340
                            if (SwingUtilities.isLeftMouseButton(evt)) {
387
                            if (SwingUtilities.isLeftMouseButton(evt)) {
388
                                if (completionScrollPane.getView().getSize().width - CompletionJList.arrowSpan() <= evt.getPoint().x) {
389
                                    CompletionItem selectedItem = completionScrollPane.getSelectedCompletionItem();
390
                                    if (selectedItem instanceof CompositeCompletionItem && !((CompositeCompletionItem)selectedItem).getSubItems().isEmpty()) {
391
                                        CompletionImpl.get().showCompletionSubItems();
392
                                        evt.consume();
393
                                        return;
394
                                    }
395
                                }
396
                                for (CompletionLayoutPopup popup : getLayout().visiblePopups) {
397
                                    if (popup instanceof CompletionPopup) {
398
                                        if (popup == CompletionPopup.this) {
399
                                            break;
400
                                        } else {
401
                                            popup.hide();
402
                                        }
403
                                    }
404
                                }
341
                                if (c != null && evt.getClickCount() == 2 ) {
405
                                if (c != null && evt.getClickCount() == 2 ) {
342
                                    CompletionItem selectedItem
406
                                    CompletionItem selectedItem
343
                                            = completionScrollPane.getSelectedCompletionItem();
407
                                            = completionScrollPane.getSelectedCompletionItem();
Lines 382-388 Link Here
382
            // Set the new data
446
            // Set the new data
383
            getPreferredSize();
447
            getPreferredSize();
384
            completionScrollPane.setData(data, title, selectedIndex);
448
            completionScrollPane.setData(data, title, selectedIndex);
385
            setAnchorOffset(anchorOffset);
449
            if (anchorOffset >= 0)
450
                setAnchorOffset(anchorOffset);
451
            if (location != null)
452
                setLocation(location);
386
453
387
            Dimension prefSize = getPreferredSize();
454
            Dimension prefSize = getPreferredSize();
388
455
Lines 412-417 Link Here
412
            return isVisible() ? completionScrollPane.getSelectedIndex() : -1;
479
            return isVisible() ? completionScrollPane.getSelectedIndex() : -1;
413
        }
480
        }
414
481
482
        public Point getSelectedLocation() {
483
            return isVisible() ? completionScrollPane.getSelectedLocation() : null;
484
        }
485
415
        public void processKeyEvent(KeyEvent evt) {
486
        public void processKeyEvent(KeyEvent evt) {
416
            if (isVisible()) {
487
            if (isVisible()) {
417
                Object actionMapKey = completionScrollPane.getInputMap().get(
488
                Object actionMapKey = completionScrollPane.getInputMap().get(
Lines 431-437 Link Here
431
        protected int getAnchorHorizontalShift() {
502
        protected int getAnchorHorizontalShift() {
432
            return COMPLETION_ANCHOR_HORIZONTAL_SHIFT;
503
            return COMPLETION_ANCHOR_HORIZONTAL_SHIFT;
433
        }
504
        }
434
435
    }
505
    }
436
    
506
    
437
    private static final class DocPopup extends CompletionLayoutPopup {
507
    private static final class DocPopup extends CompletionLayoutPopup {
Lines 484-490 Link Here
484
        protected int getAnchorHorizontalShift() {
554
        protected int getAnchorHorizontalShift() {
485
            return COMPLETION_ANCHOR_HORIZONTAL_SHIFT;
555
            return COMPLETION_ANCHOR_HORIZONTAL_SHIFT;
486
        }
556
        }
487
488
    }
557
    }
489
    
558
    
490
    private static final class TipPopup extends CompletionLayoutPopup {
559
    private static final class TipPopup extends CompletionLayoutPopup {
Lines 514-521 Link Here
514
		    CompletionImpl.get().hideToolTip();
583
		    CompletionImpl.get().hideToolTip();
515
		}
584
		}
516
            }
585
            }
517
        }
586
        }        
518
        
587
    }    
519
    }
520
    
521
}
588
}
(-)a/editor.completion/src/org/netbeans/modules/editor/completion/CompletionLayoutPopup.java (+5 lines)
Lines 136-141 Link Here
136
        anchorOffsetBounds = null;
136
        anchorOffsetBounds = null;
137
    }
137
    }
138
    
138
    
139
    final void setLocation(Point location) {
140
        this.anchorOffset = -1;
141
        anchorOffsetBounds = new Rectangle(location);
142
    }
143
    
139
    final int getAnchorOffset() {
144
    final int getAnchorOffset() {
140
	int offset = anchorOffset;
145
	int offset = anchorOffset;
141
	if (offset == -1) {
146
	if (offset == -1) {
(-)a/editor.completion/src/org/netbeans/modules/editor/completion/CompletionScrollPane.java (-17 / +40 lines)
Lines 47-52 Link Here
47
47
48
import java.awt.Color;
48
import java.awt.Color;
49
import java.awt.Dimension;
49
import java.awt.Dimension;
50
import java.awt.Point;
50
import java.awt.Rectangle;
51
import java.awt.Rectangle;
51
import java.awt.event.ActionEvent;
52
import java.awt.event.ActionEvent;
52
import java.awt.event.KeyEvent;
53
import java.awt.event.KeyEvent;
Lines 60-70 Link Here
60
import javax.swing.JLabel;
61
import javax.swing.JLabel;
61
import javax.swing.JScrollPane;
62
import javax.swing.JScrollPane;
62
import javax.swing.KeyStroke;
63
import javax.swing.KeyStroke;
64
import javax.swing.SwingUtilities;
63
import javax.swing.event.ListSelectionListener;
65
import javax.swing.event.ListSelectionListener;
64
import javax.swing.plaf.TextUI;
65
import javax.swing.text.JTextComponent;
66
import javax.swing.text.JTextComponent;
66
import javax.swing.text.Keymap;
67
import javax.swing.text.Keymap;
67
import javax.swing.text.EditorKit;
68
import org.netbeans.editor.BaseKit;
68
import org.netbeans.editor.BaseKit;
69
import org.netbeans.editor.ext.ExtKit;
69
import org.netbeans.editor.ext.ExtKit;
70
import org.netbeans.spi.editor.completion.CompletionItem;
70
import org.netbeans.spi.editor.completion.CompletionItem;
Lines 86-92 Link Here
86
    private static final String COMPLETION_PGDN = "completion-pgdn"; //NOI18N
86
    private static final String COMPLETION_PGDN = "completion-pgdn"; //NOI18N
87
    private static final String COMPLETION_BEGIN = "completion-begin"; //NOI18N
87
    private static final String COMPLETION_BEGIN = "completion-begin"; //NOI18N
88
    private static final String COMPLETION_END = "completion-end"; //NOI18N
88
    private static final String COMPLETION_END = "completion-end"; //NOI18N
89
89
    private static final String COMPLETION_SUBITEMS_SHOW = "completion-subitems-show"; //NOI18N
90
    
90
    private static final int ACTION_ESCAPE = 0;
91
    private static final int ACTION_ESCAPE = 0;
91
    private static final int ACTION_COMPLETION_UP = 1;
92
    private static final int ACTION_COMPLETION_UP = 1;
92
    private static final int ACTION_COMPLETION_DOWN = 2;
93
    private static final int ACTION_COMPLETION_DOWN = 2;
Lines 94-101 Link Here
94
    private static final int ACTION_COMPLETION_PGDN = 4;
95
    private static final int ACTION_COMPLETION_PGDN = 4;
95
    private static final int ACTION_COMPLETION_BEGIN = 5;
96
    private static final int ACTION_COMPLETION_BEGIN = 5;
96
    private static final int ACTION_COMPLETION_END = 6;
97
    private static final int ACTION_COMPLETION_END = 6;
97
98
    private static final int ACTION_COMPLETION_SUBITEMS_SHOW = 7;
98
    private CompletionJList view;
99
    
100
    private final CompletionJList view;
99
    
101
    
100
    private List dataObj;
102
    private List dataObj;
101
    
103
    
Lines 148-153 Link Here
148
        return view.getSelectedIndex();
150
        return view.getSelectedIndex();
149
    }
151
    }
150
    
152
    
153
    public Point getSelectedLocation() {
154
        Rectangle r = view.getCellBounds(getSelectedIndex(), getSelectedIndex());
155
        Point p = new Point(r.getLocation());
156
        SwingUtilities.convertPointToScreen(p, view);
157
        p.x += r.width;
158
        return p;
159
    }
160
    
151
    public @Override Dimension getPreferredSize() {
161
    public @Override Dimension getPreferredSize() {
152
        Dimension prefSize = super.getPreferredSize();
162
        Dimension prefSize = super.getPreferredSize();
153
        Dimension labelSize = topLabel != null ? topLabel.getPreferredSize() : new Dimension(0, 0);
163
        Dimension labelSize = topLabel != null ? topLabel.getPreferredSize() : new Dimension(0, 0);
Lines 162-167 Link Here
162
        return prefSize;
172
        return prefSize;
163
    }
173
    }
164
    
174
    
175
    protected CompletionJList getView() {
176
        return view;
177
    }
178
    
165
    private void setTitle(String title) {
179
    private void setTitle(String title) {
166
        if (title == null) {
180
        if (title == null) {
167
            if (topLabel != null) {
181
            if (topLabel != null) {
Lines 185-191 Link Here
185
        // This method is implemented due to the issue
199
        // This method is implemented due to the issue
186
        // #25715 - Attempt to search keymap for the keybinding that logically corresponds to the action
200
        // #25715 - Attempt to search keymap for the keybinding that logically corresponds to the action
187
        KeyStroke[] ret = new KeyStroke[] { defaultKey };
201
        KeyStroke[] ret = new KeyStroke[] { defaultKey };
188
        if (component != null) {
202
        if (component != null && editorActionName != null) {
189
            Action a = component.getActionMap().get(editorActionName);
203
            Action a = component.getActionMap().get(editorActionName);
190
            Keymap km = component.getKeymap();
204
            Keymap km = component.getKeymap();
191
            if (a != null && km != null) {
205
            if (a != null && km != null) {
Lines 200-207 Link Here
200
214
201
    private void registerKeybinding(int action, String actionName, KeyStroke stroke, String editorActionName, JTextComponent component){
215
    private void registerKeybinding(int action, String actionName, KeyStroke stroke, String editorActionName, JTextComponent component){
202
        KeyStroke[] keys = findEditorKeys(editorActionName, stroke, component);
216
        KeyStroke[] keys = findEditorKeys(editorActionName, stroke, component);
203
        for (int i = 0; i < keys.length; i++) {
217
        for (KeyStroke key : keys) {
204
            getInputMap().put(keys[i], actionName);
218
            getInputMap().put(key, actionName);
205
        }
219
        }
206
        getActionMap().put(actionName, new CompletionPaneAction(action));
220
        getActionMap().put(actionName, new CompletionPaneAction(action));
207
    }
221
    }
Lines 241-246 Link Here
241
        registerKeybinding(ACTION_COMPLETION_END, COMPLETION_END,
255
        registerKeybinding(ACTION_COMPLETION_END, COMPLETION_END,
242
        KeyStroke.getKeyStroke(KeyEvent.VK_END, 0),
256
        KeyStroke.getKeyStroke(KeyEvent.VK_END, 0),
243
        BaseKit.endLineAction, component);
257
        BaseKit.endLineAction, component);
258
259
        registerKeybinding(ACTION_COMPLETION_SUBITEMS_SHOW, COMPLETION_SUBITEMS_SHOW,
260
        KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, KeyEvent.ALT_MASK),
261
        null, component);
244
    }
262
    }
245
263
246
    List testGetData() {
264
    List testGetData() {
Lines 248-266 Link Here
248
    }
266
    }
249
    
267
    
250
    private class CompletionPaneAction extends AbstractAction {
268
    private class CompletionPaneAction extends AbstractAction {
251
        private int action;
269
        private final int action;
252
270
253
        private CompletionPaneAction(int action) {
271
        private CompletionPaneAction(int action) {
254
            this.action = action;
272
            this.action = action;
255
        }
273
        }
256
274
275
        @Override
257
        public void actionPerformed(ActionEvent actionEvent) {
276
        public void actionPerformed(ActionEvent actionEvent) {
258
            switch (action) {
277
            switch (action) {
259
		case ACTION_ESCAPE:
278
                case ACTION_ESCAPE:
260
                    LogRecord r = new LogRecord(Level.FINE, "COMPL_CANCEL"); // NOI18N
279
                    if (CompletionImpl.get().hideCompletion(false)) {
261
                    CompletionImpl.uilog(r);
280
                        LogRecord r = new LogRecord(Level.FINE, "COMPL_CANCEL"); // NOI18N
262
                    CompletionImpl.get().hideCompletion(false);
281
                        CompletionImpl.uilog(r);
263
		    break;
282
                    }
283
                    break;
264
                case ACTION_COMPLETION_UP:
284
                case ACTION_COMPLETION_UP:
265
                    view.up();
285
                    view.up();
266
                    break;
286
                    break;
Lines 271-283 Link Here
271
                    view.pageUp();
291
                    view.pageUp();
272
                    break;
292
                    break;
273
                case ACTION_COMPLETION_PGDN:
293
                case ACTION_COMPLETION_PGDN:
274
                        view.pageDown();
294
                    view.pageDown();
275
                    break;
295
                    break;
276
                case ACTION_COMPLETION_BEGIN:
296
                case ACTION_COMPLETION_BEGIN:
277
                        view.begin();
297
                    view.begin();
278
                    break;
298
                    break;
279
                case ACTION_COMPLETION_END:
299
                case ACTION_COMPLETION_END:
280
                        view.end();
300
                    view.end();
301
                    break;
302
                case ACTION_COMPLETION_SUBITEMS_SHOW:
303
                    CompletionImpl.get().showCompletionSubItems();
281
                    break;
304
                    break;
282
            }
305
            }
283
        }
306
        }
(-)ddba7068906e (+62 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2013 Sun Microsystems, Inc.
41
 */
42
43
package org.netbeans.spi.editor.completion;
44
45
import java.util.List;
46
47
/**
48
 * The interface representing a completion item containing possible sub-items.
49
 *
50
 * @author Dusan Balek
51
 * @since 1.38
52
 */
53
public interface CompositeCompletionItem extends CompletionItem {
54
    
55
    /**
56
     * Gets sub-items of the code completion item. The sub-items may be shown
57
     * as a sub-menu for the given item.
58
     * 
59
     * @return non-null list of sub-items.
60
     */
61
    List<? extends CompletionItem> getSubItems();
62
}

Return to bug 236313