Java Code Examples for org.eclipse.swt.widgets.Shell#addShellListener()

The following examples show how to use org.eclipse.swt.widgets.Shell#addShellListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WorkflowDialog.java    From hop with Apache License 2.0 6 votes vote down vote up
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;
      }
    } );
  }
 
Example 2
Source File: JobDialog.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
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;
      }
    } );
  }
 
Example 3
Source File: BaseDialog.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 4
Source File: TimeGraphFindDialog.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
@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);
}
 
Example 5
Source File: JobEntryTransDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 6
Source File: SWTUtil.java    From eclipse-cs with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * 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);
}
 
Example 7
Source File: ActionWorkflowDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 8
Source File: JavaReconciler.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@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);
}
 
Example 9
Source File: TermDbManagerDialog.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
@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();
			}
		}
	});
}
 
Example 10
Source File: TmDbManagerDialog.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
@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();
			}
		}
	});
}
 
Example 11
Source File: CommonStepDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
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;
  }
 
Example 12
Source File: TermDbManagerDialog.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
@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();
			}
		}
	});
}
 
Example 13
Source File: TmDbManagerDialog.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
@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();
			}
		}
	});
}
 
Example 14
Source File: SubtaskSheetImpl.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
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;
}
 
Example 15
Source File: ActionPipelineDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 16
Source File: JobEntryJobDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 17
Source File: RenameRefactoringPopup.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
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);
}
 
Example 18
Source File: RenameInformationPopup.java    From typescript.java with MIT License 4 votes vote down vote up
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);
	}
 
Example 19
Source File: MinimizableWizardDialog.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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();
				}
			}
		});
	}

}
 
Example 20
Source File: RenameInformationPopup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
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);
	}