Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -72,6 +75,7 @@ public PropertyDescriptor(String name, Class<?> type, Map<String, Object> attrib
if (type.isEnum() && getValueSet() == null) {
setValueSet(new ValueSet(type.getEnumConstants()));
}
setEnabled(true);
}

private static boolean equals(Object a, Object b) {
Expand Down Expand Up @@ -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");
}
Expand Down
47 changes: 35 additions & 12 deletions ceres-ui/src/main/java/com/bc/ceres/swing/binding/PropertyPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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));
Expand Down Expand Up @@ -182,27 +183,49 @@ 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);
if(components[0] instanceof JScrollPane) {
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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down