From 1f4e66695585cd35dda6e4d385df2cdd10d62a91 Mon Sep 17 00:00:00 2001 From: "nor..67" Date: Mon, 11 Jun 2012 00:39:50 +0000 Subject: [PATCH] SDK: - improved ModelImporter with failed assets list, better workflow and lots of information and help based on import results git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9470 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../jme3/gde/modelimporter/Bundle.properties | 33 +- .../jme3/gde/modelimporter/ImportModel.java | 29 +- .../ModelImporterVisualPanel1.form | 131 ++------ .../ModelImporterVisualPanel1.java | 307 ++++------------- .../ModelImporterVisualPanel3.form | 237 +++++++++++++ .../ModelImporterVisualPanel3.java | 315 ++++++++++++++++++ ...l2.form => ModelImporterVisualPanel4.form} | 48 +-- ...l2.java => ModelImporterVisualPanel4.java} | 45 +-- .../ModelImporterWizardPanel1.java | 58 ++-- .../ModelImporterWizardPanel3.java | 91 +++++ ...l2.java => ModelImporterWizardPanel4.java} | 6 +- 11 files changed, 842 insertions(+), 458 deletions(-) create mode 100644 sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterVisualPanel3.form create mode 100644 sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterVisualPanel3.java rename sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/{ModelImporterVisualPanel2.form => ModelImporterVisualPanel4.form} (69%) rename sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/{ModelImporterVisualPanel2.java => ModelImporterVisualPanel4.java} (63%) create mode 100644 sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterWizardPanel3.java rename sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/{ModelImporterWizardPanel2.java => ModelImporterWizardPanel4.java} (94%) diff --git a/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/Bundle.properties b/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/Bundle.properties index 94d602cd7..3fe1dc2d9 100644 --- a/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/Bundle.properties +++ b/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/Bundle.properties @@ -3,16 +3,31 @@ OpenIDE-Module-Display-Category=jMonkeyEngine OpenIDE-Module-Long-Description=\ This plugin allows importing models to a project using a Wizard. OpenIDE-Module-Name=Model Import Tool -ModelImporterVisualPanel2.jLabel1.text=Import to path: -ModelImporterVisualPanel2.jTextField1.text=/Models/MyModel -ModelImporterVisualPanel2.jCheckBox1.text=copy original model file(s) to project folder ModelImporterVisualPanel1.jTextField1.text= -ModelImporterVisualPanel1.jButton1.text=+ -ModelImporterVisualPanel1.jButton2.text=- -ModelImporterVisualPanel1.jButton3.text=< -ModelImporterVisualPanel1.jButton4.text=> ModelImporterVisualPanel1.jButton5.text=open model.. ModelImporterVisualPanel1.jLabel1.text=Imported Model Path: -ModelImporterVisualPanel2.jTextArea1.text=The model will be converted to j3o binary format and copied \nto the project folder including associated texture etc. files.\nThe given path will be used as the root folder for the model.\n\nIf you copy the original model files to the project folder you can re-convert the model at any time by double-clicking it. OpenIDE-Module-Short-Description=Allows importing models to a project using a Wizard -ModelImporterVisualPanel1.jButton6.text=reload with these settings +ModelImporterVisualPanel3.jTextArea1.text=The model will be converted to j3o binary format and copied \nto the project folder including associated texture etc. files.\nThe given path will be used as the root folder for the model.\n\nIf you copy the original model files to the project folder you can re-convert the model at any time by double-clicking it. +ModelImporterVisualPanel3.jLabel1.text=Import to path: +ModelImporterVisualPanel3.jTextField1.text=/Models/MyModel +ModelImporterVisualPanel3.jCheckBox1.text=copy original model file(s) to project folder +ModelImporterVisualPanel4.jLabel1.text=Import to path: +ModelImporterVisualPanel4.jTextField1.text=/Models/MyModel +ModelImporterVisualPanel4.jCheckBox1.text=copy original model file(s) to project folder +ModelImporterVisualPanel4.jTextArea1.text=The model will be converted to j3o binary format and copied \nto the project folder including associated texture etc. files.\nThe given path will be used as the root folder for the model.\n\nNote that the texture paths stored in the j3o file will be absolute! To have e.g. your textures in the Textures folder, import the model to the Textures folder and then move the j3o to the Models folder after the import.\n\nIf you copy the original model files to the project folder you can re-convert the model at any time by double-clicking it. +ModelImporterVisualPanel3.jButton3.text=< +ModelImporterVisualPanel3.jButton4.text=> +ModelImporterVisualPanel3.jButton2.text=- +ModelImporterVisualPanel3.jButton1.text=+ +ModelImporterVisualPanel2.jTextField1.text=/Models/MyModel +ModelImporterVisualPanel2.jCheckBox1.text=copy original model file(s) to project folder +ModelImporterVisualPanel2.jLabel1.text=Import to path: +ModelImporterVisualPanel2.jTextArea1.text=The model will be converted to j3o binary format and copied \nto the project folder including associated texture etc. files.\nThe given path will be used as the root folder for the model.\n\nIf you copy the original model files to the project folder you can re-convert the model at any time by double-clicking it. +ModelImporterVisualPanel1.jTextArea1.text=Note that the following requirements have to be met for a successful import:\n\n* The model format has to be supported, currently OBJ, OgreXML and Blender formats are supported\n\n* The model textures have to be in the same folder as the model or a subfolder\n\n* The textures have to be UV mapped textures\n\n* Only diffuse, normal, specular, parallax and light maps will be imported\n\n* No extended material settings will be imported\n\n* For animations be sure to have a single root bone +ModelImporterVisualPanel2.jLabel1.text_1=Asset List +ModelImporterVisualPanel2.jLabel2.text=Assets failed to load +ModelImporterVisualPanel2.statusLabel.text=jLabel3 +ModelImporterVisualPanel3.jLabel2.text=Assets failed to load +ModelImporterVisualPanel3.jLabel1.text_1=Asset List +ModelImporterVisualPanel3.statusLabel.text=jLabel3 +ModelImporterVisualPanel3.infoTextArea.text_1=Check if the model looks as expected, if some textures fail to load, make sure they are in the same folder or a subfolder of the model. If no textures can be found the model will be displayed in red. With the buttons above you can move the camera. diff --git a/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ImportModel.java b/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ImportModel.java index f26b92e15..07f39c615 100644 --- a/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ImportModel.java +++ b/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ImportModel.java @@ -25,6 +25,7 @@ import org.netbeans.api.progress.ProgressHandle; import org.netbeans.api.progress.ProgressHandleFactory; import org.netbeans.api.project.Project; import org.openide.DialogDisplayer; +import org.openide.NotifyDescriptor; import org.openide.WizardDescriptor; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileUtil; @@ -51,10 +52,9 @@ public final class ImportModel implements ActionListener { dialog.setVisible(true); dialog.toFront(); boolean cancelled = wiz.getValue() != WizardDescriptor.FINISH_OPTION; - ((ModelImporterWizardPanel1) panels[0]).cleanup(); + ((ModelImporterWizardPanel3) panels[1]).cleanup(); if (!cancelled) { new Thread(new Runnable() { - public void run() { ProgressHandle handle = ProgressHandleFactory.createHandle("Importing Model.."); handle.start(); @@ -89,8 +89,22 @@ public final class ImportModel implements ActionListener { destFolder.mkdirs(); FileObject dest = FileUtil.toFileObject(destFolder); try { - FileObject fileObj = source.copy(dest, source.getName(), source.getExt()); - if (!(assetKey instanceof TextureKey)) { + FileObject fileObj = dest.getFileObject(source.getName(), source.getExt()); + if (fileObj != null) { + NotifyDescriptor.Confirmation msg = new NotifyDescriptor.Confirmation( + "File "+source.getNameExt()+" exists, overwrite?", + NotifyDescriptor.YES_NO_OPTION, + NotifyDescriptor.WARNING_MESSAGE); + Object result = DialogDisplayer.getDefault().notify(msg); + if (NotifyDescriptor.YES_OPTION.equals(result)) { + fileObj.delete(); + fileObj = source.copy(dest, source.getName(), source.getExt()); + } else { + } + } else { + fileObj = source.copy(dest, source.getName(), source.getExt()); + } + if (!(assetKey instanceof TextureKey) && fileObj != null) { deleteList.add(fileObj); } } catch (Exception ex) { @@ -137,14 +151,15 @@ public final class ImportModel implements ActionListener { } /** - * Initialize panels representing individual wizard's steps and sets - * various properties for them influencing wizard appearance. + * Initialize panels representing individual wizard's steps and sets various + * properties for them influencing wizard appearance. */ private WizardDescriptor.Panel[] getPanels() { if (panels == null) { panels = new WizardDescriptor.Panel[]{ new ModelImporterWizardPanel1(), - new ModelImporterWizardPanel2() + new ModelImporterWizardPanel3(), + new ModelImporterWizardPanel4() }; String[] steps = new String[panels.length]; for (int i = 0; i < panels.length; i++) { diff --git a/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterVisualPanel1.form b/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterVisualPanel1.form index a032c04bf..3c6a14d39 100644 --- a/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterVisualPanel1.form +++ b/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterVisualPanel1.form @@ -1,4 +1,4 @@ - +
@@ -17,29 +17,26 @@ - + - + - + - + - - - + + - - @@ -59,6 +56,28 @@ + + + + + + + + + + + + + + + + + + + + + + @@ -72,98 +91,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterVisualPanel1.java b/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterVisualPanel1.java index 057d32f3c..7d0705c22 100644 --- a/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterVisualPanel1.java +++ b/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterVisualPanel1.java @@ -8,240 +8,134 @@ import com.jme3.asset.AssetKey; import com.jme3.gde.core.assets.AssetData; import com.jme3.gde.core.assets.AssetDataObject; import com.jme3.gde.core.assets.ProjectAssetManager; -import com.jme3.gde.core.scene.OffScenePanel; -import com.jme3.math.Vector3f; -import com.jme3.scene.Spatial; import java.io.File; -import java.util.List; -import java.util.concurrent.atomic.AtomicBoolean; import javax.swing.JPanel; -import org.netbeans.api.progress.ProgressHandle; -import org.netbeans.api.progress.ProgressHandleFactory; -import org.openide.DialogDisplayer; -import org.openide.NotifyDescriptor; -import org.openide.NotifyDescriptor.Message; import org.openide.WizardDescriptor; import org.openide.explorer.propertysheet.PropertySheet; import org.openide.filesystems.FileChooserBuilder; -import org.openide.filesystems.FileObject; import org.openide.filesystems.FileUtil; import org.openide.loaders.DataObject; +import org.openide.loaders.DataObjectNotFoundException; import org.openide.nodes.Node; import org.openide.util.Exceptions; @SuppressWarnings({"unchecked", "serial"}) public final class ModelImporterVisualPanel1 extends JPanel { - private OffScenePanel offPanel; - private String currentPath; - private String currentModelPath; - private Spatial currentModel; - private List keys; + private ModelImporterWizardPanel1 panel; private AssetKey mainKey; private PropertySheet ps; - private AtomicBoolean loading = new AtomicBoolean(false); + private ProjectAssetManager manager; + private DataObject dataObject; + private AssetData data; + private String currentPath; - /** Creates new form ModelImporterVisualPanel1 */ - public ModelImporterVisualPanel1() { + /** + * Creates new form ModelImporterVisualPanel1 + */ + public ModelImporterVisualPanel1(ModelImporterWizardPanel1 panel) { initComponents(); - offPanel = new OffScenePanel(320, 320); - offPanel.startPreview(); - jPanel1.add(offPanel); + this.panel = panel; ps = new PropertySheet(); ps.setNodes(new Node[]{}); + ps.setDescriptionAreaVisible(false); jPanel2.add(ps); } @Override public String getName() { - return "Preview Model"; + return "Import Options"; } public void loadSettings(WizardDescriptor wiz) { -// manager = (ProjectAssetManager) wiz.getProperty("manager"); + wiz.putProperty("path", null); + wiz.putProperty("manager", null); + wiz.putProperty("dataobject", null); + wiz.putProperty("assetdata", null); + wiz.putProperty("mainkey", null); + wiz.putProperty("destpath", null); + + wiz.putProperty("assetlist", null); + wiz.putProperty("failedlist", null); + wiz.putProperty("model", null); } public void applySettings(WizardDescriptor wiz) { wiz.putProperty("path", currentPath); - wiz.putProperty("assetlist", keys); + wiz.putProperty("manager", manager); + wiz.putProperty("dataobject", dataObject); + wiz.putProperty("assetdata", data); wiz.putProperty("mainkey", mainKey); if (mainKey != null) { wiz.putProperty("destpath", "Models/" + mainKey.getName().replaceAll(mainKey.getExtension(), "").replaceAll("\\.", "") + "/"); } } - public synchronized void loadModel(File path) { - loadModel(path, null); + public boolean checkValid() { + return mainKey != null && dataObject != null; } - public synchronized void loadModel(File path, AssetKey modelKey) { - ProjectAssetManager manager = new ProjectAssetManager(FileUtil.toFileObject(path).getParent()); + public synchronized void loadKey(File path) { + mainKey = null; + manager = null; + dataObject = null; + data = null; + manager = new ProjectAssetManager(FileUtil.toFileObject(path).getParent()); try { - if (modelKey != mainKey) { - keys = null; - } - if (currentModel != null) { - offPanel.detach(currentModel); - currentModel = null; - } - currentModelPath = path.getPath(); - currentPath = path.getParent(); - DataObject obj = DataObject.find(FileUtil.toFileObject(path)); - AssetData data = obj != null ? obj.getLookup().lookup(AssetData.class) : null; + dataObject = DataObject.find(FileUtil.toFileObject(path)); + data = dataObject != null ? dataObject.getLookup().lookup(AssetData.class) : null; if (data != null) { - if (modelKey == null) { - ((AssetDataObject) obj).getLookupContents().add(manager); - modelKey = data.getAssetKey(); - currentModel = (Spatial) data.loadAsset(); - keys = data.getAssetKeyList(); - } else { - ((AssetDataObject) obj).getLookupContents().add(manager); - data.setAssetKey(modelKey); - currentModel = (Spatial) data.loadAsset(); - keys = data.getAssetKeyList(); - } - } - mainKey = modelKey; - updateProperties(mainKey); - if (currentModel != null) { - offPanel.attach(currentModel); - } else { - Message msg = new NotifyDescriptor.Message( - "Cannot import this file!", - NotifyDescriptor.ERROR_MESSAGE); - DialogDisplayer.getDefault().notifyLater(msg); + ((AssetDataObject) dataObject).getLookupContents().add(manager); + mainKey = data.getAssetKey(); + updateProperties(mainKey); } - } catch (Exception e) { - Message msg = new NotifyDescriptor.Message( - "Error importing file!\n" - + "(" + e + ")", - NotifyDescriptor.ERROR_MESSAGE); - DialogDisplayer.getDefault().notifyLater(msg); - Exceptions.printStackTrace(e); + } catch (DataObjectNotFoundException ex) { + Exceptions.printStackTrace(ex); } - manager.clearCache(); + panel.fireChangeEvent(); } private void updateProperties(final AssetKey key) { - java.awt.EventQueue.invokeLater(new Runnable() { - - public void run() { - if (key == null) { - ps.setNodes(new Node[]{}); - } else { - ps.setNodes(new Node[]{new ImportKeyNode(key)}); - } - } - }); - - } - - public void cleanup() { - offPanel.stopPreview(); + if (key == null) { + ps.setNodes(new Node[]{}); + } else { + ps.setNodes(new Node[]{new ImportKeyNode(key)}); + } } - /** 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. + /** + * 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() { jPanel1 = new javax.swing.JPanel(); + jScrollPane1 = new javax.swing.JScrollPane(); + jTextArea1 = new javax.swing.JTextArea(); jPanel2 = new javax.swing.JPanel(); jTextField1 = new javax.swing.JTextField(); - jToolBar1 = new javax.swing.JToolBar(); - jButton1 = new javax.swing.JButton(); - jButton2 = new javax.swing.JButton(); - jSeparator1 = new javax.swing.JToolBar.Separator(); - jButton3 = new javax.swing.JButton(); - jButton4 = new javax.swing.JButton(); - jPanel3 = new javax.swing.JPanel(); - jButton6 = new javax.swing.JButton(); jButton5 = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel(); jPanel1.setPreferredSize(new java.awt.Dimension(320, 320)); jPanel1.setLayout(new javax.swing.BoxLayout(jPanel1, javax.swing.BoxLayout.LINE_AXIS)); + jTextArea1.setColumns(20); + jTextArea1.setLineWrap(true); + jTextArea1.setRows(5); + jTextArea1.setText(org.openide.util.NbBundle.getMessage(ModelImporterVisualPanel1.class, "ModelImporterVisualPanel1.jTextArea1.text")); // NOI18N + jTextArea1.setWrapStyleWord(true); + jScrollPane1.setViewportView(jTextArea1); + + jPanel1.add(jScrollPane1); + jPanel2.setLayout(new javax.swing.BoxLayout(jPanel2, javax.swing.BoxLayout.LINE_AXIS)); jTextField1.setEditable(false); jTextField1.setText(org.openide.util.NbBundle.getMessage(ModelImporterVisualPanel1.class, "ModelImporterVisualPanel1.jTextField1.text")); // NOI18N - jToolBar1.setFloatable(false); - jToolBar1.setRollover(true); - - org.openide.awt.Mnemonics.setLocalizedText(jButton1, org.openide.util.NbBundle.getMessage(ModelImporterVisualPanel1.class, "ModelImporterVisualPanel1.jButton1.text")); // NOI18N - jButton1.setFocusable(false); - jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); - jButton1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - jButton1.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jButton1ActionPerformed(evt); - } - }); - jToolBar1.add(jButton1); - - org.openide.awt.Mnemonics.setLocalizedText(jButton2, org.openide.util.NbBundle.getMessage(ModelImporterVisualPanel1.class, "ModelImporterVisualPanel1.jButton2.text")); // NOI18N - jButton2.setFocusable(false); - jButton2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); - jButton2.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - jButton2.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jButton2ActionPerformed(evt); - } - }); - jToolBar1.add(jButton2); - jToolBar1.add(jSeparator1); - - org.openide.awt.Mnemonics.setLocalizedText(jButton3, org.openide.util.NbBundle.getMessage(ModelImporterVisualPanel1.class, "ModelImporterVisualPanel1.jButton3.text")); // NOI18N - jButton3.setFocusable(false); - jButton3.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); - jButton3.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - jButton3.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jButton3ActionPerformed(evt); - } - }); - jToolBar1.add(jButton3); - - org.openide.awt.Mnemonics.setLocalizedText(jButton4, org.openide.util.NbBundle.getMessage(ModelImporterVisualPanel1.class, "ModelImporterVisualPanel1.jButton4.text")); // NOI18N - jButton4.setFocusable(false); - jButton4.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); - jButton4.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - jButton4.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jButton4ActionPerformed(evt); - } - }); - jToolBar1.add(jButton4); - - javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); - jPanel3.setLayout(jPanel3Layout); - jPanel3Layout.setHorizontalGroup( - jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 310, Short.MAX_VALUE) - ); - jPanel3Layout.setVerticalGroup( - jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 21, Short.MAX_VALUE) - ); - - jToolBar1.add(jPanel3); - - org.openide.awt.Mnemonics.setLocalizedText(jButton6, org.openide.util.NbBundle.getMessage(ModelImporterVisualPanel1.class, "ModelImporterVisualPanel1.jButton6.text")); // NOI18N - jButton6.setFocusable(false); - jButton6.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); - jButton6.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - jButton6.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jButton6ActionPerformed(evt); - } - }); - jToolBar1.add(jButton6); - org.openide.awt.Mnemonics.setLocalizedText(jButton5, org.openide.util.NbBundle.getMessage(ModelImporterVisualPanel1.class, "ModelImporterVisualPanel1.jButton5.text")); // NOI18N jButton5.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { @@ -256,24 +150,21 @@ public final class ModelImporterVisualPanel1 extends JPanel { layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 424, Short.MAX_VALUE) + .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 433, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton5)) - .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 559, Short.MAX_VALUE) + .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup() - .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 331, Short.MAX_VALUE) + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 228, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 559, Short.MAX_VALUE) + .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 259, javax.swing.GroupLayout.PREFERRED_SIZE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 340, Short.MAX_VALUE) - .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 340, Short.MAX_VALUE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 330, Short.MAX_VALUE) + .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) @@ -283,78 +174,24 @@ public final class ModelImporterVisualPanel1 extends JPanel { ); }// //GEN-END:initComponents - private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed - offPanel.zoomCamera(-.1f); - }//GEN-LAST:event_jButton2ActionPerformed - private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed - if (loading.get()) { - return; - } FileChooserBuilder builder = new FileChooserBuilder(this.getClass()); builder.setTitle("Select Model File"); final File file = builder.showOpenDialog(); if (file != null) { - loading.set(true); + currentPath = file.getParent(); jTextField1.setText(file.getAbsolutePath()); - new Thread(new Runnable() { - - public void run() { - ProgressHandle handle = ProgressHandleFactory.createHandle("Opening Model.."); - handle.start(); - loadModel(file); - handle.finish(); - loading.set(false); - } - }).start(); + loadKey(file); } }//GEN-LAST:event_jButton5ActionPerformed - private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed - offPanel.zoomCamera(.1f); - }//GEN-LAST:event_jButton1ActionPerformed - - private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed - offPanel.rotateCamera(Vector3f.UNIT_Y, .1f); - }//GEN-LAST:event_jButton3ActionPerformed - - private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed - offPanel.rotateCamera(Vector3f.UNIT_Y, -.1f); - }//GEN-LAST:event_jButton4ActionPerformed - -private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed - if (currentModelPath != null) { - if (loading.get()) { - return; - } - loading.set(true); - final String modelPath = currentModelPath; - final AssetKey key = mainKey; - new Thread(new Runnable() { - - public void run() { - ProgressHandle handle = ProgressHandleFactory.createHandle("Opening Model.."); - handle.start(); - loadModel(new File(modelPath), key); - handle.finish(); - loading.set(false); - } - }).start(); - } -}//GEN-LAST:event_jButton6ActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JButton jButton1; - private javax.swing.JButton jButton2; - private javax.swing.JButton jButton3; - private javax.swing.JButton jButton4; private javax.swing.JButton jButton5; - private javax.swing.JButton jButton6; private javax.swing.JLabel jLabel1; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; - private javax.swing.JPanel jPanel3; - private javax.swing.JToolBar.Separator jSeparator1; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JTextArea jTextArea1; private javax.swing.JTextField jTextField1; - private javax.swing.JToolBar jToolBar1; // End of variables declaration//GEN-END:variables } diff --git a/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterVisualPanel3.form b/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterVisualPanel3.form new file mode 100644 index 000000000..8908ccfcc --- /dev/null +++ b/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterVisualPanel3.form @@ -0,0 +1,237 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterVisualPanel3.java b/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterVisualPanel3.java new file mode 100644 index 000000000..4ef930d1b --- /dev/null +++ b/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterVisualPanel3.java @@ -0,0 +1,315 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.jme3.gde.modelimporter; + +import com.jme3.asset.AssetKey; +import com.jme3.gde.core.assets.AssetData; +import com.jme3.gde.core.assets.ProjectAssetManager; +import com.jme3.gde.core.scene.OffScenePanel; +import com.jme3.math.Vector3f; +import com.jme3.scene.Spatial; +import java.util.List; +import javax.swing.JPanel; +import org.openide.DialogDisplayer; +import org.openide.NotifyDescriptor; +import org.openide.WizardDescriptor; +import org.openide.util.Exceptions; + +@SuppressWarnings({"unchecked", "serial"}) +public final class ModelImporterVisualPanel3 extends JPanel { + + private ModelImporterWizardPanel3 panel; + private OffScenePanel offPanel; + private ProjectAssetManager manager; + private AssetData data; + private AssetKey mainKey; + private Spatial currentModel; + private List assets; + private List failed; + + /** + * Creates new form ModelImporterVisualPanel1 + */ + public ModelImporterVisualPanel3(ModelImporterWizardPanel3 panel) { + initComponents(); + this.panel = panel; + offPanel = new OffScenePanel(320, 320); + offPanel.startPreview(); + jPanel1.add(offPanel); + } + + @Override + public String getName() { + return "Preview Model"; + } + + public void loadSettings(WizardDescriptor wiz) { + manager = (ProjectAssetManager) wiz.getProperty("manager"); + mainKey = (AssetKey) wiz.getProperty("mainkey"); + data = (AssetData) wiz.getProperty("assetdata"); + loadModel(mainKey); + if (currentModel != null) { + offPanel.attach(currentModel); + } + } + + public void applySettings(WizardDescriptor wiz) { + wiz.putProperty("assetlist", assets); + wiz.putProperty("failedlist", failed); + wiz.putProperty("model", currentModel); + if (currentModel != null) { + offPanel.detach(currentModel); + } + } + + public boolean checkValid() { + return currentModel != null; + } + + public void cleanup() { + if (currentModel != null) { + offPanel.detach(currentModel); + } + offPanel.stopPreview(); + } + + public synchronized void loadModel(AssetKey modelKey) { + try { + currentModel = (Spatial) data.loadAsset(); + if (currentModel != null) { + assets = data.getAssetKeyList(); + failed = data.getFailedList(); + jList1.setListData(assets.toArray()); + jList2.setListData(failed.toArray()); + if (failed.size() > 0) { + statusLabel.setText("Model loaded, some assets could not be loaded."); + infoTextArea.setText("Check if the model looks as expected," + + " some textures fail to load, make sure they are in the same folder or a subfolder of the model." + + " Textures that can not be found will be replaced with a red material." + + "\nWith the buttons above you can move the camera."); + } else { + statusLabel.setText("Model loaded successfully."); + infoTextArea.setText("Check if the model looks as expected." + + "\nWith the buttons above you can move the camera."); + } + } else { + statusLabel.setText("Model cannot be loaded."); + infoTextArea.setText("This file can not be loaded, it is either in an unsupported format or is incompatible." + + "\n Check the bottom right corner of the SDK for a little warning sign. If it is there" + + " double-click it and report the contained stack trace at jmonkeyengine.org"); +// Message msg = new NotifyDescriptor.Message( +// "Cannot import this file!", +// NotifyDescriptor.ERROR_MESSAGE); +// DialogDisplayer.getDefault().notifyLater(msg); + } + } catch (Exception e) { + statusLabel.setText("Error importing file"); + NotifyDescriptor.Message msg = new NotifyDescriptor.Message( + "Error importing file!\n" + + "(" + e + ")", + NotifyDescriptor.ERROR_MESSAGE); + DialogDisplayer.getDefault().notifyLater(msg); + Exceptions.printStackTrace(e); + } + manager.clearCache(); + panel.fireChangeEvent(); + } + + /** + * 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() { + + jPanel1 = new javax.swing.JPanel(); + jToolBar1 = new javax.swing.JToolBar(); + jButton1 = new javax.swing.JButton(); + jButton2 = new javax.swing.JButton(); + jSeparator1 = new javax.swing.JToolBar.Separator(); + jButton3 = new javax.swing.JButton(); + jButton4 = new javax.swing.JButton(); + jPanel3 = new javax.swing.JPanel(); + jLabel2 = new javax.swing.JLabel(); + jScrollPane2 = new javax.swing.JScrollPane(); + jList1 = new javax.swing.JList(); + jScrollPane3 = new javax.swing.JScrollPane(); + jList2 = new javax.swing.JList(); + statusLabel = new javax.swing.JLabel(); + jLabel1 = new javax.swing.JLabel(); + jScrollPane1 = new javax.swing.JScrollPane(); + infoTextArea = new javax.swing.JTextArea(); + + jPanel1.setPreferredSize(new java.awt.Dimension(320, 320)); + jPanel1.setLayout(new javax.swing.BoxLayout(jPanel1, javax.swing.BoxLayout.LINE_AXIS)); + + jToolBar1.setFloatable(false); + jToolBar1.setRollover(true); + + org.openide.awt.Mnemonics.setLocalizedText(jButton1, org.openide.util.NbBundle.getMessage(ModelImporterVisualPanel3.class, "ModelImporterVisualPanel3.jButton1.text")); // NOI18N + jButton1.setFocusable(false); + jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + jButton1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + jButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton1ActionPerformed(evt); + } + }); + jToolBar1.add(jButton1); + + org.openide.awt.Mnemonics.setLocalizedText(jButton2, org.openide.util.NbBundle.getMessage(ModelImporterVisualPanel3.class, "ModelImporterVisualPanel3.jButton2.text")); // NOI18N + jButton2.setFocusable(false); + jButton2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + jButton2.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + jButton2.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton2ActionPerformed(evt); + } + }); + jToolBar1.add(jButton2); + jToolBar1.add(jSeparator1); + + org.openide.awt.Mnemonics.setLocalizedText(jButton3, org.openide.util.NbBundle.getMessage(ModelImporterVisualPanel3.class, "ModelImporterVisualPanel3.jButton3.text")); // NOI18N + jButton3.setFocusable(false); + jButton3.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + jButton3.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + jButton3.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton3ActionPerformed(evt); + } + }); + jToolBar1.add(jButton3); + + org.openide.awt.Mnemonics.setLocalizedText(jButton4, org.openide.util.NbBundle.getMessage(ModelImporterVisualPanel3.class, "ModelImporterVisualPanel3.jButton4.text")); // NOI18N + jButton4.setFocusable(false); + jButton4.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + jButton4.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + jButton4.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton4ActionPerformed(evt); + } + }); + jToolBar1.add(jButton4); + + javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); + jPanel3.setLayout(jPanel3Layout); + jPanel3Layout.setHorizontalGroup( + jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 220, Short.MAX_VALUE) + ); + jPanel3Layout.setVerticalGroup( + jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 18, Short.MAX_VALUE) + ); + + jToolBar1.add(jPanel3); + + org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(ModelImporterVisualPanel3.class, "ModelImporterVisualPanel3.jLabel2.text")); // NOI18N + + jList1.setModel(new javax.swing.AbstractListModel() { + String[] strings = { "No assets loaded" }; + public int getSize() { return strings.length; } + public Object getElementAt(int i) { return strings[i]; } + }); + jScrollPane2.setViewportView(jList1); + + jScrollPane3.setViewportView(jList2); + + statusLabel.setFont(new java.awt.Font("Lucida Grande", 1, 14)); // NOI18N + org.openide.awt.Mnemonics.setLocalizedText(statusLabel, org.openide.util.NbBundle.getMessage(ModelImporterVisualPanel3.class, "ModelImporterVisualPanel3.statusLabel.text")); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(ModelImporterVisualPanel3.class, "ModelImporterVisualPanel3.jLabel1.text_1")); // NOI18N + + infoTextArea.setColumns(20); + infoTextArea.setLineWrap(true); + infoTextArea.setRows(5); + infoTextArea.setText(org.openide.util.NbBundle.getMessage(ModelImporterVisualPanel3.class, "ModelImporterVisualPanel3.infoTextArea.text_1")); // NOI18N + infoTextArea.setWrapStyleWord(true); + jScrollPane1.setViewportView(infoTextArea); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 320, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jScrollPane2) + .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) + .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 168, Short.MAX_VALUE))) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jScrollPane1))) + .addContainerGap()) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap() + .addComponent(statusLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel2) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jScrollPane3)) + .addGroup(layout.createSequentialGroup() + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 320, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(statusLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 108, Short.MAX_VALUE) + .addContainerGap()) + ); + }// //GEN-END:initComponents + + private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed + offPanel.zoomCamera(-.1f); + }//GEN-LAST:event_jButton2ActionPerformed + + private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed + offPanel.zoomCamera(.1f); + }//GEN-LAST:event_jButton1ActionPerformed + + private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed + offPanel.rotateCamera(Vector3f.UNIT_Y, .1f); + }//GEN-LAST:event_jButton3ActionPerformed + + private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed + offPanel.rotateCamera(Vector3f.UNIT_Y, -.1f); + }//GEN-LAST:event_jButton4ActionPerformed + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JTextArea infoTextArea; + private javax.swing.JButton jButton1; + private javax.swing.JButton jButton2; + private javax.swing.JButton jButton3; + private javax.swing.JButton jButton4; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JList jList1; + private javax.swing.JList jList2; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel3; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JScrollPane jScrollPane2; + private javax.swing.JScrollPane jScrollPane3; + private javax.swing.JToolBar.Separator jSeparator1; + private javax.swing.JToolBar jToolBar1; + private javax.swing.JLabel statusLabel; + // End of variables declaration//GEN-END:variables +} diff --git a/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterVisualPanel2.form b/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterVisualPanel4.form similarity index 69% rename from sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterVisualPanel2.form rename to sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterVisualPanel4.form index 0c2c4b9d2..808ce756c 100644 --- a/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterVisualPanel2.form +++ b/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterVisualPanel4.form @@ -1,4 +1,4 @@ - +
@@ -18,15 +18,11 @@ - - - - - - - - + + + + @@ -37,11 +33,8 @@ - - - - - + + @@ -50,21 +43,21 @@ - + - + - + @@ -82,31 +75,12 @@ - + - - - - - - - - - - - - - - - - - - - diff --git a/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterVisualPanel2.java b/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterVisualPanel4.java similarity index 63% rename from sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterVisualPanel2.java rename to sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterVisualPanel4.java index fb0e72737..4db191308 100644 --- a/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterVisualPanel2.java +++ b/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterVisualPanel4.java @@ -4,26 +4,23 @@ */ package com.jme3.gde.modelimporter; -import com.jme3.asset.AssetKey; -import java.util.List; import javax.swing.JPanel; import org.openide.WizardDescriptor; -public final class ModelImporterVisualPanel2 extends JPanel { +public final class ModelImporterVisualPanel4 extends JPanel { /** Creates new form ModelImporterVisualPanel2 */ - public ModelImporterVisualPanel2() { + public ModelImporterVisualPanel4() { initComponents(); } @Override public String getName() { - return "Import Options"; + return "Project Destination"; } public void loadSettings(WizardDescriptor wiz) { jTextField1.setText((String)wiz.getProperty("destpath")); - jList1.setListData(((List)wiz.getProperty("assetlist")).toArray()); } public void applySettings(WizardDescriptor wiz) { @@ -44,43 +41,31 @@ public final class ModelImporterVisualPanel2 extends JPanel { jCheckBox1 = new javax.swing.JCheckBox(); jScrollPane1 = new javax.swing.JScrollPane(); jTextArea1 = new javax.swing.JTextArea(); - jScrollPane2 = new javax.swing.JScrollPane(); - jList1 = new javax.swing.JList(); - org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(ModelImporterVisualPanel2.class, "ModelImporterVisualPanel2.jLabel1.text")); // NOI18N + org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(ModelImporterVisualPanel4.class, "ModelImporterVisualPanel4.jLabel1.text")); // NOI18N - jTextField1.setText(org.openide.util.NbBundle.getMessage(ModelImporterVisualPanel2.class, "ModelImporterVisualPanel2.jTextField1.text")); // NOI18N + jTextField1.setText(org.openide.util.NbBundle.getMessage(ModelImporterVisualPanel4.class, "ModelImporterVisualPanel4.jTextField1.text")); // NOI18N - org.openide.awt.Mnemonics.setLocalizedText(jCheckBox1, org.openide.util.NbBundle.getMessage(ModelImporterVisualPanel2.class, "ModelImporterVisualPanel2.jCheckBox1.text")); // NOI18N + org.openide.awt.Mnemonics.setLocalizedText(jCheckBox1, org.openide.util.NbBundle.getMessage(ModelImporterVisualPanel4.class, "ModelImporterVisualPanel4.jCheckBox1.text")); // NOI18N jTextArea1.setColumns(20); jTextArea1.setEditable(false); jTextArea1.setLineWrap(true); jTextArea1.setRows(5); - jTextArea1.setText(org.openide.util.NbBundle.getMessage(ModelImporterVisualPanel2.class, "ModelImporterVisualPanel2.jTextArea1.text")); // NOI18N + jTextArea1.setText(org.openide.util.NbBundle.getMessage(ModelImporterVisualPanel4.class, "ModelImporterVisualPanel4.jTextArea1.text")); // NOI18N jTextArea1.setWrapStyleWord(true); jScrollPane1.setViewportView(jTextArea1); - jList1.setModel(new javax.swing.AbstractListModel() { - String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" }; - public int getSize() { return strings.length; } - public Object getElementAt(int i) { return strings[i]; } - }); - jScrollPane2.setViewportView(jList1); - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jLabel1) - .addContainerGap(323, Short.MAX_VALUE)) - .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 418, Short.MAX_VALUE) - .addComponent(jCheckBox1, javax.swing.GroupLayout.DEFAULT_SIZE, 418, Short.MAX_VALUE) - .addGroup(layout.createSequentialGroup() - .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 196, Short.MAX_VALUE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 212, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(303, Short.MAX_VALUE)) + .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 398, Short.MAX_VALUE) + .addComponent(jCheckBox1, javax.swing.GroupLayout.DEFAULT_SIZE, 398, Short.MAX_VALUE) + .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -90,18 +75,14 @@ public final class ModelImporterVisualPanel2 extends JPanel { .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jCheckBox1) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 204, Short.MAX_VALUE) - .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 204, Short.MAX_VALUE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 192, Short.MAX_VALUE)) ); }// //GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JCheckBox jCheckBox1; private javax.swing.JLabel jLabel1; - private javax.swing.JList jList1; private javax.swing.JScrollPane jScrollPane1; - private javax.swing.JScrollPane jScrollPane2; private javax.swing.JTextArea jTextArea1; private javax.swing.JTextField jTextField1; // End of variables declaration//GEN-END:variables diff --git a/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterWizardPanel1.java b/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterWizardPanel1.java index 83c259238..eb4c382be 100644 --- a/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterWizardPanel1.java +++ b/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterWizardPanel1.java @@ -5,6 +5,10 @@ package com.jme3.gde.modelimporter; 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; @@ -23,7 +27,7 @@ public class ModelImporterWizardPanel1 implements WizardDescriptor.Panel { // create only those which really need to be visible. public Component getComponent() { if (component == null) { - component = new ModelImporterVisualPanel1(); + component = new ModelImporterVisualPanel1(this); } return component; } @@ -37,55 +41,43 @@ public class ModelImporterWizardPanel1 implements WizardDescriptor.Panel { public boolean isValid() { // If it is always OK to press Next or Finish, then: - return true; - // If it depends on some condition (form filled out...), then: - // return someCondition(); - // and when this condition changes (last form field filled in...) then: - // fireChangeEvent(); - // and uncomment the complicated stuff below. + return component.checkValid(); } + + 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); + } } - /* - 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() { - Iterator it; - synchronized (listeners) { - it = new HashSet(listeners).iterator(); - } - ChangeEvent ev = new ChangeEvent(this); - while (it.hasNext()) { - it.next().stateChanged(ev); - } + Iterator it; + synchronized (listeners) { + it = new HashSet(listeners).iterator(); + } + ChangeEvent ev = new ChangeEvent(this); + while (it.hasNext()) { + it.next().stateChanged(ev); + } } - */ // You can use a settings object to keep track of state. Normally the // settings object will be the WizardDescriptor, so you can use // WizardDescriptor.getProperty & putProperty to store information entered // by the user. public void readSettings(Object settings) { - component.loadSettings((WizardDescriptor)settings); + component.loadSettings((WizardDescriptor) settings); } public void storeSettings(Object settings) { - component.applySettings((WizardDescriptor)settings); - } - public void cleanup(){ - component.cleanup(); + component.applySettings((WizardDescriptor) settings); } } diff --git a/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterWizardPanel3.java b/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterWizardPanel3.java new file mode 100644 index 000000000..a3f73affe --- /dev/null +++ b/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterWizardPanel3.java @@ -0,0 +1,91 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.jme3.gde.modelimporter; + +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; + +public class ModelImporterWizardPanel3 implements WizardDescriptor.Panel { + + /** + * The visual component that displays this panel. If you need to access the + * component from this class, just use getComponent(). + */ + private ModelImporterVisualPanel3 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 + // but never displayed, or not all panels are displayed, it is better to + // create only those which really need to be visible. + public Component getComponent() { + if (component == null) { + component = new ModelImporterVisualPanel3(this); + } + return component; + } + + public HelpCtx getHelp() { + // Show no Help button for this panel: + return new HelpCtx("sdk.model_loader_and_viewer"); + // If you have context help: + // return new HelpCtx(SampleWizardPanel1.class); + } + + public boolean isValid() { + // If it is always OK to press Next or Finish, then: + return component.checkValid(); + // If it depends on some condition (form filled out...), then: + // return someCondition(); + // and when this condition changes (last form field filled in...) then: + // fireChangeEvent(); + // and uncomment the complicated stuff below. + } + 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() { + Iterator it; + synchronized (listeners) { + it = new HashSet(listeners).iterator(); + } + ChangeEvent ev = new ChangeEvent(this); + while (it.hasNext()) { + it.next().stateChanged(ev); + } + } + + // You can use a settings object to keep track of state. Normally the + // settings object will be the WizardDescriptor, so you can use + // WizardDescriptor.getProperty & putProperty to store information entered + // by the user. + public void readSettings(Object settings) { + component.loadSettings((WizardDescriptor) settings); + } + + public void storeSettings(Object settings) { + component.applySettings((WizardDescriptor) settings); + } + + public void cleanup() { + component.cleanup(); + } +} diff --git a/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterWizardPanel2.java b/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterWizardPanel4.java similarity index 94% rename from sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterWizardPanel2.java rename to sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterWizardPanel4.java index b31e0ff40..49fba54dd 100644 --- a/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterWizardPanel2.java +++ b/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterWizardPanel4.java @@ -9,13 +9,13 @@ import javax.swing.event.ChangeListener; import org.openide.WizardDescriptor; import org.openide.util.HelpCtx; -public class ModelImporterWizardPanel2 implements WizardDescriptor.Panel { +public class ModelImporterWizardPanel4 implements WizardDescriptor.Panel { /** * The visual component that displays this panel. If you need to access the * component from this class, just use getComponent(). */ - private ModelImporterVisualPanel2 component; + private ModelImporterVisualPanel4 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 @@ -23,7 +23,7 @@ public class ModelImporterWizardPanel2 implements WizardDescriptor.Panel { // create only those which really need to be visible. public Component getComponent() { if (component == null) { - component = new ModelImporterVisualPanel2(); + component = new ModelImporterVisualPanel4(); } return component; }