Improve Codeless project importer:
- Add checks for folders existing
- Don't allow advancing wizard when checks fail

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10280 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
nor..67 12 years ago
parent 30eec0beeb
commit 2e95df2ed8
  1. 6
      sdk/jme3-core/src/com/jme3/gde/core/codeless/Bundle.properties
  2. 19
      sdk/jme3-core/src/com/jme3/gde/core/codeless/CodelessProjectWizardAction.java
  3. 115
      sdk/jme3-core/src/com/jme3/gde/core/codeless/CodelessProjectWizardVisualPanel1.form
  4. 137
      sdk/jme3-core/src/com/jme3/gde/core/codeless/CodelessProjectWizardVisualPanel1.java
  5. 35
      sdk/jme3-core/src/com/jme3/gde/core/codeless/CodelessProjectWizardWizardPanel1.java

@ -4,12 +4,8 @@ CodelessProjectWizardVisualPanel1.jTextField1.text=path to project
CodelessProjectWizardVisualPanel1.jButton1.text=.. CodelessProjectWizardVisualPanel1.jButton1.text=..
CodelessProjectWizardVisualPanel1.jLabel3.text=Enter the root folder of your project: CodelessProjectWizardVisualPanel1.jLabel3.text=Enter the root folder of your project:
CodelessProjectWizardVisualPanel1.jLabel1.text=Project Folder: CodelessProjectWizardVisualPanel1.jLabel1.text=Project Folder:
CodelessProjectWizardVisualPanel1.jPanel1.border.title=Information
CodelessProjectWizardVisualPanel1.jTextField2.text=path to assets CodelessProjectWizardVisualPanel1.jTextField2.text=path to assets
CodelessProjectWizardVisualPanel1.jButton2.text=.. CodelessProjectWizardVisualPanel1.jButton2.text=..
CodelessProjectWizardVisualPanel1.jLabel4.text=Enter the assets folder relative to the project folder: CodelessProjectWizardVisualPanel1.jLabel4.text=Enter the assets folder relative to the project folder:
CodelessProjectWizardVisualPanel1.jLabel5.text=A settings folder will be created in your project directory.
CodelessProjectWizardVisualPanel1.jLabel6.text=This importer will create a project that only manages the
CodelessProjectWizardVisualPanel1.jLabel7.text=external projects assets. No code or libraries will be imported.
CodelessProjectWizardVisualPanel2.jLabel1.text=TODO-No checks for now! CodelessProjectWizardVisualPanel2.jLabel1.text=TODO-No checks for now!
CodelessProjectWizardVisualPanel1.jLabel8.text=The assets folder should be in your games AssetManager root. CodelessProjectWizardVisualPanel1.jTextArea1.text=This importer will create a project that only manages the external projects assets. No code or libraries will be imported.\n\nThe specified assets folder should be your games AssetManager root or in the classpath of your project.\n\nA settings file will be created in your project directory.

@ -39,6 +39,8 @@ import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JComponent; import javax.swing.JComponent;
import org.netbeans.api.project.Project; import org.netbeans.api.project.Project;
import org.netbeans.api.project.ProjectManager; import org.netbeans.api.project.ProjectManager;
@ -57,6 +59,7 @@ import org.openide.util.actions.CallableSystemAction;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public final class CodelessProjectWizardAction extends CallableSystemAction { public final class CodelessProjectWizardAction extends CallableSystemAction {
private static final Logger logger = Logger.getLogger(CodelessProjectWizardAction.class.getName());
private WizardDescriptor.Panel[] panels; private WizardDescriptor.Panel[] panels;
public void performAction() { public void performAction() {
@ -80,21 +83,23 @@ public final class CodelessProjectWizardAction extends CallableSystemAction {
try { try {
FileObject properties = project.createData(CodelessProjectFactory.CONFIG_NAME); FileObject properties = project.createData(CodelessProjectFactory.CONFIG_NAME);
Properties propertiesObj = new Properties(); Properties propertiesObj = new Properties();
FileLock lock=properties.lock(); FileLock lock = properties.lock();
InputStream in=properties.getInputStream(); InputStream in = properties.getInputStream();
propertiesObj.load(in); propertiesObj.load(in);
in.close(); in.close();
propertiesObj.setProperty("assets.folder.name", assetsFolder); propertiesObj.setProperty("assets.folder.name", assetsFolder);
OutputStream out=properties.getOutputStream(lock); OutputStream out = properties.getOutputStream(lock);
propertiesObj.store(out, "assets properties"); propertiesObj.store(out, "assets properties");
out.close(); out.close();
lock.releaseLock(); lock.releaseLock();
Project theProject = ProjectManager.getDefault().findProject(project); Project theProject = ProjectManager.getDefault().findProject(project);
if(theProject!=null){ if (theProject != null) {
Project[] array = new Project[1]; Project[] array = new Project[1];
array[0] = theProject; array[0] = theProject;
OpenProjects.getDefault().open(array, false); OpenProjects.getDefault().open(array, false);
} else {
logger.log(Level.SEVERE, "Could not create project!");
} }
} catch (IOException ex) { } catch (IOException ex) {
Exceptions.printStackTrace(ex); Exceptions.printStackTrace(ex);
@ -102,14 +107,14 @@ public final class CodelessProjectWizardAction extends CallableSystemAction {
} }
/** /**
* Initialize panels representing individual wizard's steps and sets * Initialize panels representing individual wizard's steps and sets various
* various properties for them influencing wizard appearance. * properties for them influencing wizard appearance.
*/ */
private WizardDescriptor.Panel[] getPanels() { private WizardDescriptor.Panel[] getPanels() {
if (panels == null) { if (panels == null) {
panels = new WizardDescriptor.Panel[]{ panels = new WizardDescriptor.Panel[]{
new CodelessProjectWizardWizardPanel1(), new CodelessProjectWizardWizardPanel1(),
new CodelessProjectWizardWizardPanel2() // new CodelessProjectWizardWizardPanel2()
}; };
String[] steps = new String[panels.length]; String[] steps = new String[panels.length];
for (int i = 0; i < panels.length; i++) { for (int i = 0; i < panels.length; i++) {

@ -19,11 +19,16 @@
<Group type="102" alignment="1" attributes="0"> <Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0"> <Group type="103" groupAlignment="1" attributes="0">
<Component id="jPanel1" alignment="0" max="32767" attributes="0"/> <Component id="jScrollPane1" max="32767" attributes="0"/>
<Component id="jLabel3" alignment="0" min="-2" pref="447" max="-2" attributes="0"/>
<Component id="jToolBar1" alignment="0" max="32767" attributes="0"/> <Component id="jToolBar1" alignment="0" max="32767" attributes="0"/>
<Component id="jLabel4" alignment="0" min="-2" pref="300" max="-2" attributes="0"/>
<Component id="jToolBar2" alignment="1" max="32767" attributes="0"/> <Component id="jToolBar2" alignment="1" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jLabel3" alignment="0" min="-2" pref="447" max="-2" attributes="0"/>
<Component id="jLabel4" alignment="0" min="-2" pref="300" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
</Group> </Group>
@ -40,86 +45,14 @@
<Component id="jLabel4" min="-2" max="-2" attributes="0"/> <Component id="jLabel4" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="jToolBar2" min="-2" pref="25" max="-2" attributes="0"/> <Component id="jToolBar2" min="-2" pref="25" max="-2" attributes="0"/>
<EmptySpace pref="44" max="32767" attributes="0"/>
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
</Group> <Component id="jScrollPane1" pref="227" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JPanel" name="jPanel1">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Information">
<ResourceString PropertyName="titleX" bundle="com/jme3/gde/core/codeless/Bundle.properties" key="CodelessProjectWizardVisualPanel1.jPanel1.border.title" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</TitledBorder>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel6" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLabel7" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLabel5" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLabel8" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel6" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel7" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jLabel5" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="23" max="32767" attributes="0"/>
<Component id="jLabel8" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
</Layout> </Layout>
<SubComponents> <SubComponents>
<Component class="javax.swing.JLabel" name="jLabel5">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="com/jme3/gde/core/codeless/Bundle.properties" key="CodelessProjectWizardVisualPanel1.jLabel5.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel6">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="com/jme3/gde/core/codeless/Bundle.properties" key="CodelessProjectWizardVisualPanel1.jLabel6.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel7">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="com/jme3/gde/core/codeless/Bundle.properties" key="CodelessProjectWizardVisualPanel1.jLabel7.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel8">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="com/jme3/gde/core/codeless/Bundle.properties" key="CodelessProjectWizardVisualPanel1.jLabel8.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JLabel" name="jLabel3"> <Component class="javax.swing.JLabel" name="jLabel3">
<Properties> <Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
@ -166,6 +99,9 @@
<ResourceString bundle="com/jme3/gde/core/codeless/Bundle.properties" key="CodelessProjectWizardVisualPanel1.jTextField1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/> <ResourceString bundle="com/jme3/gde/core/codeless/Bundle.properties" key="CodelessProjectWizardVisualPanel1.jTextField1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property> </Property>
</Properties> </Properties>
<Events>
<EventHandler event="keyReleased" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="checkInput"/>
</Events>
</Component> </Component>
<Component class="javax.swing.JButton" name="jButton1"> <Component class="javax.swing.JButton" name="jButton1">
<Properties> <Properties>
@ -220,6 +156,9 @@
<ResourceString bundle="com/jme3/gde/core/codeless/Bundle.properties" key="CodelessProjectWizardVisualPanel1.jTextField2.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/> <ResourceString bundle="com/jme3/gde/core/codeless/Bundle.properties" key="CodelessProjectWizardVisualPanel1.jTextField2.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property> </Property>
</Properties> </Properties>
<Events>
<EventHandler event="keyReleased" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="checkInput"/>
</Events>
</Component> </Component>
<Component class="javax.swing.JButton" name="jButton2"> <Component class="javax.swing.JButton" name="jButton2">
<Properties> <Properties>
@ -243,5 +182,29 @@
</Property> </Property>
</Properties> </Properties>
</Component> </Component>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTextArea" name="jTextArea1">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="columns" type="int" value="20"/>
<Property name="lineWrap" type="boolean" value="true"/>
<Property name="rows" type="int" value="5"/>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="com/jme3/gde/core/codeless/Bundle.properties" key="CodelessProjectWizardVisualPanel1.jTextArea1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="wrapStyleWord" type="boolean" value="true"/>
<Property name="disabledTextColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="0" red="0" type="rgb"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents> </SubComponents>
</Form> </Form>

@ -38,9 +38,15 @@ import org.openide.filesystems.FileChooserBuilder;
public final class CodelessProjectWizardVisualPanel1 extends JPanel { public final class CodelessProjectWizardVisualPanel1 extends JPanel {
/** Creates new form CodelessProjectWizardVisualPanel1 */ private final CodelessProjectWizardWizardPanel1 panel;
public CodelessProjectWizardVisualPanel1() {
/**
* Creates new form CodelessProjectWizardVisualPanel1
*/
public CodelessProjectWizardVisualPanel1(CodelessProjectWizardWizardPanel1 panel) {
initComponents(); initComponents();
this.panel = panel;
enableAssetsPath(false);
} }
@Override @Override
@ -48,32 +54,32 @@ public final class CodelessProjectWizardVisualPanel1 extends JPanel {
return "Specify Folders"; return "Specify Folders";
} }
public String getProjectPath(){ public String getProjectPath() {
return jTextField1.getText(); return jTextField1.getText();
} }
public String getAssetsPath(){ public String getAssetsPath() {
return jTextField2.getText(); return jTextField2.getText();
} }
public void setListener(ActionListener listener){ public void setListener(ActionListener listener) {
jTextField1.addActionListener(listener); jTextField1.addActionListener(listener);
jTextField2.addActionListener(listener); jTextField2.addActionListener(listener);
} }
/** This method is called from within the constructor to public void enableAssetsPath(boolean enable) {
* initialize the form. jButton2.setEnabled(enable);
* WARNING: Do NOT modify this code. The content of this method is jTextField2.setEnabled(enable);
* always regenerated by the Form Editor. }
/**
* 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.
*/ */
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() { private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel();
jToolBar1 = new javax.swing.JToolBar(); jToolBar1 = new javax.swing.JToolBar();
jLabel1 = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel();
@ -86,44 +92,10 @@ public final class CodelessProjectWizardVisualPanel1 extends JPanel {
jTextField2 = new javax.swing.JTextField(); jTextField2 = new javax.swing.JTextField();
jButton2 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton();
jLabel4 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(CodelessProjectWizardVisualPanel1.class, "CodelessProjectWizardVisualPanel1.jPanel1.border.title"))); // NOI18N jLabel3.setFont(new java.awt.Font("Lucida Grande", 0, 12)); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(jLabel5, org.openide.util.NbBundle.getMessage(CodelessProjectWizardVisualPanel1.class, "CodelessProjectWizardVisualPanel1.jLabel5.text")); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(jLabel6, org.openide.util.NbBundle.getMessage(CodelessProjectWizardVisualPanel1.class, "CodelessProjectWizardVisualPanel1.jLabel6.text")); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(jLabel7, org.openide.util.NbBundle.getMessage(CodelessProjectWizardVisualPanel1.class, "CodelessProjectWizardVisualPanel1.jLabel7.text")); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(jLabel8, org.openide.util.NbBundle.getMessage(CodelessProjectWizardVisualPanel1.class, "CodelessProjectWizardVisualPanel1.jLabel8.text")); // NOI18N
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel6)
.addComponent(jLabel7)
.addComponent(jLabel5)
.addComponent(jLabel8))
.addContainerGap(22, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel7)
.addGap(18, 18, 18)
.addComponent(jLabel5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 23, Short.MAX_VALUE)
.addComponent(jLabel8)
.addContainerGap())
);
jLabel3.setFont(new java.awt.Font("Lucida Grande", 0, 12));
org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(CodelessProjectWizardVisualPanel1.class, "CodelessProjectWizardVisualPanel1.jLabel3.text")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(CodelessProjectWizardVisualPanel1.class, "CodelessProjectWizardVisualPanel1.jLabel3.text")); // NOI18N
jToolBar1.setFloatable(false); jToolBar1.setFloatable(false);
@ -146,6 +118,11 @@ public final class CodelessProjectWizardVisualPanel1 extends JPanel {
jToolBar1.add(jPanel2); jToolBar1.add(jPanel2);
jTextField1.setText(org.openide.util.NbBundle.getMessage(CodelessProjectWizardVisualPanel1.class, "CodelessProjectWizardVisualPanel1.jTextField1.text")); // NOI18N jTextField1.setText(org.openide.util.NbBundle.getMessage(CodelessProjectWizardVisualPanel1.class, "CodelessProjectWizardVisualPanel1.jTextField1.text")); // NOI18N
jTextField1.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
checkInput(evt);
}
});
jToolBar1.add(jTextField1); jToolBar1.add(jTextField1);
org.openide.awt.Mnemonics.setLocalizedText(jButton1, org.openide.util.NbBundle.getMessage(CodelessProjectWizardVisualPanel1.class, "CodelessProjectWizardVisualPanel1.jButton1.text")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(jButton1, org.openide.util.NbBundle.getMessage(CodelessProjectWizardVisualPanel1.class, "CodelessProjectWizardVisualPanel1.jButton1.text")); // NOI18N
@ -178,6 +155,11 @@ public final class CodelessProjectWizardVisualPanel1 extends JPanel {
jToolBar2.add(jPanel3); jToolBar2.add(jPanel3);
jTextField2.setText(org.openide.util.NbBundle.getMessage(CodelessProjectWizardVisualPanel1.class, "CodelessProjectWizardVisualPanel1.jTextField2.text")); // NOI18N jTextField2.setText(org.openide.util.NbBundle.getMessage(CodelessProjectWizardVisualPanel1.class, "CodelessProjectWizardVisualPanel1.jTextField2.text")); // NOI18N
jTextField2.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
checkInput(evt);
}
});
jToolBar2.add(jTextField2); jToolBar2.add(jTextField2);
org.openide.awt.Mnemonics.setLocalizedText(jButton2, org.openide.util.NbBundle.getMessage(CodelessProjectWizardVisualPanel1.class, "CodelessProjectWizardVisualPanel1.jButton2.text")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(jButton2, org.openide.util.NbBundle.getMessage(CodelessProjectWizardVisualPanel1.class, "CodelessProjectWizardVisualPanel1.jButton2.text")); // NOI18N
@ -188,9 +170,18 @@ public final class CodelessProjectWizardVisualPanel1 extends JPanel {
}); });
jToolBar2.add(jButton2); jToolBar2.add(jButton2);
jLabel4.setFont(new java.awt.Font("Lucida Grande", 0, 12)); jLabel4.setFont(new java.awt.Font("Lucida Grande", 0, 12)); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(jLabel4, org.openide.util.NbBundle.getMessage(CodelessProjectWizardVisualPanel1.class, "CodelessProjectWizardVisualPanel1.jLabel4.text")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(jLabel4, org.openide.util.NbBundle.getMessage(CodelessProjectWizardVisualPanel1.class, "CodelessProjectWizardVisualPanel1.jLabel4.text")); // NOI18N
jTextArea1.setEditable(false);
jTextArea1.setColumns(20);
jTextArea1.setLineWrap(true);
jTextArea1.setRows(5);
jTextArea1.setText(org.openide.util.NbBundle.getMessage(CodelessProjectWizardVisualPanel1.class, "CodelessProjectWizardVisualPanel1.jTextArea1.text")); // NOI18N
jTextArea1.setWrapStyleWord(true);
jTextArea1.setDisabledTextColor(new java.awt.Color(0, 0, 0));
jScrollPane1.setViewportView(jTextArea1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout); this.setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(
@ -198,11 +189,14 @@ public final class CodelessProjectWizardVisualPanel1 extends JPanel {
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jScrollPane1)
.addComponent(jToolBar1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jToolBar2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 447, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 447, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jToolBar1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 447, Short.MAX_VALUE) .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jLabel4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, Short.MAX_VALUE)))
.addComponent(jToolBar2, javax.swing.GroupLayout.DEFAULT_SIZE, 447, Short.MAX_VALUE))
.addContainerGap()) .addContainerGap())
); );
layout.setVerticalGroup( layout.setVerticalGroup(
@ -216,38 +210,46 @@ public final class CodelessProjectWizardVisualPanel1 extends JPanel {
.addComponent(jLabel4) .addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jToolBar2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jToolBar2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 44, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 227, Short.MAX_VALUE)
.addContainerGap()) .addContainerGap())
); );
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
FileChooserBuilder builder = new FileChooserBuilder(System.getProperty("user.home")); FileChooserBuilder builder = new FileChooserBuilder(getClass());
builder.setDefaultWorkingDirectory(new File(System.getProperty("user.dir")));
builder.setDirectoriesOnly(true); builder.setDirectoriesOnly(true);
builder.setTitle("Select Project Folder"); builder.setTitle("Select Project Folder");
File file = builder.showOpenDialog(); File file = builder.showOpenDialog();
if (file != null) { if (file != null) {
jTextField1.setText(file.getPath()); jTextField1.setText(file.getAbsolutePath() + File.separator);
panel.fireChangeEvent();
} }
}//GEN-LAST:event_jButton1ActionPerformed }//GEN-LAST:event_jButton1ActionPerformed
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
File path=new File(jTextField1.getText()); String pathName = jTextField1.getText();
if(path.isDirectory()){ File path = new File(pathName);
FileChooserBuilder builder = new FileChooserBuilder(path.getAbsolutePath().replaceAll("\\","/")); if (path.isDirectory()) {
FileChooserBuilder builder = new FileChooserBuilder(getClass());
builder.setDefaultWorkingDirectory(path);
builder.setDirectoriesOnly(true); builder.setDirectoriesOnly(true);
builder.setTitle("Select Assets Folder"); builder.setTitle("Select Assets Folder");
File file = builder.showOpenDialog(); File file = builder.showOpenDialog();
if (file != null) { if (file != null) {
try { try {
jTextField2.setText(file.getAbsolutePath().substring(path.getAbsolutePath().length(), file.getAbsolutePath().length()).replaceAll("\\","/")); jTextField2.setText(file.getAbsolutePath().substring(pathName.length(), file.getAbsolutePath().length()));
panel.fireChangeEvent();
} catch (Exception e) { } catch (Exception e) {
} }
} }
} }
}//GEN-LAST:event_jButton2ActionPerformed }//GEN-LAST:event_jButton2ActionPerformed
private void checkInput(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_checkInput
panel.fireChangeEvent();
}//GEN-LAST:event_checkInput
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1; private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2; private javax.swing.JButton jButton2;
@ -255,13 +257,10 @@ public final class CodelessProjectWizardVisualPanel1 extends JPanel {
private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3; private javax.swing.JPanel jPanel3;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea jTextArea1;
private javax.swing.JTextField jTextField1; private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2; private javax.swing.JTextField jTextField2;
private javax.swing.JToolBar jToolBar1; private javax.swing.JToolBar jToolBar1;

@ -32,6 +32,11 @@
package com.jme3.gde.core.codeless; package com.jme3.gde.core.codeless;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.io.File;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import org.openide.WizardDescriptor; import org.openide.WizardDescriptor;
import org.openide.util.HelpCtx; import org.openide.util.HelpCtx;
@ -43,6 +48,7 @@ public class CodelessProjectWizardWizardPanel1 implements WizardDescriptor.Panel
* component from this class, just use getComponent(). * component from this class, just use getComponent().
*/ */
private CodelessProjectWizardVisualPanel1 component; private CodelessProjectWizardVisualPanel1 component;
private final Set<ChangeListener> listeners = new HashSet<ChangeListener>(1); // or can use ChangeSupport in NB 6.0
// Get the visual component for the panel. In this template, the component // Get the visual component for the panel. In this template, the component
// is kept separate. This can be more efficient: if the wizard is created // is kept separate. This can be more efficient: if the wizard is created
@ -50,7 +56,7 @@ public class CodelessProjectWizardWizardPanel1 implements WizardDescriptor.Panel
// create only those which really need to be visible. // create only those which really need to be visible.
public CodelessProjectWizardVisualPanel1 getComponent() { public CodelessProjectWizardVisualPanel1 getComponent() {
if (component == null) { if (component == null) {
component = new CodelessProjectWizardVisualPanel1(); component = new CodelessProjectWizardVisualPanel1(this);
} }
return component; return component;
} }
@ -63,31 +69,33 @@ public class CodelessProjectWizardWizardPanel1 implements WizardDescriptor.Panel
} }
public boolean isValid() { public boolean isValid() {
// StatusDisplayer.getDefault().setStatusText("Check: "+component.getProjectPath()); String projectPath = component.getProjectPath();
// if (new File(component.getProjectPath()).isDirectory() String assetsPath = component.getAssetsPath();
// && new File(component.getProjectPath()+File.separator+component.getAssetsPath()).isDirectory()) { File projectFile = new File(projectPath);
if (projectFile.isDirectory()) {
component.enableAssetsPath(true);
File assetsFile = new File(projectPath + assetsPath);
if (assetsFile.isDirectory()) {
return true; return true;
// }
// return false;
} }
} else {
public final void addChangeListener(ChangeListener l) { component.enableAssetsPath(false);
} }
return false;
public final void removeChangeListener(ChangeListener l) {
} }
/*
private final Set<ChangeListener> listeners = new HashSet<ChangeListener>(1); // or can use ChangeSupport in NB 6.0
public final void addChangeListener(ChangeListener l) { public final void addChangeListener(ChangeListener l) {
synchronized (listeners) { synchronized (listeners) {
listeners.add(l); listeners.add(l);
} }
} }
public final void removeChangeListener(ChangeListener l) { public final void removeChangeListener(ChangeListener l) {
synchronized (listeners) { synchronized (listeners) {
listeners.remove(l); listeners.remove(l);
} }
} }
protected final void fireChangeEvent() { protected final void fireChangeEvent() {
Iterator<ChangeListener> it; Iterator<ChangeListener> it;
synchronized (listeners) { synchronized (listeners) {
@ -98,14 +106,13 @@ public class CodelessProjectWizardWizardPanel1 implements WizardDescriptor.Panel
it.next().stateChanged(ev); it.next().stateChanged(ev);
} }
} }
*/
// You can use a settings object to keep track of state. Normally the // You can use a settings object to keep track of state. Normally the
// settings object will be the WizardDescriptor, so you can use // settings object will be the WizardDescriptor, so you can use
// WizardDescriptor.getProperty & putProperty to store information entered // WizardDescriptor.getProperty & putProperty to store information entered
// by the user. // by the user.
public void readSettings(Object settings) { public void readSettings(Object settings) {
ActionListener listener=((WizardDescriptor)settings).getButtonListener(); ActionListener listener = ((WizardDescriptor) settings).getButtonListener();
getComponent().setListener(listener); getComponent().setListener(listener);
} }

Loading…
Cancel
Save