List of usage examples for org.eclipse.jface.dialogs Dialog getShell
@Override
public Shell getShell()
From source file:com.bdaum.zoom.ui.internal.views.DataEntryView.java
License:Open Source License
protected void setDialogLocation(Dialog dialog) { dialog.create();//from www.jav a2 s .c o m Point location = dialog.getShell().getLocation(); location.x -= 25; location.y += 30; dialog.getShell().setLocation(location); }
From source file:com.mentor.nucleus.bp.io.mdl.test.pkgcm.EditorTestUtilities.java
License:Open Source License
/** * This method emulate button press behavior on active model dialog, this * method must be called before model dialog is displayed. * @param buttonToPress Text of button, use provided static constants * @param title title of the dialog, only to be more specific * @param afterHowMuchTime after how much time to invoke the operation, as * this method is called before invocation of dialog, this method will wait for * dialog display for <b>afterHowMuchTime</b> mili secs between successive * tries./* ww w . ja va 2s . c o m*/ */ public static void DoDialog(final String buttonToPress, final String title, final int afterHowMuchTime) { final int maxRecursionDepth = 10; Display.getCurrent().asyncExec(new Runnable() { public void run() { // wait to give the expected modal dialog time to get displayed TestUtil.sleep(afterHowMuchTime); for (int callNumber = 0; callNumber < maxRecursionDepth; callNumber++) { // if the currently active shell is a dialog Shell shell = Display.getDefault().getActiveShell(); if (shell != null && shell.getData() instanceof Dialog) { Dialog dialog = (Dialog) shell.getData(); if (dialog.getShell().getText().startsWith(title)) { if (doDialog(dialog, buttonToPress)) return;//button done successfully else TestUtil.sleep(afterHowMuchTime); //wait for dialog to dispaly } } } //end for }//end run }); }
From source file:com.mentor.nucleus.bp.test.TestUtil.java
License:Open Source License
public static FailableRunnable chooseItemInDialog(final int sleep, final FailableRunnable waitRunnable, final String item, final boolean locateOnly, final boolean testNonExistence) { FailableRunnable runnable = new FailableRunnable() { @Override/*from w ww . j ava 2s . c o m*/ public void run() { sleep(sleep); waitForRunnable(waitRunnable); FailableRunnable innerRunnable = new FailableRunnable() { @Override public void run() { boolean found = false; // locate the dialog Shell[] shells = PlatformUI.getWorkbench().getDisplay().getShells(); Shell shell = null; for (int i = 0; i < shells.length; i++) { if (shells[i].getData() instanceof ElementSelectionDialog) { shell = shells[i]; break; } else if (shells[i].getText().contains("Import Projects from Git Repository")) { shell = shells[i]; break; } } if (shell != null) { Dialog dialog = (Dialog) shell.getData(); Control[] children = dialog.getShell().getChildren(); for (int i = 0; i < children.length; i++) { Table table = findTable(children); if (table != null) { // if a deselect all button is present // press it before selecting the desired // item Button deselect = findButton(shell, "&Deselect All"); if (deselect != null) { deselect.notifyListeners(SWT.Selection, new Event()); while (PlatformUI.getWorkbench().getDisplay().readAndDispatch()) ; } TableItem[] items = table.getItems(); for (int j = 0; j < items.length; j++) { if (items[j].getText().equals(item)) { // do not select if locateOnly is // true if (!locateOnly) { table.setSelection(items[j]); Event event = new Event(); event.item = items[j]; table.notifyListeners(SWT.Selection, event); while (PlatformUI.getWorkbench().getDisplay().readAndDispatch()) ; } found = true; break; } } break; } } } if (testNonExistence) { if (found) { setFailure("Found the unexpected item in the selection dialog (" + item + ")."); } } else { if (!found) { setFailure("Could not locate the expected item in the selection dialog (" + item + ")."); } } setComplete(); } private Table findTable(Control[] children) { for (Control child : children) { if (child instanceof Table) { return (Table) child; } else if (child instanceof Composite) { Table result = findTable(((Composite) child).getChildren()); if (result != null) { return result; } } } return null; } }; // must be run in the UI thread PlatformUI.getWorkbench().getDisplay().syncExec(innerRunnable); if (!innerRunnable.getFailure().equals("")) { setFailure(innerRunnable.getFailure()); } setComplete(); } }; Thread chooserThread = new Thread(runnable); chooserThread.start(); return runnable; }
From source file:com.motorola.studio.android.common.utilities.ui.WidgetsUtil.java
License:Apache License
/** * Center the dialog./*from w ww . j a v a 2 s . c o m*/ * * @param dialog The dialog. */ public static void centerDialog(Dialog dialog) { centerDialog(dialog.getShell()); }
From source file:com.siteview.mde.internal.ui.search.dependencies.ShowResultsAction.java
License:Open Source License
public void run() { if (fUnusedImports.length == 0) { MessageDialog.openInformation(MDEPlugin.getActiveWorkbenchShell(), MDEUIMessages.UnusedDependencies_title, MDEUIMessages.UnusedDependencies_notFound); } else {//from ww w .ja va 2 s . com Dialog dialog; if (fReadOnly) { // Launched from Dependencies View, show information dialog dialog = getUnusedDependeciesInfoDialog(); } else { dialog = new UnusedImportsDialog(MDEPlugin.getActiveWorkbenchShell(), fModel, fUnusedImports); dialog.create(); } dialog.getShell().setText(MDEUIMessages.UnusedDependencies_title); dialog.open(); } }
From source file:com.siteview.mde.internal.ui.util.SWTUtil.java
License:Open Source License
public static 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:com.tocea.scertify.eclipse.scertifycode.ui.util.SWTUtil.java
License:Open Source License
/** * Adds support to resizable dialogs for (re)storing the dialog size. * //w ww . j a v a2 s. c o m * @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) { final Shell shell = dialog.getShell(); final ShellResizeSupportListener shellSupport = new ShellResizeSupportListener(dialog, settings, dialogKey); shell.addControlListener(shellSupport); shell.addShellListener(shellSupport); shell.addDisposeListener(shellSupport); }
From source file:eclipse.testframework.ui.util.DialogCheck.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. * * @param dialog the test dialog to be verified. *///from w ww. j a v a2s .c o m public static void assertDialogTexts(Dialog dialog) { Assert.assertNotNull(dialog); dialog.setBlockOnOpen(false); dialog.open(); Shell shell = dialog.getShell(); verifyCompositeText(shell); dialog.close(); }
From source file:eu.hydrologis.jgrass.ui.utilities.CatalogJGrassMapsetTreeViewerDialog.java
License:Open Source License
public void open(Shell parentShell) { try {//ww w .j a va2 s.c o m setRequireContinue(false); Dialog dialog = new Dialog(parentShell) { @Override protected void configureShell(Shell shell) { super.configureShell(shell); shell.setText(Messages.getString("CatalogJGrassMapsetTreeViewerDialog.choosemapset")); //$NON-NLS-1$ } @Override protected Point getInitialSize() { return new Point(250, 250); } @Override protected Control createDialogArea(Composite parent) { Composite parentPanel = (Composite) super.createDialogArea(parent); GridLayout gLayout = (GridLayout) parentPanel.getLayout(); gLayout.numColumns = 1; active = new CatalogJGrassMapsetsTreeViewer(parentPanel, SWT.BORDER, SWT.SINGLE); return parentPanel; } @Override protected void buttonPressed(int buttonId) { super.buttonPressed(buttonId); if (buttonId == OK) { newLayers = active.getSelectedLayers(); } else { newLayers = null; } setRequireContinue(true); } }; dialog.setBlockOnOpen(true); dialog.open(); while (!isContinueRequired()) { if (dialog.getShell().isDisposed()) { break; } if (Display.getCurrent().readAndDispatch()) { continue; } try { Thread.sleep(300); } catch (InterruptedException ex) { ex.printStackTrace(); } } } catch (Exception e) { e.printStackTrace(); } }
From source file:eu.udig.catalog.jgrass.activeregion.dialogs.CatalogJGrassMapsetTreeViewerDialog.java
License:Open Source License
public void open(Shell parentShell) { try {/* ww w. j a v a 2 s . c o m*/ setRequireContinue(false); Dialog dialog = new Dialog(parentShell) { @Override protected void configureShell(Shell shell) { super.configureShell(shell); shell.setText("Select mapset"); //$NON-NLS-1$ } @Override protected Point getInitialSize() { return new Point(250, 250); } @Override protected Control createDialogArea(Composite parent) { Composite parentPanel = (Composite) super.createDialogArea(parent); GridLayout gLayout = (GridLayout) parentPanel.getLayout(); gLayout.numColumns = 1; active = new CatalogJGrassMapsetsTreeViewer(parentPanel, SWT.BORDER, SWT.SINGLE); return parentPanel; } @Override protected void buttonPressed(int buttonId) { super.buttonPressed(buttonId); if (buttonId == OK) { newLayers = active.getSelectedLayers(); } else { newLayers = null; } setRequireContinue(true); } }; dialog.setBlockOnOpen(true); dialog.open(); while (!isContinueRequired()) { if (dialog.getShell().isDisposed()) { break; } if (Display.getCurrent().readAndDispatch()) { continue; } try { Thread.sleep(300); } catch (InterruptedException ex) { ex.printStackTrace(); } } } catch (Exception e) { e.printStackTrace(); } }