3131 */
3232package com .jme3 .gde .templates .gradledesktop ;
3333
34- import com .jme3 .gde .templates .gradledesktop .options .GUILibrary ;
35- import com .jme3 .gde .templates .gradledesktop .options .NetworkingLibrary ;
36- import com .jme3 .gde .templates .gradledesktop .options .PhysicsLibrary ;
34+ import com .jme3 .gde .templates .gradledesktop .options .CachedOptionsContainer ;
35+ import com .jme3 .gde .templates .gradledesktop .options .TemplateLibrary ;
3736import java .awt .event .ActionEvent ;
3837import java .awt .event .ActionListener ;
3938import javax .swing .DefaultComboBoxModel ;
5049import org .openide .util .NbBundle ;
5150
5251/**
53- * UI Compoment for the New Gradle Game Wizard GUI panel.
52+ * UI Component for the New Gradle Game Wizard GUI panel.
5453 *
5554 * @author peedeeboy
5655 */
5756public class GradleDesktopGameGuiPanelVisual extends JPanel {
5857
59- private final GradleDesktopGameGuiPanel panel ;
60-
6158 /**
6259 * Creates new form GradleDesktopGameGuiPanelVisual
6360 */
6461 public GradleDesktopGameGuiPanelVisual (GradleDesktopGameGuiPanel panel ) {
6562 initComponents ();
63+
6664 updateGuiLibraryDescription ();
6765 updatePhysicsLibraryDescription ();
6866 updateNetworkingLibraryDescription ();
69-
70- this .panel = panel ;
7167 }
7268
7369 private void updateGuiLibraryDescription () {
74- GUILibrary selectedGuiLibrary = ( GUILibrary ) guiComboBox .getSelectedItem ( );
70+ TemplateLibrary selectedGuiLibrary = guiComboBox . getItemAt ( guiComboBox .getSelectedIndex () );
7571 guiDescriptionTextArea .setText (selectedGuiLibrary .getDescription ());
7672 }
7773
7874 private void updatePhysicsLibraryDescription () {
79- PhysicsLibrary selectedPhysicsLibrary = ( PhysicsLibrary ) physicsEngineComboBox .getSelectedItem ( );
75+ TemplateLibrary selectedPhysicsLibrary = physicsEngineComboBox . getItemAt ( physicsEngineComboBox .getSelectedIndex () );
8076 physicsEngineDescriptionTextArea .setText (selectedPhysicsLibrary .getDescription ());
8177 }
8278
8379 private void updateNetworkingLibraryDescription () {
84- NetworkingLibrary selectedNetworkingLibrary = ( NetworkingLibrary ) networkingComboBox .getSelectedItem ( );
80+ TemplateLibrary selectedNetworkingLibrary = networkingComboBox . getItemAt ( networkingComboBox .getSelectedIndex () );
8581 networkingDescriptionTextArea .setText (selectedNetworkingLibrary .getDescription ());
8682 }
8783
8884 protected void store (WizardDescriptor d ) {
89- GUILibrary selectedGuiLibrary = ( GUILibrary ) guiComboBox .getSelectedItem ( );
90- PhysicsLibrary selectedPhysicsLibrary = ( PhysicsLibrary ) physicsEngineComboBox .getSelectedItem ( );
91- NetworkingLibrary selectedNetworkingLibrary = ( NetworkingLibrary ) networkingComboBox .getSelectedItem ( );
85+ TemplateLibrary selectedGuiLibrary = guiComboBox . getItemAt ( guiComboBox .getSelectedIndex () );
86+ TemplateLibrary selectedPhysicsLibrary = physicsEngineComboBox . getItemAt ( physicsEngineComboBox .getSelectedIndex () );
87+ TemplateLibrary selectedNetworkingLibrary = networkingComboBox . getItemAt ( networkingComboBox .getSelectedIndex () );
9288
9389 d .putProperty ("guiLibrary" , selectedGuiLibrary );
9490 d .putProperty ("physicsLibrary" , selectedPhysicsLibrary );
@@ -122,7 +118,7 @@ private void initComponents() {
122118 guiLabel .setLabelFor (guiComboBox );
123119 Mnemonics .setLocalizedText (guiLabel , NbBundle .getMessage (GradleDesktopGameGuiPanelVisual .class , "GradleDesktopGameGuiPanelVisual.guiLabel.text" )); // NOI18N
124120
125- guiComboBox .setModel (new DefaultComboBoxModel ( GUILibrary . values ( )));
121+ guiComboBox .setModel (new DefaultComboBoxModel < TemplateLibrary >( CachedOptionsContainer . getInstance (). getGuiLibraries (). toArray ( TemplateLibrary []:: new )));
126122 guiComboBox .addActionListener (new ActionListener () {
127123 public void actionPerformed (ActionEvent evt ) {
128124 guiComboBoxActionPerformed (evt );
@@ -139,7 +135,7 @@ public void actionPerformed(ActionEvent evt) {
139135 physicsEngineLabel .setLabelFor (physicsEngineComboBox );
140136 Mnemonics .setLocalizedText (physicsEngineLabel , NbBundle .getMessage (GradleDesktopGameGuiPanelVisual .class , "GradleDesktopGameGuiPanelVisual.physicsEngineLabel.text" )); // NOI18N
141137
142- physicsEngineComboBox .setModel (new DefaultComboBoxModel ( PhysicsLibrary . values ( )));
138+ physicsEngineComboBox .setModel (new DefaultComboBoxModel < TemplateLibrary >( CachedOptionsContainer . getInstance (). getPhysicsLibraries (). toArray ( TemplateLibrary []:: new )));
143139 physicsEngineComboBox .addActionListener (new ActionListener () {
144140 public void actionPerformed (ActionEvent evt ) {
145141 physicsEngineComboBoxActionPerformed (evt );
@@ -156,7 +152,7 @@ public void actionPerformed(ActionEvent evt) {
156152 networkingLabel .setLabelFor (networkingComboBox );
157153 Mnemonics .setLocalizedText (networkingLabel , NbBundle .getMessage (GradleDesktopGameGuiPanelVisual .class , "GradleDesktopGameGuiPanelVisual.networkingLabel.text" )); // NOI18N
158154
159- networkingComboBox .setModel (new DefaultComboBoxModel ( NetworkingLibrary . values ( )));
155+ networkingComboBox .setModel (new DefaultComboBoxModel < TemplateLibrary >( CachedOptionsContainer . getInstance (). getNetworkingLibraries (). toArray ( TemplateLibrary []:: new )));
160156 networkingComboBox .addActionListener (new ActionListener () {
161157 public void actionPerformed (ActionEvent evt ) {
162158 networkingComboBoxActionPerformed (evt );
@@ -239,17 +235,17 @@ private void networkingComboBoxActionPerformed(ActionEvent evt) {//GEN-FIRST:eve
239235
240236
241237 // Variables declaration - do not modify//GEN-BEGIN:variables
242- private JComboBox <String > guiComboBox ;
238+ private JComboBox <TemplateLibrary > guiComboBox ;
243239 private JScrollPane guiDescriptionScrollPane ;
244240 private JTextArea guiDescriptionTextArea ;
245241 private JLabel guiLabel ;
246242 private JSeparator jSeparator1 ;
247243 private JSeparator jSeparator2 ;
248- private JComboBox <String > networkingComboBox ;
244+ private JComboBox <TemplateLibrary > networkingComboBox ;
249245 private JScrollPane networkingDescriptionScrollPane ;
250246 private JTextArea networkingDescriptionTextArea ;
251247 private JLabel networkingLabel ;
252- private JComboBox <String > physicsEngineComboBox ;
248+ private JComboBox <TemplateLibrary > physicsEngineComboBox ;
253249 private JScrollPane physicsEngineDescriptionScrollPane ;
254250 private JTextArea physicsEngineDescriptionTextArea ;
255251 private JLabel physicsEngineLabel ;
0 commit comments