- make Model Import Tool work without selecting a project explicitly

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9811 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
nor..67 12 years ago
parent 48bfbf0a65
commit a49c4068de
  1. 2
      sdk/jme3-assetpack-support/nbproject/genfiles.properties
  2. 4
      sdk/jme3-assetpack-support/nbproject/project.xml
  3. 2
      sdk/jme3-assetpack-support/src/com/jme3/gde/assetpack/actions/ProjectSelection.form
  4. 6
      sdk/jme3-assetpack-support/src/com/jme3/gde/assetpack/actions/ProjectSelection.java
  5. 8
      sdk/jme3-model-importer/nbproject/genfiles.properties
  6. 17
      sdk/jme3-model-importer/nbproject/project.xml
  7. 3
      sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/Bundle.properties
  8. 35
      sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ImportModel.java
  9. 69
      sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ProjectSelection.form
  10. 142
      sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ProjectSelection.java
  11. 4
      sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/layer.xml

@ -3,6 +3,6 @@ build.xml.script.CRC32=c0969383
build.xml.stylesheet.CRC32=a56c6a5b@1.42.2 build.xml.stylesheet.CRC32=a56c6a5b@1.42.2
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=9f2b8f14 nbproject/build-impl.xml.data.CRC32=b5dd9827
nbproject/build-impl.xml.script.CRC32=4d376df0 nbproject/build-impl.xml.script.CRC32=4d376df0
nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.50.1 nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.50.1

@ -185,7 +185,9 @@
</run-dependency> </run-dependency>
</dependency> </dependency>
</module-dependencies> </module-dependencies>
<public-packages/> <public-packages>
<package>com.jme3.gde.assetpack.project</package>
</public-packages>
</data> </data>
</configuration> </configuration>
</project> </project>

@ -1,4 +1,4 @@
<?xml version="1.1" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> <Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Properties> <Properties>

@ -44,8 +44,14 @@ public class ProjectSelection extends javax.swing.JDialog {
} }
public Project getSelected() { public Project getSelected() {
if (selected < 0) {
return null;
}
if (projects.size() > selected) {
return projects.get(selected); return projects.get(selected);
} }
return null;
}
public static Project showProjectSelection() { public static Project showProjectSelection() {
List<Project> validProjects = new ArrayList<Project>(); List<Project> validProjects = new ArrayList<Project>();

@ -1,8 +1,8 @@
build.xml.data.CRC32=2db6ec0e build.xml.data.CRC32=ae2392d0
build.xml.script.CRC32=b6310686 build.xml.script.CRC32=b6310686
build.xml.stylesheet.CRC32=a56c6a5b@2.49.1 build.xml.stylesheet.CRC32=a56c6a5b@2.50.1
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=2db6ec0e nbproject/build-impl.xml.data.CRC32=ae2392d0
nbproject/build-impl.xml.script.CRC32=4db64ed5 nbproject/build-impl.xml.script.CRC32=4db64ed5
nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.49.1 nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.50.1

@ -6,6 +6,14 @@
<code-name-base>com.jme3.gde.modelimporter</code-name-base> <code-name-base>com.jme3.gde.modelimporter</code-name-base>
<suite-component/> <suite-component/>
<module-dependencies> <module-dependencies>
<dependency>
<code-name-base>com.jme3.gde.assetpack</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>3.0</specification-version>
</run-dependency>
</dependency>
<dependency> <dependency>
<code-name-base>com.jme3.gde.core</code-name-base> <code-name-base>com.jme3.gde.core</code-name-base>
<build-prerequisite/> <build-prerequisite/>
@ -42,6 +50,15 @@
<specification-version>1.30</specification-version> <specification-version>1.30</specification-version>
</run-dependency> </run-dependency>
</dependency> </dependency>
<dependency>
<code-name-base>org.netbeans.modules.projectuiapi</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<release-version>1</release-version>
<specification-version>1.57.1.8</specification-version>
</run-dependency>
</dependency>
<dependency> <dependency>
<code-name-base>org.openide.awt</code-name-base> <code-name-base>org.openide.awt</code-name-base>
<build-prerequisite/> <build-prerequisite/>

@ -1,4 +1,5 @@
CTL_ImportModel=Import Model (Select Project) CTL_ImportModel=Import Model
ProjectSelection.jButton1.text=Select Project
OpenIDE-Module-Display-Category=jMonkeyEngine OpenIDE-Module-Display-Category=jMonkeyEngine
OpenIDE-Module-Long-Description=\ OpenIDE-Module-Long-Description=\
This plugin allows importing models to a project using a Wizard. This plugin allows importing models to a project using a Wizard.

@ -14,7 +14,6 @@ import java.awt.Component;
import java.awt.Dialog; import java.awt.Dialog;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.Iterator; import java.util.Iterator;
@ -24,29 +23,59 @@ import javax.swing.JComponent;
import org.netbeans.api.progress.ProgressHandle; import org.netbeans.api.progress.ProgressHandle;
import org.netbeans.api.progress.ProgressHandleFactory; import org.netbeans.api.progress.ProgressHandleFactory;
import org.netbeans.api.project.Project; import org.netbeans.api.project.Project;
import org.netbeans.api.project.ProjectInformation;
import org.netbeans.api.project.ui.OpenProjects;
import org.openide.DialogDisplayer; import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor; import org.openide.NotifyDescriptor;
import org.openide.WizardDescriptor; import org.openide.WizardDescriptor;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
import org.openide.awt.ActionReferences;
import org.openide.awt.ActionRegistration;
import org.openide.filesystems.FileObject; import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil; import org.openide.filesystems.FileUtil;
import org.openide.loaders.DataObject; import org.openide.loaders.DataObject;
import org.openide.util.Exceptions; import org.openide.util.Exceptions;
import org.openide.util.NbBundle;
@ActionID(
category = "File",
id = "com.jme3.gde.modelimporter.ImportModel")
@ActionRegistration(
iconBase = "com/jme3/gde/modelimporter/103_.png",
displayName = "#CTL_ImportModel")
@ActionReferences({
@ActionReference(path = "Menu/File", position = 1413),
@ActionReference(path = "Toolbars/File", position = 310)
})
@NbBundle.Messages("CTL_SomeAction=test")
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public final class ImportModel implements ActionListener { public final class ImportModel implements ActionListener {
private final Project context; private Project context;
private WizardDescriptor.Panel[] panels; private WizardDescriptor.Panel[] panels;
public ImportModel() {
}
public ImportModel(Project context) { public ImportModel(Project context) {
this.context = context; this.context = context;
} }
public void actionPerformed(ActionEvent ev) { public void actionPerformed(ActionEvent ev) {
if (context == null) {
this.context = OpenProjects.getDefault().getMainProject();
if (context == null) {
context = ProjectSelection.showProjectSelection();
}
if (context == null) {
return;
}
}
final WizardDescriptor wiz = new WizardDescriptor(getPanels()); final WizardDescriptor wiz = new WizardDescriptor(getPanels());
// {0} will be replaced by WizardDesriptor.Panel.getComponent().getName() // {0} will be replaced by WizardDesriptor.Panel.getComponent().getName()
wiz.setTitleFormat(new MessageFormat("{0}")); wiz.setTitleFormat(new MessageFormat("{0}"));
wiz.setTitle("Import Model to Project"); wiz.setTitle("Import Model to Project " + context.getLookup().lookup(ProjectInformation.class).getDisplayName());
wiz.putProperty("project", context); wiz.putProperty("project", context);
Dialog dialog = DialogDisplayer.getDefault().createDialog(wiz); Dialog dialog = DialogDisplayer.getDefault().createDialog(wiz);
dialog.setVisible(true); dialog.setVisible(true);

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="2"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jComboBox1" alignment="0" pref="227" max="32767" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jComboBox1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JComboBox" name="jComboBox1">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="4">
<StringItem index="0" value="Item 1"/>
<StringItem index="1" value="Item 2"/>
<StringItem index="2" value="Item 3"/>
<StringItem index="3" value="Item 4"/>
</StringArray>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jComboBox1ActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="jButton1">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="com/jme3/gde/modelimporter/Bundle.properties" key="ProjectSelection.jButton1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>

@ -0,0 +1,142 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* ProjectSelection.java
*
* Created on 02.07.2011, 15:08:08
*/
package com.jme3.gde.modelimporter;
import com.jme3.gde.assetpack.project.AssetPackProject;
import com.jme3.gde.core.assets.ProjectAssetManager;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.swing.JFrame;
import org.netbeans.api.project.Project;
import org.netbeans.api.project.ProjectInformation;
import org.netbeans.api.project.ui.OpenProjects;
/**
*
* @author normenhansen
*/
public class ProjectSelection extends javax.swing.JDialog {
private List<Project> projects;
private int selected = 0;
/**
* Creates new form ProjectSelection
*/
public ProjectSelection(List<Project> projects) {
super(new JFrame(), true);
initComponents();
setLocationRelativeTo(null);
this.projects = projects;
jComboBox1.removeAllItems();
for (Iterator<Project> it = projects.iterator(); it.hasNext();) {
Project project = it.next();
ProjectInformation info = project.getLookup().lookup(ProjectInformation.class);
jComboBox1.addItem(info.getName());
}
}
public Project getSelected() {
if (selected < 0) {
return null;
}
if (projects.size() > selected) {
return projects.get(selected);
}
return null;
}
public static Project showProjectSelection() {
List<Project> validProjects = new ArrayList<Project>();
Project[] projects = OpenProjects.getDefault().getOpenProjects();
for (Project project : projects) {
if (!(project instanceof AssetPackProject) && project.getLookup().lookup(ProjectAssetManager.class) != null) {
validProjects.add(project);
}
}
if (validProjects.size() == 1) {
return validProjects.get(0);
}
ProjectSelection sel = new ProjectSelection(validProjects);
sel.setVisible(true);
return sel.getSelected();
}
public static ProjectAssetManager getProjectAssetManager() {
Project proj = showProjectSelection();
if (proj == null) {
return null;
} else {
return proj.getLookup().lookup(ProjectAssetManager.class);
}
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jComboBox1 = new javax.swing.JComboBox();
jButton1 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
jComboBox1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jComboBox1ActionPerformed(evt);
}
});
jButton1.setText(org.openide.util.NbBundle.getMessage(ProjectSelection.class, "ProjectSelection.jButton1.text")); // NOI18N
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jComboBox1, 0, 227, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(jButton1))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton1))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
selected = jComboBox1.getSelectedIndex();
}//GEN-LAST:event_jComboBox1ActionPerformed
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
setVisible(false);
}//GEN-LAST:event_jButton1ActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JComboBox jComboBox1;
// End of variables declaration//GEN-END:variables
}

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd"> <!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
<filesystem> <filesystem>
<folder name="Actions"> <!--folder name="Actions">
<folder name="Import"> <folder name="Import">
<file name="com-jme3-gde-modelimporter-ImportModel.instance"> <file name="com-jme3-gde-modelimporter-ImportModel.instance">
<attr name="delegate" methodvalue="org.openide.awt.Actions.inject"/> <attr name="delegate" methodvalue="org.openide.awt.Actions.inject"/>
@ -30,5 +30,5 @@
<attr name="originalFile" stringvalue="Actions/Import/com-jme3-gde-modelimporter-ImportModel.instance"/> <attr name="originalFile" stringvalue="Actions/Import/com-jme3-gde-modelimporter-ImportModel.instance"/>
</file> </file>
</folder> </folder>
</folder> </folder-->
</filesystem> </filesystem>

Loading…
Cancel
Save