diff --git a/sdk/jme3-templates/src/com/jme3/gde/templates/Bundle.properties b/sdk/jme3-templates/src/com/jme3/gde/templates/Bundle.properties index 7e30db593..cfcb10340 100644 --- a/sdk/jme3-templates/src/com/jme3/gde/templates/Bundle.properties +++ b/sdk/jme3-templates/src/com/jme3/gde/templates/Bundle.properties @@ -5,3 +5,4 @@ OpenIDE-Module-Long-Description=\ OpenIDE-Module-Name=Project Templates OpenIDE-Module-Short-Description=Provides Project Templates Templates/Project/JME3/BasicGameProject.zip=BasicGame +Templates/Project/JME3/JME3TestsAndroidProject.zip=jME3TestsAndroid diff --git a/sdk/jme3-templates/src/com/jme3/gde/templates/Phone_16.gif b/sdk/jme3-templates/src/com/jme3/gde/templates/Phone_16.gif new file mode 100644 index 000000000..40bb42dff Binary files /dev/null and b/sdk/jme3-templates/src/com/jme3/gde/templates/Phone_16.gif differ diff --git a/sdk/jme3-templates/src/com/jme3/gde/templates/layer.xml b/sdk/jme3-templates/src/com/jme3/gde/templates/layer.xml index dde0bd2ee..5facb0761 100644 --- a/sdk/jme3-templates/src/com/jme3/gde/templates/layer.xml +++ b/sdk/jme3-templates/src/com/jme3/gde/templates/layer.xml @@ -12,6 +12,13 @@ + + + + + + + diff --git a/sdk/jme3-templates/src/com/jme3/gde/templates/testsandroid/Bundle.properties b/sdk/jme3-templates/src/com/jme3/gde/templates/testsandroid/Bundle.properties new file mode 100644 index 000000000..436a69ce1 --- /dev/null +++ b/sdk/jme3-templates/src/com/jme3/gde/templates/testsandroid/Bundle.properties @@ -0,0 +1,6 @@ +LBL_CreateProjectStep=Name and Location +JME3TestsAndroidPanelVisual.browseButton.text=Br&owse... +JME3TestsAndroidPanelVisual.createdFolderLabel.text=Project &Folder: +JME3TestsAndroidPanelVisual.projectNameLabel.text=Project &Name: +JME3TestsAndroidPanelVisual.projectLocationLabel.text=Project &Location: +JME3TestsAndroidPanelVisual.browseButton.actionCommand=BROWSE diff --git a/sdk/jme3-templates/src/com/jme3/gde/templates/testsandroid/JME3TestsAndroidDescription.html b/sdk/jme3-templates/src/com/jme3/gde/templates/testsandroid/JME3TestsAndroidDescription.html new file mode 100644 index 000000000..69a83534b --- /dev/null +++ b/sdk/jme3-templates/src/com/jme3/gde/templates/testsandroid/JME3TestsAndroidDescription.html @@ -0,0 +1,12 @@ + + + + + + + Sample jME3 Tests Template for Android project + + diff --git a/sdk/jme3-templates/src/com/jme3/gde/templates/testsandroid/JME3TestsAndroidPanelVisual.form b/sdk/jme3-templates/src/com/jme3/gde/templates/testsandroid/JME3TestsAndroidPanelVisual.form new file mode 100644 index 000000000..83c79b84c --- /dev/null +++ b/sdk/jme3-templates/src/com/jme3/gde/templates/testsandroid/JME3TestsAndroidPanelVisual.form @@ -0,0 +1,122 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/sdk/jme3-templates/src/com/jme3/gde/templates/testsandroid/JME3TestsAndroidPanelVisual.java b/sdk/jme3-templates/src/com/jme3/gde/templates/testsandroid/JME3TestsAndroidPanelVisual.java new file mode 100644 index 000000000..7990fea05 --- /dev/null +++ b/sdk/jme3-templates/src/com/jme3/gde/templates/testsandroid/JME3TestsAndroidPanelVisual.java @@ -0,0 +1,262 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.jme3.gde.templates.testsandroid; + +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 JME3TestsAndroidPanelVisual extends JPanel implements DocumentListener { + + public static final String PROP_PROJECT_NAME = "projectName"; + private JME3TestsAndroidWizardPanel panel; + + public JME3TestsAndroidPanelVisual(JME3TestsAndroidWizardPanel 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(JME3TestsAndroidPanelVisual.class, "JME3TestsAndroidPanelVisual.projectNameLabel.text")); // NOI18N + + projectLocationLabel.setLabelFor(projectLocationTextField); + org.openide.awt.Mnemonics.setLocalizedText(projectLocationLabel, org.openide.util.NbBundle.getMessage(JME3TestsAndroidPanelVisual.class, "JME3TestsAndroidPanelVisual.projectLocationLabel.text")); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(browseButton, org.openide.util.NbBundle.getMessage(JME3TestsAndroidPanelVisual.class, "JME3TestsAndroidPanelVisual.browseButton.text")); // NOI18N + browseButton.setActionCommand(org.openide.util.NbBundle.getMessage(JME3TestsAndroidPanelVisual.class, "JME3TestsAndroidPanelVisual.browseButton.actionCommand")); // 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(JME3TestsAndroidPanelVisual.class, "JME3TestsAndroidPanelVisual.createdFolderLabel.text")); // 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 + String command = evt.getActionCommand(); + if ("BROWSE".equals(command)) { + JFileChooser chooser = new JFileChooser(); + FileUtil.preventFileChooserSymlinkTraversal(chooser, null); + chooser.setDialogTitle("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 + javax.swing.JButton browseButton; + javax.swing.JLabel createdFolderLabel; + javax.swing.JTextField createdFolderTextField; + javax.swing.JLabel projectLocationLabel; + javax.swing.JTextField projectLocationTextField; + javax.swing.JLabel projectNameLabel; + 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) { + // TODO if using org.openide.dialogs >= 7.8, can use WizardDescriptor.PROP_ERROR_MESSAGE: + wizardDescriptor.putProperty("WizardPanel_errorMessage", + "Project Name is not a valid folder name."); + return false; // Display name not specified + } + File f = FileUtil.normalizeFile(new File(projectLocationTextField.getText()).getAbsoluteFile()); + if (!f.isDirectory()) { + String message = "Project Folder is not a valid path."; + wizardDescriptor.putProperty("WizardPanel_errorMessage", 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("WizardPanel_errorMessage", + "Project Folder cannot be created."); + return false; + } + + if (FileUtil.toFileObject(projLoc) == null) { + String message = "Project Folder is not a valid path."; + wizardDescriptor.putProperty("WizardPanel_errorMessage", message); + return false; + } + + File[] kids = destFolder.listFiles(); + if (destFolder.exists() && kids != null && kids.length > 0) { + // Folder exists and is not empty + wizardDescriptor.putProperty("WizardPanel_errorMessage", + "Project Folder already exists and is not empty."); + return false; + } + wizardDescriptor.putProperty("WizardPanel_errorMessage", ""); + return true; + } + + void store(WizardDescriptor d) { + String name = projectNameTextField.getText().trim(); + String folder = createdFolderTextField.getText().trim(); + + d.putProperty("projdir", new File(folder)); + d.putProperty("name", name); + } + + void read(WizardDescriptor settings) { + File projectLocation = (File) settings.getProperty("projdir"); + 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"); + if (projectName == null) { + projectName = "JME3TestsAndroid"; + } + 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 --git a/sdk/jme3-templates/src/com/jme3/gde/templates/testsandroid/JME3TestsAndroidWizardIterator.java b/sdk/jme3-templates/src/com/jme3/gde/templates/testsandroid/JME3TestsAndroidWizardIterator.java new file mode 100644 index 000000000..5b394af4c --- /dev/null +++ b/sdk/jme3-templates/src/com/jme3/gde/templates/testsandroid/JME3TestsAndroidWizardIterator.java @@ -0,0 +1,247 @@ +/* + * Copyright (c) 2009-2010 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.gde.templates.testsandroid; + +import java.awt.Component; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.text.MessageFormat; +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.Exceptions; +import org.openide.util.NbBundle; +import org.openide.xml.XMLUtil; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; +import org.xml.sax.InputSource; + +public class JME3TestsAndroidWizardIterator implements WizardDescriptor./*Progress*/InstantiatingIterator { + + private int index; + private WizardDescriptor.Panel[] panels; + private WizardDescriptor wiz; + + public JME3TestsAndroidWizardIterator() { + } + + public static JME3TestsAndroidWizardIterator createIterator() { + return new JME3TestsAndroidWizardIterator(); + } + + private WizardDescriptor.Panel[] createPanels() { + return new WizardDescriptor.Panel[]{ + new JME3TestsAndroidWizardPanel(),}; + } + + private String[] createSteps() { + return new String[]{ + NbBundle.getMessage(JME3TestsAndroidWizardIterator.class, "LBL_CreateProjectStep") + }; + } + + public Set/**/ instantiate(/*ProgressHandle handle*/) throws IOException { + Set resultSet = new LinkedHashSet(); + File dirF = FileUtil.normalizeFile((File) wiz.getProperty("projdir")); + 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 = 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 #. + // TODO if using org.openide.dialogs >= 7.8, can use WizardDescriptor.PROP_*: + jc.putClientProperty("WizardPanel_contentSelectedIndex", new Integer(i)); + // Step name (actually the whole list for reference). + jc.putClientProperty("WizardPanel_contentData", steps); + } + } + } + + public void uninitialize(WizardDescriptor wiz) { + this.wiz.putProperty("projdir", null); + this.wiz.putProperty("name", null); + this.wiz = null; + panels = null; + } + + public String name() { + return MessageFormat.format("{0} of {1}", + 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()); + if ("nbproject/project.xml".equals(entry.getName())) { + // Special handling for setting name of Ant-based projects; customize as needed: + filterProjectXML(fo, str, projectRoot.getName()); + } else { + writeFile(str, fo); + } + } + } + } finally { + source.close(); + } + } + + private static void writeFile(ZipInputStream str, FileObject fo) throws IOException { + OutputStream out = fo.getOutputStream(); + try { + FileUtil.copy(str, out); + } finally { + out.close(); + } + } + + private static void filterProjectXML(FileObject fo, ZipInputStream str, String name) throws IOException { + try { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + FileUtil.copy(str, baos); + Document doc = XMLUtil.parse(new InputSource(new ByteArrayInputStream(baos.toByteArray())), false, false, null, null); + NodeList nl = doc.getDocumentElement().getElementsByTagName("name"); + if (nl != null) { + for (int i = 0; i < nl.getLength(); i++) { + Element el = (Element) nl.item(i); + if (el.getParentNode() != null && "data".equals(el.getParentNode().getNodeName())) { + NodeList nl2 = el.getChildNodes(); + if (nl2.getLength() > 0) { + nl2.item(0).setNodeValue(name); + } + break; + } + } + } + OutputStream out = fo.getOutputStream(); + try { + XMLUtil.write(doc, out, "UTF-8"); + } finally { + out.close(); + } + } catch (Exception ex) { + Exceptions.printStackTrace(ex); + writeFile(str, fo); + } + + } +} diff --git a/sdk/jme3-templates/src/com/jme3/gde/templates/testsandroid/JME3TestsAndroidWizardPanel.java b/sdk/jme3-templates/src/com/jme3/gde/templates/testsandroid/JME3TestsAndroidWizardPanel.java new file mode 100644 index 000000000..26f61c800 --- /dev/null +++ b/sdk/jme3-templates/src/com/jme3/gde/templates/testsandroid/JME3TestsAndroidWizardPanel.java @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2009-2010 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.gde.templates.testsandroid; + +import java.awt.Component; +import java.util.HashSet; +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. + */ +public class JME3TestsAndroidWizardPanel implements WizardDescriptor.Panel, + WizardDescriptor.ValidatingPanel, WizardDescriptor.FinishablePanel { + + private WizardDescriptor wizardDescriptor; + private JME3TestsAndroidPanelVisual component; + + public JME3TestsAndroidWizardPanel() { + } + + public Component getComponent() { + if (component == null) { + component = new JME3TestsAndroidPanelVisual(this); + component.setName(NbBundle.getMessage(JME3TestsAndroidWizardPanel.class, "LBL_CreateProjectStep")); + } + return component; + } + + public HelpCtx getHelp() { + return new HelpCtx("sdk.project_creation"); + } + + public boolean isValid() { + getComponent(); + return component.valid(wizardDescriptor); + } + private final Set listeners = new HashSet(1); // or can use ChangeSupport in NB 6.0 + + public final void addChangeListener(ChangeListener l) { + synchronized (listeners) { + listeners.add(l); + } + } + + public final void removeChangeListener(ChangeListener l) { + synchronized (listeners) { + listeners.remove(l); + } + } + + protected final void fireChangeEvent() { + Set ls; + synchronized (listeners) { + ls = new HashSet(listeners); + } + ChangeEvent ev = new ChangeEvent(this); + for (ChangeListener l : ls) { + l.stateChanged(ev); + } + } + + public void readSettings(Object settings) { + wizardDescriptor = (WizardDescriptor) settings; + component.read(wizardDescriptor); + } + + public void storeSettings(Object settings) { + WizardDescriptor d = (WizardDescriptor) settings; + component.store(d); + } + + public boolean isFinishPanel() { + return true; + } + + public void validate() throws WizardValidationException { + getComponent(); + component.validate(wizardDescriptor); + } +}