List of usage examples for org.eclipse.jface.dialogs Dialog open
public int open()
From source file:ca.uwaterloo.gp.fmp.provider.action.XMLExport.java
License:Open Source License
public void run() { StringBuffer output = new StringBuffer(); // run recursion exportNode(output, object, 0);/*from ww w . ja va 2s .co m*/ final String text = output.toString(); //System.out.println(text); Dialog dialog = new MessageDialog(shell, "XML Export", null, null, MessageDialog.NONE, new String[] { "OK" }, 0) { protected Control createDialogArea(Composite parent) { Color white = shell.getDisplay().getSystemColor(SWT.COLOR_WHITE); parent.setBackground(white); // Composite composite = (Composite) super.createDialogArea(parent); // composite.setBackground(white); // Text field fText = new Text(parent, SWT.MULTI); fText.setEditable(false); fText.setText(text); fText.selectAll(); fText.setBackground(white); return fText; } }; /* * Michal: unfortunately this only works in Eclipse 3.2 PopupDialog dialog = new PopupDialog(shell, PopupDialog.INFOPOPUPRESIZE_SHELLSTYLE, true, false, false, false, "XML Export", "Use <CTRL>-C to copy to clipboard, <ESC> to dismiss.") { protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); // Text field fText= new Text(composite, SWT.MULTI); fText.setEditable(false); fText.setText(text); fText.selectAll(); return composite; } };*/ dialog.open(); }
From source file:com.amazonaws.eclipse.explorer.s3.actions.DeleteBucketAction.java
License:Apache License
@Override public void run() { Dialog dialog = newConfirmationDialog(getText() + "?", "Are you sure you want to delete the selected buckets?"); if (dialog.open() <= 0) return;//from w w w . j a v a2s. c om new Job("Deleting Buckets") { @Override protected IStatus run(IProgressMonitor monitor) { try { AmazonS3 s3 = AwsToolkitCore.getClientFactory().getS3Client(); ObjectUtils objectUtils = new ObjectUtils(s3); for (Bucket bucket : buckets) { objectUtils.deleteBucketAndAllVersions(bucket.getName()); } Display.getDefault().asyncExec(new Runnable() { public void run() { S3ContentProvider.getInstance().refresh(); } }); return Status.OK_STATUS; } catch (Exception e) { return new Status(IStatus.ERROR, AwsToolkitCore.PLUGIN_ID, "Unable to delete buckets: " + e.getMessage(), e); } } }.schedule(); }
From source file:com.amazonaws.eclipse.explorer.s3.actions.DeleteObjectAction.java
License:Apache License
@Override public void run() { Dialog dialog = newConfirmationDialog(getText() + "?", "Are you sure you want to delete the selected objects?"); if (dialog.open() <= 0) return;/* w w w.j a v a 2 s . c om*/ new Job("Deleting Objects") { @Override protected IStatus run(IProgressMonitor monitor) { final Collection<S3ObjectSummary> selectedObjects = new ArrayList<S3ObjectSummary>(); Display.getDefault().syncExec(new Runnable() { public void run() { selectedObjects.addAll(table.getSelectedObjects()); } }); monitor.beginTask("Deleting objects", selectedObjects.size()); try { AmazonS3 s3 = AwsToolkitCore.getClientFactory().getS3Client(); for (S3ObjectSummary summary : selectedObjects) { s3.deleteObject(summary.getBucketName(), summary.getKey()); monitor.worked(1); } Display.getDefault().asyncExec(new Runnable() { public void run() { String prefix = null; if (selectedObjects.size() == 1) { String key = selectedObjects.iterator().next().getKey(); int slashIndex = key.lastIndexOf('/'); if (slashIndex > 0) { prefix = key.substring(0, slashIndex); } } table.refresh(prefix); } }); return Status.OK_STATUS; } catch (Exception e) { return new Status(IStatus.ERROR, AwsToolkitCore.PLUGIN_ID, "Unable to delete objects: " + e.getMessage(), e); } finally { monitor.done(); } } }.schedule(); }
From source file:com.android.ide.eclipse.installer.InstallAndroidSdk.java
License:Open Source License
public void earlyStartup() { if (!InstallerActivator.showMeInstaller()) { return;//from w w w .ja va 2s .c o m } String sdkDir = AdtPlugin.getDefault().getPreferenceStore().getString(AdtPrefs.PREFS_SDK_DIR); if (!isValidSdk(sdkDir)) { Display.getDefault().asyncExec(new Runnable() { public void run() { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); Dialog dialog = new InstallSdkDialog(shell); dialog.open(); } }); } }
From source file:com.aptana.git.ui.internal.actions.AbstractGithubHandler.java
License:Open Source License
/** * Grabs the {@link IGithubRepository} for the selected repository. Forces user to login to github if not logged in. * If user cancels login or some other error occurs we bail out and return null. * //from w w w . java 2s . c o m * @return * @throws ExecutionException */ protected IGithubRepository getGithubRepo() throws ExecutionException { final GitRepository repo = getSelectedRepository(); if (repo == null) { throw new ExecutionException(Messages.CreatePullRequestHandler_NoRepoErr); } IGithubRepository ghRepo = null; while (ghRepo == null) { try { ghRepo = repo.getGithubRepo(); } catch (CoreException ce) { if (ce.getStatus().getCode() == IGithubManager.GITHUB_LOGIN_CODE) { // prompt for login! final GithubAccountPageProvider userInfoProvider = new GithubAccountPageProvider(); Dialog dialog = new Dialog(UIUtils.getActiveShell()) { @Override protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); Control userInfoControl = userInfoProvider.createContents(composite); userInfoControl.setLayoutData( GridDataFactory.fillDefaults().grab(true, false).span(3, 1).create()); return composite; } @Override protected void okPressed() { if (!userInfoProvider.performOk()) { // TODO Show an error message that we were unable to login? return; } super.okPressed(); } }; if (dialog.open() == Window.CANCEL) { return null; // User cancelled } // we'll restart the loop and try again... } else { // some other error. Quit trying to get repo from github throw new ExecutionException(ce.getMessage(), ce); } } } return ghRepo; }
From source file:com.aptana.ide.server.ui.views.actions.NewServerAction.java
License:Open Source License
/** * @see org.eclipse.jface.action.Action#run() *//* ww w .j a v a2 s . c o m*/ public void run() { try { ICanAdd adapter = (ICanAdd) type.getAdapter(ICanAdd.class); if (adapter != null) { adapter.doAdd(); return; } IConfigurationDialog dialog = ServerDialogPageRegistry.getInstance().getDialog(type.getId()); dialog.setConfiguration(ServerManager.getInstance().getInitialServerConfiguration(type.getId())); dialog.setEdit(false); Dialog dialog3 = dialog.getDialog(); int open = dialog3.open(); if (open == Dialog.OK) { IAbstractConfiguration configuration = dialog.getConfiguration(); createdServer = ServerManager.getInstance().addServer(configuration); //checking if server requires patching List<IServerPatcher> patchers = ServerPatchers.getPatchers(createdServer.getServerType().getId()); if (patchers != null && patchers.size() != 0) { List<IServerPatcher> requiredPatchers = new ArrayList<IServerPatcher>(); for (IServerPatcher patcher : patchers) { if (patcher.checkPatchRequired(createdServer)) { requiredPatchers.add(patcher); } } //if patching is required if (requiredPatchers.size() != 0) { ServerPatchingWizard wizard = new ServerPatchingWizard(createdServer.getName(), requiredPatchers); WizardDialog wizardDialog = new WizardDialog(Display.getDefault().getActiveShell(), (IWizard) wizard); wizardDialog.create(); int result = wizardDialog.open(); if (result == Window.OK) { for (IServerPatcher patcher : requiredPatchers) { if (patcher.isConfigured()) { patcher.applyPatch(createdServer); } } } } } } } catch (Exception e) { MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error while adding server", //$NON-NLS-1$ e.getMessage()); IdeLog.log(ServerUIPlugin.getDefault(), IStatus.ERROR, "exception while opening new server dialog", e); //$NON-NLS-1$ } }
From source file:com.aptana.ide.syncing.ui.actions.SiteConnectionPropertiesAction.java
License:Open Source License
public void run(IAction action) { if (selectedObject == null) { return;/* w ww . ja v a2 s . co m*/ } try { Dialog dlg = PropertyDialogsRegistry.getInstance().createPropertyDialog(selectedObject, targetPart.getSite()); if (dlg != null) { if (dlg instanceof IPropertyDialog) { ((IPropertyDialog) dlg).setPropertySource(selectedObject); } dlg.open(); } } catch (CoreException e) { UIUtils.showErrorMessage(Messages.SiteConnectionPropertiesAction_ERR_CreateDialogFailed, e); } }
From source file:com.aptana.ide.syncing.ui.wizards.RemoteConnectionSelectionPage.java
License:Open Source License
public void widgetSelected(SelectionEvent e) { Object source = e.getSource(); if (source == newSiteButton) { final Shell shell = getShell(); Dialog dlg = new FTPPropertyDialogProvider().createPropertyDialog(new IShellProvider() { public Shell getShell() { return shell; }/*from w w w .j a v a 2s . c o m*/ }); if (dlg instanceof IPropertyDialog) { ((IPropertyDialog) dlg).setPropertySource( CoreIOPlugin.getConnectionPointManager().getType(IBaseFTPConnectionPoint.TYPE_FTP)); } int ret = dlg.open(); if (ret == Window.OK) { populateTable(); if (dlg instanceof IPropertyDialog) { checkItem((IConnectionPoint) ((IPropertyDialog) dlg).getPropertySource()); } } } else if (source == syncOnFinish) { setSynchronize(syncOnFinish.getSelection()); } }
From source file:com.aptana.ide.ui.ftp.actions.NewFTPConnectionAction.java
License:Open Source License
public void run(IAction action) { Dialog dlg = new FTPPropertyDialogProvider().createPropertyDialog(targetPart.getSite()); if (dlg instanceof IPropertyDialog) { String typeId = action.getId(); int index = typeId.lastIndexOf('.'); if (index >= 0 && index + 1 < typeId.length()) { typeId = typeId.substring(index + 1); }//from w w w . java 2s . c o m ((IPropertyDialog) dlg).setPropertySource(CoreIOPlugin.getConnectionPointManager().getType(typeId)); } dlg.open(); }
From source file:com.aptana.ide.ui.ftp.navigator.actions.DoubleClickAction.java
License:Open Source License
public void run() { if (selectionHasChildren()) { super.run(); } else {/*www. jav a 2s. c o m*/ // no connection point has been defined; opens the FTP dialog Dialog dialog = new FTPPropertyDialogProvider().createPropertyDialog(new IShellProvider() { public Shell getShell() { return fShell; } }); if (dialog instanceof IPropertyDialog) { ((IPropertyDialog) dialog).setPropertySource( CoreIOPlugin.getConnectionPointManager().getType(FTPConnectionPoint.TYPE)); } dialog.open(); } }