List of usage examples for org.eclipse.jface.dialogs MessageDialogWithToggle PROMPT
String PROMPT
To view the source code for org.eclipse.jface.dialogs MessageDialogWithToggle PROMPT.
Click Source Link
From source file:ccw.leiningen.NewLeiningenProjectWizard.java
License:Open Source License
/** * Updates the perspective based on the current settings in the * Workbench/Perspectives preference page. * // w w w.j a va2s.c o m * Use the setting for the new perspective opening if we are set to open in * a new perspective. * <p> * A new project wizard class will need to implement the * <code>IExecutableExtension</code> interface so as to gain access to the * wizard's <code>IConfigurationElement</code>. That is the configuration * element to pass into this method. * </p> * * @param configElement - * the element we are updating with * * @see IPreferenceConstants#OPM_NEW_WINDOW * @see IPreferenceConstants#OPM_ACTIVE_PAGE * @see IWorkbenchPreferenceConstants#NO_NEW_PERSPECTIVE */ public static void updatePerspective(IConfigurationElement configElement) { // Do not change perspective if the configuration element is // not specified. if (configElement == null) { return; } // Retrieve the new project open perspective preference setting String perspSetting = PrefUtil.getAPIPreferenceStore() .getString(IDE.Preferences.PROJECT_OPEN_NEW_PERSPECTIVE); String promptSetting = IDEWorkbenchPlugin.getDefault().getPreferenceStore() .getString(IDEInternalPreferences.PROJECT_SWITCH_PERSP_MODE); // Return if do not switch perspective setting and are not prompting if (!(promptSetting.equals(MessageDialogWithToggle.PROMPT)) && perspSetting.equals(IWorkbenchPreferenceConstants.NO_NEW_PERSPECTIVE)) { return; } // Read the requested perspective id to be opened. String finalPerspId = configElement.getAttribute(FINAL_PERSPECTIVE); if (finalPerspId == null) { return; } // Map perspective id to descriptor. IPerspectiveRegistry reg = PlatformUI.getWorkbench().getPerspectiveRegistry(); // leave this code in - the perspective of a given project may map to // activities other than those that the wizard itself maps to. IPerspectiveDescriptor finalPersp = reg.findPerspectiveWithId(finalPerspId); if (finalPersp != null && finalPersp instanceof IPluginContribution) { IPluginContribution contribution = (IPluginContribution) finalPersp; if (contribution.getPluginId() != null) { IWorkbenchActivitySupport workbenchActivitySupport = PlatformUI.getWorkbench().getActivitySupport(); IActivityManager activityManager = workbenchActivitySupport.getActivityManager(); IIdentifier identifier = activityManager .getIdentifier(WorkbenchActivityHelper.createUnifiedId(contribution)); Set idActivities = identifier.getActivityIds(); if (!idActivities.isEmpty()) { Set enabledIds = new HashSet(activityManager.getEnabledActivityIds()); if (enabledIds.addAll(idActivities)) { workbenchActivitySupport.setEnabledActivityIds(enabledIds); } } } } else { IDEWorkbenchPlugin.log("Unable to find perspective " //$NON-NLS-1$ + finalPerspId + " in BasicNewProjectResourceWizard.updatePerspective"); //$NON-NLS-1$ return; } // gather the preferred perspectives // always consider the final perspective (and those derived from it) // to be preferred ArrayList preferredPerspIds = new ArrayList(); addPerspectiveAndDescendants(preferredPerspIds, finalPerspId); String preferred = configElement.getAttribute(PREFERRED_PERSPECTIVES); if (preferred != null) { StringTokenizer tok = new StringTokenizer(preferred, " \t\n\r\f,"); //$NON-NLS-1$ while (tok.hasMoreTokens()) { addPerspectiveAndDescendants(preferredPerspIds, tok.nextToken()); } } IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (window != null) { IWorkbenchPage page = window.getActivePage(); if (page != null) { IPerspectiveDescriptor currentPersp = page.getPerspective(); // don't switch if the current perspective is a preferred // perspective if (currentPersp != null && preferredPerspIds.contains(currentPersp.getId())) { return; } } // prompt the user to switch if (!confirmPerspectiveSwitch(window, finalPersp)) { return; } } int workbenchPerspectiveSetting = WorkbenchPlugin.getDefault().getPreferenceStore() .getInt(IPreferenceConstants.OPEN_PERSP_MODE); // open perspective in new window setting if (workbenchPerspectiveSetting == IPreferenceConstants.OPM_NEW_WINDOW) { openInNewWindow(finalPersp); return; } // replace active perspective setting otherwise replaceCurrentPerspective(finalPersp); }
From source file:com.android.ide.eclipse.adt.internal.editors.layout.properties.XmlPropertyEditor.java
License:Open Source License
@Override protected boolean setEditorText(Property property, String text) throws Exception { Object oldValue = property.getValue(); String old = oldValue != null ? oldValue.toString() : null; // If users enters a new id without specifying the @id/@+id prefix, insert it boolean isId = isIdProperty(property); if (isId && !text.startsWith(PREFIX_RESOURCE_REF)) { text = NEW_ID_PREFIX + text;/*from www. j a va2s.c o m*/ } // Handle id refactoring: if you change an id, may want to update references too. // Ask user. if (isId && property instanceof XmlProperty && old != null && !old.isEmpty() && text != null && !text.isEmpty() && !text.equals(old)) { XmlProperty xmlProperty = (XmlProperty) property; IPreferenceStore store = AdtPlugin.getDefault().getPreferenceStore(); String refactorPref = store.getString(AdtPrefs.PREFS_REFACTOR_IDS); boolean performRefactor = false; Shell shell = AdtPlugin.getShell(); if (refactorPref == null || refactorPref.isEmpty() || refactorPref.equals(MessageDialogWithToggle.PROMPT)) { MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoCancelQuestion(shell, "Update References?", "Update all references as well? " + "This will update all XML references and Java R field references.", "Do not show again", false, store, AdtPrefs.PREFS_REFACTOR_IDS); switch (dialog.getReturnCode()) { case IDialogConstants.CANCEL_ID: return false; case IDialogConstants.YES_ID: performRefactor = true; break; case IDialogConstants.NO_ID: performRefactor = false; break; } } else { performRefactor = refactorPref.equals(MessageDialogWithToggle.ALWAYS); } if (performRefactor) { CommonXmlEditor xmlEditor = xmlProperty.getXmlEditor(); if (xmlEditor != null) { IProject project = xmlEditor.getProject(); if (project != null && shell != null) { RenameResourceWizard.renameResource(shell, project, ResourceType.ID, stripIdPrefix(old), stripIdPrefix(text), false); } } } } property.setValue(text); return true; }
From source file:com.aptana.ide.core.ui.preferences.PreferenceInitializer.java
License:Open Source License
/** * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences() *///from w w w . j av a2 s .c om public void initializeDefaultPreferences() { IPreferenceStore store = CoreUIPlugin.getDefault().getPreferenceStore(); store.setDefault(IPreferenceConstants.P_ENABLED, true); store.setDefault(IPreferenceConstants.P_SCHEDULE, IPreferenceConstants.VALUE_ON_STARTUP); store.setDefault(IPreferenceConstants.P_DOWNLOAD, false); store.setDefault(IPreferenceConstants.PREF_AUTO_BACKUP_ENABLED, true); store.setDefault(IPreferenceConstants.PREF_AUTO_BACKUP_LASTNAME, ""); //$NON-NLS-1$ store.setDefault(IPreferenceConstants.PREF_AUTO_BACKUP_PATH, ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString() + File.separatorChar + "preferences"); //$NON-NLS-1$ store.setDefault(IPreferenceConstants.PREF_FILE_EXPLORER_WEB_FILES, "*.js;*.htm;*.html;*.xhtm;*.xhtml;*.css;*.xml;*.xsl;*.xslt;" //$NON-NLS-1$ + "*.fla;*.gif;*.jpg;*.jpeg;*.php;*.asp;*.jsp;*.png;*.as;*.sdoc;*.swf;*.shtml;*.txt;*.aspx;*.asmx;"); //$NON-NLS-1$ store.setDefault(com.aptana.ide.core.preferences.IPreferenceConstants.PREF_GLOBAL_SYNC_CLOAKING_EXTENSIONS, ".svn;.tmp*~;.settings;CVS;.git;.DS_Store"); //$NON-NLS-1$ store.setDefault(IPreferenceConstants.INITIAL_POOL_SIZE, DEFAULT_INITIAL_POOL_SIZE); store.setDefault(IPreferenceConstants.MAX_POOL_SIZE, DEFAULT_MAX_POOL_SIZE); store = Activator.getDefault().getPreferenceStore(); store.setDefault(IPreferencesConstants2.SWITCH_TO_APTANA_PRESPECTIVE, MessageDialogWithToggle.PROMPT); }
From source file:com.aptana.ide.editors.preferences.AdvancedPreferencePage.java
License:Open Source License
/** * Creates the field editors. Field editors are abstractions of the common GUI blocks needed to manipulate various * types of preferences. Each field editor knows how to save and restore itself. *///ww w.j a va 2 s. co m public void createFieldEditors() { addTab(Messages.AdvancedPreferencePage_User); Composite appearanceComposite = getFieldEditorParent(); addField(new StringFieldEditor(com.aptana.ide.core.ui.preferences.IPreferenceConstants.PREF_USER_NAME, com.aptana.ide.core.ui.preferences.Messages.GeneralPreferencePage_EmailAddressForBugReports, appearanceComposite)); switchPerspectiveField = new RadioGroupFieldEditor(IPreferencesConstants2.SWITCH_TO_APTANA_PRESPECTIVE, Messages.AdvancedPreferencePage_switchToAptanaPerspective, 3, new String[][] { { Messages.AdvancedPreferencePage_Always, MessageDialogWithToggle.ALWAYS }, { Messages.AdvancedPreferencePage_Never, MessageDialogWithToggle.NEVER }, { Messages.AdvancedPreferencePage_Prompt, MessageDialogWithToggle.PROMPT } }, appearanceComposite, true); addField(switchPerspectiveField); if (Platform.OS_WIN32.equals(Platform.getOS())) { Group ieGroup = new Group(appearanceComposite, SWT.NONE); GridData ieData = new GridData(SWT.FILL, SWT.FILL, true, true); ieData.horizontalSpan = 2; ieGroup.setLayoutData(ieData); ieGroup.setLayout(new GridLayout(1, true)); ieGroup.setText(Messages.AdvancedPreferencePage_IESettings); notepad = new Button(ieGroup, SWT.RADIO); notepad.setText(Messages.AdvancedPreferencePage_AssociateWithNotepad); notepad.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { setErrorMessage(null); setValid(true); } }); otherButton = new Button(ieGroup, SWT.RADIO); otherButton.setText(Messages.AdvancedPreferencePage_AssociateWithOther); Composite other = new Composite(ieGroup, SWT.NONE); GridLayout otherLayout = new GridLayout(2, false); otherLayout.marginHeight = 0; other.setLayout(otherLayout); other.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); text = new Text(other, SWT.BORDER | SWT.SINGLE); text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); text.setEditable(false); text.setEnabled(false); browse = new Button(other, SWT.PUSH); browse.setEnabled(false); browse.setText(StringUtils.ellipsify(CoreStrings.BROWSE)); browse.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { FileDialog dialog = new FileDialog(browse.getShell(), SWT.OPEN); String program = dialog.open(); if (program != null) { text.setText(program); setErrorMessage(null); setValid(true); } } }); otherButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { boolean selection = otherButton.getSelection(); browse.setEnabled(selection); text.setEnabled(selection); if (!selection) { text.setText(""); //$NON-NLS-1$ } else { if (text.getText().length() < 1) { setErrorMessage(Messages.AdvancedPreferencePage_PleaseSpecifyApplication); setValid(false); } } } }); String current = null; try { current = PlatformUtils.queryRegestryStringValue(IE_PREVIEW_KEY, null); } catch (Exception e) { IdeLog.logError(UnifiedEditorsPlugin.getDefault(), Messages.AdvancedPreferencePage_ERR_ErrorGettingRegistryValue, e); } if (current != null) { if (current.equalsIgnoreCase(IE_PREVIEW_NOTEPAD_VALUE) || current.endsWith(IE_PREVIEW_NOTEPAD_VALUE)) { notepad.setSelection(true); } else { otherButton.setSelection(true); browse.setEnabled(true); text.setEnabled(true); text.setText(current); } } } addTab(Messages.AdvancedPreferencePage_Debugging); appearanceComposite = getFieldEditorParent(); Composite group = com.aptana.ide.core.ui.preferences.GeneralPreferencePage.createGroup(appearanceComposite, Messages.AdvancedPreferencePage_LBL_AdvancedFunctionality); addField(new BooleanFieldEditor(IPreferenceConstants.SHOW_DEBUG_HOVER, Messages.AdvancedPreferencePage_ShowDebugInformation, group)); // addField(new BooleanFieldEditor(com.aptana.ide.core.preferences.IPreferenceConstants.SHOW_LIVE_HELP, // "Show live help", group)); addField(new BooleanFieldEditor(IPreferenceConstants.PARSER_OFF_UI, Messages.AdvancedPreferencePage_LBL_ParserOffUI, group)); group = com.aptana.ide.core.ui.preferences.GeneralPreferencePage.createGroup(appearanceComposite, Messages.AdvancedPreferencePage_LBL_DebuggingOutputLevel); //addField(new BooleanFieldEditor(com.aptana.ide.core.preferences.IPreferenceConstants.PREF_ENABLE_DEBUGGING, // Messages.AdvancedPreferencePage_LogDebuggingMessages, appearanceComposite)); Composite debugComp = new Composite(group, SWT.NONE); GridLayout pkcLayout = new GridLayout(3, false); pkcLayout.marginWidth = 0; pkcLayout.marginHeight = 0; debugComp.setLayout(pkcLayout); debugComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); Label pianoKeyLabel = new Label(debugComp, SWT.LEFT); pianoKeyLabel.setText(Messages.AdvancedPreferencePage_LBL_ControlDebugInformationAmountHelp); GridData pklData = new GridData(SWT.FILL, SWT.FILL, true, false); pklData.horizontalSpan = 3; pianoKeyLabel.setLayoutData(pklData); Label less = new Label(debugComp, SWT.LEFT); less.setText(Messages.AdvancedPreferencePage_LBL_Errors); debugSlider = new Scale(debugComp, SWT.HORIZONTAL); debugSlider.setIncrement(1); debugSlider.setMinimum(1); debugSlider.setMaximum(3); Preferences p = AptanaCorePlugin.getDefault().getPluginPreferences(); debugSlider.setSelection(p.getInt(com.aptana.ide.core.preferences.IPreferenceConstants.PREF_DEBUG_LEVEL)); Label more = new Label(debugComp, SWT.LEFT); more.setText(Messages.AdvancedPreferencePage_LBL_All); final Label currentValue = new Label(debugComp, SWT.LEFT); currentValue.setText(getValueLabel(debugSlider.getSelection())); currentValue.setFont(SWTUtils.getDefaultSmallFont()); pklData = new GridData(SWT.FILL, SWT.FILL, true, false); pklData.horizontalSpan = 3; currentValue.setLayoutData(pklData); debugSlider.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent selectionevent) { currentValue.setText(getValueLabel(debugSlider.getSelection())); } public void widgetSelected(SelectionEvent selectionevent) { currentValue.setText(getValueLabel(debugSlider.getSelection())); } }); }
From source file:com.aptana.ide.wizards.LibraryProjectWizard.java
License:Open Source License
/** * Updates the perspective based on the current settings in the Workbench/Perspectives preference page. Use the * setting for the new perspective opening if we are set to open in a new perspective. * <p>//from w w w . ja v a2 s . c o m * A new project wizard class will need to implement the <code>IExecutableExtension</code> interface so as to gain * access to the wizard's <code>IConfigurationElement</code>. That is the configuration element to pass into this * method. * </p> * * @param configElement - * the element we are updating with * @see IPreferenceConstants#OPM_NEW_WINDOW * @see IPreferenceConstants#OPM_ACTIVE_PAGE * @see IWorkbenchPreferenceConstants#NO_NEW_PERSPECTIVE */ public static void updatePerspective(IConfigurationElement configElement) { // Do not change perspective if the configuration element is // not specified. if (configElement == null) { return; } // Retrieve the new project open perspective preference setting String perspSetting = PrefUtil.getAPIPreferenceStore() .getString(IDE.Preferences.PROJECT_OPEN_NEW_PERSPECTIVE); String promptSetting = IDEWorkbenchPlugin.getDefault().getPreferenceStore() .getString(IDEInternalPreferences.PROJECT_SWITCH_PERSP_MODE); // Return if do not switch perspective setting and are not prompting if (!(promptSetting.equals(MessageDialogWithToggle.PROMPT)) && perspSetting.equals(IWorkbenchPreferenceConstants.NO_NEW_PERSPECTIVE)) { return; } // Read the requested perspective id to be opened. String finalPerspId = configElement.getAttribute(FINAL_PERSPECTIVE); if (finalPerspId == null) { return; } // Map perspective id to descriptor. IPerspectiveRegistry reg = PlatformUI.getWorkbench().getPerspectiveRegistry(); // leave this code in - the perspective of a given project may map to // activities other than those that the wizard itself maps to. IPerspectiveDescriptor finalPersp = reg.findPerspectiveWithId(finalPerspId); if (finalPersp != null && finalPersp instanceof IPluginContribution) { IPluginContribution contribution = (IPluginContribution) finalPersp; if (contribution.getPluginId() != null) { IWorkbenchActivitySupport workbenchActivitySupport = PlatformUI.getWorkbench().getActivitySupport(); IActivityManager activityManager = workbenchActivitySupport.getActivityManager(); IIdentifier identifier = activityManager .getIdentifier(WorkbenchActivityHelper.createUnifiedId(contribution)); Set idActivities = identifier.getActivityIds(); if (!idActivities.isEmpty()) { Set enabledIds = new HashSet(activityManager.getEnabledActivityIds()); if (enabledIds.addAll(idActivities)) { workbenchActivitySupport.setEnabledActivityIds(enabledIds); } } } } else { IDEWorkbenchPlugin.log("Unable to find persective " //$NON-NLS-1$ + finalPerspId + " in BasicNewProjectResourceWizard.updatePerspective"); //$NON-NLS-1$ return; } // gather the preferred perspectives // always consider the final perspective (and those derived from it) // to be preferred ArrayList preferredPerspIds = new ArrayList(); addPerspectiveAndDescendants(preferredPerspIds, finalPerspId); String preferred = configElement.getAttribute(PREFERRED_PERSPECTIVES); if (preferred != null) { StringTokenizer tok = new StringTokenizer(preferred, " \t\n\r\f,"); //$NON-NLS-1$ while (tok.hasMoreTokens()) { addPerspectiveAndDescendants(preferredPerspIds, tok.nextToken()); } } IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (window != null) { IWorkbenchPage page = window.getActivePage(); if (page != null) { IPerspectiveDescriptor currentPersp = page.getPerspective(); // don't switch if the current perspective is a preferred // perspective if (currentPersp != null && preferredPerspIds.contains(currentPersp.getId())) { return; } } // prompt the user to switch if (!confirmPerspectiveSwitch(window, finalPersp)) { return; } } int workbenchPerspectiveSetting = WorkbenchPlugin.getDefault().getPreferenceStore() .getInt(IPreferenceConstants.OPEN_PERSP_MODE); // open perspective in new window setting if (workbenchPerspectiveSetting == IPreferenceConstants.OPM_NEW_WINDOW) { openInNewWindow(finalPersp); return; } // replace active perspective setting otherwise replaceCurrentPerspective(finalPersp); }
From source file:com.aptana.js.debug.ui.internal.preferences.JSDebugUIPreferenceInitializer.java
License:Open Source License
/** * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences() *///from w w w .j ava 2 s. c o m public void initializeDefaultPreferences() { IEclipsePreferences node = EclipseUtil.defaultScope().getNode(JSDebugUIPlugin.PLUGIN_ID); // default preferences node.putBoolean(IJSDebugUIConstants.PREF_CONFIRM_EXIT_DEBUGGER, true); node.put(IJSDebugUIConstants.PREF_SHOW_DETAILS, IJSDebugUIConstants.DETAIL_PANE); node.putBoolean(IJSDebugUIConstants.PREF_SHOW_CONSTANTS, false); node.put(IJSDebugUIConstants.CONSOLE_WARN_COLOR, StringConverter.asString(new RGB(255, 215, 0))); // override default org.eclipse.debug.ui options node = EclipseUtil.defaultScope().getNode(DebugUIPlugin.getDefault().getBundle().getSymbolicName()); if (MessageDialogWithToggle.NEVER .equals(node.get(IInternalDebugUIConstants.PREF_SWITCH_TO_PERSPECTIVE, StringUtil.EMPTY))) { node.put(IInternalDebugUIConstants.PREF_SWITCH_TO_PERSPECTIVE, MessageDialogWithToggle.PROMPT); } }
From source file:com.aptana.ui.dialogs.SaveAndLaunchPromptDialog.java
License:Open Source License
protected void okPressed() { IPreferenceStore store = DebugUIPlugin.getDefault().getPreferenceStore(); String val = (savePref.getSelection() ? MessageDialogWithToggle.ALWAYS : MessageDialogWithToggle.PROMPT); store.setValue(IInternalDebugUIConstants.PREF_SAVE_DIRTY_EDITORS_BEFORE_LAUNCH, val); super.okPressed(); }
From source file:com.atlassian.connector.eclipse.internal.crucible.ui.CrucibleUiPlugin.java
License:Open Source License
@Override public void start(BundleContext context) throws Exception { super.start(context); plugin = this; switchingPerspectivesListener = new SwitchingPerspectiveReviewActivationListener(); activeReviewManager = new ActiveReviewManager(true); activeReviewManager.addReviewActivationListener(switchingPerspectivesListener); avatarImages = new AvatarImages(); enableActiveReviewManager();// ww w. ja v a2 s .c o m plugin.getPreferenceStore().setDefault(CrucibleUiConstants.PREFERENCE_ACTIVATE_REVIEW, MessageDialogWithToggle.PROMPT); }
From source file:com.ebmwebsourcing.petals.server.ui.preferences.PetalsServerPreferenceInitializer.java
License:Open Source License
@Override public void initializeDefaultPreferences() { IPreferenceStore store = PetalsServerPlugin.getDefault().getPreferenceStore(); store.setDefault(PetalsServerPreferencePage.START_IN_CONSOLE_MODE, MessageDialogWithToggle.PROMPT); }
From source file:com.ebmwebsourcing.petals.server.ui.preferences.PetalsServerPreferencePage.java
License:Open Source License
@Override protected Control createContents(Composite parent) { Composite container = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginTop = 20;/* ww w. j a va 2s . c o m*/ container.setLayout(layout); container.setLayoutData(new GridData(GridData.FILL_BOTH)); String[][] labelAndValues = new String[][] { new String[] { "Yes", MessageDialogWithToggle.ALWAYS }, new String[] { "No", MessageDialogWithToggle.NEVER }, new String[] { "Prompt", MessageDialogWithToggle.PROMPT } }; this.startModeField = new RadioGroupFieldEditor(START_IN_CONSOLE_MODE, "Start in Console mode", 3, labelAndValues, container, true); return container; }