Skip to content

Commit a805bd7

Browse files
committed
Use TreeSet and clean up
1 parent 6b6400d commit a805bd7

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

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

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@
2323
import java.io.File;
2424
import java.io.IOException;
2525
import java.util.ArrayList;
26-
import java.util.Collections;
26+
import java.util.Arrays;
2727
import java.util.LinkedHashMap;
2828
import java.util.LinkedList;
2929
import java.util.List;
3030
import java.util.Map;
3131
import java.util.Map.Entry;
32+
import java.util.Set;
33+
import java.util.TreeSet;
3234
import java.util.logging.Logger;
3335
import java.util.stream.Collectors;
3436
import javax.swing.event.DocumentEvent;
@@ -44,7 +46,6 @@
4446
import org.openide.loaders.DataObject;
4547
import org.openide.nodes.Node;
4648
import org.openide.util.HelpCtx;
47-
import org.openide.util.lookup.InstanceContent;
4849
import org.openide.windows.CloneableTopComponent;
4950

5051
/**
@@ -57,7 +58,6 @@ public final class MaterialEditorTopComponent extends CloneableTopComponent impl
5758

5859
private static MaterialEditorTopComponent instance;
5960
private static final String PREFERRED_ID = "MaterialEditorTopComponent";
60-
private final InstanceContent lookupContents = new InstanceContent();
6161
private DataObject dataObject;
6262
private EditableMaterialFile materialFile;
6363
private String materialFileName;
@@ -572,15 +572,8 @@ public void setMatDefList(final String[] matDefs, String selected) {
572572
materialFile = null;
573573
jComboBox1.removeAllItems();
574574
jComboBox1.addItem("");
575-
List<String> matDefList = new ArrayList<>();
576-
for(String s: matDefs) {
577-
if (!matDefList.contains(s)){
578-
matDefList.add(s);
579-
}
580-
}
581-
Collections.sort(matDefList);
582-
String[] sortedMatDefs = matDefList.toArray(String[]::new);
583-
for (String string : sortedMatDefs) {
575+
Set<String> matDefList = new TreeSet<>(Arrays.asList(matDefs));
576+
for (String string : matDefList) {
584577
jComboBox1.addItem(string);
585578
}
586579
jComboBox1.setSelectedItem(selected);
@@ -589,13 +582,13 @@ public void setMatDefList(final String[] matDefs, String selected) {
589582

590583
private void updateProperties() {
591584
for (Component component : optionsPanel.getComponents()) {
592-
if (component instanceof MaterialPropertyWidget) {
593-
((MaterialPropertyWidget) component).registerChangeListener(null);
585+
if (component instanceof MaterialPropertyWidget materialPropertyWidget) {
586+
materialPropertyWidget.registerChangeListener(null);
594587
}
595588
}
596589
for (Component component : texturePanel.getComponents()) {
597-
if (component instanceof MaterialPropertyWidget) {
598-
((MaterialPropertyWidget) component).registerChangeListener(null);
590+
if (component instanceof MaterialPropertyWidget materialPropertyWidget) {
591+
materialPropertyWidget.registerChangeListener(null);
599592
}
600593
}
601594
optionsPanel.removeAll();

0 commit comments

Comments
 (0)