List of usage examples for org.eclipse.jface.dialogs Dialog getShell
@Override
public Shell getShell()
From source file:eu.udig.catalog.jgrass.core.ChooseCoordinateReferenceSystemDialog.java
License:Open Source License
public void open(Shell parentShell) { goGo = false;//from w w w. j a v a2 s. c o m Dialog dialog = new Dialog(parentShell) { @Override protected void configureShell(Shell shell) { super.configureShell(shell); shell.setText("Choose CRS"); } // @Override // protected Point getInitialSize() { // return new Point(250, 250); // } @Override protected Control createDialogArea(Composite parent) { Composite comp = (Composite) super.createDialogArea(parent); GridLayout gLayout = (GridLayout) comp.getLayout(); gLayout.numColumns = 1; chooser = new CRSChooser(new Controller() { public void handleClose() { buttonPressed(OK); } public void handleOk() { buttonPressed(OK); } }); return chooser.createControl(parent); } @Override protected void buttonPressed(int buttonId) { if (buttonId == OK) { try { crs = chooser.getCRS(); } catch (Exception e) { } } close(); goGo = true; } }; dialog.setBlockOnOpen(true); dialog.open(); while (!goGo) { if (dialog.getShell().isDisposed()) { break; } if (Display.getCurrent().readAndDispatch()) { // dialog.getShell().getDisplay().readAndDispatch()) { continue; } if (goGo) { break; } try { Thread.sleep(300); } catch (InterruptedException ex) { ex.printStackTrace(); } } }
From source file:gov.redhawk.ui.util.SWTUtil.java
License:Open Source License
/** * Sets the dialog size.//w w w . j a v a2 s . c om * * @param dialog the dialog * @param width the width * @param height the height */ public static void setDialogSize(final Dialog dialog, int width, int height) { final Point computedSize = dialog.getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT); width = Math.max(computedSize.x, width); height = Math.max(computedSize.y, height); dialog.getShell().setSize(width, height); }
From source file:net.sf.eclipsecs.ui.util.SWTUtil.java
License:Open Source License
/** * Adds support to resizable dialogs for (re)storing the dialog size. * //from w w w .java 2s . com * @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); }
From source file:org.eclipse.emf.ecp.rap.spi.util.RAPWrapper.java
License:Open Source License
/** * {@inheritDoc}//from ww w .j ava2 s . c o m * * @see org.eclipse.emf.ecp.edit.internal.swt.util.DialogWrapper#openDialog(org.eclipse.jface.dialogs.Dialog, * org.eclipse.emf.ecp.edit.spi.swt.util.ECPDialogExecutor) * @since 1.5 */ @Override public void openDialog(final Dialog dialog, final ECPDialogExecutor callBack) { dialog.setBlockOnOpen(false); dialog.open(); dialog.getShell().addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent event) { callBack.handleResult(dialog.getReturnCode()); } }); }
From source file:org.eclipse.jst.jsf.common.ui.internal.dialogfield.AbstractClassButtonDialogField.java
License:Open Source License
private void setDialogSize(Dialog dialog, int width, int height) { Point computedSize = dialog.getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT); width = Math.max(computedSize.x, width); height = Math.max(computedSize.y, height); dialog.getShell().setSize(width, height); }
From source file:org.eclipse.jst.server.tomcat.ui.tests.UITestHelper.java
License:Open Source License
/** * Automated test that checks all the labels and buttons of a dialog * to make sure there is enough room to display all the text. Any * text that wraps is only approximated and is currently not accurate. * /*from w w w . jav a2s.co m*/ * @param dialog the test dialog to be verified. */ public static void assertDialog(Dialog dialog) { Assert.assertNotNull(dialog); dialog.setBlockOnOpen(false); dialog.open(); Shell shell = dialog.getShell(); verifyCompositeText(shell); dialog.close(); }
From source file:org.eclipse.jubula.client.ui.utils.DialogUtils.java
License:Open Source License
/** * Sets the technical widget name for the given dialog in the corresponding * parent shell, if that shell exists and is modal. * Otherwise nothing is done.// w ww . java 2 s . com * NOTE: This method must be called after create() was called on the dialog. * The widget name cannot be set in the dialog itself. * @param dialog the modal dialog for that the wigdet name has to be set in * the corresponding parent shell */ public static void setWidgetNameForModalDialog(Dialog dialog) { final Shell parentShell = dialog.getShell(); if ((parentShell != null) && ((parentShell.getStyle() & MODAL) > 0)) { setWidgetName(parentShell, getShortClassName(dialog.getClass())); } }
From source file:org.eclipse.oomph.internal.ui.Capture.java
License:Open Source License
public Image capture() { final AtomicReference<Image> image = new AtomicReference<Image>(); final Display display = PlatformUI.getWorkbench().getDisplay(); final org.eclipse.jface.dialogs.Dialog backgroundDialog = new org.eclipse.jface.dialogs.Dialog( (Shell) null) {/*from w w w . j a v a 2 s . c o m*/ { setShellStyle(SWT.MAX); } @Override protected Control createDialogArea(Composite parent) { Control control = super.createDialogArea(parent); control.setBackground(display.getSystemColor(SWT.COLOR_WHITE)); return control; } }; UIUtil.asyncExec(new Runnable() { public void run() { backgroundDialog.open(); } }); while (backgroundDialog.getShell() == null) { try { Thread.sleep(100); } catch (InterruptedException ex) { // Ignore. } } final Shell backgroundShell = backgroundDialog.getShell(); final T element = new WorkUnit<T, RuntimeException>() { @Override protected T doExecute() { backgroundShell.setMaximized(true); return create(backgroundShell); } }.execute(); UIUtil.asyncExec(new Runnable() { public void run() { open(element); } }); UIUtil.asyncExec(new Runnable() { public void run() { Shell shell = getShell(element); Rectangle bounds = shell.getBounds(); bounds.x = 30; bounds.y = 50; shell.setBounds(bounds); } }); while (!new WorkUnit<Boolean, RuntimeException>() { @Override protected Boolean doExecute() { return isReady(element); } }.execute()) { try { Thread.sleep(100); } catch (InterruptedException ex) { // Ignore. } } try { Thread.sleep(1000); } catch (InterruptedException ex) { // Ignore. } new WorkUnit.Void<RuntimeException>() { @Override protected void doProcess() { preprocess(element); } }.execute(); new WorkUnit.Void<RuntimeException>() { @Override protected void doProcess() { postProcess(element); } }.execute(); new WorkUnit.Void<RuntimeException>() { @Override protected void doProcess() { image.set(capture(element)); } }.execute(); new WorkUnit.Void<RuntimeException>() { @Override protected void doProcess() { close(element); backgroundShell.close(); } }.execute(); return image.get(); }
From source file:org.eclipse.pde.internal.ui.search.dependencies.ShowResultsAction.java
License:Open Source License
public void run() { if (fUnusedImports.length == 0) { MessageDialog.openInformation(PDEPlugin.getActiveWorkbenchShell(), PDEUIMessages.UnusedDependencies_title, PDEUIMessages.UnusedDependencies_notFound); } else {/* w w w. j a v a2s . co m*/ Dialog dialog; if (fReadOnly) { // Launched from Dependencies View, show information dialog dialog = getUnusedDependeciesInfoDialog(); } else { dialog = new UnusedImportsDialog(PDEPlugin.getActiveWorkbenchShell(), fModel, fUnusedImports); dialog.create(); } dialog.getShell().setText(PDEUIMessages.UnusedDependencies_title); dialog.open(); } }
From source file:org.eclipse.scout.rt.ui.rap.keystroke.KeyStrokeManager.java
License:Open Source License
private boolean isWidgetModalDialog(Widget widget) { if (widget instanceof Shell) { Object data = widget.getData(); if (data instanceof Dialog) { Dialog dialog = (Dialog) data; if ((dialog.getShell().getStyle() & SWT.APPLICATION_MODAL) == SWT.APPLICATION_MODAL) { return true; }/*from w w w . j av a2 s . co m*/ } } return false; }