Skip to content

Commit

Permalink
Fix visual issues with property sheet
Browse files Browse the repository at this point in the history
  • Loading branch information
Emil Forslund committed Nov 25, 2015
1 parent 1d99440 commit da85ea3
Show file tree
Hide file tree
Showing 18 changed files with 78 additions and 101 deletions.
Expand Up @@ -42,8 +42,8 @@ public abstract class AbstractNodeProperty implements Node {
protected AbstractNodeProperty(Speedment speedment) {
this.speedment = speedment;
this.name = new SimpleStringProperty();
this.enabled = new SimpleBooleanProperty();
this.expanded = new SimpleBooleanProperty();
this.enabled = new SimpleBooleanProperty(true);
this.expanded = new SimpleBooleanProperty(true);
}

protected AbstractNodeProperty(Speedment speedment, Node prototype) {
Expand All @@ -57,8 +57,8 @@ protected AbstractNodeProperty(Speedment speedment, Node prototype) {
public Stream<PropertySheet.Item> getGuiVisibleProperties() {
return Stream.concat(
Stream.of(
new BooleanPropertyItem(enabled, "General", "Enabled", "True if this node should be included in the code generation."),
new StringPropertyItem(name, "General", "Name", "The name of the persisted entity represented by this node.")
new BooleanPropertyItem(enabled, "Enabled", "True if this node should be included in the code generation."),
new StringPropertyItem(name, "Name", "The name of the persisted entity represented by this node.")
), guiVisibleProperties()
);
}
Expand Down
Expand Up @@ -81,35 +81,30 @@ protected Stream<PropertySheet.Item> guiVisibleProperties() {
return Stream.of(
// TODO: Add TypeMapper
new StringPropertyItem(
alias,
getClass().getSimpleName(),
alias,
"Alias",
"The name to use in the generated code to represent this entity."
),
new BooleanPropertyItem(
nullable,
getClass().getSimpleName(),
"Is Nullable",
nullable,
"Is Nullable",
"If this column can hold 'null'-values or not."
),
new BooleanPropertyItem(
autoIncrement,
getClass().getSimpleName(),
"Is Auto Incrementing",
autoIncrement,
"Is Auto Incrementing",
"If this column will increment automatically for each new entity."
),
new EnumPropertyItem(
FieldStorageType.class,
fieldStorageType,
"Internal Implementation",
FieldStorageType.class,
fieldStorageType,
"Field Storage Type",
"The type of storage to use for fields of this kind."
),
new EnumPropertyItem(
ColumnCompressionType.class,
columnCompressionType,
"Internal Implementation",
"Column Compression Type",
columnCompressionType,
"Column Compression Type",
"The compression strategy to use for fields of this kind."
)
);
Expand Down
Expand Up @@ -100,26 +100,22 @@ protected Stream<PropertySheet.Item> guiVisibleProperties() {
return Stream.of(
// TODO: Add DbmsType
new StringPropertyItem(
ipAddress,
"Connection",
ipAddress,
"IP Address",
"The ip of the database host."
),
new IntegerPropertyItem(
port,
"Connection",
port,
"Port",
"The port of the database on the database host."
),
new StringPropertyItem(
username,
"Connection",
username,
"Username",
"The username to use when connecting to the database."
),
new StringPasswordPropertyItem(
password,
"Connection",
password,
"Password",
"The password to use when connecting to the database."
)
Expand Down
Expand Up @@ -67,13 +67,11 @@ protected Stream<PropertySheet.Item> guiVisibleProperties() {
return Stream.of(
new StringPropertyItem(
foreignTableName,
getClass().getSimpleName(),
"Foreign Table Name",
"The name of the database table that this foreign key references."
),
new StringPropertyItem(
foreignColumnName,
getClass().getSimpleName(),
"Foreign Column Name",
"The name of the database column that this foreign key references."
)
Expand Down
Expand Up @@ -59,8 +59,7 @@ protected Stream<PropertySheet.Item> guiVisibleProperties() {
return Stream.of(
new EnumPropertyItem<>(
OrderType.class,
orderType,
getClass().getSimpleName(),
orderType,
"Ordering",
"The default ordering to use for this index."
)
Expand Down
Expand Up @@ -65,8 +65,7 @@ public IndexProperty(Speedment speedment, Table parent, Index prototype) {
protected Stream<PropertySheet.Item> guiVisibleProperties() {
return Stream.of(
new BooleanPropertyItem(
unique,
getClass().getSimpleName(),
unique,
"Is Unique",
"True if elements in this index are unique."
)
Expand Down
Expand Up @@ -78,14 +78,12 @@ public ProjectProperty(Speedment speedment, Project prototype) {
protected Stream<PropertySheet.Item> guiVisibleProperties() {
return Stream.of(
new StringPropertyItem(
packageName,
getClass().getSimpleName(),
packageName,
"Package Name",
"The name of the package to place all generated files in. This should be a fully qualified java package name."
),
new StringPropertyItem(
packageLocation,
getClass().getSimpleName(),
packageLocation,
"Package Location",
"The folder to store all generated files in. This should be a relative name from the working directory."
)
Expand Down
Expand Up @@ -89,41 +89,35 @@ public SchemaProperty(Speedment speedment, Dbms parent, Schema prototype) {
protected Stream<PropertySheet.Item> guiVisibleProperties() {
return Stream.of(
new StringPropertyItem(
schemaName,
getClass().getSimpleName(),
schemaName,
"Schema Name",
"The name for this schema in the database."
),
new StringPropertyItem(
catalogName,
getClass().getSimpleName(),
catalogName,
"Package Location",
"The catalog name for this schema."
),
new BooleanPropertyItem(
defaultSchema,
getClass().getSimpleName(),
defaultSchema,
"Is Default Schema",
"True if this is the default schema to use."
),
new EnumPropertyItem(
FieldStorageType.class,
fieldStorageType,
"Internal Implementation",
fieldStorageType,
"Field Storage Type",
"The default type of storage to use for entities of this kind."
),
new EnumPropertyItem(
ColumnCompressionType.class,
columnCompressionType,
"Internal Implementation",
columnCompressionType,
"Column Compression Type",
"The default compression strategy to use for entities of this kind."
),
new EnumPropertyItem(
StorageEngineType.class,
storageEngineType,
"Internal Implementation",
storageEngineType,
"Storage Engine Type",
"The default storage engine to use for entities of this kind."
)
Expand Down
Expand Up @@ -93,29 +93,25 @@ public TableProperty(Speedment speedment, Schema parent, Table prototype) {
protected Stream<PropertySheet.Item> guiVisibleProperties() {
return Stream.of(
new StringPropertyItem(
tableName,
getClass().getSimpleName(),
tableName,
"Table Name",
"The name that is used for this entity in the database."
),
new EnumPropertyItem(
FieldStorageType.class,
fieldStorageType,
"Internal Implementation",
fieldStorageType,
"Field Storage Type",
"The type of storage to use for entities of this kind."
),
new EnumPropertyItem(
ColumnCompressionType.class,
columnCompressionType,
"Internal Implementation",
columnCompressionType,
"Column Compression Type",
"The compression strategy to use for entities of this kind."
),
new EnumPropertyItem(
StorageEngineType.class,
storageEngineType,
"Internal Implementation",
storageEngineType,
"Storage Engine Type",
"The storage engine to use for entities of this kind."
)
Expand Down
Expand Up @@ -32,8 +32,8 @@
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.control.TitledPane;
import javafx.scene.control.TreeItem;
import javafx.scene.layout.StackPane;
import org.controlsfx.control.PropertySheet;

/**
Expand All @@ -45,7 +45,7 @@ public final class WorkspaceController implements Initializable {
private final UISession session;
private final ObservableList<PropertySheet.Item> properties;

private @FXML StackPane workspace;
private @FXML TitledPane workspace;

private WorkspaceController(UISession session) {
this.session = requireNonNull(session);
Expand All @@ -57,23 +57,35 @@ private WorkspaceController(UISession session) {
.addListener((ListChangeListener.Change<? extends TreeItem<AbstractNodeProperty>> change) -> {
properties.clear();

MapStream.fromValues(
change.getList().stream()
.map(TreeItem::getValue)
.flatMap(node -> node.getGuiVisibleProperties()),
property -> property.getName()
).groupingBy(item -> item.getName())
.mapValue(list ->
list.stream().reduce((a, b) -> {
if (a == null || b == null) {
return null;
} else {
if (Objects.equals(a.getValue(), b.getValue())) {
return a;
} else return null;
}
}).orElse(null)
).values().forEach(properties::add);
if (!change.getList().isEmpty()) {
final TreeItem<AbstractNodeProperty> treeItem = change.getList().get(0);

if (treeItem != null) {
final AbstractNodeProperty node = treeItem.getValue();
node.getGuiVisibleProperties()
.forEachOrdered(properties::add);
}
}

// MapStream.fromValues(
// change.getList().stream().sequential()
// .map(TreeItem::getValue)
// .flatMap(node -> node.getGuiVisibleProperties()),
// property -> property.getName()
// ).groupingBy(item -> item.getName())
// .mapValue(list ->
// list.stream().reduce((a, b) -> {
// if (a == null || b == null) {
// return null;
// } else {
// if (Objects.equals(a.getValue(), b.getValue())) {
// return a;
// } else return null;
// }
// }).orElse(null)
// ).values()
// .filter(item -> item != null)
// .forEach(properties::add);
});
}

Expand All @@ -82,8 +94,8 @@ public void initialize(URL location, ResourceBundle resources) {

final PropertySheet sheet = new PropertySheet(properties);

sheet.setMode(PropertySheet.Mode.CATEGORY);
sheet.setModeSwitcherVisible(true);
sheet.setMode(PropertySheet.Mode.NAME);
sheet.setModeSwitcherVisible(false);
sheet.setSearchBoxVisible(true);
sheet.setPropertyEditorFactory(item -> {
if (item instanceof AbstractPropertyItem<?, ?>) {
Expand All @@ -95,7 +107,7 @@ public void initialize(URL location, ResourceBundle resources) {
);
});

workspace.getChildren().add(sheet);
workspace.setContent(sheet);
}

public static Node create(UISession session) {
Expand Down
Expand Up @@ -32,13 +32,11 @@
public abstract class AbstractPropertyItem<T, PROPERTY extends ObservableValue<T> & WritableValue<T>> implements PropertySheet.Item {

private final PROPERTY property;
private final String category;
private final String name;
private final String description;

protected AbstractPropertyItem(PROPERTY property, String category, String name, String description) {
protected AbstractPropertyItem(PROPERTY property, String name, String description) {
this.property = requireNonNull(property);
this.category = requireNonNull(category);
this.name = requireNonNull(name);
this.description = requireNonNull(description);
}
Expand All @@ -47,7 +45,7 @@ protected AbstractPropertyItem(PROPERTY property, String category, String name,

@Override
public final String getCategory() {
return category;
return "Node";
}

@Override
Expand Down
Expand Up @@ -26,8 +26,8 @@
*/
public final class BooleanPropertyItem extends AbstractPropertyItem<Boolean, BooleanProperty> {

public BooleanPropertyItem(BooleanProperty value, String category, String name, String description) {
super(value, category, name, description);
public BooleanPropertyItem(BooleanProperty value, String name, String description) {
super(value, name, description);
}

@Override
Expand Down
Expand Up @@ -31,8 +31,8 @@ public final class EnumPropertyItem<E extends Enum<E>> extends AbstractPropertyI

private final Class<E> enumType;

public EnumPropertyItem(Class<E> enumType, Property<E> property, String category, String name, String description) {
super(property, category, name, description);
public EnumPropertyItem(Class<E> enumType, Property<E> property, String name, String description) {
super(property, name, description);
this.enumType = requireNonNull(enumType);
}

Expand Down
Expand Up @@ -26,8 +26,8 @@
*/
public final class IntegerPropertyItem extends AbstractPropertyItem<Number, IntegerProperty> {

public IntegerPropertyItem(IntegerProperty value, String category, String name, String description) {
super(value, category, name, description);
public IntegerPropertyItem(IntegerProperty value, String name, String description) {
super(value, name, description);
}

@Override
Expand Down
Expand Up @@ -26,8 +26,8 @@
*/
public final class StringPasswordPropertyItem extends AbstractPropertyItem<String, StringProperty> {

public StringPasswordPropertyItem(StringProperty value, String category, String name, String description) {
super(value, category, name, description);
public StringPasswordPropertyItem(StringProperty value, String name, String description) {
super(value, name, description);
}

@Override
Expand Down

0 comments on commit da85ea3

Please sign in to comment.