@Override protected ShellListener getShellListener() { return new ShellAdapter() { @Override public void shellClosed(final ShellEvent event) { setReturnCode(Window.CANCEL); } }; }
protected ShellListener getShellListener() { return new ShellAdapter() { public void shellClosed(ShellEvent event) { event.doit= false; // don't close now setReturnCode(CANCEL); close(); } }; }
@Override protected ShellListener getShellListener() { return new ShellAdapter() { @Override public void shellClosed(final ShellEvent event) { value = null; setReturnCode(Window.CANCEL); } }; }
@Override protected ShellListener getShellListener() { return new ShellAdapter() { @Override public void shellClosed(final ShellEvent event) { event.doit = false; } }; }
@Override protected ShellListener getShellListener() { return new ShellAdapter() { @Override public void shellClosed(final ShellEvent event) { maxTimePerIteration = null; minRecordsPerIteration = null; setReturnCode(Window.CANCEL); } }; }
@Override public String open() { Shell parent = getParent(); Display display = parent.getDisplay(); // create shell shell = new Shell( parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN ); shell.setText( BaseMessages.getString( PKG, getTitleKey() ) ); changed = metaInfo.hasChanged(); // create form layout FormLayout formLayout = new FormLayout(); formLayout.marginHeight = LARGE_MARGIN; formLayout.marginWidth = LARGE_MARGIN; shell.setLayout( formLayout ); shell.setMinimumSize( getMinimumWidth(), getMinimumHeight() ); shell.setSize( getMinimumWidth(), getMinimumHeight() ); props.setLook( shell ); setShellImage( shell, (StepMetaInterface) metaInfo ); final Control top = buildStepNameInput( this.shell ); final Composite container = new Composite( shell, SWT.NONE ); container.setLayout( new FormLayout() ); props.setLook( container ); buildContent( container ); Composite buttons = createButtons(); final Label bottomSeparator = new SeparatorBuilder( shell, props ) .setLeftPlacement( LEFT_PLACEMENT ) .setRightPlacement( RIGHT_PLACEMENT ) .build(); ( (FormData) bottomSeparator.getLayoutData() ).bottom = new FormAttachment( buttons, -LARGE_MARGIN ); FormData containerLD = new FormData(); containerLD.top = new FormAttachment( top, LARGE_MARGIN ); containerLD.bottom = new FormAttachment( bottomSeparator, -LARGE_MARGIN ); containerLD.left = new FormAttachment( LEFT_PLACEMENT ); containerLD.right = new FormAttachment( RIGHT_PLACEMENT ); container.setLayoutData( containerLD ); stepName.addModifyListener( changeListener ); // listener to detect X or something that kills this window ShellListener lsShell = new ShellAdapter() { public void shellClosed( ShellEvent e ) { cancel(); } }; shell.addShellListener( lsShell ); // load information (based on previous usage) loadData( metaInfo ); metaInfo.setChanged( changed ); // set focus on step name stepName.selectAll(); stepName.setFocus(); // open shell shell.open(); while ( !shell.isDisposed() ) { if ( !display.readAndDispatch() ) { display.sleep(); } } return stepname; }
/** * Returns a shell listener. This shell listener gets registered with this * window's shell. * <p> * The default implementation of this framework method returns a new * listener that makes this window the active window for its window manager * (if it has one) when the shell is activated, and calls the framework * method <code>handleShellCloseEvent</code> when the shell is closed. * Subclasses may extend or reimplement. * </p> * * @return a shell listener */ protected ShellListener getShellListener() { return new ShellAdapter() { public void shellClosed(ShellEvent event) { event.doit = false; // don't close now if (canHandleShellCloseEvent()) { handleShellCloseEvent(); } } }; }
/** * Adds the listener to the collection of listeners who will be notified * when operations are performed on the receiver, by sending the listener * one of the messages defined in the <code>ShellListener</code> interface. * * @param listener * the listener which should be notified * * @exception IllegalArgumentException * <ul> * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> * </ul> * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been * disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver</li> * </ul> * * @see ShellListener * @see #removeShellListener */ public void addShellListener(ShellListener listener) { checkWidget(); if (listener == null) error(SWT.ERROR_NULL_ARGUMENT); TypedListener typedListener = new TypedListener(listener); addListener(SWT.Close, typedListener); addListener(SWT.Iconify, typedListener); addListener(SWT.Deiconify, typedListener); addListener(SWT.Activate, typedListener); addListener(SWT.Deactivate, typedListener); }
/** * Removes the listener from the collection of listeners who will be * notified when operations are performed on the receiver. * * @param listener * the listener which should no longer be notified * * @exception IllegalArgumentException * <ul> * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> * </ul> * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been * disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver</li> * </ul> * * @see ShellListener * @see #addShellListener */ public void removeShellListener(ShellListener listener) { checkWidget(); if (listener == null) error(SWT.ERROR_NULL_ARGUMENT); if (eventTable == null) return; eventTable.unhook(SWT.Close, listener); eventTable.unhook(SWT.Iconify, listener); eventTable.unhook(SWT.Deiconify, listener); eventTable.unhook(SWT.Activate, listener); eventTable.unhook(SWT.Deactivate, listener); }