Edit docking group constraints and qualify document tab behavior in IntelliJ
This commit is contained in:
@@ -47,7 +47,11 @@ final class GridDockDocument {
|
||||
"releaseSpaceWhenEmpty",
|
||||
"collapsible",
|
||||
"preferredWidth",
|
||||
"preferredHeight"),
|
||||
"preferredHeight",
|
||||
"minimumWidth",
|
||||
"minimumHeight",
|
||||
"persistent",
|
||||
"splitDirections"),
|
||||
"DockSplitDefinition", List.of("destinationId", "orientation", "position"));
|
||||
|
||||
static List<String> options(String field) {
|
||||
@@ -56,6 +60,7 @@ final class GridDockDocument {
|
||||
"groupingEnabled",
|
||||
"groupsCollapsed",
|
||||
"visibleWhenEmpty",
|
||||
"persistent",
|
||||
"releaseSpaceWhenEmpty",
|
||||
"collapsible" ->
|
||||
List.of("true", "false");
|
||||
@@ -63,6 +68,7 @@ final class GridDockDocument {
|
||||
case "selectionMode" -> List.of("NONE", "SINGLE", "MULTIPLE");
|
||||
case "tabSide" -> List.of("TOP", "RIGHT", "BOTTOM", "LEFT");
|
||||
case "mode" -> List.of("DOCKED", "OVERLAY");
|
||||
case "splitDirections" -> List.of("ALL", "NONE", "HORIZONTAL", "VERTICAL");
|
||||
case "orientation" -> List.of("HORIZONTAL", "VERTICAL");
|
||||
case "kind" -> List.of("TEXT", "INTEGER", "DECIMAL", "BOOLEAN");
|
||||
default -> List.of();
|
||||
@@ -246,14 +252,22 @@ final class GridDockDocument {
|
||||
&& Set.of(
|
||||
"width",
|
||||
"minimumWidth",
|
||||
"minimumHeight",
|
||||
"maximumWidth",
|
||||
"preferredWidth",
|
||||
"preferredHeight",
|
||||
"position")
|
||||
.contains(field)) {
|
||||
double n = Double.parseDouble(value);
|
||||
if (!Double.isFinite(n) || n <= 0 || field.equals("position") && n >= 1)
|
||||
boolean groupMinimum =
|
||||
type(e).equals("DockGroupDefinition")
|
||||
&& (field.equals("minimumWidth") || field.equals("minimumHeight"));
|
||||
if (groupMinimum) {
|
||||
if (!Double.isFinite(n) || n < 0)
|
||||
throw new IllegalArgumentException("Enter a finite group minimum of 0 or more pixels.");
|
||||
} else if (!Double.isFinite(n) || n <= 0 || field.equals("position") && n >= 1) {
|
||||
throw new IllegalArgumentException("Invalid " + field);
|
||||
}
|
||||
}
|
||||
if (!value.isEmpty()
|
||||
&& Set.of("pageSize", "maximumPageSize").contains(field)
|
||||
|
||||
@@ -241,6 +241,16 @@ final class GridDockEditor extends VBox {
|
||||
visible(apply, editable);
|
||||
visible(value, editable);
|
||||
if (!editable) return;
|
||||
String hint =
|
||||
doc.type(e).equals("DockGroupDefinition")
|
||||
? switch (field) {
|
||||
case "minimumWidth", "minimumHeight" -> "Default: 80 px";
|
||||
case "persistent" -> "Default: true";
|
||||
case "splitDirections" -> "Default: ALL";
|
||||
default -> "";
|
||||
}
|
||||
: "";
|
||||
value.setPromptText(hint);
|
||||
value.getItems().setAll(GridDockDocument.options(field));
|
||||
value.setValue(e.getAttribute(field));
|
||||
value.getEditor().setText(e.getAttribute(field));
|
||||
|
||||
@@ -5,6 +5,31 @@ import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class GridDockDocumentTest {
|
||||
@Test
|
||||
void dockMinimaAllowZeroWithoutChangingGridColumnRules() throws Exception {
|
||||
var source =
|
||||
"<?import de.neitzel.fx.docking.*?><DockGroupDefinition destinationId='messages'/>";
|
||||
var doc = new GridDockDocument(source);
|
||||
var group = doc.xml.elements.getFirst();
|
||||
for (String field : java.util.List.of("minimumWidth", "minimumHeight")) {
|
||||
for (String invalid : java.util.List.of("-1", "NaN", "Infinity", "wide"))
|
||||
assertThrows(IllegalArgumentException.class, () -> doc.set(group, field, invalid));
|
||||
var changed = new GridDockDocument(doc.xml.source.apply(doc.set(group, field, "0")));
|
||||
var reset =
|
||||
new GridDockDocument(
|
||||
changed.xml.source.apply(changed.set(changed.xml.elements.getFirst(), field, "")));
|
||||
var result = reset.xml.elements.getFirst();
|
||||
assertFalse(result.hasAttribute(field));
|
||||
assertEquals("messages", result.getAttribute("destinationId"));
|
||||
}
|
||||
assertThrows(IllegalArgumentException.class, () -> doc.set(group, "persistent", "yes"));
|
||||
assertThrows(IllegalArgumentException.class, () -> doc.set(group, "splitDirections", "RIGHT"));
|
||||
var grid = new GridDockDocument("<?import de.neitzel.fx.view.*?><DataGridColumn/>");
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> grid.set(grid.xml.elements.getFirst(), "minimumWidth", "0"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void updatingOneGroupLabelRetainsReferencesCommentsAndNestedEntries() throws Exception {
|
||||
String source =
|
||||
|
||||
Reference in New Issue
Block a user