Example usage for org.eclipse.jface.util SafeRunnable setIgnoreErrors

List of usage examples for org.eclipse.jface.util SafeRunnable setIgnoreErrors

Introduction

In this page you can find the example usage for org.eclipse.jface.util SafeRunnable setIgnoreErrors.

Prototype

public static void setIgnoreErrors(boolean flag) 

Source Link

Document

Flag to avoid interactive error dialogs during automated testing.

Usage

From source file:org.eclipse.ant.tests.ui.debug.AbstractAntDebugTest.java

License:Open Source License

public AbstractAntDebugTest(String name) {
    super(name);//from  w  w  w .  ja  va 2  s .  c om
    // set error dialog to non-blocking to avoid hanging the UI during test
    ErrorDialog.AUTOMATED_MODE = true;
    SafeRunnable.setIgnoreErrors(true);
}

From source file:org.eclipse.e4.ui.internal.workbench.swt.E4Testable.java

License:Open Source License

/**
 * The <code>WorkbenchTestable</code> implementation of this
 * <code>TestableObject</code> method ensures that the workbench has been
 * set.//from   www.jav  a  2 s .  co m
 */
public void testingStarting() {
    Assert.isNotNull(workbench);
    oldAutomatedMode = ErrorDialog.AUTOMATED_MODE;
    ErrorDialog.AUTOMATED_MODE = true;
    oldIgnoreErrors = SafeRunnable.getIgnoreErrors();
    SafeRunnable.setIgnoreErrors(true);
}

From source file:org.eclipse.e4.ui.internal.workbench.swt.E4Testable.java

License:Open Source License

/**
 * The <code>WorkbenchTestable</code> implementation of this
 * <code>TestableObject</code> method flushes the event queue, then closes
 * the workbench.//w w w  .  j a v  a  2  s .co m
 */
public void testingFinished() {
    // force events to be processed, and ensure the close is done in the UI
    // thread
    display.syncExec(new Runnable() {
        public void run() {
            Assert.isTrue(workbench.close());
        }
    });
    ErrorDialog.AUTOMATED_MODE = oldAutomatedMode;
    SafeRunnable.setIgnoreErrors(oldIgnoreErrors);
}

From source file:org.eclipse.gmf.tests.runtime.common.ui.action.actions.global.GlobalRedoActionTest.java

License:Open Source License

/**
 * Tests that the action is not enabled when it's part is closed.
 *//*from   ww  w  .  j ava  2s.c  om*/
public void ignore_dispose_131781() {

    // Enables testing that closing the view doesn't cause exceptions to be
    // reported to the user
    SafeRunnable.setIgnoreErrors(false);

    // Re-set the undo context to ensure that the RedoActionHandler's part
    // listener is registered AFTER the GlobalRedoAction. We can then test
    // that closing the part doesn't cause the RedoActionHandler's part
    // listener to throw an NPE.
    redoAction.setUndoContext(redoAction.getUndoContext());

    try {
        OperationHistoryFactory.getOperationHistory().undo(redoAction.getUndoContext(),
                new NullProgressMonitor(), null);
    } catch (ExecutionException e) {
        e.printStackTrace();
        fail("Unexpected exception: " + e.getLocalizedMessage()); //$NON-NLS-1$
    }

    assertTrue(redoAction.isEnabled());

    // Close the view
    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().hideView(part);

    assertFalse(redoAction.isEnabled());

    SafeRunnable.setIgnoreErrors(true);
}

From source file:org.eclipse.gmf.tests.runtime.common.ui.action.actions.global.GlobalUndoActionTest.java

License:Open Source License

/**
 * Tests that the action is not enabled when it's part is closed.
 *//* w ww  .ja  va 2  s  .c o m*/
public void ignore_dispose_131781() throws PartInitException {

    // Enables testing that closing the view doesn't cause exceptions to be
    // reported to the user
    SafeRunnable.setIgnoreErrors(false);

    // Re-set the undo context to ensure that the UndoActionHandler's part
    // listener is registered AFTER the GlobalUndoAction. We can then test
    // that closing the part doesn't cause the UndoActionHandler's part
    // listener to throw an NPE.
    undoAction.setUndoContext(undoAction.getUndoContext());

    try {
        OperationHistoryFactory.getOperationHistory().undo(undoAction.getUndoContext(),
                new NullProgressMonitor(), null);
    } catch (ExecutionException e) {
        e.printStackTrace();
        fail("Unexpected exception: " + e.getLocalizedMessage()); //$NON-NLS-1$
    }

    assertTrue(undoAction.isEnabled());

    // Close the view
    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().hideView(part);

    assertFalse(undoAction.isEnabled());

    SafeRunnable.setIgnoreErrors(true);

    // Close the view
    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(part.getViewSite().getId());
}

From source file:org.eclipse.jdt.debug.tests.AbstractDebugTest.java

License:Open Source License

/**
 * Constructor// w  w  w. j av a  2  s. c  om
 * @param name
 */
public AbstractDebugTest(String name) {
    super(name);
    // set error dialog to non-blocking to avoid hanging the UI during test
    ErrorDialog.AUTOMATED_MODE = true;
    SafeRunnable.setIgnoreErrors(true);
}

From source file:org.eclipse.objectteams.otdt.debug.tests.AbstractOTDTDebugTest.java

License:Open Source License

public AbstractOTDTDebugTest(String name) {
    super(name);//from www. j a va 2s  .  c  o  m
    // set error dialog to non-blocking to avoid hanging the UI during test
    ErrorDialog.AUTOMATED_MODE = true;
    SafeRunnable.setIgnoreErrors(true);
}

From source file:org.eclipse.ui.internal.testing.WorkbenchTestable.java

License:Open Source License

/**
 * The <code>WorkbenchTestable</code> implementation of this
 * <code>TestableObject</code> method flushes the event queue,
 * then closes the workbench./*from   w  w w.j  a v  a2 s. co  m*/
 */
public void testingFinished() {
    // force events to be processed, and ensure the close is done in the UI thread
    display.syncExec(new Runnable() {
        public void run() {
            Assert.isTrue(workbench.close());
        }
    });
    ErrorDialog.AUTOMATED_MODE = oldAutomatedMode;
    SafeRunnable.setIgnoreErrors(oldIgnoreErrors);
}

From source file:org.eclipse.wst.debug.core.tests.AbstractDebugTest.java

License:Open Source License

/**
 * Constructor
 * @param name
 */
public AbstractDebugTest(String name) {
    super(name);
    SafeRunnable.setIgnoreErrors(true);
}

From source file:org.fusesource.ide.camel.test.util.editor.AbstractCamelEditorIT.java

License:Open Source License

@Before
public void setup() throws Exception {
    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    IWorkbenchPart welcomePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
            .getActivePart();//from w  w  w .  j ava  2s . co m
    welcomePage.dispose();
    page.closeAllEditors(false);
    page.closeAllPerspectives(false, false);
    PlatformUI.getWorkbench().showPerspective(FusePerspective.ID, page.getWorkbenchWindow());
    safeRunnableIgnoreErrorStateBeforeTests = SafeRunnable.getIgnoreErrors();
    SafeRunnable.setIgnoreErrors(false);
    statusHandlerBeforetest = Policy.getStatusHandler();
    statusHandlerCalled = false;
    Policy.setStatusHandler(new StatusHandler() {

        @Override
        public void show(IStatus status, String title) {
            statusHandlerCalled = true;
        }
    });
}