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

(-)spi.navigator/apichanges.xml (+15 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="NavigatorPanelWithToolbar">
112
        <api name="navigator_api"/>
113
        <summary>Added SPI interface <code>NavigatorPanelWithToolbar</code></summary>
114
        <version major="1" minor="25"/>
115
        <date year="2012" month="8" day="20"/>
116
        <author login="jpeska"/>
117
        <compatibility binary="compatible" source="compatible" deprecation="no" deletion="no" addition="yes"/>
118
        <description>
119
            <p>
120
                Added SPI interface <code>NavigatorPanelWithToolbar</code>. Clients will implement this interface when they need a toolbar for their Navigator view/panel.
121
            </p>
122
        </description>
123
        <class package="org.netbeans.spi.navigator" name="NavigatorPanelWithToolbar"/>
124
        <issue number="217091"/>
125
    </change>
111
    <change id="NavigatorPanel.Registration">
126
    <change id="NavigatorPanel.Registration">
112
        <api name="navigator_api"/>
127
        <api name="navigator_api"/>
113
        <summary>Added <code>@NavigatorPanel.Registration</code></summary>
128
        <summary>Added <code>@NavigatorPanel.Registration</code></summary>
(-)spi.navigator/manifest.mf (-1 / +1 lines)
Lines 2-5 Link Here
2
OpenIDE-Module: org.netbeans.spi.navigator/1
2
OpenIDE-Module: org.netbeans.spi.navigator/1
3
OpenIDE-Module-Layer: org/netbeans/modules/navigator/resources/layer.xml
3
OpenIDE-Module-Layer: org/netbeans/modules/navigator/resources/layer.xml
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/navigator/resources/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/navigator/resources/Bundle.properties
5
OpenIDE-Module-Specification-Version: 1.24
5
OpenIDE-Module-Specification-Version: 1.25
(-)spi.navigator/src/org/netbeans/modules/navigator/LazyPanel.java (-1 / +7 lines)
Lines 45-50 Link Here
45
import java.util.Map;
45
import java.util.Map;
46
import javax.swing.JComponent;
46
import javax.swing.JComponent;
47
import org.netbeans.spi.navigator.NavigatorPanel;
47
import org.netbeans.spi.navigator.NavigatorPanel;
48
import org.netbeans.spi.navigator.NavigatorPanelWithToolbar;
48
import org.netbeans.spi.navigator.NavigatorPanelWithUndo;
49
import org.netbeans.spi.navigator.NavigatorPanelWithUndo;
49
import org.openide.awt.UndoRedo;
50
import org.openide.awt.UndoRedo;
50
import org.openide.util.Lookup;
51
import org.openide.util.Lookup;
Lines 52-58 Link Here
52
/**
53
/**
53
 * Delegating panel for use from {@link NavigatorPanel.Registration}.
54
 * Delegating panel for use from {@link NavigatorPanel.Registration}.
54
 */
55
 */
55
public class LazyPanel implements NavigatorPanelWithUndo {
56
public class LazyPanel implements NavigatorPanelWithUndo, NavigatorPanelWithToolbar {
56
57
57
    /**
58
    /**
58
     * Referenced from generated layer.
59
     * Referenced from generated layer.
Lines 112-115 Link Here
112
        return p instanceof NavigatorPanelWithUndo ? ((NavigatorPanelWithUndo) p).getUndoRedo() : UndoRedo.NONE;
113
        return p instanceof NavigatorPanelWithUndo ? ((NavigatorPanelWithUndo) p).getUndoRedo() : UndoRedo.NONE;
113
    }
114
    }
114
115
116
    @Override
117
    public JComponent getToolbarComponent() {
118
        NavigatorPanel p = initialize();
119
        return p instanceof NavigatorPanelWithToolbar ? ((NavigatorPanelWithToolbar) p).getToolbarComponent() : null;
120
    }
115
}
121
}
(-)spi.navigator/src/org/netbeans/modules/navigator/NavigatorTC.form (-3 / +21 lines)
Lines 7-12 Link Here
7
    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
7
    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
8
    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
8
    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
9
    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
9
    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
10
    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
10
    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
11
    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
11
    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
12
    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
12
    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
13
    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
Lines 22-36 Link Here
22
        </Constraint>
23
        </Constraint>
23
      </Constraints>
24
      </Constraints>
24
25
25
      <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
26
      <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
26
      <SubComponents>
27
      <SubComponents>
27
        <Component class="javax.swing.JComboBox" name="panelSelector">
28
        <Component class="javax.swing.JComboBox" name="panelSelector">
29
          <Properties>
30
            <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
31
              <Dimension value="[100, 20]"/>
32
            </Property>
33
          </Properties>
28
          <Constraints>
34
          <Constraints>
29
            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
35
            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
30
              <BorderConstraints direction="Center"/>
36
              <GridBagConstraints gridX="-1" gridY="-1" gridWidth="-1" gridHeight="0" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="1.0" weightY="0.0"/>
31
            </Constraint>
37
            </Constraint>
32
          </Constraints>
38
          </Constraints>
33
        </Component>
39
        </Component>
40
        <Container class="javax.swing.JPanel" name="pnlToolbar">
41
          <Properties>
42
            <Property name="opaque" type="boolean" value="false"/>
43
          </Properties>
44
          <Constraints>
45
            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
46
              <GridBagConstraints gridX="-1" gridY="-1" gridWidth="-1" gridHeight="0" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="3" insetsBottom="0" insetsRight="0" anchor="13" weightX="1.5" weightY="0.0"/>
47
            </Constraint>
48
          </Constraints>
49
50
          <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
51
        </Container>
34
      </SubComponents>
52
      </SubComponents>
35
    </Container>
53
    </Container>
36
    <Container class="javax.swing.JPanel" name="contentArea">
54
    <Container class="javax.swing.JPanel" name="contentArea">
(-)spi.navigator/src/org/netbeans/modules/navigator/NavigatorTC.java (-3 / +50 lines)
Lines 46-51 Link Here
46
46
47
import java.awt.BorderLayout;
47
import java.awt.BorderLayout;
48
import java.awt.Color;
48
import java.awt.Color;
49
import java.awt.GridBagConstraints;
49
import java.awt.event.ActionEvent;
50
import java.awt.event.ActionEvent;
50
import java.awt.event.ActionListener;
51
import java.awt.event.ActionListener;
51
import java.util.List;
52
import java.util.List;
Lines 59-64 Link Here
59
import javax.swing.UIManager;
60
import javax.swing.UIManager;
60
import org.netbeans.spi.navigator.NavigatorDisplayer;
61
import org.netbeans.spi.navigator.NavigatorDisplayer;
61
import org.netbeans.spi.navigator.NavigatorPanel;
62
import org.netbeans.spi.navigator.NavigatorPanel;
63
import org.netbeans.spi.navigator.NavigatorPanelWithToolbar;
62
import org.netbeans.spi.navigator.NavigatorPanelWithUndo;
64
import org.netbeans.spi.navigator.NavigatorPanelWithUndo;
63
import org.openide.ErrorManager;
65
import org.openide.ErrorManager;
64
import org.openide.awt.UndoRedo;
66
import org.openide.awt.UndoRedo;
Lines 92-97 Link Here
92
            NbBundle.getMessage(NavigatorTC.class, "MSG_NotAvailable")); //NOI18N
94
            NbBundle.getMessage(NavigatorTC.class, "MSG_NotAvailable")); //NOI18N
93
    /** Listener for the panel selector combobox */
95
    /** Listener for the panel selector combobox */
94
    private ActionListener panelSelectionListener;
96
    private ActionListener panelSelectionListener;
97
    /** Testing purposes - component representing selected panel toolbar */
98
    private JComponent toolbarComponent;
95
99
96
    /** Creates new NavigatorTC, singleton */
100
    /** Creates new NavigatorTC, singleton */
97
    private NavigatorTC() {
101
    private NavigatorTC() {
Lines 214-219 Link Here
214
        } else {
218
        } else {
215
            contentArea.removeAll();
219
            contentArea.removeAll();
216
            contentArea.add(panel.getComponent(), BorderLayout.CENTER);
220
            contentArea.add(panel.getComponent(), BorderLayout.CENTER);
221
222
            pnlToolbar.removeAll();
223
            if (panel instanceof NavigatorPanelWithToolbar && ((NavigatorPanelWithToolbar)panel).getToolbarComponent() != null) {
224
                toolbarComponent = ((NavigatorPanelWithToolbar)panel).getToolbarComponent();
225
                GridBagConstraints gbc = new GridBagConstraints();
226
                gbc.anchor = GridBagConstraints.WEST;
227
                gbc.fill = GridBagConstraints.HORIZONTAL;
228
                gbc.weightx = 1.0;
229
                pnlToolbar.add(toolbarComponent, gbc);
230
                pnlToolbar.setVisible(true);
231
            } else {
232
                toolbarComponent = null;
233
                pnlToolbar.setVisible(false);
234
            }
217
            revalidate();
235
            revalidate();
218
            repaint();
236
            repaint();
219
        }
237
        }
Lines 336-341 Link Here
336
        return controller;
354
        return controller;
337
    }
355
    }
338
356
357
    /**
358
     * For testing
359
     */
360
    JComponent getToolbar() {
361
        return toolbarComponent;
362
    }
363
339
    /*************** private stuff ************/
364
    /*************** private stuff ************/
340
    
365
    
341
    /** Removes regular UI content and sets UI to empty state */
366
    /** Removes regular UI content and sets UI to empty state */
Lines 364-370 Link Here
364
        repaint();
389
        repaint();
365
    }
390
    }
366
    
391
    
367
    
392
368
    /** This method is called from within the constructor to
393
    /** This method is called from within the constructor to
369
     * initialize the form.
394
     * initialize the form.
370
     * WARNING: Do NOT modify this code. The content of this method is
395
     * WARNING: Do NOT modify this code. The content of this method is
Lines 372-387 Link Here
372
     */
397
     */
373
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
398
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
374
    private void initComponents() {
399
    private void initComponents() {
400
        java.awt.GridBagConstraints gridBagConstraints;
375
401
376
        holderPanel = new javax.swing.JPanel();
402
        holderPanel = new javax.swing.JPanel();
377
        panelSelector = new javax.swing.JComboBox();
403
        panelSelector = new javax.swing.JComboBox();
404
        pnlToolbar = new javax.swing.JPanel();
378
        contentArea = new javax.swing.JPanel();
405
        contentArea = new javax.swing.JPanel();
379
406
380
        setLayout(new java.awt.BorderLayout());
407
        setLayout(new java.awt.BorderLayout());
381
408
382
        holderPanel.setLayout(new java.awt.BorderLayout());
409
        holderPanel.setLayout(new java.awt.GridBagLayout());
383
        holderPanel.add(panelSelector, java.awt.BorderLayout.CENTER);
384
410
411
        panelSelector.setMinimumSize(new java.awt.Dimension(100, 20));
412
        gridBagConstraints = new java.awt.GridBagConstraints();
413
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.RELATIVE;
414
        gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
415
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
416
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
417
        gridBagConstraints.weightx = 1.0;
418
        holderPanel.add(panelSelector, gridBagConstraints);
419
420
        pnlToolbar.setOpaque(false);
421
        pnlToolbar.setLayout(new java.awt.GridBagLayout());
422
        gridBagConstraints = new java.awt.GridBagConstraints();
423
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.RELATIVE;
424
        gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
425
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
426
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
427
        gridBagConstraints.weightx = 1.5;
428
        gridBagConstraints.insets = new java.awt.Insets(0, 3, 0, 0);
429
        holderPanel.add(pnlToolbar, gridBagConstraints);
430
385
        add(holderPanel, java.awt.BorderLayout.NORTH);
431
        add(holderPanel, java.awt.BorderLayout.NORTH);
386
432
387
        contentArea.setLayout(new java.awt.BorderLayout());
433
        contentArea.setLayout(new java.awt.BorderLayout());
Lines 393-398 Link Here
393
    private javax.swing.JPanel contentArea;
439
    private javax.swing.JPanel contentArea;
394
    private javax.swing.JPanel holderPanel;
440
    private javax.swing.JPanel holderPanel;
395
    private javax.swing.JComboBox panelSelector;
441
    private javax.swing.JComboBox panelSelector;
442
    private javax.swing.JPanel pnlToolbar;
396
    // End of variables declaration//GEN-END:variables
443
    // End of variables declaration//GEN-END:variables
397
444
398
    
445
    
(-)spi.navigator/src/org/netbeans/spi/navigator/NavigatorPanelWithToolbar.java (+67 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2012 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 2012 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.spi.navigator;
43
44
import javax.swing.JComponent;
45
46
/** Description of navigation view with a toolbar component on top of basic
47
 * NavigatorPanel and NavigatorPanelWithUndo features.
48
 *
49
 * Clients will implement this interface when they need a toolbar for their Navigator view/panel.
50
 *
51
 * Implementors of this interface will be plugged into Navigator UI.
52
 * @see NavigatorPanel.Registration
53
 *
54
 * @since 1.25
55
 *
56
 * @author jpeska
57
 */
58
public interface NavigatorPanelWithToolbar extends NavigatorPanel {
59
60
    /** Returns a JComponent which represents panel toolbar.
61
     *
62
     * It allows clients to display a toolbar on top of the Navigator window, next to the panel chooser (ComboBox).
63
     *
64
     * @return Instance of JComponent.
65
     */
66
    public JComponent getToolbarComponent();
67
}
(-)spi.navigator/test/unit/src/org/netbeans/modules/navigator/NavigatorTCTest.java (+68 lines)
Lines 63-68 Link Here
63
import org.netbeans.spi.navigator.NavigatorHandler;
63
import org.netbeans.spi.navigator.NavigatorHandler;
64
import org.netbeans.spi.navigator.NavigatorLookupHint;
64
import org.netbeans.spi.navigator.NavigatorLookupHint;
65
import org.netbeans.spi.navigator.NavigatorPanel;
65
import org.netbeans.spi.navigator.NavigatorPanel;
66
import org.netbeans.spi.navigator.NavigatorPanelWithToolbar;
66
import org.netbeans.spi.navigator.NavigatorPanelWithUndo;
67
import org.netbeans.spi.navigator.NavigatorPanelWithUndo;
67
import org.openide.awt.UndoRedo;
68
import org.openide.awt.UndoRedo;
68
import org.openide.filesystems.FileObject;
69
import org.openide.filesystems.FileObject;
Lines 597-602 Link Here
597
            ic.remove(mime2Hint);
598
            ic.remove(mime2Hint);
598
        }
599
        }
599
    }
600
    }
601
602
    public void testFeature217091_Toolbar () throws Exception {
603
        System.out.println("Testing feature #217091, providing Toolbar...");
604
605
        InstanceContent ic = getInstanceContent();
606
607
        TestLookupHint toolbarHint = new TestLookupHint("toolbar/tester");
608
        ic.add(toolbarHint);
609
610
        NavigatorTC navTC = NavigatorTC.getInstance();
611
        NavigatorTCHandle navTCH = new NavigatorTCHandle(navTC);
612
        try {
613
            navTCH.open();
614
            waitForProviders(navTC);
615
616
            NavigatorPanel selPanel = navTC.getSelectedPanel();
617
            assertNotNull("Selected panel should not be null", navTC.getSelectedPanel());
618
            assertTrue("Panel class not expected", selPanel instanceof ToolbarProvider);
619
            ToolbarProvider provider = (ToolbarProvider)selPanel;
620
621
            JComponent toolbarProvider = provider.getToolbarComponent();
622
            JComponent toolbarTC = navTC.getToolbar();
623
624
            assertTrue("Expected toolbar " + toolbarProvider + ", but got " + toolbarTC, toolbarProvider == toolbarTC);
625
        } finally {
626
            // cleanup
627
            navTCH.close();
628
            ic.remove(toolbarHint);
629
        }
630
    }
600
    
631
    
601
    /** Singleton global lookup. Lookup change notification won't come
632
    /** Singleton global lookup. Lookup change notification won't come
602
     * if setting global lookup (UnitTestUtils.prepareTest) is called
633
     * if setting global lookup (UnitTestUtils.prepareTest) is called
Lines 886-891 Link Here
886
            return null;
917
            return null;
887
        }
918
        }
888
    }
919
    }
920
921
    public static final class ToolbarProvider implements NavigatorPanelWithToolbar {
922
923
        private JComponent toolbar;
924
925
        @Override
926
        public JComponent getToolbarComponent() {
927
            if (toolbar == null) {
928
                toolbar = new JLabel("dummy toolbar");
929
            }
930
            return toolbar;
931
        }
932
933
        public String getDisplayName() {
934
            return "Toolbar provider";
935
        }
936
937
        public String getDisplayHint() {
938
            return null;
939
        }
940
941
        public JComponent getComponent() {
942
            return new JLabel("dummy component");
943
        }
944
945
        public void panelActivated(Lookup context) {
946
            // no operation
947
        }
948
949
        public void panelDeactivated() {
950
            // no operation
951
        }
952
953
        public Lookup getLookup() {
954
            return null;
955
        }
956
    }
889
    
957
    
890
    public static abstract class LastSelBase implements NavigatorPanel {
958
    public static abstract class LastSelBase implements NavigatorPanel {
891
        
959
        
(-)spi.navigator/test/unit/src/org/netbeans/modules/navigator/resources/testCorrectCallsOfNavigatorPanelMethodsLayer.xml (+11 lines)
Lines 101-106 Link Here
101
            </folder>
101
            </folder>
102
        </folder>
102
        </folder>
103
    </folder>
103
    </folder>
104
105
    <!-- provider for testing Toolbar component -->
106
    <folder name="Navigator">
107
        <folder name="Panels">
108
            <folder name="toolbar">
109
                <folder name="tester">
110
                    <file name="org-netbeans-modules-navigator-NavigatorTCTest$ToolbarProvider.instance"/>
111
                </folder>
112
            </folder>
113
        </folder>
114
    </folder>
104
    
115
    
105
    <!-- provider for testing Explorer View integration -->
116
    <!-- provider for testing Explorer View integration -->
106
    <folder name="Navigator">
117
    <folder name="Navigator">

Return to bug 217091