# Custom ResourceWorkspace in Designer

**URL:** <https://forum.inductiveautomation.com/t/custom-resourceworkspace-in-designer/15614>\
**Category:** Module Development\
**Created:** [October 9, 2017, 9:16pm UTC](https://forum.inductiveautomation.com/t/custom-resourceworkspace-in-designer/15614 "2017-10-09T21:16:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 9, 2017, 9:16pm UTC](https://forum.inductiveautomation.com/t/custom-resourceworkspace-in-designer/15614/1 "2017-10-09T21:16:10Z")

</div>

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](http://files.inductiveautomation.com/sdk/javadoc/ignition79/793/com/inductiveautomation/ignition/designer/model/DesignerContext.html#registerResourceWorkspace-com.inductiveautomation.ignition.designer.model.ResourceWorkspace-) 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](http://files.inductiveautomation.com/sdk/javadoc/ignition79/793/com/inductiveautomation/ignition/designer/WorkspaceManager.html), but no obvious way to get a reference to it. Well, the [IgnitionDesigner](http://files.inductiveautomation.com/sdk/javadoc/ignition79/793/com/inductiveautomation/ignition/designer/IgnitionDesigner.html) 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. /-:

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [October 9, 2017, 9:45pm UTC](https://forum.inductiveautomation.com/t/custom-resourceworkspace-in-designer/15614/2 "2017-10-09T21:45:10Z")

</div>

ClientContext’s [`getRootPaneContainer`](http://files.inductiveautomation.com/sdk/javadoc/ignition79/793/com/inductiveautomation/ignition/client/model/ClientContext.html#getRootPaneContainer--) returns an [`IgnitionDesigner`](http://files.inductiveautomation.com/sdk/javadoc/ignition79/794-beta1/com/inductiveautomation/ignition/designer/IgnitionDesigner.html) from which you can call [`getWorkspace`](http://files.inductiveautomation.com/sdk/javadoc/ignition79/794-beta1/com/inductiveautomation/ignition/designer/IgnitionDesigner.html#getWorkspace--) to get the WorkspaceManager instance (which then allows you to `setSelectedWorkspace`):

```python
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())

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 9, 2017, 9:54pm UTC](https://forum.inductiveautomation.com/t/custom-resourceworkspace-in-designer/15614/3 "2017-10-09T21:54:56Z")

</div>

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”.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 9, 2017, 9:58pm UTC](https://forum.inductiveautomation.com/t/custom-resourceworkspace-in-designer/15614/4 "2017-10-09T21:58:01Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [October 9, 2017, 10:12pm UTC](https://forum.inductiveautomation.com/t/custom-resourceworkspace-in-designer/15614/5 "2017-10-09T22:12:50Z")

</div>

> [@pturmel](#):
>
> 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.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 9, 2017, 11:25pm UTC](https://forum.inductiveautomation.com/t/custom-resourceworkspace-in-designer/15614/6 "2017-10-09T23:25:39Z")

</div>

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. /-:

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 10, 2017, 5:05pm UTC](https://forum.inductiveautomation.com/t/custom-resourceworkspace-in-designer/15614/7 "2017-10-10T17:05:47Z")

</div>

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).
