use of org.openide.windows.Mode in project ACS by ACS-Community.
the class WindowUtils method findTopComponent.
/**
* Utility method: Returns the TopComponent with the given programmatic name in the given workspace,
* or <code>null</code> if there is no such TopComponent.
* @param workspace the workspace in which to look for the TopComponent
* @param componentName the programmatic name of the TopComponent
* @return Returns the TopComponent with the given programmatic name,
* or <code>null</code> if there is no such TopComponent
*/
public static TopComponent findTopComponent(Workspace workspace, String componentName) {
Assertion.assertTrue(workspace != null, "workspace != null");
Assertion.assertTrue(componentName != null, "componentName != null");
Iterator modesIterator = workspace.getModes().iterator();
while (modesIterator.hasNext()) {
Mode mode = (Mode) modesIterator.next();
TopComponent[] tcs = mode.getTopComponents();
for (int i = 0; i < tcs.length; i++) {
TopComponent element = tcs[i];
if (element.getName().equals(componentName)) {
return element;
}
}
}
return null;
}
use of org.openide.windows.Mode 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;
}
use of org.openide.windows.Mode in project ACS by ACS-Community.
the class WindowUtils method openInMode.
/**
* Utility method: opens a topcomponent in the given workspace in a mode with the
* indicated name. This method first looks if the mode already exists, or else
* creates it.
* @param workspace the workspace top open the component in
* @param component the component to open
* @param modeName the (code) name of the mode
* @param frameType indicates the type of the window frame,
* should be one of {@link #INTERNAL_FRAME}, {@link #TOP_FRAME}, or {@link #DESKTOP_FRAME}
* @return the mode the topcomponent was opened in.
*/
public static Mode openInMode(Workspace workspace, TopComponent component, String modeName, int frameType) {
Assertion.assertTrue(workspace != null, "workspace != null");
Assertion.assertTrue(component != null, "component != null");
Assertion.assertTrue(modeName != null, "modeName != null");
setPersistMode(component, PERSIST_NEVER);
Mode mode = workspace.findMode(modeName);
if (mode == null) {
mode = workspace.createMode(modeName, modeName, null);
}
mode.dockInto(component);
workspace.activate();
frameResidesInDesktop(mode, frameType);
component.open(workspace);
component.requestFocus();
return mode;
}
use of org.openide.windows.Mode in project enclojure by EricThorsen.
the class ReplTopComponent method open.
@Override
public void open() {
// Open the repl in the output pane by default
Mode m = WindowManager.getDefault().findMode("output");
if (m != null) {
m.dockInto(this);
}
super.open();
}
Aggregations