Skip to content

Commit

Permalink
Rewrite the observable config model base class
Browse files Browse the repository at this point in the history
  • Loading branch information
Emil Forslund committed Jan 21, 2016
1 parent e135848 commit 051c0fe
Show file tree
Hide file tree
Showing 16 changed files with 282 additions and 450 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -378,7 +378,7 @@
<!-- LICENSE INFORMATION <!-- LICENSE INFORMATION
FontawesomeFX:8.8 FontawesomeFX:8.8
Apache 2 License Apache 2 License
http://logging.apache.org/log4j/2.x/license.html http://www.apache.org/licenses/LICENSE-2.0.txt
2015-12-04 2015-12-04
emifor emifor
--> -->
Expand Down

Large diffs are not rendered by default.

Expand Up @@ -26,15 +26,15 @@
* @author Emil Forslund * @author Emil Forslund
* @param <THIS> this class type * @param <THIS> this class type
*/ */
public abstract class AbstractRootDocumentProperty<THIS extends AbstractRootDocumentProperty<? super THIS>> public abstract class AbstractRootDocumentProperty<THIS extends AbstractRootDocumentProperty<? super THIS>>
extends AbstractDocumentProperty<THIS> { extends AbstractDocumentProperty<THIS> {


public AbstractRootDocumentProperty(Map<String, Object> data) { public AbstractRootDocumentProperty(Map<String, Object> data) {
super(data); super(data);
} }


@Override @Override
public final Optional<? extends Document> getParent() { public final Optional<? extends DocumentProperty> getParent() {
return Optional.empty(); return Optional.empty();
} }


Expand Down
Expand Up @@ -167,7 +167,4 @@ public String toString(TypeMapper<?, ?> typeMapper) {
} }
} }
}; };

@Override
public void prepare() { /* Do nothing since this document has no known children. */ }
} }
Expand Up @@ -145,12 +145,6 @@ public SchemaProperty addNewSchema() {
return created; return created;
} }



@Override
public void prepare() {
schemas().forEach(DocumentProperty::prepare);
}

@Override @Override
public String toString() { public String toString() {
return toStringHelper(this); return toStringHelper(this);
Expand Down
Expand Up @@ -50,7 +50,4 @@ public Stream<PropertySheet.Item> getUiVisibleProperties(Speedment speedment) {
public Class<? extends Document> mainInterface() { public Class<? extends Document> mainInterface() {
return Document.class; return Document.class;
} }

@Override
public void prepare() { /* Do nothing since this document has no known children. */ }
} }
Expand Up @@ -19,6 +19,7 @@
import com.speedment.config.Document; import com.speedment.config.Document;
import com.speedment.config.db.trait.HasMainInterface; import com.speedment.config.db.trait.HasMainInterface;
import com.speedment.exception.SpeedmentException; import com.speedment.exception.SpeedmentException;
import com.speedment.internal.ui.config.trait.HasExpandedProperty;
import com.speedment.internal.ui.config.trait.HasUiVisibleProperties; import com.speedment.internal.ui.config.trait.HasUiVisibleProperties;
import java.util.Map; import java.util.Map;
import java.util.function.BiFunction; import java.util.function.BiFunction;
Expand Down Expand Up @@ -62,7 +63,10 @@
* *
* @author Emil Forslund * @author Emil Forslund
*/ */
public interface DocumentProperty extends Document, HasUiVisibleProperties, HasMainInterface, Observable { public interface DocumentProperty extends Document,
HasUiVisibleProperties,
HasMainInterface,
Observable {


/** /**
* Wraps the specified String value in a property so that changes to it can * Wraps the specified String value in a property so that changes to it can
Expand Down Expand Up @@ -145,10 +149,9 @@ public interface DocumentProperty extends Document, HasUiVisibleProperties, HasM
* *
* @param <T> result type * @param <T> result type
* @param key the key to look at * @param key the key to look at
* @param type the expected result type
* @return an observable list of the documents under that key * @return an observable list of the documents under that key
*/ */
<T extends DocumentProperty> ObservableList<T> observableListOf(String key/*, Class<T> type*/); <T extends DocumentProperty> ObservableList<T> observableListOf(String key);


/** /**
* Returns a list of all children instantiated using * Returns a list of all children instantiated using
Expand Down Expand Up @@ -181,10 +184,4 @@ public interface DocumentProperty extends Document, HasUiVisibleProperties, HasM
* any events observing the tree will know the state has changed. * any events observing the tree will know the state has changed.
*/ */
void invalidate(); void invalidate();

/**
* Goes through all {@code ObservableList ObservableLists} in the tree and
* make sure every one has been initalized.
*/
void prepare();
} }
Expand Up @@ -105,7 +105,4 @@ public Column findForeignColumn() throws SpeedmentException {
public String toString() { public String toString() {
return toStringHelper(this); return toStringHelper(this);
} }

@Override
public void prepare() { /* Do nothing since this document has no known children. */ }
} }
Expand Up @@ -88,12 +88,6 @@ public boolean isExpandedByDefault() {
return false; return false;
} }



@Override
public void prepare() {
foreignKeyColumns().forEach(DocumentProperty::prepare);
}

@Override @Override
public String toString() { public String toString() {
return toStringHelper(this); return toStringHelper(this);
Expand Down
Expand Up @@ -52,7 +52,4 @@ public Stream<PropertySheet.Item> getUiVisibleProperties(Speedment speedment) {
public String toString() { public String toString() {
return toStringHelper(this); return toStringHelper(this);
} }

@Override
public void prepare() { /* Do nothing since this document has no known children. */ }
} }
Expand Up @@ -101,12 +101,6 @@ public boolean isExpandedByDefault() {
return false; return false;
} }



@Override
public void prepare() {
indexColumns().forEach(DocumentProperty::prepare);
}

@Override @Override
public String toString() { public String toString() {
return toStringHelper(this); return toStringHelper(this);
Expand Down
Expand Up @@ -48,7 +48,4 @@ public Stream<PropertySheet.Item> getUiVisibleProperties(Speedment speedment) {
public String toString() { public String toString() {
return toStringHelper(this); return toStringHelper(this);
} }

@Override
public void prepare() { /* Do nothing since this document has no known children. */ }
} }
Expand Up @@ -175,9 +175,4 @@ public String getName() throws SpeedmentException {
public String toString() { public String toString() {
return toStringHelper(this); return toStringHelper(this);
} }

@Override
public void prepare() {
dbmses().forEach(DocumentProperty::prepare);
}
} }
Expand Up @@ -103,12 +103,6 @@ public TableProperty addNewTable() {
return created; return created;
} }



@Override
public void prepare() {
tables().forEach(DocumentProperty::prepare);
}

@Override @Override
public String toString() { public String toString() {
return toStringHelper(this); return toStringHelper(this);
Expand Down
Expand Up @@ -151,15 +151,6 @@ public PrimaryKeyColumnProperty addNewPrimaryKeyColumn() {
return created; return created;
} }



@Override
public void prepare() {
columns().forEach(DocumentProperty::prepare);
indexes().forEach(DocumentProperty::prepare);
foreignKeys().forEach(DocumentProperty::prepare);
primaryKeyColumns().forEach(DocumentProperty::prepare);
}

@Override @Override
public String toString() { public String toString() {
return toStringHelper(this); return toStringHelper(this);
Expand Down
Expand Up @@ -99,7 +99,6 @@ private void prepareTree(ProjectProperty project) {
hierarchy.setCellFactory(view -> new DocumentPropertyCell(ui)); hierarchy.setCellFactory(view -> new DocumentPropertyCell(ui));
hierarchy.getSelectionModel().setSelectionMode(SINGLE); hierarchy.getSelectionModel().setSelectionMode(SINGLE);


project.prepare();
populateTree(project); populateTree(project);
} }


Expand Down

0 comments on commit 051c0fe

Please sign in to comment.