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:com.eclipsesource.jshint.ui.internal.preferences.ui.PathPatternDialog_Test.java
License:Open Source License
private static void openNonBlocking(Dialog dialog) { dialog.setBlockOnOpen(false); dialog.open(); }
From source file:com.nextep.designer.vcs.ui.services.impl.VersioningUIService.java
License:Open Source License
@Override public List<IVersionable<?>> undoCheckOut(IProgressMonitor monitor, final IVersionable<?>... checkedOutVersions) { final IWorkspaceService workspaceService = CorePlugin.getService(IWorkspaceService.class); // Building confirm text final List<IVersionable<?>> elts = new ArrayList<IVersionable<?>>(); for (IVersionable<?> v : checkedOutVersions) { if (v.getVersion().getUser() != workspaceService.getCurrentUser()) { throw new ErrorException(MessageFormat.format(VCSUIMessages.getString("undoCheckoutInvalidUser"), //$NON-NLS-1$ v.getType().getName().toLowerCase(), v.getName(), v.getVersion().getUser().getName())); }//from w ww . j a va 2s. c o m elts.add(v); for (IReferenceable r : v.getReferenceMap().values()) { if (r instanceof IVersionable<?>) { if (((IVersionable<?>) r).getVersion().getStatus() == IVersionStatus.CHECKED_OUT) { elts.add((IVersionable<?>) r); } } } } // initializing dialog ConfirmUndoCheckoutDialog commitDlg = new ConfirmUndoCheckoutDialog(elts); Dialog dlg = new TitleAreaDialogWrapper(UIHelper.getShell(), commitDlg, SWT.RESIZE | SWT.TITLE | SWT.BORDER); dlg.setBlockOnOpen(true); dlg.open(); // If user confirmed, we start undo checkout if (dlg.getReturnCode() == Window.OK) { final IVersioningOperationContext context = versioningService .createVersioningContext(VersioningOperation.UNDO_CHECKOUT, Arrays.asList(checkedOutVersions)); // Validation validate(context); // Execution Job j = new BlockingJob(VCSUIMessages.getString("version.ui.undoCheckOutJob")) { //$NON-NLS-1$ @Override protected IStatus run(IProgressMonitor monitor) { try { // listenerService.setDispatchMode(IListenerService.ASYNCHED); List<IVersionable<?>> undoCheckouts = versioningService.undoCheckOut(monitor, context); setSelection(undoCheckouts); } catch (CancelException e) { return Status.CANCEL_STATUS; // } finally { // listenerService.setDispatchMode(IListenerService.SYNCHED); } return Status.OK_STATUS; } }; j.setUser(true); j.schedule(); } return Collections.emptyList(); }
From source file:com.nextep.designer.vcs.ui.validators.VersionSettingsValidator.java
License:Open Source License
@Override public IStatus validate(IVersioningOperationContext context) { List<IUIComponent> components = new ArrayList<IUIComponent>(); // Adding settings validation dialog if needed if (needsSettingsValidation(context)) { components.add(new VersionSettingsDialog(context)); }/*from w w w . j a va2 s . c o m*/ // Adding commit confirmation (on commit) if (context.getVersioningOperation() == VersioningOperation.COMMIT) { List<IVersionable<?>> elementsToConfirm = buildConfirmList(context.getVersionables()); components.add(new ConfirmCommitDialog(context, elementsToConfirm, components.isEmpty())); } // Displaying Dialog dlg = null; if (components.size() == 1) { dlg = new TitleAreaDialogWrapper(UIHelper.getShell(), components.iterator().next(), SWT.RESIZE | SWT.TITLE | SWT.BORDER); } else if (components.size() > 1) { final IWizard wiz = new ComponentWizard(VCSUIMessages.getString("dialog.versionSettings.title"), //$NON-NLS-1$ components); dlg = new ComponentWizardDialog(UIHelper.getShell(), wiz, true); } else { // Nothing to validate return Status.OK_STATUS; } dlg.setBlockOnOpen(true); dlg.open(); return dlg.getReturnCode() == Window.OK ? Status.OK_STATUS : Status.CANCEL_STATUS; }
From source file:com.nokia.cpp.internal.api.utils.ui.ShowDialogWhenWorkbenchVisibleJob.java
License:Open Source License
/** * Create and schedule a job to show a dialog once the shell is visible. * No response will be reported from the dialog, so we mark it non-blocking. * @param shell the shell, or null to select the active workbench window * @param dialog the dialog to show/* www .j av a 2 s . co m*/ */ public static void start(Shell shell, Dialog dialog) { dialog.setBlockOnOpen(false); Job job = new ShowDialogWhenWorkbenchVisibleJob(shell, dialog); job.schedule(); }
From source file:com.nokia.tools.vct.navigator.sign.ShowSigningStatusAction.java
License:Open Source License
@Override public void run() { final Shell shell = Display.getCurrent().getActiveShell(); Dialog dialog = new StatusDialog(shell, project); dialog.setBlockOnOpen(true); dialog.open();// w ww . j a v a2 s . c om }
From source file:eclipse.testframework.ui.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. * * @param dialog the test dialog to be verified. *///from ww w. j a va 2 s . c om public static void assertDialogTexts(Dialog dialog) { Assert.assertNotNull(dialog); dialog.setBlockOnOpen(false); dialog.open(); Shell shell = dialog.getShell(); verifyCompositeText(shell); dialog.close(); }
From source file:eu.hydrologis.jgrass.formeditor.model.widgets.FormComboCellEditor.java
License:Open Source License
private void handleEvent() { Shell shell = new Shell(Display.getDefault(), SWT.DIALOG_TRIM | SWT.PRIMARY_MODAL); Dialog dialog = new Dialog(shell) { @Override//from w w w . j a v a 2 s . c o m protected void configureShell(Shell shell) { super.configureShell(shell); shell.setText("Insert data"); } @Override protected Point getInitialSize() { return new Point(320, 300); } @Override protected Control createDialogArea(Composite parent) { Composite mainComposite = new Composite(parent, SWT.NONE); mainComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); mainComposite.setLayout(new GridLayout(2, false)); manualButton = new Button(mainComposite, SWT.RADIO); manualButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); manualButton.setText("Manual"); manualButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { boolean selection = manualButton.getSelection(); handleEnablements(selection); } }); manualText = new Text(mainComposite, SWT.SINGLE | SWT.LEAD | SWT.BORDER); manualText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); manualText.setText(""); fileButton = new Button(mainComposite, SWT.RADIO); GridData fileButtonGD = new GridData(SWT.BEGINNING, SWT.CENTER, false, false); fileButtonGD.horizontalSpan = 2; fileButton.setLayoutData(fileButtonGD); fileButton.setText("File"); fileButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { boolean selection = fileButton.getSelection(); handleEnablements(!selection); } }); Group fileGroup = new Group(mainComposite, SWT.NONE); GridData fileGroupGD = new GridData(SWT.FILL, SWT.FILL, true, false); fileGroupGD.horizontalSpan = 2; fileGroup.setLayoutData(fileGroupGD); fileGroup.setLayout(new GridLayout(3, false)); // fileGroup.setText(); Label pathLabel = new Label(fileGroup, SWT.NONE); pathLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); pathLabel.setText("Path"); pathText = new Text(fileGroup, SWT.SINGLE | SWT.LEAD | SWT.BORDER | SWT.READ_ONLY); pathText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); pathText.setText(""); browseButton = new Button(fileGroup, SWT.PUSH); browseButton.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false)); browseButton.setText("..."); //$NON-NLS-1$ browseButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() { public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { IMap activeMap = ApplicationGIS.getActiveMap(); ILayer selectedLayer = activeMap.getEditManager().getSelectedLayer(); ID id = selectedLayer.getGeoResource().getID(); if (id.isFile()) { File layerFile = id.toFile(); FileDialog fileDialog = new FileDialog(pathText.getShell(), SWT.OPEN); // fileDialog.setFilterExtensions(extentions); fileDialog.setFilterPath(layerFile.getParent()); String path = fileDialog.open(); if (path != null && path.length() >= 1) { File tableFile = new File(path); String tableParentName = tableFile.getParentFile().getName().trim(); String layerParentName = layerFile.getParentFile().getName().trim(); if (tableParentName.equals(layerParentName)) { pathText.setText(tableFile.getName()); } else { MessageDialog.openWarning(browseButton.getShell(), "WARNING", "The linked table needs to be inside of the same folder as the resource file."); } } } else { MessageDialog.openWarning(browseButton.getShell(), "WARNING", "Currently linking of files is supported only for file based resources."); handleEnablements(true); } } }); Label separatorBabel = new Label(fileGroup, SWT.NONE); separatorBabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); separatorBabel.setText("Separator"); separatorText = new Text(fileGroup, SWT.SINGLE | SWT.LEAD | SWT.BORDER); GridData separatorTextGD = new GridData(SWT.FILL, SWT.CENTER, true, false); separatorTextGD.horizontalSpan = 2; separatorText.setLayoutData(separatorTextGD); separatorText.setText(","); linkButton = new Button(fileGroup, SWT.CHECK); GridData linkButtonGD = new GridData(SWT.BEGINNING, SWT.CENTER, false, false); linkButtonGD.horizontalSpan = 3; linkButton.setLayoutData(linkButtonGD); linkButton.setText("link file"); Label attributeValueLabel = new Label(fileGroup, SWT.NONE); attributeValueLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); attributeValueLabel.setText("Attribute value column"); attributeValueText = new Text(fileGroup, SWT.SINGLE | SWT.LEAD | SWT.BORDER); GridData attributeValueGD = new GridData(SWT.FILL, SWT.CENTER, true, false); attributeValueGD.horizontalSpan = 2; attributeValueText.setLayoutData(attributeValueGD); attributeValueText.setText("1"); Label guiNameLabel = new Label(fileGroup, SWT.NONE); guiNameLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); guiNameLabel.setText("Interface name column"); guiNameText = new Text(fileGroup, SWT.SINGLE | SWT.LEAD | SWT.BORDER); GridData guiNameTextGD = new GridData(SWT.FILL, SWT.CENTER, true, false); guiNameTextGD.horizontalSpan = 2; guiNameText.setLayoutData(guiNameTextGD); guiNameText.setText("2"); setValuesFromValueString(); return mainComposite; } @Override protected void buttonPressed(int buttonId) { if (buttonId == OK) { if (manualButton.getSelection()) { valueString = manualText.getText(); } else { setValueStringFromFileType(); } editOccured(null); } super.buttonPressed(buttonId); } }; dialog.setBlockOnOpen(true); dialog.open(); // Point location = mainButton.getLocation(); // // Point size = dialog.getSize(); // dialog.setLocation(location.x - size.x, location.y + size.y); }
From source file:eu.hydrologis.jgrass.ui.actions.g_setmapset.java
License:Open Source License
public void run(IAction action) { final ScopedPreferenceStore m_preferences = (ScopedPreferenceStore) ConsoleEditorPlugin.getDefault() .getPreferenceStore();//ww w . j ava 2s . com Dialog dialog = new Dialog(window.getShell()) { private Text text; protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); composite.setLayout(new GridLayout(4, false)); Label label = new Label(composite, SWT.NONE); label.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); label.setText("mapset path"); mapset = m_preferences.getString(PreferencesInitializer.CONSOLE_ARGV_MAPSET); if (mapset != null) { File f = new File(mapset); if (!f.exists()) { mapset = ""; } } text = new Text(composite, SWT.SINGLE | SWT.LEAD | SWT.BORDER); text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); text.setText(mapset); final Button mapsetSelectionButton = new Button(composite, SWT.PUSH); mapsetSelectionButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); mapsetSelectionButton.setToolTipText("Select a mapset from the catalog."); mapsetSelectionButton.setText("catalog"); mapsetSelectionButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() { public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { CatalogJGrassMapsetTreeViewerDialog cDialog = new CatalogJGrassMapsetTreeViewerDialog(); cDialog.open(mapsetSelectionButton.getShell()); List<JGrassMapsetGeoResource> selectedLayers = cDialog.getSelectedLayers(); if (selectedLayers == null || selectedLayers.size() == 0) { return; } JGrassMapsetGeoResource grassMapsetGeoResource = selectedLayers.get(0); File mapsetFile = grassMapsetGeoResource.getFile(); if (mapsetFile.exists() && GrassPlugin.getDefault().isMapsetConsistent(mapsetFile.getAbsolutePath())) { text.setText(mapsetFile.getAbsolutePath()); } else { String msg = "This is not a valid GRASS mapset folder. Please supply a valid mapset folder."; popupError(msg); } } }); Button browseButton = new Button(composite, SWT.PUSH); browseButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); browseButton.setText("..."); browseButton.setToolTipText("Browse the filesystem for a mapset folder."); browseButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() { public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { DirectoryDialog fileDialog = new DirectoryDialog(window.getShell(), SWT.OPEN); String path = fileDialog.open(); if (path != null) { File f = new File(path); if (f.exists() && GrassPlugin.getDefault().isMapsetConsistent(path)) { text.setText(f.getAbsolutePath()); } else { String msg = "This is not a valid GRASS mapset folder. Please supply a valid mapset folder."; popupError(msg); } } } }); return composite; } protected void configureShell(Shell shell) { super.configureShell(shell); shell.setText("g.setmapset"); shell.setSize(new Point(450, 120)); Shell mainshell = PlatformUI.getWorkbench().getDisplay().getActiveShell(); Rectangle bounds = mainshell.getBounds(); Rectangle rect = shell.getBounds(); int x = bounds.x + (bounds.width - rect.width) / 2; int y = bounds.y + (bounds.height - rect.height) / 2; shell.setLocation(x, y); } protected void okPressed() { m_preferences.setValue(PreferencesInitializer.CONSOLE_ARGV_MAPSET, text.getText()); super.okPressed(); } }; dialog.setBlockOnOpen(true); dialog.open(); }
From source file:eu.hydrologis.jgrass.ui.utilities.CatalogJGrassMapsetTreeViewerDialog.java
License:Open Source License
public void open(Shell parentShell) { try {//w w w .j a v a 2s . c o m setRequireContinue(false); Dialog dialog = new Dialog(parentShell) { @Override protected void configureShell(Shell shell) { super.configureShell(shell); shell.setText(Messages.getString("CatalogJGrassMapsetTreeViewerDialog.choosemapset")); //$NON-NLS-1$ } @Override protected Point getInitialSize() { return new Point(250, 250); } @Override protected Control createDialogArea(Composite parent) { Composite parentPanel = (Composite) super.createDialogArea(parent); GridLayout gLayout = (GridLayout) parentPanel.getLayout(); gLayout.numColumns = 1; active = new CatalogJGrassMapsetsTreeViewer(parentPanel, SWT.BORDER, SWT.SINGLE); return parentPanel; } @Override protected void buttonPressed(int buttonId) { super.buttonPressed(buttonId); if (buttonId == OK) { newLayers = active.getSelectedLayers(); } else { newLayers = null; } setRequireContinue(true); } }; dialog.setBlockOnOpen(true); dialog.open(); while (!isContinueRequired()) { if (dialog.getShell().isDisposed()) { break; } if (Display.getCurrent().readAndDispatch()) { continue; } try { Thread.sleep(300); } catch (InterruptedException ex) { ex.printStackTrace(); } } } catch (Exception e) { e.printStackTrace(); } }
From source file:eu.udig.catalog.jgrass.activeregion.dialogs.CatalogJGrassMapsetTreeViewerDialog.java
License:Open Source License
public void open(Shell parentShell) { try {/* w ww. j a va2 s . c om*/ setRequireContinue(false); Dialog dialog = new Dialog(parentShell) { @Override protected void configureShell(Shell shell) { super.configureShell(shell); shell.setText("Select mapset"); //$NON-NLS-1$ } @Override protected Point getInitialSize() { return new Point(250, 250); } @Override protected Control createDialogArea(Composite parent) { Composite parentPanel = (Composite) super.createDialogArea(parent); GridLayout gLayout = (GridLayout) parentPanel.getLayout(); gLayout.numColumns = 1; active = new CatalogJGrassMapsetsTreeViewer(parentPanel, SWT.BORDER, SWT.SINGLE); return parentPanel; } @Override protected void buttonPressed(int buttonId) { super.buttonPressed(buttonId); if (buttonId == OK) { newLayers = active.getSelectedLayers(); } else { newLayers = null; } setRequireContinue(true); } }; dialog.setBlockOnOpen(true); dialog.open(); while (!isContinueRequired()) { if (dialog.getShell().isDisposed()) { break; } if (Display.getCurrent().readAndDispatch()) { continue; } try { Thread.sleep(300); } catch (InterruptedException ex) { ex.printStackTrace(); } } } catch (Exception e) { e.printStackTrace(); } }