git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7808 75d07b2b-3a1a-0410-a2c5-0572b91ccdca3.0
parent
324750e4aa
commit
a4f1eb8b2c
@ -1 +1,2 @@ |
||||
CTL_PreviewAssetPackItem=Preview |
||||
ProjectSelection.jButton1.text=Select Project |
||||
|
@ -0,0 +1,69 @@ |
||||
<?xml version="1.1" 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/assetpack/actions/Bundle.properties" key="ProjectSelection.jButton1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> |
||||
</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,135 @@ |
||||
/* |
||||
* 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.assetpack.actions; |
||||
|
||||
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() { |
||||
return projects.get(selected); |
||||
} |
||||
|
||||
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
|
||||
} |
Loading…
Reference in new issue