Merge branch 'designer-clear-toolbar' into designer-breadcrumbbar

This commit is contained in:
Clément Fournier
2019-01-13 21:49:10 +01:00
4 changed files with 40 additions and 24 deletions

View File

@ -135,14 +135,16 @@ public class MainDesignerController extends AbstractController {
// the editor controller will initialize this after this controller
sourceEditorController.focusNodeParentageCrumbBar = focusNodeParentageBreadCrumbBar;
Platform.runLater(this::updateRecentFilesMenu);
Platform.runLater(this::refreshAST); // initial refreshing
Platform.runLater(() -> sourceEditorController.moveCaret(0, 0));
}
@Override
protected void afterChildrenInit() {
updateRecentFilesMenu();
refreshAST(); // initial refreshing
sourceEditorController.moveCaret(0, 0);
}
public void shutdown() {
try {
SettingsPersistenceUtil.persistProperties(this, DesignerUtil.getSettingsFile());

View File

@ -137,9 +137,6 @@ public class XPathPanelController extends AbstractController {
.or(xpathVersionProperty().changes())
.subscribe(tick -> parent.refreshXPathResults());
// init autocompletion
Supplier<CompletionResultSource> suggestionMaker = () -> XPathCompletionSource.forLanguage(parent.getLanguageVersion().getLanguage());
new XPathAutocompleteProvider(xpathExpressionArea, suggestionMaker).initialiseAutoCompletion();
}
@ -147,9 +144,25 @@ public class XPathPanelController extends AbstractController {
@Override
protected void afterParentInit() {
bindToParent();
// init autocompletion only after binding to parent and settings restore
// otherwise the popup is shown on startup
Supplier<CompletionResultSource> suggestionMaker = () -> XPathCompletionSource.forLanguage(parent.getLanguageVersion().getLanguage());
new XPathAutocompleteProvider(xpathExpressionArea, suggestionMaker).initialiseAutoCompletion();
}
// Binds the underlying rule parameters to the parent UI, disconnecting it from the wizard if need be
private void bindToParent() {
DesignerUtil.rewire(getRuleBuilder().languageProperty(), Val.map(parent.languageVersionProperty(), LanguageVersion::getLanguage));
DesignerUtil.rewireInit(getRuleBuilder().xpathVersionProperty(), xpathVersionProperty());
DesignerUtil.rewireInit(getRuleBuilder().xpathExpressionProperty(), xpathExpressionProperty());
DesignerUtil.rewireInit(getRuleBuilder().rulePropertiesProperty(),
propertyTableView.rulePropertiesProperty(), propertyTableView::setRuleProperties);
}
private void initialiseVersionSelection() {
ToggleGroup xpathVersionToggleGroup = new ToggleGroup();
@ -214,17 +227,6 @@ public class XPathPanelController extends AbstractController {
}
// Binds the underlying rule parameters to the parent UI, disconnecting it from the wizard if need be
private void bindToParent() {
DesignerUtil.rewire(getRuleBuilder().languageProperty(),
Val.map(parent.languageVersionProperty(), LanguageVersion::getLanguage));
DesignerUtil.rewire(getRuleBuilder().xpathVersionProperty(), xpathVersionProperty());
DesignerUtil.rewire(getRuleBuilder().xpathExpressionProperty(), xpathExpressionProperty());
DesignerUtil.rewireInit(getRuleBuilder().rulePropertiesProperty(),
propertyTableView.rulePropertiesProperty(), propertyTableView::setRuleProperties);
}
/**

View File

@ -34,12 +34,12 @@ public class ObservableXPathRuleBuilder extends ObservableRuleBuilder {
}
@PersistentProperty
public Var<String> xpathVersionProperty() {
return xpathVersion;
}
@PersistentProperty
public String getXpathExpression() {
return xpathExpression.getValue();
}

View File

@ -34,14 +34,16 @@ public class AbstractController implements Initializable, SettingsOwner {
public final void initialize(URL url, ResourceBundle resourceBundle) {
beforeParentInit();
for (AbstractController child : getChildren()) {
Platform.runLater(child::afterParentInit);
child.afterParentInit();
}
afterChildrenInit();
}
/**
* Executed before the parent's initialization.
* Always executed once.
* Always executed once at the start of the initialization
* of this controller.
*/
protected void beforeParentInit() {
// by default do nothing
@ -49,8 +51,8 @@ public class AbstractController implements Initializable, SettingsOwner {
/**
* Executed after the parent's initialization. This also means,
* after persistent settings restoration. If this node has no
* Executed after the parent's initialization (so after {@link #afterChildrenInit()}).
* This also means, after persistent settings restoration. If this node has no
* parent, then this is never executed.
*/
protected void afterParentInit() {
@ -58,6 +60,16 @@ public class AbstractController implements Initializable, SettingsOwner {
}
/**
* Runs once after every child has finished their initialization.
* This will be run in all cases. It's only useful if the children
* do something useful in their {@link #afterParentInit()}.
*/
protected void afterChildrenInit() {
// by default do nothing
}
@Override
public List<? extends SettingsOwner> getChildrenSettingsNodes() {
return getChildren();