List of usage examples for org.eclipse.jface.preference IPreferenceStore getBoolean
boolean getBoolean(String name);
From source file:com.mentor.nucleus.bp.ui.text.editor.SyntaxHighlightingPreferencesStore.java
License:Open Source License
public IPreferenceModel loadModel(IPreferenceStore store, BasePlugin plugin, IPreferenceModel model) { SyntaxHighlightingPreferences prefs = null; if (model == null) prefs = new SyntaxHighlightingPreferences(plugin.getSharedColors()); else {// w ww. j a v a 2 s . c o m if (!(model instanceof SyntaxHighlightingPreferences)) { throw new IllegalArgumentException("Cannot load instance of " + model.getClass().getName()); } prefs = (SyntaxHighlightingPreferences) model; } prefs.isSystemColor = store.getBoolean(BACKGROUND_IS_SYSTEM_COLOR); prefs.backgroundRGB = PreferenceConverter.getColor(store, BACKGROUND_RGB); int tokenTypeCount = store.getInt(TOKEN_TYPE_COUNT); if (tokenTypeCount == 0) { restoreModelDefaults(prefs); return prefs; } for (int i = 0; i < tokenTypeCount; i++) { int typeId = store.getInt(TOKEN_TYPE_ID + i); String typeDesc = store.getString(TOKEN_DESCRIPTION + typeId); RGB foregroundRGB = parseRGB(store.getString(TOKEN_FOREGROUND + typeId)); boolean isBold = store.getBoolean(TOKEN_IS_BOLD + typeId); int style = SWT.NULL; if (isBold) style = SWT.BOLD; prefs.setTextAttribute(typeId, typeDesc, foregroundRGB, null, style); } return prefs; }
From source file:com.microsoft.tfs.client.common.ui.dialogs.vc.GatedCheckinDialog.java
License:Open Source License
private void loadUserSettings() { final IPreferenceStore prefs = TFSCommonUIClientPlugin.getDefault().getPreferenceStore(); if (allowKeepCheckedOut) { final boolean flag = prefs .getBoolean(UIPreferenceConstants.GATED_CONFIRMATION_PRESERVE_PENDING_CHANGES); preserveLocalChangesButton.setSelection(flag); preserveLocalChanges = flag;//from w w w . j a v a 2 s. c o m } if (buildDefinitionCombo != null) { final String uri = prefs.getString(UIPreferenceConstants.GATED_CONFIRMATION_LAST_BUILD_DEFINITION); for (int i = 0; i < buildDefinitionUris.length; i++) { if (buildDefinitionUris[i].equals(uri)) { buildDefinitionCombo.select(i); buildDefinitionSelectionChanged(); break; } } } }
From source file:com.microsoft.tfs.client.common.ui.dialogs.vc.RollbackItemDialog.java
License:Open Source License
@Override protected void okPressed() { try {/*from w ww . j av a 2s.c o m*/ item = rollbackItemControl.getItem(); if (!ServerPath.isServerPath(item)) { final String serverPath = repository.getWorkspace().getMappedServerPath(item); if (StringUtil.isNullOrEmpty(serverPath)) { final String noMappingExistsFormat = Messages .getString("RollbackItemDialog.NoMappingExistsFormat"); //$NON-NLS-1$ MessageBoxHelpers.errorMessageBox(getShell(), Messages.getString("RollbackItemDialog.ErrorBoxTitle"), //$NON-NLS-1$ MessageFormat.format(noMappingExistsFormat, item)); return; } item = serverPath; } item = ServerPath.canonicalize(item); rollbackOperationType = rollbackItemControl.getRollbackOperationType(); rollbackOptions = RollbackOptions.NONE; final IPreferenceStore preferences = TFSCommonUIClientPlugin.getDefault().getPreferenceStore(); if (!preferences.getBoolean(UIPreferenceConstants.AUTO_RESOLVE_CONFLICTS)) { rollbackOptions = rollbackOptions.combine(RollbackOptions.NO_AUTO_RESOLVE); } if (rollbackOperationType == RollbackOperationType.SPECIFIC_VERSION) { fromVersion = rollbackItemControl.getVersionSpec(); toVersion = LatestVersionSpec.INSTANCE; rollbackOptions = rollbackOptions.combine(RollbackOptions.TO_VERSION); } else if (rollbackOperationType == RollbackOperationType.SINGLE_CHANGESET) { fromVersion = VersionSpec.parseSingleVersionFromSpec(rollbackItemControl.getSingleChangesetID(), VersionControlConstants.AUTHENTICATED_USER); toVersion = fromVersion; } else if (rollbackOperationType == RollbackOperationType.CHANGESET_RANGE) { final int changesetFromID = Integer.parseInt(rollbackItemControl.getChangesetFromID()); final int changesetToID = Integer.parseInt(rollbackItemControl.getChangesetToID()); fromVersion = VersionSpec.parseSingleVersionFromSpec( String.valueOf(Math.min(changesetFromID, changesetToID)), VersionControlConstants.AUTHENTICATED_USER); toVersion = VersionSpec.parseSingleVersionFromSpec( String.valueOf(Math.max(changesetFromID, changesetToID)), VersionControlConstants.AUTHENTICATED_USER); } } catch (final Exception e) { MessageBoxHelpers.errorMessageBox(getShell(), Messages.getString("RollbackItemDialog.ErrorBoxTitle"), //$NON-NLS-1$ e.getMessage()); return; } super.okPressed(); }
From source file:com.microsoft.tfs.client.common.ui.helpers.CredentialsHelper.java
License:Open Source License
public static Credentials getOAuthCredentials(final URI serverURI, final JwtCredentials accessToken, final Action<DeviceFlowResponse> callback) { removeStaleOAuth2Token();/*from w ww .j a v a2 s. c o m*/ final IPreferenceStore prefStore = TFSCommonUIClientPlugin.getDefault().getPreferenceStore(); final String saverUserAgentProvider = System .getProperty(UIPreferenceConstants.USER_AGENT_PROVIDER_PROPERTY); if (prefStore.getBoolean(UIPreferenceConstants.USE_DEVICE_FLOW_AUTHENTICATION)) { /* * The OAuth device flow has been requested either by an Eclipse * preference or by JVM system property. We're setting the system * property -DuserAgentProvider to "none". */ System.setProperty(UIPreferenceConstants.USER_AGENT_PROVIDER_PROPERTY, UIPreferenceConstants.USER_AGENT_PROVIDER_VALUE); // ClientTelemetryHelper.sendDialogOpened(this); } else if (UIPreferenceConstants.USER_AGENT_PROVIDER_VALUE .equalsIgnoreCase(System.getProperty(UIPreferenceConstants.USER_AGENT_PROVIDER_PROPERTY))) { /* * The OAuth device flow has not been requested by an Eclipse * preference. We're removing the system property * -DuserAgentProvider only if it is set to "none". It might be also * set by the user to "StandardWidgetToolkit" or "JavaFx". */ System.getProperties().remove(UIPreferenceConstants.USER_AGENT_PROVIDER_PROPERTY); } try { final Authenticator authenticator; final OAuth2Authenticator oauth2Authenticator = OAuth2Authenticator.getAuthenticator(CLIENT_ID, REDIRECT_URL, accessTokenStore, callback); final Token token; final AuthLibHttpClientFactory authLibHttpClientFactory = new AuthLibHttpClientFactory(); Global.setHttpClientFactory(authLibHttpClientFactory); if (serverURI != null) { log.debug("Interactively retrieving credential based on oauth2 flow for " + serverURI.toString()); //$NON-NLS-1$ log.debug("Trying to persist credential, generating a PAT"); //$NON-NLS-1$ authenticator = new VstsPatAuthenticator(oauth2Authenticator, tokenStore); final String tokenKey = authenticator.getUriToKeyConversion().convert(serverURI, authenticator.getAuthType()); removeStalePersonalAccessToken(tokenKey, serverURI); final TokenPair oauth2Token = (accessToken == null) ? null : new TokenPair(accessToken.getAccessToken(), "null"); //$NON-NLS-1$ token = authenticator.getPersonalAccessToken(serverURI, VsoTokenScope.AllScopes, getAccessTokenDescription(serverURI.toString()), PromptBehavior.AUTO, oauth2Token); } else { log.debug("Interactively retrieving credential based on oauth2 flow for VSTS"); //$NON-NLS-1$ log.debug("Do not try to persist, generating oauth2 token."); //$NON-NLS-1$ authenticator = oauth2Authenticator; final TokenPair tokenPair = authenticator.getOAuth2TokenPair(); token = tokenPair != null ? tokenPair.AccessToken : null; } if (token != null && token.Type != null && !StringUtil.isNullOrEmpty(token.Value)) { switch (token.Type) { case Personal: return new PatCredentials(token.Value); case Access: return new JwtCredentials(token.Value); } } } finally { if (StringUtil.isNullOrEmpty(saverUserAgentProvider)) { System.getProperties().remove(UIPreferenceConstants.USER_AGENT_PROVIDER_PROPERTY); } else { System.setProperty(UIPreferenceConstants.USER_AGENT_PROVIDER_PROPERTY, saverUserAgentProvider); } } log.warn(Messages.getString("CredentialsHelper.InteractiveAuthenticationFailedDetailedLog1")); //$NON-NLS-1$ log.warn(Messages.getString("CredentialsHelper.InteractiveAuthenticationFailedDetailedLog2")); //$NON-NLS-1$ log.warn(Messages.getString("CredentialsHelper.InteractiveAuthenticationFailedDetailedLog3")); //$NON-NLS-1$ removeOAuth2Token(true); // Failed to get credential, return null return null; }
From source file:com.microsoft.tfs.client.common.ui.prefs.LabelDecoratorPreferencePage.java
License:Open Source License
private void initializeValues() { final IPreferenceStore prefs = TFSCommonUIClientPlugin.getDefault().getPreferenceStore(); decorateFolders.setSelection(prefs.getBoolean(UIPreferenceConstants.LABEL_DECORATION_DECORATE_FOLDERS)); decorateWithChangeset.setSelection(prefs.getBoolean(UIPreferenceConstants.LABEL_DECORATION_SHOW_CHANGESET)); decorateWithServerItem/* w w w .ja v a 2s . c o m*/ .setSelection(prefs.getBoolean(UIPreferenceConstants.LABEL_DECORATION_SHOW_SERVER_ITEM)); decorateWithIgnoredStatus .setSelection(prefs.getBoolean(UIPreferenceConstants.LABEL_DECORATION_SHOW_IGNORED_STATUS)); }
From source file:com.microsoft.tfs.client.common.ui.prefs.MainPreferencePage.java
License:Open Source License
private void initializeValues() { final IPreferenceStore store = getPreferenceStore(); reconnectButton.setSelection(store.getBoolean(UIPreferenceConstants.RECONNECT_AT_STARTUP)); connectAtImportButton/*from w w w . j a v a2 s. c o m*/ .setSelection(store.getBoolean(UIPreferenceConstants.CONNECT_MAPPED_PROJECTS_AT_IMPORT)); acceptUntrustedCertificatesButton .setSelection(store.getBoolean(UIPreferenceConstants.ACCEPT_UNTRUSTED_CERTIFICATES)); if (showBrowserPreference()) { setEmbeddedBrowserType(store.getInt(UIPreferenceConstants.EMBEDDED_WEB_BROWSER_TYPE)); } }
From source file:com.microsoft.tfs.client.common.ui.prefs.SourceControlPreferencePage.java
License:Open Source License
private void initializeValues() { final IPreferenceStore store = getPreferenceStore(); autoGetButton.setSelection(store.getBoolean(UIPreferenceConstants.GET_LATEST_ON_CHECKOUT)); showDeletedItemsButton.setSelection(store.getBoolean(UIPreferenceConstants.SHOW_DELETED_ITEMS)); autoResolveButton.setSelection(store.getBoolean(UIPreferenceConstants.AUTO_RESOLVE_CONFLICTS)); if (UIPreferenceConstants.CHECKOUT_LOCK_LEVEL_CHECKOUT .equals(store.getString(UIPreferenceConstants.CHECKOUT_LOCK_LEVEL))) { lockLevelCheckOutButton.setSelection(true); lockLevelCheckInButton.setSelection(false); lockLevelUnchangedButton.setSelection(false); } else if (UIPreferenceConstants.CHECKOUT_LOCK_LEVEL_CHECKIN .equals(store.getString(UIPreferenceConstants.CHECKOUT_LOCK_LEVEL))) { lockLevelCheckOutButton.setSelection(false); lockLevelCheckInButton.setSelection(true); lockLevelUnchangedButton.setSelection(false); } else {/*from ww w.j a va 2 s .co m*/ lockLevelCheckOutButton.setSelection(false); lockLevelCheckInButton.setSelection(false); lockLevelUnchangedButton.setSelection(true); } notifyButton.setSelection(MessageDialogWithToggle.ALWAYS .equals(store.getString(UIPreferenceConstants.HIDE_ALL_FILES_UP_TO_DATE_MESSAGE))); checkinMessageButton.setSelection(!MessageDialogWithToggle.ALWAYS .equals(store.getString(UIPreferenceConstants.PROMPT_BEFORE_CHECKIN))); checkoutBackgroundButton.setSelection(!store.getBoolean(UIPreferenceConstants.CHECKOUT_FOREGROUND) && !store.getBoolean(UIPreferenceConstants.CHECKOUT_SYNCHRONOUS) && !store.getBoolean(UIPreferenceConstants.PROMPT_BEFORE_CHECKOUT)); checkoutForegroundButton.setSelection(store.getBoolean(UIPreferenceConstants.CHECKOUT_FOREGROUND)); checkoutPromptButton.setSelection(store.getBoolean(UIPreferenceConstants.PROMPT_BEFORE_CHECKOUT)); }
From source file:com.microsoft.tfs.client.common.ui.tasks.vc.RollbackTask.java
License:Open Source License
public RollbackTask(final Shell shell, final TFSRepository repository, final String itemPath, final VersionSpec versionFrom, final VersionSpec versionTo) { super(shell); showDialog = true;/*from w ww. j av a2s . c om*/ Check.notNull(repository, "repository"); //$NON-NLS-1$ this.repository = repository; this.itemPath = itemPath; this.versionFrom = versionFrom; this.versionTo = versionTo; rollbackOptions = RollbackOptions.NONE; rollbackOptions = rollbackOptions.combine(RollbackOptions.KEEP_MERGE_HISTORY); final IPreferenceStore preferences = TFSCommonUIClientPlugin.getDefault().getPreferenceStore(); if (!preferences.getBoolean(UIPreferenceConstants.AUTO_RESOLVE_CONFLICTS)) { rollbackOptions = rollbackOptions.combine(RollbackOptions.NO_AUTO_RESOLVE); } }
From source file:com.microsoft.tfs.client.common.ui.teambuild.buildstatus.BuildStatusAlerter.java
License:Open Source License
private boolean getPreference(final String preferenceKey) { final IPreferenceStore prefs = TFSCommonUIClientPlugin.getDefault().getPreferenceStore(); if (prefs.contains(preferenceKey)) { return prefs.getBoolean(preferenceKey); } else {//from w ww. j a v a2 s . co m return prefs.getDefaultBoolean(preferenceKey); } }
From source file:com.microsoft.tfs.client.common.ui.teambuild.prefs.BuildNotificationPreferencePage.java
License:Open Source License
private void initializeValues() { /*// w w w . j a va2 s . c om * Note: The interval preference is from the non-UI common client * plug-in because BuildStatusManager is in that plug-in and uses the * pref directly. * * TODO Use a non-deprecated method to access the preferences in the * non-UI common client plug-in or refactor TFSServer and * BuildStatusManager not to use a pref (pass in the value). */ final Preferences nonUIPrefs = TFSCommonClientPlugin.getDefault().getPluginPreferences(); int refreshIntervalMillis = nonUIPrefs.getInt(PreferenceConstants.BUILD_STATUS_REFRESH_INTERVAL); if (refreshIntervalMillis <= 0) { refreshIntervalMillis = nonUIPrefs.getDefaultInt(PreferenceConstants.BUILD_STATUS_REFRESH_INTERVAL); } int refreshIntervalMins = 0; if (refreshIntervalMillis > 0) { refreshIntervalMins = refreshIntervalMillis / (60 * 1000); } if (refreshIntervalMins <= 0) { refreshIntervalMins = 5; } refreshTimeText.setText(Integer.toString(refreshIntervalMins)); /* * These prefs are in the UI client with most other prefs. */ final IPreferenceStore uiPrefs = TFSCommonUIClientPlugin.getDefault().getPreferenceStore(); final boolean notifySuccess = uiPrefs.contains(UIPreferenceConstants.BUILD_NOTIFICATION_SUCCESS) ? uiPrefs.getBoolean(UIPreferenceConstants.BUILD_NOTIFICATION_SUCCESS) : uiPrefs.getDefaultBoolean(UIPreferenceConstants.BUILD_NOTIFICATION_SUCCESS); final boolean notifyPartiallySucceeded = uiPrefs .contains(UIPreferenceConstants.BUILD_NOTIFICATION_PARTIALLY_SUCCEEDED) ? uiPrefs.getBoolean(UIPreferenceConstants.BUILD_NOTIFICATION_PARTIALLY_SUCCEEDED) : uiPrefs.getDefaultBoolean(UIPreferenceConstants.BUILD_NOTIFICATION_PARTIALLY_SUCCEEDED); final boolean notifyFailure = uiPrefs.contains(UIPreferenceConstants.BUILD_NOTIFICATION_FAILURE) ? uiPrefs.getBoolean(UIPreferenceConstants.BUILD_NOTIFICATION_FAILURE) : uiPrefs.getDefaultBoolean(UIPreferenceConstants.BUILD_NOTIFICATION_FAILURE); notifyBuildSuccessButton.setSelection(notifySuccess); notifyBuildPartiallySucceededButton.setSelection(notifyPartiallySucceeded); notifyBuildFailureButton.setSelection(notifyFailure); }