Package java.util.prefs

Examples of java.util.prefs.Preferences


        p.setNote("Done.");
        p.setProgress(++progress);
    }

    private InputStream getLMSTemplate() throws IOException {
        Preferences userPrefs = Preferences.userNodeForPackage(CourseBuilder.class);
        if (userPrefs.getBoolean("courseBuilder.useInternalTemplate", true)) {
            return getClass().getResourceAsStream("/lmshtml.zip");
        } else {
            return new FileInputStream(userPrefs.get("courseBuilder.externalTemplate", ""));
        }
    }
View Full Code Here


  if (g.error()) {    // Any bad command line argument?
    usage(null);    // If so, whine and exit
  }

  // Get user's preferences, if any.
  Preferences prefs = Preferences.userRoot().node("/jimm/datavision");

  // Set look & feel.
  try {
    javax.swing.UIManager.setLookAndFeel(javax.swing.UIManager.getSystemLookAndFeelClassName());
  } catch (Exception e) {
    // Default L&F will be used if any problems occur, most probably,
    // ClassNotFound.
  }

    DataVision dv = new DataVision();

    // Language
    if (g.hasOption('g') || g.hasOption('i'))
  I18N.setLanguage(new Locale(g.option('g', "").toLowerCase(),
            g.option('i', "").toUpperCase()));

    dv.layoutEngineChoiceFromOptions(g);
    dv.dataSourceFromOptions(g);

    if (dv.hasLayoutEngine()) {
  if (dv.usesGUI())  // Can ask for password via GUI
      ErrorHandler.useGUI(true);
  else if (!g.hasOption('n') && !g.hasOption('p') && !g.hasOption('e'))
      usage(I18N.get("DataVision.n_or_p"));
    }

    dv.paramXMLFile = g.option('r', null); // Parameter XML file name or null
    dv.reportDir = g.option('R', null); // Report Directory or null
    dv.outputDir = g.option('o', null); // Output Directory or null

    // Store the report directory in the preferences for this package
    // These values are stored in the root package jimm.datavision
    if (dv.reportDir != null) {
        prefs.put("reportDir",dv.reportDir);
    }
    if (dv.outputDir != null) {
        prefs.put("outputDir",dv.outputDir);
    }

    if (g.argc() == 0) {
  if (startupDialog())  // Returns true if we should exit
      return;
View Full Code Here

  /**
   * Creates user preferences read from Java preferences.
   */
  public FileFurnitureLibraryUserPreferences() {
    Preferences preferences = getPreferences();
    setLanguage(preferences.get(LANGUAGE, getLanguage()));   
    setUnit(LengthUnit.valueOf(preferences.get(UNIT, getLengthUnit().name())));
    setDefaultCreator(preferences.get(DEFAULT_CREATOR, getDefaultCreator()));
    boolean offlineFurnitureLibrary = preferences.getBoolean(OFFLINE_FURNITURE_LIBRARY, isFurnitureLibraryOffline());
    if (isOnlineFurnitureLibrarySupported()) {
      setFurnitureLibraryOffline(offlineFurnitureLibrary);
      setFurnitureResourcesLocalDirectory(preferences.get(FURNITURE_RESOURCES_LOCAL_DIRECTORY,
          getFurnitureResourcesLocalDirectory()));
      setFurnitureResourcesRemoteURLBase(preferences.get(FURNITURE_RESOURCES_REMOTE_URL_BASE,
          getFurnitureResourcesRemoteURLBase()));
    }
  }
View Full Code Here

    }
  }
 
  @Override
  public void write() throws RecorderException {
    Preferences preferences = getPreferences();
    preferences.put(LANGUAGE, getLanguage());
    preferences.put(UNIT, getLengthUnit().name());  
    if (getDefaultCreator() != null) {
      preferences.put(DEFAULT_CREATOR, getDefaultCreator());
    } else {
      preferences.remove(DEFAULT_CREATOR);
    }
    preferences.putBoolean(OFFLINE_FURNITURE_LIBRARY, isFurnitureLibraryOffline());
    if (getFurnitureResourcesLocalDirectory() != null) {
      preferences.put(FURNITURE_RESOURCES_LOCAL_DIRECTORY, getFurnitureResourcesLocalDirectory());
    } else {
      preferences.remove(FURNITURE_RESOURCES_LOCAL_DIRECTORY);
    }
    if (getFurnitureResourcesRemoteURLBase() != null) {
      preferences.put(FURNITURE_RESOURCES_REMOTE_URL_BASE, getFurnitureResourcesRemoteURLBase());
    } else {
      preferences.remove(FURNITURE_RESOURCES_REMOTE_URL_BASE);
    }
   
    try {
      // Write preferences
      preferences.sync();
    } catch (BackingStoreException ex) {
      throw new RecorderException("Couldn't write preferences", ex);
    }
  }
View Full Code Here

    String ac = ae.getActionCommand();

    // Set the starting report directory (null is default home directory)
    // Store the report directory in the preferences for this package
    Preferences prefs = Preferences.userRoot().node("/jimm/datavision");
    String reportDir = prefs.get("reportDir", null);
    System.out.println("reportDir(1) = " + reportDir);

    // Open an existing report
    if (ac.equalsIgnoreCase(I18N.get("StartupDialog.open"))) {
      JFileChooser jfc = new JFileChooser();
      if (reportDir != null) {
        jfc.setCurrentDirectory(new File(reportDir));
      }
      jfc.setMultiSelectionEnabled(false);
      int rv = jfc.showOpenDialog(this);
      if (rv == JFileChooser.APPROVE_OPTION) {
        selectedFile = jfc.getSelectedFile().getPath();
        // If the file path has changed then store it in the preferences
        String jfcap = jfc.getSelectedFile().getAbsolutePath();
        if (jfcap != null) {
          File f = new File(jfcap);
          String newReportDir = f.getParent();
          if (newReportDir == null) {
            newReportDir = reportDir;
          }
          if (newReportDir != null) {
            boolean changed = true;
            if (reportDir != null && newReportDir.compareTo(reportDir) == 0) {
              changed = false;
            }
            if (changed) {
              prefs.put("reportDir", newReportDir);
            }
          }
        }
        dispose();
      }
View Full Code Here

    // Set the starting report directory (null is default home directory)
    // Store the report directory in the preferences for this package
    if (jfc != null) {
        if (key == null || key.trim().equals(""))
            key="reportDir";
        Preferences prefs = Preferences.userRoot().node("/jimm/datavision");
        String dir = prefs.get(key,null);
        if (dir != null)
            jfc.setCurrentDirectory(new File(dir));
    }
}
View Full Code Here

    if (jfc != null) {
        if (key == null || key.trim().equals(""))
            key="reportDir";
        String selectedFile = jfc.getSelectedFile().getPath();
        if (selectedFile != null) {
            Preferences prefs = Preferences.userRoot().node("/jimm/datavision");
            String dir = prefs.get(key,null);
            // If the file path has changed then store it in the
            // preferences
            String jfcap=jfc.getSelectedFile().getAbsolutePath();
            if (jfcap != null) {
                File f=new File(jfcap);
                String newdir=f.getParent();
                if (newdir == null)
                    newdir=dir;
                if (newdir != null) {
                    boolean changed=true;
                    if (dir != null && newdir.compareTo(dir) == 0)
                        changed=false;
                    if (changed)
                        prefs.put(key,newdir);
                }
            }
        }
    }
}
View Full Code Here

    }

    try
    {
      final Enumeration keys = config.getConfigProperties();
      final Preferences pref = base.node(configPath);
      pref.clear();
      while (keys.hasMoreElements())
      {
        final String key = (String) keys.nextElement();
        final String value = config.getConfigProperty(key);
        if (value != null)
        {
          pref.put(key, value);
        }
      }
      pref.sync();
    }
    catch (BackingStoreException be)
    {
      throw new ConfigStoreException("Failed to store config" + configPath, be);
    }
View Full Code Here

    }

    try
    {
      final Properties props = new Properties();
      final Preferences pref = base.node(configPath);
      final String[] keysArray = pref.keys();
      for (int i = 0; i < keysArray.length; i++)
      {
        final String key = keysArray[i];
        final String value = pref.get(key, null);
        if (value != null)
        {
          props.setProperty(key, value);
        }
      }
View Full Code Here

   public static void main(String[] args) {
      try {
         System.setProperty("java.util.logging.config.file", "testlog.properties");
         LogManager.getLogManager().readConfiguration();

         Preferences prefs = loadArgs(args);
        
         DbWriterExample example = new DbWriterExample();
         example.pollingExample(prefs);
      }
      catch (Throwable e) {
View Full Code Here

TOP

Related Classes of java.util.prefs.Preferences

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.