use of org.netbeans.core.windows.WindowManagerImpl in project netbeans-rcp-lite by outersky.
the class DocumentsDlg method activate.
// GEN-LAST:event_closeDocuments
private void activate(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_activate
// Add your handling code here:
Node[] selNodes = explorer.getSelectedNodes();
if (selNodes.length == 0) {
return;
}
closeDialog();
final TopComponent tc = ((TopComponentNode) selNodes[0]).getTopComponent();
// Call using invokeLater to make sure it is performed after dialog
// is closed.
SwingUtilities.invokeLater(new Runnable() {
public void run() {
// #37226-41075 Unmaximized the other mode if needed.
WindowManagerImpl wm = WindowManagerImpl.getInstance();
ModeImpl mode = (ModeImpl) wm.findMode(tc);
if (mode != null && mode != wm.getCurrentMaximizedMode()) {
wm.switchMaximizedMode(null);
}
tc.requestActive();
}
});
}
use of org.netbeans.core.windows.WindowManagerImpl in project netbeans-rcp-lite by outersky.
the class SlideBar method getRestoreModeNameForTab.
private String getRestoreModeNameForTab(TabData tab) {
Component c = tab.getComponent();
if (c instanceof TopComponent) {
WindowManagerImpl wm = WindowManagerImpl.getInstance();
String tcId = wm.findTopComponentID((TopComponent) c);
if (null != tcId) {
Mode prevMode = wm.getPreviousModeForTopComponent(tcId, tabbed.getSlidingMode());
if (null != prevMode)
return prevMode.getName();
}
}
return null;
}
use of org.netbeans.core.windows.WindowManagerImpl in project netbeans-rcp-lite by outersky.
the class SlideBar method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
if (e instanceof TabActionEvent) {
TabActionEvent tae = (TabActionEvent) e;
if (TabbedContainer.COMMAND_RESTORE_GROUP.equals(tae.getActionCommand())) {
String nameOfModeToRestore = tae.getGroupName();
WindowManagerImpl wm = WindowManagerImpl.getInstance();
ModeImpl modeToRestore = (ModeImpl) wm.findMode(nameOfModeToRestore);
if (null != modeToRestore) {
wm.userRestoredMode(tabbed.getSlidingMode(), modeToRestore);
}
}
}
}
use of org.netbeans.core.windows.WindowManagerImpl in project netbeans-rcp-lite by outersky.
the class GroupsManager method closeGroup.
boolean closeGroup(DocumentGroupImpl group) {
// NOI18N
TopComponent welcomeTc = WindowManager.getDefault().findTopComponent("Welcome");
boolean welcomeWasOpened = null != welcomeTc && welcomeTc.isOpened();
// save the window system first
Lookup.getDefault().lookup(WindowSystem.class).save();
// collect documents
WindowManagerImpl wmi = WindowManagerImpl.getInstance();
ArrayList<TopComponent> documents = new ArrayList<>(TopComponent.getRegistry().getOpened().size());
for (TopComponent tc : TopComponent.getRegistry().getOpened()) {
if (wmi.isEditorTopComponent(tc)) {
documents.add(tc);
}
}
String name = group.getName();
File userDir = Places.getUserDirectory();
// NOI18N
File root = new File(new File(userDir, "config"), DOCUMENT_GROUPS);
File groupDir = new File(root, name);
// remove old data (if any)
deleteAll(groupDir);
groupDir.mkdirs();
FileObject groupFO = FileUtil.toFileObject(groupDir);
Preferences prefs = getPreferences().node(name);
try {
prefs.clear();
} catch (BackingStoreException ex) {
LOG.log(Level.INFO, null, ex);
}
prefs.put(DISPLAY_NAME, group.toString());
File configRoot = new File(new File(Places.getUserDirectory(), CONFIG), WINDOWS2_LOCAL);
File modesRoot = new File(configRoot, MODES);
for (ModeImpl mode : wmi.getModes()) {
if (mode.getKind() == Constants.MODE_KIND_EDITOR) {
String modeName = mode.getName();
// NOI18N //NOI18N
FileObject modeFO = FileUtil.toFileObject(new File(modesRoot, modeName + "." + WSMODE));
if (null == modeFO) {
continue;
}
try {
modeFO.copy(groupFO, modeName, WSMODE);
} catch (IOException ex) {
LOG.log(Level.INFO, null, ex);
continue;
}
StringBuilder sb = new StringBuilder();
for (String id : mode.getOpenedTopComponentsIDs()) {
sb.append(id);
sb.append(ID_SEPARATOR);
}
prefs.put(modeName, sb.toString());
}
}
// copy TopComponents
File componentRoot = new File(configRoot, COMPONENTS);
for (TopComponent tc : documents) {
String id = wmi.findTopComponentID(tc);
if (tc.equals(welcomeTc) && !welcomeWasOpened)
continue;
if (tc.getPersistenceType() == TopComponent.PERSISTENCE_NEVER) {
continue;
}
// NOI18N //NOI18N
FileObject tcFO = FileUtil.toFileObject(new File(componentRoot, id + "." + SETTINGS));
if (tcFO == null) {
continue;
}
try {
tcFO.copy(groupFO, id, SETTINGS);
} catch (IOException ex) {
LOG.log(Level.INFO, null, ex);
}
}
// TODO save recent view list
// NOI18N
getPreferences().put(SEL_GROUP, "");
return true;
}
use of org.netbeans.core.windows.WindowManagerImpl in project netbeans-rcp-lite by outersky.
the class SwitchRoleKeepDocumentsAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
String role = e.getActionCommand();
WindowManagerImpl wm = WindowManagerImpl.getInstance();
wm.setRole(role, true);
}
Aggregations