Package java.util.prefs

Examples of java.util.prefs.Preferences


class StartupCrash {

    private final static String StartupKey = "StartupSuccessful";

    static void startupStarted() {
        Preferences prefs = Preferences.userRoot().node("/com/lightcrafts/app");
        prefs.putBoolean(StartupKey, false);
        try {
            prefs.sync();
        }
        catch (BackingStoreException e) {
            System.err.println("Couldn't access Preferences in StartupCrash");
            e.printStackTrace();
        }
View Full Code Here


        }
        // Just let startup continue; maybe we'll get lucky.
    }

    static void startupEnded() {
        Preferences prefs = Preferences.userRoot().node("/com/lightcrafts/app");
        prefs.putBoolean(StartupKey, true);
    }
View Full Code Here

        Preferences prefs = Preferences.userRoot().node("/com/lightcrafts/app");
        prefs.putBoolean(StartupKey, true);
    }

    static void checkLastStartupSuccessful() {
        Preferences prefs = Preferences.userRoot().node("/com/lightcrafts/app");
        boolean wasSuccessful = prefs.getBoolean(StartupKey, true);
        if (! wasSuccessful) {
            JButton help = new JButton(LOCALE.get("StartupErrorHelpOption"));
            help.addActionListener(
                new ActionListener() {
                    public void actionPerformed(ActionEvent event) {
                        showHelpDialog();
                    }
                }
            );
            JTextArea text = createText(LOCALE.get("StartupErrorMessage"));
            int option = JOptionPane.showOptionDialog(
                null,
                text,
                LOCALE.get("StartupErrorDialogTitle"),
                JOptionPane.OK_OPTION,
                JOptionPane.WARNING_MESSAGE,
                null,
                new Object[] {
                    help,
                    LOCALE.get("StartupErrorResetOption"),
                    LOCALE.get("StartupErrorDontResetOption")
                },
                LOCALE.get("StartupErrorDontResetOption")
            );
            if (option == 1) {
                text = createText(LOCALE.get("ResetWarningMajor"));
                option = JOptionPane.showOptionDialog(
                    null,
                    text,
                    LOCALE.get("ResetDialogTitle"),
                    JOptionPane.OK_CANCEL_OPTION,
                    JOptionPane.WARNING_MESSAGE,
                    null,
                    new Object[] {
                        help,
                        LOCALE.get("StartupErrorResetOption"),
                        LOCALE.get("StartupErrorDontResetOption")
                    },
                    LOCALE.get("StartupErrorDontResetOption")
                );
                if (option == 1) {
                    boolean success = true;
                    try {
                        Preferences root = Preferences.userRoot();
                        Preferences node = root.node("/com/lightcrafts");
                        node.removeNode();
                    }
                    catch (BackingStoreException e) {
                        System.err.println(
                            "StartupCrash failed to reset Preferences"
                        );
View Full Code Here

        if (option == 1) {
            boolean success = true;
            try {
                // On Linux, the license state resides in preferences.
                Object licenseState = DummyLicenseLibrary.getLicenseState();
                Preferences root = Preferences.userRoot();
                Preferences node = root.node("/com/lightcrafts");
                node.removeNode();
                node.flush();
                if (licenseState != null) {
                    DummyLicenseLibrary.setLicenseState(licenseState);
                }
            }
            catch (BackingStoreException e) {
View Full Code Here

    public FileChooser getFileChooser() {
        return new LinuxFileChooser();
    }

    public ICC_Profile getDisplayProfile() {
        Preferences prefs = Preferences.userRoot().node(
            "/com/lightcrafts/platform/linux"
        );
        String path = prefs.get("DisplayProfile", null);
        if (path != null) {
            try {
                return ICC_Profile.getInstance(path);
            }
            catch (Throwable e) {
View Full Code Here

        restoreLayout();

        // The first time this layout is used, initialize the middle split
        // pane divider (between the thumbnails and the preview area).
        String firstLayoutTag = "FirstLayout";
        Preferences prefs = Preferences.userNodeForPackage(BrowserLayout.class);
        boolean isFirstLayout = prefs.getBoolean(firstLayoutTag, true);
        if (isFirstLayout) {
            // Must enqueue, because the JSplitPane API requires the location
            // to be specified relative to the top of the component, we
            // want to specify relative to the bottom, and so we can only
            // do this after the component size has been determined.
            EventQueue.invokeLater(
                new Runnable() {
                    public void run() {
                        Dimension size = middleSplit.getSize();
                        // The number, 220, is coupled with the thumbnail
                        // size initialization in SizeSlider.
                        middleSplit.setDividerLocation(size.height - 220);
                    }
                }
            );
            prefs.putBoolean(firstLayoutTag, false);
        }
        HelpButton help = new HelpButton();
        help.setAlignmentX(1f);

        setLayout(new BorderLayout());
View Full Code Here

//    }
//  }
 
  public void refillConfigs()
  {
    final Preferences  childPrefs;
    final String[]    cfgIDs;
    Preferences      cfgPrefs;
   
    try {
      childPrefs  = audioPrefs.node( NODE_CONF );
      cfgIDs    = childPrefs.childrenNames();
      ggRecordConfig.removeAllItems();
      for( int i = 0; i < cfgIDs.length; i++ ) {
        cfgPrefs  = childPrefs.node( cfgIDs[ i ]);
        if( cfgPrefs.getInt( RoutingConfig.KEY_RC_NUMCHANNELS, -1 ) == numChannels ) {
          ggRecordConfig.addItem( new StringItem( cfgIDs[ i ], cfgPrefs.get( RoutingConfig.KEY_NAME, cfgIDs[ i ])));
        }
      }
    }
    catch( BackingStoreException e1 ) {
      System.err.println( e1.getClass().getName() + " : " + e1.getLocalizedMessage() );
View Full Code Here

 
  /*
   */
  private void initBounds()
  {
    final Preferences      cp  = getClassPrefs();
    final BasicWindowHandler  bwh  = getWindowHandler();
    final Rectangle        sr  = bwh.getWindowSpace();
    final Dimension        dt  = stringToDimension( cp.get( KEY_TRACKSIZE, null ));
    final Dimension        d  = dt == null ? new Dimension() : dt;
    final float          hf  = (float) Math.sqrt( Math.max( 1, waveView.getNumChannels() ));
    final Dimension        winSize;
    final Rectangle        wr;
    int              w  = d.width;
    int              h  = d.height;
    sr.x    += 36;
    sr.y    += 36;
    sr.width  -= 60;
    sr.height  -= 60;
    if( w <= 0 ) {
      w = sr.width*2/3 - AudioTrackRowHeader.ROW_WIDTH;
    }
    if( h <= 0 ) {
      h = (sr.height - 106) / 4; // 106 = approx. extra space for title bar, tool bar etc.
    }
//System.out.println( "read KEY_TRACKSIZE : " + d );
//System.out.println( "w " + w + "; h " + h + "; hf " + hf );
    waveView.setPreferredSize( new Dimension( w, (int) (h * hf + 0.5f) ));
    pack();
    winSize = getSize();
    wr = new Rectangle( lastLeftTop.x + 21, lastLeftTop.y + 23,
        winSize.width, winSize.height );
    GUIUtil.wrapWindowBounds( wr, sr );
    lastLeftTop.setLocation( wr.getLocation() );
    setBounds( wr );
//System.out.println( "winSize " + winSize + "; wr " + wr );
    waveView.addComponentListener( new ComponentAdapter() {
      public void componentResized( ComponentEvent e )
      {
        if( waveExpanded ) {
          final Dimension dNew = e.getComponent().getSize();
          dNew.height = (int) (dNew.height / hf + 0.5f);
          if( !dNew.equals( d )) {
//System.out.println( "write KEY_TRACKSIZE : " + dNew );
            d.setSize( dNew );
            cp.put( KEY_TRACKSIZE, AppWindow.dimensionToString( dNew ));
          }
        }
      }
    });
  }
View Full Code Here

  {
    collConfigs[ id ].clear();
    setConfigNames[ id ].clear();
    setConfigIDs[ id ].clear();
   
    final Preferences  ocPrefs    = audioPrefs.node( KEY_PREFSNODE[ id ]);
    final String[]    arrayNames;
    RoutingConfig    cfg;
    Preferences      cfgPrefs;

    try {
      arrayNames = ocPrefs.childrenNames();
//System.err.println( "Got "+arrayNames.length+" children . " );
    }
View Full Code Here

    }
  }
 
  protected boolean toPrefs( int id )
  {
    final Preferences  ocPrefs    = audioPrefs.node( KEY_PREFSNODE[ id ]);
//    final String[]    arrayNames;
    RoutingConfig    cfg;
    Preferences      cfgPrefs;
    String        cfgID;

    try {
//      arrayNames = ocPrefs.childrenNames();
//      for( int i = 0; i < arrayNames.length; i++ ) {
//        cfgPrefs = ocPrefs.node( arrayNames[ i ]);
//        cfgPrefs.removeNode();
////System.err.println( "removing "+arrayNames[ i ]);
//      }
   
      for( int i = 0; i < collConfigs[ id ].size(); i++ ) {
        cfg = (RoutingConfig) collConfigs[ id ].get( i );
        if( setDirtyConfigs[ id ].remove( cfg.id )) {
          cfgPrefs  = ocPrefs.node( cfg.id );
          cfg.toPrefs( cfgPrefs );
//System.err.println( "adding / updating "+cfg.id + " (" + cfg.name + ")" );
        }
      }
     
      for( Iterator iter = setDirtyConfigs[ id ].iterator(); iter.hasNext(); ) {
        cfgID = (String) iter.next();
        cfgPrefs = ocPrefs.node(cfgID );
        cfgPrefs.removeNode();
//System.err.println( "removing "+cfgID );
      }
     
      ocPrefs.flush();
    }
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.