下面列出了org.eclipse.swt.widgets.Shell#addShellListener ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private static void addDeprecation( Shell shell ) {
if ( shell == null ) {
return;
}
shell.addShellListener( new ShellAdapter() {
private boolean deprecation = false;
@Override public void shellActivated( ShellEvent shellEvent ) {
super.shellActivated( shellEvent );
if ( deprecation ) {
return;
}
String deprecated = BaseMessages.getString( PKGBASE, "ActionCategory.Category.Deprecated" ).toLowerCase();
shell.setText( shell.getText() + " (" + deprecated + ")" );
deprecation = true;
}
} );
}
@Override
public void create() {
super.create();
Shell shell = getShell();
shell.addShellListener(fActivationListener);
// fill in combo contents
fFindField.removeModifyListener(fFindModifyListener);
updateCombo(fFindField, fFindHistory);
fFindField.addModifyListener(fFindModifyListener);
// get find string
initFindStringFromSelection();
shell.setMinimumSize(shell.getSize());
// set dialog position
if (fDialogPositionInit != null) {
shell.setBounds(fDialogPositionInit);
}
shell.setText(Messages.TimeGraphFindDialog_FindTitle);
}
/**
* Returns a {@link org.eclipse.swt.events.SelectionAdapter} that is used to "submit" the dialog.
*/
private Display prepareLayout() {
// Prep the parent shell and the dialog shell
final Shell parent = getParent();
final Display display = parent.getDisplay();
shell = new Shell( parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.SHEET );
shell.setImage( GUIResource.getInstance().getImageSpoon() );
props.setLook( shell );
// Detect X or ALT-F4 or something that kills this window...
shell.addShellListener( new ShellAdapter() {
@Override
public void shellClosed( ShellEvent e ) {
dispose();
}
} );
final FormLayout formLayout = new FormLayout();
formLayout.marginWidth = MARGIN_SIZE;
formLayout.marginHeight = MARGIN_SIZE;
shell.setLayout( formLayout );
shell.setText( this.title );
return display;
}
private static void addDeprecation( Shell shell ) {
if ( shell == null ) {
return;
}
shell.addShellListener( new ShellAdapter() {
private boolean deprecation = false;
@Override public void shellActivated( ShellEvent shellEvent ) {
super.shellActivated( shellEvent );
if ( deprecation ) {
return;
}
String deprecated = BaseMessages.getString( PKGBASE, "JobCategory.Category.Deprecated" ).toLowerCase();
shell.setText( shell.getText() + " (" + deprecated + ")" );
deprecation = true;
}
} );
}
public JobEntryInterface open() {
Shell parent = getParent();
display = parent.getDisplay();
shell = new Shell( parent, props.getJobsDialogStyle() );
props.setLook( shell );
JobDialog.setShellImage( shell, jobEntry );
backupChanged = jobEntry.hasChanged();
createElements();
// Detect [X] or ALT-F4 or something that kills this window...
shell.addShellListener( new ShellAdapter() {
public void shellClosed( ShellEvent e ) {
cancel();
}
} );
getData();
setActive();
BaseStepDialog.setSize( shell );
int width = 750;
int height = Const.isWindows() ? 730 : 718;
shell.setSize( width, height );
shell.open();
while ( !shell.isDisposed() ) {
if ( !display.readAndDispatch() ) {
display.sleep();
}
}
return jobEntry;
}
public IAction open() {
Shell parent = getParent();
display = parent.getDisplay();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.MIN | SWT.MAX | SWT.RESIZE);
props.setLook(shell);
WorkflowDialog.setShellImage(shell, action);
backupChanged = action.hasChanged();
createElements();
// Detect [X] or ALT-F4 or something that kills this window...
shell.addShellListener(new ShellAdapter() {
public void shellClosed(ShellEvent e) {
cancel();
}
});
getData();
setActive();
BaseTransformDialog.setSize(shell);
int width = 750;
int height = Const.isWindows() ? 730 : 720;
shell.setSize(width, height);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return action;
}
public IAction open() {
Shell parent = getParent();
display = parent.getDisplay();
shell = new Shell( parent, SWT.DIALOG_TRIM | SWT.MIN | SWT.MAX | SWT.RESIZE );
props.setLook( shell );
WorkflowDialog.setShellImage( shell, action );
backupChanged = action.hasChanged();
createElements();
// Detect [X] or ALT-F4 or something that kills this window...
shell.addShellListener( new ShellAdapter() {
public void shellClosed( ShellEvent e ) {
cancel();
}
} );
getData();
setActive();
BaseTransformDialog.setSize( shell );
int width = 750;
int height = Const.isWindows() ? 730 : 718;
shell.setSize( width, height );
shell.open();
while ( !shell.isDisposed() ) {
if ( !display.readAndDispatch() ) {
display.sleep();
}
}
return action;
}
public JobEntryInterface open() {
Shell parent = getParent();
display = parent.getDisplay();
shell = new Shell( parent, props.getJobsDialogStyle() );
props.setLook( shell );
JobDialog.setShellImage( shell, jobEntry );
backupChanged = jobEntry.hasChanged();
createElements();
// Detect [X] or ALT-F4 or something that kills this window...
shell.addShellListener( new ShellAdapter() {
public void shellClosed( ShellEvent e ) {
cancel();
}
} );
getData();
setActive();
BaseStepDialog.setSize( shell );
int width = 750;
int height = Const.isWindows() ? 730 : 720;
shell.setSize( width, height );
shell.open();
while ( !shell.isDisposed() ) {
if ( !display.readAndDispatch() ) {
display.sleep();
}
}
return jobEntry;
}
/**
* Adds support to resizable dialogs for (re)storing the dialog size.
*
* @param dialog
* the dialog to add support to
* @param settings
* the dialog settings to store the size in
* @param dialogKey
* the unique key for the dialog
*/
public static void addResizeSupport(Dialog dialog, IDialogSettings settings, String dialogKey) {
Shell shell = dialog.getShell();
ShellResizeSupportListener shellSupport = new ShellResizeSupportListener(dialog, settings,
dialogKey);
shell.addControlListener(shellSupport);
shell.addShellListener(shellSupport);
shell.addDisposeListener(shellSupport);
}
@Override
public void install(ITextViewer textViewer) {
super.install(textViewer);
fPartListener= new PartListener();
IWorkbenchPartSite site= fTextEditor.getSite();
IWorkbenchWindow window= site.getWorkbenchWindow();
window.getPartService().addPartListener(fPartListener);
fActivationListener= new ActivationListener(textViewer.getTextWidget());
Shell shell= window.getShell();
shell.addShellListener(fActivationListener);
fJavaElementChangedListener= new ElementChangedListener();
JavaCore.addElementChangedListener(fJavaElementChangedListener);
fResourceChangeListener= new ResourceChangeListener();
IWorkspace workspace= JavaPlugin.getWorkspace();
workspace.addResourceChangeListener(fResourceChangeListener);
fPropertyChangeListener= new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
if (SpellingService.PREFERENCE_SPELLING_ENABLED.equals(event.getProperty()) || SpellingService.PREFERENCE_SPELLING_ENGINE.equals(event.getProperty()))
forceReconciling();
}
};
JavaPlugin.getDefault().getCombinedPreferenceStore().addPropertyChangeListener(fPropertyChangeListener);
fReconciledElement= EditorUtility.getEditorInputJavaElement(fTextEditor, false);
}
@Override
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
newShell.setText(Messages.getString("dialog.TermDbManagerDialog.title"));
newShell.addShellListener(new ShellAdapter() {
public void shellActivated(ShellEvent e) {
if (lastShellSize == null) {
lastShellSize = getShell().getSize();
}
}
});
}
@Override
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
newShell.setText(Messages.getString("dialog.TmDbManagerDialog.title"));
newShell.addShellListener(new ShellAdapter() {
public void shellActivated(ShellEvent e) {
if (lastShellSize == null) {
lastShellSize = getShell().getSize();
}
}
});
}
private Display prepareLayout() {
// Prep the parent shell and the dialog shell
final Shell parent = getParent();
final Display display = parent.getDisplay();
shell = new Shell( parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN );
props.setLook( shell );
setShellImage( shell, meta );
// Detect X or ALT-F4 or something that kills this window...
shell.addShellListener( new ShellAdapter() {
@Override
public void shellClosed( ShellEvent e ) {
cancel();
}
} );
changed = meta.hasChanged();
final FormLayout formLayout = new FormLayout();
formLayout.marginWidth = BaseDialog.MARGIN_SIZE;
formLayout.marginHeight = BaseDialog.MARGIN_SIZE;
shell.setLayout( formLayout );
shell.setText( getTitle() );
return display;
}
@Override
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
newShell.setText(Messages.getString("dialog.TermDbManagerDialog.title"));
newShell.addShellListener(new ShellAdapter() {
public void shellActivated(ShellEvent e) {
if (lastShellSize == null) {
lastShellSize = getShell().getSize();
}
}
});
}
@Override
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
newShell.setText(Messages.getString("dialog.TmDbManagerDialog.title"));
newShell.addShellListener(new ShellAdapter() {
public void shellActivated(ShellEvent e) {
if (lastShellSize == null) {
lastShellSize = getShell().getSize();
}
}
});
}
protected Shell createPopupShell( )
{
POPUP_ATTACHING = true;
Shell shell = getWizard( ).createPopupContainer( );
shell.addShellListener( this );
shell.setImage( UIHelper.getImage( "icons/obj16/chartbuilder.gif" ) ); //$NON-NLS-1$
POPUP_ATTACHING = false;
return shell;
}
public void open() {
// Must cache here, since editor context is not available in menu from popup shell:
openDialogBinding = getOpenDialogBinding();
Shell workbenchShell = editor.getSite().getShell();
final Display display = workbenchShell.getDisplay();
popup = new Shell(workbenchShell, SWT.ON_TOP | SWT.NO_TRIM | SWT.TOOL);
popupLayout = new GridLayout(2, false);
popupLayout.marginWidth = 1;
popupLayout.marginHeight = 1;
popupLayout.marginLeft = 4;
popupLayout.horizontalSpacing = 0;
popup.setLayout(popupLayout);
createContent(popup);
updatePopupLocation();
new PopupVisibilityManager().start();
// Leave linked mode when popup loses focus
// (except when focus goes back to workbench window or menu is open):
popup.addShellListener(new ShellAdapter() {
@Override
public void shellDeactivated(ShellEvent e) {
if (iSMenuUp)
return;
final Shell editorShell = editor.getSite().getShell();
display.asyncExec(new Runnable() {
// post to UI thread since editor shell only gets activated after popup has lost focus
@Override
public void run() {
Shell activeShell = display.getActiveShell();
if (activeShell != editorShell) {
controller.cancelLinkedMode();
}
}
});
}
});
if (!MAC) { // carbon and cocoa draw their own border...
popup.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent pe) {
pe.gc.drawPolygon(getPolygon(true));
}
});
}
UIJob delayJob = new UIJob(display, "Delayed RenameInformationPopup") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
delayJobFinished = true;
if (popup != null && !popup.isDisposed()) {
updateVisibility();
}
return Status.OK_STATUS;
}
};
delayJob.setSystem(true);
delayJob.setPriority(Job.INTERACTIVE);
delayJob.schedule(POPUP_VISIBILITY_DELAY);
}
public void open() {
// Must cache here, since editor context is not available in menu from popup shell:
fOpenDialogBinding= getOpenDialogBinding();
Shell workbenchShell= fEditor.getSite().getShell();
final Display display= workbenchShell.getDisplay();
fPopup= new Shell(workbenchShell, SWT.ON_TOP | SWT.NO_TRIM | SWT.TOOL);
fPopupLayout= new GridLayout(3, false);
fPopupLayout.marginWidth= 1;
fPopupLayout.marginHeight= 1;
fPopupLayout.marginLeft= 4;
fPopupLayout.horizontalSpacing= 0;
fPopup.setLayout(fPopupLayout);
createContent(fPopup);
updatePopupLocation(true);
new PopupVisibilityManager().start();
// Leave linked mode when popup loses focus
// (except when focus goes back to workbench window or menu is open):
fPopup.addShellListener(new ShellAdapter() {
@Override
public void shellDeactivated(ShellEvent e) {
if (fIsMenuUp)
return;
final Shell editorShell= fEditor.getSite().getShell();
display.asyncExec(new Runnable() {
// post to UI thread since editor shell only gets activated after popup has lost focus
@Override
public void run() {
Shell activeShell= display.getActiveShell();
if (activeShell != editorShell) {
fRenameLinkedMode.cancel();
}
}
});
}
});
if (! MAC) { // carbon and cocoa draw their own border...
fPopup.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent pe) {
pe.gc.drawPolygon(getPolygon(true));
}
});
}
// fPopup.moveBelow(null); // make sure hovers are on top of the info popup
// XXX workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=170774
// fPopup.moveBelow(workbenchShell.getShells()[0]);
UIJob delayJob= new UIJob(display, RefactoringMessages.RenameInformationPopup_delayJobName) {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
fDelayJobFinished= true;
if (fPopup != null && ! fPopup.isDisposed()) {
updateVisibility();
}
return Status.OK_STATUS;
}
};
delayJob.setSystem(true);
delayJob.setPriority(Job.INTERACTIVE);
delayJob.schedule(POPUP_VISIBILITY_DELAY);
}
/**
* The Hide button has been pressed.
*/
public void hidePressed()
{
if (hideOnFinish)
{
final Shell activeShell = getShell();
toast = new GenericInfoPopupDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
infoTitle, infoMessage, new Runnable()
{
public void run()
{
activeShell.setVisible(true);
}
});
toast.open();
activeShell.setVisible(false);
activeShell.addListener(SWT.Show, new Listener()
{
public void handleEvent(Event event)
{
if (toast != null)
{
// Incase if the shell is opened through other source, close the toast
toast.close();
}
}
});
activeShell.addShellListener(new ShellAdapter()
{
@Override
public void shellClosed(ShellEvent e)
{
if (toast != null)
{
// In case the shell gets closed programatically, close the toast.
toast.close();
}
}
});
}
}
public void open() {
// Must cache here, since editor context is not available in menu from popup shell:
fOpenDialogBinding= getOpenDialogBinding();
Shell workbenchShell= fEditor.getSite().getShell();
final Display display= workbenchShell.getDisplay();
fPopup= new Shell(workbenchShell, SWT.ON_TOP | SWT.NO_TRIM | SWT.TOOL);
fPopupLayout= new GridLayout(2, false);
fPopupLayout.marginWidth= 1;
fPopupLayout.marginHeight= 1;
fPopupLayout.marginLeft= 4;
fPopupLayout.horizontalSpacing= 0;
fPopup.setLayout(fPopupLayout);
createContent(fPopup);
updatePopupLocation(true);
new PopupVisibilityManager().start();
// Leave linked mode when popup loses focus
// (except when focus goes back to workbench window or menu is open):
fPopup.addShellListener(new ShellAdapter() {
@Override
public void shellDeactivated(ShellEvent e) {
if (fIsMenuUp)
return;
final Shell editorShell= fEditor.getSite().getShell();
display.asyncExec(new Runnable() {
// post to UI thread since editor shell only gets activated after popup has lost focus
public void run() {
Shell activeShell= display.getActiveShell();
if (activeShell != editorShell) {
fRenameLinkedMode.cancel();
}
}
});
}
});
if (! MAC) { // carbon and cocoa draw their own border...
fPopup.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent pe) {
pe.gc.drawPolygon(getPolygon(true));
}
});
}
// fPopup.moveBelow(null); // make sure hovers are on top of the info popup
// XXX workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=170774
// fPopup.moveBelow(workbenchShell.getShells()[0]);
UIJob delayJob= new UIJob(display, ReorgMessages.RenameInformationPopup_delayJobName) {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
fDelayJobFinished= true;
if (fPopup != null && ! fPopup.isDisposed()) {
updateVisibility();
}
return Status.OK_STATUS;
}
};
delayJob.setSystem(true);
delayJob.setPriority(Job.INTERACTIVE);
delayJob.schedule(POPUP_VISIBILITY_DELAY);
}