Skip to content

Commit

Permalink
Avoids adding an empty group to the output display. (#180)
Browse files Browse the repository at this point in the history
When the CDI contains a group that has no name, no description and no data elements, we skip rendering an empty box.
  • Loading branch information
balazsracz committed Mar 21, 2021
1 parent a2d2910 commit 34bf899
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/org/openlcb/cdi/swing/CdiPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -871,16 +871,18 @@ public void visitGroup(ConfigRepresentation.GroupEntry e) {
super.visitGroup(e);
factory.handleGroupPaneEnd(groupPane);

if (oldPane instanceof SegmentPane) {
// we make toplevel groups collapsible.
groupPane.setBorder(null);
JPanel ret = new util.CollapsiblePanel(groupPane.getName(), groupPane);
// ret.setBorder(BorderFactory.createLineBorder(java.awt.Color.RED)); //debugging
ret.setAlignmentY(Component.TOP_ALIGNMENT);
ret.setAlignmentX(Component.LEFT_ALIGNMENT);
oldPane.add(ret);
} else {
oldPane.add(groupPane);
if (groupPane.getComponentCount() > 0) {
if (oldPane instanceof SegmentPane) {
// we make toplevel groups collapsible.
groupPane.setBorder(null);
JPanel ret = new util.CollapsiblePanel(groupPane.getName(), groupPane);
// ret.setBorder(BorderFactory.createLineBorder(java.awt.Color.RED)); //debugging
ret.setAlignmentY(Component.TOP_ALIGNMENT);
ret.setAlignmentX(Component.LEFT_ALIGNMENT);
oldPane.add(ret);
} else {
oldPane.add(groupPane);
}
}

// restore stack
Expand Down

0 comments on commit 34bf899

Please sign in to comment.