# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: F:\Sources\Release55\core # 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: startup/src/org/netbeans/core/startup/Splash.java *** F:\Sources\Release55\core\startup\src\org\netbeans\core\startup\Splash.java Base (1.2.16.2) --- F:\Sources\Release55\core\startup\src\org\netbeans\core\startup\Splash.java Locally Modified (Based On 1.2.16.2) *************** *** 23,28 **** --- 23,30 ---- import java.awt.Frame; import java.awt.Graphics; import java.awt.Graphics2D; + import java.awt.GridBagConstraints; + import java.awt.GridBagLayout; import java.awt.Image; import java.awt.Rectangle; import java.awt.RenderingHints; *************** *** 48,55 **** import javax.swing.SwingConstants; import javax.swing.SwingUtilities; import javax.swing.WindowConstants; - import javax.swing.event.ChangeEvent; - import javax.swing.event.ChangeListener; import org.openide.ErrorManager; import org.openide.util.Utilities; import org.openide.util.NbBundle; --- 50,55 ---- *************** *** 58,64 **** * * @author Ian Formanek, David Peroutka */ ! public final class Splash implements SwingConstants { /** The splash image */ static Reference splashRef; --- 58,64 ---- * * @author Ian Formanek, David Peroutka */ ! public final class Splash implements SwingConstants { /** The splash image */ static Reference splashRef; *************** *** 66,77 **** /** The about image */ static Reference aboutRef; ! public static void showSplashDialog (java.awt.Frame parent, javax.swing.JComponent info) { ! createSplashDialog (parent, info).setVisible(true); } ! static JDialog createSplashDialog (java.awt.Frame parent, javax.swing.JComponent info) { ! SplashDialog splashDialog = new SplashDialog (parent, info); return splashDialog; } --- 66,77 ---- /** The about image */ static Reference aboutRef; ! public static void showSplashDialog (Frame parent, JComponent infoPanel, JComponent licensePanel) { ! createSplashDialog (parent, infoPanel, licensePanel).setVisible(true); } ! static JDialog createSplashDialog (Frame parent, JComponent infoPanel, JComponent licensePanel) { ! SplashDialog splashDialog = new SplashDialog (parent, infoPanel, licensePanel); return splashDialog; } *************** *** 182,187 **** --- 182,188 ---- } } + /** * This class implements double-buffered splash screen component. */ *************** *** 460,469 **** --- 461,475 ---- return new Dimension(image.getWidth (null), image.getHeight (null)); } + public Dimension getMinimumSize() { + return getPreferredSize(); + } + public boolean isOpaque () { return true; } + } private static class AboutComponent extends SplashComponent { *************** *** 559,573 **** private final SplashComponent splashComponent = new AboutComponent(); /** Creates a new SplashDialog */ ! public SplashDialog (java.awt.Frame parent, javax.swing.JComponent infoPanel) { super (parent, true); - JPanel splashPanel = new JPanel(); JTabbedPane tabbedPane = new JTabbedPane(); setTitle (NbBundle.getMessage(Splash.class, "CTL_About_Title")); ! // add splash component ! splashPanel.add (splashComponent); ! tabbedPane.addTab(NbBundle.getMessage(Splash.class, "CTL_About_Title"), splashPanel); tabbedPane.addTab(NbBundle.getMessage(Splash.class, "CTL_About_Detail"), infoPanel); getContentPane().add(tabbedPane, BorderLayout.CENTER); --- 565,576 ---- private final SplashComponent splashComponent = new AboutComponent(); /** Creates a new SplashDialog */ ! public SplashDialog (Frame parent, JComponent infoPanel, JComponent licensePanel) { super (parent, true); JTabbedPane tabbedPane = new JTabbedPane(); setTitle (NbBundle.getMessage(Splash.class, "CTL_About_Title")); ! tabbedPane.addTab(NbBundle.getMessage(Splash.class, "CTL_About_Title"), getSplashPanel(licensePanel)); tabbedPane.addTab(NbBundle.getMessage(Splash.class, "CTL_About_Detail"), infoPanel); getContentPane().add(tabbedPane, BorderLayout.CENTER); *************** *** 586,591 **** --- 589,620 ---- setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); } + /** Configures and returns content of first tab - splash panel, with + * possible license info if present. + * + * @param licenseComp component containing license/copyright info or null + * if not present. + * + * @return Component representing splash panel. + */ + private JComponent getSplashPanel (JComponent licenseComp) { + JPanel splashPanel = new JPanel(new GridBagLayout()); + splashPanel.add(splashComponent, new GridBagConstraints()); + + if (licenseComp != null) { + GridBagConstraints gridBagConstraints = new GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 1; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + splashPanel.add(licenseComp, gridBagConstraints); + } + + return splashPanel; + } + + /** * Prints the given progress message on the splash screen. * @param x specifies a string that is to be displayed Index: test/unit/src/org/netbeans/core/actions/AboutActionTest.java *** F:\Sources\Release55\core\test\unit\src\org\netbeans\core\actions\AboutActionTest.java No Base Revision --- F:\Sources\Release55\core\test\unit\src\org\netbeans\core\actions\AboutActionTest.java Locally New *************** *** 1,0 **** --- 1,67 ---- + /* + * Sun Public License Notice + * + * The contents of this file are subject to the Sun Public License + * Version 1.0 (the "License"). You may not use this file except in + * compliance with the License. A copy of the License is available at + * http://www.sun.com/ + * + * The Original Code is NetBeans. The Initial Developer of the Original + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + */ + + package org.netbeans.core.actions; + + import java.beans.PropertyVetoException; + import java.io.IOException; + import java.net.URL; + import javax.swing.JComponent; + import javax.swing.JScrollPane; + import javax.swing.JTextArea; + import javax.swing.text.Utilities; + import junit.framework.Assert; + import org.netbeans.junit.NbTestCase; + import org.openide.filesystems.Repository; + import org.openide.filesystems.XMLFileSystem; + import org.openide.util.Lookup; + import org.openide.util.lookup.Lookups; + import org.openide.util.lookup.ProxyLookup; + import org.xml.sax.SAXException; + + /** Simple test of correct loading of license files from About/Licenses folder. + * + * @author Dafe Simonek + */ + public class AboutActionTest extends NbTestCase { + + public AboutActionTest(String testName) { + super(testName); + } + + protected void setUp() throws Exception { + } + + protected void tearDown() throws Exception { + } + + public void testGetLicenseComp () throws Exception { + UnitTestUtils.prepareTest(new String [] { "/org/netbeans/core/actions/data/testGetLicenseCompLayer.xml" }); + + System.out.println("Testing loading and concatenating of multiple license files..."); + JComponent comp = AboutAction.getLicenseComp(); + assertNotNull("Component containing license/copyright is null", comp); + assertTrue(comp instanceof JScrollPane); + + comp = (JComponent) ((JScrollPane)comp).getViewport().getView(); + assertNotNull(comp); + + assertTrue(comp instanceof JTextArea); + + String text = ((JTextArea)comp).getText(); + assertTrue(text.indexOf("first license text") != -1); + assertTrue(text.indexOf("second license text") != -1); + } + + + } Index: test/unit/src/org/netbeans/core/actions/data/license2.txt *** F:\Sources\Release55\core\test\unit\src\org\netbeans\core\actions\data\license2.txt No Base Revision --- F:\Sources\Release55\core\test\unit\src\org\netbeans\core\actions\data\license2.txt Locally New *************** *** 1,0 **** --- 1,1 ---- + second license text. Index: test/unit/src/org/netbeans/core/actions/UnitTestUtils.java *** F:\Sources\Release55\core\test\unit\src\org\netbeans\core\actions\UnitTestUtils.java No Base Revision --- F:\Sources\Release55\core\test\unit\src\org\netbeans\core\actions\UnitTestUtils.java Locally New *************** *** 1,0 **** --- 1,106 ---- + /* + * Sun Public License Notice + * + * The contents of this file are subject to the Sun Public License + * Version 1.0 (the "License"). You may not use this file except in + * compliance with the License. A copy of the License is available at + * http://www.sun.com/ + * + * The Original Code is NetBeans. The Initial Developer of the Original + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun + * Microsystems, Inc. All Rights Reserved. + */ + + package org.netbeans.core.actions; + + import java.beans.PropertyVetoException; + import java.io.File; + import java.io.IOException; + import java.net.URL; + import javax.swing.text.Utilities; + import junit.framework.Assert; + import org.netbeans.junit.NbTestCase; + import org.openide.filesystems.FileObject; + import org.openide.filesystems.FileUtil; + import org.openide.filesystems.LocalFileSystem; + import org.openide.filesystems.Repository; + import org.openide.filesystems.XMLFileSystem; + import org.openide.util.Lookup; + import org.openide.util.lookup.Lookups; + import org.openide.util.lookup.ProxyLookup; + import org.xml.sax.SAXException; + + /** + * Allows tests to install own layers for testing. + * Copied from org.netbeans.api.project.TestUtil. + * + * @author Dafe Simonek + */ + public class UnitTestUtils extends ProxyLookup { + + public static UnitTestUtils DEFAULT_LOOKUP = null; + + /** Creates a new instance of UnitTestUtils */ + public UnitTestUtils() { + Assert.assertNull(DEFAULT_LOOKUP); + DEFAULT_LOOKUP = this; + } + + /** Makes global layer from given string resource info */ + public static void prepareTest(String[] stringLayers) + throws IOException, SAXException, PropertyVetoException { + prepareTest(stringLayers, null); + } + + public static void prepareTest (String[] stringLayers, Lookup lkp) + throws IOException, SAXException, PropertyVetoException { + URL[] layers = new URL[stringLayers.length]; + + for (int cntr = 0; cntr < layers.length; cntr++) { + layers[cntr] = Utilities.class.getResource(stringLayers[cntr]); + } + + XMLFileSystem system = new XMLFileSystem(); + system.setXmlUrls(layers); + + Repository repository = new Repository(system); + + if (lkp == null) { + DEFAULT_LOOKUP.setLookup(new Object[] { repository }, UnitTestUtils.class.getClassLoader()); + } else { + DEFAULT_LOOKUP.setLookup(new Object[] { repository }, lkp, UnitTestUtils.class.getClassLoader()); + } + } + + /** + * Set the global default lookup with some fixed instances including META-INF/services/*. + */ + private static void setLookup(Object[] instances, ClassLoader cl) { + DEFAULT_LOOKUP.setLookups(new Lookup[] { + Lookups.fixed(instances), + Lookups.metaInfServices(cl), + Lookups.singleton(cl), + }); + } + + private static void setLookup(Object[] instances, Lookup lkp, ClassLoader cl) { + DEFAULT_LOOKUP.setLookups(new Lookup[] { + lkp, + Lookups.fixed(instances), + Lookups.metaInfServices(cl), + Lookups.singleton(cl), + }); + } + + + static { + UnitTestUtils.class.getClassLoader().setDefaultAssertionStatus(true); + System.setProperty("org.openide.util.Lookup", UnitTestUtils.class.getName()); + Assert.assertEquals(UnitTestUtils.class, Lookup.getDefault().getClass()); + } + + public static void initLookup() { + //currently nothing. + } + + } Index: test/unit/src/org/netbeans/core/actions/data/testGetLicenseCompLayer.xml *** F:\Sources\Release55\core\test\unit\src\org\netbeans\core\actions\data\testGetLicenseCompLayer.xml No Base Revision --- F:\Sources\Release55\core\test\unit\src\org\netbeans\core\actions\data\testGetLicenseCompLayer.xml Locally New *************** *** 1,0 **** --- 1,11 ---- + + + + + + + + + + + Index: test/unit/src/org/netbeans/core/actions/data/license1.txt *** F:\Sources\Release55\core\test\unit\src\org\netbeans\core\actions\data\license1.txt No Base Revision --- F:\Sources\Release55\core\test\unit\src\org\netbeans\core\actions\data\license1.txt Locally New *************** *** 1,0 **** --- 1,1 ---- + first license text. Index: src/org/netbeans/core/actions/Bundle.properties *** F:\Sources\Release55\core\src\org\netbeans\core\actions\Bundle.properties Base (1.146) --- F:\Sources\Release55\core\src\org\netbeans\core\actions\Bundle.properties Locally Modified (Based On 1.146) *************** *** 50,52 **** --- 50,57 ---- # jump next/prev actions JumpNextAction=Ne&xt Error JumpPrevAction=&Previous Error + + # AboutAction - additional copyright notices in about box + EXC_LicenseReadBroken=Error during reading of license/copyright file {0}. + EXC_LicenseFileNotFound=License/copyright file {0} can't be found. + Index: src/org/netbeans/core/actions/AboutAction.java *** F:\Sources\Release55\core\src\org\netbeans\core\actions\AboutAction.java Base (1.20) --- F:\Sources\Release55\core\src\org\netbeans\core\actions\AboutAction.java Locally Modified (Based On 1.20) *************** *** 13,32 **** package org.netbeans.core.actions; ! import javax.swing.ImageIcon; ! import javax.swing.JMenuItem; ! ! import org.openide.awt.Mnemonics; import org.openide.util.HelpCtx; import org.openide.util.NbBundle; - import org.openide.util.Utilities; import org.openide.util.actions.CallableSystemAction; - import org.openide.util.actions.Presenter; import org.netbeans.core.startup.Splash; /** The action that shows the AboutBox. --- 13,40 ---- package org.netbeans.core.actions; ! import java.awt.Color; ! import java.awt.FontMetrics; ! import java.io.BufferedReader; ! import java.io.FileNotFoundException; ! import java.io.IOException; ! import java.io.InputStream; ! import java.io.InputStreamReader; ! import java.io.StringWriter; ! import java.text.MessageFormat; ! import javax.swing.JComponent; ! import javax.swing.JScrollPane; ! import javax.swing.JTextArea; ! import javax.swing.border.EmptyBorder; import org.openide.util.HelpCtx; import org.openide.util.NbBundle; import org.openide.util.actions.CallableSystemAction; import org.netbeans.core.startup.Splash; + import org.openide.ErrorManager; + import org.openide.filesystems.FileObject; + import org.openide.filesystems.FileSystem; + import org.openide.filesystems.Repository; /** The action that shows the AboutBox. * *************** *** 38,44 **** public void performAction () { Splash.showSplashDialog ( org.openide.windows.WindowManager.getDefault ().getMainWindow (), ! new org.netbeans.core.ui.ProductInformationPanel () ); } --- 49,56 ---- public void performAction () { Splash.showSplashDialog ( org.openide.windows.WindowManager.getDefault ().getMainWindow (), ! new org.netbeans.core.ui.ProductInformationPanel (), ! getLicenseComp() ); } *************** *** 54,60 **** --- 66,170 ---- return NbBundle.getMessage(AboutAction.class, "About"); } + /** Utility method; loads license text from About/License folder on default + * file system and feeds it into resulting text area. + * + * @return Text area containing loaded license text or null if no license + * file was found or some kind of other I/O error happenned. + */ + /* package private for tests */ static JComponent getLicenseComp () { + FileSystem fs = Repository.getDefault().getDefaultFileSystem(); + FileObject licenseFolder = fs.findResource("About/Licenses"); + if (licenseFolder == null) { + return null; } + + FileObject[] foArray = licenseFolder.getChildren(); + if (foArray.length <= 0) { + return null; + } + + String curLicense; + boolean isSomeLicense = false; + StringWriter sw = new StringWriter(); + for (int i = 0; i < foArray.length; i++) { + curLicense = loadLicenseText(foArray[i]); + if (curLicense != null) { + sw.write(curLicense); + isSomeLicense = true; + } + // new line between multiple licenses + if (i < foArray.length - 1) { + sw.append("\n"); //NOI18N + } + } + + if (!isSomeLicense) { + return null; + } + + JTextArea ta = new JTextArea(sw.toString(), 4, 0); + ta.setBorder(new EmptyBorder(5, 12, 0, 12)); + ta.setEditable(false); + ta.setBackground(new Color(0, 27, 51)); // harcoded color to match release55 splash background + ta.setForeground(Color.WHITE); + ta.setFont(ta.getFont().deriveFont((float)9)); + ta.setWrapStyleWord(true); + + JScrollPane sp = new JScrollPane(ta); + sp.setBorder(null); + + return sp; + } + + /** Tries to load text stored in given file object. + * + * @param fo File object to retrieve text from + * @return String containing text from the file, or null if file can't be found + * or some kind of I/O error appeared. + */ + private static String loadLicenseText (FileObject fo) { + InputStream is = null; + try { + is = fo.getInputStream(); + } catch (FileNotFoundException ex) { + // warning if license file not found + String msg = MessageFormat.format( + NbBundle.getBundle(AboutAction.class).getString("EXC_LicenseFileNotFound"), + new Object[] { fo.getPath() } + ); + ErrorManager em = ErrorManager.getDefault(); + em.annotate(ex, msg); + em.notify(ErrorManager.INFORMATIONAL, ex); + return null; + } + + BufferedReader in = new BufferedReader(new InputStreamReader(is)); + StringWriter result = new StringWriter(); + int curChar; + try { + // reading content of license file + while ((curChar = in.read()) != -1) { + result.write(curChar); + } + } catch (IOException ex) { + // don't return anything if any problem during read + String msg = MessageFormat.format( + NbBundle.getBundle(AboutAction.class).getString("EXC_LicenseReadBroken"), + new Object[] { fo.getPath() } + ); + ErrorManager em = ErrorManager.getDefault(); + em.annotate(ex, msg); + em.notify(ErrorManager.INFORMATIONAL, ex); + return null; + } + + return result.toString(); + } + + + }