List of usage examples for org.eclipse.jface.dialogs Dialog close
@Override public boolean close()
From source file:org.eclipse.nebula.widgets.treemapper.tests.ProgrammaticTest.java
License:Open Source License
@Test public void testBug365445_ko() { final String a = "a", b = "b", c = "c"; final String[] treeContent = new String[] { a, b, c }; final String[] mappings = new String[] { a, b, c, "d" }; Dialog dialog = openMapperDialog(treeContent, mappings); dialog.close(); }
From source file:org.eclipse.ui.tests.filteredtree.FilteredTreeTests.java
License:Open Source License
public void testCreateMyFilteredTree() { fRootElement = TestElement.createModel(DEPTH, NUM_ITEMS); final int treeStyle = SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FLAT; Dialog dialog = new FilteredTreeDialog((Shell) null, treeStyle) { protected FilteredTree doCreateFilteredTree(Composite comp, int style) { return createMyFilteredTree(comp, treeStyle); }//from w w w . j a va 2 s .c o m }; dialog.create(); Assert.isNotNull(fTreeViewer, "Filtered tree is null"); int itemCount = fTreeViewer.getViewer().getTree().getItemCount(); Assert.isTrue(itemCount == NUM_ITEMS, "tree item count " + itemCount + " does not match expected: " + NUM_ITEMS); dialog.close(); }
From source file:org.eclipse.ui.tests.filteredtree.FilteredTreeTests.java
License:Open Source License
private void runFilteredTreeTest(final int treeStyle) { fRootElement = TestElement.createModel(DEPTH, NUM_ITEMS); Dialog dialog = new FilteredTreeDialog((Shell) null, treeStyle) { protected FilteredTree doCreateFilteredTree(Composite comp, int style) { return createFilteredTree(comp, treeStyle); }// w ww. j av a 2 s. c om }; dialog.create(); Assert.isNotNull(fTreeViewer, "Filtered tree is null"); int itemCount = fTreeViewer.getViewer().getTree().getItemCount(); Assert.isTrue(itemCount == NUM_ITEMS, "tree item count " + itemCount + " does not match expected: " + NUM_ITEMS); dialog.close(); }
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. * //w w w .ja v a 2s. c o m * @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(); }
From source file:org.eclipse.ui.tests.leaks.LeakTests.java
License:Open Source License
/** * Test for leaks if dialog is disposed before it is closed. * This is really testing the framework rather than individual * dialogs, since many dialogs or windows will fail if the shell * is destroyed prior to closing them./*from w w w . j av a2s . c o m*/ * See bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=123296 */ public void testDestroyedDialogLeaks() throws Exception { ReferenceQueue queue = new ReferenceQueue(); // Use SaveAs dialog because it's simple to invoke and utilizes // framework function such as storing dialog bounds. // We are really testing the framework itself here. Dialog newDialog = new SaveAsDialog(fWin.getShell()); newDialog.setBlockOnOpen(false); newDialog.open(); assertNotNull(newDialog); Reference ref = createReference(queue, newDialog); try { // Dispose the window before closing it. newDialog.getShell().dispose(); newDialog.close(); newDialog = null; checkRef(queue, ref); } finally { ref.clear(); } }
From source file:org.eclipse.vjet.testframework.util.DefaultDialogProcessor.java
License:Open Source License
public void processDialog(Object dialog) { /**//w ww . j a v a2 s.co m * If this is a ProgressMonitorDialog, then ignore. The ProgressMonitorDialog does * not block the UI from running. */ if (dialog instanceof ProgressMonitorDialog) { return; } System.out.println("Processing dialog: " + dialog.getClass().getName()); // Handle jface dialog if (dialog instanceof org.eclipse.jface.dialogs.Dialog) { org.eclipse.jface.dialogs.Dialog jfaceDialog = (org.eclipse.jface.dialogs.Dialog) dialog; jfaceDialog.close(); return; } // Handle swt dialog if (dialog instanceof org.eclipse.swt.widgets.Dialog) { org.eclipse.swt.widgets.Dialog swtDialog = (org.eclipse.swt.widgets.Dialog) dialog; Assert.fail("org.eclipse.swt.widgets.Dialog is currently not supported"); return; } // Handle dialogPage. These are typically some sort of wizard if (dialog instanceof DialogPage) { DialogPage dialogPage = (DialogPage) dialog; Assert.fail("DialogPage is currently not supported"); return; } }
From source file:org.locationtech.udig.catalog.tests.ui.workflow.BasicWorkflowTest.java
License:Open Source License
@Test public void testNonBlocking() { Shell shell = new Shell(Display.getDefault()); final Dialog dialog = new Dialog(shell) { };/*from ww w . j a v a 2 s. co m*/ Listener1 l = new Listener1() { @Override public void finished(State state) { super.finished(state); Display.getDefault().asyncExec(new Runnable() { public void run() { dialog.close(); } }); } }; pipe.addListener(l); pipe.start(); pipe.next(); pipe.next(); pipe.next(); pipe.next(); pipe.next(); //need to open a dialog here to "halt" the ui thread so that the // the workbench doesn't close while the pipe is still running dialog.setBlockOnOpen(true); dialog.open(); if (!shell.isDisposed()) shell.dispose(); assertTrue(l.state1); assertTrue(l.state2); assertTrue(l.state3); assertTrue(l.state4); assertTrue(l.state5); assertTrue(l.finished); assertTrue(!l.fail); assertEquals(i, 6); assertNotNull(pipe.getState(State1.class)); assertNotNull(pipe.getState(State2.class)); assertNotNull(pipe.getState(State3.class)); assertNotNull(pipe.getState(State4.class)); assertNotNull(pipe.getState(State5.class)); assertTrue(pipe.getState(State1.class).ran); assertTrue(pipe.getState(State2.class).ran); assertTrue(pipe.getState(State3.class).ran); assertTrue(pipe.getState(State4.class).ran); assertTrue(pipe.getState(State5.class).ran); }
From source file:org.locationtech.udig.catalog.tests.ui.workflow.BasicWorkflowTest.java
License:Open Source License
@Ignore @Test//from w w w . j a v a 2 s . com public void testStateFailureNonBlocking() { Shell shell = new Shell(Display.getDefault()); final Dialog dialog = new Dialog(shell) { }; //test where one state craps out s4.run = false; Listener1 l = new Listener2() { @Override public void stateFailed(State state) { super.stateFailed(state); if (dialog.getShell().isVisible()) { dialog.getShell().getDisplay().asyncExec(new Runnable() { public void run() { dialog.close(); }; }); } } @Override public void finished(State state) { super.finished(state); dialog.close(); } }; pipe.addListener(l); pipe.start(); pipe.next(); pipe.next(); pipe.next(); pipe.next(); pipe.next(); //need to open a dialog here to "halt" the ui thread so that the // the workbench doesn't close while the pipe is still running // create a watchdog to kill it after a specified amount of time Runnable runnable = new Runnable() { public void run() { System.out.println("Running"); //$NON-NLS-1$ try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("Is dialog active dialog"); //$NON-NLS-1$ Display.getDefault().syncExec(new Runnable() { public void run() { if (dialog.getShell().isVisible()) { dialog.close(); } } }); } }; new Thread(runnable).start(); dialog.setBlockOnOpen(true); if (!l.finished) dialog.open(); if (!shell.isDisposed()) shell.dispose(); assertTrue(l.state1); assertTrue(l.state2); assertTrue(l.state3); assertTrue(!l.state4); assertTrue(!l.state5); assertTrue(!l.finished); assertTrue(!l.fail); assertEquals(i, 4); assertNotNull(pipe.getState(State1.class)); assertNotNull(pipe.getState(State2.class)); assertNotNull(pipe.getState(State3.class)); assertNotNull(pipe.getState(State4.class)); assertNull(pipe.getState(State5.class)); assertTrue(pipe.getState(State1.class).ran); assertTrue(pipe.getState(State2.class).ran); assertTrue(pipe.getState(State3.class).ran); assertTrue(pipe.getState(State4.class).ran); assertEquals(pipe.getCurrentState(), s4); }