Added table contents to ComponentPresetChooserDialog.
This commit is contained in:
parent
85f939b6d8
commit
26f8fdf63b
@ -1590,3 +1590,9 @@ PresetModel.lbl.database = From database...
|
|||||||
|
|
||||||
! Component Preset Chooser Dialog
|
! Component Preset Chooser Dialog
|
||||||
ComponentPresetChooserDialog.title = Choose component preset
|
ComponentPresetChooserDialog.title = Choose component preset
|
||||||
|
table.column.Manufacturer = Manufacturer
|
||||||
|
table.column.PartNo = Part Number
|
||||||
|
table.column.OuterDiameter = Outer Diameter
|
||||||
|
table.column.InnerDiameter = Inner Diameter
|
||||||
|
table.column.Length = Length
|
||||||
|
|
||||||
|
@ -1,11 +1,16 @@
|
|||||||
package net.sf.openrocket.gui.configdialog;
|
package net.sf.openrocket.gui.configdialog;
|
||||||
|
|
||||||
|
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
|
import javax.swing.JButton;
|
||||||
import javax.swing.JCheckBox;
|
import javax.swing.JCheckBox;
|
||||||
import javax.swing.JComboBox;
|
import javax.swing.JComboBox;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JSpinner;
|
import javax.swing.JSpinner;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
import net.sf.openrocket.document.OpenRocketDocument;
|
import net.sf.openrocket.document.OpenRocketDocument;
|
||||||
@ -15,8 +20,10 @@ import net.sf.openrocket.gui.adaptors.DoubleModel;
|
|||||||
import net.sf.openrocket.gui.adaptors.PresetModel;
|
import net.sf.openrocket.gui.adaptors.PresetModel;
|
||||||
import net.sf.openrocket.gui.components.BasicSlider;
|
import net.sf.openrocket.gui.components.BasicSlider;
|
||||||
import net.sf.openrocket.gui.components.UnitSelector;
|
import net.sf.openrocket.gui.components.UnitSelector;
|
||||||
|
import net.sf.openrocket.gui.dialogs.preset.ComponentPresetChooserDialog;
|
||||||
import net.sf.openrocket.l10n.Translator;
|
import net.sf.openrocket.l10n.Translator;
|
||||||
import net.sf.openrocket.material.Material;
|
import net.sf.openrocket.material.Material;
|
||||||
|
import net.sf.openrocket.preset.ComponentPreset;
|
||||||
import net.sf.openrocket.rocketcomponent.BodyTube;
|
import net.sf.openrocket.rocketcomponent.BodyTube;
|
||||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||||
import net.sf.openrocket.startup.Application;
|
import net.sf.openrocket.startup.Application;
|
||||||
@ -42,8 +49,29 @@ public class BodyTubeConfig extends RocketComponentConfig {
|
|||||||
presetComboBox = new JComboBox(new PresetModel(component));
|
presetComboBox = new JComboBox(new PresetModel(component));
|
||||||
presetComboBox.setEditable(false);
|
presetComboBox.setEditable(false);
|
||||||
panel.add(presetComboBox, "wrap para");
|
panel.add(presetComboBox, "wrap para");
|
||||||
|
//FIXME: temporarily put the select from table button in the config dialog.
|
||||||
|
{
|
||||||
|
JButton opendialog = new JButton("o");
|
||||||
|
opendialog.addActionListener(
|
||||||
|
new ActionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
ComponentPresetChooserDialog dialog =
|
||||||
|
new ComponentPresetChooserDialog( SwingUtilities.getWindowAncestor(BodyTubeConfig.this),
|
||||||
|
BodyTubeConfig.this.component,
|
||||||
|
ComponentPreset.MANUFACTURER,
|
||||||
|
ComponentPreset.PARTNO,
|
||||||
|
ComponentPreset.OUTER_DIAMETER,
|
||||||
|
ComponentPreset.INNER_DIAMETER,
|
||||||
|
ComponentPreset.LENGTH);
|
||||||
|
dialog.setVisible(true);
|
||||||
|
ComponentPreset preset = dialog.getSelectedComponentPreset();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
panel.add( opendialog, "wrap" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//// Body tube length
|
//// Body tube length
|
||||||
panel.add(new JLabel(trans.get("BodyTubecfg.lbl.Bodytubelength")));
|
panel.add(new JLabel(trans.get("BodyTubecfg.lbl.Bodytubelength")));
|
||||||
|
@ -10,14 +10,22 @@ import java.util.List;
|
|||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JDialog;
|
import javax.swing.JDialog;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JTable;
|
||||||
|
import javax.swing.ListSelectionModel;
|
||||||
|
import javax.swing.table.TableModel;
|
||||||
|
import javax.swing.table.TableRowSorter;
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
|
import net.sf.openrocket.gui.adaptors.Column;
|
||||||
|
import net.sf.openrocket.gui.adaptors.ColumnTableModel;
|
||||||
import net.sf.openrocket.gui.util.GUIUtil;
|
import net.sf.openrocket.gui.util.GUIUtil;
|
||||||
import net.sf.openrocket.l10n.Translator;
|
import net.sf.openrocket.l10n.Translator;
|
||||||
import net.sf.openrocket.preset.ComponentPreset;
|
import net.sf.openrocket.preset.ComponentPreset;
|
||||||
import net.sf.openrocket.preset.TypedKey;
|
import net.sf.openrocket.preset.TypedKey;
|
||||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||||
import net.sf.openrocket.startup.Application;
|
import net.sf.openrocket.startup.Application;
|
||||||
|
import net.sf.openrocket.unit.Value;
|
||||||
|
|
||||||
public class ComponentPresetChooserDialog extends JDialog {
|
public class ComponentPresetChooserDialog extends JDialog {
|
||||||
|
|
||||||
@ -31,21 +39,16 @@ public class ComponentPresetChooserDialog extends JDialog {
|
|||||||
private boolean okClicked = false;
|
private boolean okClicked = false;
|
||||||
|
|
||||||
|
|
||||||
public ComponentPresetChooserDialog(Window owner, RocketComponent component, TypedKey<?>... columnKeys) {
|
public ComponentPresetChooserDialog(Window owner, RocketComponent component, final TypedKey<?>... columnKeys) {
|
||||||
super(owner, trans.get("title"), Dialog.ModalityType.APPLICATION_MODAL);
|
super(owner, trans.get("title"), Dialog.ModalityType.APPLICATION_MODAL);
|
||||||
|
|
||||||
this.component = component;
|
this.component = component;
|
||||||
|
|
||||||
// FIXME: Make generic for component type
|
|
||||||
presets = Application.getComponentPresetDao().listAll();
|
presets = Application.getComponentPresetDao().listAll();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
JPanel panel = new JPanel(new MigLayout("fill"));
|
JPanel panel = new JPanel(new MigLayout("fill"));
|
||||||
|
|
||||||
/*
|
final Column[] columns = new Column[columnKeys.length];
|
||||||
Column[] columns = new Column[columnKeys.length];
|
|
||||||
|
|
||||||
for (int i = 0; i < columnKeys.length; i++) {
|
for (int i = 0; i < columnKeys.length; i++) {
|
||||||
final TypedKey<?> key = columnKeys[i];
|
final TypedKey<?> key = columnKeys[i];
|
||||||
@ -53,12 +56,11 @@ public class ComponentPresetChooserDialog extends JDialog {
|
|||||||
@Override
|
@Override
|
||||||
public Object getValueAt(int row) {
|
public Object getValueAt(int row) {
|
||||||
if (key.getType() == Double.class && key.getUnitGroup() != null) {
|
if (key.getType() == Double.class && key.getUnitGroup() != null) {
|
||||||
return new Value(, null);
|
double v = (Double) ComponentPresetChooserDialog.this.presets.get(row).get(key);
|
||||||
|
return new Value( v, key.getUnitGroup() );
|
||||||
|
} else {
|
||||||
|
return ComponentPresetChooserDialog.this.presets.get(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -66,14 +68,25 @@ public class ComponentPresetChooserDialog extends JDialog {
|
|||||||
ColumnTableModel tableModel = new ColumnTableModel(columns) {
|
ColumnTableModel tableModel = new ColumnTableModel(columns) {
|
||||||
@Override
|
@Override
|
||||||
public int getRowCount() {
|
public int getRowCount() {
|
||||||
// FIXME Auto-generated method stub
|
return ComponentPresetChooserDialog.this.presets.size();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final JTable table = new JTable( tableModel );
|
||||||
|
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||||
|
|
||||||
|
final TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(tableModel);
|
||||||
|
// FIXME we might need some custom sorters.
|
||||||
|
/*for (int i = 0; i < columnKeys.length; i++) {
|
||||||
|
TypedKey<?> column = columnKeys[i];
|
||||||
|
sorter.setComparator(i, column.getComparator());
|
||||||
|
}*/
|
||||||
|
table.setRowSorter(sorter);
|
||||||
|
|
||||||
|
JScrollPane scrollpane = new JScrollPane();
|
||||||
|
scrollpane.setViewportView(table);
|
||||||
|
panel.add(scrollpane, "grow, width :500:, height :300:, spanx, wrap para");
|
||||||
|
|
||||||
|
|
||||||
// OK / Cancel buttons
|
// OK / Cancel buttons
|
||||||
JButton okButton = new JButton(trans.get("dlg.but.ok"));
|
JButton okButton = new JButton(trans.get("dlg.but.ok"));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user