Java Code Examples for org.osgi.service.prefs.Preferences#node()

The following examples show how to use org.osgi.service.prefs.Preferences#node() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PluginPreferencesImpl.java    From ganttproject with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Preferences node(String path) {
  if (path.endsWith("/")) {
    if (!"/".equals(path)) {
      throw new IllegalArgumentException("Path can't end with /");
    }
  }
  if (path.startsWith("/")) {
    if (myParent != null) {
      return myParent.node(path);
    }
    path = path.substring(1);
  }
  if ("".equals(path)) {
    return this;
  }
  int firstSlash = path.indexOf('/');
  String prefix = firstSlash == -1 ? path : path.substring(0, firstSlash);
  String suffix = firstSlash == -1 ? "" : path.substring(firstSlash + 1);
  Preferences child = myChildren.get(prefix);
  if (child == null) {
    child = createChild(prefix);
  }
  return child.node(suffix);
}
 
Example 2
Source File: ExportFileWizardImpl.java    From ganttproject with GNU General Public License v3.0 6 votes vote down vote up
public ExportFileWizardImpl(UIFacade uiFacade, IGanttProject project, Preferences pluginPreferences) {
  super(uiFacade, language.getText("exportWizard.dialog.title"));
  final Preferences exportNode = pluginPreferences.node("/instance/net.sourceforge.ganttproject/export");
  myProject = project;
  myState = new State();
  myState.myPublishInWebOption.setValue(exportNode.getBoolean("publishInWeb", false));
  myState.myPublishInWebOption.addChangeValueListener(new ChangeValueListener() {
    @Override
    public void changeValue(ChangeValueEvent event) {
      exportNode.putBoolean("publishInWeb", myState.myPublishInWebOption.getValue());
    }
  });
  if (ourExporters == null) {
    ourExporters = PluginManager.getExporters();
  }
  myState.setExporter(ourLastSelectedExporter == null ? ourExporters.get(0) : ourLastSelectedExporter);
  for (Exporter e : ourExporters) {
    e.setContext(project, uiFacade, pluginPreferences);
  }
  addPage(new ExporterChooserPage(ourExporters, myState));
  addPage(new FileChooserPage(myState, myProject, this, exportNode));
}
 
Example 3
Source File: JavaCorePreferenceModifyListener.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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);
}
 
Example 4
Source File: DefaultRulePreferences.java    From CogniCrypt with Eclipse Public License 2.0 5 votes vote down vote up
public static void addDefaults() {
	Preferences rulePreferences = InstanceScope.INSTANCE.getNode(de.cognicrypt.core.Activator.PLUGIN_ID);
	String[] listOfNodes;
	try {
		listOfNodes = rulePreferences.childrenNames();
		if (listOfNodes.length == 0) {
			Section ini = Utils.getConfig().get(Constants.INI_URL_HEADER);
			List<Ruleset> listOfRulesets = new ArrayList<Ruleset>() {
		 		private static final long serialVersionUID = 1L;
		 		{
		 			add(new Ruleset(ini.get(Constants.INI_JCA_NEXUS), true));
		 			add(new Ruleset(ini.get(Constants.INI_BC_NEXUS)));
		 			add(new Ruleset(ini.get(Constants.INI_TINK_NEXUS)));
		 			add(new Ruleset(ini.get(Constants.INI_BCJCA_NEXUS)));
		 		}
		 	};
		 	for (Iterator<Ruleset> itr = listOfRulesets.iterator(); itr.hasNext();) {
	 			Ruleset ruleset = (Ruleset) itr.next();
	
	 			Preferences subPref = rulePreferences.node(ruleset.getFolderName());
	 			subPref.putBoolean("CheckboxState", ruleset.isChecked());
	 			subPref.put("FolderName", ruleset.getFolderName());
	 			subPref.put("SelectedVersion", ruleset.getSelectedVersion());
	 			subPref.put("Url", ruleset.getUrl());
	 		}
		}
	} catch (BackingStoreException e) {
		Activator.getDefault().logError(e);
	}
}
 
Example 5
Source File: ImporterFromGanttFile.java    From ganttproject with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setContext(IGanttProject project, UIFacade uiFacade, Preferences preferences) {
  super.setContext(project, uiFacade, preferences);
  final Preferences node = preferences.node("/instance/net.sourceforge.ganttproject/import");
  myMergeResourcesOption.lock();
  myMergeResourcesOption.loadPersistentValue(node.get(myMergeResourcesOption.getID(),
      HumanResourceMerger.MergeResourcesOption.BY_ID));
  myMergeResourcesOption.commit();
  myMergeResourcesOption.addChangeValueListener(new ChangeValueListener() {
    @Override
    public void changeValue(ChangeValueEvent event) {
      node.put(myMergeResourcesOption.getID(), String.valueOf(event.getNewValue()));
    }
  });
}