I’ve been poking around in the JavaDocs trying to figure out what I need to properly switch designer workspaces when a user clicks on one my custom NavTree nodes. The DesignerContext provides a method to register a new workspace, but I haven’t been able to figure out how to select it after registration. There appears to be an appropriate method of WorkspaceManager, but no obvious way to get a reference to it. Well, the IgnitionDesigner class offers getWorkspace(), but there’s no obvious way to get it either.
I’m guessing there’s a static method somewhere, but I haven’t found it. /-:
ClientContext’s getRootPaneContainer
returns an IgnitionDesigner
from which you can call getWorkspace
to get the WorkspaceManager instance (which then allows you to setSelectedWorkspace
):
workspaceManager = event.source.parent.getAppContext().getRootPaneContainer().getWorkspace()
for i in range(workspaceManager.getWorkspaceCount()):
if workspaceManager.getWorkspace(i).getKey() == 'webdev-workspace':
workspaceManager.setSelectedWorkspace(workspaceManager.getWorkspace(i).getKey())
Ah, I just figured out that the DesignerContext getFrame() method is actually returning an IgnitionDesigner object, too. Sneaky. I noticed that IgnitionDesigner inherits from JFrame and my brain went “ding ding ding”.
Ah ha! IgnitionDesigner has a static getFrame() method, too! And it yields an IgnitionDesigner!
Three solutions? Is there a proper solution that’s most likely to keep my Java module working over the next several versions?
I'll let someone better qualified answer that - but my WAG is that IgnitionDesigner.getFrame()
would be the best solution.
Well, that worked. New workspace loads and switches like it is supposed to, and with educated guesses on how ScriptTab works, I have my own script editor that looks just like the shared/project editor. With working function sidebar. Custom non-resource-based reload/deploy buttons in the lower right. Sweet.
I spoke too soon. Works in v7.7 and v7.8. It blew up in v7.9. AutoCompileCodeEditor is gone. /-:
I was wrong. AutoCompileCodeEditor is there, but with altered method names. Had to use reflection to work around it to have a multi-version module (loads in 7.7, 7.8, and 7.9).