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

(-)a/o.n.swing.outline/apichanges.xml (+17 lines)
Lines 199-204 Link Here
199
      <class package="org.netbeans.swing.etable" name="ETableColumnModel"/>
199
      <class package="org.netbeans.swing.etable" name="ETableColumnModel"/>
200
      <issue number="195226"/>
200
      <issue number="195226"/>
201
    </change>
201
    </change>
202
    <change id="column_selection_popup_or_dialog">
203
      <api name="etable_outline"/>
204
      <summary>Allow more detailed customization of whether popup menu or dialog
205
      is displayed to select visible columns.</summary>
206
      <version major="1" minor="17"/>
207
      <date day="7" month="11" year="2011"/>
208
      <author login="mentlicher"/>
209
      <compatibility addition="yes" binary="compatible" deprecation="no"/>
210
      <description>
211
        <p>Added <code>ETable.setColumnSelectionPopupOn(int mouseButton, Boolean popup)</code>,
212
                 <code>ETable.isColumnSelectionPopupOn(int mouseButton)</code> and
213
                 <code>ETable.showColumnSelectionDialog()</code> methods.
214
        </p>
215
      </description>
216
      <class package="org.netbeans.swing.etable" name="ETable"/>
217
      <issue number="200991"/>
218
    </change>
202
219
203
</changes>
220
</changes>
204
221
(-)a/o.n.swing.outline/manifest.mf (-1 / +1 lines)
Lines 1-5 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.swing.outline
2
OpenIDE-Module: org.netbeans.swing.outline
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/swing/outline/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/swing/outline/Bundle.properties
4
OpenIDE-Module-Specification-Version: 1.16
4
OpenIDE-Module-Specification-Version: 1.17
5
5
(-)a/o.n.swing.outline/src/org/netbeans/swing/etable/ETable.java (-14 / +100 lines)
Lines 253-262 Link Here
253
     */
253
     */
254
    private static TableColumnSelector defaultColumnSelector;
254
    private static TableColumnSelector defaultColumnSelector;
255
    
255
    
256
    /**
256
    private final Object columnSelectionPopupLock = new Object();
257
     * The column selection corner can use either dialog or popup menu.
257
    private Boolean[] columnSelectionPopup = new Boolean[] {
258
     */
258
        null,                                   // no button
259
    private boolean popupUsedFromTheCorner;
259
        Boolean.FALSE,                          // dialog on left-click
260
        null,                                   // no action on middle button
261
        Boolean.TRUE,                           // popup on right-click
262
    };
260
    
263
    
261
    private boolean columnHidingAllowed = true;
264
    private boolean columnHidingAllowed = true;
262
    
265
    
Lines 1054-1061 Link Here
1054
                    b.addMouseListener(new MouseAdapter() {
1057
                    b.addMouseListener(new MouseAdapter() {
1055
                        @Override
1058
                        @Override
1056
                        public void mouseClicked(MouseEvent me) {
1059
                        public void mouseClicked(MouseEvent me) {
1057
                            if (me.getButton() == MouseEvent.BUTTON3) {
1060
                            Boolean isPopup = isColumnSelectionPopupOn(me.getButton());
1061
                            if (Boolean.TRUE.equals(isPopup)) {
1058
                                ColumnSelectionPanel.showColumnSelectionPopup(b, ETable.this);
1062
                                ColumnSelectionPanel.showColumnSelectionPopup(b, ETable.this);
1063
                            } else if (Boolean.FALSE.equals(isPopup)) {
1064
                                ColumnSelectionPanel.showColumnSelectionDialog(ETable.this);
1059
                            }
1065
                            }
1060
                        }
1066
                        }
1061
                    });
1067
                    });
Lines 2246-2259 Link Here
2246
    }
2252
    }
2247
    
2253
    
2248
    /**
2254
    /**
2249
     * Mouse listener attached to the JTableHeader of this table. Single
2255
     * Mouse listener attached to the scroll pane of this table, handles the case
2250
     * click on the table header should trigger sorting on that column.
2256
     * when no columns are displayed.
2251
     * Double click on the column divider automatically resizes the column.
2252
     */
2257
     */
2253
    private class ColumnSelectionMouseListener extends MouseAdapter {
2258
    private class ColumnSelectionMouseListener extends MouseAdapter {
2254
        @Override
2259
        @Override
2255
        public void mouseClicked(MouseEvent me) {
2260
        public void mouseClicked(MouseEvent me) {
2256
            if (me.getButton() == MouseEvent.BUTTON3) {
2261
            if (me.getButton() != MouseEvent.BUTTON1) {
2262
                Boolean isPopup = isColumnSelectionPopupOn(me.getButton());
2263
                if (Boolean.TRUE.equals(isPopup)) {
2264
                    ColumnSelectionPanel.showColumnSelectionPopup (me.getComponent (), me.getX(), me.getY(), ETable.this);
2265
                } else if (Boolean.FALSE.equals(isPopup)) {
2266
                    ColumnSelectionPanel.showColumnSelectionDialog(ETable.this);
2267
                }
2257
                ColumnSelectionPanel.showColumnSelectionPopup (me.getComponent (), me.getX(), me.getY(), ETable.this);
2268
                ColumnSelectionPanel.showColumnSelectionPopup (me.getComponent (), me.getX(), me.getY(), ETable.this);
2258
            }
2269
            }
2259
        }
2270
        }
Lines 2266-2273 Link Here
2266
    private class HeaderMouseListener extends MouseAdapter {
2277
    private class HeaderMouseListener extends MouseAdapter {
2267
        @Override
2278
        @Override
2268
        public void mouseClicked(MouseEvent me) {
2279
        public void mouseClicked(MouseEvent me) {
2269
            if (me.getButton() == MouseEvent.BUTTON3) {
2280
            if (me.getButton() == MouseEvent.BUTTON3) { // Other buttons are reserved for sorting
2270
                ColumnSelectionPanel.showColumnSelectionPopup (me.getComponent (), me.getX(), me.getY(), ETable.this);
2281
                Boolean isPopup = isColumnSelectionPopupOn(MouseEvent.BUTTON3);
2282
                if (Boolean.TRUE.equals(isPopup)) {
2283
                    ColumnSelectionPanel.showColumnSelectionPopup (me.getComponent (), me.getX(), me.getY(), ETable.this);
2284
                } else if (Boolean.FALSE.equals(isPopup)) {
2285
                    ColumnSelectionPanel.showColumnSelectionDialog(ETable.this);
2286
                }
2271
                return;
2287
                return;
2272
            }
2288
            }
2273
            TableColumn resColumn = getResizingColumn(me.getPoint());
2289
            TableColumn resColumn = getResizingColumn(me.getPoint());
Lines 2673-2688 Link Here
2673
2689
2674
    /**
2690
    /**
2675
     * The column selection corner can use either dialog or popup menu.
2691
     * The column selection corner can use either dialog or popup menu.
2692
     * 
2693
     * @return <code>true</code>, when left mouse click invokes a popup menu,
2694
     * or <code>false</code>, when left mouse click opens a dialog for column selection.
2676
     */
2695
     */
2677
    public boolean isPopupUsedFromTheCorner() {
2696
    public boolean isPopupUsedFromTheCorner() {
2678
        return popupUsedFromTheCorner;
2697
        synchronized (columnSelectionPopupLock) {
2698
            Boolean popupUsedFromTheCorner = columnSelectionPopup[1];
2699
            return (popupUsedFromTheCorner != null) ? popupUsedFromTheCorner.booleanValue() : false;
2700
        }
2679
    }
2701
    }
2680
2702
2681
    /**
2703
    /**
2682
     * The column selection corner can use either dialog or popup menu.
2704
     * The column selection corner can use either dialog or popup menu.<br/>
2705
     * This method is equivalent to {@link #setColumnSelectionPopupOn(int, java.lang.Boolean)}
2706
     * with arguments <code>3</code> and <code>popupUsedFromTheCorner</code>.
2707
     * 
2708
     * @param popupUsedFromTheCorner When <code>true</code>, left mouse click invokes a popup menu,
2709
     * when <code>false</code>, left mouse click opens a dialog for column selection.
2683
     */
2710
     */
2684
    public void setPopupUsedFromTheCorner(boolean popupUsedFromTheCorner) {
2711
    public void setPopupUsedFromTheCorner(boolean popupUsedFromTheCorner) {
2685
        this.popupUsedFromTheCorner = popupUsedFromTheCorner;
2712
        synchronized (columnSelectionPopupLock) {
2713
            columnSelectionPopup[1] = popupUsedFromTheCorner ? Boolean.TRUE : Boolean.FALSE;
2714
        }
2715
    }
2716
    
2717
    /**
2718
     * Test if the popup with column selection menu or column selection dialog
2719
     * is displayed as a response to the mouse event.<br/>
2720
     * By default, popup menu is displayed on button3 mouse click
2721
     * and dialog or popup menu is displayed on the corner
2722
     * button1 mouse action, depending on the value of {@link #isPopupUsedFromTheCorner()}
2723
     * 
2724
     * @param mouseButton The button of the mouse event
2725
     * @return <code>Boolean.TRUE</code> when popup menu is displayed,
2726
     * <code>Boolean.FALSE</code> when dialog is displayed,
2727
     * <code>null</code> when nothing is displayed.
2728
     * @since 1.17
2729
     */
2730
    public Boolean isColumnSelectionPopupOn(int mouseButton) {
2731
        if (mouseButton < 0) {
2732
            throw new IllegalArgumentException("Button = "+mouseButton);
2733
        }
2734
        synchronized (columnSelectionPopupLock) {
2735
            if (mouseButton >= columnSelectionPopup.length) {
2736
                return null;
2737
            }
2738
            return columnSelectionPopup[mouseButton];
2739
        }
2740
    }
2741
    
2742
    /**
2743
     * Set if popup with column selection menu or column selection dialog
2744
     * should be displayed as a response to the mouse event.<br/>
2745
     * 
2746
     * @param mouseButton The button of the mouse event
2747
     * @param popup <code>Boolean.TRUE</code> when popup menu should be displayed,
2748
     * <code>Boolean.FALSE</code> when dialog should be displayed,
2749
     * <code>null</code> when nothing should be displayed.
2750
     * @since 1.17
2751
     */
2752
    public void setColumnSelectionPopupOn(int mouseButton, Boolean popup) {
2753
        if (mouseButton < 0) {
2754
            throw new IllegalArgumentException("Button = "+mouseButton);
2755
        }
2756
        synchronized (columnSelectionPopupLock) {
2757
            if (mouseButton >= columnSelectionPopup.length) {
2758
                Boolean[] csp = new Boolean[mouseButton + 1];
2759
                System.arraycopy(columnSelectionPopup, 0, csp, 0, columnSelectionPopup.length);
2760
                columnSelectionPopup = csp;
2761
            }
2762
            columnSelectionPopup[mouseButton] = popup;
2763
        }
2764
    }
2765
    
2766
    /**
2767
     * Shows dialog that allows to show/hide columns.
2768
     * @since 1.17
2769
     */
2770
    public final void showColumnSelectionDialog() {
2771
        ColumnSelectionPanel.showColumnSelectionDialog(this);
2686
    }
2772
    }
2687
2773
2688
    /**
2774
    /**

Return to bug 200991