Skip to content

Commit e520e4c

Browse files
authored
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
2 parents f45c7f7 + ab3972d commit e520e4c

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public final class MaterialEditorTopComponent extends CloneableTopComponent impl
6969
private final SaveCookie saveCookie = new SaveCookieImpl();
7070
private boolean saveImmediate = true;
7171
private boolean updateProperties = false;
72-
private final List<MaterialChangeListener> materialListeners = new ArrayList<MaterialChangeListener>();
72+
private final List<MaterialChangeListener> materialListeners = new ArrayList<>();
7373

7474
public MaterialEditorTopComponent() {
7575
}

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,14 @@
5151
</Table>
5252
</Property>
5353
</Properties>
54+
<AuxValues>
55+
<AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="SNDefVisualPanel2_varTable"/>
56+
</AuxValues>
5457
</Component>
5558
</SubComponents>
5659
</Container>
5760
<Container class="javax.swing.JToolBar" name="jToolBar1">
5861
<Properties>
59-
<Property name="floatable" type="boolean" value="false"/>
6062
<Property name="rollover" type="boolean" value="true"/>
6163
</Properties>
6264

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

+13-5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
package com.jme3.gde.shadernodedefinition.wizard;
3333

3434
import java.awt.EventQueue;
35+
import javax.swing.DefaultCellEditor;
36+
import javax.swing.JComboBox;
3537
import javax.swing.JPanel;
3638
import javax.swing.JTextField;
3739
import javax.swing.event.ListSelectionEvent;
@@ -40,9 +42,11 @@
4042

4143
@SuppressWarnings({"unchecked", "rawtypes"})
4244
public final class SNDefVisualPanel2 extends JPanel {
43-
44-
private final Object[] emptyObj = {"", "", ""};
45+
46+
private final Object[] emptyObj = {"float", "", ""};
4547
private final String type;
48+
private final String[] varTypes = new String[]{"bool", "int", "float", "vec2",
49+
"vec3", "vec4", "sampler", "sampler2D", "sampler3D", "mat3", "mat4"};
4650

4751
/**
4852
* Creates new form SNDefVisualPanel2
@@ -51,7 +55,10 @@ public SNDefVisualPanel2(String type) {
5155
initComponents();
5256
this.type = type;
5357
titleLabel.setText(type);
54-
varTable.getColumnModel().getSelectionModel().addListSelectionListener(new ExploreSelectionListener());
58+
varTable.getColumnModel().getSelectionModel().addListSelectionListener(
59+
new ExploreSelectionListener());
60+
varTable.getColumn("Type").setCellEditor(new DefaultCellEditor(
61+
new JComboBox(varTypes)));
5562
}
5663

5764
@Override
@@ -107,7 +114,9 @@ public void run() {
107114
// Edit.
108115
if (varTable.isCellEditable(row, col)) {
109116
varTable.editCellAt(row, col);
110-
((JTextField) varTable.getEditorComponent()).selectAll();
117+
if(col != 0) {
118+
((JTextField) varTable.getEditorComponent()).selectAll();
119+
}
111120
varTable.getEditorComponent().requestFocusInWindow();
112121
}
113122
}
@@ -149,7 +158,6 @@ public Class getColumnClass(int columnIndex) {
149158
});
150159
jScrollPane1.setViewportView(varTable);
151160

152-
jToolBar1.setFloatable(false);
153161
jToolBar1.setRollover(true);
154162

155163
org.openide.awt.Mnemonics.setLocalizedText(titleLabel, org.openide.util.NbBundle.getMessage(SNDefVisualPanel2.class, "SNDefVisualPanel2.titleLabel.text")); // NOI18N

0 commit comments

Comments
 (0)