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

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

源代码1 项目: 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;
}
 
源代码2 项目: birt   文件: ExceptionDialog.java
/**
 * @param parentShell
 */
protected ExceptionDialog(Shell parentShell, String title, String msg,
							Throwable ex) {
	super( parentShell );
	this._title = title;
	this.message = msg;
	this._exception = ex;
	if ( parentShell != null )
		this._display = parentShell.getDisplay( );
	else
		this._display = PlatformUI.getWorkbench( )
				.getDisplay( )
				.getActiveShell( )
				.getDisplay( );

	setShellStyle( SWT.DIALOG_TRIM | SWT.RESIZE | SWT.APPLICATION_MODAL );
}
 
源代码3 项目: tmxeditor8   文件: SimpleModelExample.java
public SimpleModelExample(IJaretTableModel tableModel) {
    _tableModel = tableModel;
    _shell = new Shell(Display.getCurrent());
    _shell.setText("simple jaret table example");
    createControls();
    _shell.open();
    Display display;
    display = _shell.getDisplay();
    _shell.pack();
    _shell.setSize(1000, 700);

    /*
     * do the event loop until the shell is closed to block the call
     */
    while (_shell != null && !_shell.isDisposed()) {
        try {
            if (!display.readAndDispatch())
                display.sleep();
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }
    display.update();
}
 
源代码4 项目: xtext-eclipse   文件: TextViewerShiftAction.java
/**
 * The <code>TextOperationAction</code> implementation of this <code>IAction</code> method runs the operation with
 * the current operation code.
 */
@Override
public void run() {
	if (fOperationCode == -1 || fOperationTarget == null)
		return;

	ITextViewer viewer = getTextViewer();
	if (viewer == null)
		return;

	if (!canModifyViewer())
		return;

	Display display = null;

	Shell shell = viewer.getTextWidget().getShell();
	if (shell != null && !shell.isDisposed())
		display = shell.getDisplay();

	BusyIndicator.showWhile(display, new Runnable() {
		@Override
		public void run() {
			fOperationTarget.doOperation(fOperationCode);
		}
	});
}
 
源代码5 项目: tlaplus   文件: UIHelper.java
/**
 * This method returns a built in SWT image. This method was mostly copied
 * directly from {@link IconAndMessageDialog}. The argument should be an
 * icon constant defined in {@link SWT}. These constants begin with "ICON".
 * This method returns null if the argument is not such a constant or if the
 * platform does not define and image corresponding to that constant. I
 * would assume you figure that one out by trial and error.
 * 
 * @param imageID
 * @return
 */
public static Image getSWTImage(final int imageID) {

	Shell shell = getShell();
	final Display display;
	if (shell == null || shell.isDisposed()) {
		display = Display.getCurrent();
	} else {
		display = shell.getDisplay();
	}

	final Image[] image = new Image[1];
	display.syncExec(new Runnable() {
		public void run() {
			image[0] = display.getSystemImage(imageID);
		}
	});

	return image[0];

}
 
private static boolean queryDialog(final Shell parent, final String title, final String message) {
	Display display= parent.getDisplay();
	if (display == null || display.isDisposed())
		return false;

	final boolean[] returnValue= new boolean[1];
	Runnable runnable= new Runnable() {
		public void run() {
			returnValue[0]= MessageDialog.openQuestion(parent, title, message);
		}
	};
	display.syncExec(runnable);

	return returnValue[0];
}
 
源代码7 项目: pentaho-kettle   文件: EnterSearchDialog.java
public EnterSearchDialog( Shell parentShell ) {
  this.parentShell = parentShell;
  this.display = parentShell.getDisplay();

  retval = true;

  searchingSteps = true;
  searchingDatabases = true;
  searchingNotes = true;
}
 
源代码8 项目: texlipse   文件: TexInformationControl.java
public TexInformationControl(TexEditor editor, Shell container) {
    this.editor = editor;
    document = editor.getTexDocument();
    refMana = editor.getDocumentModel().getRefMana();
    shell = new Shell(container, SWT.NO_FOCUS | SWT.ON_TOP | SWT.MODELESS);
    GridLayout layout = new GridLayout(2, false);
    layout.marginHeight = 3;
    layout.marginWidth = 3;
    shell.setLayout(layout);
    display = shell.getDisplay();
    shell.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
}
 
@Override
public void setInitiallyActiveShell(Shell activeShell) {
    this.fInitiallyActiveShell = activeShell;
    this.fFocusControl = null;
    if (activeShell != null) {
        Display display = activeShell.getDisplay();
        if (display != null) {
            this.fFocusControl = display.getFocusControl();
        }
    }
}
 
源代码10 项目: neoscada   文件: DisplayCallbackHandler.java
public DisplayCallbackHandler ( final Shell parentShell, final String dialogTitle, final String dialogMessage )
{
    this.parentShell = parentShell;
    this.display = parentShell.getDisplay ();
    this.dialogTitle = dialogTitle;
    this.dialogMessage = dialogMessage;
}
 
源代码11 项目: SWET   文件: SWTUtil.java
public static void center(Composite parent, Shell child, double xfrac,
		double yfrac) {
	Display dsp = child.getDisplay();
	Rectangle region = parent.isVisible() ? parent.getBounds()
			: getCurrentMonitorBounds(dsp);
	center(region, child, xfrac, yfrac);
}
 
private Display getDisplay() {
	Shell shell= getShell();
	if (shell != null) {
		return shell.getDisplay();
	}
	return null;
}
 
public KettleFileRepositoryDialog( Shell parent, int style, RepositoryMeta repositoryMeta,
  RepositoriesMeta repositoriesMeta ) {
  this.display = parent.getDisplay();
  this.props = PropsUI.getInstance();
  this.input = (KettleFileRepositoryMeta) repositoryMeta;
  this.masterRepositoriesMeta = repositoriesMeta.clone();
  this.masterRepositoryName = repositoryMeta.getName();

  // this.repositories = repositoriesMeta;
  shell = new Shell( parent, style | SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN );
  shell.setText( BaseMessages.getString( PKG, "KettleFileRepositoryDialog.Dialog.Main.Title" ) );
}
 
源代码14 项目: pentaho-kettle   文件: RepositoriesController.java
public void login() {
  if ( loginModel.isValid() == false ) {
    return;
  }
  KettleWaitBox box;
  try {
    box = (KettleWaitBox) document.createElement( "iconwaitbox" );
    box.setIndeterminate( true );
    box.setCanCancel( false );
    box.setIcon( "ui/images/kettle_logo_small.svg" );
    box.setTitle( BaseMessages.getString( PKG, "RepositoryExplorerDialog.Connection.Wait.Title" ) );
    box.setMessage( BaseMessages.getString( PKG, "RepositoryExplorerDialog.Connection.Wait.Message" ) );
    final Shell loginShell = (Shell) loginDialog.getRootObject();
    final Display display = loginShell.getDisplay();
    box.setDialogParent( loginShell );
    box.setRunnable( new WaitBoxRunnable( box ) {
      @Override
      public void run() {
        try {
          helper.loginToRepository();

          waitBox.stop();
          display.syncExec( new Runnable() {
            public void run() {
              loginDialog.hide();
              okButton.setDisabled( false );
              cancelButton.setDisabled( false );

              if ( helper.getConnectedRepository().getConnectMessage() != null ) {
                getMessageBox().setTitle( BaseMessages.getString( PKG, "ConnectMessageTitle" ) );
                getMessageBox().setMessage( helper.getConnectedRepository().getConnectMessage() );
                getMessageBox().open();
              }

              getCallback().onSuccess( helper.getConnectedRepository() );
            }
          } );

        } catch ( final Throwable th ) {

          waitBox.stop();

          try {
            display.syncExec( new Runnable() {
              public void run() {

                getCallback().onError( th );
                okButton.setDisabled( false );
                cancelButton.setDisabled( false );
              }
            } );
          } catch ( Exception e ) {
            e.printStackTrace();
          }

        }
      }

      @Override
      public void cancel() {
      }

    } );
    okButton.setDisabled( true );
    cancelButton.setDisabled( true );
    box.start();
  } catch ( XulException e1 ) {
    getCallback().onError( e1 );
  }
}
 
源代码15 项目: pentaho-kettle   文件: ShowHelpDialog.java
public void open() {
  Shell parent = getParent();
  display = parent.getDisplay();

  shell = createShell( parent );
  shell.setImage( GUIResource.getInstance().getImageSpoon() );
  props.setLook( shell );

  FormLayout formLayout = new FormLayout();

  shell.setLayout( formLayout );
  shell.setText( dialogTitle );

  //Set Images
  setImages();

  // Canvas
  wBrowser = new Browser( shell, SWT.NONE );
  props.setLook( wBrowser );

  // Browser canvas
  FormData fdBrowser = new FormData();
  fdBrowser.top = new FormAttachment( 0, TOOLBAR_HEIGHT );
  fdBrowser.bottom = new FormAttachment( 100, 0 );
  fdBrowser.right = new FormAttachment( 100, 0 );
  fdBrowser.left = new FormAttachment( 0, 0 );
  wBrowser.setLayoutData( fdBrowser );
  wBrowser.setUrl( url );

  // Left toolbar (back, forward, refresh, home)
  toolbarLeft = new ToolBar( shell, SWT.WRAP );
  FormData fdToolbarLeft = new FormData();
  fdToolbarLeft.top = new FormAttachment( 0, MARGIN );
  toolbarLeft.setLayoutData( fdToolbarLeft );
  toolbarLeft.setCursor( cursorEnabled );
  toolbarLeft.setBackground( toolbarLeft.getParent().getBackground() );

  tltmBack = new ToolItem( toolbarLeft, SWT.PUSH );
  tltmBack.setImage( imageBackEnabled );
  tltmBack.setDisabledImage( imageBackDisabled );
  tltmBack.setToolTipText( BaseMessages.getString( PKG, "Spoon.Documentation.Tooltip.Back" ) );
  tltmBack.setEnabled( false );

  tltmForward = new ToolItem( toolbarLeft, SWT.PUSH );
  tltmForward.setImage( imageForwardEnabled );
  tltmForward.setDisabledImage( imageForwardDisabled );
  tltmForward.setToolTipText( BaseMessages.getString( PKG, "Spoon.Documentation.Tooltip.Forward" ) );
  tltmForward.setEnabled( false );

  tltmRefresh = new ToolItem( toolbarLeft, SWT.PUSH );
  tltmRefresh.setImage( imageRefreshEnabled );
  tltmRefresh.setDisabledImage( imageRefreshDisabled );
  tltmRefresh.setToolTipText( BaseMessages.getString( PKG, "Spoon.Documentation.Tooltip.Refresh" ) );
  tltmRefresh.setEnabled( true );

  tltmHome = new ToolItem( toolbarLeft, SWT.PUSH );
  tltmHome.setImage( imageHomeEnabled );
  tltmHome.setDisabledImage( imageHomeDisabled );
  tltmHome.setToolTipText( BaseMessages.getString( PKG, "Spoon.Documentation.Tooltip.Home" ) );
  tltmHome.setEnabled( true );

  // Right toolbar (print)
  toolbarRight = new ToolBar( shell, SWT.WRAP );
  FormData fdToolbarRight = new FormData();
  fdToolbarRight.top = new FormAttachment( 0, MARGIN );
  fdToolbarRight.right = new FormAttachment( 100, -1 * TOOL_ITEM_SPACING );
  toolbarRight.setLayoutData( fdToolbarRight );
  toolbarRight.setCursor( cursorEnabled );
  toolbarRight.setBackground( toolbarRight.getParent().getBackground() );

  // URL toolbar element
  textURL = new Text( shell, SWT.BORDER );
  FormData fdText = new FormData();
  fdText.top = new FormAttachment( 0, MARGIN );
  fdText.right = new FormAttachment( toolbarRight, -1 * TOOL_ITEM_SPACING );
  fdText.left = new FormAttachment( toolbarLeft, TOOL_ITEM_SPACING );
  textURL.setLayoutData( fdText );
  textURL.setForeground( new Color( display, 101, 101, 101 ) );

  tltmPrint = new ToolItem( toolbarRight, SWT.PUSH );
  tltmPrint.setImage( imagePrintEnabled );
  tltmPrint.setDisabledImage( imagePrintDisabled );
  tltmPrint.setToolTipText( BaseMessages.getString( PKG, "Spoon.Documentation.Tooltip.Print" ) );
  tltmPrint.setEnabled( true );

  setUpListeners();

  // Specs are 760/530, but due to rendering differences, we need to adjust the actual hgt/wdt used
  BaseStepDialog.setSize( shell, 755, 538, true );
  shell.setMinimumSize( 515, 408 );

  shell.open();
  while ( !shell.isDisposed() ) {
    if ( !display.readAndDispatch() ) {
      display.sleep();
    }
  }
}
 
源代码16 项目: RepDev   文件: RunReportShell.java
public RunReportShell(Shell parent, SymitarFile file) {
	this.parent = parent;
	display = parent.getDisplay();
	this.file = file;
	this.sym = file.getSym();
}
 
源代码17 项目: nebula   文件: DualListSnippet.java
private static List<DLItem> createItems(final Shell shell) {
	final List<DLItem> list = new ArrayList<>();

	String defaultFontName = null;
	int defaultHeight = -1;
	for (final FontData fontData : shell.getFont().getFontData()) {
		if (defaultFontName == null) {
			defaultFontName = fontData.getName();
		}
		if (defaultHeight == -1) {
			defaultHeight = fontData.getHeight();
		}
	}

	final Font font = new Font(shell.getDisplay(), defaultFontName, defaultHeight, SWT.BOLD);

	list.add(new DLItem("Austria", createImage(shell, "austria")));
	list.add(new DLItem("Belgium", createImage(shell, "belgium")));
	list.add(new DLItem("Bulgaria", createImage(shell, "bulgaria")));
	list.add(new DLItem("Cyprus", createImage(shell, "cyprus")));
	list.add(new DLItem("Czech Republic", createImage(shell, "czech")));
	list.add(new DLItem("Denmark", createImage(shell, "denmark")));
	list.add(new DLItem("Estonia", createImage(shell, "estonia")));
	list.add(new DLItem("Finland", createImage(shell, "finland")));
	list.add(new DLItem("France", createImage(shell, "france"), font));
	list.add(new DLItem("Germany", createImage(shell, "germany")));
	list.add(new DLItem("Greece", createImage(shell, "greece")));
	list.add(new DLItem("Hungary", createImage(shell, "hungary")));
	list.add(new DLItem("Ireland", createImage(shell, "ireland")));
	list.add(new DLItem("Italy", createImage(shell, "italy")));
	list.add(new DLItem("Latvia", createImage(shell, "latvia")));
	list.add(new DLItem("Lithuania", createImage(shell, "lithuania")));
	list.add(new DLItem("Luxembourg", createImage(shell, "luxembourg")));
	list.add(new DLItem("Malta", createImage(shell, "malta")));
	list.add(new DLItem("Netherlands", createImage(shell, "netherlands")));
	list.add(new DLItem("Poland", createImage(shell, "poland"), shell.getDisplay().getSystemColor(SWT.COLOR_WHITE), shell.getDisplay().getSystemColor(SWT.COLOR_RED)));
	list.add(new DLItem("Portugal", createImage(shell, "portugal")));
	list.add(new DLItem("Romania", createImage(shell, "romania")));
	list.add(new DLItem("Slovakia", createImage(shell, "slovakia")));
	list.add(new DLItem("Slovenia", createImage(shell, "slovenia")));
	list.add(new DLItem("Spain", createImage(shell, "spain")));
	list.add(new DLItem("Sweden", createImage(shell, "sweden")));
	list.add(new DLItem("United Kingdom", createImage(shell, "unitedkingdom")));

	shell.addDisposeListener(e -> {
		font.dispose();
	});

	return list;
}
 
源代码18 项目: bonita-studio   文件: BonitaPreferenceDialog.java
public BonitaPreferenceDialog(final Shell parentShell) {
    super(parentShell);
    setShellStyle(SWT.CLOSE | SWT.BORDER | SWT.APPLICATION_MODAL);
    applyOnBack = new ArrayList<>();
    swtResourcesRegistry = new SWTResourcesRegistry(parentShell.getDisplay());
}
 
public void setVisible(boolean visible)
{
	Shell shell = getShell();
	if (shell.isVisible() == visible)
		return;

	if (!visible)
	{
		super.setVisible(false);
		setInput(null);
		return;
	}

	/*
	 * The Browser widget flickers when made visible while it is not completely loaded. The fix is to delay the call
	 * to setVisible until either loading is completed (see ProgressListener in constructor), or a timeout has been
	 * reached.
	 */
	final Display display = shell.getDisplay();

	// Make sure the display wakes from sleep after timeout:
	display.timerExec(100, new Runnable()
	{
		public void run()
		{
			fCompleted = true;
		}
	});

	while (!fCompleted)
	{
		// Drive the event loop to process the events required to load the browser widget's contents:
		if (!display.readAndDispatch())
		{
			display.sleep();
		}
	}

	shell = getShell();
	if (shell == null || shell.isDisposed())
		return;

	/*
	 * Avoids flickering when replacing hovers, especially on Vista in ON_CLICK mode. Causes flickering on GTK.
	 * Carbon does not care.
	 */
	if ("win32".equals(SWT.getPlatform())) //$NON-NLS-1$
		shell.moveAbove(null);

	super.setVisible(true);
}
 
/**
 * @return true when OK is hit, false when CANCEL
 */
public boolean open() {

  Shell parent = getParent();
  Display display = parent.getDisplay();

  shell = new Shell( parent, SWT.RESIZE | SWT.MAX | SWT.MIN | SWT.DIALOG_TRIM );
  shell.setImage( GUIResource.getInstance().getImageSpoon() );
  props.setLook( shell );

  margin = Const.MARGIN + 2;
  middle = Const.MIDDLE_PCT;

  FormLayout formLayout = new FormLayout();

  shell.setLayout( formLayout );
  shell.setText( "Graph Model Editor" );

  Button wOK = new Button( shell, SWT.PUSH );
  wOK.setText( BaseMessages.getString( PKG, "System.Button.OK" ) );
  wOK.addListener( SWT.Selection, event -> ok() );
  Button wCancel = new Button( shell, SWT.PUSH );
  wCancel.setText( BaseMessages.getString( PKG, "System.Button.Cancel" ) );
  wCancel.addListener( SWT.Selection, event -> cancel() );

  BaseStepDialog.positionBottomButtons( shell, new Button[] { wOK, wCancel }, margin, null );

  // Add a tab folder
  //
  wTabs = new CTabFolder( shell, SWT.BORDER );
  FormData fdTabs = new FormData();
  fdTabs.left = new FormAttachment( 0, 0 );
  fdTabs.right = new FormAttachment( 100, 0 );
  fdTabs.top = new FormAttachment( 0, 0 );
  fdTabs.bottom = new FormAttachment( wOK, -margin * 2 );
  wTabs.setLayoutData( fdTabs );

  addModelTab();
  addNodesTab();
  addRelationshipsTab();
  addGraphTab();

  // Select the model tab
  //
  wTabs.setSelection( 0 );

  // Set the shell size, based upon previous time...
  BaseStepDialog.setSize( shell );

  getData();

  shell.open();
  while ( !shell.isDisposed() ) {
    if ( !display.readAndDispatch() ) {
      display.sleep();
    }
  }

  return ok;
}