# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: C:\Projects\core-main # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. Index: spi.navigator/apichanges.xml --- spi.navigator/apichanges.xml Base (BASE) +++ spi.navigator/apichanges.xml Locally Modified (Based On LOCAL) @@ -108,6 +108,21 @@ + + + Added SPI interface NavigatorPanelWithToolbar + + + + + +

+ Added SPI interface NavigatorPanelWithToolbar. Clients will implement this interface when they need a toolbar for their Navigator view/panel. +

+
+ + +
Added @NavigatorPanel.Registration Index: spi.navigator/manifest.mf --- spi.navigator/manifest.mf Base (BASE) +++ spi.navigator/manifest.mf Locally Modified (Based On LOCAL) @@ -2,4 +2,4 @@ OpenIDE-Module: org.netbeans.spi.navigator/1 OpenIDE-Module-Layer: org/netbeans/modules/navigator/resources/layer.xml OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/navigator/resources/Bundle.properties -OpenIDE-Module-Specification-Version: 1.24 +OpenIDE-Module-Specification-Version: 1.25 Index: spi.navigator/src/org/netbeans/modules/navigator/LazyPanel.java --- spi.navigator/src/org/netbeans/modules/navigator/LazyPanel.java Base (BASE) +++ spi.navigator/src/org/netbeans/modules/navigator/LazyPanel.java Locally Modified (Based On LOCAL) @@ -45,6 +45,7 @@ import java.util.Map; import javax.swing.JComponent; import org.netbeans.spi.navigator.NavigatorPanel; +import org.netbeans.spi.navigator.NavigatorPanelWithToolbar; import org.netbeans.spi.navigator.NavigatorPanelWithUndo; import org.openide.awt.UndoRedo; import org.openide.util.Lookup; @@ -52,7 +53,7 @@ /** * Delegating panel for use from {@link NavigatorPanel.Registration}. */ -public class LazyPanel implements NavigatorPanelWithUndo { +public class LazyPanel implements NavigatorPanelWithUndo, NavigatorPanelWithToolbar { /** * Referenced from generated layer. @@ -112,4 +113,9 @@ return p instanceof NavigatorPanelWithUndo ? ((NavigatorPanelWithUndo) p).getUndoRedo() : UndoRedo.NONE; } + @Override + public JComponent getToolbarComponent() { + NavigatorPanel p = initialize(); + return p instanceof NavigatorPanelWithToolbar ? ((NavigatorPanelWithToolbar) p).getToolbarComponent() : null; + } } Index: spi.navigator/src/org/netbeans/modules/navigator/NavigatorTC.form --- spi.navigator/src/org/netbeans/modules/navigator/NavigatorTC.form Base (BASE) +++ spi.navigator/src/org/netbeans/modules/navigator/NavigatorTC.form Locally Modified (Based On LOCAL) @@ -7,6 +7,7 @@ + @@ -22,15 +23,32 @@ - + + + + + + - - + + + + + + + + + + + + + + Index: spi.navigator/src/org/netbeans/modules/navigator/NavigatorTC.java --- spi.navigator/src/org/netbeans/modules/navigator/NavigatorTC.java Base (BASE) +++ spi.navigator/src/org/netbeans/modules/navigator/NavigatorTC.java Locally Modified (Based On LOCAL) @@ -46,6 +46,7 @@ import java.awt.BorderLayout; import java.awt.Color; +import java.awt.GridBagConstraints; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.List; @@ -59,6 +60,7 @@ import javax.swing.UIManager; import org.netbeans.spi.navigator.NavigatorDisplayer; import org.netbeans.spi.navigator.NavigatorPanel; +import org.netbeans.spi.navigator.NavigatorPanelWithToolbar; import org.netbeans.spi.navigator.NavigatorPanelWithUndo; import org.openide.ErrorManager; import org.openide.awt.UndoRedo; @@ -92,6 +94,8 @@ NbBundle.getMessage(NavigatorTC.class, "MSG_NotAvailable")); //NOI18N /** Listener for the panel selector combobox */ private ActionListener panelSelectionListener; + /** Testing purposes - component representing selected panel toolbar */ + private JComponent toolbarComponent; /** Creates new NavigatorTC, singleton */ private NavigatorTC() { @@ -214,6 +218,20 @@ } else { contentArea.removeAll(); contentArea.add(panel.getComponent(), BorderLayout.CENTER); + + pnlToolbar.removeAll(); + if (panel instanceof NavigatorPanelWithToolbar && ((NavigatorPanelWithToolbar)panel).getToolbarComponent() != null) { + toolbarComponent = ((NavigatorPanelWithToolbar)panel).getToolbarComponent(); + GridBagConstraints gbc = new GridBagConstraints(); + gbc.anchor = GridBagConstraints.WEST; + gbc.fill = GridBagConstraints.HORIZONTAL; + gbc.weightx = 1.0; + pnlToolbar.add(toolbarComponent, gbc); + pnlToolbar.setVisible(true); + } else { + toolbarComponent = null; + pnlToolbar.setVisible(false); + } revalidate(); repaint(); } @@ -336,6 +354,13 @@ return controller; } + /** + * For testing + */ + JComponent getToolbar() { + return toolbarComponent; + } + /*************** private stuff ************/ /** Removes regular UI content and sets UI to empty state */ @@ -364,7 +389,7 @@ repaint(); } - + /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is @@ -372,16 +397,37 @@ */ // //GEN-BEGIN:initComponents private void initComponents() { + java.awt.GridBagConstraints gridBagConstraints; holderPanel = new javax.swing.JPanel(); panelSelector = new javax.swing.JComboBox(); + pnlToolbar = new javax.swing.JPanel(); contentArea = new javax.swing.JPanel(); setLayout(new java.awt.BorderLayout()); - holderPanel.setLayout(new java.awt.BorderLayout()); - holderPanel.add(panelSelector, java.awt.BorderLayout.CENTER); + holderPanel.setLayout(new java.awt.GridBagLayout()); + panelSelector.setMinimumSize(new java.awt.Dimension(100, 20)); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridwidth = java.awt.GridBagConstraints.RELATIVE; + gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; + gridBagConstraints.weightx = 1.0; + holderPanel.add(panelSelector, gridBagConstraints); + + pnlToolbar.setOpaque(false); + pnlToolbar.setLayout(new java.awt.GridBagLayout()); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridwidth = java.awt.GridBagConstraints.RELATIVE; + gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; + gridBagConstraints.weightx = 1.5; + gridBagConstraints.insets = new java.awt.Insets(0, 3, 0, 0); + holderPanel.add(pnlToolbar, gridBagConstraints); + add(holderPanel, java.awt.BorderLayout.NORTH); contentArea.setLayout(new java.awt.BorderLayout()); @@ -393,6 +439,7 @@ private javax.swing.JPanel contentArea; private javax.swing.JPanel holderPanel; private javax.swing.JComboBox panelSelector; + private javax.swing.JPanel pnlToolbar; // End of variables declaration//GEN-END:variables Index: spi.navigator/src/org/netbeans/spi/navigator/NavigatorPanelWithToolbar.java --- spi.navigator/src/org/netbeans/spi/navigator/NavigatorPanelWithToolbar.java Base (BASE) +++ spi.navigator/src/org/netbeans/spi/navigator/NavigatorPanelWithToolbar.java Locally New @@ -0,0 +1,67 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2012 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2012 Sun Microsystems, Inc. + */ +package org.netbeans.spi.navigator; + +import javax.swing.JComponent; + +/** Description of navigation view with a toolbar component on top of basic + * NavigatorPanel and NavigatorPanelWithUndo features. + * + * Clients will implement this interface when they need a toolbar for their Navigator view/panel. + * + * Implementors of this interface will be plugged into Navigator UI. + * @see NavigatorPanel.Registration + * + * @since 1.25 + * + * @author jpeska + */ +public interface NavigatorPanelWithToolbar extends NavigatorPanel { + + /** Returns a JComponent which represents panel toolbar. + * + * It allows clients to display a toolbar on top of the Navigator window, next to the panel chooser (ComboBox). + * + * @return Instance of JComponent. + */ + public JComponent getToolbarComponent(); +} Index: spi.navigator/test/unit/src/org/netbeans/modules/navigator/NavigatorTCTest.java --- spi.navigator/test/unit/src/org/netbeans/modules/navigator/NavigatorTCTest.java Base (BASE) +++ spi.navigator/test/unit/src/org/netbeans/modules/navigator/NavigatorTCTest.java Locally Modified (Based On LOCAL) @@ -63,6 +63,7 @@ import org.netbeans.spi.navigator.NavigatorHandler; import org.netbeans.spi.navigator.NavigatorLookupHint; import org.netbeans.spi.navigator.NavigatorPanel; +import org.netbeans.spi.navigator.NavigatorPanelWithToolbar; import org.netbeans.spi.navigator.NavigatorPanelWithUndo; import org.openide.awt.UndoRedo; import org.openide.filesystems.FileObject; @@ -597,6 +598,36 @@ ic.remove(mime2Hint); } } + + public void testFeature217091_Toolbar () throws Exception { + System.out.println("Testing feature #217091, providing Toolbar..."); + + InstanceContent ic = getInstanceContent(); + + TestLookupHint toolbarHint = new TestLookupHint("toolbar/tester"); + ic.add(toolbarHint); + + NavigatorTC navTC = NavigatorTC.getInstance(); + NavigatorTCHandle navTCH = new NavigatorTCHandle(navTC); + try { + navTCH.open(); + waitForProviders(navTC); + + NavigatorPanel selPanel = navTC.getSelectedPanel(); + assertNotNull("Selected panel should not be null", navTC.getSelectedPanel()); + assertTrue("Panel class not expected", selPanel instanceof ToolbarProvider); + ToolbarProvider provider = (ToolbarProvider)selPanel; + + JComponent toolbarProvider = provider.getToolbarComponent(); + JComponent toolbarTC = navTC.getToolbar(); + + assertTrue("Expected toolbar " + toolbarProvider + ", but got " + toolbarTC, toolbarProvider == toolbarTC); + } finally { + // cleanup + navTCH.close(); + ic.remove(toolbarHint); + } + } /** Singleton global lookup. Lookup change notification won't come * if setting global lookup (UnitTestUtils.prepareTest) is called @@ -886,6 +917,43 @@ return null; } } + + public static final class ToolbarProvider implements NavigatorPanelWithToolbar { + + private JComponent toolbar; + + @Override + public JComponent getToolbarComponent() { + if (toolbar == null) { + toolbar = new JLabel("dummy toolbar"); + } + return toolbar; + } + + public String getDisplayName() { + return "Toolbar provider"; + } + + public String getDisplayHint() { + return null; + } + + public JComponent getComponent() { + return new JLabel("dummy component"); + } + + public void panelActivated(Lookup context) { + // no operation + } + + public void panelDeactivated() { + // no operation + } + + public Lookup getLookup() { + return null; + } + } public static abstract class LastSelBase implements NavigatorPanel { Index: spi.navigator/test/unit/src/org/netbeans/modules/navigator/resources/testCorrectCallsOfNavigatorPanelMethodsLayer.xml --- spi.navigator/test/unit/src/org/netbeans/modules/navigator/resources/testCorrectCallsOfNavigatorPanelMethodsLayer.xml Base (BASE) +++ spi.navigator/test/unit/src/org/netbeans/modules/navigator/resources/testCorrectCallsOfNavigatorPanelMethodsLayer.xml Locally Modified (Based On LOCAL) @@ -101,6 +101,17 @@ + + + + + + + + + + +