How would you reset the default layout? #189
-
I write a lot of how-to guides that require me to reset the default layout of the docking panels. How would I adapt the /**
* Persistent IDs were generated using <code>UUID.randomUUID().toString()</code>
* or <a href="https://www.uuidgenerator.net/">one of many websites</a>.
*/
private void createDefaultLayout() {
setSize(800, 600);
setLocationByPlatform(true);
RootDockingPanel root = new RootDockingPanel(this);
add(root, BorderLayout.CENTER);
DockingPanel renderView = new DockingPanel("8e50154c-a149-4e95-9db5-4611d24cc0cc", "3D view");
renderView.add(renderPanel, BorderLayout.CENTER);
Docking.dock(renderView, this, DockingRegion.CENTER);
windows.add(renderView);
DockingPanel treeView = new DockingPanel("c6b04902-7e53-42bc-8096-fa5d43289362", "Scene");
NodeTreeView nodeTreeView = new NodeTreeView();
treeView.add(nodeTreeView, BorderLayout.CENTER);
Docking.dock(treeView, this, DockingRegion.WEST);
windows.add(treeView);
DockingPanel detailView = new DockingPanel("67e45223-79f5-4ce2-b15a-2912228b356f", "Details");
NodeDetailView nodeDetailView = new NodeDetailView();
detailView.add(nodeDetailView, BorderLayout.CENTER);
Docking.dock(detailView, treeView, DockingRegion.SOUTH);
windows.add(detailView);
DockingPanel logView = new DockingPanel("5e565f83-9734-4281-9828-92cd711939df", "Log");
logView.add(logPanel, BorderLayout.CENTER);
windows.add(logView);
DockingPanel editorView = new DockingPanel("3f8f54e1-af78-4994-a1c2-21a68ec294c9", "Editor");
editorView.add(editPanel, BorderLayout.CENTER);
windows.add(editorView);
DockingPanel aboutView = new DockingPanel("976af87b-90f3-42ce-a5d6-e4ab663fbb15", "About");
aboutView.add(new AboutPanel(), BorderLayout.CENTER);
Docking.dock(aboutView,treeView,DockingRegion.CENTER);
windows.add(aboutView);
DockingPanel webcamView = new DockingPanel("1331fbb0-ceda-4c67-b343-6539d4f939a1", "USB Camera");
webcamView.add(webCamPanel, BorderLayout.CENTER);
windows.add(webcamView);
DockingPanel textInterfaceView = new DockingPanel("7796a733-8e33-417a-b363-b28174901e40", "Serial Interface");
textInterfaceView.add(textInterface, BorderLayout.CENTER);
windows.add(textInterfaceView);
} |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
I went with this solution. /**
* Persistent IDs were generated using <code>UUID.randomUUID().toString()</code>
* or <a href="https://www.uuidgenerator.net/">one of many websites</a>.
*/
private void createDefaultLayout() {
DockingPanel renderView = new DockingPanel("8e50154c-a149-4e95-9db5-4611d24cc0cc", "3D view");
renderView.add(renderPanel, BorderLayout.CENTER);
windows.add(renderView);
DockingPanel treeView = new DockingPanel("c6b04902-7e53-42bc-8096-fa5d43289362", "Scene");
NodeTreeView nodeTreeView = new NodeTreeView();
treeView.add(nodeTreeView, BorderLayout.CENTER);
windows.add(treeView);
DockingPanel detailView = new DockingPanel("67e45223-79f5-4ce2-b15a-2912228b356f", "Details");
NodeDetailView nodeDetailView = new NodeDetailView();
detailView.add(nodeDetailView, BorderLayout.CENTER);
windows.add(detailView);
DockingPanel logView = new DockingPanel("5e565f83-9734-4281-9828-92cd711939df", "Log");
logView.add(logPanel, BorderLayout.CENTER);
windows.add(logView);
DockingPanel editorView = new DockingPanel("3f8f54e1-af78-4994-a1c2-21a68ec294c9", "Editor");
editorView.add(editPanel, BorderLayout.CENTER);
windows.add(editorView);
DockingPanel aboutView = new DockingPanel("976af87b-90f3-42ce-a5d6-e4ab663fbb15", "About");
aboutView.add(new AboutPanel(), BorderLayout.CENTER);
windows.add(aboutView);
DockingPanel webcamView = new DockingPanel("1331fbb0-ceda-4c67-b343-6539d4f939a1", "USB Camera");
webcamView.add(webCamPanel, BorderLayout.CENTER);
windows.add(webcamView);
DockingPanel textInterfaceView = new DockingPanel("7796a733-8e33-417a-b363-b28174901e40", "Serial Interface");
textInterfaceView.add(textInterface, BorderLayout.CENTER);
windows.add(textInterfaceView);
}
/**
* Reset the default layout. These depend on the order of creation in createDefaultLayout().
*/
private void resetDefaultLayout() {
setSize(1000, 700);
for(DockingPanel w : windows) {
Docking.undock(w);
}
var renderView = windows.get(0);
var treeView = windows.get(1);
var detailView = windows.get(2);
var aboutView = windows.get(5);
Docking.dock(renderView, this, DockingRegion.CENTER);
Docking.dock(treeView, this, DockingRegion.WEST);
Docking.dock(detailView, treeView, DockingRegion.SOUTH);
Docking.dock(aboutView, treeView, DockingRegion.CENTER);
} |
Beta Was this translation helpful? Give feedback.
-
This is built into Modern Docking and can be seen in action in the demo. ApplicationLayout defaultLayout = new WindowLayoutBuilder(alwaysDisplayed.getPersistentID())
.dock(one.getPersistentID(), alwaysDisplayed.getPersistentID())
.dock(two.getPersistentID(), one.getPersistentID(), DockingRegion.SOUTH)
.dockToRoot(three.getPersistentID(), DockingRegion.WEST)
.dock(four.getPersistentID(), two.getPersistentID(), DockingRegion.CENTER)
.dock(propertiesDemoPanel.getPersistentID(), four.getPersistentID(), DockingRegion.CENTER)
.dockToRoot(output.getPersistentID(), DockingRegion.SOUTH)
.dockToRoot(themes.getPersistentID(), DockingRegion.EAST)
.dock(explorer.getPersistentID(), themes.getPersistentID(), DockingRegion.CENTER)
.display(themes.getPersistentID())
.buildApplicationLayout();
DockingLayouts.addLayout("default", defaultLayout);
AppState.setDefaultApplicationLayout(defaultLayout); This builds a layout from the persistent ID strings and regions, adds the layout to Layouts can be restored with JMenuItem restoreDefaultLayout = new ApplicationLayoutMenuItem("default", "Restore Default Layout");
window.add(restoreDefaultLayout); This will be better detailed in the new documentation. The wiki currently has a working with layouts page. But might not be complete. |
Beta Was this translation helpful? Give feedback.
-
Neat. I gave it a quick try. Couldn't figure out how to set the small icon for the |
Beta Was this translation helpful? Give feedback.
This is built into Modern Docking and can be seen in action in the demo.