new support classes added

This commit is contained in:
Daniel Collin 2015-10-20 06:56:14 +00:00
parent 9764f546da
commit 83e0196c50
21 changed files with 798 additions and 9 deletions

View file

@ -0,0 +1,27 @@
package com.coder.client.property;
import org.controlsfx.property.editor.Editors;
import org.controlsfx.property.editor.PropertyEditor;
public class CheckBoxProperty extends CoderClientProperty<Boolean> {
public CheckBoxProperty(String name, boolean defaultValue){
super(name, defaultValue);
}
@Override
public String getDescription() {
return null;
}
@Override
public Class<?> getType() {
return Boolean.class;
}
@Override
public PropertyEditor<?> getEditor() {
return Editors.createCheckEditor(this);
}
}

View file

@ -0,0 +1,51 @@
package com.coder.client.property;
import java.util.Optional;
import org.controlsfx.control.PropertySheet;
import org.controlsfx.property.editor.PropertyEditor;
public abstract class CoderClientProperty<T> implements PropertySheet.Item {
private String name;
private T value;
public CoderClientProperty(String name, T defaultValue){
this.name = name;
this.value = defaultValue;
}
@Override
public String getName(){
return name;
}
@Override
public Object getValue() {
return value;
}
@Override
public boolean isEditable() {
return true;
}
@SuppressWarnings("unchecked")
@Override
public void setValue(Object value) {
this.value = (T)value;
}
@Override
public Optional<Class<? extends PropertyEditor<?>>> getPropertyEditorClass() {
return Optional.empty();
}
@Override
public String getCategory() {
return "";
}
public abstract PropertyEditor<?> getEditor();
}

View file

@ -0,0 +1,31 @@
package com.coder.client.property;
import java.util.Collection;
import org.controlsfx.property.editor.Editors;
import org.controlsfx.property.editor.PropertyEditor;
public class ComboBoxProperty extends CoderClientProperty<String> {
private Collection<String> valueAlternatives;
public ComboBoxProperty(String name, String defaultValue, Collection<String> valueAlternatives){
super(name, defaultValue);
this.valueAlternatives = valueAlternatives;
}
@Override
public String getDescription() {
return null;
}
@Override
public Class<?> getType() {
return valueAlternatives.getClass();
}
@Override
public PropertyEditor<?> getEditor() {
return Editors.createChoiceEditor(this, valueAlternatives);
}
}