Better looking checkboxes.
- Booleans are now shown as centered checkboxes - Refactored detail button to class
This commit is contained in:
parent
e449f28419
commit
0e35f8e0f4
@ -14,7 +14,8 @@ public class PropertyBoolSelector extends JCheckBox {
|
|||||||
|
|
||||||
public PropertyBoolSelector(PropertyEditor pe) {
|
public PropertyBoolSelector(PropertyEditor pe) {
|
||||||
super();
|
super();
|
||||||
setBackground(Color.WHITE);
|
setHorizontalAlignment(JLabel.CENTER);
|
||||||
|
setBorderPainted(true);
|
||||||
propertyEditor = pe;
|
propertyEditor = pe;
|
||||||
if (propertyEditor.getAsText().equals("True")) {
|
if (propertyEditor.getAsText().equals("True")) {
|
||||||
setSelected(true);
|
setSelected(true);
|
||||||
|
@ -209,7 +209,7 @@ public final class PropertySheetPanel extends JPanel implements PropertyChangeLi
|
|||||||
propertyDescriptors = bi.getPropertyDescriptors();
|
propertyDescriptors = bi.getPropertyDescriptors();
|
||||||
methodDescriptors = bi.getMethodDescriptors();
|
methodDescriptors = bi.getMethodDescriptors();
|
||||||
} catch (IntrospectionException ex) {
|
} catch (IntrospectionException ex) {
|
||||||
System.err.println("PropertySheetPanel.setTarget(): Couldn't introspect");
|
LOGGER.log(Level.SEVERE, "Could not create editor for object.", ex);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,7 +270,7 @@ public final class PropertySheetPanel extends JPanel implements PropertyChangeLi
|
|||||||
if (objectValues[i] == null) {
|
if (objectValues[i] == null) {
|
||||||
continue; // expert, hidden, or no getter/setter available
|
continue; // expert, hidden, or no getter/setter available
|
||||||
}
|
}
|
||||||
JComponent newView = null;
|
JComponent newView;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
propertyEditors[i] = makeEditor(propertyDescriptors[i], name, objectValues[i]);
|
propertyEditors[i] = makeEditor(propertyDescriptors[i], name, objectValues[i]);
|
||||||
@ -288,11 +288,11 @@ public final class PropertySheetPanel extends JPanel implements PropertyChangeLi
|
|||||||
itemIndex++;
|
itemIndex++;
|
||||||
newView = getView(propertyEditors[i]);
|
newView = getView(propertyEditors[i]);
|
||||||
if (newView == null) {
|
if (newView == null) {
|
||||||
System.err.println("Warning: Property \"" + name + "\" has non-displayable editor. Skipping.");
|
LOGGER.warning("Warning: Property \"" + name + "\" has non-displayable editor. Skipping.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("Skipping property " + name + " ; exception: " + ex);
|
LOGGER.warning("Skipping property " + name + " ; exception: " + ex);
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
continue;
|
continue;
|
||||||
} // end try
|
} // end try
|
||||||
@ -706,7 +706,7 @@ public final class PropertySheetPanel extends JPanel implements PropertyChangeLi
|
|||||||
JComponent newView = null;
|
JComponent newView = null;
|
||||||
newView = getView(tmpEdit);
|
newView = getView(tmpEdit);
|
||||||
if (newView == null) {
|
if (newView == null) {
|
||||||
System.err.println("Warning: Property \"" + propertyDescriptors[i].getDisplayName() + "\" has non-displayable editor. Skipping.");
|
LOGGER.warning("Property \"" + propertyDescriptors[i].getDisplayName() + "\" has non-displayable editor. Skipping.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
propertyEditors[i].addPropertyChangeListener(this);
|
propertyEditors[i].addPropertyChangeListener(this);
|
||||||
@ -743,17 +743,16 @@ public final class PropertySheetPanel extends JPanel implements PropertyChangeLi
|
|||||||
}
|
}
|
||||||
} catch (InvocationTargetException ex) {
|
} catch (InvocationTargetException ex) {
|
||||||
if (ex.getTargetException() instanceof PropertyVetoException) {
|
if (ex.getTargetException() instanceof PropertyVetoException) {
|
||||||
System.out.println("PropertySheetPanel.wasModified(): WARNING: Vetoed; reason is: " + ex.getTargetException().getMessage());
|
LOGGER.warning("PropertySheetPanel.wasModified(): WARNING: Vetoed; reason is: " + ex.getTargetException().getMessage());
|
||||||
} else {
|
} else {
|
||||||
System.out.println("PropertySheetPanel.wasModified(): InvocationTargetException while updating " + property.getName());
|
LOGGER.warning("PropertySheetPanel.wasModified(): InvocationTargetException while updating " + property.getName());
|
||||||
System.out.println("PropertySheetPanel.wasModified(): " + ex.getMessage());
|
LOGGER.warning("PropertySheetPanel.wasModified(): " + ex.getMessage());
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("PropertySheetPanel.wasModified(): Unexpected exception while updating " + property.getName());
|
LOGGER.warning("PropertySheetPanel.wasModified(): Unexpected exception while updating " + property.getName());
|
||||||
}
|
}
|
||||||
if (views[i] != null && views[i] instanceof PropertyPanel) {
|
if (views[i] != null && views[i] instanceof PropertyPanel) {
|
||||||
//System.err.println("Trying to repaint the property canvas");
|
|
||||||
views[i].repaint();
|
views[i].repaint();
|
||||||
revalidate();
|
revalidate();
|
||||||
}
|
}
|
||||||
@ -780,10 +779,10 @@ public final class PropertySheetPanel extends JPanel implements PropertyChangeLi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (propIndex == -1) {
|
if (propIndex == -1) {
|
||||||
System.err.println("error: could not identify event editor! (PropertySheetPanel)");
|
LOGGER.severe("Could not identify event editor! (PropertySheetPanel)");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
System.err.println("unknown event source! (PropertySheetPanel)");
|
LOGGER.warning("Unknown event source! (PropertySheetPanel)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -981,30 +980,18 @@ final class PropertyCellRenderer extends DefaultTableCellRenderer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||||
|
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||||
|
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
return this;
|
return this;
|
||||||
} else if (value instanceof String) {
|
} else if (value instanceof String) {
|
||||||
// Really hacky but it adds a prefix so the alignment looks ok
|
|
||||||
setText((String) value);
|
setText((String) value);
|
||||||
return this;
|
return this;
|
||||||
} else if (value instanceof eva2.gui.PropertyPanel) {
|
} else if (value instanceof eva2.gui.PropertyPanel) {
|
||||||
JComponent component = new JPanel();
|
JComponent component = new JPanel();
|
||||||
component.setLayout(new BorderLayout());
|
component.setLayout(new BorderLayout());
|
||||||
component.add((PropertyPanel) value, BorderLayout.CENTER);
|
component.add((PropertyPanel) value, BorderLayout.CENTER);
|
||||||
final JButton dialogButton = new JButton("...") {
|
final JButton dialogButton = new DetailButton();
|
||||||
@Override
|
|
||||||
public void paint(Graphics g) {
|
|
||||||
Color old = g.getColor();
|
|
||||||
g.setColor(Color.WHITE);
|
|
||||||
g.fillRect(0,0,100,100);
|
|
||||||
g.setColor(old);
|
|
||||||
super.paint(g);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
dialogButton.setMargin(new Insets(0, 0, 0, 0));
|
|
||||||
dialogButton.putClientProperty("JButton.buttonType", "bevel");
|
|
||||||
dialogButton.setBackground(Color.WHITE);
|
|
||||||
component.add(dialogButton, BorderLayout.LINE_END);
|
component.add(dialogButton, BorderLayout.LINE_END);
|
||||||
return component;
|
return component;
|
||||||
} else if (value instanceof PropertyText) {
|
} else if (value instanceof PropertyText) {
|
||||||
@ -1026,7 +1013,6 @@ final class PropertyCellRenderer extends DefaultTableCellRenderer {
|
|||||||
|
|
||||||
final class PropertyCellEditor extends AbstractCellEditor implements TableCellEditor {
|
final class PropertyCellEditor extends AbstractCellEditor implements TableCellEditor {
|
||||||
private Logger LOGGER = Logger.getLogger(PropertyCellEditor.class.getName());
|
private Logger LOGGER = Logger.getLogger(PropertyCellEditor.class.getName());
|
||||||
private JLabel empty = new JLabel();
|
|
||||||
private Object value;
|
private Object value;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1034,27 +1020,13 @@ final class PropertyCellEditor extends AbstractCellEditor implements TableCellEd
|
|||||||
LOGGER.log(Level.FINEST, "Editor Component: " + value.getClass());
|
LOGGER.log(Level.FINEST, "Editor Component: " + value.getClass());
|
||||||
this.value = value;
|
this.value = value;
|
||||||
JComponent component;
|
JComponent component;
|
||||||
if (value == null) {
|
if (value instanceof String) {
|
||||||
component = empty;
|
|
||||||
} else if (value instanceof String) {
|
|
||||||
component = new JLabel(value.toString());
|
component = new JLabel(value.toString());
|
||||||
} else if (value instanceof PropertyPanel) {
|
} else if (value instanceof PropertyPanel) {
|
||||||
component = new JPanel();
|
component = new JPanel();
|
||||||
component.setLayout(new BorderLayout());
|
component.setLayout(new BorderLayout());
|
||||||
component.add((PropertyPanel) value, BorderLayout.CENTER);
|
component.add((PropertyPanel) value, BorderLayout.CENTER);
|
||||||
final JButton dialogButton = new JButton("...") {
|
final JButton dialogButton = new DetailButton();
|
||||||
@Override
|
|
||||||
public void paint(Graphics g) {
|
|
||||||
Color old = g.getColor();
|
|
||||||
g.setColor(Color.WHITE);
|
|
||||||
g.fillRect(0,0,100,100);
|
|
||||||
g.setColor(old);
|
|
||||||
super.paint(g);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
dialogButton.setMargin(new Insets(0, 0, 0, 0));
|
|
||||||
dialogButton.putClientProperty("JButton.buttonType", "bevel");
|
|
||||||
dialogButton.setBackground(Color.WHITE);
|
|
||||||
dialogButton.addActionListener(event -> {
|
dialogButton.addActionListener(event -> {
|
||||||
((PropertyPanel) value).showDialog();
|
((PropertyPanel) value).showDialog();
|
||||||
fireEditingStopped();
|
fireEditingStopped();
|
||||||
@ -1084,8 +1056,24 @@ final class PropertyCellEditor extends AbstractCellEditor implements TableCellEd
|
|||||||
int selectedColumn = sourceTable.getSelectedColumn();
|
int selectedColumn = sourceTable.getSelectedColumn();
|
||||||
String columnName = sourceTable.getColumnName(selectedColumn);
|
String columnName = sourceTable.getColumnName(selectedColumn);
|
||||||
/* If the columnName equals Key it holds the keys */
|
/* If the columnName equals Key it holds the keys */
|
||||||
return !"Key".equals(columnName);
|
return !"Attribute".equals(columnName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final class DetailButton extends JButton {
|
||||||
|
public DetailButton() {
|
||||||
|
super("<html>…</html>");
|
||||||
|
this.setMargin(new Insets(0, 0, 0, 0));
|
||||||
|
this.putClientProperty("JButton.buttonType", "bevel");
|
||||||
|
this.setBackground(Color.WHITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void paint(Graphics g) {
|
||||||
|
Color old = g.getColor();
|
||||||
|
g.setColor(Color.WHITE);
|
||||||
|
g.fillRect(0,0,100,100);
|
||||||
|
g.setColor(old);
|
||||||
|
super.paint(g);
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,9 +1,4 @@
|
|||||||
package eva2.gui;
|
package eva2.gui;
|
||||||
/*
|
|
||||||
* Title: EvA2 Description: Copyright: Copyright (c) 2003 Company: University of Tuebingen, Computer
|
|
||||||
* Architecture @author Holger Ulmer, Felix Streichert, Hannes Planatscher @version: $Revision: 57 $
|
|
||||||
* $Date: 2007-05-04 14:22:16 +0200 (Fri, 04 May 2007) $ $Author: mkron $
|
|
||||||
*/
|
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.beans.PropertyEditor;
|
import java.beans.PropertyEditor;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user