Java Code Examples for org.eclipse.swt.widgets.Shell#getDisplay()
The following examples show how to use
org.eclipse.swt.widgets.Shell#getDisplay() .
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: ExceptionDialog.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * @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 ); }
Example 2
Source File: SimpleModelExample.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
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(); }
Example 3
Source File: BaseDialog.java From pentaho-kettle with Apache License 2.0 | 6 votes |
/** * 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: TextViewerShiftAction.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
/** * 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); } }); }
Example 5
Source File: UIHelper.java From tlaplus with MIT License | 6 votes |
/** * 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]; }
Example 6
Source File: KettleFileRepositoryDialog.java From pentaho-kettle with Apache License 2.0 | 5 votes |
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" ) ); }
Example 7
Source File: ClipboardOperationAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private Display getDisplay() { Shell shell= getShell(); if (shell != null) { return shell.getDisplay(); } return null; }
Example 8
Source File: SWTUtil.java From SWET with MIT License | 5 votes |
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); }
Example 9
Source File: DisplayCallbackHandler.java From neoscada with Eclipse Public License 1.0 | 5 votes |
public DisplayCallbackHandler ( final Shell parentShell, final String dialogTitle, final String dialogMessage ) { this.parentShell = parentShell; this.display = parentShell.getDisplay (); this.dialogTitle = dialogTitle; this.dialogMessage = dialogMessage; }
Example 10
Source File: InformationPresenterControlManager.java From Pydev with Eclipse Public License 1.0 | 5 votes |
@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(); } } }
Example 11
Source File: TexInformationControl.java From texlipse with Eclipse Public License 1.0 | 5 votes |
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)); }
Example 12
Source File: EnterSearchDialog.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public EnterSearchDialog( Shell parentShell ) { this.parentShell = parentShell; this.display = parentShell.getDisplay(); retval = true; searchingSteps = true; searchingDatabases = true; searchingNotes = true; }
Example 13
Source File: FatJarPackagerUtil.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
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]; }
Example 14
Source File: DualListSnippet.java From nebula with Eclipse Public License 2.0 | 4 votes |
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; }
Example 15
Source File: BonitaPreferenceDialog.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
public BonitaPreferenceDialog(final Shell parentShell) { super(parentShell); setShellStyle(SWT.CLOSE | SWT.BORDER | SWT.APPLICATION_MODAL); applyOnBack = new ArrayList<>(); swtResourcesRegistry = new SWTResourcesRegistry(parentShell.getDisplay()); }
Example 16
Source File: CustomBrowserInformationControl.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
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); }
Example 17
Source File: GraphModelDialog.java From knowbi-pentaho-pdi-neo4j-output with Apache License 2.0 | 4 votes |
/** * @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; }
Example 18
Source File: RunReportShell.java From RepDev with GNU General Public License v3.0 | 4 votes |
public RunReportShell(Shell parent, SymitarFile file) { this.parent = parent; display = parent.getDisplay(); this.file = file; this.sym = file.getSym(); }
Example 19
Source File: ShowHelpDialog.java From pentaho-kettle with Apache License 2.0 | 4 votes |
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(); } } }
Example 20
Source File: RepositoriesController.java From pentaho-kettle with Apache License 2.0 | 4 votes |
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 ); } }