List of usage examples for org.eclipse.jface.dialogs Dialog setBlockOnOpen
public void setBlockOnOpen(boolean shouldBlock)
open
method should block until the window closes. 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 www. ja v a2 s . 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.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 w w w. java 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/*www.j av a 2s .c o m*/ 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); }
From source file:org.locationtech.udig.omsbox.view.widgets.GuiTextField.java
License:Open Source License
@Override public Control makeGui(Composite parent) { int cols = 1; if (isInFile || isInFolder || isOutFile || isOutFolder || isCrs || isMultiline) { cols = 2;/*from w w w .java 2s . c o m*/ } final boolean isFile = isInFile || isOutFile; final boolean isFolder = isInFolder || isOutFolder; parent = new Composite(parent, SWT.NONE); parent.setLayoutData(constraints); GridLayout layout = new GridLayout(cols, false); layout.marginWidth = 0; layout.marginHeight = 0; parent.setLayout(layout); if (!isMultiline) { text = new StyledText(parent, SWT.RIGHT | SWT.BORDER); GridData textGD = new GridData(SWT.FILL, SWT.CENTER, true, false); textGD.widthHint = 100; text.setLayoutData(textGD); // text.setLineAlignment(0, 1, SWT.RIGHT); } else if (isMapcalc) { text = MapcalculatorUtils.createMapcalcPanel(parent, rows); } else { text = new StyledText(parent, SWT.MULTI | SWT.WRAP | SWT.LEAD | SWT.BORDER | SWT.V_SCROLL); GridData textGD = new GridData(SWT.FILL, SWT.CENTER, true, true); textGD.verticalSpan = rows; textGD.widthHint = 100; text.setLayoutData(textGD); } text.addModifyListener(this); text.addFocusListener(this); if (data.fieldValue != null) { String tmp = data.fieldValue; if (tmp.contains(OmsBoxConstants.WORKINGFOLDER)) { // check if there is a working folder defined String workingFolder = OmsBoxPlugin.getDefault().getWorkingFolder(); workingFolder = checkBackSlash(workingFolder, true); if (workingFolder != null) { tmp = tmp.replaceFirst(OmsBoxConstants.WORKINGFOLDER, workingFolder); data.fieldValue = tmp; } else { data.fieldValue = ""; } } data.fieldValue = checkBackSlash(data.fieldValue, isFile); text.setText(data.fieldValue); // text.setSelection(text.getCharCount()); } if (isMultiline) { for (int i = 0; i < rows; i++) { Label dummyLabel = new Label(parent, SWT.NONE); dummyLabel.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false)); // dummyLabel.setText(""); } } if (isFile) { final Button browseButton = new Button(parent, SWT.PUSH); browseButton.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false)); browseButton.setText("..."); browseButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { FileDialog fileDialog = new FileDialog(text.getShell(), isInFile ? SWT.OPEN : SWT.SAVE); String lastFolderChosen = OmsBoxPlugin.getDefault().getLastFolderChosen(); fileDialog.setFilterPath(lastFolderChosen); String path = fileDialog.open(); if (path == null || path.length() < 1) { text.setText(""); } else { path = checkBackSlash(path, isFile); text.setText(path); text.setSelection(text.getCharCount()); setDataValue(); } OmsBoxPlugin.getDefault().setLastFolderChosen(fileDialog.getFilterPath()); } }); } if (isFolder) { final Button browseButton = new Button(parent, SWT.PUSH); browseButton.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false)); browseButton.setText("..."); browseButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { DirectoryDialog directoryDialog = new DirectoryDialog(text.getShell(), isInFolder ? SWT.OPEN : SWT.SAVE); String lastFolderChosen = OmsBoxPlugin.getDefault().getLastFolderChosen(); directoryDialog.setFilterPath(lastFolderChosen); String path = directoryDialog.open(); if (path == null || path.length() < 1) { text.setText(""); } else { path = checkBackSlash(path, isFile); text.setText(path); // text.setSelection(text.getCharCount()); setDataValue(); } OmsBoxPlugin.getDefault().setLastFolderChosen(directoryDialog.getFilterPath()); } }); } if (isCrs) { // the crs choice group final Button crsButton = new Button(parent, SWT.BORDER); crsButton.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false)); crsButton.setText("..."); //$NON-NLS-1$ crsButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() { public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { Shell shell = new Shell(text.getShell(), SWT.SHELL_TRIM); Dialog dialog = new Dialog(shell) { private CRSChooser chooser; private CoordinateReferenceSystem crs; @Override protected void configureShell(Shell shell) { super.configureShell(shell); shell.setText("Choose CRS"); } @Override protected Control createDialogArea(Composite parent) { Composite comp = (Composite) super.createDialogArea(parent); GridLayout gLayout = (GridLayout) comp.getLayout(); gLayout.numColumns = 1; chooser = new CRSChooser(new Controller() { public void handleClose() { buttonPressed(OK); } public void handleOk() { buttonPressed(OK); } }); return chooser.createControl(parent); } @Override protected void buttonPressed(int buttonId) { if (buttonId == OK) { crs = chooser.getCRS(); try { String codeFromCrs = OmsBoxUtils.getCodeFromCrs(crs); text.setText(codeFromCrs); } catch (Exception e) { e.printStackTrace(); } } close(); } }; dialog.setBlockOnOpen(true); dialog.open(); } }); // initially set to map's crs IMap activeMap = ApplicationGIS.getActiveMap(); if (activeMap != null) { try { CoordinateReferenceSystem crs = activeMap.getViewportModel().getCRS(); String codeFromCrs = OmsBoxUtils.getCodeFromCrs(crs); text.setText(codeFromCrs); setDataValue(); } catch (Exception e) { e.printStackTrace(); } } } if (isNorthing || isEasting || isEastingNorthing) { addMapMouseListener(); } if (isProcessing()) { addRegionListener(); ILayer processingRegionLayer = OmsBoxPlugin.getDefault().getProcessingRegionMapGraphic(); IStyleBlackboard blackboard = processingRegionLayer.getStyleBlackboard(); Object object = blackboard.get(ProcessingRegionStyleContent.ID); if (object instanceof ProcessingRegionStyle) { ProcessingRegionStyle processingStyle = (ProcessingRegionStyle) object; setRegion(processingStyle); } } text.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { if (isNorthing || isEasting || isEastingNorthing) { removeMapMouseListener(); } if (isProcessing()) { removeRegionListener(); } } }); addDrop(); return text; }
From source file:org.locationtech.udig.processingtoolbox.ToolboxView.java
License:Open Source License
@Override public void createPartControl(Composite parent) { // create tree viewer PatternFilter patternFilter = new PatternFilter(); FilteredTree filter = new FilteredTree(parent, SWT.SINGLE | SWT.BORDER, patternFilter, true); viewer = filter.getViewer();//from w w w. j a v a 2s. co m viewer.setContentProvider(new ViewContentProvider()); viewer.setLabelProvider(new ViewLabelProvider()); viewer.setAutoExpandLevel(2); viewer.setInput(buildTree()); viewer.addDoubleClickListener(new IDoubleClickListener() { @Override public void doubleClick(DoubleClickEvent event) { IStructuredSelection selection = (IStructuredSelection) viewer.getSelection(); final TreeObject node = (TreeObject) selection.getFirstElement(); if (TreeParent.class.isAssignableFrom(node.getClass())) { return; } final Shell shell = Display.getCurrent().getActiveShell(); final IMap map = ApplicationGIS.getActiveMap(); Display.getCurrent().asyncExec(new Runnable() { @SuppressWarnings("nls") @Override public void run() { if (map != ApplicationGIS.NO_MAP) { Dialog dialog = null; if (node.getFactory() == null) { String nodeName = node.getProcessName().getLocalPart(); if (nodeName.equalsIgnoreCase("BoxPlotDialog")) { dialog = new BoxPlotDialog(shell, map); } else if (nodeName.equalsIgnoreCase("BubbleChartDialog")) { dialog = new BubbleChartDialog(shell, map); } else if (nodeName.equalsIgnoreCase("FieldCalculatorDialog")) { dialog = new FieldCalculatorDialog(shell, map); } else if (nodeName.equalsIgnoreCase("FormatConversionDialog")) { dialog = new FormatConversionDialog(shell, map); } else if (nodeName.equalsIgnoreCase("HistogramDialog")) { dialog = new HistogramDialog(shell, map); } else if (nodeName.equalsIgnoreCase("MoranScatterPlotDialog")) { dialog = new MoranScatterPlotDialog(shell, map); } else if (nodeName.equalsIgnoreCase("ScatterPlotDialog")) { dialog = new ScatterPlotDialog(shell, map); } else if (nodeName.equalsIgnoreCase("TextfileToPointDialog")) { dialog = new TextfileToPointDialog(shell, map); } else if (nodeName.equalsIgnoreCase("ThematicMapDialog")) { dialog = new ThematicMapDialog(shell, map); } else if (nodeName.equalsIgnoreCase("GeometryToFeaturesDialog")) { dialog = new GeometryToFeaturesDialog(shell, map); } else if (nodeName.equalsIgnoreCase("SpatialWeightsMatrixDialog")) { dialog = new SpatialWeightsMatrixDialog(shell, map); } else if (nodeName.equalsIgnoreCase("MergeFeaturesDialog")) { dialog = new MergeFeaturesDialog(shell, map); } else if (nodeName.equalsIgnoreCase("SplitByAttributesDialog")) { dialog = new SplitByAttributesDialog(shell, map); } else if (nodeName.equalsIgnoreCase("SplitByFeaturesDialog")) { dialog = new SplitByFeaturesDialog(shell, map); } else if (nodeName.equalsIgnoreCase("ExportStyleDialog")) { dialog = new ExportStyleDialog(shell, map); } else if (nodeName.equalsIgnoreCase("AmoebaWizardDialog")) { dialog = new AmoebaWizardDialog(shell, new AmoebaWizard(map)); } } else { dialog = new ProcessExecutionDialog(shell, map, node.getFactory(), node.getProcessName()); } if (dialog != null) { dialog.setBlockOnOpen(true); dialog.open(); } } else { MessageDialog.openInformation(shell, Messages.ToolboxView_Title, Messages.ToolboxView_NoActiveMap); } } }); } }); // action bar IToolBarManager toolbarMgr = getViewSite().getActionBars().getToolBarManager(); toolbarMgr.add(getEnvironmentAction()); }
From source file:org.locationtech.udig.validation.test.FeatureValidationTest.java
License:Open Source License
@Test public void testNullZeroOp() throws Exception { //create features suitable for the test GeometryFactory factory = new GeometryFactory(); // test with 2 arbitrary features, with the second having a null attribute LineString[] line = new LineString[3]; line[0] = factory.createLineString(new Coordinate[] { new Coordinate(10, 10), new Coordinate(10, 20), }); line[1] = factory.createLineString(new Coordinate[] { new Coordinate(20, 10), new Coordinate(20, 20), new Coordinate(30, 15), new Coordinate(20, 15), new Coordinate(20, 30) }); String[] attrValues = new String[2]; attrValues[0] = "value0"; //$NON-NLS-1$ attrValues[1] = null;//from ww w . j a v a2s . c o m SimpleFeatureType ft = DataUtilities.createType("myLineType", "*geom:LineString,name:String"); //$NON-NLS-1$ //$NON-NLS-2$ ft = DataUtilities.createSubType(ft, null, DefaultEngineeringCRS.CARTESIAN_2D); SimpleFeature[] features = new SimpleFeature[2]; // add lines features[0] = SimpleFeatureBuilder.build(ft, new Object[] { line[0], attrValues[0] }, Integer.toString(0)); features[1] = SimpleFeatureBuilder.build(ft, new Object[] { line[1], attrValues[1] }, Integer.toString(1)); //FeatureFactory ff = new FeatureFactory(); IGeoResource resource = MapTests.createGeoResource(features, true); Map map = MapTests.createNonDynamicMapAndRenderer(resource, new Dimension(500, 512)); ValidateNullZero isValidAttr = new ValidateNullZero(); // test the dialog Dialog dialog = isValidAttr.getDialog(Display.getDefault().getActiveShell(), ((ILayer) map.getLayersInternal().get(0)).getSchema()); dialog.setBlockOnOpen(false); dialog.open(); // check the default xPath assertEquals(isValidAttr.xPath, "geom"); // first entry in attributes //$NON-NLS-1$ //set a new xPath isValidAttr.combo.select(1); // check the new xPath assertEquals(isValidAttr.xPath, "name"); // second entry in attributes //$NON-NLS-1$ // other checks... System.out.println("END OF DIALOG TESTS"); //$NON-NLS-1$ ////////assertEquals(1,isValidAttr.genericResults.failedFeatures.size()); }
From source file:org.rdkit.knime.wizards.RDKitNodesWizardsPage.java
License:Open Source License
/** * Shows the help dialog window.//from www . j av a 2 s.c o m */ public void showHelp() { // Copy help files to temp directory URL fileUrlTemp = null; try { fileUrlTemp = makeHelpFilesAvailable(); } catch (IOException exc) { // Ignored - handled later } final Shell parentShell = getShell(); if (fileUrlTemp != null) { final URL fileUrl = fileUrlTemp; Dialog dialog = new Dialog(parentShell) { @Override protected Control createDialogArea(final Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); Browser browser = new Browser(composite, SWT.BORDER | SWT.FILL); browser.setUrl(fileUrl.toString()); GridData data = new GridData(GridData.FILL_BOTH); browser.setLayoutData(data); return composite; } @Override protected void createButtonsForButtonBar(final Composite parent) { // create OK button createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); } @Override protected Point getInitialSize() { return new Point(700, 700); } @Override protected Point getInitialLocation(final Point initialSize) { Dimension dimScreen = Toolkit.getDefaultToolkit().getScreenSize(); return new Point(dimScreen.width / 2 - initialSize.x / 2, dimScreen.height / 2 - initialSize.y / 2); } @Override protected void configureShell(final Shell newShell) { super.configureShell(newShell); newShell.setText("RDKit Node Types"); } }; dialog.setBlockOnOpen(true); dialog.open(); // Blocks } else { MessageBox msgBox = new MessageBox(parentShell, SWT.ICON_ERROR | SWT.OK); msgBox.setText("Error"); msgBox.setMessage("Sorry. The help file is not available."); msgBox.open(); } }
From source file:org.springframework.ide.eclipse.webflow.ui.graph.dialogs.DialogUtils.java
License:Open Source License
/** * @param element// w ww . j a va2s.co m * @param newMode * @param parent * @return */ public static int openPropertiesDialog(final IWebflowModelElement parent, final IWebflowModelElement element, final boolean newMode, final int index) { final Integer[] result = new Integer[1]; final Shell shell = getShell(); Display.getDefault().syncExec(new Runnable() { public void run() { Dialog dialog = null; if (element instanceof IEndState) { dialog = new EndStatePropertiesDialog(shell, parent, (IEndState) element); } else if (element instanceof IViewState) { dialog = new ViewStatePropertiesDialog(shell, parent, (IViewState) element); } else if (element instanceof ISubflowState) { dialog = new SubFlowStatePropertiesDialog(shell, parent, (ISubflowState) element, index); } else if (element instanceof IActionState) { dialog = new ActionStatePropertiesDialog(shell, parent, (IActionState) element); } else if (element instanceof Action) { dialog = new ActionPropertiesDialog(shell, parent, (Action) element); } else if (element instanceof BeanAction) { dialog = new BeanActionPropertiesDialog(shell, parent, (BeanAction) element); } else if (element instanceof EvaluateAction) { dialog = new EvaluateActionPropertiesDialog(shell, parent, (EvaluateAction) element); } else if (element instanceof Set) { dialog = new SetActionPropertiesDialog(shell, parent, (Set) element); } else if (element instanceof OutputAttribute) { dialog = new InputAttributeEditorDialog(shell, (IOutputAttribute) element); } else if (element instanceof InputAttribute) { dialog = new InputAttributeEditorDialog(shell, (IInputAttribute) element); } else if (element instanceof IMapping) { dialog = new MappingEditorDialog(shell, (IMapping) element); } else if (element instanceof ExceptionHandler) { dialog = new ExceptionHandlerPropertiesDialog(shell, parent, (ExceptionHandler) element); } else if (element instanceof IStateTransition) { dialog = new StateTransitionPropertiesDialog(shell, parent, (IStateTransition) element); } else if (element instanceof IDecisionState) { dialog = new DecisionStatePropertiesDialog(shell, parent, (IDecisionState) element); } else if (element instanceof IIf) { dialog = new IfPropertiesDialog(shell, (IDecisionState) parent, (IIf) element, newMode); } else if (element instanceof IWebflowState) { dialog = new WebflowStatePropertiesDialog(shell, (IWebflowState) element); } if (dialog != null) { dialog.setBlockOnOpen(true); result[0] = dialog.open(); } } }); return result[0]; }
From source file:org.wso2.developerstudio.datamapper.diagram.custom.action.ConcatManyAction.java
License:Apache License
/** * {@inheritDoc}/*from w ww. j a va2 s . co m*/ */ protected void doRun(IProgressMonitor progressMonitor) { EditPart selectedEP = getSelectedEditPart(); EObject selectedObj = ((View) selectedEP.getModel()).getElement(); Dialog configureConcat = new ConfigureConcatOperatorDialog(Display.getDefault().getActiveShell(), (Concat) selectedObj, getEditingDomain(), selectedEP); configureConcat.setBlockOnOpen(true); configureConcat.open(); }
From source file:org.wso2.developerstudio.datamapper.diagram.custom.action.ConfigureCustomFunctionAction.java
License:Apache License
/** * {@inheritDoc}//from w ww . j a v a 2 s. c o m */ protected void doRun(IProgressMonitor progressMonitor) { EditPart selectedEP = getSelectedEditPart(); EObject selectedObj = ((View) selectedEP.getModel()).getElement(); Dialog configureCustomFunction = new ConfigureCustomFunctionOperatorDialog( Display.getDefault().getActiveShell(), (CustomFunction) selectedObj, getEditingDomain(), selectedEP); configureCustomFunction.setBlockOnOpen(true); configureCustomFunction.open(); }