Skip to content

Commit

Permalink
feat: Add DockSystem#validate.
Browse files Browse the repository at this point in the history
  • Loading branch information
teletha committed Mar 14, 2022
1 parent c4dacab commit ff2b1f8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main/java/viewtify/ui/dock/DockSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ static void requestSavingLayout() {
layout().save.accept(true);
}

/**
* Validate dock system. Clean up the invalidate area.
*/
public static void validate() {
layout().roots.forEach(RootArea::validate);
}

/**
* Register a new view within this dock system.
* <p/>
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/viewtify/ui/dock/TabArea.java
Original file line number Diff line number Diff line change
Expand Up @@ -291,4 +291,15 @@ private boolean compare(String tester, String test) {
protected boolean hasView(String id) {
return viewInitial.contains(id);
}

/**
* {@inheritDoc}
*/
@Override
protected void validate() {
if (getIds().isEmpty()) {
parent.remove(this);
}
}

}
11 changes: 11 additions & 0 deletions src/main/java/viewtify/ui/dock/ViewArea.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import javafx.geometry.Orientation;
import javafx.scene.Parent;

import kiss.Managed;
import viewtify.ui.UITab;
import viewtify.ui.UserInterface;
Expand Down Expand Up @@ -216,4 +217,14 @@ protected void setViewportRatio(double ratio) {
protected void setLocation(int kind) {

}

/**
* Validate myself.
*/
protected void validate() {
// don't use iterator to avoid ConcurrentModificationException
for (int i = children.size() - 1; 0 <= i; i--) {
children.get(i).validate();
}
}
}

0 comments on commit ff2b1f8

Please sign in to comment.