Package java.util.prefs

Examples of java.util.prefs.Preferences


  public static List createDefaults( Preferences mainPrefs, double lastVersion )
  {
    File      f;
    String      value;
    Preferences    childPrefs, childPrefs2;
    final String  fs      = File.separator;
    final boolean  isMacOS    = System.getProperty( "os.name" ).indexOf( "Mac OS" ) >= 0;
        final boolean  isWindows  = System.getProperty( "os.name" ).indexOf( "Windows" ) >= 0;
    final List    warnings  = new ArrayList();
 
    putDontOverwrite( IOUtil.getUserPrefs(), IOUtil.KEY_TEMPDIR, System.getProperty( "java.io.tmpdir" ));

    // general
    putDontOverwrite( mainPrefs, KEY_LOOKANDFEEL, UIManager.getSystemLookAndFeelClassName() );
    putBooleanDontOverwrite( mainPrefs, CoverGrowBox.KEY_INTRUDINGSIZE, isMacOS );
    putBooleanDontOverwrite( mainPrefs, KEY_INSERTIONFOLLOWSPLAY, true );
    putBooleanDontOverwrite( mainPrefs, KEY_VIEWCHANMETERS , true );
    putBooleanDontOverwrite( mainPrefs, KEY_VIEWMARKERS , true );
    putBooleanDontOverwrite( mainPrefs, KEY_VIEWNULLLINIE , true );
    putBooleanDontOverwrite( mainPrefs, KEY_VIEWVERTICALRULERS, true );
    putBooleanDontOverwrite( mainPrefs, KEY_CATCH, true );
   
    putIntDontOverwrite( mainPrefs, KEY_TIMEUNITS, TIME_MINSECS );
    putIntDontOverwrite( mainPrefs, KEY_VERTSCALE, VSCALE_AMP_LIN );

    // audio
    childPrefs  = mainPrefs.node( NODE_AUDIO );
    childPrefs.remove( "boottimeout" );    // not used any more
    childPrefs.remove( "audiodevice" );    // not used any more
    childPrefs.remove( "audioinputs" );    // not used any more
    childPrefs.remove( "audiooutputs" )// not used any more

        putDontOverwrite( childPrefs, KEY_AUTOPLAYFROMFINDER, AUTOPLAYFROMFINDER_NONE );

    // audioboxes
    value = AudioBoxConfig.ID_DEFAULT;
    putDontOverwrite( childPrefs, KEY_AUDIOBOX, value );
    try {
      if( !childPrefs.nodeExists( NODE_AUDIOBOXES )) {
        childPrefs2  = childPrefs.node( NODE_AUDIOBOXES );
        new AudioBoxConfig( value, "Default", 8, 8, true ).toPrefs( childPrefs2.node( value ));
      }
    }
    catch( BackingStoreException e1 ) {
      warnings.add( e1.toString() );
    }

    putDontOverwrite( childPrefs, KEY_AUDIORATE, new Param( 0, ParamSpace.FREQ | ParamSpace.HERTZ ).toString() );
    putDontOverwrite( childPrefs, KEY_AUDIOBUSSES, new Param( 256, ParamSpace.NONE ).toString() );
    putDontOverwrite( childPrefs, KEY_SCMEMSIZE, new Param( 8, ParamSpace.NONE ).toString() );
    putDontOverwrite( childPrefs, KEY_SCBLOCKSIZE, new Param( 64, ParamSpace.NONE ).toString() );
    putBooleanDontOverwrite( childPrefs, KEY_SCRENDEZVOUS, true );
//    putBooleanDontOverwrite( childPrefs, KEY_AUTOBOOT, false );

    // outputconfigs
    value = "out1to2";
    putDontOverwrite( childPrefs, KEY_OUTPUTCONFIG, value );
    try {
      if( !childPrefs.nodeExists( NODE_OUTPUTCONFIGS )) {
        childPrefs2 = childPrefs.node( NODE_OUTPUTCONFIGS );
        new RoutingConfig( value, "Out 1-2", new int[] { 0, 1 }, -90f ).toPrefs(
          childPrefs2.node( value ));
        value = "out1to8";
        new RoutingConfig( value, "Out 1-8", new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }, -45f ).toPrefs(
          childPrefs2.node( value ));
//        // ok dis wan is rather for demonstration purpose
//        new RoutingConfig( value, 2, new int[] { 1, 0 }, -90f ).toPrefs(
//          childPrefs2.node( "Reversed Stereo" ));
      }
    }
    catch( BackingStoreException e1 ) {
      warnings.add( e1.toString() );
    }

    // inputconfigs
    try {
      if( !childPrefs.nodeExists( NODE_INPUTCONFIGS )) {
        childPrefs2 = childPrefs.node( NODE_INPUTCONFIGS );
        value = "in1";
        new RoutingConfig( value, "In 1", new int[] { 0 }, 0f ).toPrefs(
          childPrefs2.node( value ));
        value = "in1to2";
        new RoutingConfig( value, "In 1-2", new int[] { 0, 1 }, 0f ).toPrefs(
          childPrefs2.node( value ));
        value = "in1to8";
        new RoutingConfig( value, "In 1-8", new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }, 0f ).toPrefs(
          childPrefs2.node( value ));
//        // ok dis wan is rather for demonstration purpose
//        new RoutingConfig( value, 2, new int[] { 1, 0 }, -90f ).toPrefs(
//          childPrefs2.node( "Reversed Stereo" ));
      }
    }
    catch( BackingStoreException e1 ) {
      warnings.add( e1.toString() );
    }

//    try {
//      value   = InetAddress.getLocalHost().getHostName() + ":57110";
//    }
//    catch( IOException e1 ) {
//      System.err.println( e1.toString() );
//      value   = "127.0.0.1:57109";  // not 57110 which may interfere with a running copy of sclang
//    }
//    putDontOverwrite( childPrefs, KEY_SUPERCOLLIDEROSC, value );
    putDontOverwrite( childPrefs, KEY_SCPROTOCOL, OSCChannel.TCP );
    putDontOverwrite( childPrefs, KEY_SCPORT, new Param( 0, ParamSpace.NONE | ParamSpace.ABS ).toString() );
   
    // sc app
    if( childPrefs.get( KEY_SUPERCOLLIDERAPP, null ) == null ) {
      f  = findFile( isWindows ? "scsynth.exe" : "scsynth", new String[] {
        fs + "Applications" + fs + "SuperCollider_f",
        fs + "Applications" + fs + "SuperCollider",
        fs + "usr" + fs + "local" + fs + "bin",
        fs + "usr" + fs + "bin",
        "C:\\Program Files\\SuperCollider_f",
        "C:\\Program Files\\PsyCollider"
      });
      if( f == null ) {
        if( isMacOS ) {
          try {
            f = MRJAdapter.findApplication( "SCjm" );
            if( f != null ) f = new File( f.getParentFile(), "scsynth" );
          }
          catch( IOException e1 ) { /* ignore */ }
        }
        if( f == null ) {
          warnings.add( AbstractApplication.getApplication().getResourceString( "errSCSynthAppNotFound" ));
        }
      }
      if( f != null ) putDontOverwrite( childPrefs, KEY_SUPERCOLLIDERAPP, f.getAbsolutePath() );
    }

    value = childPrefs.get( KEY_SUPERCOLLIDERAPP, null );
    putBooleanDontOverwrite( childPrefs, KEY_AUTOBOOT, (value != null) && new File( value ).isFile() );

    // OSC
    childPrefs  = OSCRoot.getInstance().getPreferences();
    if( childPrefs.get( OSCGUI.KEY_SWINGAPP, null ) == null ) {
      final String[] folders = new String[ value == null ? 2 : 4 ];
      folders[ 0 ] = fs + "Applications" + fs + "SwingOSC";
      folders[ 1 ] = "C:\\Program Files\\SwingOSC";
      if( value != null ) {
        folders[ 2 ] = new File( value ).getParentFile().getAbsolutePath();
        folders[ 3 ] = new File( new File( new File( value ).getParentFile(), "SwingOSC" ), "build" ).getAbsolutePath();
      }
      f  = findFile( "SwingOSC.jar", folders );
//      if( f == null ) {
//        warnings.add( AbstractApplication.getApplication().getResourceString( "errSCSynthAppNotFound" ));
//      }
      if( f != null ) putDontOverwrite( childPrefs, OSCGUI.KEY_SWINGAPP, f.getAbsolutePath() );
    }
   
    // view
    childPrefs  = mainPrefs.node( NODE_VIEW );
    try {
      if( !childPrefs.nodeExists( NODE_SONAGRAM )) {
        childPrefs2 = childPrefs.node( NODE_SONAGRAM );
        new ConstQ().writePrefs( childPrefs2 );
      }
    }
    catch( BackingStoreException e1 ) {
      warnings.add( e1.toString() );
View Full Code Here


    if( instance != null ) throw new IllegalStateException( "Only one instance allowed" );
    instance  = this;
 
    final Application        app      = AbstractApplication.getApplication();
    final Preferences        userPrefs  = app.getUserPrefs();
    final PreferenceChangeListener  oCfgListener;

    audioPrefs        = userPrefs.node( PrefsUtil.NODE_AUDIO );
    so            = new ServerOptions();
    so.setBlockAllocFactory( new ContiguousBlockAllocator.Factory() )// deals better with fragmentation
   
    oCfgListener = new PreferenceChangeListener() {
      public void preferenceChange( PreferenceChangeEvent e )
View Full Code Here

  protected void outputConfigChanged()
  {
    SuperColliderPlayer p;
   
    final String    cfgID    = audioPrefs.get( PrefsUtil.KEY_OUTPUTCONFIG, null );
    final Preferences  childPrefs  = audioPrefs.node( PrefsUtil.NODE_OUTPUTCONFIGS );
    RoutingConfig    newCfg    = null;

//    oCfg = null;
   
    if( oCfgNode != null ) {
      oCfgDynPrefs.stopListening();
      oCfgDynPrefs.setPreferences( null );
      oCfgNode = null;
    }

    try {
      if( (cfgID != null) && childPrefs.nodeExists( cfgID )) {
        oCfgNode  = childPrefs.node( cfgID );
        newCfg    = new RoutingConfig( oCfgNode );
//        oCfgNode.addPreferenceChangeListener( oCfgListener );
        oCfgDynPrefs.setPreferences( oCfgNode );
        oCfgDynPrefs.startListening();
      }
View Full Code Here

  public Main( String[] args )
  {
    super( Main.class, APP_NAME );

    final List          warnings;
    final Preferences      prefs      = getUserPrefs();
    final double        prefsVersion;
//    final ObserverPalette    frameObserver;
//    final ControlRoomFrame    paletteCtrlRoom;
    final MainFrame        mainFrame;
//    final CacheManager      cacheManager;
    final OSCRoot        oscServer;
    final SuperColliderClient  superCollider;
    String            lafName;
    List            openDoc      = null;

    // ---- init prefs ----

    oscServer      = new OSCRoot( prefs.node( OSCRoot.DEFAULT_NODE ), 0x4549 );
    prefsVersion = prefs.getDouble( PrefsUtil.KEY_VERSION, 0.0 );
    if( prefsVersion < APP_VERSION ) {
      warnings = PrefsUtil.createDefaults( prefs, prefsVersion );
    } else {
      warnings = null;
    }
   
    // ---- check commandline options ----

        // WebLookAndFeel.install();
        // System.out.println(UIManager.getLookAndFeel().getName());
        UIManager.installLookAndFeel("WebLookAndFeel", "com.alee.laf.WebLookAndFeel");
        WebCheckBoxStyle   .animated            = false;
        WebProgressBarStyle.progressTopColor    = Color.lightGray;
        WebProgressBarStyle.progressBottomColor = Color.gray;
        // XXX TODO: how to really turn of animation?
        WebProgressBarStyle.highlightWhite      = new Color(255, 255, 255, 0); // 48)
        WebProgressBarStyle.highlightDarkWhite  = new Color(255, 255, 255, 0);

    lafName = prefs.get( PrefsUtil.KEY_LOOKANDFEEL, null );
    for( int i = 0; i < args.length; i++ ) {
      if( args[ i ].startsWith( "-" )) {
        if( args[ i ].equals( "-laf" )) {
          if( (i + 2) < args.length ) {
            UIManager.installLookAndFeel( args[ i + 1 ], args[ i + 2 ]);
            if( lafName == null ) lafName = args[ i + 2 ];
            i += 2;
          } else {
            System.err.println( "Option -laf requires two additional arguments (screen-name and class-name)." );
            System.exit( 1 );
          }
        } else {
          System.err.println( "Unknown option " + args[ i ]);
          System.exit( 1 );
        }
      } else {
        if( openDoc == null ) openDoc = new ArrayList();
        openDoc.add( args[ i ]);
      }
    }
       
    // ---- init look-and-feel ----

    System.setProperty( "swing.aatext", "true" );
    lookAndFeelUpdate( lafName );

//    JFrame.setDefaultLookAndFeelDecorated( true );

    // ---- init infrastructure ----
    // warning : reihenfolge is crucial
//    oscServer      = new OSCRoot( prefs.node( OSCRoot.DEFAULT_NODE ), 0x4549 );
    osc          = new OSCRouterWrapper( oscServer, this );
    final CacheManager cache = new PrefCacheManager( prefs.node( PrefCacheManager.DEFAULT_NODE ));
    superCollider    = new SuperColliderClient();

    init();
   
    // ---- listeners ----

    quitAfterSaveListener = new ProcessingThread.Listener() {
      public void processStarted( ProcessingThread.Event e ) { /* empty */ }

      // if the saving was successfull, we will call closeAll again
      public void processStopped( ProcessingThread.Event e )
      {
        if( e.isDone() ) {
          quit();
        }
      }
    };

    try {
      superCollider.init();
    }
    catch( IOException e1 ) {
      BasicWindowHandler.showErrorDialog( null, e1, "SuperColliderClient Initialization" );
      System.exit( 1 );
      return;
    }

//    scPlugInManager    = new SCPlugInManager( this );

    // ---- component views ----

    mainFrame    = new MainFrame();
    ((BasicWindowHandler) getWindowHandler()).setDefaultBorrower( mainFrame );
    final AppWindow ctrlRoom  = new ControlRoomFrame();
    final AppWindow observer  = new ObserverPalette();

    // means no preferences found, so
    // do some more default initializations
    // and display splash screen
    if( prefsVersion == 0.0 ) {
      ctrlRoom.setVisible( true );
      observer.setVisible( true );
      if( cache.getFolder().isDirectory() ) {
        cache.setActive( true );
      }
        new WelcomeScreen( this );
    }

    if( warnings != null ) {
      for( int i = 0; i < warnings.size(); i++ ) {
        System.err.println( warnings.get( i ));
      }
    }

    oscServer.init();
   
    if( prefs.node( PrefsUtil.NODE_AUDIO ).getBoolean( PrefsUtil.KEY_AUTOBOOT, false )) {
      superCollider.boot();
    }
   
//    de.sciss.gui.MultiStateButton.makeTestFrame( javax.swing.SwingConstants.CENTER, javax.swing.SwingConstants.CENTER );
   
View Full Code Here

    this.fullScale  = fullScale;
    this.model    = model;

    constQ      = new ConstQ();
   
    final Preferences cqPrefs = AbstractApplication.getApplication().getUserPrefs().node( PrefsUtil.NODE_VIEW ).node( PrefsUtil.NODE_SONAGRAM );
    constQ.readPrefs( cqPrefs );
    constQ.setSampleRate( fullScale.getRate() );
    System.out.println( "Creating ConstQ Kernels..." );
    constQ.createKernels();
    numKernels    = constQ.getNumKernels();
View Full Code Here

    static String cachedPreferences(String productName) {
        // ~/Library/Preferences/com.apple.java.util.prefs.plist
        // .java/.userPrefs/com/google/gwt/dev/shell/prefs.xml
        // HKEY_CURRENT_USER\SOFTWARE\JavaSoft\Prefs
        Preferences p = Preferences.userNodeForPackage(CvalInfo.class);
        return p.get(productName, null);
    }
View Full Code Here

    /*
     * used in tests
     */
    static void cacheLicenseInfo(CvalInfo info) {
        if (info != null) {
            Preferences p = Preferences.userNodeForPackage(CvalInfo.class);
            if (info.toString().length() > Preferences.MAX_VALUE_LENGTH) {
                // This should never happen since MAX_VALUE_LENGTH is big
                // enough.
                // But server could eventually send a very big message, so we
                // discard it in cache and would use hard-coded messages.
                info.setMessage(null);
            }
            p.put(info.getProduct().getName(), info.toString());
        }
    }
View Full Code Here

    /*
     * used in tests
     */
    static void deleteCache(String productName) {
        Preferences p = Preferences.userNodeForPackage(CvalInfo.class);
        p.remove(productName);
    }
View Full Code Here

        }
        return info;
    }

    private CvalInfo getCachedLicenseInfo(String productName) {
        Preferences p = Preferences.userNodeForPackage(CvalInfo.class);
        String json = p.get(productName, "");
        if (!json.isEmpty()) {
            CvalInfo info = parseJson(json);
            if (info != null) {
                return info;
            }
View Full Code Here

        }
    }

    private void initFromPrefs() {

        Preferences prefs = Preferences.userNodeForPackage(ConnectDialog.class);

        usernameTextField.setText(prefs.get("username", System.getProperty("user.name")));
        portSpinnerModel.setValue(prefs.getInt("port", 1025));
        hostTextField.setText(prefs.get("host", ""));

        caTopTextField.setText(prefs.get("caTop", System.getProperty("com.sun.grid.jgdi.caTop")));
        keyStoreTextField.setText(prefs.get("keyStore", System.getProperty("com.sun.grid.jgdi.keyStore")));
    }
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.