org.eclipse.swt.widgets.Shell#addShellListener ( )源码实例Demo

下面列出了org.eclipse.swt.widgets.Shell#addShellListener ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: hop   文件: WorkflowDialog.java
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;
      }
    } );
  }
 
源代码2 项目: tracecompass   文件: TimeGraphFindDialog.java
@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);
}
 
源代码3 项目: pentaho-kettle   文件: BaseDialog.java
/**
 * 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;
}
 
源代码4 项目: pentaho-kettle   文件: JobDialog.java
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;
      }
    } );
  }
 
源代码5 项目: pentaho-kettle   文件: JobEntryJobDialog.java
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;
}
 
源代码6 项目: hop   文件: ActionPipelineDialog.java
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;
}
 
源代码7 项目: hop   文件: ActionWorkflowDialog.java
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;
}
 
源代码8 项目: pentaho-kettle   文件: JobEntryTransDialog.java
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;
}
 
源代码9 项目: eclipse-cs   文件: SWTUtil.java
/**
 * 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);
}
 
源代码11 项目: translationstudio8   文件: TermDbManagerDialog.java
@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();
			}
		}
	});
}
 
源代码12 项目: translationstudio8   文件: TmDbManagerDialog.java
@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();
			}
		}
	});
}
 
源代码13 项目: pentaho-kettle   文件: CommonStepDialog.java
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;
  }
 
源代码14 项目: tmxeditor8   文件: TermDbManagerDialog.java
@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();
			}
		}
	});
}
 
源代码15 项目: tmxeditor8   文件: TmDbManagerDialog.java
@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();
			}
		}
	});
}
 
源代码16 项目: birt   文件: SubtaskSheetImpl.java
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;
}
 
源代码17 项目: xtext-eclipse   文件: RenameRefactoringPopup.java
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);
}
 
源代码18 项目: typescript.java   文件: RenameInformationPopup.java
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);
	}
 
源代码19 项目: APICloud-Studio   文件: MinimizableWizardDialog.java
/**
 * 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);
	}