Example usage for org.eclipse.jface.wizard IWizardPage getErrorMessage

List of usage examples for org.eclipse.jface.wizard IWizardPage getErrorMessage

Introduction

In this page you can find the example usage for org.eclipse.jface.wizard IWizardPage getErrorMessage.

Prototype

String getErrorMessage();

Source Link

Document

Returns the current error message for this dialog page.

Usage

From source file:com.windowtester.runtime.swt.locator.jface.WizardErrorMessageLocator.java

License:Open Source License

public String getText(IUIContext ui) throws WidgetSearchException {
    final String[] errorMessage = new String[1];
    final Exception[] exception = new Exception[1];
    Display.getDefault().syncExec(new Runnable() {
        public void run() {
            Shell activeShell = Display.getDefault().getActiveShell();
            if (activeShell == null) {
                exception[0] = new WidgetSearchException("No active shell");
                return;
            }/*from  ww  w.  ja  v  a  2  s. co  m*/
            Object dialog = activeShell.getData();
            if (!(dialog instanceof WizardDialog)) {
                exception[0] = new WidgetSearchException("Expected WizardDialog but found " + dialog);
                return;
            }
            final IWizardPage page = ((WizardDialog) dialog).getCurrentPage();
            if (page == null) {
                exception[0] = new WidgetSearchException("WizardDialog current page is null");
                return;
            }
            errorMessage[0] = page.getErrorMessage();
        }
    });
    if (exception[0] != null)
        throw ((WidgetSearchException) exception[0]);
    return errorMessage[0];
}

From source file:eu.geclipse.ui.wizards.ConnectionWizard.java

License:Open Source License

private void setCurrentErrorMessage(final IWizardPage fromPage) {
    String errorMessage = fromPage.getErrorMessage();
    WizardPage toPage = (WizardPage) getContainer().getCurrentPage();
    toPage.setErrorMessage(errorMessage);
}

From source file:org.eclipse.m2e.integration.tests.common.UIIntegrationTestCase.java

License:Open Source License

protected static void assertWizardMessage(final String message, final int severity) throws Exception {
    bot.sleep(1000);/* w w w.  j a v  a  2 s .c o  m*/
    final AssertionError[] error = new AssertionError[] { null };
    Display.getDefault().syncExec(new Runnable() {
        public void run() {
            try {
                Object data = bot.activeShell().widget.getData();
                assertTrue("Current dialog is expected to be a wizard", data instanceof WizardDialog);

                boolean error = severity == WizardPage.ERROR;

                IWizardPage page = ((WizardDialog) data).getCurrentPage();
                String wizardMessage = error ? page.getErrorMessage() : page.getMessage();
                String prefix = error ? "Wizard error " : "Wizard message ";

                if (message == null) {
                    assertNull(prefix + "should be null", wizardMessage);
                } else {
                    assertNotNull(prefix + "should not be null", wizardMessage);
                    assertEquals(prefix + "is not as expected", message, wizardMessage.trim());
                }
            } catch (AssertionError e) {
                error[0] = e;
            }
        }
    });
    if (error[0] != null) {
        takeScreenShot(error[0]);
    }
}

From source file:org.eclipse.ui.tests.dialogs.UIEditWorkingSetWizardAuto.java

License:Open Source License

public void testEditPage() throws Throwable {
    IWizardPage page = fWizardDialog.getCurrentPage();
    assertTrue(page instanceof IWorkingSetPage);

    /*//from  www . ja  v  a  2  s  .c o m
     * Verify that correct working set edit page is displayed
     */
    assertTrue(page.getClass() == fDefaultEditPage.getClass());
    /*
     * Test initial page state
     */
    assertTrue(page.canFlipToNextPage() == false);
    assertTrue(fWizard.canFinish() == false);
    assertNull(page.getErrorMessage());
    /*
     * Test page state with preset page input
     */
    IWorkingSetManager workingSetManager = fWorkbench.getWorkingSetManager();
    IWorkingSet workingSet = workingSetManager.createWorkingSet(WORKING_SET_NAME_1,
            new IAdaptable[] { p1, f2 });
    ((WorkingSetEditWizard) fWizard).setSelection(workingSet);

    List widgets = getWidgets((Composite) page.getControl(), Text.class);
    Text text = (Text) widgets.get(0);
    assertEquals(WORKING_SET_NAME_1, text.getText());
    assertTrue(page.canFlipToNextPage() == false);
    assertTrue(fWizard.canFinish() == false);
    assertNull(page.getErrorMessage());
    widgets = getWidgets((Composite) page.getControl(), Tree.class);
    Tree tree = (Tree) widgets.get(0);
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    assertEquals(workspace.getRoot().getProjects().length, tree.getItemCount());
    setTextWidgetText(WORKING_SET_NAME_2, page);
    assertTrue(fWizard.canFinish());

    /*
     * Test page state with partial page input
     */
    setTextWidgetText("", page);
    assertTrue(page.canFlipToNextPage() == false);
    assertTrue(fWizard.canFinish() == false);
    assertNotNull(page.getErrorMessage());

    /*
     * Test page state with complete page input
     */
    setTextWidgetText(WORKING_SET_NAME_2, page);
    checkTreeItems();
    assertTrue(page.canFlipToNextPage() == false);
    assertTrue(fWizard.canFinish());
    assertNull(page.getErrorMessage());

    fWizard.performFinish();
    workingSet = ((WorkingSetEditWizard) fWizard).getSelection();
    IAdaptable[] workingSetItems = workingSet.getElements();
    assertEquals(WORKING_SET_NAME_2, workingSet.getName());
    assertTrue(ArrayUtil.contains(workingSetItems, p1));
    assertTrue(ArrayUtil.contains(workingSetItems, p2));

    DialogCheck.assertDialogTexts(fWizardDialog, this);
}

From source file:org.eclipse.ui.tests.dialogs.UINewWorkingSetWizardAuto.java

License:Open Source License

public void testEditPage() throws Throwable {
    WorkingSetRegistry registry = WorkbenchPlugin.getDefault().getWorkingSetRegistry();
    IWizardPage page = fWizardDialog.getCurrentPage();
    IWizardPage defaultEditPage = registry.getDefaultWorkingSetPage();
    String defaultEditPageClassName = defaultEditPage.getClass().getName();
    WorkingSetDescriptor[] descriptors = getEditableWorkingSetDescriptors();

    // the first page must be the type selection page iff there is more than one working set type
    assertEquals(descriptors.length > 1, (page instanceof WorkingSetTypePage));

    if (page instanceof WorkingSetTypePage) {
        /*//  ww w .  j  a  v a  2  s  . c o  m
         * Select the default (Resource) working set type
         * and advance to edit page.
         */
        List widgets = getWidgets((Composite) page.getControl(), Table.class);
        Table table = (Table) widgets.get(0);
        TableItem[] items = table.getItems();
        String workingSetName = null;
        for (int descriptorIndex = 0; descriptorIndex < descriptors.length; descriptorIndex++) {
            WorkingSetDescriptor descriptor = descriptors[descriptorIndex];
            if (defaultEditPageClassName.equals(descriptor.getPageClassName())) {
                workingSetName = descriptor.getName();
                break;
            }
        }
        assertNotNull(workingSetName);
        boolean found = false;
        for (int i = 0; i < items.length; i++) {
            if (items[i].getText().equals(workingSetName)) {
                table.setSelection(i);
                found = true;
                break;
            }
        }
        assertTrue(found);
        fWizardDialog.showPage(fWizard.getNextPage(page));
    }
    page = fWizardDialog.getCurrentPage();
    assertTrue(page instanceof IWorkingSetPage);

    /*
     * Verify that correct working set edit page is displayed
     */
    assertTrue(page.getClass() == defaultEditPage.getClass());
    /*
     * Test initial page state
     */
    assertFalse(page.canFlipToNextPage());
    assertFalse(fWizard.canFinish());
    assertNull(page.getErrorMessage());
    assertNull(page.getMessage());

    /*
     * Test page state with partial page input
     */
    setTextWidgetText(WORKING_SET_NAME_1, page);
    assertFalse(page.canFlipToNextPage());
    assertTrue(fWizard.canFinish()); // allow for empty sets
    assertNull(page.getErrorMessage());
    assertNotNull(page.getMessage());

    /*
     * Test page state with page complete input
     */
    checkTreeItems();
    assertFalse(page.canFlipToNextPage());
    assertTrue(fWizard.canFinish());
    assertNull(page.getErrorMessage());
    assertNull(page.getMessage());

    fWizard.performFinish();
    IWorkingSet workingSet = ((WorkingSetNewWizard) fWizard).getSelection();
    IAdaptable[] workingSetItems = workingSet.getElements();
    assertEquals(WORKING_SET_NAME_1, workingSet.getName());

    List widgets = getWidgets((Composite) page.getControl(), Tree.class);
    Tree tree = (Tree) widgets.get(0);
    assertEquals(workingSetItems.length, tree.getItemCount());
    assertTrue(ArrayUtil.contains(workingSetItems, p1));
    assertTrue(ArrayUtil.contains(workingSetItems, p2));

    /*
     * Check page texts 
     */
    DialogCheck.assertDialogTexts(fWizardDialog, this);
}