Merge pull request #1323 from SiboVG/issue-1320

[fixes #1320] Remove 'Custom' material option from preference's add new material
This commit is contained in:
SiboVG 2022-05-01 23:52:22 +02:00 committed by GitHub
commit 12cba42dca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 4 deletions

View File

@ -21,9 +21,9 @@ public abstract class Material implements Comparable<Material> {
private static final Translator trans = Application.getTranslator();
public enum Type {
LINE("Databases.materials.types.Line", UnitGroup.UNITS_DENSITY_LINE),
SURFACE("Databases.materials.types.Surface", UnitGroup.UNITS_DENSITY_SURFACE),
BULK("Databases.materials.types.Bulk", UnitGroup.UNITS_DENSITY_BULK),
SURFACE("Databases.materials.types.Surface", UnitGroup.UNITS_DENSITY_SURFACE),
LINE("Databases.materials.types.Line", UnitGroup.UNITS_DENSITY_LINE),
CUSTOM("Databases.materials.types.Custom", UnitGroup.UNITS_DENSITY_BULK);
private final String name;

View File

@ -4,6 +4,10 @@ import java.awt.Dialog;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import javax.swing.JButton;
import javax.swing.JCheckBox;
@ -78,7 +82,13 @@ public class CustomMaterialDialog extends JDialog {
// Material type (if not known)
panel.add(new JLabel(trans.get("custmatdlg.lbl.Materialtype")));
if (material == null) {
typeBox = new JComboBox<Material.Type>(Material.Type.values());
// Remove the CUSTOM material option from the dropdown box
Material.Type[] values = Material.Type.values();
List<Material.Type> values_list = new LinkedList<>(Arrays.asList(values));
values_list.remove(Material.Type.CUSTOM);
values = values_list.toArray(new Material.Type[0]);
typeBox = new JComboBox<>(values);
typeBox.setSelectedItem(Material.Type.BULK);
typeBox.setEditable(false);
typeBox.addActionListener(new ActionListener() {