Java Code Examples for java.util.prefs.Preferences#userRoot()

The following examples show how to use java.util.prefs.Preferences#userRoot() . 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: NbPreferences.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static Provider getPreferencesProvider() {
    Provider retval = Lookup.getDefault().lookup(Provider.class);
    if (retval == null) {
         retval = new Provider() {
              public Preferences preferencesForModule(Class cls) {
                   return Preferences.userNodeForPackage(cls);
              }

              public Preferences preferencesRoot() {
                   return Preferences.userRoot();
              }                         
         };
         // Avoided warning in case it is set 
         //(e.g. from NbTestCase - org.netbeans.junit.internal.MemoryPreferencesFactory).
         String prefsFactory = System.getProperty("java.util.prefs.PreferencesFactory");//NOI18N
         if (!"org.netbeans.junit.internal.MemoryPreferencesFactory".equals(prefsFactory)) {//NOI18N
             Logger logger = Logger.getLogger(NbPreferences.class.getName());
             logger.log(prefsFactory == null ? Level.WARNING : Level.FINE,
                     "NetBeans implementation of Preferences not found");//NOI18N
         } 
    }
    return retval;
}
 
Example 2
Source File: FilePreferencesXmlSupport.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Import preferences from the specified input stream, which is assumed to
 * contain an XML document in the format described in the Preferences spec.
 *
 * @throws IOException
 *             if reading from the specified output stream results in an
 *             <tt>IOException</tt>.
 * @throws InvalidPreferencesFormatException
 *             Data on input stream does not constitute a valid XML document
 *             with the mandated document type.
 */
static void importPreferences(InputStream is) throws IOException, InvalidPreferencesFormatException {
    try {
        Document doc = loadPrefsDoc(is);
        String xmlVersion = doc.getDocumentElement().getAttribute("EXTERNAL_XML_VERSION");
        if (xmlVersion.compareTo(EXTERNAL_XML_VERSION) > 0)
            throw new InvalidPreferencesFormatException("Exported preferences file format version " + xmlVersion
                    + " is not supported. This java installation can read" + " versions " + EXTERNAL_XML_VERSION
                    + " or older. You may need" + " to install a newer version of JDK.");

        Element xmlRoot = (Element) doc.getDocumentElement().getChildNodes().item(0);
        Preferences prefsRoot = (xmlRoot.getAttribute("type").equals("user") ? Preferences.userRoot()
                : Preferences.systemRoot());
        ImportSubtree(prefsRoot, xmlRoot);
    } catch (SAXException | BackingStoreException e) {
        throw new InvalidPreferencesFormatException(e);
    }
}
 
Example 3
Source File: XmlSupport.java    From java-scanner-access-twain with GNU Affero General Public License v3.0 6 votes vote down vote up
static void importPreferences(InputStream is)
    throws IOException, InvalidPreferencesFormatException
{
    try {
        Document doc = loadPrefsDoc(is);
        String xmlVersion =
            doc.getDocumentElement().getAttribute("EXTERNAL_XML_VERSION");
        if (xmlVersion.compareTo(EXTERNAL_XML_VERSION) > 0)
            throw new InvalidPreferencesFormatException(
            "Exported preferences file format version " + xmlVersion +
            " is not supported. This java installation can read" +
            " versions " + EXTERNAL_XML_VERSION + " or older. You may need" +
            " to install a newer version of JDK.");

        Element xmlRoot = (Element) doc.getDocumentElement().
                                           getChildNodes().item(0);
        Preferences prefsRoot =
            (xmlRoot.getAttribute("type").equals("user") ?
                        Preferences.userRoot() : Preferences.systemRoot());
        ImportSubtree(prefsRoot, xmlRoot);
    } catch(SAXException e) {
        throw new InvalidPreferencesFormatException(e);
    }
}
 
Example 4
Source File: PreferencesEntityStoreAssembler.java    From attic-polygene-java with Apache License 2.0 6 votes vote down vote up
@Override
public void assemble( ModuleAssembly module )
{
    super.assemble( module );
    String applicationName = module.layer().application().name();

    Preferences root = Preferences.userRoot();
    Preferences node = root.node( applicationName );
    PreferencesEntityStoreInfo info = new PreferencesEntityStoreInfo( node );
    ServiceDeclaration service = module.services( PreferencesEntityStoreService.class )
                                       .setMetaInfo( info )
                                       .visibleIn( visibility() )
                                       .instantiateOnStartup();
    if( hasIdentity() )
    {
        service.identifiedBy( identity() );
    }
}
 
Example 5
Source File: TestPreferences.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testNodeExists() throws Exception {
    Preferences pref = getPreferencesNode();
    Preferences pref2 = pref.node("a/b/c");
    while(pref2 != Preferences.userRoot()) {
        assertTrue(pref2.nodeExists(""));
        Preferences parent = pref2.parent();
        pref2.removeNode();
        assertFalse(pref2.nodeExists(""));
        pref2 = parent;
    }
    
    assertNotNull(getPreferencesNode().node("a/b/c/d"));
    assertTrue(getPreferencesNode().node("a/b/c/d").nodeExists(""));
}
 
Example 6
Source File: DefaultsManager.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 
 * @param pParent
 * @param pk
 * @return
 */
private static final Preferences create( Preferences pParent,
		PreferenceKey pk )
{
	return ( pParent == null ) ? ( Preferences.userRoot( ) )
			: pParent.node( pk.getKey( ) );
}
 
Example 7
Source File: Utility.java    From iBioSim with Apache License 2.0 5 votes vote down vote up
public static void submitBugReportTemp(String message) {
	Preferences biosimrc = Preferences.userRoot();
	String command = biosimrc.get("biosim.general.browser", "");
	command = command + " http://www.github.com/MyersResearchGroup/iBioSim/issues";
	Runtime exec = Runtime.getRuntime();
	try
	{
		exec.exec(command);
	}
	catch (IOException e1)
	{
		e1.printStackTrace();
		JOptionPane.showMessageDialog(Gui.frame, "Unable to open bug database.", "Error", JOptionPane.ERROR_MESSAGE);
	}
}
 
Example 8
Source File: VerilogSynthesisView.java    From iBioSim with Apache License 2.0 5 votes vote down vote up
/**
 * Load default fields for Synthesis View Window
 * @param specFileId - ID of specification file.
 */
public void loadDefaultSynthesisProperties(String specFileId) {
	Preferences prefs = Preferences.userRoot();

	synthProps = new Properties();
	synthProps.setProperty(GlobalConstants.SBOL_SYNTH_SPEC_PROPERTY, specFileId);
	synthProps.setProperty(GlobalConstants.SBOL_SYNTH_SPEC_PATH_PROPERTY, this.verilogSpecPath);
	synthProps.setProperty(GlobalConstants.SBOL_SYNTH_LIBS_PROPERTY, prefs.get(GlobalConstants.SBOL_SYNTH_LIBS_PREFERENCE, ""));
	synthProps.setProperty(GlobalConstants.SBOL_SYNTH_METHOD_PROPERTY, prefs.get(GlobalConstants.SBOL_SYNTH_METHOD_PREFERENCE, GlobalConstants.SBOL_SYNTH_EXHAUST_BB));
	synthProps.setProperty(GlobalConstants.SBOL_SYNTH_NUM_SOLNS_PROPERTY, prefs.get(GlobalConstants.SBOL_SYNTH_NUM_SOLNS_PREFERENCE, "1"));

	saveSynthesisProperties();
	loadSynthesisOptions();
}
 
Example 9
Source File: ComponentBundle.java    From soabase with Apache License 2.0 5 votes vote down vote up
@Override
public void run(Environment environment)
{
    final ComponentManager componentManager = new ComponentManager(appName, companyName, footerMessage);
    final Preferences preferences = Preferences.userRoot();
    AbstractBinder binder = new AbstractBinder()
    {
        @Override
        protected void configure()
        {
            bind(preferences).to(Preferences.class);
            bind(componentManager).to(ComponentManager.class);
        }
    };
    SoaBundle.getFeatures(environment).putNamed(componentManager, ComponentManager.class, SoaFeatures.DEFAULT_NAME);
    SoaBundle.getFeatures(environment).putNamed(preferences, Preferences.class, SoaFeatures.DEFAULT_NAME);

    componentManager.getTabs().addAll(tabs);
    componentManager.getMetrics().addAll(metrics);

    List<IndexMapping> mappings = Lists.newArrayList
    (
        new IndexMapping("", "index.html"),
        new IndexMapping("/vm", "vm.html"),
        new IndexMapping("/logs", "logs.html"),
        new IndexMapping("/signin", "signin.html", true)
    );
    IndexServlet servlet = new IndexServlet(componentManager, mappings, authSpec);
    servlet.setServlets(environment.servlets());

    environment.jersey().register(binder);
}
 
Example 10
Source File: SBMLutilities.java    From iBioSim with Apache License 2.0 5 votes vote down vote up
/**
 * Convert ASTNodes into a string
 */
public static String myFormulaToString(ASTNode mathFormula)
{
	if (mathFormula == null)
	{
		return "";
	}
	setTimeToT(mathFormula);
	String formula;
	Preferences.userRoot();
	formula = JSBML.formulaToString(mathFormula);
	// FormulaCompilerLibSBML compiler = new FormulaCompilerLibSBML();
	// formula = ASTNode.formulaToString(mathFormula, compiler);
	// formula = myFormulaToStringInfix(mathFormula);
	formula = formula.replaceAll("arccot", "acot");
	formula = formula.replaceAll("arccoth", "acoth");
	formula = formula.replaceAll("arccsc", "acsc");
	formula = formula.replaceAll("arccsch", "acsch");
	formula = formula.replaceAll("arcsec", "asec");
	formula = formula.replaceAll("arcsech", "asech");
	formula = formula.replaceAll("arccosh", "acosh");
	formula = formula.replaceAll("arcsinh", "asinh");
	formula = formula.replaceAll("arctanh", "atanh");
	String newformula = formula.replaceFirst("00e", "0e");
	while (!(newformula.equals(formula)))
	{
		formula = newformula;
		newformula = formula.replaceFirst("0e\\+", "e+");
		newformula = newformula.replaceFirst("0e-", "e-");
	}
	formula = formula.replaceFirst("\\.e\\+", ".0e+");
	formula = formula.replaceFirst("\\.e-", ".0e-");
	return formula;
}
 
Example 11
Source File: TechMapping.java    From iBioSim with Apache License 2.0 5 votes vote down vote up
/**
 * Get default fields to set the Synthesis View panel by storing the fields in a property file.
 * @param specFileID - ID of specification file
 * @return 
 */
public static Properties createDefaultSynthesisProperties(String specFileID) 
{
	Properties synthProps = new Properties();
	Preferences prefs = Preferences.userRoot();
	synthProps.setProperty(GlobalConstants.SBOL_SYNTH_SPEC_PROPERTY, specFileID);
	synthProps.setProperty(GlobalConstants.SBOL_SYNTH_LIBS_PROPERTY, 
			prefs.get(GlobalConstants.SBOL_SYNTH_LIBS_PREFERENCE, ""));
	synthProps.setProperty(GlobalConstants.SBOL_SYNTH_METHOD_PROPERTY,
			prefs.get(GlobalConstants.SBOL_SYNTH_METHOD_PREFERENCE, 
					GlobalConstants.SBOL_SYNTH_EXHAUST_BB));
	synthProps.setProperty(GlobalConstants.SBOL_SYNTH_NUM_SOLNS_PROPERTY, 
			prefs.get(GlobalConstants.SBOL_SYNTH_NUM_SOLNS_PREFERENCE, "1"));
	return synthProps;
}
 
Example 12
Source File: PreferencesPlaceholderConfigurer.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * This implementation eagerly fetches the Preferences instances
 * for the required system and user tree nodes.
 */
@Override
public void afterPropertiesSet() {
	this.systemPrefs = (this.systemTreePath != null) ?
			Preferences.systemRoot().node(this.systemTreePath) : Preferences.systemRoot();
	this.userPrefs = (this.userTreePath != null) ?
			Preferences.userRoot().node(this.userTreePath) : Preferences.userRoot();
}
 
Example 13
Source File: TestFrame.java    From ensemble-clustering with MIT License 5 votes vote down vote up
private void initializeGeometry () {
    Preferences p = Preferences.userRoot();
    Preferences oculus = p.node("com.oculusinfo");
    Preferences test = oculus.node("testing");

    int x = test.getInt("test.frame.x", 100);
    int y = test.getInt("test.frame.y", 100);
    int width = test.getInt("test.frame.width", 500);
    int height = test.getInt("test.frame.height", 500);

    setLocation(x, y);
    setSize(width, height);
}
 
Example 14
Source File: GCM2SBML.java    From iBioSim with Apache License 2.0 4 votes vote down vote up
private void loadDefaultParameters() {
	Preferences biosimrc = Preferences.userRoot();

	HashMap<String, String> defaultParameters;

	defaultParameters = new HashMap<String, String>();
	
	defaultParameters.put(GlobalConstants.FORWARD_KREP_STRING, biosimrc.get("biosim.gcm.KREP_VALUE", ""));
	defaultParameters.put(GlobalConstants.REVERSE_KREP_STRING, "1");
	
		defaultParameters.put(GlobalConstants.FORWARD_KACT_STRING, biosimrc.get("biosim.gcm.KACT_VALUE", ""));
	defaultParameters.put(GlobalConstants.REVERSE_KACT_STRING, "1");

		defaultParameters.put(GlobalConstants.FORWARD_KCOMPLEX_STRING, biosimrc.get("biosim.gcm.KCOMPLEX_VALUE", ""));
	defaultParameters.put(GlobalConstants.REVERSE_KCOMPLEX_STRING, "1");

		defaultParameters.put(GlobalConstants.FORWARD_RNAP_BINDING_STRING, biosimrc.get("biosim.gcm.RNAP_BINDING_VALUE", ""));
	defaultParameters.put(GlobalConstants.REVERSE_RNAP_BINDING_STRING, "1");

		defaultParameters.put(GlobalConstants.FORWARD_ACTIVATED_RNAP_BINDING_STRING, 
			biosimrc.get("biosim.gcm.ACTIVATED_RNAP_BINDING_VALUE", ""));
	defaultParameters.put(GlobalConstants.REVERSE_ACTIVATED_RNAP_BINDING_STRING, "1");

	defaultParameters.put(GlobalConstants.FORWARD_MEMDIFF_STRING, biosimrc.get("biosim.gcm.FORWARD_MEMDIFF_VALUE", ""));
	defaultParameters.put(GlobalConstants.REVERSE_MEMDIFF_STRING, biosimrc.get("biosim.gcm.REVERSE_MEMDIFF_VALUE", ""));

	defaultParameters.put(GlobalConstants.KDECAY_STRING, biosimrc.get("biosim.gcm.KDECAY_VALUE", ""));
	defaultParameters.put(GlobalConstants.KECDECAY_STRING, biosimrc.get("biosim.gcm.KECDECAY_VALUE", ""));
	defaultParameters.put(GlobalConstants.COOPERATIVITY_STRING, biosimrc.get("biosim.gcm.COOPERATIVITY_VALUE", ""));
	defaultParameters.put(GlobalConstants.RNAP_STRING, biosimrc.get("biosim.gcm.RNAP_VALUE", ""));
	defaultParameters.put(GlobalConstants.OCR_STRING, biosimrc.get("biosim.gcm.OCR_VALUE", ""));
	defaultParameters.put(GlobalConstants.KBASAL_STRING, biosimrc.get("biosim.gcm.KBASAL_VALUE", ""));
	defaultParameters.put(GlobalConstants.PROMOTER_COUNT_STRING, biosimrc.get("biosim.gcm.PROMOTER_COUNT_VALUE", ""));
	defaultParameters.put(GlobalConstants.STOICHIOMETRY_STRING, biosimrc.get("biosim.gcm.STOICHIOMETRY_VALUE", ""));
	defaultParameters.put(GlobalConstants.ACTIVATED_STRING, biosimrc.get("biosim.gcm.ACTIVED_VALUE", ""));
	defaultParameters.put(GlobalConstants.KECDIFF_STRING, biosimrc.get("biosim.gcm.KECDIFF_VALUE", ""));

	for (String s : defaultParameters.keySet()) {
		parameters.put(s, defaultParameters.get(s));
	}

}
 
Example 15
Source File: LHPNEditor.java    From iBioSim with Apache License 2.0 4 votes vote down vote up
public void viewLhpn() {
	try {
		File work = new File(directory);
		if (new File(directory + File.separator + filename).exists()) {
			String dotFile = filename.replace(".lpn", ".dot");
			File dot = new File(directory + File.separator + dotFile);
			dot.delete();
			Preferences biosimrc = Preferences.userRoot();
			String command = biosimrc.get("biosim.general.graphviz", "");
			command = command + " " + dotFile;
			Runtime exec = Runtime.getRuntime();
			lhpnFile.printDot(directory + File.separator + dotFile);
			if (dot.exists()) {
				exec.exec(command, null, work);
			} else {
				File log = new File(directory + File.separator + "atacs.log");
				BufferedReader input = new BufferedReader(new FileReader(
						log));
				String line = null;
				JTextArea messageArea = new JTextArea();
				while ((line = input.readLine()) != null) {
					messageArea.append(line);
					messageArea
							.append(System.getProperty("line.separator"));
				}
				input.close();
				messageArea.setLineWrap(true);
				messageArea.setWrapStyleWord(true);
				messageArea.setEditable(false);
				JScrollPane scrolls = new JScrollPane();
				scrolls.setMinimumSize(new Dimension(500, 500));
				scrolls.setPreferredSize(new Dimension(500, 500));
				scrolls.setViewportView(messageArea);
				JOptionPane.showMessageDialog(Gui.frame, scrolls, "Log",
						JOptionPane.INFORMATION_MESSAGE);
			}
		} else {
			JOptionPane.showMessageDialog(this,
					"No circuit has been generated yet.", "Error",
					JOptionPane.ERROR_MESSAGE);
		}
	} catch (Exception e1) {
		e1.printStackTrace();
		JOptionPane.showMessageDialog(this, "Unable to view circuit.",
				"Error", JOptionPane.ERROR_MESSAGE);
	}
}
 
Example 16
Source File: VerificationView.java    From iBioSim with Apache License 2.0 4 votes vote down vote up
/**
 * Calls the appropriate dot program to show the graph.
 * @param fileName The absolute file name.
 */
public void showGraph(String fileName)
{
	File file = new File(fileName);

	File work = file.getParentFile();
	try {
		Runtime exec = Runtime.getRuntime();
		if (new File(fileName).exists()) {

			long kB = 1024;	// number of bytes in a kilobyte.

			long fileSize = file.length()/kB; // Size of file in megabytes.

			// If the file is larger than a given amount of megabytes,
			// then give the user the chance to cancel the operation.

			int thresholdSize = 100;	// Specifies the threshold for giving the
			// user the option to not attempt to open the file.
			if(fileSize > thresholdSize)
			{
				int answer = JOptionPane.showConfirmDialog(Gui.frame,
						"The size of the file exceeds " + thresholdSize + " kB."
								+ "The file may not open. Do you want to continue?", 
								"Do you want to continue?", JOptionPane.YES_NO_OPTION);

				if(answer == JOptionPane.NO_OPTION)
				{
					return;
				}
			}
			Preferences biosimrc = Preferences.userRoot();
			String command = biosimrc.get("biosim.general.graphviz", "") + " ";
			Process dot = exec.exec(command + fileName, null, work);
			log.addText(command + fileName + "\n");
			dot.waitFor();
		} else {
			JOptionPane.showMessageDialog(Gui.frame,
					"Unable to view dot file.", "Error",
					JOptionPane.ERROR_MESSAGE);
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
Example 17
Source File: EditPreferences.java    From iBioSim with Apache License 2.0 4 votes vote down vote up
public void preferences() {
	Preferences biosimrc = Preferences.userRoot();
	if (biosimrc.get("biosim.check.undeclared", "").equals("false")) {
		checkUndeclared = false;
	}
	else {
		checkUndeclared = true;
	}
	if (biosimrc.get("biosim.check.units", "").equals("false")) {
		checkUnits = false;
	}
	else {
		checkUnits = true;
	}
	JPanel generalPrefs = generalPreferences(biosimrc);
	JPanel schematicPrefs = schematicPreferences(biosimrc);
	JPanel modelPrefs = modelPreferences(biosimrc);
	JPanel analysisPrefs = analysisPreferences(biosimrc);

	// create tabs
	JTabbedPane prefTabs = new JTabbedPane();
	if (async) prefTabs.addTab("General Preferences", generalPrefs);
	if (async) prefTabs.addTab("Schematic Preferences", schematicPrefs);
	if (async) prefTabs.addTab("Model Preferences", modelPrefs);
	if (async) prefTabs.addTab("Analysis Preferences", analysisPrefs);

	boolean problem;
	int value;
	do {
		problem = false;
		Object[] options = { "Save", "Cancel" };
		value = JOptionPane.showOptionDialog(frame, prefTabs, "Preferences", JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE, null,
				options, options[0]);

		// if user hits "save", store and/or check new data
		if (value == JOptionPane.YES_OPTION) {
			if (async) saveGeneralPreferences(biosimrc);
			if (async) problem = saveSchematicPreferences(biosimrc);
			if (async && !problem) problem = saveModelPreferences(biosimrc);
			if (async && !problem) problem = saveAnalysisPreferences(biosimrc);
			try {
				biosimrc.sync();
			}
			catch (BackingStoreException e) {
				e.printStackTrace();
			}
		}
	} while (value == JOptionPane.YES_OPTION && problem);
}
 
Example 18
Source File: NbPreferencesTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public @Override void run(final TestResult result) {
    //just do registration before code NbTestCase
    NbPreferencesFactory.doRegistration();       
    Preferences.userRoot();                        
    super.run(result);
}
 
Example 19
Source File: InstallBlenderExporterPanel.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@SuppressWarnings("unchecked")
private static String getWindowsRegistryBlenderPath() {

    final int HKEY_CURRENT_USER = 0x80000001;
    final int KEY_QUERY_VALUE = 1;
    final int KEY_SET_VALUE = 2;
    final int KEY_READ = 0x20019;

    String value = null;

    final Preferences userRoot = Preferences.userRoot();
    final Class clz = userRoot.getClass();
    try {
        Class[] parms1 = {byte[].class, int.class, int.class};
        final Method mOpenKey = clz.getDeclaredMethod("openKey",
                parms1);
        mOpenKey.setAccessible(true);

        Class[] parms2 = {int.class};
        final Method mCloseKey = clz.getDeclaredMethod("closeKey",
                parms2);
        mCloseKey.setAccessible(true);

        Class[] parms3 = {int.class, byte[].class};
        final Method mWinRegQueryValue = clz.getDeclaredMethod(
                "WindowsRegQueryValueEx", parms3);
        mWinRegQueryValue.setAccessible(true);

        Class[] parms4 = {int.class, int.class, int.class};
        final Method mWinRegEnumValue = clz.getDeclaredMethod(
                "WindowsRegEnumValue1", parms4);
        mWinRegEnumValue.setAccessible(true);

        Class[] parms5 = {int.class};
        final Method mWinRegQueryInfo = clz.getDeclaredMethod(
                "WindowsRegQueryInfoKey1", parms5);
        mWinRegQueryInfo.setAccessible(true);

        // Should be: HKEY_CURRENT_USER\Volatile Environment, key NWUSERNAME
        final String subKey = "Volatile Environment";

        Object[] objects1 = {toByteArray(subKey), new Integer(KEY_READ), new Integer(KEY_READ)};
        Integer hSettings = (Integer) mOpenKey.invoke(userRoot,
                objects1);

        Object[] objects2 = {hSettings, toByteArray("NWUSERNAME")};
        byte[] b = (byte[]) mWinRegQueryValue.invoke(userRoot,
                objects2);
        value = (b != null ? new String(b).trim() : null);
        System.out.println(value);

        Object[] objects3 = {hSettings};
        mCloseKey.invoke(Preferences.userRoot(), objects3);

    } catch (Exception e) {
        System.out.println("Error getting value Windows registry: ");
        e.printStackTrace();
    }
    return value;
}
 
Example 20
Source File: PrefsDisplayer.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
void mountBundles(Bundle[] bl) {
  if(bundlesNode != null) {
    if(bl.length == 0) {
      return;
    }
    Bundle[] bl0 = bundlesNode.getBundles();
    if(bl.length == bl0.length) {
      boolean bSame = true;
      for(int i = 0; i < bl.length; i++) {
        if(bl[i].getBundleId() != bl0[i].getBundleId()) {
          bSame = false;
        }
      }
      if(bSame) {
        return;
      }
    }
  }

  if(bundlesNode != null) {
    bundlesNode.close();
    bundlesNode = null;
  }

  rootNode = new MountedPreferences();

  Preferences sys  = Preferences.systemRoot();
  Preferences user = Preferences.userRoot();

  jvmNode = new MountedPreferences();
  jvmNode.mount((AbstractPreferences)user, "user");
  jvmNode.mount((AbstractPreferences)sys, "sys");

  rootNode.mount(jvmNode, JVM_NAME);

  boolean hasPS = psTracker.getService() != null;

  if(hasPS) {
    bundlesNode =
      new OSGiBundlesPreferences(bl != null ? bl : (new Bundle[0]));


    rootNode.mount(bundlesNode, BUNDLES_NAME);
  }

  editor.setPreferences(rootNode);

  if(hasPS) {
    editor.getJPrefsTree().searchAndExpand(BUNDLES_NAME, 3);
  }
  editor.getJPrefsTree().searchAndExpand(JVM_NAME, 3);

  editor.setPreferences(rootNode);

}