import net.sf.openrocket.gui.dialogs.CustomMaterialDialog;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.material.Material;
+import net.sf.openrocket.preset.loader.MaterialHolder;
import net.sf.openrocket.startup.Application;
-import javax.swing.*;
-import java.awt.*;
+import javax.swing.DefaultComboBoxModel;
+import javax.swing.SwingUtilities;
+import java.awt.Component;
/**
* A material model specifically for presets.
private static final Translator trans = Application.getTranslator();
+ private Material.Type type;
+
private Component parent;
- public MaterialModel(Component theParent, Material.Type type) {
+
+ public MaterialModel(Component theParent, Material.Type theType, Database<Material> materials) {
parent = theParent;
+ type = theType;
+ database = materials;
+ database.addDatabaseListener(this);
+ }
+
+ public MaterialModel(Component theParent, Material.Type theType) {
+ parent = theParent;
+ type = theType;
switch (type) {
case LINE:
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
- CustomMaterialDialog dialog = new CustomMaterialDialog(
- SwingUtilities.getWindowAncestor(parent),
- (Material) getSelectedItem(), true,
+ CustomMaterialDialog dialog = new CustomMaterialDialog(SwingUtilities.getWindowAncestor(parent), (Material) getSelectedItem(), true,
//// Define custom material
trans.get("MaterialModel.title.Defcustmat"));
this.fireContentsChanged(this, 0, database.size());
}
+ public Material.Type getType() {
+ return type;
+ }
+
+ public void removeListener() {
+ database.removeChangeListener(this);
+ }
}