diff -r e2a3e210c3db .hgignore --- a/.hgignore Tue Feb 16 14:13:16 2010 +0100 +++ b/.hgignore Tue Feb 16 15:45:47 2010 +0100 @@ -20,6 +20,7 @@ ^\.externalToolBuilders/.*$ ^hs_err_pid[0-9]*\.log ^[^/]+/external/[^/]+\.(zip|jar|gz|bz2|gem|dll|xpi)$ +^apisupport.equinoxdemo/equinoxdemo/netbinox/.*$ ^o.apache.tools.ant.module/external/lib$ ^classfile/\.nbintdb$ ^classfile/classfile\.jar$ diff -r e2a3e210c3db apisupport.equinoxdemo/build.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apisupport.equinoxdemo/build.xml Tue Feb 16 15:45:47 2010 +0100 @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff -r e2a3e210c3db apisupport.equinoxdemo/equinoxdemo/branding/core/core.jar/org/netbeans/core/startup/Bundle.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apisupport.equinoxdemo/equinoxdemo/branding/core/core.jar/org/netbeans/core/startup/Bundle.properties Tue Feb 16 15:45:47 2010 +0100 @@ -0,0 +1,2 @@ +currentVersion=Equinox Sample {0} +LBL_splash_window_title=Starting Equinox Sample diff -r e2a3e210c3db apisupport.equinoxdemo/equinoxdemo/branding/modules/org-netbeans-core-windows.jar/org/netbeans/core/windows/view/ui/Bundle.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apisupport.equinoxdemo/equinoxdemo/branding/modules/org-netbeans-core-windows.jar/org/netbeans/core/windows/view/ui/Bundle.properties Tue Feb 16 15:45:47 2010 +0100 @@ -0,0 +1,2 @@ +CTL_MainWindow_Title=Equinox Sample {0} +CTL_MainWindow_Title_No_Project=Equinox Sample {0} diff -r e2a3e210c3db apisupport.equinoxdemo/equinoxdemo/build.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apisupport.equinoxdemo/equinoxdemo/build.xml Tue Feb 16 15:45:47 2010 +0100 @@ -0,0 +1,15 @@ + + + + + + Builds the module suite equinox-suite. + + + + + + + + + diff -r e2a3e210c3db apisupport.equinoxdemo/equinoxdemo/nbproject/build-impl.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apisupport.equinoxdemo/equinoxdemo/nbproject/build-impl.xml Tue Feb 16 15:45:47 2010 +0100 @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r e2a3e210c3db apisupport.equinoxdemo/equinoxdemo/nbproject/genfiles.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apisupport.equinoxdemo/equinoxdemo/nbproject/genfiles.properties Tue Feb 16 15:45:47 2010 +0100 @@ -0,0 +1,8 @@ +build.xml.data.CRC32=4e759413 +build.xml.script.CRC32=b432f9be +build.xml.stylesheet.CRC32=531c622b@1.36 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=4e759413 +nbproject/build-impl.xml.script.CRC32=1e22e482 +nbproject/build-impl.xml.stylesheet.CRC32=56de960a@1.37 diff -r e2a3e210c3db apisupport.equinoxdemo/equinoxdemo/nbproject/platform.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apisupport.equinoxdemo/equinoxdemo/nbproject/platform.properties Tue Feb 16 15:45:47 2010 +0100 @@ -0,0 +1,27 @@ +cluster.path=\ + ${nbplatform.active.dir}/harness:\ + ${nbplatform.active.dir}/platform:\ + netbinox +disabled.modules=\ + org.jdesktop.layout,\ + org.netbeans.api.visual,\ + org.netbeans.core.execution,\ + org.netbeans.core.multiview,\ + org.netbeans.insane,\ + org.netbeans.libs.felix,\ + org.netbeans.libs.jsr223,\ + org.netbeans.modules.apisupport.harness,\ + org.netbeans.modules.apisupport.tc.cobertura,\ + org.netbeans.modules.autoupdate.services,\ + org.netbeans.modules.autoupdate.ui,\ + org.netbeans.modules.core.kit,\ + org.netbeans.modules.favorites,\ + org.netbeans.modules.jellytools.platform,\ + org.netbeans.modules.jemmy,\ + org.openide.compat,\ + org.openide.execution,\ + org.openide.options,\ + org.openide.util.enumerations +extcluster.netbinox.javadoc= +extcluster.netbinox.sources= +nbplatform.active=default diff -r e2a3e210c3db apisupport.equinoxdemo/equinoxdemo/nbproject/project.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apisupport.equinoxdemo/equinoxdemo/nbproject/project.properties Tue Feb 16 15:45:47 2010 +0100 @@ -0,0 +1,8 @@ +app.icon=branding/core/core.jar/org/netbeans/core/startup/frame48.gif +project.license=gpl20 +app.name=equinoxsample +app.title=Equinox Sample +branding.token=${app.name} +modules=\ + ${project.org.apidesign.netbinox.showbundles} +project.org.apidesign.netbinox.showbundles=showbundles diff -r e2a3e210c3db apisupport.equinoxdemo/equinoxdemo/nbproject/project.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apisupport.equinoxdemo/equinoxdemo/nbproject/project.xml Tue Feb 16 15:45:47 2010 +0100 @@ -0,0 +1,9 @@ + + + org.netbeans.modules.apisupport.project.suite + + + equinox-suite + + + diff -r e2a3e210c3db apisupport.equinoxdemo/equinoxdemo/showbundles/build.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apisupport.equinoxdemo/equinoxdemo/showbundles/build.xml Tue Feb 16 15:45:47 2010 +0100 @@ -0,0 +1,8 @@ + + + + + + Builds, tests, and runs the project org.apidesign.netbinox.showbundles. + + diff -r e2a3e210c3db apisupport.equinoxdemo/equinoxdemo/showbundles/manifest.mf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apisupport.equinoxdemo/equinoxdemo/showbundles/manifest.mf Tue Feb 16 15:45:47 2010 +0100 @@ -0,0 +1,9 @@ +Manifest-Version: 1.0 +Bundle-Activator: org.apidesign.netbinox.showbundles.Installer +Bundle-Localization: org/apidesign/netbinox/showbundles/Bundle +Bundle-Name: %OpenIDE-Module-Name +Bundle-SymbolicName: org.apidesign.netbinox.showbundles +Bundle-Version: 1.0 +Import-Package: org.osgi.framework +OpenIDE-Module-Layer: org/apidesign/netbinox/showbundles/layer.xml + diff -r e2a3e210c3db apisupport.equinoxdemo/equinoxdemo/showbundles/nbproject/build-impl.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apisupport.equinoxdemo/equinoxdemo/showbundles/nbproject/build-impl.xml Tue Feb 16 15:45:47 2010 +0100 @@ -0,0 +1,45 @@ + + + + + + + + + + + + + You must set 'suite.dir' to point to your containing module suite + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r e2a3e210c3db apisupport.equinoxdemo/equinoxdemo/showbundles/nbproject/genfiles.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apisupport.equinoxdemo/equinoxdemo/showbundles/nbproject/genfiles.properties Tue Feb 16 15:45:47 2010 +0100 @@ -0,0 +1,8 @@ +build.xml.data.CRC32=3a4a90c7 +build.xml.script.CRC32=fe55fcc8 +build.xml.stylesheet.CRC32=79c3b980@1.37 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=3a4a90c7 +nbproject/build-impl.xml.script.CRC32=0acebef1 +nbproject/build-impl.xml.stylesheet.CRC32=261c4bef@1.37 diff -r e2a3e210c3db apisupport.equinoxdemo/equinoxdemo/showbundles/nbproject/project.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apisupport.equinoxdemo/equinoxdemo/showbundles/nbproject/project.properties Tue Feb 16 15:45:47 2010 +0100 @@ -0,0 +1,2 @@ +javac.source=1.6 +javac.compilerargs=-Xlint -Xlint:-serial diff -r e2a3e210c3db apisupport.equinoxdemo/equinoxdemo/showbundles/nbproject/project.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apisupport.equinoxdemo/equinoxdemo/showbundles/nbproject/project.xml Tue Feb 16 15:45:47 2010 +0100 @@ -0,0 +1,92 @@ + + + org.netbeans.modules.apisupport.project + + + org.apidesign.netbinox.showbundles + + + + org.netbeans.libs.osgi + + + + 1.0 + + + + org.netbeans.modules.settings + + + + 1 + 1.25 + + + + org.openide.awt + + + + 7.21 + + + + org.openide.explorer + + + + 6.26 + + + + org.openide.nodes + + + + 7.14 + + + + org.openide.util + + + + 8.1 + + + + org.openide.util.lookup + + + + 8.1 + + + + org.openide.windows + + + + 6.32 + + + + + + unit + + org.netbeans.libs.junit4 + + + + org.netbeans.modules.nbjunit + + + + + + + + + diff -r e2a3e210c3db apisupport.equinoxdemo/equinoxdemo/showbundles/nbproject/suite.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apisupport.equinoxdemo/equinoxdemo/showbundles/nbproject/suite.properties Tue Feb 16 15:45:47 2010 +0100 @@ -0,0 +1,1 @@ +suite.dir=${basedir}/.. diff -r e2a3e210c3db apisupport.equinoxdemo/equinoxdemo/showbundles/src/org/apidesign/netbinox/showbundles/Bundle.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apisupport.equinoxdemo/equinoxdemo/showbundles/src/org/apidesign/netbinox/showbundles/Bundle.properties Tue Feb 16 15:45:47 2010 +0100 @@ -0,0 +1,6 @@ +CTL_ShowBundlesAction=ShowBundles +CTL_ShowBundlesTopComponent=ShowBundles Window +HINT_ShowBundlesTopComponent=This is a ShowBundles window +OpenIDE-Module-Name=Show OSGi Bundle List + +LAB_AllBundles=All Bundles diff -r e2a3e210c3db apisupport.equinoxdemo/equinoxdemo/showbundles/src/org/apidesign/netbinox/showbundles/Installer.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apisupport.equinoxdemo/equinoxdemo/showbundles/src/org/apidesign/netbinox/showbundles/Installer.java Tue Feb 16 15:45:47 2010 +0100 @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2010 Jaroslav Tulach + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +package org.apidesign.netbinox.showbundles; + +import java.awt.Image; +import org.openide.nodes.BeanNode; +import org.openide.nodes.Children; +import org.openide.nodes.Node; +import org.openide.util.Exceptions; +import org.openide.util.ImageUtilities; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.osgi.framework.BundleEvent; +import org.osgi.framework.BundleListener; + +/** + * Remembers connection to BundleContext. + */ +public class Installer implements BundleActivator { + private static BundleContext context; + + @Override + public void start(BundleContext c) throws Exception { + context = c; + } + + @Override + public void stop(BundleContext c) throws Exception { + context = null; + } + + public static Children createBundleChildren() { + assert context != null; + return new BundleChildren(); + } + + private static final class BundleChildren extends Children.Keys + implements BundleListener { + @Override + protected void addNotify() { + context.addBundleListener(this); + bundleChanged(null); + } + + @Override + protected void removeNotify() { + context.removeBundleListener(this); + } + + @Override + protected Node[] createNodes(Bundle t) { + try { + Node bn = new BeanNode(t) { + @Override + public Image getIcon(int type) { + if (getBean().getLocation().startsWith("netigso:/")) { // NOI18N + return ImageUtilities.loadImage("org/apidesign/netbinox/showbundles/module.png"); + } else { + return ImageUtilities.loadImage("org/apidesign/netbinox/showbundles/bundle.png"); + } + } + + @Override + public Image getOpenedIcon(int type) { + return getIcon(type); + } + }; + bn.setName(t.getSymbolicName()); + return new Node[]{bn}; + } catch (Exception ex) { + Exceptions.printStackTrace(ex); + return null; + } + } + + @Override + public void bundleChanged(BundleEvent be) { + setKeys(context.getBundles()); + } + } +} diff -r e2a3e210c3db apisupport.equinoxdemo/equinoxdemo/showbundles/src/org/apidesign/netbinox/showbundles/ShowBundlesTopComponent.form --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apisupport.equinoxdemo/equinoxdemo/showbundles/src/org/apidesign/netbinox/showbundles/ShowBundlesTopComponent.form Tue Feb 16 15:45:47 2010 +0100 @@ -0,0 +1,58 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff -r e2a3e210c3db apisupport.equinoxdemo/equinoxdemo/showbundles/src/org/apidesign/netbinox/showbundles/ShowBundlesTopComponent.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apisupport.equinoxdemo/equinoxdemo/showbundles/src/org/apidesign/netbinox/showbundles/ShowBundlesTopComponent.java Tue Feb 16 15:45:47 2010 +0100 @@ -0,0 +1,166 @@ +/* + * Copyright (C) 2010 Jaroslav Tulach + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +package org.apidesign.netbinox.showbundles; + +import java.util.logging.Logger; +import org.openide.util.NbBundle; +import org.openide.windows.TopComponent; +import org.openide.windows.WindowManager; +import org.netbeans.api.settings.ConvertAsProperties; +import org.openide.explorer.ExplorerManager; +import org.openide.nodes.AbstractNode; +import org.openide.util.ImageUtilities; + +/** + * Top component which displays list of bundles. + */ +@ConvertAsProperties(dtd = "-//org.apidesign.netbinox.showbundles//ShowBundles//EN", +autostore = false) +public final class ShowBundlesTopComponent extends TopComponent +implements ExplorerManager.Provider { + private ExplorerManager em; + private static ShowBundlesTopComponent instance; + private static final String PREFERRED_ID = "ShowBundlesTopComponent"; + + public ShowBundlesTopComponent() { + setIcon(ImageUtilities.loadImage("org/apidesign/netbinox/showbundles/bundle.png")); // NOI18N + AbstractNode root = new AbstractNode(Installer.createBundleChildren()); + root.setName("bundles"); // NOI18N + root.setIconBaseWithExtension("org/apidesign/netbinox/showbundles/bundle.png"); // NOI18N + root.setDisplayName(NbBundle.getMessage(ShowBundlesTopComponent.class, "LAB_AllBundles")); + this.em = new ExplorerManager(); + em.setRootContext(root); + initComponents(); + setName(NbBundle.getMessage(ShowBundlesTopComponent.class, "CTL_ShowBundlesTopComponent")); + setToolTipText(NbBundle.getMessage(ShowBundlesTopComponent.class, "HINT_ShowBundlesTopComponent")); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + split = new javax.swing.JSplitPane(); + tree = new org.openide.explorer.view.BeanTreeView(); + sheet = new org.openide.explorer.propertysheet.PropertySheetView(); + + split.setLeftComponent(tree); + split.setRightComponent(sheet); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(split, javax.swing.GroupLayout.DEFAULT_SIZE, 1168, Short.MAX_VALUE) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(split, javax.swing.GroupLayout.DEFAULT_SIZE, 486, Short.MAX_VALUE) + .addContainerGap()) + ); + }// //GEN-END:initComponents + + // Variables declaration - do not modify//GEN-BEGIN:variables + private org.openide.explorer.propertysheet.PropertySheetView sheet; + private javax.swing.JSplitPane split; + private org.openide.explorer.view.BeanTreeView tree; + // End of variables declaration//GEN-END:variables + /** + * Gets default instance. Do not use directly: reserved for *.settings files only, + * i.e. deserialization routines; otherwise you could get a non-deserialized instance. + * To obtain the singleton instance, use {@link #findInstance}. + */ + public static synchronized ShowBundlesTopComponent getDefault() { + if (instance == null) { + instance = new ShowBundlesTopComponent(); + } + return instance; + } + + /** + * Obtain the ShowBundlesTopComponent instance. Never call {@link #getDefault} directly! + */ + public static synchronized ShowBundlesTopComponent findInstance() { + TopComponent win = WindowManager.getDefault().findTopComponent(PREFERRED_ID); + if (win == null) { + Logger.getLogger(ShowBundlesTopComponent.class.getName()).warning( + "Cannot find " + PREFERRED_ID + " component. It will not be located properly in the window system."); + return getDefault(); + } + if (win instanceof ShowBundlesTopComponent) { + return (ShowBundlesTopComponent) win; + } + Logger.getLogger(ShowBundlesTopComponent.class.getName()).warning( + "There seem to be multiple components with the '" + PREFERRED_ID + + "' ID. That is a potential source of errors and unexpected behavior."); + return getDefault(); + } + + @Override + public int getPersistenceType() { + return TopComponent.PERSISTENCE_ALWAYS; + } + + @Override + public void componentOpened() { + // TODO add custom code on component opening + } + + @Override + public void componentClosed() { + // TODO add custom code on component closing + } + + void writeProperties(java.util.Properties p) { + // better to version settings since initial version as advocated at + // http://wiki.apidesign.org/wiki/PropertyFiles + p.setProperty("version", "1.0"); + // TODO store your settings + } + + Object readProperties(java.util.Properties p) { + if (instance == null) { + instance = this; + } + instance.readPropertiesImpl(p); + return instance; + } + + private void readPropertiesImpl(java.util.Properties p) { + String version = p.getProperty("version"); + // TODO read your settings according to their version + } + + @Override + protected String preferredID() { + return PREFERRED_ID; + } + + @Override + public ExplorerManager getExplorerManager() { + return em; + } +} diff -r e2a3e210c3db apisupport.equinoxdemo/equinoxdemo/showbundles/src/org/apidesign/netbinox/showbundles/ShowBundlesTopComponentSettings.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apisupport.equinoxdemo/equinoxdemo/showbundles/src/org/apidesign/netbinox/showbundles/ShowBundlesTopComponentSettings.xml Tue Feb 16 15:45:47 2010 +0100 @@ -0,0 +1,12 @@ + + + + + + + + + diff -r e2a3e210c3db apisupport.equinoxdemo/equinoxdemo/showbundles/src/org/apidesign/netbinox/showbundles/ShowBundlesTopComponentWstcref.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apisupport.equinoxdemo/equinoxdemo/showbundles/src/org/apidesign/netbinox/showbundles/ShowBundlesTopComponentWstcref.xml Tue Feb 16 15:45:47 2010 +0100 @@ -0,0 +1,11 @@ + + + + + + + + diff -r e2a3e210c3db apisupport.equinoxdemo/equinoxdemo/showbundles/src/org/apidesign/netbinox/showbundles/bundle.png Binary file apisupport.equinoxdemo/equinoxdemo/showbundles/src/org/apidesign/netbinox/showbundles/bundle.png has changed diff -r e2a3e210c3db apisupport.equinoxdemo/equinoxdemo/showbundles/src/org/apidesign/netbinox/showbundles/layer.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apisupport.equinoxdemo/equinoxdemo/showbundles/src/org/apidesign/netbinox/showbundles/layer.xml Tue Feb 16 15:45:47 2010 +0100 @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r e2a3e210c3db apisupport.equinoxdemo/equinoxdemo/showbundles/src/org/apidesign/netbinox/showbundles/module.png Binary file apisupport.equinoxdemo/equinoxdemo/showbundles/src/org/apidesign/netbinox/showbundles/module.png has changed diff -r e2a3e210c3db apisupport.equinoxdemo/equinoxdemo/showbundles/test/unit/src/org/apidesign/netbinox/showbundles/InstallerTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apisupport.equinoxdemo/equinoxdemo/showbundles/test/unit/src/org/apidesign/netbinox/showbundles/InstallerTest.java Tue Feb 16 15:45:47 2010 +0100 @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2010 Jaroslav Tulach + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +package org.apidesign.netbinox.showbundles; + +import java.util.List; +import junit.framework.Test; +import org.netbeans.junit.NbModuleSuite; +import org.netbeans.junit.NbTestCase; +import org.openide.nodes.Children; +import org.openide.nodes.Node; + +/** Integration test that launches the application and checks + * the status of enabled bundles. + */ +public class InstallerTest extends NbTestCase { + + public InstallerTest(String testName) { + super(testName); + } + + public static Test suite() { + return NbModuleSuite.create( + NbModuleSuite.emptyConfiguration().addTest(InstallerTest.class).gui(false) + .clusters(".*") + ); + } + + public void testChildrenAndTheirNodes() throws Exception { + Children ch = Installer.createBundleChildren(); + List arr = ch.snapshot(); + + for (Node n : arr) { + if (n.getName().contains("equinox")) { + // OK + return; + } + } + fail("Equinox not found: " + arr); + } +} diff -r e2a3e210c3db apisupport.equinoxdemo/manifest.mf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apisupport.equinoxdemo/manifest.mf Tue Feb 16 15:45:47 2010 +0100 @@ -0,0 +1,6 @@ +Manifest-Version: 1.0 +OpenIDE-Module: org.netbeans.modules.apisupport.equinoxdemo +OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/apisupport/equinoxdemo/Bundle.properties +OpenIDE-Module-Specification-Version: 1.1 +OpenIDE-Module-Layer: org/netbeans/modules/apisupport/equinoxdemo/layer.xml +AutoUpdate-Show-In-Client: false diff -r e2a3e210c3db apisupport.equinoxdemo/nbproject/project.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apisupport.equinoxdemo/nbproject/project.properties Tue Feb 16 15:45:47 2010 +0100 @@ -0,0 +1,6 @@ +javac.source=1.6 +javac.compilerargs=-Xlint -Xlint:-serial +test-unit-sys-prop.test.nbroot=${nb_all} +test.unit.run.cp.extra=${tools.jar} +toplink-essentials.jar=${nb_all}/nbbuild/netbeans/${nb.cluster.java.dir}/modules/ext/toplink/toplink-essentials.jar +toplink-essentials-agent.jar=${nb_all}/nbbuild/netbeans/${nb.cluster.java.dir}/modules/ext/toplink/toplink-essentials-agent.jar diff -r e2a3e210c3db apisupport.equinoxdemo/nbproject/project.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apisupport.equinoxdemo/nbproject/project.xml Tue Feb 16 15:45:47 2010 +0100 @@ -0,0 +1,95 @@ + + + org.netbeans.modules.apisupport.project + + + org.netbeans.modules.apisupport.equinoxdemo + + + org.netbeans.modules.projectapi + + + + 1 + 1.29 + + + + org.netbeans.modules.projectuiapi + + + + 1 + 1.41 + + + + org.openide.awt + + + + 7.20 + + + + org.openide.dialogs + + + + 7.14 + + + + org.openide.filesystems + + + + 7.33 + + + + org.openide.util + + + + 8.0 + + + + + + unit + + org.netbeans.libs.junit4 + + + + org.netbeans.modules.apisupport.equinoxdemo + + + + + org.netbeans.modules.apisupport.project + + + + + + org.netbeans.modules.masterfs + + + + + org.netbeans.modules.nbjunit + + + + + org.netbeans.modules.projectui + + + + + + + diff -r e2a3e210c3db apisupport.equinoxdemo/src/org/netbeans/modules/apisupport/equinoxdemo/Bundle.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apisupport.equinoxdemo/src/org/netbeans/modules/apisupport/equinoxdemo/Bundle.properties Tue Feb 16 15:45:47 2010 +0100 @@ -0,0 +1,42 @@ +OpenIDE-Module-Name=Equinox Application Platform Sample + +LBL_CreateProjectStep=Create a new Equinox Application project +LBL_DownloadStep=Download libraries +OpenIDE-Module-Display-Category=Developing NetBeans +OpenIDE-Module-Long-Description=\ + Sample application based on the NetBeans platform and Equinox. +OpenIDE-Module-Short-Description=Sample NetBeans platform application. +SampleAppFile=Equinox based Platform Application + +# {0} - step # +# {1} - step count +SampleAppWizardIterator.name.format={0} of {1} +SampleAppPanelVisual.project_name=Project &Name: +SampleAppPanelVisual.default_prj_name=Equinox Application +SampleAppPanelVisual.folder_exists=Project Folder already exists and is not empty. +SampleAppPanelVisual.folder_creation_error=Project Folder cannot be created. +SampleAppPanelVisual.invalid_path=Project Folder is not a valid path. +SampleAppPanelVisual.invalid_folder_name=Project Name is not a valid folder name. +SampleAppPanelVisual.select_project_location=Select Project Location +SampleAppPanelVisual.project_folder=Project &Folder: +SampleAppPanelVisual.browse=Br&owse... +SampleAppPanelVisual.project_location=Project &Location: +SampleAppWarningVisual.readLicense.text=I agree with terms of GPL v2.0 license +MSG_WARNING=\ +

This sample requires additional binaries \ + (provided by the Netbinox project)\ + distributed under GPL v2.0 license. Do you want to download them now? \ +

\ +

\ + In case some application is based on this sample it may become subject of \ + Netbinox's GPL v2.0 license restrictions. \ + You may be required to redistribute sources of such application \ + under similar license. \ + Read more about the \ + viral nature of GPL and ways to avoid it. \ +

\ +

\ + Click finish to download and use the Netbinox + GPL components of this sample. \ +

+SampleAppWarningVisual.info.contentType=text/html diff -r e2a3e210c3db apisupport.equinoxdemo/src/org/netbeans/modules/apisupport/equinoxdemo/SampleAppDescription.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apisupport.equinoxdemo/src/org/netbeans/modules/apisupport/equinoxdemo/SampleAppDescription.html Tue Feb 16 15:45:47 2010 +0100 @@ -0,0 +1,54 @@ + + + + + + + + Illustrates how to use the NetBeans Platform and Equinox together. + See + tutorial + for more information. + + + diff -r e2a3e210c3db apisupport.equinoxdemo/src/org/netbeans/modules/apisupport/equinoxdemo/SampleAppPanelVisual.form --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apisupport.equinoxdemo/src/org/netbeans/modules/apisupport/equinoxdemo/SampleAppPanelVisual.form Tue Feb 16 15:45:47 2010 +0100 @@ -0,0 +1,118 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff -r e2a3e210c3db apisupport.equinoxdemo/src/org/netbeans/modules/apisupport/equinoxdemo/SampleAppPanelVisual.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apisupport.equinoxdemo/src/org/netbeans/modules/apisupport/equinoxdemo/SampleAppPanelVisual.java Tue Feb 16 15:45:47 2010 +0100 @@ -0,0 +1,300 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Sun Microsystems, Inc. All rights reserved. + * + * 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2010 Sun + * Microsystems, Inc. All Rights Reserved. + * + * 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. + */ +package org.netbeans.modules.apisupport.equinoxdemo; + +import java.io.File; +import javax.swing.JFileChooser; +import javax.swing.JPanel; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.text.Document; +import org.netbeans.spi.project.ui.support.ProjectChooser; +import org.openide.WizardDescriptor; +import org.openide.WizardValidationException; +import org.openide.filesystems.FileUtil; + +public class SampleAppPanelVisual extends JPanel implements DocumentListener { + + private static final String WIZARD_PANEL_ERROR_MESSAGE = WizardDescriptor.PROP_ERROR_MESSAGE; // NOI18N + + public static final String PROP_PROJECT_NAME = "projectName"; // NOI18N + + private SampleAppWizardPanel panel; + + /** Creates new form PanelProjectLocationVisual */ + public SampleAppPanelVisual(SampleAppWizardPanel panel) { + initComponents(); + this.panel = panel; + // Register listener on the textFields to make the automatic updates + projectNameTextField.getDocument().addDocumentListener(this); + projectLocationTextField.getDocument().addDocumentListener(this); + } + + + public String getProjectName() { + return this.projectNameTextField.getText(); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + projectNameLabel = new javax.swing.JLabel(); + projectNameTextField = new javax.swing.JTextField(); + projectLocationLabel = new javax.swing.JLabel(); + projectLocationTextField = new javax.swing.JTextField(); + browseButton = new javax.swing.JButton(); + createdFolderLabel = new javax.swing.JLabel(); + createdFolderTextField = new javax.swing.JTextField(); + + projectNameLabel.setLabelFor(projectNameTextField); + org.openide.awt.Mnemonics.setLocalizedText(projectNameLabel, org.openide.util.NbBundle.getMessage(SampleAppPanelVisual.class, "SampleAppPanelVisual.project_name")); // NOI18N + + projectLocationLabel.setLabelFor(projectLocationTextField); + org.openide.awt.Mnemonics.setLocalizedText(projectLocationLabel, org.openide.util.NbBundle.getMessage(SampleAppPanelVisual.class, "SampleAppPanelVisual.project_location")); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(browseButton, org.openide.util.NbBundle.getMessage(SampleAppPanelVisual.class, "SampleAppPanelVisual.browse")); // NOI18N + browseButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + browseButtonActionPerformed(evt); + } + }); + + createdFolderLabel.setLabelFor(createdFolderTextField); + org.openide.awt.Mnemonics.setLocalizedText(createdFolderLabel, org.openide.util.NbBundle.getMessage(SampleAppPanelVisual.class, "SampleAppPanelVisual.project_folder")); // NOI18N + + createdFolderTextField.setEditable(false); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(projectNameLabel) + .addComponent(projectLocationLabel) + .addComponent(createdFolderLabel)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(projectNameTextField, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE) + .addComponent(projectLocationTextField, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE) + .addComponent(createdFolderTextField, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(browseButton) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(projectNameLabel) + .addComponent(projectNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(projectLocationLabel) + .addComponent(projectLocationTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(browseButton)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(createdFolderLabel) + .addComponent(createdFolderTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(213, Short.MAX_VALUE)) + ); + }// //GEN-END:initComponents + + private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed + JFileChooser chooser = new JFileChooser(); + FileUtil.preventFileChooserSymlinkTraversal(chooser, null); + chooser.setDialogTitle(org.openide.util.NbBundle.getMessage(SampleAppPanelVisual.class, "SampleAppPanelVisual.select_project_location")); + chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + String path = this.projectLocationTextField.getText(); + if (path.length() > 0) { + File f = new File(path); + if (f.exists()) { + chooser.setSelectedFile(f); + } + } + if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) { + File projectDir = chooser.getSelectedFile(); + projectLocationTextField.setText(FileUtil.normalizeFile(projectDir).getAbsolutePath()); + } + panel.fireChangeEvent(); + + }//GEN-LAST:event_browseButtonActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton browseButton; + private javax.swing.JLabel createdFolderLabel; + private javax.swing.JTextField createdFolderTextField; + private javax.swing.JLabel projectLocationLabel; + private javax.swing.JTextField projectLocationTextField; + private javax.swing.JLabel projectNameLabel; + private javax.swing.JTextField projectNameTextField; + // End of variables declaration//GEN-END:variables + + @Override + public void addNotify() { + super.addNotify(); + //same problem as in 31086, initial focus on Cancel button + projectNameTextField.requestFocus(); + } + + boolean valid(WizardDescriptor wizardDescriptor) { + + if (projectNameTextField.getText().length() == 0) { + wizardDescriptor.putProperty(WIZARD_PANEL_ERROR_MESSAGE, + org.openide.util.NbBundle.getMessage(SampleAppPanelVisual.class, "SampleAppPanelVisual.invalid_folder_name")); + return false; // Display name not specified + } + File f = FileUtil.normalizeFile(new File(projectLocationTextField.getText()).getAbsoluteFile()); + if (!f.isDirectory()) { + String message = org.openide.util.NbBundle.getMessage(SampleAppPanelVisual.class, "SampleAppPanelVisual.invalid_path"); + wizardDescriptor.putProperty(WIZARD_PANEL_ERROR_MESSAGE, message); + return false; + } + final File destFolder = FileUtil.normalizeFile(new File(createdFolderTextField.getText()).getAbsoluteFile()); + + File projLoc = destFolder; + while (projLoc != null && !projLoc.exists()) { + projLoc = projLoc.getParentFile(); + } + if (projLoc == null || !projLoc.canWrite()) { + wizardDescriptor.putProperty(WIZARD_PANEL_ERROR_MESSAGE, + org.openide.util.NbBundle.getMessage(SampleAppPanelVisual.class, "SampleAppPanelVisual.folder_creation_error")); + return false; + } + + if (FileUtil.toFileObject(projLoc) == null) { + String message = org.openide.util.NbBundle.getMessage(SampleAppPanelVisual.class, "SampleAppPanelVisual.invalid_path"); + wizardDescriptor.putProperty(WIZARD_PANEL_ERROR_MESSAGE, message); + return false; + } + + File[] kids = destFolder.listFiles(); + if (destFolder.exists() && kids != null && kids.length > 0) { + // Folder exists and is not empty + wizardDescriptor.putProperty(WIZARD_PANEL_ERROR_MESSAGE, + org.openide.util.NbBundle.getMessage(SampleAppPanelVisual.class, "SampleAppPanelVisual.folder_exists")); + return false; + } + wizardDescriptor.putProperty(WIZARD_PANEL_ERROR_MESSAGE, ""); + return true; + } + + void store(WizardDescriptor d) { + String name = projectNameTextField.getText().trim(); + String folder = createdFolderTextField.getText().trim(); + + d.putProperty("projdir", new File(folder)); // NOI18N + d.putProperty("name", name); // NOI18N + } + + void read(WizardDescriptor settings) { + File projectLocation = (File) settings.getProperty("projdir"); // NOI18N + if (projectLocation == null || projectLocation.getParentFile() == null || !projectLocation.getParentFile().isDirectory()) { + projectLocation = ProjectChooser.getProjectsFolder(); + } else { + projectLocation = projectLocation.getParentFile(); + } + this.projectLocationTextField.setText(projectLocation.getAbsolutePath()); + + String projectName = (String) settings.getProperty("name"); // NOI18N + if(projectName == null) { + projectName = org.openide.util.NbBundle.getMessage(SampleAppPanelVisual.class, "SampleAppPanelVisual.default_prj_name"); + } + this.projectNameTextField.setText(projectName); + this.projectNameTextField.selectAll(); + } + + void validate(WizardDescriptor d) throws WizardValidationException { + // nothing to validate + } + + // Implementation of DocumentListener -------------------------------------- + + public void changedUpdate(DocumentEvent e) { + updateTexts(e); + if (this.projectNameTextField.getDocument() == e.getDocument()) { + firePropertyChange(PROP_PROJECT_NAME,null,this.projectNameTextField.getText()); + } + } + + public void insertUpdate(DocumentEvent e) { + updateTexts(e); + if (this.projectNameTextField.getDocument() == e.getDocument()) { + firePropertyChange(PROP_PROJECT_NAME,null,this.projectNameTextField.getText()); + } + } + + public void removeUpdate(DocumentEvent e) { + updateTexts(e); + if (this.projectNameTextField.getDocument() == e.getDocument()) { + firePropertyChange(PROP_PROJECT_NAME,null,this.projectNameTextField.getText()); + } + } + + /** Handles changes in the Project name and project directory, */ + private void updateTexts(DocumentEvent e) { + + Document doc = e.getDocument(); + + if (doc == projectNameTextField.getDocument() || doc == projectLocationTextField.getDocument()) { + // Change in the project name + + String projectName = projectNameTextField.getText(); + String projectFolder = projectLocationTextField.getText(); + + //if (projectFolder.trim().length() == 0 || projectFolder.equals(oldName)) { + createdFolderTextField.setText(projectFolder + File.separatorChar + projectName); + //} + + } + panel.fireChangeEvent(); // Notify that the panel changed + } + +} diff -r e2a3e210c3db apisupport.equinoxdemo/src/org/netbeans/modules/apisupport/equinoxdemo/SampleAppWarningPanel.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apisupport.equinoxdemo/src/org/netbeans/modules/apisupport/equinoxdemo/SampleAppWarningPanel.java Tue Feb 16 15:45:47 2010 +0100 @@ -0,0 +1,121 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Sun Microsystems, Inc. All rights reserved. + * + * 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2010 Sun + * Microsystems, Inc. All Rights Reserved. + * + * 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. + */ +package org.netbeans.modules.apisupport.equinoxdemo; + +import java.awt.Component; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import org.openide.WizardDescriptor; +import org.openide.util.HelpCtx; +import org.openide.util.NbBundle; + +/** + * Warning about the license. + */ +public class SampleAppWarningPanel +implements WizardDescriptor.Panel, WizardDescriptor.FinishablePanel { + private WizardDescriptor wizardDescriptor; + private SampleAppWarningVisual component; + + public SampleAppWarningPanel() { + } + + @Override + public Component getComponent() { + if (component == null) { + component = new SampleAppWarningVisual(this); + component.setName(NbBundle.getMessage(SampleAppWarningPanel.class, "LBL_CreateProjectStep")); + } + return component; + } + + @Override + public HelpCtx getHelp() { + return new HelpCtx(SampleAppWarningPanel.class); + } + + @Override + public boolean isValid() { + getComponent(); + return component.valid(wizardDescriptor); + } + + private final Set listeners = new HashSet(3); + @Override + public final void addChangeListener(ChangeListener l) { + synchronized (listeners) { + listeners.add(l); + } + } + @Override + public final void removeChangeListener(ChangeListener l) { + synchronized (listeners) { + listeners.remove(l); + } + } + protected final void fireChangeEvent() { + Iterator it; + synchronized (listeners) { + it = new HashSet(listeners).iterator(); + } + ChangeEvent ev = new ChangeEvent(this); + while (it.hasNext()) { + ((ChangeListener) it.next()).stateChanged(ev); + } + } + + @Override + public void readSettings(Object settings) { + } + + @Override + public void storeSettings(Object settings) { + } + + @Override + public boolean isFinishPanel() { + return true; + } + +} diff -r e2a3e210c3db apisupport.equinoxdemo/src/org/netbeans/modules/apisupport/equinoxdemo/SampleAppWarningVisual.form --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apisupport.equinoxdemo/src/org/netbeans/modules/apisupport/equinoxdemo/SampleAppWarningVisual.form Tue Feb 16 15:45:47 2010 +0100 @@ -0,0 +1,76 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff -r e2a3e210c3db apisupport.equinoxdemo/src/org/netbeans/modules/apisupport/equinoxdemo/SampleAppWarningVisual.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apisupport.equinoxdemo/src/org/netbeans/modules/apisupport/equinoxdemo/SampleAppWarningVisual.java Tue Feb 16 15:45:47 2010 +0100 @@ -0,0 +1,140 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * + * 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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 2010 Sun Microsystems, Inc. + */ + +/* + * SampleAppWarningVisual.java + * + * Created on 16.2.2010, 15:07:58 + */ + +package org.netbeans.modules.apisupport.equinoxdemo; + +import javax.swing.event.HyperlinkEvent; +import org.openide.WizardDescriptor; +import org.openide.awt.HtmlBrowser.URLDisplayer; + +/** + * + * @author Jaroslav Tulach + */ +class SampleAppWarningVisual extends javax.swing.JPanel { + SampleAppWarningPanel panel; + SampleAppWarningVisual(SampleAppWarningPanel panel) { + this.panel = panel; + initComponents(); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + info = new javax.swing.JEditorPane(); + readLicense = new javax.swing.JCheckBox(); + + info.setContentType(org.openide.util.NbBundle.getMessage(SampleAppWarningVisual.class, "SampleAppWarningVisual.info.contentType", new Object[] {})); // NOI18N + info.setEditable(false); + info.setText(org.openide.util.NbBundle.getMessage(SampleAppWarningVisual.class, "MSG_WARNING", new Object[] {})); // NOI18N + info.setOpaque(false); + info.addHyperlinkListener(new javax.swing.event.HyperlinkListener() { + public void hyperlinkUpdate(javax.swing.event.HyperlinkEvent evt) { + infoHyperlinkUpdate(evt); + } + }); + + readLicense.setText(org.openide.util.NbBundle.getMessage(SampleAppWarningVisual.class, "SampleAppWarningVisual.readLicense.text", new Object[] {})); // NOI18N + readLicense.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + readLicenseActionPerformed(evt); + } + }); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(readLicense, javax.swing.GroupLayout.DEFAULT_SIZE, 384, Short.MAX_VALUE) + .addContainerGap()) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(13, 13, 13) + .addComponent(info, javax.swing.GroupLayout.PREFERRED_SIZE, 373, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(14, Short.MAX_VALUE))) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap(219, Short.MAX_VALUE) + .addComponent(readLicense, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addComponent(info, javax.swing.GroupLayout.PREFERRED_SIZE, 207, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(43, Short.MAX_VALUE))) + ); + }// //GEN-END:initComponents + + private void readLicenseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_readLicenseActionPerformed + panel.fireChangeEvent(); + }//GEN-LAST:event_readLicenseActionPerformed + + private void infoHyperlinkUpdate(javax.swing.event.HyperlinkEvent evt) {//GEN-FIRST:event_infoHyperlinkUpdate + if (HyperlinkEvent.EventType.ACTIVATED == evt.getEventType()) { + URLDisplayer.getDefault().showURLExternal(evt.getURL()); + } + }//GEN-LAST:event_infoHyperlinkUpdate + + boolean valid(WizardDescriptor wizardDescriptor) { + return readLicense.isSelected(); + } + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JEditorPane info; + private javax.swing.JCheckBox readLicense; + // End of variables declaration//GEN-END:variables + + +} diff -r e2a3e210c3db apisupport.equinoxdemo/src/org/netbeans/modules/apisupport/equinoxdemo/SampleAppWizardIterator.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apisupport.equinoxdemo/src/org/netbeans/modules/apisupport/equinoxdemo/SampleAppWizardIterator.java Tue Feb 16 15:45:47 2010 +0100 @@ -0,0 +1,208 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Sun Microsystems, Inc. All rights reserved. + * + * 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2010 Sun + * Microsystems, Inc. All Rights Reserved. + * + * 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. + */ +package org.netbeans.modules.apisupport.equinoxdemo; + +import java.awt.Component; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Enumeration; +import java.util.LinkedHashSet; +import java.util.NoSuchElementException; +import java.util.Set; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; +import javax.swing.JComponent; +import javax.swing.event.ChangeListener; +import org.netbeans.api.project.ProjectManager; +import org.netbeans.spi.project.ui.support.ProjectChooser; +import org.netbeans.spi.project.ui.templates.support.Templates; +import org.openide.WizardDescriptor; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; +import org.openide.util.NbBundle; + +public class SampleAppWizardIterator implements WizardDescriptor.InstantiatingIterator { + + private static final long serialVersionUID = 1L; + + private transient int index; + private transient WizardDescriptor.Panel[] panels; + private transient WizardDescriptor wiz; + + public SampleAppWizardIterator() {} + + public static SampleAppWizardIterator createIterator() { + return new SampleAppWizardIterator(); + } + + private WizardDescriptor.Panel[] createPanels() { + return new WizardDescriptor.Panel[] { + new SampleAppWizardPanel(), + new SampleAppWarningPanel() + }; + } + + private String[] createSteps() { + return new String[] { + NbBundle.getMessage(SampleAppWizardIterator.class, "LBL_CreateProjectStep"), + NbBundle.getMessage(SampleAppWizardIterator.class, "LBL_DownloadStep") + }; + } + + public Set/**/ instantiate() throws IOException { + Set resultSet = new LinkedHashSet(); + File dirF = FileUtil.normalizeFile((File) wiz.getProperty("projdir")); // NOI18N + dirF.mkdirs(); + + FileObject template = Templates.getTemplate(wiz); + FileObject dir = FileUtil.toFileObject(dirF); + unZipFile(template.getInputStream(), dir); + + // Always open top dir as a project: + resultSet.add(dir); + // Look for nested projects to open as well: + Enumeration e = dir.getFolders(true); + while (e.hasMoreElements()) { + FileObject subfolder = (FileObject) e.nextElement(); + if (ProjectManager.getDefault().isProject(subfolder)) { + resultSet.add(subfolder); + } + } + + File parent = dirF.getParentFile(); + if (parent != null && parent.exists()) { + ProjectChooser.setProjectsFolder(parent); + } + + return resultSet; + } + + public void initialize(WizardDescriptor wiz) { + this.wiz = wiz; + index = 0; + panels = createPanels(); + // Make sure list of steps is accurate. + String[] steps = createSteps(); + for (int i = 0; i < panels.length; i++) { + Component c = panels[i].getComponent(); + if (steps[i] == null) { + // Default step name to component name of panel. + // Mainly useful for getting the name of the target + // chooser to appear in the list of steps. + steps[i] = c.getName(); + } + if (c instanceof JComponent) { // assume Swing components + JComponent jc = (JComponent) c; + // Step #. + jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, new Integer(i)); // NOI18N + // Step name (actually the whole list for reference). + jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps); // NOI18N + } + } + } + + public void uninitialize(WizardDescriptor wiz) { + this.wiz.putProperty("projdir",null); // NOI18N + this.wiz.putProperty("name",null); // NOI18N + this.wiz = null; + panels = null; + } + + public String name() { + return NbBundle.getMessage(SampleAppWizardIterator.class, "SampleAppWizardIterator.name.format", + new Object[] {new Integer(index + 1), new Integer(panels.length)}); + } + + public boolean hasNext() { + return index < panels.length - 1; + } + + public boolean hasPrevious() { + return index > 0; + } + + public void nextPanel() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + index++; + } + + public void previousPanel() { + if (!hasPrevious()) { + throw new NoSuchElementException(); + } + index--; + } + + public WizardDescriptor.Panel current() { + return panels[index]; + } + + // If nothing unusual changes in the middle of the wizard, simply: + public final void addChangeListener(ChangeListener l) {} + public final void removeChangeListener(ChangeListener l) {} + + private static void unZipFile(InputStream source, FileObject projectRoot) throws IOException { + try { + ZipInputStream str = new ZipInputStream(source); + ZipEntry entry; + while ((entry = str.getNextEntry()) != null) { + if (entry.isDirectory()) { + FileUtil.createFolder(projectRoot, entry.getName()); + } else { + FileObject fo = FileUtil.createData(projectRoot, entry.getName()); + OutputStream out = fo.getOutputStream(); + try { + FileUtil.copy(str, out); + } finally { + out.close(); + } + } + } + } finally { + source.close(); + } + } + +} diff -r e2a3e210c3db apisupport.equinoxdemo/src/org/netbeans/modules/apisupport/equinoxdemo/SampleAppWizardPanel.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apisupport.equinoxdemo/src/org/netbeans/modules/apisupport/equinoxdemo/SampleAppWizardPanel.java Tue Feb 16 15:45:47 2010 +0100 @@ -0,0 +1,132 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Sun Microsystems, Inc. All rights reserved. + * + * 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2010 Sun + * Microsystems, Inc. All Rights Reserved. + * + * 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. + */ +package org.netbeans.modules.apisupport.equinoxdemo; + +import java.awt.Component; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import org.openide.WizardDescriptor; +import org.openide.WizardValidationException; +import org.openide.util.HelpCtx; +import org.openide.util.NbBundle; + +/** + * Panel just asking for basic info. + */ +class SampleAppWizardPanel implements WizardDescriptor.Panel, + WizardDescriptor.ValidatingPanel, WizardDescriptor.FinishablePanel { + + private WizardDescriptor wizardDescriptor; + private SampleAppPanelVisual component; + + public SampleAppWizardPanel() { + } + + @Override + public Component getComponent() { + if (component == null) { + component = new SampleAppPanelVisual(this); + component.setName(NbBundle.getMessage(SampleAppWizardPanel.class, "LBL_CreateProjectStep")); + } + return component; + } + + @Override + public HelpCtx getHelp() { + return new HelpCtx(SampleAppWizardPanel.class); + } + + @Override + public boolean isValid() { + getComponent(); + return component.valid(wizardDescriptor); + } + + private final Set listeners = new HashSet(1); + public final void addChangeListener(ChangeListener l) { + synchronized (listeners) { + listeners.add(l); + } + } + @Override + public final void removeChangeListener(ChangeListener l) { + synchronized (listeners) { + listeners.remove(l); + } + } + protected final void fireChangeEvent() { + Iterator it; + synchronized (listeners) { + it = new HashSet(listeners).iterator(); + } + ChangeEvent ev = new ChangeEvent(this); + while (it.hasNext()) { + ((ChangeListener) it.next()).stateChanged(ev); + } + } + + @Override + public void readSettings(Object settings) { + wizardDescriptor = (WizardDescriptor) settings; + component.read(wizardDescriptor); + } + + @Override + public void storeSettings(Object settings) { + WizardDescriptor d = (WizardDescriptor) settings; + component.store(d); + } + + @Override + public boolean isFinishPanel() { + return false; + } + + @Override + public void validate() throws WizardValidationException { + getComponent(); + component.validate(wizardDescriptor); + } + +} diff -r e2a3e210c3db apisupport.equinoxdemo/src/org/netbeans/modules/apisupport/equinoxdemo/bundle.png Binary file apisupport.equinoxdemo/src/org/netbeans/modules/apisupport/equinoxdemo/bundle.png has changed diff -r e2a3e210c3db apisupport.equinoxdemo/src/org/netbeans/modules/apisupport/equinoxdemo/layer.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apisupport.equinoxdemo/src/org/netbeans/modules/apisupport/equinoxdemo/layer.xml Tue Feb 16 15:45:47 2010 +0100 @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + diff -r e2a3e210c3db apisupport.equinoxdemo/test/unit/src/org/netbeans/modules/apisupport/equinoxdemo/BuildEquinoxSampleApplicationTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apisupport.equinoxdemo/test/unit/src/org/netbeans/modules/apisupport/equinoxdemo/BuildEquinoxSampleApplicationTest.java Tue Feb 16 15:45:47 2010 +0100 @@ -0,0 +1,176 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Sun Microsystems, Inc. All rights reserved. + * + * 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2010 Sun + * Microsystems, Inc. All Rights Reserved. + * + * 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. + */ +package org.netbeans.modules.apisupport.equinoxdemo; + +import java.io.File; +import java.io.FilenameFilter; +import java.io.InputStream; +import java.util.Properties; +import org.apache.tools.ant.module.api.support.ActionUtils; +import org.netbeans.api.project.ProjectManager; +import org.netbeans.modules.apisupport.project.DialogDisplayerImpl; +import org.netbeans.modules.apisupport.project.InstalledFileLocatorImpl; +import org.netbeans.modules.apisupport.project.TestAntLogger; +import org.netbeans.modules.apisupport.project.TestBase; +import org.netbeans.modules.apisupport.project.layers.LayerTestBase; +import org.netbeans.modules.apisupport.project.suite.SuiteProject; +import org.netbeans.spi.project.support.ant.GeneratedFilesHelper; +import org.openide.DialogDescriptor; +import org.openide.execution.ExecutorTask; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; + +/** + * Invokes various Ant targets over equinoxdemo sample. + * + * @author Tomas Musil + */ +public class BuildEquinoxSampleApplicationTest extends TestBase { + + private File sampleFolder = null; + + static { + // #65461: do not try to load ModuleInfo instances from ant module + System.setProperty("org.netbeans.core.startup.ModuleSystem.CULPRIT", "true"); + LayerTestBase.Lkp.setLookup(new Object[0]); + DialogDisplayerImpl.returnFromNotify(DialogDescriptor.NO_OPTION); + } + + public BuildEquinoxSampleApplicationTest(String testName) { + super(testName); + } + + @Override + protected void setUp() throws Exception { + clearWorkDir(); + noDataDir = true; + super.setUp(); + InstalledFileLocatorImpl.registerDestDir(destDirF); + TestAntLogger.getDefault().setEnabled(true); + } + + @Override + protected void tearDown() throws Exception { + TestAntLogger.getDefault().setEnabled(false); + } + + public int runAntTargetsOnSample(String[] targets) throws Exception { + InputStream is = getClass().getClassLoader().getResourceAsStream("org/netbeans/modules/apisupport/equinoxdemo/EquinoxDemo.zip"); + assertNotNull(is); + sampleFolder = new File(getWorkDir(), "sample"); + sampleFolder.mkdir(); + FileObject fo = FileUtil.toFileObject(sampleFolder); + assertNotNull(fo); + + + try { + FileUtil.extractJar(fo, is); + } finally { + is.close(); + } + + File buildProps = new File(getWorkDir(), "build.properties"); + File privateFolder = new File(new File(sampleFolder, "nbproject"), "private"); + privateFolder.mkdir(); + + FileObject platfPrivateProps = FileUtil.copyFile(FileUtil.toFileObject(buildProps), FileUtil.toFileObject(privateFolder), "platform-private"); + assertNotNull(platfPrivateProps); + SuiteProject sampleSuite = (SuiteProject) ProjectManager.getDefault().findProject(fo); + assertNotNull(sampleSuite); + FileObject buildScript = sampleSuite.getProjectDirectory().getFileObject(GeneratedFilesHelper.BUILD_XML_PATH); + assertNotNull(buildScript); + assertTrue(buildScript.isValid()); + Properties props = new Properties(); + File toplinkJar1 = new File(destDirF, "java/modules/ext/toplink/toplink-essentials.jar"); + assertTrue(toplinkJar1.getAbsolutePath(), toplinkJar1.isFile()); + File toplinkJar2 = new File(destDirF, "java/modules/ext/toplink/toplink-essentials-agent.jar"); + assertTrue(toplinkJar2.getAbsolutePath(), toplinkJar2.isFile()); + props.setProperty("libs.toplink.classpath", "" + toplinkJar1 + File.pathSeparator + toplinkJar2); + + System.out.println("------------- BUILD OUTPUT --------------"); + ExecutorTask et = ActionUtils.runTarget(buildScript, targets, props); + et.waitFinished(); + System.out.println("-----------------------------------------"); + return et.result(); + } + + public void testBuildZip() throws Exception { + int ret = runAntTargetsOnSample(new String[]{"build-zip"}); + assertEquals("build-zipant target should return zero - build successful", 0, ret); + File dist = new File(sampleFolder, "dist"); + File zipFile = new File(dist, "equinoxsample.zip"); + assertTrue("ZIP file should be in dist folder", zipFile.exists()); + } + + public void testBuild() throws Exception { + int ret = runAntTargetsOnSample(new String[] {"build"}); + assertEquals("build ant target should return zero - build successful", 0 , ret); + File buildFolder = new File(sampleFolder,"build"); + assertTrue("build folder should exist", buildFolder.exists() && buildFolder.isDirectory()); + String[] children = buildFolder.list(); + assertTrue("build folder is not empty", children.length>0); + + } + + public void testBuildNBMs() throws Exception { + int ret = runAntTargetsOnSample(new String[] {"nbms"}); + assertEquals("build ant target should return zero - build successful", 0 , ret); + File buildFolder = new File(sampleFolder,"build"); + File updatesFolder = new File(buildFolder,"updates"); + assertTrue("build/update folder exists", updatesFolder.exists() && updatesFolder.isDirectory()); + File showBundles = new File(updatesFolder, "org-apidesign-netbinox-showbundles.nbm"); + assertTrue("Our NBM is in build/updates folder", showBundles.exists()); + assertEquals("1 nbm is in build/updates folder", 1, updatesFolder.list(new FilenameFilter() { + public boolean accept(File dir, String name) { + return name.indexOf("nbm") != -1; + } + }).length); + } + + public void testClean() throws Exception { + int ret = runAntTargetsOnSample(new String[]{"clean"}); + assertEquals("clean ant target should return zero - build successful", 0, ret); + File buildFolder = new File(sampleFolder, "build"); + File distFolder = new File(sampleFolder, "dist"); + assertTrue("build and dist folders are deleted", !distFolder.exists() && !buildFolder.exists()); + } +} +