List of usage examples for org.eclipse.jface.dialogs MessageDialog QUESTION
int QUESTION
To view the source code for org.eclipse.jface.dialogs MessageDialog QUESTION.
Click Source Link
From source file:com.android.ide.eclipse.auidt.internal.editors.layout.gre.ClientRulesEngine.java
License:Open Source License
@Override public String displayFragmentSourceInput() { try {/*from w w w . ja va 2 s. c o m*/ // Compute a search scope: We need to merge all the subclasses // android.app.Fragment and android.support.v4.app.Fragment IJavaSearchScope scope = SearchEngine.createWorkspaceScope(); IProject project = mRulesEngine.getProject(); final IJavaProject javaProject = BaseProjectHelper.getJavaProject(project); if (javaProject != null) { IType oldFragmentType = javaProject.findType(CLASS_V4_FRAGMENT); // First check to make sure fragments are available, and if not, // warn the user. IAndroidTarget target = Sdk.getCurrent().getTarget(project); // No, this should be using the min SDK instead! if (target.getVersion().getApiLevel() < 11 && oldFragmentType == null) { // Compatibility library must be present MessageDialog dialog = new MessageDialog(Display.getCurrent().getActiveShell(), "Fragment Warning", null, "Fragments require API level 11 or higher, or a compatibility " + "library for older versions.\n\n" + " Do you want to install the compatibility library?", MessageDialog.QUESTION, new String[] { "Install", "Cancel" }, 1 /* default button: Cancel */); int answer = dialog.open(); if (answer == 0) { if (!AddSupportJarAction.install(project)) { return null; } } else { return null; } } // Look up sub-types of each (new fragment class and compatibility fragment // class, if any) and merge the two arrays - then create a scope from these // elements. IType[] fragmentTypes = new IType[0]; IType[] oldFragmentTypes = new IType[0]; if (oldFragmentType != null) { ITypeHierarchy hierarchy = oldFragmentType.newTypeHierarchy(new NullProgressMonitor()); oldFragmentTypes = hierarchy.getAllSubtypes(oldFragmentType); } IType fragmentType = javaProject.findType(CLASS_FRAGMENT); if (fragmentType != null) { ITypeHierarchy hierarchy = fragmentType.newTypeHierarchy(new NullProgressMonitor()); fragmentTypes = hierarchy.getAllSubtypes(fragmentType); } IType[] subTypes = new IType[fragmentTypes.length + oldFragmentTypes.length]; System.arraycopy(fragmentTypes, 0, subTypes, 0, fragmentTypes.length); System.arraycopy(oldFragmentTypes, 0, subTypes, fragmentTypes.length, oldFragmentTypes.length); scope = SearchEngine.createJavaSearchScope(subTypes, IJavaSearchScope.SOURCES); } Shell parent = AdtPlugin.getDisplay().getActiveShell(); final AtomicReference<String> returnValue = new AtomicReference<String>(); final AtomicReference<SelectionDialog> dialogHolder = new AtomicReference<SelectionDialog>(); final SelectionDialog dialog = JavaUI.createTypeDialog(parent, new ProgressMonitorDialog(parent), scope, IJavaElementSearchConstants.CONSIDER_CLASSES, false, // Use ? as a default filter to fill dialog with matches "?", //$NON-NLS-1$ new TypeSelectionExtension() { @Override public Control createContentArea(Composite parentComposite) { Composite composite = new Composite(parentComposite, SWT.NONE); composite.setLayout(new GridLayout(1, false)); Button button = new Button(composite, SWT.PUSH); button.setText("Create New..."); button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { String fqcn = createNewFragmentClass(javaProject); if (fqcn != null) { returnValue.set(fqcn); dialogHolder.get().close(); } } }); return composite; } @Override public ITypeInfoFilterExtension getFilterExtension() { return new ITypeInfoFilterExtension() { @Override public boolean select(ITypeInfoRequestor typeInfoRequestor) { int modifiers = typeInfoRequestor.getModifiers(); if (!Flags.isPublic(modifiers) || Flags.isInterface(modifiers) || Flags.isEnum(modifiers)) { return false; } return true; } }; } }); dialogHolder.set(dialog); dialog.setTitle("Choose Fragment Class"); dialog.setMessage("Select a Fragment class (? = any character, * = any string):"); if (dialog.open() == IDialogConstants.CANCEL_ID) { return null; } if (returnValue.get() != null) { return returnValue.get(); } Object[] types = dialog.getResult(); if (types != null && types.length > 0) { return ((IType) types[0]).getFullyQualifiedName(); } } catch (JavaModelException e) { AdtPlugin.log(e, null); } catch (CoreException e) { AdtPlugin.log(e, null); } return null; }
From source file:com.android.ide.eclipse.gldebugger.ShaderEditor.java
License:Apache License
public void widgetSelected(SelectionEvent e) { if (e.getSource() == uploadShader && null != current) { uploadShader();// ww w.j ava 2 s.c o m return; } else if (e.getSource() == restoreShader && null != current) { current.source = styledText.getText(); styledText.setText(current.originalSource); return; } if (list.getSelectionCount() < 1) return; if (null != current && !current.source.equals(styledText.getText())) { String[] btns = { "&Upload", "&Save", "&Discard" }; MessageDialog dialog = new MessageDialog(this.getShell(), "Shader Edited", null, "Shader source has been edited", MessageDialog.QUESTION, btns, 0); int rc = dialog.open(); if (rc == SWT.DEFAULT || rc == 0) uploadShader(); else if (rc == 1) current.source = styledText.getText(); // else if (rc == 2) do nothing; selection is changing } String[] details = list.getSelection()[0].split("\\s+"); final int contextId = Integer.parseInt(details[0], 16); int name = Integer.parseInt(details[2]); current = mGLFramesView.debugContexts.get(contextId).currentContext.serverShader.shaders.get(name); styledText.setText(current.source); }
From source file:com.aptana.editor.common.preferences.ValidationPreferencePage.java
License:Open Source License
/** * If changes don't require a rebuild, return false. Otherwise prompt user and take their answer. * //from ww w .ja v a 2 s. c o m * @return */ private boolean rebuild() { if (promptForRebuild()) { MessageDialog dialog = new MessageDialog(getShell(), Messages.ValidationPreferencePage_RebuildDialogTitle, null, Messages.ValidationPreferencePage_RebuildDialogMessage, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); return (dialog.open() == 0); } return false; }
From source file:com.aptana.editor.php.ui.preferences.OptionsConfigurationBlock.java
License:Open Source License
protected boolean processChanges(IWorkbenchPreferenceContainer container) { IScopeContext currContext = fLookupOrder[0]; List<Key> changedOptions = new ArrayList<Key>(); boolean needsBuild = getChanges(currContext, changedOptions); if (changedOptions.isEmpty()) { hasChanges = false;/*from ww w .j a va2s . c om*/ return true; } else { hasChanges = true; } boolean doBuild = false; if (needsBuild) { String[] strings = getFullBuildDialogStrings(fProject == null); if (strings != null) { MessageDialog dialog = new MessageDialog(getShell(), strings[0], null, strings[1], MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 2); int res = dialog.open(); if (res == 0) { doBuild = true; } else if (res != 1) { return false; // cancel pressed } } } if (doBuild) { prepareForBuild(); } if (container != null) { // no need to apply the changes to the original store: will be done by the page container if (doBuild) { // post build container.registerUpdateJob(CoreUtility.getBuildJob(fProject)); } } else { // apply changes right away try { fManager.applyChanges(); } catch (BackingStoreException e) { IdeLog.logError(PHPEplPlugin.getDefault(), "Error applying changes", e); //$NON-NLS-1$ return false; } if (doBuild) { CoreUtility.getBuildJob(fProject).schedule(); } } return true; }
From source file:com.aptana.formatter.ui.preferences.OptionsConfigurationBlock.java
License:Open Source License
protected boolean processChanges(IWorkbenchPreferenceContainer container) { IScopeContext currContext = fLookupOrder[0]; List<PreferenceKey> changedOptions = new ArrayList<PreferenceKey>(); boolean needsBuild = getChanges(currContext, changedOptions); if (changedOptions.isEmpty()) { return true; }/*from w ww .java 2 s. c o m*/ if (needsBuild) { int count = getRebuildCount(); if (count > fRebuildCount) { needsBuild = false; // build already requested fRebuildCount = count; } } boolean doBuild = false; if (needsBuild) { IPreferenceChangeRebuildPrompt prompt = getPreferenceChangeRebuildPrompt(fProject == null, changedOptions); if (prompt != null) { MessageDialog dialog = new MessageDialog(getShell(), prompt.getTitle(), null, prompt.getMessage(), MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 2); int res = dialog.open(); if (res == 0) { doBuild = true; } else if (res != 1) { return false; // cancel pressed } } } if (container != null) { // no need to apply the changes to the original store: will be done // by the page container if (doBuild) { // post build incrementRebuildCount(); for (Job job : createBuildJobs(fProject)) { container.registerUpdateJob(job); } } } else { // apply changes right away try { fManager.applyChanges(); } catch (BackingStoreException e) { IdeLog.logError(FormatterUIEplPlugin.getDefault(), e, IDebugScopes.DEBUG); return false; } if (doBuild) { for (Job job : createBuildJobs(fProject)) { job.schedule(); } } } return true; }
From source file:com.aptana.ide.core.ui.wizards.WizardFolderImportPage.java
License:Open Source License
/** * The <code>WizardDataTransfer</code> implementation of this <code>IOverwriteQuery</code> method asks the user * whether the existing resource at the given path should be overwritten. * /*from w ww . ja va2 s. c om*/ * @param pathString * @return the user's reply: one of <code>"YES"</code>, <code>"NO"</code>, <code>"ALL"</code>, or * <code>"CANCEL"</code> */ public String queryOverwrite(String pathString) { Path path = new Path(pathString); String messageString; // Break the message up if there is a file name and a directory // and there are at least 2 segments. if (path.getFileExtension() == null || path.segmentCount() < 2) { messageString = NLS.bind(IDEWorkbenchMessages.WizardDataTransfer_existsQuestion, pathString); } else { messageString = NLS.bind(IDEWorkbenchMessages.WizardDataTransfer_overwriteNameAndPathQuestion, path.lastSegment(), path.removeLastSegments(1).toOSString()); } final MessageDialog dialog = new MessageDialog(getContainer().getShell(), IDEWorkbenchMessages.Question, null, messageString, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.NO_TO_ALL_LABEL, IDialogConstants.CANCEL_LABEL }, 0); String[] response = new String[] { YES, ALL, NO, NO_ALL, CANCEL }; // run in syncExec because callback is from an operation, // which is probably not running in the UI thread. getControl().getDisplay().syncExec(new Runnable() { public void run() { dialog.open(); } }); return dialog.getReturnCode() < 0 ? CANCEL : response[dialog.getReturnCode()]; }
From source file:com.aptana.ide.rcp.IDEWorkbenchAdvisor.java
License:Open Source License
/** * Initialize the listener for settings changes. *///from ww w . j a v a2 s. c o m private void initializeSettingsChangeListener() { settingsChangeListener = new Listener() { boolean currentHighContrast = Display.getCurrent().getHighContrast(); public void handleEvent(org.eclipse.swt.widgets.Event event) { if (Display.getCurrent().getHighContrast() == currentHighContrast) return; currentHighContrast = !currentHighContrast; // make sure they really want to do this if (new MessageDialog(null, IDEWorkbenchMessages.SystemSettingsChange_title, null, IDEWorkbenchMessages.SystemSettingsChange_message, MessageDialog.QUESTION, new String[] { IDEWorkbenchMessages.SystemSettingsChange_yes, IDEWorkbenchMessages.SystemSettingsChange_no }, 1).open() == Window.OK) { PlatformUI.getWorkbench().restart(); } } }; }
From source file:com.aptana.ide.server.ui.views.GenericServersView.java
License:Open Source License
private void doDelete() { IStructuredSelection selection = (IStructuredSelection) serverViewer.getSelection(); if (selection.isEmpty()) { return;// w w w. j a v a2 s . com } IServer server = (IServer) selection.getFirstElement(); if (!server.canDelete().isOK()) { return; } boolean mayStop = (server.getServerState() != IServer.STATE_STOPPED && server.getServerState() != IServer.STATE_UNKNOWN); boolean askStopBeforeDelete = (server.askStopBeforeDelete().getCode() == IStatus.OK); DeleteServerConfirmDialog dlg = new DeleteServerConfirmDialog(getViewSite().getShell(), Messages.ServersView_CONFIRM_DELETE, null, StringUtils.format(Messages.ServersView_CONFIRM_DELETE_TEXT, server.getName()), MessageDialog.QUESTION, new String[] { Messages.GenericServersView_YES, Messages.GenericServersView_NO }, 0, mayStop, askStopBeforeDelete); int openConfirm = dlg.open(); if (openConfirm != 0) { return; } boolean doStop = dlg.shouldStop; if (doStop) { server.stop(true, null, null); } try { ServerCore.getServerManager().removeServer(server); } catch (CoreException e) { MessageDialog.openError(getViewSite().getShell(), Messages.ServersView_CONFIRM_DELETE, StringUtils.format(Messages.ServersView_CONFIRM_DELETE_TEXT, server.getName())); } }
From source file:com.aptana.ide.syncing.ui.dialogs.SiteConnectionsEditorDialog.java
License:Open Source License
protected boolean doSelectionChange() { if (sitePropertiesWidget.isChanged()) { MessageDialog dlg = new MessageDialog(getShell(), Messages.SiteConnectionsEditorDialog_SaveConfirm_Title, null, MessageFormat.format(Messages.SiteConnectionsEditorDialog_SaveConfirm_Message, sitePropertiesWidget.getSource().getName()), MessageDialog.QUESTION, new String[] { IDialogConstants.NO_LABEL, IDialogConstants.YES_LABEL, IDialogConstants.CANCEL_LABEL }, 1);//from ww w . j ava2 s . com switch (dlg.open()) { case 1: if (sitePropertiesWidget.applyChanges()) { break; } else { // unresolved error exists in the current selection MessageDialog.openWarning(getShell(), Messages.SiteConnectionsEditorDialog_UnresolvedWarning_Title, Messages.SiteConnectionsEditorDialog_UnresolvedWarning_Message); } case 2: return false; } } return true; }
From source file:com.aptana.ide.syncing.ui.views.SmartSyncDialog.java
License:Open Source License
/** * @see org.eclipse.jface.window.Window#open() *//*from ww w.jav a2 s . c o m*/ public int open() { if (sourceConnectionPoint instanceof IProjectProvider) { IProjectProvider projectProvider = (IProjectProvider) sourceConnectionPoint; IProject project = projectProvider.getProject(); if (project != null) { try { if (Boolean.TRUE.equals((Boolean) project.getSessionProperty(Synchronizer.SYNC_IN_PROGRESS))) { MessageDialog messageDialog = new MessageDialog(CoreUIUtils.getActiveShell(), Messages.SmartSyncDialog_SyncInProgressTitle, null, Messages.SmartSyncDialog_SyncInProgress, MessageDialog.QUESTION, new String[] { IDialogConstants.CANCEL_LABEL, Messages.SmartSyncDialog_ContinueLabel, }, 0); if (messageDialog.open() == 0) { return CANCEL; } } } catch (CoreException e) { } } } if (!compareInBackground) { super.open(); } load(true); return OK; }