mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
added enum editor
This commit is contained in:
+15
@@ -0,0 +1,15 @@
|
||||
package org.diylc.common;
|
||||
|
||||
public enum Orientation {
|
||||
|
||||
DEFAULT, _90, _180, _270;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (this == DEFAULT) {
|
||||
return "Default";
|
||||
} else {
|
||||
return name().replace("_", "") + " degrees clockwise";
|
||||
}
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package org.diylc.gui.editor;
|
||||
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.ItemListener;
|
||||
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.JComboBox;
|
||||
|
||||
import org.diylc.common.PropertyWrapper;
|
||||
|
||||
public class EnumEditor extends JComboBox {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final PropertyWrapper property;
|
||||
|
||||
public EnumEditor(PropertyWrapper property) {
|
||||
this.property = property;
|
||||
Object[] values = property.getType().getEnumConstants();
|
||||
setModel(new DefaultComboBoxModel(values));
|
||||
setSelectedItem(property.getValue());
|
||||
addItemListener(new ItemListener() {
|
||||
|
||||
@Override
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
if (e.getStateChange() == ItemEvent.SELECTED) {
|
||||
EnumEditor.this.property.setValue(e.getItem());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+4
-1
@@ -6,7 +6,6 @@ import java.awt.Component;
|
||||
import org.diylc.common.PropertyWrapper;
|
||||
import org.diylc.core.measures.AbstractMeasure;
|
||||
|
||||
|
||||
public class FieldEditorFactory {
|
||||
|
||||
public static Component createFieldEditor(PropertyWrapper property) {
|
||||
@@ -22,6 +21,10 @@ public class FieldEditorFactory {
|
||||
MeasureEditor editor = new MeasureEditor(property);
|
||||
return editor;
|
||||
}
|
||||
if (property.getType().isEnum()) {
|
||||
EnumEditor editor = new EnumEditor(property);
|
||||
return editor;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ public class PropertyEditorDialog extends ButtonDialog {
|
||||
private Set<PropertyWrapper> defaultedProperties;
|
||||
|
||||
public PropertyEditorDialog(JFrame owner, List<PropertyWrapper> properties) {
|
||||
super(owner, "Editor", new String[] { ButtonDialog.OK, ButtonDialog.CANCEL });
|
||||
super(owner, "Component Editor", new String[] { ButtonDialog.OK, ButtonDialog.CANCEL });
|
||||
|
||||
LOG.debug("Creating property editor for: " + properties);
|
||||
|
||||
|
||||
+1
@@ -10,6 +10,7 @@ import org.diylc.common.PropertyWrapper;
|
||||
public class StringEditor extends JTextField {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final PropertyWrapper property;
|
||||
|
||||
public StringEditor(PropertyWrapper property) {
|
||||
|
||||
+2
-1
@@ -55,7 +55,8 @@ public class StatusBar extends JPanel implements IPlugIn {
|
||||
|
||||
private JComboBox getZoomBox() {
|
||||
if (zoomBox == null) {
|
||||
zoomBox = new JComboBox(new Double[] { 0.25d, 0.5d, 0.75d, 1d, 1.5d, 2d });
|
||||
zoomBox = new JComboBox(new Double[] { 0.25d, 0.3333d, 0.5d, 0.6667d, 0.75d, 1d, 1.25d,
|
||||
1.5d, 2d });
|
||||
zoomBox.setSelectedItem(1d);
|
||||
zoomBox.setFocusable(false);
|
||||
zoomBox.setRenderer(new PercentageListCellRenderer());
|
||||
|
||||
Reference in New Issue
Block a user