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());
+ }
+}
+