use of org.eclipse.swt.widgets.Shell in project cogtool by cogtool.
the class UI method performAction.
/**
* Wrapper method for invoking performAction; uses this as the
* transmuter. ContextMenuManager is currently the only place that
* invokes performAction as "context".
*
* @param id the general semantic LID to lookup and perform action for
* @param isContextSelection true if we should specialize based on the
* current contextual selection;
* false to use the standard selection
* @return <code>true</code> if it is ok to continue with action processing
* and <code>false</code> if processing should stop.
*/
public boolean performAction(ListenerIdentifier id, boolean isContextSelection) {
View view = getView();
boolean wasPerforming = view.isPerformingAction();
Shell s = getShell();
Cursor oldCursor = s.getCursor();
view.setStatusMessage("");
view.setPerformingAction(true);
s.setCursor(WindowUtil.BUSY_CURSOR_INSTANCE);
// false means a normal action, not caused by a context menu selection
try {
return lIDMap.performAction(this, id, isContextSelection);
} catch (RecoverableException ex) {
RcvrExceptionHandler.recover(ex, getStandardInteraction());
} finally {
view.setPerformingAction(wasPerforming);
if (!s.isDisposed()) {
s.setCursor(oldCursor);
}
}
return false;
}
use of org.eclipse.swt.widgets.Shell in project cogtool by cogtool.
the class View method setVisible.
/**
* Set whether the associated window (and view) is visible.
*
* @param visible true iff the associated window/view should be visible
* @author mlh
*/
public void setVisible(boolean visible) {
Shell window = getShell();
if (window != null) {
if (visible) {
// Suppress drawing until everything is done.
// setDrawingOK(false);
WindowUtil.display(window, false);
// Recompute layout of the shell contents.
// Should not be called too often, but since SetVisible should
// only be called on window creation it should be done here.
window.layout(true, true);
// setDrawingOK(true);
} else {
window.setVisible(false);
}
} else {
throw new RcvrUIException("No window available for setting window visibility.");
}
}
use of org.eclipse.swt.widgets.Shell in project cogtool by cogtool.
the class View method takeFocus.
/**
* Bring the associated window to the front and make active by
* making the window have the focus and "un-minimize" it.
*
* @author mlh
*/
public void takeFocus() {
Shell window = getShell();
if (window != null) {
window.setActive();
window.setMinimized(false);
} else {
throw new RcvrUIException("No window available for taking the focus.");
}
}
use of org.eclipse.swt.widgets.Shell in project cogtool by cogtool.
the class DefaultUI method setInitiallyEnabled.
/**
* Sets the "always-enabled" widgets;
* call this at the end of the subclass constructor!
* <p>
* All model editing windows support:
* Paste, SaveProject, SaveProjectAs, and CloseWindow
* <p>
* Take this opportunity to interpose a listener when the
* associated SWT window is closed by the user without using
* a CogTool menu item. This listener will also save the window's
* location in case a new window is restored for the associated
* model object.
*
* @author mlh
*/
@Override
protected void setInitiallyEnabled(boolean forConstruction) {
super.setInitiallyEnabled(forConstruction);
if (undoMgrViewHandler != null) {
undoMgrViewHandler.resetView(undoManager);
}
setEnabled(CogToolLID.Paste, ListenerIdentifierMap.ALL, MenuUtil.ENABLED);
setEnabled(CogToolLID.SaveProject, ListenerIdentifierMap.ALL, MenuUtil.ENABLED);
setEnabled(CogToolLID.SaveProjectAs, ListenerIdentifierMap.ALL, MenuUtil.ENABLED);
setEnabled(CogToolLID.CloseWindow, ListenerIdentifierMap.ALL, MenuUtil.ENABLED);
setEnabled(CogToolLID.CloseProject, ListenerIdentifierMap.ALL, MenuUtil.ENABLED);
setEnabled(CogToolLID.Properties, ListenerIdentifierMap.ALL, MenuUtil.ENABLED);
Shell window = getShell();
if (forConstruction && (window != null)) {
window.removeShellListener(closeListener);
window.addShellListener(closeListener);
}
}
use of org.eclipse.swt.widgets.Shell in project cogtool by cogtool.
the class DefaultUI method dispose.
/**
* Recover any system resources being used to support the view being
* used by this UI instance.
* <p>
* At this point, we must remove alert handlers and the interposed
* listener on the associated SWT Shell object.
*
* @author mlh
*/
@Override
public void dispose() {
if (undoManager != null) {
undoManager.removeAllHandlers(this);
}
project.removeAllHandlers(this);
try {
UndoManager.removeSavePointChangeHandler(project, undoMgrTitleHandler);
} catch (IllegalStateException ex) {
System.err.println("Ignoring fact that removeSavePointChangeHandler failed.");
}
Shell window = getShell();
CogTool.controllerNexus.saveWindowLocation(project, getModelObject(), window.getBounds());
if (window != null) {
if (closeListener != null) {
window.removeShellListener(closeListener);
}
}
super.dispose();
}
Aggregations