Example usage for org.eclipse.jface.dialogs Dialog setBlockOnOpen

List of usage examples for org.eclipse.jface.dialogs Dialog setBlockOnOpen

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs Dialog setBlockOnOpen.

Prototype

public void setBlockOnOpen(boolean shouldBlock) 

Source Link

Document

Sets whether the open method should block until the window closes.

Usage

From source file:org.bonitasoft.studio.tests.draw2d.TestLifeCycleWidget.java

License:Open Source License

private void testSelectionEvent(final String eventType, final ConnectorEvent eventTypeThatShouldBeselected,
        final int taskLifeCycle) {

    UIThreadRunnable.syncExec(new VoidResult() {
        public void run() {
            Dialog dialog = new Dialog(Display.getDefault().getActiveShell()) {
                @Override//from  w w  w .j  a v  a2 s  .  c  o  m
                protected Control createDialogArea(Composite parent) {
                    Control superParent = super.createDialogArea(parent);

                    lcw = new LifeCycleWidget(parent, eventType, null);
                    return superParent;
                }

                @Override
                protected void configureShell(Shell newShell) {
                    super.configureShell(newShell);
                    newShell.setText("Test Life cycle widget: " + eventType + eventTypeThatShouldBeselected
                            + taskLifeCycle);
                }
            };
            dialog.setBlockOnOpen(false);
            dialog.open();
            bot.waitUntil(Conditions.shellIsActive(
                    "Test Life cycle widget: " + eventType + eventTypeThatShouldBeselected + taskLifeCycle),
                    10000);
            bot.button(IDialogConstants.CANCEL_LABEL).click();
        }
    });

    final String eventTypeTheoric = eventTypeThatShouldBeselected.toString();
    for (EventCircle eventCircle : lcw.getEventFigures()) {
        final String event = eventCircle.getEvent();
        if (event.equals(eventTypeTheoric)) {
            assertEquals("The event circle" + event + " should be selected",
                    eventCircle.getLocalForegroundColor().getRed(), 73);
        } else {
            assertEquals("The event circle" + event + " should not be selected",
                    eventCircle.getLocalForegroundColor().getRed(), 235);
        }
    }

    bot.waitUntil(Conditions.shellIsActive("Bonita BPM"));

}

From source file:org.codecover.eclipse.views.controls.DeleteTestElementsSelectDialog.java

License:Open Source License

@Override
protected void okPressed() {
    Object[] elementsToDelete;/*ww  w  .  j  a va  2 s.  co m*/
    Dialog confirmDialog;
    elementsToDelete = removeTestCasesOfContainedTestSessions(this.viewer.getCheckedElements());
    this.close();
    if (elementsToDelete.length > 0) {
        confirmDialog = new DeleteTestElementsConfirmDialog(this.getParentShell(), elementsToDelete);
        confirmDialog.setBlockOnOpen(true);
        if (confirmDialog.open() == DeleteTestElementsConfirmDialog.YES_BUTTON_INDEX) {
            try {
                CodeCoverPlugin.getDefault().getTSContainerManager().setActiveTSContainer(this.tscInfo,
                        new DeleteTestElementsRunnable(elementsToDelete), null);
            } catch (FileLoadException e) {
                showRaceConditionErrorDialog(e);
            } catch (OutOfMemoryError e) {
                showRaceConditionErrorDialog(e);
                logger.error("Out of memory while loading" + //$NON-NLS-1$
                        " test session container: " //$NON-NLS-1$
                        + this.tscInfo.getPath().toString(), new InvocationTargetException(e));
            } catch (InvocationTargetException e) {
                if (e.getCause() instanceof ConcurrentModificationException) {
                    showRaceConditionErrorDialog(e.getCause());
                } else {
                    logger.error("Unknown error during" + //$NON-NLS-1$
                            " deletion of" + //$NON-NLS-1$
                            " test sessions/test cases", e); //$NON-NLS-1$
                }
            } catch (CancelException e) {
                logger.warning("User canceled deletion of" + //$NON-NLS-1$
                        " test sessions/test cases during" + //$NON-NLS-1$
                        " execution", e); //$NON-NLS-1$
            }
        }
    }
}

From source file:org.codecover.eclipse.views.controls.DeleteTSCsSelectDialog.java

License:Open Source License

@Override
protected void okPressed() {
    List<TSContainerInfo> tscsToDelete = new ArrayList<TSContainerInfo>();
    Dialog confirmDialog;
    for (Object tsc : this.viewer.getCheckedElements()) {
        tscsToDelete.add((TSContainerInfo) tsc);
    }/*ww  w  .  java  2 s .  c  o m*/
    this.close();
    if (tscsToDelete.isEmpty()) {
        return;
    }
    confirmDialog = new DeleteTSCsConfirmDialog(this.getParentShell(), tscsToDelete);
    confirmDialog.setBlockOnOpen(true);
    if (confirmDialog.open() == DeleteTSCsConfirmDialog.YES_BUTTON_INDEX) {
        try {
            CodeCoverPlugin.getDefault().getTSContainerManager().deleteTestSessionContainers(tscsToDelete,
                    null);
        } catch (CoreException e) {
            ErrorDialog.openError(this.getParentShell(), DIALOG_ERROR_TITLE, null,
                    new Status(IStatus.ERROR, CodeCoverPlugin.PLUGIN_ID, IStatus.OK, DIALOG_ERROR_MSG, e));
        } catch (CancelException e) {
            // ignore because it can't be thrown if no monitor was passed
        }
    }
}

From source file:org.eclipse.compare.tests.TextMergeViewerTest.java

License:Open Source License

private void runInDialog(Object input, Runnable runnable, final CompareConfiguration cc) throws Exception {
    Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    Dialog dialog = new Dialog(shell) {
        protected Control createDialogArea(Composite parent) {
            Composite composite = (Composite) super.createDialogArea(parent);
            viewer = new TestMergeViewer(composite, cc);
            return composite;
        }//from   www .ja  v a  2s  . co  m
    };
    dialog.setBlockOnOpen(false);
    dialog.open();
    viewer.setInput(input);
    try {
        runnable.run();
    } catch (WrappedException e) {
        e.throwException();
    }
    dialog.close();
    viewer = null;
}

From source file:org.eclipse.emf.ecp.rap.spi.util.RAPWrapper.java

License:Open Source License

/**
 * {@inheritDoc}/*w  ww .j a v  a  2  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.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.
 * /*w  w w. jav  a 2  s.  c  o 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.rcp.properties.ProjectGeneralPropertyPage.java

License:Open Source License

/**
 * @param parent The parent <code>Composite</code>
 *//*from w  w  w  .  j  a va2 s .  c o  m*/
private void createTrackChangesDeleteDataButton(Composite parent) {
    m_deleteChanges = new Button(parent, SWT.PUSH);
    m_deleteChanges.setText(Messages.PrefPageTrackChangesDeleteData);
    GridData gridData = new GridData(SWT.END, SWT.BEGINNING, false, false);
    gridData.horizontalSpan = 1;
    gridData.grabExcessHorizontalSpace = false;
    m_deleteChanges.setLayoutData(gridData);

    m_deleteChanges.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            Dialog qDialog = new MessageDialog(getShell(), Messages.UtilsConfirmation, null,
                    Messages.PrefPageTrackChangesDeleteDataQuestion, MessageDialog.QUESTION,
                    new String[] { Messages.UtilsYes, Messages.UtilsNo }, 0);
            qDialog.setBlockOnOpen(true);
            qDialog.open();
            if (qDialog.getReturnCode() == 0) {
                // delete all tracked changes
                try {
                    PlatformUI.getWorkbench().getProgressService().run(true, false,
                            new DeleteTrackedChangesOperation());
                } catch (InvocationTargetException ite) {
                    // nothing
                } catch (InterruptedException ie) {
                    // nothing
                }
            }
        }
    });
}

From source file:org.eclipse.nebula.widgets.treemapper.tests.ProgrammaticTest.java

License:Open Source License

/**
 * @param treeContent//from w w  w.  ja v  a2s  .c o  m
 * @param mappings
 * @return
 */
private Dialog openMapperDialog(final String[] treeContent, final String[] mappings) {
    Dialog dialog = new Dialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()) {
        @Override
        public Composite createDialogArea(Composite parent) {
            Composite res = (Composite) super.createDialogArea(parent);
            TreeMapper<String, String, String> mapper = new TreeMapper<String, String, String>(parent,
                    new ObjectSemanticSupport(),
                    new TreeMapperUIConfigProvider(ColorConstants.blue, 2, ColorConstants.darkBlue, 4));
            mapper.setContentProviders(new ArrayTreeContentProvider(), new ArrayTreeContentProvider());
            mapper.setInput(treeContent, treeContent, Arrays.asList(mappings));
            return res;
        }
    };
    dialog.setBlockOnOpen(false);
    dialog.open();
    return dialog;
}

From source file:org.eclipse.servicesregistry.search.ui.test.classifications.pageobjects.ClassificationsTreePageObject.java

License:Open Source License

private void createUi(final ClassificationTreeContribution contribution,
        final IDiscoveryEnvironment environment) {
    asyncExec(new VoidResult() {
        @Override//from  w  w  w.  j a  v  a 2 s .  co m
        public void run() {
            final Dialog dlg = new Dialog(PlatformUI.getWorkbench().getDisplay().getActiveShell()) {
                @Override
                protected Control createContents(Composite parent) {
                    parent.setLayout(new FillLayout(SWT.VERTICAL));
                    final Composite hostComposite = new Composite(parent, SWT.NONE);
                    hostComposite.setLayout(new FormLayout());
                    contribution.createUi(hostComposite, Mockito.mock(IServicesRegistryDestination.class),
                            toolkit, environment, null);
                    contribution.handleVisibilityChange(true);
                    return parent;
                }
            };

            dlg.setBlockOnOpen(false);
            dlg.open();
            shell = new SWTBotShell(dlg.getShell());
        }
    });

    Assertions.waitAssert(new IWaitCondition() {

        @Override
        public boolean checkCondition() throws ConditionCheckException {
            return shell != null;
        }
    }, "Test shell could not be created");
}

From source file:org.eclipse.ui.tests.harness.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.
 * /*from  w w  w  . j a v a 2 s. c om*/
 * @param dialog the test dialog to be verified.
 * @param assert this is the test case object, assertions will be
 * executed on this object.
 */
public static void assertDialogTexts(Dialog dialog, Assert assertion) {
    Assert.assertNotNull(dialog);
    dialog.setBlockOnOpen(false);
    dialog.open();
    Shell shell = dialog.getShell();
    verifyCompositeText(shell, assertion);
    dialog.close();
}