use of org.netbeans.core.windows.ModeImpl in project netbeans-rcp-lite by outersky.
the class MaximizeWindowAction method actionPerformed.
/**
* Perform the action. Sets/unsets maximzed mode.
*/
@Override
public void actionPerformed(java.awt.event.ActionEvent ev) {
state = !state;
getMenuItem().setSelected(state);
WindowManagerImpl wm = WindowManagerImpl.getInstance();
TopComponent curTC = getTCToWorkWith();
if (wm.isDocked(curTC)) {
// inside main window
ModeImpl mode = (ModeImpl) wm.findMode(curTC);
String tcID = wm.findTopComponentID(curTC);
if (mode.getKind() == Constants.MODE_KIND_SLIDING) {
// maximize/restore slided-in window
wm.userToggledTopComponentSlideInMaximize(tcID);
} else if (null != mode) {
ModeImpl previousMax = wm.getCurrentMaximizedMode();
if (null != previousMax) {
if (previousMax.getKind() == Constants.MODE_KIND_EDITOR && mode.getKind() == Constants.MODE_KIND_VIEW) {
wm.switchMaximizedMode(mode);
} else {
wm.switchMaximizedMode(null);
}
} else {
wm.switchMaximizedMode(mode);
}
} else {
wm.switchMaximizedMode(null);
}
} else {
// separate windows
ModeImpl curMax = (ModeImpl) wm.findMode(curTC);
if (curMax != null) {
if (curMax.getFrameState() == Frame.NORMAL) {
curMax.setFrameState(Frame.MAXIMIZED_BOTH);
} else {
curMax.setFrameState(Frame.NORMAL);
}
}
}
updateState();
}
use of org.netbeans.core.windows.ModeImpl in project netbeans-rcp-lite by outersky.
the class MinimizeWindowAction method checkEnabled.
private boolean checkEnabled() {
TopComponent context = TopComponent.getRegistry().getActivated();
if (null == context) {
return false;
}
SlideController slideController = (SlideController) SwingUtilities.getAncestorOfClass(SlideController.class, context);
if (null == slideController)
return false;
ModeImpl mode = (ModeImpl) WindowManagerImpl.getInstance().findMode(context);
if (null == mode)
return false;
if (WindowManagerImpl.getInstance().isTopComponentMinimized(context))
return false;
if (mode.getState() != Constants.MODE_STATE_JOINED)
return false;
if (mode.getKind() != Constants.MODE_KIND_VIEW)
return false;
return Switches.isTopComponentSlidingEnabled() && Switches.isSlidingEnabled(context);
}
use of org.netbeans.core.windows.ModeImpl in project netbeans-rcp-lite by outersky.
the class ResetWindowsAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
final WindowSystem ws = Lookup.getDefault().lookup(WindowSystem.class);
if (null == ws) {
// unsupported window system implementation
Logger.getLogger(ResetWindowsAction.class.getName()).log(Level.INFO, // NOI18N
"Reset Windows action does not support custom WindowSystem implementations.");
return;
}
final WindowManagerImpl wm = WindowManagerImpl.getInstance();
// cancel full-screen mode
MainWindow.getInstance().setFullScreenMode(false);
wm.getMainWindow().setExtendedState(JFrame.NORMAL);
// NOI18N
TopComponentGroupImpl projectTCGroup = (TopComponentGroupImpl) wm.findTopComponentGroup("OpenedProjects");
final boolean isProjectsTCGroupOpened = null != projectTCGroup && projectTCGroup.isOpened();
// get a list of editor windows that should stay open even after the reset
final TopComponent[] editors = collectEditors();
// close all other windows just in case they hold some references to editor windows
wm.closeNonEditorViews();
// hide the main window to hide some window operations before the actual reset is performed
wm.getMainWindow().setVisible(false);
// find an editor window that will be activated after the reset (may be null)
final TopComponent activeEditor = wm.getArbitrarySelectedEditorTopComponent();
// make sure that componentHidden() gets called on all opened and selected editors
// so that they can reset their respective states and/or release some listeners
wm.deselectEditorTopComponents();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
// find the local folder that must be deleted
try {
FileObject rootFolder = PersistenceManager.getDefault().getRootLocalFolder();
if (reset && null != rootFolder) {
for (FileObject fo : rootFolder.getChildren()) {
if (PersistenceManager.COMPS_FOLDER.equals(fo.getName()))
// do not delete settings files
continue;
fo.delete();
}
}
} catch (IOException ioE) {
ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ioE);
}
// reset the window system
ws.hide();
WindowManagerImpl.getInstance().resetModel();
// keep mappings to TopComponents created so far
PersistenceManager.getDefault().reset();
PersistenceHandler.getDefault().clear();
ws.load();
ws.show();
if (isProjectsTCGroupOpened) {
// NOI18N
TopComponentGroup tcGroup = wm.findTopComponentGroup("OpenedProjects");
if (null != tcGroup)
tcGroup.open();
}
// NOI18N
ModeImpl editorMode = (ModeImpl) wm.findMode("editor");
RegistryImpl registry = (RegistryImpl) TopComponent.getRegistry();
// re-open editor windows that were opened before the reset
for (int i = 0; i < editors.length && null != editorMode; i++) {
ModeImpl mode = (ModeImpl) wm.findMode(editors[i]);
if (null == mode) {
RetainLocation retainLocation = editors[i].getClass().getAnnotation(RetainLocation.class);
if (null != retainLocation) {
String preferedModeName = retainLocation.value();
mode = (ModeImpl) wm.findMode(preferedModeName);
}
}
if (null == mode) {
mode = editorMode;
}
if (null != mode)
mode.addOpenedTopComponentNoNotify(editors[i]);
// #210380 - do not call componentOpened on the editors
registry.addTopComponent(editors[i]);
}
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
Frame mainWindow = wm.getMainWindow();
mainWindow.invalidate();
mainWindow.repaint();
}
});
// activate some editor window
if (null != activeEditor) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
activeEditor.requestActive();
}
});
}
}
});
}
use of org.netbeans.core.windows.ModeImpl in project netbeans-rcp-lite by outersky.
the class ResizeModeAction method updateEnabled.
private void updateEnabled() {
ModeImpl contextMode = getModeToWorkWith();
if (null == contextMode || contextMode.getKind() == Constants.MODE_KIND_EDITOR || contextMode.getState() == Constants.MODE_STATE_SEPARATED || null == contextMode.getSelectedTopComponent()) {
setEnabled(false);
return;
}
Component c = contextMode.getSelectedTopComponent();
MultiSplitPane splitPane = (MultiSplitPane) SwingUtilities.getAncestorOfClass(MultiSplitPane.class, c);
if (null == splitPane) {
setEnabled(false);
return;
}
setEnabled(true);
}
use of org.netbeans.core.windows.ModeImpl in project netbeans-rcp-lite by outersky.
the class SwitchToRecentDocumentAction method actionPerformed.
/**
* Perform the action. Sets/unsets maximzed mode.
*/
public void actionPerformed(java.awt.event.ActionEvent ev) {
WindowManagerImpl wm = WindowManagerImpl.getInstance();
String[] ids = wm.getRecentViewIDList();
if (ids.length == 0) {
return;
}
for (int i = 0; i < ids.length; i++) {
String tcId = ids[i];
ModeImpl mode = (ModeImpl) wm.findModeForOpenedID(tcId);
if (mode == null) {
continue;
}
if (mode.getKind() == Constants.MODE_KIND_EDITOR) {
// #37030 Unmaximize other mode if needed.
if (mode != wm.getCurrentMaximizedMode()) {
wm.switchMaximizedMode(null);
}
TopComponent tc = wm.findTopComponent(tcId);
if (null != tc) {
tc.requestActive();
break;
}
}
}
}
Aggregations