diff --git a/ceres-binding/src/main/java/com/bc/ceres/binding/PropertyDescriptor.java b/ceres-binding/src/main/java/com/bc/ceres/binding/PropertyDescriptor.java index 1714d31895c..b90f5078cf3 100644 --- a/ceres-binding/src/main/java/com/bc/ceres/binding/PropertyDescriptor.java +++ b/ceres-binding/src/main/java/com/bc/ceres/binding/PropertyDescriptor.java @@ -37,8 +37,11 @@ * to instances of this class. * * @author Norman Fomferra + * @author Daniel Knowles * @since 0.6 */ +// MAR2020 - Knowles - Added setEnabled so that some properties can be initially disabled + public class PropertyDescriptor { private final String name; @@ -72,6 +75,7 @@ public PropertyDescriptor(String name, Class type, Map attrib if (type.isEnum() && getValueSet() == null) { setValueSet(new ValueSet(type.getEnumConstants())); } + setEnabled(true); } private static boolean equals(Object a, Object b) { @@ -148,6 +152,14 @@ public void setDescription(String description) { setAttribute("description", description); } + public boolean getEnabled() { + return getBooleanProperty("enabled"); + } + + public void setEnabled(boolean enabled) { + setAttribute("enabled", enabled); + } + public boolean isNotNull() { return getBooleanProperty("notNull"); } diff --git a/ceres-ui/src/main/java/com/bc/ceres/swing/binding/PropertyPane.java b/ceres-ui/src/main/java/com/bc/ceres/swing/binding/PropertyPane.java index 71f8e7885fc..d369c4f4bb5 100644 --- a/ceres-ui/src/main/java/com/bc/ceres/swing/binding/PropertyPane.java +++ b/ceres-ui/src/main/java/com/bc/ceres/swing/binding/PropertyPane.java @@ -25,6 +25,7 @@ import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; +import javax.swing.JComboBox; import java.awt.Color; import java.awt.Font; @@ -43,24 +44,24 @@ * @version $Revision$ $Date$ * @ */ -// JAN2018 - Daniel Knowles - Added method to return property pane as a JScrollPane - - -// JAN2018 - Daniel Knowles - Moved some of the logic for adding components to a public method which can also be called by +// JAN2019 - Knowles - Added method to return property pane as a JScrollPane +// JAN2019 - Knowles - Moved some of the logic for adding components to a public method which can also be called by // the preferences GUIs. // - Added tooltips: NOTE: actual tooltips values will be added in the future. // NOTE: this does not contain section breaks which may be added in the future for a future // revision of map gridlines and other tools. - +// MAR2021 - Knowles - Added setEnabled so that some properties can be initially disabled public class PropertyPane { private final BindingContext bindingContext; - private final static String DASHES = "----------"; + private final static String DASHES = "----"; + private final static String DASHES_SUBSECTION = "- - - -"; public static final String PROPERTY_SECTIONBREAK_NAME_SUFFIX = ".section"; + public static final String PROPERTY_SUBSECTIONBREAK_NAME_SUFFIX = ".subsection"; public PropertyPane(PropertySet propertySet) { this(new BindingContext(propertySet)); @@ -182,6 +183,8 @@ static public JComponent[] addComponent(int rowIndex, TableLayout layout, JPanel if (components.length == 2) { components[0].setToolTipText(descriptor.getDescription()); components[1].setToolTipText(descriptor.getDescription()); + components[0].setEnabled(descriptor.getEnabled()); + components[1].setEnabled(descriptor.getEnabled()); layout.setCellWeightX(rowIndex, 0, 0.0); panel.add(components[1], cell(rowIndex, 0)); layout.setCellWeightX(rowIndex, 1, 1.0); @@ -189,20 +192,40 @@ static public JComponent[] addComponent(int rowIndex, TableLayout layout, JPanel layout.setRowWeightY(rowIndex, 1.0); layout.setRowFill(rowIndex, TableLayout.Fill.BOTH); } + if (components[0] instanceof JComboBox) { + layout.setRowWeightX(rowIndex, 1.0); + layout.setCellFill(rowIndex, 1, TableLayout.Fill.NONE); + } panel.add(components[0], cell(rowIndex, 1)); } else { layout.setCellColspan(rowIndex, 0, 2); layout.setCellWeightX(rowIndex, 0, 1.0); + if (descriptor.getName().endsWith(PROPERTY_SECTIONBREAK_NAME_SUFFIX) || descriptor.getName().endsWith(PROPERTY_SUBSECTIONBREAK_NAME_SUFFIX)) { + if (descriptor.getDisplayName() != null && descriptor.getDisplayName().length() > 0) { + JLabel sectionLabel; if (descriptor.getName().endsWith(PROPERTY_SECTIONBREAK_NAME_SUFFIX)) { - if (descriptor.getDisplayName() != null && descriptor.getDisplayName().length() > 0 ) { - JLabel sectionLabel = new JLabel(DASHES + " " + descriptor.getDisplayName() + " " + DASHES); + sectionLabel = new JLabel(DASHES + " " + descriptor.getDisplayName() + " " + DASHES); + +// sectionLabel = new JLabel("• " + descriptor.getDisplayName() + " •"); + int origFontSize = sectionLabel.getFont().getSize(); + int increasedFontSize = (int) Math.floor(origFontSize * 1.15); + Font sectionFont = new Font(sectionLabel.getFont().getName(), Font.BOLD, increasedFontSize); + sectionLabel.setFont(sectionFont); + } else { +// sectionLabel = new JLabel( "‣ " + descriptor.getDisplayName() + " --"); + sectionLabel = new JLabel("‣ " + descriptor.getDisplayName() + ":"); +// sectionLabel = new JLabel( "‣ " + descriptor.getDisplayName()); + int origFontSize = sectionLabel.getFont().getSize(); + int increasedFontSize = (int) Math.floor(origFontSize * 1.1); +// Font sectionFont=new Font(sectionLabel.getFont().getName(),Font.ITALIC | Font.BOLD,sectionLabel.getFont().getSize()); + Font sectionFont = new Font(sectionLabel.getFont().getName(), Font.BOLD, increasedFontSize); + sectionLabel.setFont(sectionFont); + } sectionLabel.setToolTipText(descriptor.getDescription()); sectionLabel.setForeground(Color.BLACK); - Font sectionFont=new Font(sectionLabel.getFont().getName(),Font.ITALIC,sectionLabel.getFont().getSize()); - sectionLabel.setFont(sectionFont); - panel.add(sectionLabel); + panel.add(sectionLabel, cell(rowIndex, 0)); } else { - panel.add(new JLabel(" ")); + panel.add(new JLabel(" "), cell(rowIndex, 0)); } } else { components[0].setToolTipText(descriptor.getDescription()); diff --git a/ceres-ui/src/main/java/com/bc/ceres/swing/binding/internal/NumericEditor.java b/ceres-ui/src/main/java/com/bc/ceres/swing/binding/internal/NumericEditor.java index 5d7fd6ac640..8805b559fb0 100644 --- a/ceres-ui/src/main/java/com/bc/ceres/swing/binding/internal/NumericEditor.java +++ b/ceres-ui/src/main/java/com/bc/ceres/swing/binding/internal/NumericEditor.java @@ -45,7 +45,7 @@ public boolean isValidFor(PropertyDescriptor propertyDescriptor) { @Override public JComponent createEditorComponent(PropertyDescriptor propertyDescriptor, BindingContext bindingContext) { JTextField textField = new JTextField(); - textField.setHorizontalAlignment(SwingConstants.RIGHT); + textField.setHorizontalAlignment(SwingConstants.LEFT); int fontSize = textField.getFont().getSize(); textField.setFont(new Font("Courier", Font.PLAIN, fontSize)); ComponentAdapter adapter = new TextComponentAdapter(textField);