org.eclipse.ui.services.ISourceProviderService#org.osgi.service.prefs.BackingStoreException源码实例Demo

下面列出了org.eclipse.ui.services.ISourceProviderService#org.osgi.service.prefs.BackingStoreException 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: sarl   文件: IssueInformationPage.java
/** Invoked when the wizard is closed with the "Finish" button.
 *
 * @return {@code true} for closing the wizard; {@code false} for keeping it open.
 */
public boolean performFinish() {
	final IEclipsePreferences prefs = SARLEclipsePlugin.getDefault().getPreferences();
	final String login = this.trackerLogin.getText();
	if (Strings.isEmpty(login)) {
		prefs.remove(PREFERENCE_LOGIN);
	} else {
		prefs.put(PREFERENCE_LOGIN, login);
	}
	try {
		prefs.sync();
		return true;
	} catch (BackingStoreException e) {
		ErrorDialog.openError(getShell(), e.getLocalizedMessage(), e.getLocalizedMessage(),
				SARLEclipsePlugin.getDefault().createStatus(IStatus.ERROR, e));
		return false;
	}
}
 
public static String getStartupUrl(Shell shell, IProject project,
    Map<String, Set<String>> hostPagesByModule, boolean isExternal) {
  LegacyGWTHostPageSelectionDialog dialog = new LegacyGWTHostPageSelectionDialog(
      shell, project, hostPagesByModule, isExternal);

  if (dialog.open() == Window.OK) {
    try {
      WebAppProjectProperties.setLaunchConfigExternalUrlPrefix(project,
          dialog.getExternalUrlPrefix());
    } catch (BackingStoreException e) {
      GWTPluginLog.logError(e);
    }
    return dialog.getUrl();
  }

  // User clicked Cancel
  return null;
}
 
源代码3 项目: gwt-eclipse-plugin   文件: ProjectUtilities.java
/**
 * Creates a populated project via the {@link IWebAppProjectCreator}.
 *
 * @throws FileNotFoundException
 * @throws UnsupportedEncodingException
 * @throws MalformedURLException
 * @throws BackingStoreException
 * @throws ClassNotFoundException
 * @throws SdkException
 * @throws CoreException
 * @throws IOException
 */
public static IProject createPopulatedProject(String projectName,
    IWebAppProjectCreator.Participant... creationParticipants) throws MalformedURLException,
    ClassNotFoundException, UnsupportedEncodingException, FileNotFoundException, CoreException,
    SdkException, BackingStoreException, IOException {

  IWebAppProjectCreator projectCreator = ProjectUtilities.createWebAppProjectCreator();
  projectCreator.setProjectName(projectName);
  projectCreator.setPackageName(projectName.toLowerCase());

  for (IWebAppProjectCreator.Participant participant : creationParticipants) {
    participant.updateWebAppProjectCreator(projectCreator);
  }

  projectCreator.create(new NullProgressMonitor());

  return ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
}
 
/**
 * This method removes the spaces for tabs and tab width preferences from the default scope of the plugin preference
 * store.
 */
protected void removePluginDefaults()
{
	IEclipsePreferences store = getDefaultPluginPreferenceStore();
	if (store == null)
	{
		return;
	}

	store.remove(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS);
	store.remove(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH);
	try
	{
		store.flush();
	}
	catch (BackingStoreException e)
	{
		IdeLog.logError(CommonEditorPlugin.getDefault(), e);
	}
}
 
源代码5 项目: APICloud-Studio   文件: UserAgentManager.java
public void clearPreferences(IProject project)
{
	if (project != null)
	{
		// Save to the project scope
		IEclipsePreferences preferences = new ProjectScope(project).getNode(CommonEditorPlugin.PLUGIN_ID);
		preferences.remove(IPreferenceConstants.USER_AGENT_PREFERENCE);
		try
		{
			preferences.flush();
		}
		catch (BackingStoreException e)
		{
			// ignore
		}
	}
}
 
public IEclipsePreferences preApply(IEclipsePreferences node) {
	// the node does not need to be the root of the hierarchy
	Preferences root = node.node("/"); //$NON-NLS-1$
	try {
		// we must not create empty preference nodes, so first check if the node exists
		if (root.nodeExists(InstanceScope.SCOPE)) {
			Preferences instance = root.node(InstanceScope.SCOPE);
			// we must not create empty preference nodes, so first check if the node exists
			if (instance.nodeExists(JavaCore.PLUGIN_ID)) {
				cleanJavaCore(instance.node(JavaCore.PLUGIN_ID));
			}
		}
	} catch (BackingStoreException e) {
		// do nothing
	}
	return super.preApply(node);
}
 
public boolean performOk() {
	MergeFileAssociation[] currentAssociations = getMergeFileAssociations();
	for (int i = 0; i < currentAssociations.length; i++) {
		currentAssociations[i].remove();
	}
	for (int i = 0; i < mergeFileAssociations.length; i++) {
		Preferences prefs = MergeFileAssociation.getParentPreferences().node(mergeFileAssociations[i].getFileType());
		if (mergeFileAssociations[i].getMergeProgram() == null) prefs.put("mergeProgram", ""); //$NON-NLS-1$ //$NON-NLS-1$ //$NON-NLS-2$
		else prefs.put("mergeProgram", mergeFileAssociations[i].getMergeProgram()); //$NON-NLS-1$
		if (mergeFileAssociations[i].getParameters() == null)prefs.put("parameters", ""); //$NON-NLS-1$ //$NON-NLS-1$ //$NON-NLS-2$ 
		else prefs.put("parameters", mergeFileAssociations[i].getParameters()); //$NON-NLS-1$
		prefs.putInt("type", mergeFileAssociations[i].getType()); //$NON-NLS-1$
		try {
			prefs.flush();
		} catch (BackingStoreException e) {}
	}
	return super.performOk();
}
 
源代码8 项目: CogniCrypt   文件: Ruleset.java
public Ruleset(Preferences subPrefs) throws BackingStoreException {
	String[] keys = subPrefs.keys();
	for (String key : keys) {
		switch (key) {
			case "SelectedVersion":
				this.selectedVersion = subPrefs.get(key, "");
				break;
			case "CheckboxState":
				this.isChecked = subPrefs.getBoolean(key, false);
				break;
			case "FolderName":
				this.folderName = subPrefs.get(key, "");
				break;
			case "Url":
				this.url = subPrefs.get(key, "");
				break;
			default:
				break;
		}
	}
}
 
/**
 * Updates the persistent configuration.
 * @param config The new configuration to be saved.
 */
@Override
public void update(Map<ConfigTypes, String> config) {
    ConfigLogger configLogger = new ConfigLogger("Updated Project configuration with the following:");
    for (Map.Entry<ConfigTypes, String> entry : config.entrySet())
    {    
        preferences.put(entry.getKey().toString(), entry.getValue());
        this.config.put(entry.getKey(), entry.getValue());
        configLogger.append(entry);
    }
    configLogger.log();
    try {
        preferences.flush();
    } catch (BackingStoreException e) {
        Logger.log(IStatus.ERROR, e.getMessage());
        e.printStackTrace();
    }
    notifyListeners(config);
}
 
源代码10 项目: APICloud-Studio   文件: EclipseUtil.java
/**
 * Migrate the existing preferences from instance scope to configuration scope and then remove the preference key
 * from the instance scope.
 */
public static void migratePreference(String pluginId, String preferenceKey)
{
	IEclipsePreferences configNode = EclipseUtil.configurationScope().getNode(pluginId);
	if (StringUtil.isEmpty(configNode.get(preferenceKey, null))) // no value in config scope
	{
		IEclipsePreferences instanceNode = EclipseUtil.instanceScope().getNode(pluginId);
		String instancePrefValue = instanceNode.get(preferenceKey, null);
		if (!StringUtil.isEmpty(instancePrefValue))
		{
			// only migrate if there is a value!
			configNode.put(preferenceKey, instancePrefValue);
			instanceNode.remove(preferenceKey);
			try
			{
				configNode.flush();
				instanceNode.flush();
			}
			catch (BackingStoreException e)
			{
				IdeLog.logWarning(CorePlugin.getDefault(), e.getMessage(), e);
			}
		}
	}
}
 
源代码11 项目: APICloud-Studio   文件: ThemeManager.java
/**
 * Set the FG, BG, selection and current line colors on our editors.
 * 
 * @param theme
 */
private void setAptanaEditorColorsToMatchTheme(Theme theme)
{
	IEclipsePreferences prefs = EclipseUtil.instanceScope().getNode("com.aptana.editor.common"); //$NON-NLS-1$
	prefs.putBoolean(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT, false);
	prefs.put(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND, toString(theme.getForeground()));

	prefs.putBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, false);
	prefs.put(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND, toString(theme.getBackground()));

	prefs.putBoolean(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT, false);
	prefs.put(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND, toString(theme.getForeground()));

	prefs.put(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR,
			toString(theme.getLineHighlightAgainstBG()));
	try
	{
		prefs.flush();
	}
	catch (BackingStoreException e)
	{
		IdeLog.logError(ThemePlugin.getDefault(), e);
	}
}
 
private void updatePreferences(IEclipsePreferences preferences) {

	 	IEclipsePreferences oldPreferences = loadPreferences();
	 	if (oldPreferences != null) {
			try {
		 		String[] propertyNames = oldPreferences.childrenNames();
				for (int i = 0; i < propertyNames.length; i++){
					String propertyName = propertyNames[i];
				    String propertyValue = oldPreferences.get(propertyName, ""); //$NON-NLS-1$
				    if (!"".equals(propertyValue)) { //$NON-NLS-1$
					    preferences.put(propertyName, propertyValue);
				    }
				}
				// save immediately new preferences
				preferences.flush();
			} catch (BackingStoreException e) {
				// fails silently
			}
		}
	 }
 
源代码13 项目: eclipse   文件: BazelClasspathContainer.java
private boolean isSourcePath(String path) throws JavaModelException, BackingStoreException {
  Path pp = new File(instance.getWorkspaceRoot().toString() + File.separator + path).toPath();
  IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
  for (IClasspathEntry entry : project.getRawClasspath()) {
    if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
      IResource res = root.findMember(entry.getPath());
      if (res != null) {
        String file = res.getLocation().toOSString();
        if (!file.isEmpty() && pp.startsWith(file)) {
          IPath[] inclusionPatterns = entry.getInclusionPatterns();
          if (!matchPatterns(pp, entry.getExclusionPatterns()) && (inclusionPatterns == null
              || inclusionPatterns.length == 0 || matchPatterns(pp, inclusionPatterns))) {
            return true;
          }
        }
      }
    }
  }
  return false;
}
 
源代码14 项目: gwt-eclipse-plugin   文件: GWTProjectProperties.java
public static void setFileNamesCopiedToWebInfLib(IProject project,
    List<String> fileNamesCopiedToWebInfLib) throws BackingStoreException {
  IEclipsePreferences prefs = getProjectProperties(project);
  StringBuilder sb = new StringBuilder();
  boolean addPipe = false;
  for (String fileNameCopiedToWebInfLib : fileNamesCopiedToWebInfLib) {
    if (addPipe) {
      sb.append("|");
    } else {
      addPipe = true;
    }

    sb.append(fileNameCopiedToWebInfLib);
  }

  prefs.put(FILES_COPIED_TO_WEB_INF_LIB, sb.toString());
  prefs.flush();
}
 
源代码15 项目: CodeCheckerEclipsePlugin   文件: CcConfiguration.java
/**
 * Loads project level preferences from disk.
 */
@Override
public void load() {
    validate();
    config = new HashMap<>();
    try {
        for (String configKey : preferences.keys()) {
            ConfigTypes ct = ConfigTypes.getFromString(configKey);
            if (ct != null) {
                if (ConfigTypes.COMMON_TYPE.contains(ct)) {
                    config.put((ConfigTypes)ct, preferences.get(configKey, STR_EMPTY));
                }
            }
        }
    } catch (BackingStoreException e) {
        e.printStackTrace();
    }
}
 
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
	if (monitor.isCanceled()) {
		return Status.CANCEL_STATUS;
	}
	monitor.beginTask(NLS.bind(TypeScriptCoreMessages.SaveProjectPreferencesJob_taskName, project.getName()), 1);

	try {
		preferences.flush();
	} catch (BackingStoreException e) {
		IStatus status = new Status(Status.ERROR, TypeScriptCorePlugin.PLUGIN_ID,
				"Error while saving  project preferences", e);
		throw new CoreException(status);
	}

	monitor.worked(1);
	monitor.done();

	return Status.OK_STATUS;
}
 
源代码17 项目: APICloud-Studio   文件: UIPlugin.java
private void updateInitialPerspectiveVersion()
{
	// updates the initial stored version so that user won't get a prompt on a new workspace
	boolean hasStartedBefore = Platform.getPreferencesService().getBoolean(PLUGIN_ID,
			IPreferenceConstants.IDE_HAS_LAUNCHED_BEFORE, false, null);
	if (!hasStartedBefore)
	{
		IEclipsePreferences prefs = (EclipseUtil.instanceScope()).getNode(PLUGIN_ID);
		prefs.putInt(IPreferenceConstants.PERSPECTIVE_VERSION, WebPerspectiveFactory.VERSION);
		prefs.putBoolean(IPreferenceConstants.IDE_HAS_LAUNCHED_BEFORE, true);
		try
		{
			prefs.flush();
		}
		catch (BackingStoreException e)
		{
			IdeLog.logError(getDefault(), Messages.UIPlugin_ERR_FailToSetPref, e);
		}
	}
}
 
源代码18 项目: xtext-xtend   文件: AbstractProfileManager.java
/**
 * @param uiPrefs
 * @param allOptions
 */
private void addAll(IEclipsePreferences uiPrefs, Map allOptions) {
	try {
		String[] keys = uiPrefs.keys();
		for (int i = 0; i < keys.length; i++) {
			String key = keys[i];
			String val = uiPrefs.get(key, null);
			if (val != null) {
				allOptions.put(key, val);
			}
		}
	} catch (BackingStoreException e) {
		// ignore
	}

}
 
@Override
protected void performDefaults()
{
	IEclipsePreferences store = getPluginPreferenceStore();

	store.remove(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS);
	store.remove(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH);

	setPluginDefaults();
	setTabSpaceCombo();
	super.performDefaults();
	try
	{
		store.flush();
	}
	catch (BackingStoreException e)
	{
		IdeLog.logError(CommonEditorPlugin.getDefault(), e);
	}
}
 
源代码20 项目: hybris-commerce-eclipse-plugin   文件: Activator.java
public void resetPlatform(String platformHome) {
	
	try {
		Preferences preferences = InstanceScope.INSTANCE.getNode("com.hybris.hyeclipse.preferences");
		preferences.put("platform_home", platformHome);
		preferences.flush();
	}
	catch (BackingStoreException e) {
		logError("Failed to persist platform_home", e);
	}
	
	getTypeSystemExporter().setPlatformHome(null);
	getTypeSystemExporter().nullifySystemConfig();
	getTypeSystemExporter().nullifyPlatformConfig();
	getTypeSystemExporter().nullifyTypeSystem();
	getTypeSystemExporter().nullifyAllTypes();
	getTypeSystemExporter().nullifyAllTypeNames();
}
 
源代码21 项目: n4js   文件: WorkingSetManagerBrokerImpl.java
/**
 * (non-API)
 *
 * <p>
 * Resets the actual and the persistent state of the current broker instance and of all available working set
 * managers. This method does not remove any registered listeners. Also refreshes the common navigator view.
 *
 * <p>
 * This method is exposed only for testing and recovery purposes. It is highly discouraged to invoke from production
 * code.
 */
@VisibleForTesting
public void resetState() {

	for (final Resetable resetable : from(getWorkingSetManagers()).filter(Resetable.class)) {
		resetable.reset();
	}

	try {
		getPreferences().clear();
		getPreferences().flush();
		workingSetTopLevel.set(false);
		for (final TopLevelElementChangedListener listener : topLevelElementChangeListeners) {
			listener.topLevelElementChanged(workingSetTopLevel.get());
		}
		final Collection<WorkingSetManager> managers = getWorkingSetManagers();
		if (!managers.isEmpty()) {
			activeWorkingSetManager.set(managers.iterator().next());
		} else {
			activeWorkingSetManager.set(null);
		}

		refreshNavigator(true);
	} catch (final BackingStoreException e) {
		LOGGER.error("Error occurred while reseting persisted the state.", e);
	}

}
 
private void removeFacet(IProject project) throws CoreException {
  GWTProjectPropertyPage projectProperty = new GWTProjectPropertyPage();
  try {
    projectProperty.removeGWTSdkForFacet(project);
  } catch (BackingStoreException e) {
    GwtWtpPlugin.logError("Could not uinstall the GWT facet.", e);
  }
}
 
private static void savePreferences(final IScopeContext context) throws BackingStoreException {
	try {
		context.getNode(JavaUI.ID_PLUGIN).flush();
	} finally {
		context.getNode(JavaCore.PLUGIN_ID).flush();
	}
}
 
源代码24 项目: xds-ide   文件: PreferenceCommons.java
/**
 * TODO : implement better architecture for storing preferences.
 * 
 * @param scope
 * @param qualifier
 * @see org.osgi.service.prefs.Preferences#flush
 */
public static void flush(IScopeContext scope, String qualifier) {
	try {
           IEclipsePreferences node = scope.getNode(qualifier);
           node.flush();
       } catch (BackingStoreException e) {
           LogHelper.logError(e);
       }
}
 
源代码25 项目: gwt-eclipse-plugin   文件: GWTPreferences.java
/**
 * Sets the port number to use for the SourceViewerServer.
 *
 * @param port the port number to save
 */
public static void setSourceViewerServerPort(int port) {
  IEclipsePreferences workspacePreferences = getEclipsePreferences();
  workspacePreferences.putInt(SOURCE_VIEWER_SERVER_PORT, port);
  try {
    workspacePreferences.flush();
  } catch (BackingStoreException e) {
    CorePluginLog.logError(e);
  }
}
 
/**
 * Flushes the instance scope of this plug-in.
 * 
 * @since 3.7
 */
public static void flushInstanceScope() {
	try {
		InstanceScope.INSTANCE.getNode(JavaUI.ID_PLUGIN).flush();
	} catch (BackingStoreException e) {
		log(e);
	}
}
 
源代码27 项目: tm4e   文件: ThemeContribution.java
private Action createAction(final String scopeName, final ITheme theme, boolean whenDark) {
	return new Action(theme.getName()) {
		@Override
		public void run() {
			IThemeManager manager = TMUIPlugin.getThemeManager();
			IThemeAssociation association = new ThemeAssociation(theme.getId(), scopeName, whenDark);
			manager.registerThemeAssociation(association);
			try {
				manager.save();
			} catch (BackingStoreException e) {
				e.printStackTrace();
			}
		}
	};
}
 
源代码28 项目: goclipse   文件: PreferenceHelper.java
protected void flush(IProject project) throws CommonException {
	try {
		getProjectNode(project).flush();
	} catch(BackingStoreException e) {
		throwCommonException(e);
	}
}
 
源代码29 项目: eclipse   文件: BazelProjectSupport.java
/**
 * List of build flags for <code>project</code>, taken from the project configuration
 */
public static List<String> getBuildFlags(IProject project) throws BackingStoreException {
  // Get the list of targets from the preferences
  IScopeContext projectScope = new ProjectScope(project);
  Preferences projectNode = projectScope.getNode(Activator.PLUGIN_ID);
  ImmutableList.Builder<String> builder = ImmutableList.builder();
  for (String s : projectNode.keys()) {
    if (s.startsWith("buildArgs")) {
      builder.add(projectNode.get(s, ""));
    }
  }
  return builder.build();
}
 
源代码30 项目: eclipse   文件: BazelProjectSupport.java
/**
 * Return the {@link BazelInstance} corresponding to the given <code>project</code>. It looks for
 * the instance that runs for the workspace root configured for that project.
 *
 * @throws BazelNotFoundException
 */
public static BazelCommand.BazelInstance getBazelCommandInstance(IProject project)
    throws BackingStoreException, IOException, InterruptedException, BazelNotFoundException {
  IScopeContext projectScope = new ProjectScope(project.getProject());
  Preferences projectNode = projectScope.getNode(Activator.PLUGIN_ID);
  File workspaceRoot =
      new File(projectNode.get("workspaceRoot", project.getLocation().toFile().toString()));
  return Activator.getDefault().getCommand().getInstance(workspaceRoot);
}