use of org.openide.windows.Workspace in project ACS by ACS-Community.
the class WindowUtils method createWorkspace.
/**
* Utility method: creates a workspace and adds it to the WindowManager's list of workspaces.
* The new workspace will appear as the last one in the list.
*
* @param codeName the code name of the new workspace
* @param displayName the display name of the new workspace
*/
public static Workspace createWorkspace(String codeName, String displayName) {
Assertion.assertTrue(codeName != null, "codeName != null");
if (displayName == null || displayName.equalsIgnoreCase(""))
displayName = codeName;
Workspace[] workspaces = new Workspace[WindowManager.getDefault().getWorkspaces().length + 1];
Workspace[] currentList = WindowManager.getDefault().getWorkspaces();
int i = 0;
for (; i < currentList.length; i++) {
workspaces[i] = currentList[i];
}
Workspace ws = WindowManager.getDefault().createWorkspace(codeName, displayName);
workspaces[i] = ws;
WindowManager.getDefault().setWorkspaces(workspaces);
return ws;
}
use of org.openide.windows.Workspace in project ACS by ACS-Community.
the class WindowUtils method performDesktopFrameAction.
//
// -- implements XXX ----------------------------------------------
//
//
// -- PROTECTED METHODS -------------------------------------------
//
//
// -- PRIVATE METHODS ---------------------------------------------
//
private static boolean performDesktopFrameAction(Mode mode, TopComponent comp, ClassLoader classLoader, Class modeImplClass, Class windowUtilsClass) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, ClassNotFoundException {
Workspace ws = mode.getWorkspace();
Object currentConstraints = CONSTRAINT_WEST;
Method findConstrainedModeMethod = windowUtilsClass.getMethod("findConstrainedMode", new Class[] { Workspace.class, Object.class });
Object constrainedMode = findConstrainedModeMethod.invoke(null, new Object[] { ws, currentConstraints });
if (constrainedMode != null) {
Mode westMode = (Mode) constrainedMode;
Method getContainerInstanceMethod = modeImplClass.getMethod("getContainerInstance", null);
Object tcc = getContainerInstanceMethod.invoke(mode, null);
if (tcc != null) {
Class topComponentContainerClass = Class.forName("org.netbeans.core.windows.frames.TopComponentContainer", true, classLoader);
Method removeTopComponentMethod = topComponentContainerClass.getMethod("removeTopComponent", new Class[] { TopComponent.class });
removeTopComponentMethod.invoke(tcc, new Object[] { comp });
Method dockIntoMethod = modeImplClass.getMethod("dockInto", new Class[] { TopComponent.class, Object.class });
dockIntoMethod.invoke(westMode, new Object[] { comp, currentConstraints });
return true;
}
}
return false;
}