Java Code Examples for org.osgi.service.prefs.BackingStoreException

The following are top voted examples for showing how to use org.osgi.service.prefs.BackingStoreException. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: n4js   File: ProjectNameFilterAwareWorkingSetManager.java   Source Code and License 6 votes vote down vote up
@Override
public IStatus saveState(final IProgressMonitor monitor) {
	final IStatus superSaveResult = super.saveState(monitor);

	if (superSaveResult.isOK()) {

		final Preferences node = getPreferences();
		node.put(ORDERED_FILTERS_KEY, Joiner.on(SEPARATOR).join(orderedWorkingSetFilters));

		try {
			node.flush();
		} catch (final BackingStoreException e) {
			final String message = "Error occurred while saving state to preference store.";
			LOGGER.error(message, e);
			return statusHelper.createError(message, e);
		}

		return statusHelper.OK();
	}

	return superSaveResult;
}
 
Example 2
Project: n4js   File: WorkingSetManagerImpl.java   Source Code and License 6 votes vote down vote up
@Override
public IStatus saveState(final IProgressMonitor monitor) {

	final Preferences node = getPreferences();

	// Save ordered labels.
	node.put(ORDERED_IDS_KEY, Joiner.on(SEPARATOR).join(orderedWorkingSetIds));

	// Save visible labels.
	node.put(VISIBLE_IDS_KEY, Joiner.on(SEPARATOR).join(visibleWorkingSetIds));

	try {
		node.flush();
	} catch (final BackingStoreException e) {
		final String message = "Error occurred while saving state to preference store.";
		LOGGER.error(message, e);
		return statusHelper.createError(message, e);
	}

	return statusHelper.OK();
}
 
Example 3
Project: n4js   File: WorkingSetManagerBrokerImpl.java   Source Code and License 6 votes vote down vote up
private IStatus saveState() {

		final Preferences node = getPreferences();
		// Top level element.
		node.putBoolean(IS_WORKINGSET_TOP_LEVEL_KEY, workingSetTopLevel.get());

		// Active working set manager.
		final WorkingSetManager activeManager = getActiveManager();
		final String activeId = activeManager == null ? null : activeManager.getId();
		node.put(ACTIVE_MANAGER_KEY, Strings.nullToEmpty(activeId));

		try {
			node.flush();
			return OK_STATUS;
		} catch (final BackingStoreException e) {
			final String message = "Unexpected error when trying to persist working set broker state.";
			LOGGER.error(message, e);
			return statusHelper.createError(message, e);
		}
	}
 
Example 4
Project: n4js   File: OsgiBinariesPreferenceStore.java   Source Code and License 6 votes vote down vote up
@Override
public IStatus save() {
	try {
		final IEclipsePreferences node = InstanceScope.INSTANCE.getNode(QUALIFIER);
		for (final Entry<Binary, URI> entry : getOrCreateState().entrySet()) {
			final URI path = entry.getValue();
			if (null != path) {
				final File file = new File(path);
				if (file.isDirectory()) {
					node.put(entry.getKey().getId(), file.getAbsolutePath());
				}
			} else {
				// Set to default.
				node.put(entry.getKey().getId(), "");
			}
		}
		node.flush();
		return OK_STATUS;
	} catch (final BackingStoreException e) {
		final String message = "Unexpected error when trying to persist binary preferences.";
		LOGGER.error(message, e);
		return statusHelper.createError(message, e);
	}
}
 
Example 5
Project: EclipseMinifyBuilder   File: PrefsAccess.java   Source Code and License 6 votes vote down vote up
/**
 * Remove a resource (i.e. all its properties) from the builder's preferences.
 * 
 * @param prefs the preferences
 * @param resource the resource
 * @throws BackingStoreException
 */
public static void removeResource(Preferences prefs, IResource resource) 
		throws CoreException {
	try {
		String[] keys = prefs.keys();
		for (String key: keys) {
			if (key.endsWith("//" + resource.getProjectRelativePath().toPortableString())) {
				prefs.remove(key);
			}
		}
		prefs.flush();
	} catch (BackingStoreException e) {
		throw new CoreException(new Status(
				IStatus.ERROR, MinifyBuilder.BUILDER_ID, e.getMessage(), e));
	}
}
 
Example 6
Project: EclipseMinifyBuilder   File: PrefsAccess.java   Source Code and License 6 votes vote down vote up
/**
 * Associate one resource's properties with another resource.
 * 
 * @param fromPrefs the preferences to take the properties from
 * @param fromResource the resource to take the properties from
 * @param toPrefs the preferences to move the properties to
 * @param toResource the resource to associated with the properties
 * @throws BackingStoreException
 */
public static void moveResource(Preferences fromPrefs, IResource fromResource,
		Preferences toPrefs, IResource toResource) 
		throws CoreException {
	try {
		String[] keys = fromPrefs.keys();
		for (String key: keys) {
			if (key.endsWith("//" + fromResource.getProjectRelativePath().toPortableString())) {
				String resourcePreference = key.substring(0, key.indexOf('/'));
				toPrefs.put(preferenceKey(toResource, resourcePreference), fromPrefs.get(key, ""));
				fromPrefs.remove(key);
			}
		}
		fromPrefs.flush();
		toPrefs.flush();
	} catch (BackingStoreException e) {
		throw new CoreException(new Status(
				IStatus.ERROR, MinifyBuilder.BUILDER_ID, e.getMessage(), e));
	}
}
 
Example 7
Project: EclipseMinifyBuilder   File: MinifyPropertyPage.java   Source Code and License 6 votes vote down vote up
public boolean performOk() {
	try {
		Preferences prefs = builderPreferences();
		if (!performSpecificOk(prefs)) {
			return false;
		}
	    for (int i = 0; i < options()[0].length; i++) {
	    	if (selection.getText().equals(options()[1][i])) {
				prefs.put(preferenceKey(MinifyBuilder.MINIFIER), options()[0][i]);
	    	}
	    }
	    if (prefs.get(preferenceKey(
	    		MinifyBuilder.MINIFIER), MinifyBuilder.DONT_MINIFY)
	    		.equals(MinifyBuilder.DONT_MINIFY)) {
	    	PrefsAccess.removeResource(prefs, (IResource)getElement());
	    }
		prefs.flush();
		((IResource)getElement()).touch(null);
	} catch (CoreException | BackingStoreException e) {
		return false;
	}
	return true;
}
 
Example 8
Project: pgcodekeeper   File: EclipseEnvironment.java   Source Code and License 6 votes vote down vote up
private void initVisits() {
    String currentTime = String.valueOf(System.currentTimeMillis());
    this.currentVisit = currentTime;
    this.firstVisit = preferences.get(USAGE_REPORT_PREF.FIRST_VISIT, null);
    if (firstVisit == null) {
        this.firstVisit = currentTime;
        preferences.put(USAGE_REPORT_PREF.FIRST_VISIT, firstVisit);
    }
    lastVisit = preferences.get(USAGE_REPORT_PREF.LAST_VISIT, currentTime);
    visitCount = preferences.getLong(USAGE_REPORT_PREF.VISIT_COUNT, 1);

    preferences.put(USAGE_REPORT_PREF.LAST_VISIT, currentTime);
    preferences.putLong(USAGE_REPORT_PREF.VISIT_COUNT, visitCount+1);
    try {
        preferences.flush();
    } catch (BackingStoreException e) {
        Log.log(Log.LOG_ERROR, Messages.EclipseEnvironment_Error_SavePreferences, e);
    }
}
 
Example 9
Project: com.onpositive.prefeditor   File: PlatformPreferenceProvider.java   Source Code and License 6 votes vote down vote up
protected void loadPrefsFromNode(Preferences preferences) {
	try {
		String[] keys = preferences.keys();
		if (keys.length <= 0) {
			return;
		}
		List<KeyValue> preferenceList = preferenceEntries.get(preferences.absolutePath());
		if (null == preferenceList) {
			preferenceList = new ArrayList<>();
			preferenceEntries.put(preferences.absolutePath(), preferenceList);
		}
		for (String key : keys) {
			String value = preferences.get(key, "*default*");
			KeyValue current = new KeyValue(preferences.absolutePath(), key, value);
			preferenceList.add(current);
		}
	} catch (org.osgi.service.prefs.BackingStoreException e) {
		PrefEditorPlugin.log(e);
	}
}
 
Example 10
Project: tm4e   File: ThemeManager.java   Source Code and License 6 votes vote down vote up
@Override
public void save() throws BackingStoreException {
	// Save Themes in the
	// "${workspace_loc}/metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.tm4e.ui.prefs"
	String json = PreferenceHelper.toJsonThemes(
			Arrays.stream(getThemes()).filter(t -> t.getPluginId() == null).collect(Collectors.toList()));
	IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(TMUIPlugin.PLUGIN_ID);
	prefs.put(PreferenceConstants.THEMES, json);

	// Save Theme associations in the
	// "${workspace_loc}/metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.tm4e.ui.prefs"
	json = PreferenceHelper.toJsonThemeAssociations(Arrays.stream(getAllThemeAssociations())
			.filter(t -> t.getPluginId() == null).collect(Collectors.toList()));
	prefs.put(PreferenceConstants.THEME_ASSOCIATIONS, json);

	// Save preferences
	prefs.flush();
}
 
Example 11
Project: eclipse-asciidoctools   File: AsciidocConfiguration.java   Source Code and License 6 votes vote down vote up
private static boolean updateConfigurationFromSettings(AsciidocConfiguration configuration, IProject project) {
	final IScopeContext projectScope = new ProjectScope(project);
	IEclipsePreferences preferences = projectScope.getNode(Activator.PLUGIN_ID);
	try {
		createSettings(project, BACKEND_DEFAULT, RESOURCESPATH_DEFAULT, SOURCESPATH_DEFAULT, STYLESHEETPATH_DEFAULT, TARGETPATH_DEFAULT);
		configuration.setBackend(preferences.get(BACKEND_PROPERTY, BACKEND_DEFAULT));
		configuration.setResourcesPath(preferences.get(RESOURCESPATH_PROPERTY, RESOURCESPATH_DEFAULT));
		configuration.setSourcesPath(preferences.get(SOURCESPATH_PROPERTY, SOURCESPATH_DEFAULT));
		configuration.setStylesheetPath(preferences.get(STYLESHEETPATH_PROPERTY, STYLESHEETPATH_DEFAULT));
		configuration.setTargetPath(preferences.get(TARGETPATH_PROPERTY, TARGETPATH_DEFAULT));
	} catch (BackingStoreException e) {
		Activator.getDefault().getLog().log(new Status(IStatus.WARNING, Activator.PLUGIN_ID, e.getMessage(), e));
		return false;
	}
	configuration.source = AsciidocConfigurationSource.SETTINGS;
	return true;
}
 
Example 12
Project: eclipse   File: BazelProjectSupport.java   Source Code and License 6 votes vote down vote up
private static void addSettings(IProject project, String workspaceRoot, List<String> targets,
    List<String> buildFlags) throws BackingStoreException {
  IScopeContext projectScope = new ProjectScope(project);
  Preferences projectNode = projectScope.getNode(Activator.PLUGIN_ID);
  int i = 0;
  for (String target : targets) {
    projectNode.put("target" + i, target);
    i++;
  }
  projectNode.put("workspaceRoot", workspaceRoot);
  i = 0;
  for (String flag : buildFlags) {
    projectNode.put("buildFlag" + i, flag);
    i++;
  }
  projectNode.flush();
}
 
Example 13
Project: eclipse   File: BazelClasspathContainer.java   Source Code and License 6 votes vote down vote up
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;
}
 
Example 14
Project: team-explorer-everywhere   File: ViewState.java   Source Code and License 6 votes vote down vote up
public boolean persistList(final List list, final String key, final Class itemType) {
    try {
        if (currentNode.nodeExists(key)) {
            currentNode.node(key).removeNode();
        }

        final Preferences listNode = currentNode.node(key);
        final ObjectSerializer serializer = getObjectSerializer(itemType);

        for (int i = 0; i < list.size(); i++) {
            final String objString = serializer.toString(list.get(i));
            listNode.put(String.valueOf(i), objString);
        }

        return true;
    } catch (final BackingStoreException ex) {
        return false;
    }
}
 
Example 15
Project: team-explorer-everywhere   File: ViewState.java   Source Code and License 6 votes vote down vote up
public List restoreList(final String key, final Class itemType) {
    try {
        if (!currentNode.nodeExists(key)) {
            return null;
        }

        final List results = new ArrayList();
        final Preferences listNode = currentNode.node(key);
        final String[] keys = listNode.keys();
        Arrays.sort(keys);
        final ObjectSerializer serializer = getObjectSerializer(itemType);

        for (int i = 0; i < keys.length; i++) {
            final String currentKey = listNode.get(keys[i], null);
            final Object object = serializer.fromString(currentKey);
            if (object != null) {
                results.add(object);
            }
        }

        return results;
    } catch (final BackingStoreException ex) {
        return null;
    }
}
 
Example 16
Project: team-explorer-everywhere   File: TableColumnWidthsPersistence.java   Source Code and License 6 votes vote down vote up
/**
 * Persists table column widths. Users of this class should have already
 * added some mappings before calling this method.
 */
public void persist() {
    final Preferences node = getPreferencesNode(key);

    for (final Iterator it = mappings.keySet().iterator(); it.hasNext();) {
        final String columnKey = (String) it.next();
        final int ix = getIndexForKey(columnKey);
        if (ix == -1) {
            continue;
        }
        final int width = tableColumnWidths[ix];
        if (width > 0) {
            node.putInt(columnKey, width);
        }
    }

    try {
        node.flush();
    } catch (final BackingStoreException e) {
        log.warn("can't flush prefs node", e); //$NON-NLS-1$
        return;
    }
}
 
Example 17
Project: subclipse   File: SVNUIPlugin.java   Source Code and License 6 votes vote down vote up
public MergeFileAssociation[] getMergeFileAssociations() throws BackingStoreException {
	ArrayList associations = new ArrayList();
	String[] childrenNames = MergeFileAssociation.getParentPreferences().childrenNames();
	for (int i = 0; i < childrenNames.length; i++) {
		org.osgi.service.prefs.Preferences node = MergeFileAssociation.getParentPreferences().node(childrenNames[i]);
		MergeFileAssociation association = new MergeFileAssociation();
		association.setFileType(childrenNames[i]);
		association.setMergeProgram(node.get("mergeProgram", "")); //$NON-NLS-1$,  //$NON-NLS-1$
		association.setParameters(node.get("parameters", "")); //$NON-NLS-1$,  //$NON-NLS-1$
		association.setType(node.getInt("type",MergeFileAssociation.BUILT_IN));
		associations.add(association);
	}
	MergeFileAssociation[] associationArray = new MergeFileAssociation[associations.size()];
	associations.toArray(associationArray);	
	Arrays.sort(associationArray);
	return associationArray;
}
 
Example 18
Project: subclipse   File: SVNUIPlugin.java   Source Code and License 6 votes vote down vote up
public MergeFileAssociation getMergeFileAssociation(String fileName) throws BackingStoreException {
	MergeFileAssociation[] mergeFileAssociations = getMergeFileAssociations();
	for (int i = 0; i < mergeFileAssociations.length; i++) {
		if (mergeFileAssociations[i].getFileType().equals(fileName)) return mergeFileAssociations[i];
	}
	for (int i = 0; i < mergeFileAssociations.length; i++) {
		if (mergeFileAssociations[i].matches(fileName)) return mergeFileAssociations[i];
	}
	MergeFileAssociation mergeFileAssociation = new MergeFileAssociation();
       IPreferenceStore preferenceStore = getPreferenceStore();
       if (preferenceStore.getBoolean(ISVNUIConstants.PREF_MERGE_USE_EXTERNAL))
       	mergeFileAssociation.setType(MergeFileAssociation.DEFAULT_EXTERNAL);
       else
       	mergeFileAssociation.setType(MergeFileAssociation.BUILT_IN);
       return mergeFileAssociation;
}
 
Example 19
Project: subclipse   File: MergeFileAssociationPreferencePage.java   Source Code and License 6 votes vote down vote up
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();
}
 
Example 20
Project: google-cloud-eclipse   File: AppEngineDeployPreferencesPanelTest.java   Source Code and License 6 votes vote down vote up
@Test
public void testProjectSavedInPreferencesSelected()
    throws ProjectRepositoryException, InterruptedException, BackingStoreException {
  IEclipsePreferences node =
      new ProjectScope(project).getNode(DeployPreferences.PREFERENCE_STORE_QUALIFIER);
  try {
    node.put("project.id", "projectId1");
    node.put("account.email", EMAIL_1);
    model = new DeployPreferences(project);

    initializeProjectRepository();
    when(loginService.getAccounts()).thenReturn(twoAccountSet);
    deployPanel = createPanel(true /* requireValues */);
    deployPanel.latestGcpProjectQueryJob.join();

    ProjectSelector projectSelector = getProjectSelector();
    IStructuredSelection selection = projectSelector.getViewer().getStructuredSelection();
    assertThat(selection.size(), is(1));
    assertThat(((GcpProject) selection.getFirstElement()).getId(), is("projectId1"));
  } finally {
    node.clear();
  }
}
 
Example 21
Project: hybris-commerce-eclipse-plugin   File: Activator.java   Source Code and License 6 votes vote down vote up
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();
}
 
Example 22
Project: CodeCheckerEclipsePlugin   File: CcConfiguration.java   Source Code and License 6 votes vote down vote up
private  Map<ConfigTypes, String> getConfigEclipse(IEclipsePreferences pref ) {
    Map<ConfigTypes, String> ret = new HashMap<ConfigTypes, String>();
    for (ConfigTypes k:ConfigTypes.values()){
        if (defaults.containsKey(k))
            ret.put(k,defaults.get(k));
        else
            ret.put(k,"");
    }

    try {
        for (String configKey : pref.keys()) {
            for (ConfigTypes c : configKeys.keySet()) {
                if (configKey.equals(configKeys.get(c))){
                    ret.put(c, pref.get(configKey, ""));
                }
            }
        }
    } catch (BackingStoreException e) {
    }


    return ret;
}
 
Example 23
Project: gwt-eclipse-plugin   File: LegacyGWTHostPageSelectionDialog.java   Source Code and License 6 votes vote down vote up
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;
}
 
Example 24
Project: typescript.java   File: SaveProjectPreferencesJob.java   Source Code and License 6 votes vote down vote up
@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;
}
 
Example 25
Project: cft   File: StsTestUtil.java   Source Code and License 6 votes vote down vote up
/**
 * Set a bunch of preferences so that m2eclipse hopefully isn't doing a lot
 * of time consuming stuff in the background.
 */
public static void mavenOffline() throws Error {
	System.out.println("Pacifying m2eclipse...");
	IEclipsePreferences m2EclipsePrefs = new InstanceScope().getNode("org.eclipse.m2e.core");
	m2EclipsePrefs.putBoolean("eclipse.m2.offline", true);
	m2EclipsePrefs.putBoolean("eclipse.m2.globalUpdatePolicy", false);
	m2EclipsePrefs.putBoolean("eclipse.m2.updateIndexes", false);
	try {
		m2EclipsePrefs.flush();
	}
	catch (BackingStoreException e) {
		throw new Error(e);
	}

	// LegacyProjectChecker.NON_BLOCKING = true;
	System.out.println("Pacifying m2eclipse...DONE");
}
 
Example 26
Project: filesync4eclipse   File: ProjectProperties.java   Source Code and License 6 votes vote down vote up
@Override
public void removed(NodeChangeEvent event) {
    try {
        // in case preferences are entirely deleted
        if(event.getParent() == preferences && !preferences.nodeExists("")) {
            // code below throws exception
            // preferences.removeNodeChangeListener(this);
            // preferences.removePreferenceChangeListener(this);
            return;
        }
    } catch (BackingStoreException e) {
        // ignore
        return;
    }
    if (!isIgnorePreferenceListeners()) {
        buildPathMap(preferences);
    } else {
        rebuildPathMap = true;
    }
}
 
Example 27
Project: cft   File: ModuleCache.java   Source Code and License 6 votes vote down vote up
protected synchronized void remove(IServer server) {
	dataByServer.remove(server);

	CloudFoundryServer cfs =  (CloudFoundryServer)server.loadAdapter(CloudFoundryServer.class, null);
	
	String serverId =  cfs.getServerId(); 
	
	if (serverId != null) {
		IEclipsePreferences node = new InstanceScope().getNode(CloudFoundryPlugin.PLUGIN_ID);
		node.remove(KEY_MODULE_MAPPING_LIST + ":" + serverId); //$NON-NLS-1$
		try {
			node.flush();
		}
		catch (BackingStoreException e) {
			CloudFoundryPlugin
					.getDefault()
					.getLog()
					.log(new Status(IStatus.ERROR, CloudFoundryPlugin.PLUGIN_ID,
							"Failed to remove application mappings", e)); //$NON-NLS-1$
		}
	}
}
 
Example 28
Project: mondo-hawk   File: HModel.java   Source Code and License 6 votes vote down vote up
public void delete() throws BackingStoreException {
	removeHawkFromMetadata(getHawkConfig());

	File f = hawk.getModelIndexer().getParentFolder();
	if (this.isRunning()) {
		try {
			hawk.getModelIndexer().shutdown(ShutdownRequestType.ONLY_LOCAL);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	if (f.exists()) {
		getConsole().println("Hawk instance removed from ui but persistence remains at: " + f);
	}
}
 
Example 29
Project: mytourbook   File: PreferenceInitializer.java   Source Code and License 6 votes vote down vote up
public static void migratePreferences() {

		Preferences pref = new ProfileScope(getDefaultAgentLocation(), IProfileRegistry.SELF).getNode(P2_Activator.PLUGIN_ID);

		try {
			if (pref.keys().length == 0) {
				// migrate preferences from instance scope to profile scope
				Preferences oldPref = new InstanceScope().getNode(P2_Activator.PLUGIN_ID);
				// don't migrate everything.  Some of the preferences moved to
				// another bundle.
				pref.put(PreferenceConstants.PREF_OPEN_WIZARD_ON_ERROR_PLAN, oldPref.get(PreferenceConstants.PREF_OPEN_WIZARD_ON_ERROR_PLAN, MessageDialogWithToggle.PROMPT));
				pref.putBoolean(PreferenceConstants.PREF_SHOW_LATEST_VERSION, oldPref.getBoolean(PreferenceConstants.PREF_SHOW_LATEST_VERSION, true));
				pref.flush();
			}
		} catch (BackingStoreException e) {
			StatusManager.getManager().handle(new Status(IStatus.ERROR, P2_Activator.PLUGIN_ID, 0, ProvSDKMessages.PreferenceInitializer_Error, e), StatusManager.LOG);
		}
	}
 
Example 30
Project: bts   File: TextAnnotationSettingsPage.java   Source Code and License 6 votes vote down vote up
/**
 * @return
 */
private List<EclipsePreferences> loadAnnotationPreferenceNodes() {
	Preferences rootNode = ConfigurationScope.INSTANCE.getNode(Activator.BUNDLE_ID);
	
	annotationsNode = (EclipsePreferences) rootNode.node(BTSCorpusConstants.PREF_ANNOTATION_SETTINGS);
	List<EclipsePreferences> nodes = new Vector<EclipsePreferences>();
	if (annotationsNode != null)
	{
		try {
			for (String n : annotationsNode.childrenNames())
			{
				if (annotationsNode.nodeExists(n))
				{
					nodes.add((EclipsePreferences) annotationsNode.node(n));
				}
			}
		} catch (BackingStoreException e) {
			e.printStackTrace();
		}
	}
			
	return nodes;
}
 
Example 31
Project: bts   File: TextAnnotationSettingsPage.java   Source Code and License 6 votes vote down vote up
@Override
public boolean performOk() {
	if (settingsEditors == null) return super.performOk();
	
	for (TextAnnotationSettingsEditor editor : settingsEditors)
	{
		editor.save();
	}
	
	try {
		annotationsNode.flush();
	} catch (BackingStoreException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	eventBroker.post("event_preferences_changed/"+BTSCorpusConstants.PREF_ANNOTATION_SETTINGS, 
			annotationsNode.absolutePath());
	return super.performOk();
}
 
Example 32
Project: bts   File: TextAnnotationSettingsPage.java   Source Code and License 6 votes vote down vote up
/**
 * @param selectionAdapter
 * @param node
 */
public void delete(TextAnnotationSettingsEditor editor, Preferences node) {
	annotationsNodes.remove(node);
	annotationsNode.remove(node.name());
	
	settingsEditors.remove(editor);
	editor.getParent().dispose();
	Point p = sc.getSize();
	sc.setSize(p.x + variant, p.y);
	variant  = -variant;
	try {
		node.removeNode();
	} catch (BackingStoreException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
Example 33
Project: APICloud-Studio   File: UIPlugin.java   Source Code and License 6 votes vote down vote up
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);
		}
	}
}
 
Example 34
Project: PerformanceHat   File: AbstractFeedbackPropertyPage.java   Source Code and License 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public final boolean performOk() {
  final IEclipsePreferences projectPreferences = getProjectPreferences();
  for (final PropertyPageField field : fields) {
    field.storeValue(projectPreferences);
  }
  try {
    projectPreferences.flush();
  }
  catch (final BackingStoreException e) {
    // settings could not be saved.
    e.printStackTrace();
  }
  return super.performOk();
}
 
Example 35
Project: jsweet-eclipse-plugin   File: ProjectPreferenceStore.java   Source Code and License 6 votes vote down vote up
private void writeProperties() throws IOException {
	IEclipsePreferences projectPreferences = this.getProjectPreferences();
	for (String name : super.preferenceNames()) {
		if (this.projectSpecificSettings) {
			String value = this.getString(name);
			projectPreferences.put(name, value);
		} else {
			projectPreferences.remove(name);
		}
	}
	try {
		projectPreferences.flush();
	} catch (BackingStoreException e) {
		throw new IOException(e);
	}
}
 
Example 36
Project: APICloud-Studio   File: UserAgentManager.java   Source Code and License 6 votes vote down vote up
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
		}
	}
}
 
Example 37
Project: dockerfoundry   File: HttpTracer.java   Source Code and License 6 votes vote down vote up
/**
 * 
 * @param enable true if tracing should be enabled for all clients/all
 * servers. False otherwise.
 */
public synchronized void enableTracing(boolean enable) {
	isEnabled = enable;
	IEclipsePreferences prefs = DockerFoundryPlugin.getDefault().getPreferences();
	prefs.putBoolean(PREFERENCE_TRACE, isEnabled);
	try {
		prefs.flush();
	}
	catch (BackingStoreException e) {
		DockerFoundryPlugin.logError(e);
	}

	if (isEnabled) {
		DockerFoundryPlugin.getCallback().showTraceView(isEnabled);
	}
}
 
Example 38
Project: dockerfoundry   File: ModuleCache.java   Source Code and License 6 votes vote down vote up
private void setLocalModuleToCloudModuleMapping(Map<String, String> list) {
	String string = convertMapToString(list);
	IEclipsePreferences node = new InstanceScope().getNode(DockerFoundryPlugin.PLUGIN_ID);
	DockerFoundryPlugin.trace("Updated mapping: " + string); //$NON-NLS-1$
	node.put(KEY_MODULE_MAPPING_LIST + ":" + getServerId(), string); //$NON-NLS-1$
	try {
		node.flush();
	}
	catch (BackingStoreException e) {
		DockerFoundryPlugin
				.getDefault()
				.getLog()
				.log(new Status(IStatus.ERROR, DockerFoundryPlugin.PLUGIN_ID,
						"Failed to update application mappings", e)); //$NON-NLS-1$
	}
}
 
Example 39
Project: APICloud-Studio   File: EclipseUtil.java   Source Code and License 6 votes vote down vote up
/**
 * 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);
			}
		}
	}
}
 
Example 40
Project: plan   File: NWDays.java   Source Code and License 6 votes vote down vote up
@Override
public boolean performOk() {
	Preferences preferences = ConfigurationScope.INSTANCE.getNode("org.mdpm.lng.plan.preferences");
	preferences.putBoolean("sunday", sunday.getSelection());
	preferences.putBoolean("monday", monday.getSelection());
	preferences.putBoolean("tuesday", tuesday.getSelection());
	preferences.putBoolean("wednesday", wednesday.getSelection());
	preferences.putBoolean("thursday", thursday.getSelection());
	preferences.putBoolean("friday", friday.getSelection());
	preferences.putBoolean("saturday", saturday.getSelection());
	String tmp="";
	if(dates.getItemCount()>0){
	for (int k=0; k<dates.getItemCount();k++){
		tmp = tmp+dates.getItem(k)+",";
	}
	}
    preferences.put("dates",tmp);
	//preferences.put
	try {
		preferences.flush();
	} catch (BackingStoreException e) {
		e.printStackTrace();
	}
	return super.performOk();
}
 
Example 41
Project: mondo-demo-wt   File: WTNewProjectInfo.java   Source Code and License 6 votes vote down vote up
public boolean Create_Project() throws CoreException, BackingStoreException, IOException
{	
	project = ResourcesPlugin.getWorkspace().getRoot().getProject(features.Get_sysId());
	if (!project.exists()) {
	    project.create(null);
	    project.open(null);
		try {
	    	IProjectDescription description = project.getDescription();
	    	String[] natures = description.getNatureIds();
	    	String[] newNatures = new String[natures.length + 1];
			newNatures[natures.length] = WTNewProjectNature.ID;
	    	System.arraycopy(natures, 0, newNatures, 0, natures.length);		    	
	    	description.setNatureIds(newNatures);
	    	project.setDescription(description, null);
			
			Create_XMI_Associated(project);
	
	    }catch (CoreException e) {
	        // Something went wrong
			e.printStackTrace();
	    }
	}		
	
	return true;				
}
 
Example 42
Project: gwt-eclipse-plugin   File: MavenProjectConfigurator.java   Source Code and License 6 votes vote down vote up
/**
 * Save the settings for the GWT nature in the application GWT preferences.
 *
 * @param project
 * @param mavenProject
 * @param mavenConfig
 * @throws BackingStoreException
 */
private void persistGwtNatureSettings(IProject project, MavenProject mavenProject, Xpp3Dom mavenConfig)
    throws BackingStoreException {
  IPath warOutDir = getWarOutDir(project, mavenProject);

  WebAppProjectProperties.setWarSrcDir(project, getWarSrcDir(mavenProject, mavenConfig)); // src/main/webapp
  WebAppProjectProperties.setWarSrcDirIsOutput(project, getLaunchFromHere(mavenConfig)); // false

  // TODO the extension should be used, from WarArgProcessor
  WebAppProjectProperties.setLastUsedWarOutLocation(project, warOutDir);

  WebAppProjectProperties.setGwtMavenModuleName(project, getGwtModuleName(mavenProject));
  WebAppProjectProperties.setGwtMavenModuleShortName(project, getGwtModuleShortName(mavenProject));

  String message = "MavenProjectConfiguratior Maven: Success with setting up GWT Nature\n";
  message += "\tartifactId=" + mavenProject.getArtifactId() + "\n";
  message += "\tversion=" + mavenProject.getVersion() + "\n";
  message += "\twarOutDir=" + warOutDir;
  Activator.log(message);
}
 
Example 43
Project: e4-cookbook-migration-guide   File: ScopedPreferenceStore.java   Source Code and License 6 votes vote down vote up
/**
 * Dispose the receiver.
 */
private void disposePreferenceStoreListener() {

	IEclipsePreferences root = (IEclipsePreferences) Platform
			.getPreferencesService().getRootNode().node(
					Plugin.PLUGIN_PREFERENCE_SCOPE);
	try {
		if (!(root.nodeExists(nodeQualifier))) {
			return;
		}
	} catch (BackingStoreException e) {
		return;// No need to report here as the node won't have the
		// listener
	}

	IEclipsePreferences preferences = getStorePreferences();
	if (preferences == null) {
		return;
	}
	if (preferencesListener != null) {
		preferences.removePreferenceChangeListener(preferencesListener);
		preferencesListener = null;
	}
}
 
Example 44
Project: mondo-hawk   File: HModel.java   Source Code and License 6 votes vote down vote up
public void removeHawkFromMetadata(HawkConfig config) throws BackingStoreException {
	IEclipsePreferences preferences = HManager.getPreferences();

	String xml = preferences.get("config", null);

	if (xml != null) {
		XStream stream = new XStream(new DomDriver());
		stream.processAnnotations(HawksConfig.class);
		stream.processAnnotations(HawkConfig.class);
		stream.setClassLoader(HawksConfig.class.getClassLoader());
		HawksConfig hc = (HawksConfig) stream.fromXML(xml);
		hc.removeLoc(config);
		xml = stream.toXML(hc);
		preferences.put("config", xml);
		preferences.flush();
	} else {
		getConsole().printerrln("removeHawkFromMetadata tried to load preferences but it could not.");
	}
}
 
Example 45
Project: che   File: ChePreferences.java   Source Code and License 6 votes vote down vote up
protected Properties convertToProperties(Properties result, String prefix)
    throws BackingStoreException {
  // add the key/value pairs from this node
  boolean addSeparator = prefix.length() != 0;
  // thread safety: copy reference in case of concurrent change
  ImmutableMap temp;
  synchronized (childAndPropertyLock) {
    temp = properties;
  }
  String[] keys = temp.keys();
  for (int i = 0, imax = keys.length; i < imax; i++) {
    String value = temp.get(keys[i]);
    if (value != null) result.put(encodePath(prefix, keys[i]), value);
  }
  //        // recursively add the child information
  //        IEclipsePreferences[] childNodes = getChildren(true);
  //        for (int i = 0; i < childNodes.length; i++) {
  //            ChePreferences child = (ChePreferences) childNodes[i];
  //            String fullPath = addSeparator ? prefix + PATH_SEPARATOR + child.name() :
  // child.name();
  //            child.convertToProperties(result, fullPath);
  //        }
  return result;
}
 
Example 46
Project: PDFReporter-Studio   File: ReportingPrefPage.java   Source Code and License 6 votes vote down vote up
/**
   * @see org.eclipse.jface.preference.IPreferencePage#performOk()
   */
  public boolean performOk() {
      IEclipsePreferences prefs = MsgEditorPreferences.getEclipsePreferenceStore();
      prefs.putInt(MsgEditorPreferences.REPORT_MISSING_VALUES_LEVEL, reportMissingVals.getSelectionIndex());
      prefs.putInt(MsgEditorPreferences.REPORT_DUPL_VALUES_LEVEL, reportDuplVals.getSelectionIndex());
      prefs.putInt(MsgEditorPreferences.REPORT_SIM_VALUES_LEVEL, reportSimVals.getSelectionIndex());
      prefs.putBoolean(MsgEditorPreferences.REPORT_SIM_VALUES_WORD_COMPARE,reportSimValsMode[0].getSelection());
      prefs.putBoolean(MsgEditorPreferences.REPORT_SIM_VALUES_LEVENSTHEIN, reportSimValsMode[1].getSelection());
      double precision = 0.75d;
      try{
      	double textPrecision = Double.parseDouble(reportSimPrecision.getText());
      	precision = textPrecision;
      } catch (NumberFormatException ex){}
      prefs.putDouble(MsgEditorPreferences.REPORT_SIM_VALUES_PRECISION, precision);
      try {
	prefs.flush();
} catch (BackingStoreException e) {
	e.printStackTrace();
}
      refreshEnabledStatuses();
      return super.performOk();
  }
 
Example 47
Project: APICloud-Studio   File: PreferenceUtils.java   Source Code and License 6 votes vote down vote up
/**
 * Sets if the new files and folders should update their permissions to specific permissions after transferring.
 * 
 * @param shouldSpecific
 *            true if the permissions should be updated, false otherwise
 * @param direction
 *            indicates if this is for upload or download permissions
 */
public static void setSpecificPermissions(boolean shouldSpecific, PermissionDirection direction)
{
	IEclipsePreferences prefs = EclipseUtil.instanceScope().getNode(CoreIOPlugin.PLUGIN_ID);
	switch (direction)
	{
		case UPLOAD:
			prefs.putBoolean(IPreferenceConstants.UPLOAD_SPECIFIC_PERMISSIONS, shouldSpecific);
			break;
		case DOWNLOAD:
			prefs.putBoolean(IPreferenceConstants.DOWNLOAD_SPECIFIC_PERMISSIONS, shouldSpecific);
			break;
	}
	try
	{
		prefs.flush();
	}
	catch (BackingStoreException e)
	{
		IdeLog.logError(CoreIOPlugin.getDefault(), e);
	}
}
 
Example 48
Project: APICloud-Studio   File: MergeFileAssociationPreferencePage.java   Source Code and License 6 votes vote down vote up
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();
}
 
Example 49
Project: che   File: JavaProject.java   Source Code and License 6 votes vote down vote up
@Override
public void setOption(String optionName, String optionValue) {
  // Store option value
  IEclipsePreferences projectPreferences = getEclipsePreferences();
  boolean modified =
      getJavaModelManager().storePreference(optionName, optionValue, projectPreferences, null);

  // Write changes
  if (modified) {
    try {
      projectPreferences.flush();
    } catch (BackingStoreException e) {
      // problem with pref store - quietly ignore
    }
  }
  getJavaModelManager().resetProjectOptions(JavaProject.this);
  JavaProject.this.resetCaches(); // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=233568
}
 
Example 50
Project: Correct   File: ConfigureGroupsPage.java   Source Code and License 6 votes vote down vote up
private void loadFromPref() {
	try {
		groups = PrefIO.readConfig();
	} catch (BackingStoreException e) {
		e.printStackTrace();
	}
	
	for(Group g: groups) {
		listGroup.add(GROUP + g.getGroupID());
	}
	if(listGroup.getItemCount() > 0) {
		listGroup.select(1);
		updateMemberList();
	}
	updateGroups();
}
 
Example 51
Project: gwt-eclipse-plugin   File: GwtFacetInstallSdkDelegate.java   Source Code and License 6 votes vote down vote up
/**
 * Add a GWT SDK container for standard project only.
 */
private void addGwtSdkContainer(IProject project, GwtSdk newSdk)
    throws FileNotFoundException, CoreException, BackingStoreException {
  IJavaProject javaProject = JavaCore.create(project);

  GWTUpdateWebInfFolderCommand updateWebInfCommand = new GWTUpdateWebInfFolderCommand(javaProject, newSdk);

  // Maybe there is a SDK registered already
  GwtSdk oldSdk = GwtSdk.findSdkFor(javaProject);

  // Named container, not individual jars
  UpdateType updateType = UpdateType.NAMED_CONTAINER;

  GWTUpdateProjectSdkCommand command = new GWTUpdateProjectSdkCommand(javaProject, oldSdk, newSdk, updateType,
      updateWebInfCommand);
  command.execute();
}
 
Example 52
Project: gwt-eclipse-plugin   File: WebAppProjectProperties.java   Source Code and License 6 votes vote down vote up
/**
 * If the given project is not already a Web App (i.e. it does not have a defined WAR directory), and it is a Dynamic
 * Web Project, then set the WAR directory to be equivalent to the Web Project's WebContent directory, and ensure that
 * the directory is set to be "input-only".
 */
public static void maybeSetWebAppPropertiesForDynamicWebProject(IProject project) throws BackingStoreException {
  if (WebAppUtilities.isWebApp(project)) {
    return;
  }

  try {
    if (!DynamicWebProjectUtilities.isDynamicWebProject(project)) {
      return;
    }

    IPath webContentFolder = DynamicWebProjectUtilities.getWebContentFolder(project);
    if (webContentFolder != null) {
      WebAppProjectProperties.setWarSrcDir(project, webContentFolder);
      WebAppProjectProperties.setWarSrcDirIsOutput(project, false);
    }
  } catch (CoreException ce) {
    CorePluginLog.logError(ce);
  }
}
 
Example 53
Project: gwt-eclipse-plugin   File: GWTProjectProperties.java   Source Code and License 6 votes vote down vote up
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();
}
 
Example 54
Project: gwt-eclipse-plugin   File: WebappProjectPropertyPage.java   Source Code and License 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
protected void saveProjectProperties() throws BackingStoreException, CoreException {
  IProject project = getProject();

  // Save project properties
  List<IPath> excludedJars = excludedJarsField.getElements();
  WebAppProjectProperties.setJarsExcludedFromWebInfLib(project, excludedJars);
  WebAppProjectProperties.setWarSrcDir(project, warDir);
  WebAppProjectProperties.setWarSrcDirIsOutput(project, isWarSrcDirOutputButton.getSelection());

  // If the project has a managed WAR output directory, update the default
  // Java output directory
  if (WebAppUtilities.hasManagedWarOut(project)) {
    WebAppUtilities.setOutputLocationToWebInfClasses(JavaCore.create(project), null);
  }
}
 
Example 55
Project: APICloud-Studio   File: PreferenceUtils.java   Source Code and License 6 votes vote down vote up
/**
 * Sets the specific permissions used for new folders created when transferring.
 * 
 * @param permissions
 *            permissions in decimal form
 * @param direction
 *            indicates if this is for upload or download permissions
 */
public static void setFolderPermissions(long permissions, PermissionDirection direction)
{
	IEclipsePreferences prefs = EclipseUtil.instanceScope().getNode(CoreIOPlugin.PLUGIN_ID);
	switch (direction)
	{
		case UPLOAD:
			prefs.putLong(IPreferenceConstants.UPLOAD_FOLDER_PERMISSION, permissions);
			break;
		case DOWNLOAD:
			prefs.putLong(IPreferenceConstants.DOWNLOAD_FOLDER_PERMISSION, permissions);
			break;
	}
	try
	{
		prefs.flush();
	}
	catch (BackingStoreException e)
	{
		IdeLog.logError(CoreIOPlugin.getDefault(), e);
	}
}
 
Example 56
Project: n4js   File: WorkingSetManagerImpl.java   Source Code and License 5 votes vote down vote up
@Override
public void reset() {
	try {
		getPreferences().clear();
		getPreferences().flush();
		discardWorkingSetState();
		discardWorkingSetCaches();
		restoreState(new NullProgressMonitor());
	} catch (BackingStoreException e) {
		LOGGER.error("Error occurred while clearing persisted state.", e);
	}
}
 
Example 57
Project: n4js   File: WorkingSetManagerBrokerImpl.java   Source Code and License 5 votes vote down vote up
/**
 * (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);
	}

}
 
Example 58
Project: n4js   File: OsgiExternalLibraryPreferenceStore.java   Source Code and License 5 votes vote down vote up
@Override
protected IStatus doSave(final ExternalLibraryPreferenceModel modelToSave) {
	final IEclipsePreferences node = InstanceScope.INSTANCE.getNode(QUALIFIER);
	node.put(CONFIGURATION_KEY, modelToSave.toJsonString());
	try {
		node.flush();
		return OK_STATUS;
	} catch (final BackingStoreException e) {
		final String message = "Unexpected error when trying to persist external library preferences.";
		LOGGER.error(message, e);
		return statusHelper.createError(message, e);
	}
}
 
Example 59
Project: AgentWorkbench   File: BundleProperties.java   Source Code and License 5 votes vote down vote up
/**
 * Saves the bundle properties.
 */
public void save() {
	this.setGlobal2Preferences();
	try {
		this.getEclipsePreferences().flush();
	} catch (BackingStoreException bsEx) {
		bsEx.printStackTrace();
	}
}
 
Example 60
Project: ide-plugins   File: ProjectData.java   Source Code and License 5 votes vote down vote up
public static void persistOptIn(String email, boolean uptodate, String mobileLicense, String desktopLicense) {
       PREFERENCES.put(ProjectConstants.PARAM_USER_IDE_OPTIN, "true");
       PREFERENCES.put(ProjectConstants.PARAM_USER_EMAIL, email);
       PREFERENCES.putBoolean(ProjectConstants.PARAM_USER_UPTODATE, uptodate);
       PREFERENCES.put(ProjectConstants.PARAM_USER_LICENSE_MOBILE, mobileLicense);
       PREFERENCES.put(ProjectConstants.PARAM_USER_LICENSE_DESKTOP, desktopLicense);
       PREFERENCES.put(ProjectConstants.PARAM_USER_MAC_ADDRESS, TemplateUtils.getMacAddress());
       PREFERENCES.put(ProjectConstants.PARAM_USER_PLUGIN_VERSION, ProjectConstants.PLUGIN_VERSION);
	try {
       	PREFERENCES.flush();
	} catch (BackingStoreException e) {
		e.printStackTrace();
	}
}