Skip to content

Commit

Permalink
Merge pull request #400 from neph1/324_Type_could_be_drop_down_menu
Browse files Browse the repository at this point in the history
#324 - changes VarType to JComboBox with hardcoded values for Shader Node wizard
  • Loading branch information
neph1 authored Sep 3, 2023
2 parents f45c7f7 + ab3972d commit e520e4c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -40,9 +42,11 @@

@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
Expand All @@ -51,7 +55,10 @@ public SNDefVisualPanel2(String type) {
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
Expand Down Expand Up @@ -107,7 +114,9 @@ public void run() {
// Edit.
if (varTable.isCellEditable(row, col)) {
varTable.editCellAt(row, col);
((JTextField) varTable.getEditorComponent()).selectAll();
if(col != 0) {
((JTextField) varTable.getEditorComponent()).selectAll();
}
varTable.getEditorComponent().requestFocusInWindow();
}
}
Expand Down Expand Up @@ -149,7 +158,6 @@ public Class getColumnClass(int columnIndex) {
});
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
Expand Down

0 comments on commit e520e4c

Please sign in to comment.