List of usage examples for org.eclipse.jface.dialogs Dialog open
public int open()
From source file:org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.java
License:Open Source License
/** * Opens the refactoring dialog for the refactoring wizard passed to the constructor. * The method first checks the initial conditions of the refactoring. If the condition * checking returns a status with a severity of {@link RefactoringStatus#FATAL} then * a message dialog is opened containing the corresponding status message. No wizard * dialog is opened in this situation. If the condition checking passes then the * refactoring dialog is opened./* w w w . ja va2 s . co m*/ * <p> * The methods ensures that the workspace lock is held while the condition checking, * change creation and change execution is performed. Clients can't make any assumption * about the thread in which these steps are executed. However the framework ensures * that the workspace lock is transfered to the thread in which the execution of the * steps takes place. * </p> * @param parent the parent shell for the dialog or <code>null</code> if the dialog * is a top level dialog * @param dialogTitle the dialog title of the message box presenting the failed * condition check (if any) * @param context the runnable context to use for conditions checking before the * refactoring wizard dialog is visible. If <code>null</code>, the workbench window's * progress service is used. * * @return {@link #INITIAL_CONDITION_CHECKING_FAILED} if the initial condition checking * failed and no wizard dialog was presented. Otherwise either {@link IDialogConstants#OK_ID} * or {@link IDialogConstants#CANCEL_ID} is returned depending on whether the user * has pressed the OK or cancel button on the wizard dialog. * * @throws InterruptedException if the initial condition checking got canceled by * the user. * * @since 3.5 */ public int run(final Shell parent, final String dialogTitle, final IRunnableContext context) throws InterruptedException { Assert.isNotNull(dialogTitle); final Refactoring refactoring = fWizard.getRefactoring(); final IJobManager manager = Job.getJobManager(); final int[] result = new int[1]; final InterruptedException[] canceled = new InterruptedException[1]; Runnable r = new Runnable() { public void run() { try { // we are getting the block dialog for free if we pass in null manager.beginRule(ResourcesPlugin.getWorkspace().getRoot(), null); refactoring.setValidationContext(parent); fInitialConditions = checkInitialConditions(refactoring, parent, dialogTitle, context); if (fInitialConditions.hasFatalError()) { String message = fInitialConditions.getMessageMatchingSeverity(RefactoringStatus.FATAL); MessageDialog.openError(parent, dialogTitle, message); result[0] = INITIAL_CONDITION_CHECKING_FAILED; } else { fWizard.setInitialConditionCheckingStatus(fInitialConditions); Dialog dialog = RefactoringUI.createRefactoringWizardDialog(fWizard, parent); dialog.create(); IWizardContainer wizardContainer = (IWizardContainer) dialog; if (wizardContainer.getCurrentPage() == null) /* * Don't show the dialog at all if there are no user * input pages and change creation was cancelled. */ result[0] = Window.CANCEL; else result[0] = dialog.open(); } } catch (InterruptedException e) { canceled[0] = e; } catch (OperationCanceledException e) { canceled[0] = new InterruptedException(e.getMessage()); } finally { manager.endRule(ResourcesPlugin.getWorkspace().getRoot()); refactoring.setValidationContext(null); RefactoringContext refactoringContext = fWizard.getRefactoringContext(); if (refactoringContext != null) refactoringContext.dispose(); } } }; BusyIndicator.showWhile(parent != null ? parent.getDisplay() : null, r); if (canceled[0] != null) throw canceled[0]; return result[0]; }
From source file:org.eclipse.m2e.integration.tests.InputHistoryTest.java
License:Open Source License
@Test public void testInputHistory() { Display.getDefault().syncExec(new Runnable() { public void run() { // open the dialog once, set values, close Dialog d = new Dialog(new Shell()); d.open(); d.combo.setText(COMBO_TEXT); d.ccombo.setText(CCOMBO_TEXT); d.close();/*from w w w . java 2s .c om*/ // open the dialog again, make sure the history is there d = new Dialog(new Shell()); d.open(); try { assertEquals("Combo default value", COMBO_TEXT, d.combo.getText()); assertEquals("Combo history length", 1, d.combo.getItemCount()); assertEquals("Combo history value", COMBO_TEXT, d.combo.getItem(0)); assertEquals("CCombo default value", "", d.ccombo.getText()); assertEquals("CCombo history length", 1, d.ccombo.getItemCount()); assertEquals("CCombo history value", CCOMBO_TEXT, d.ccombo.getItem(0)); d.combo.setText(COMBO_TEXT2); d.ccombo.setText(CCOMBO_TEXT2); } finally { d.close(); } // open the dialog the third time, make sure the history is updated d = new Dialog(new Shell()); d.open(); try { assertEquals("Combo default value", COMBO_TEXT2, d.combo.getText()); assertEquals("Combo history length", 2, d.combo.getItemCount()); assertEquals("Combo history value (new)", COMBO_TEXT2, d.combo.getItem(0)); assertEquals("Combo history value (old)", COMBO_TEXT, d.combo.getItem(1)); assertEquals("CCombo default value", "", d.ccombo.getText()); assertEquals("CCombo history length", 2, d.ccombo.getItemCount()); assertEquals("CCombo history value (new)", CCOMBO_TEXT2, d.ccombo.getItem(0)); assertEquals("CCombo history value (old)", CCOMBO_TEXT, d.ccombo.getItem(1)); } finally { d.close(); } } }); }
From source file:org.eclipse.nebula.widgets.treemapper.tests.ProgrammaticTest.java
License:Open Source License
/** * @param treeContent/*w w w . jav a 2s . c o m*/ * @param mappings * @return */ private Dialog openMapperDialog(final String[] treeContent, final String[] mappings) { Dialog dialog = new Dialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()) { @Override public Composite createDialogArea(Composite parent) { Composite res = (Composite) super.createDialogArea(parent); TreeMapper<String, String, String> mapper = new TreeMapper<String, String, String>(parent, new ObjectSemanticSupport(), new TreeMapperUIConfigProvider(ColorConstants.blue, 2, ColorConstants.darkBlue, 4)); mapper.setContentProviders(new ArrayTreeContentProvider(), new ArrayTreeContentProvider()); mapper.setInput(treeContent, treeContent, Arrays.asList(mappings)); return res; } }; dialog.setBlockOnOpen(false); dialog.open(); return dialog; }
From source file:org.eclipse.oomph.internal.ui.Capture.java
License:Open Source License
public Image capture() { final AtomicReference<Image> image = new AtomicReference<Image>(); final Display display = PlatformUI.getWorkbench().getDisplay(); final org.eclipse.jface.dialogs.Dialog backgroundDialog = new org.eclipse.jface.dialogs.Dialog( (Shell) null) {/* w w w .jav a 2 s. c om*/ { setShellStyle(SWT.MAX); } @Override protected Control createDialogArea(Composite parent) { Control control = super.createDialogArea(parent); control.setBackground(display.getSystemColor(SWT.COLOR_WHITE)); return control; } }; UIUtil.asyncExec(new Runnable() { public void run() { backgroundDialog.open(); } }); while (backgroundDialog.getShell() == null) { try { Thread.sleep(100); } catch (InterruptedException ex) { // Ignore. } } final Shell backgroundShell = backgroundDialog.getShell(); final T element = new WorkUnit<T, RuntimeException>() { @Override protected T doExecute() { backgroundShell.setMaximized(true); return create(backgroundShell); } }.execute(); UIUtil.asyncExec(new Runnable() { public void run() { open(element); } }); UIUtil.asyncExec(new Runnable() { public void run() { Shell shell = getShell(element); Rectangle bounds = shell.getBounds(); bounds.x = 30; bounds.y = 50; shell.setBounds(bounds); } }); while (!new WorkUnit<Boolean, RuntimeException>() { @Override protected Boolean doExecute() { return isReady(element); } }.execute()) { try { Thread.sleep(100); } catch (InterruptedException ex) { // Ignore. } } try { Thread.sleep(1000); } catch (InterruptedException ex) { // Ignore. } new WorkUnit.Void<RuntimeException>() { @Override protected void doProcess() { preprocess(element); } }.execute(); new WorkUnit.Void<RuntimeException>() { @Override protected void doProcess() { postProcess(element); } }.execute(); new WorkUnit.Void<RuntimeException>() { @Override protected void doProcess() { image.set(capture(element)); } }.execute(); new WorkUnit.Void<RuntimeException>() { @Override protected void doProcess() { close(element); backgroundShell.close(); } }.execute(); return image.get(); }
From source file:org.eclipse.oomph.setup.internal.installer.InstallerDialog.java
License:Open Source License
@Override protected void createToolItemsForToolBar(ToolBar toolBar) { ToolItem networkProxySettingsToolItem = createToolItem(toolBar, "install_prefs_proxy", "Network proxy settings"); networkProxySettingsToolItem.addSelectionListener(new SelectionAdapter() { @Override/* w w w.j ava2s.co m*/ public void widgetSelected(SelectionEvent e) { Dialog dialog = new NetworkConnectionsDialog(getShell()); dialog.open(); } }); AccessUtil.setKey(networkProxySettingsToolItem, "proxy"); ToolItem sshSettingsToolItem = createToolItem(toolBar, "install_prefs_ssh2", "SSH2 settings"); sshSettingsToolItem.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Dialog dialog = new NetworkSSH2Dialog(getShell()); dialog.open(); } }); AccessUtil.setKey(sshSettingsToolItem, "ssh"); ToolItem simpleToolItem = createToolItem(toolBar, "simple", "Switch to simple mode"); simpleToolItem.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { close(); setReturnCode(RETURN_SIMPLE); } }); AccessUtil.setKey(simpleToolItem, "simple"); updateToolItem = createToolItem(toolBar, "install_update0", "Update"); updateToolItem.setDisabledImage(SetupInstallerPlugin.INSTANCE.getSWTImage("install_searching0")); updateToolItem.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { selfUpdate(); } }); AccessUtil.setKey(updateToolItem, "update"); }
From source file:org.eclipse.oomph.setup.presentation.AbstractTableAction.java
License:Open Source License
@Override public void run() { if (UIUtil.isBrowserAvailable()) { Dialog dialog = new CommandTableDialog(part.getSite().getShell()); dialog.open(); } else {/*from w ww .j a v a2 s .c o m*/ try { String html = renderHTML(); File tempFile = File.createTempFile("table", ".html"); IOUtil.writeUTF8(tempFile, html); OS.INSTANCE.openSystemBrowser(tempFile.toURI().toString()); } catch (Exception ex) { ErrorDialog.open(ex); } } }
From source file:org.eclipse.oomph.setup.presentation.SetupActionBarContributor.java
License:Open Source License
@Override public void menuAboutToShow(IMenuManager menuManager) { menuAboutToShowGen(menuManager);/*w w w.j a v a 2 s . c o m*/ menuManager.insertBefore("ui-actions", new Action() { @Override public String getText() { return "Working Sets Preview..."; } @Override public void run() { Dialog dialog = new PreviewDialog(activeEditorPart.getSite().getShell(), activeEditorPart) { private List<WorkingSet> workingSets = new ArrayList<WorkingSet>(); @Override protected void selectionChanged(IWorkbenchPart part, ISelection selection) { if (part == activeEditorPart) { List<WorkingSet> oldWorkingSets = workingSets; workingSets = getWorkingSets(); if (workingSets != oldWorkingSets) { reconcile(); tree.setInput(input); tree.expandAll(); } } super.selectionChanged(part, selection); } @Override protected List<WorkingSet> getWorkingSets() { IStructuredSelection selection = (IStructuredSelection) ((ISelectionProvider) activeEditorPart) .getSelection(); LOOP: for (Object object : selection.toArray()) { if (object instanceof EObject) { for (EObject eObject = (EObject) object; eObject != null; eObject = eObject .eContainer()) { List<WorkingSet> workingSets = getWorkingSets(eObject); if (workingSets != null) { this.workingSets = workingSets; break LOOP; } } } } return workingSets; } private List<WorkingSet> getWorkingSets(EObject eObject) { for (EReference eReference : eObject.eClass().getEAllReferences()) { if (eReference.isMany() && eReference.getEType() == WorkingSetsPackage.Literals.WORKING_SET) { @SuppressWarnings("unchecked") EList<WorkingSet> value = (EList<WorkingSet>) eObject.eGet(eReference); return value; } } return null; } }; dialog.open(); } }); menuManager.insertBefore("ui-actions", openInSetupEditorAction); menuManager.insertBefore("ui-actions", openInTextEditorAction); }
From source file:org.eclipse.oomph.workingsets.presentation.WorkingSetsActionBarContributor.java
License:Open Source License
@Override public void menuAboutToShow(IMenuManager menuManager) { menuAboutToShowGen(menuManager);//from w w w .j a v a2 s.c o m menuManager.insertBefore("ui-actions", new Action() { @Override public String getText() { return "Preview..."; } @Override public void run() { Dialog dialog = new PreviewDialog(activeEditorPart.getSite().getShell(), activeEditorPart); dialog.open(); } }); }
From source file:org.eclipse.osee.framework.ui.skynet.panels.AbstractItemSelectPanel.java
License:Open Source License
private final void createDialog() throws OseeCoreException { T lastSelected = getSelected();/*www . ja va 2 s . c om*/ if (lastSelected == null) { lastSelected = getDefaultItem(); } Shell shell = AWorkbench.getActiveShell(); Dialog dialog = createSelectDialog(shell, lastSelected); int result = dialog.open(); if (result == Window.OK) { if (updateFromDialogResult(dialog)) { updateCurrentItemWidget(); Event event = new Event(); event.widget = currentItemWidget.getControl(); fireSelectionEvent(event); } } }
From source file:org.eclipse.papyrus.customization.properties.ui.OpenCustomization.java
License:Open Source License
public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); Dialog dialog = new CustomizationDialog(window.getShell()); dialog.open(); return null;/*w ww. j ava2 s . co m*/ }