diff --git a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/FlightConfigurablePanel.java b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/FlightConfigurablePanel.java index 4b65690fc..4cfa8413a 100644 --- a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/FlightConfigurablePanel.java +++ b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/FlightConfigurablePanel.java @@ -139,9 +139,6 @@ public abstract class FlightConfigurablePanel { @@ -220,15 +234,62 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel } - private class MotorTableCellRenderer extends FlightConfigurablePanel.FlightConfigurableCellRenderer { - + private class MotorTableCellRenderer implements TableCellRenderer { + private void setSelected( JComponent c, JTable table, boolean isSelected, boolean hasFocus ) { + c.setOpaque(true); + if ( isSelected) { + c.setBackground(table.getSelectionBackground()); + c.setForeground(table.getSelectionForeground()); + } else { + c.setBackground(table.getBackground()); + c.setForeground(table.getForeground()); + } + Border b = null; + if ( hasFocus ) { + if (isSelected) { + b = UIManager.getBorder("Table.focusSelectedCellHighlightBorder"); + } else { + b = UIManager.getBorder("Table.focusCellHighligtBorder"); + } + } else { + b = new EmptyBorder(1,1,1,1); + } + c.setBorder(b); + } + @Override - protected void format(MotorMount mount, String configId, JLabel label) { + public Component getTableCellRendererComponent(JTable table,Object value, boolean isSelected, boolean hasFocus, int row,int column) { + switch (column) { + case 0: { + JLabel label = new JLabel(descriptor.format(rocket, (String) value)); + setSelected(label, table, isSelected, hasFocus); + return label; + } + default: { + Pair v = (Pair) value; + String id = v.getU(); + MotorMount component = v.getV(); + JLabel label = format(component, id); + setSelected(label, table, isSelected, hasFocus); + return label; + } + } + } + + protected JLabel format(MotorMount mount, String configId) { + JLabel label = new JLabel(); + label.setLayout(new BoxLayout(label, BoxLayout.X_AXIS)); MotorConfiguration motorConfig = mount.getMotorConfiguration().get(configId); String motorString = getMotorSpecification(mount, motorConfig); - String ignitionString = getIgnitionEventString(configId, mount); - label.setText(motorString + " " + ignitionString); + JLabel motorDescriptionLabel = new JLabel(motorString); + label.add(motorDescriptionLabel); + label.add( Box.createRigidArea(new Dimension(10,0))); + JLabel ignitionLabel = getIgnitionEventString(configId, mount); + label.add(ignitionLabel); + label.validate(); + return label; +// label.setText(motorString + " " + ignitionString); } private String getMotorSpecification(MotorMount mount, MotorConfiguration motorConfig) { @@ -250,24 +311,31 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel return c.toAbsolute(Coordinate.NUL).length; } + protected final void shaded(JLabel label) { + GUIUtil.changeFontStyle(label, Font.ITALIC); + label.setForeground(Color.GRAY); + } - private String getIgnitionEventString(String id, MotorMount mount) { + private JLabel getIgnitionEventString(String id, MotorMount mount) { IgnitionConfiguration ignitionConfig = mount.getIgnitionConfiguration().get(id); IgnitionConfiguration.IgnitionEvent ignitionEvent = ignitionConfig.getIgnitionEvent(); Double ignitionDelay = ignitionConfig.getIgnitionDelay(); boolean isDefault = mount.getIgnitionConfiguration().isDefault(id); + JLabel label = new JLabel(); String str = trans.get("MotorMount.IgnitionEvent.short." + ignitionEvent.name()); - if (ignitionDelay > 0.001) { + if (ignitionEvent != IgnitionEvent.NEVER && ignitionDelay > 0.001) { str = str + " + " + UnitGroup.UNITS_SHORT_TIME.toStringUnit(ignitionDelay); } if (isDefault) { + shaded(label); String def = trans.get("MotorConfigurationTableModel.table.ignition.default"); str = def.replace("{0}", str); } - return str; + label.setText(str); + return label; } }