Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public Object clone() {
HashSet set = (HashSet)dockables.clone();
FloatingGroup clone = new FloatingGroup(name, set);
clone.frame = frame;
clone.windowBounds = (Rectangle)windowBounds.clone();
clone.windowBounds = getBounds();
return clone;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,14 @@ public Element serialize(Document document, Object object) {
Element floatingGroupElement = document.createElement(PersistenceConstants.FLOATING_GROUP_ELEMENT_NAME);
floatingGroupElement.setAttribute(PersistenceConstants.FLOATING_GROUP_ATTRIBUTE_NAME, floatingGroup.getName());

ISerializer rectangleSerializer = SerializerRegistry.getSerializer(Rectangle.class);
Element rectangleElement = rectangleSerializer.serialize(document, floatingGroup.getBounds());
floatingGroupElement.appendChild(rectangleElement);
// Bounds are null until the group's frame is first shown; deserialize
// already accepts a missing Rectangle element
Rectangle bounds = floatingGroup.getBounds();
if (bounds != null) {
ISerializer rectangleSerializer = SerializerRegistry.getSerializer(Rectangle.class);
Element rectangleElement = rectangleSerializer.serialize(document, bounds);
floatingGroupElement.appendChild(rectangleElement);
}

for (Iterator it = floatingGroup.getDockableIterator(); it.hasNext();) {
String dockableId = (String) it.next();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,16 @@ void testGroupWithoutDockablesSurvives() throws Exception {
assertEquals(0, result.getDockableCount());
}

// Known bug (https://github.com/opencollab/flexdock/issues/32):
// a group whose bounds were never set cannot be serialized (NPE in
// RectangleSerializer). Once fixed, assertThrows fails: round-trip the group instead and
// check that its bounds stay null.
@Test
void testGroupWithoutBoundsKnownBug() {
void testGroupWithoutBoundsSurvives() throws Exception {
FloatingGroup group = new FloatingGroup("unbounded");
group.addDockable("first");

FloatingGroup result = (FloatingGroup) XmlRoundTrip.roundTrip(serializer, group);

assertThrows(NullPointerException.class, () -> XmlRoundTrip.roundTrip(serializer, group));
assertEquals("unbounded", result.getName());
assertNull(result.getBounds());
assertEquals(getDockableIds(group), getDockableIds(result));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,16 @@ void testCloneCopiesFloatingGroups() {
assertEquals(new Rectangle(5, 6, 7, 8), clone.getGroup("state.group").getBounds());
}

@Test
void testCloneCopiesFloatingGroupWithoutBounds() {
layout.addFloatingGroup(new FloatingGroup("state.unbounded"));

Layout clone = (Layout) layout.clone();

assertNotNull(clone.getGroup("state.unbounded"));
assertNull(clone.getGroup("state.unbounded").getBounds());
}

@Test
void testDockableJoinsOneFloatingGroupAtATime() {
layout.add(known);
Expand Down
1 change: 1 addition & 0 deletions release-notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Fixes:
* DockingSplitPane: apply the percentage consistently in setDividerLocation()
* DockingSplitPane: keep the percentage set before the size is known
* UIFactory: create a custom theme under a look and feel without a theme mapping
* FloatingGroup: save and clone a floating group whose bounds were never set

== flexdock 1.3 RELEASE NOTES ==

Expand Down
Loading