Browse Source

Merge pull request #400 from neph1/324_Type_could_be_drop_down_menu

#324 - changes VarType to JComboBox with hardcoded values for Shader Node wizard
Rickard Edén 1 year ago
parent
commit
e520e4cb6f

+ 1 - 1
jme3-materialeditor/src/com/jme3/gde/materials/multiview/MaterialEditorTopComponent.java

@@ -69,7 +69,7 @@ public final class MaterialEditorTopComponent extends CloneableTopComponent impl
     private final SaveCookie saveCookie = new SaveCookieImpl();
     private boolean saveImmediate = true;
     private boolean updateProperties = false;
-    private final List<MaterialChangeListener> materialListeners = new ArrayList<MaterialChangeListener>();
+    private final List<MaterialChangeListener> materialListeners = new ArrayList<>();
 
     public MaterialEditorTopComponent() {
     }

+ 3 - 1
jme3-materialeditor/src/com/jme3/gde/shadernodedefinition/wizard/SNDefVisualPanel2.form

@@ -51,12 +51,14 @@
               </Table>
             </Property>
           </Properties>
+          <AuxValues>
+            <AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="SNDefVisualPanel2_varTable"/>
+          </AuxValues>
         </Component>
       </SubComponents>
     </Container>
     <Container class="javax.swing.JToolBar" name="jToolBar1">
       <Properties>
-        <Property name="floatable" type="boolean" value="false"/>
         <Property name="rollover" type="boolean" value="true"/>
       </Properties>
 

+ 13 - 5
jme3-materialeditor/src/com/jme3/gde/shadernodedefinition/wizard/SNDefVisualPanel2.java

@@ -32,6 +32,8 @@
 package com.jme3.gde.shadernodedefinition.wizard;
 
 import java.awt.EventQueue;
+import javax.swing.DefaultCellEditor;
+import javax.swing.JComboBox;
 import javax.swing.JPanel;
 import javax.swing.JTextField;
 import javax.swing.event.ListSelectionEvent;
@@ -40,9 +42,11 @@ import javax.swing.table.DefaultTableModel;
 
 @SuppressWarnings({"unchecked", "rawtypes"})
 public final class SNDefVisualPanel2 extends JPanel {
-
-    private final Object[] emptyObj = {"", "", ""};
+    
+    private final Object[] emptyObj = {"float", "", ""};
     private final String type;
+    private final String[] varTypes = new String[]{"bool", "int", "float", "vec2", 
+        "vec3", "vec4", "sampler", "sampler2D", "sampler3D", "mat3", "mat4"};
 
     /**
      * Creates new form SNDefVisualPanel2
@@ -51,7 +55,10 @@ public final class SNDefVisualPanel2 extends JPanel {
         initComponents();
         this.type = type;
         titleLabel.setText(type);
-        varTable.getColumnModel().getSelectionModel().addListSelectionListener(new ExploreSelectionListener());
+        varTable.getColumnModel().getSelectionModel().addListSelectionListener(
+                new ExploreSelectionListener());
+        varTable.getColumn("Type").setCellEditor(new DefaultCellEditor(
+                new JComboBox(varTypes)));
     }
 
     @Override
@@ -107,7 +114,9 @@ public final class SNDefVisualPanel2 extends JPanel {
                 // Edit.
                 if (varTable.isCellEditable(row, col)) {
                     varTable.editCellAt(row, col);
-                    ((JTextField) varTable.getEditorComponent()).selectAll();
+                    if(col != 0) {
+                        ((JTextField) varTable.getEditorComponent()).selectAll();
+                    }
                     varTable.getEditorComponent().requestFocusInWindow();
                 }
             }
@@ -149,7 +158,6 @@ public final class SNDefVisualPanel2 extends JPanel {
         });
         jScrollPane1.setViewportView(varTable);
 
-        jToolBar1.setFloatable(false);
         jToolBar1.setRollover(true);
 
         org.openide.awt.Mnemonics.setLocalizedText(titleLabel, org.openide.util.NbBundle.getMessage(SNDefVisualPanel2.class, "SNDefVisualPanel2.titleLabel.text")); // NOI18N