Example usage for java.util.prefs Preferences userNodeForPackage

List of usage examples for java.util.prefs Preferences userNodeForPackage

Introduction

In this page you can find the example usage for java.util.prefs Preferences userNodeForPackage.

Prototype

public static Preferences userNodeForPackage(Class<?> c) 

Source Link

Document

Returns the preference node from the calling user's preference tree that is associated (by convention) with the specified class's package.

Usage

From source file:org.domainmath.gui.MainFrame.java

/**
 * Creates Reference menus//w  w  w . j a va 2  s  .  co  m
 */
public void makeMenu() {
    try {
        Preferences pr = Preferences.userNodeForPackage(this.getClass());
        StringTokenizer t = new StringTokenizer(pr.get("Ref_list", null), "=;");

        while (t.hasMoreTokens()) {
            referenceMenu.add(new DocumentAction(t.nextToken(), t.nextToken()));
        }
    } catch (Exception ex) {
    }
}

From source file:org.domainmath.gui.MainFrame.java

public void loadPackageAuto() {
    Preferences pr2 = Preferences.userNodeForPackage(this.getClass());
    String packageList = pr2.get("DomainMath_Packages", ";");

    StringTokenizer t = new StringTokenizer(packageList, ";");

    while (t.hasMoreTokens()) {
        MainFrame.octavePanel.evaluate("pkg load " + t.nextToken());
    }//w  ww . j  a  v a 2  s  . c  o m

}

From source file:org.domainmath.gui.MainFrame.java

public void saveFrameSize(int w, int h) {
    Preferences pr2 = Preferences.userNodeForPackage(this.getClass());
    pr2.putInt("Frame_width", w);
    pr2.putInt("Frame_height", h);

}

From source file:com.mirth.connect.client.ui.Frame.java

public boolean logout(boolean quit) {
    if (!confirmLeave()) {
        return false;
    }// w  w w .  j  ava 2  s.com

    // MIRTH-3074 Remove the keyEventDispatcher to prevent memory leak.
    KeyboardFocusManager.getCurrentKeyboardFocusManager().removeKeyEventDispatcher(keyEventDispatcher);

    statusUpdaterExecutor.shutdownNow();

    if (currentContentPage == messageBrowser) {
        mirthClient.getServerConnection().abort(messageBrowser.getAbortOperations());
    }

    userPreferences = Preferences.userNodeForPackage(Mirth.class);
    userPreferences.putInt("maximizedState", getExtendedState());
    userPreferences.putInt("width", getWidth());
    userPreferences.putInt("height", getHeight());

    LoadedExtensions.getInstance().stopPlugins();

    try {
        mirthClient.logout();
        mirthClient.close();
        this.dispose();

        if (!quit) {
            LoginPanel.getInstance().initialize(PlatformUI.SERVER_URL, PlatformUI.CLIENT_VERSION, "", "");
        }
    } catch (ClientException e) {
        alertThrowable(this, e);
    }

    return true;
}

From source file:org.domainmath.gui.MainFrame.java

public void exitApp() {
    int j = fileTab.getTabCount() - 1;
    while (j != -1) {

        askSave(j);//from w w  w .j  a  va2s .  c o  m
        j--;
    }
    ShutDown shutDown = new ShutDown(this, "DomainMath IDE", "Really do you want to exit?");
    JButton yes = new JButton("Yes");
    JButton no = new JButton("No");
    JCheckBox confirmation = shutDown.getCheckBox();
    Preferences pr2 = Preferences.userNodeForPackage(this.getClass());
    boolean skipConfirmation = pr2.getBoolean("skip_confirmation", false);

    confirmation.addItemListener((ItemEvent e) -> {
        if (ItemEvent.DESELECTED == e.getStateChange()) {
            pr2.putBoolean("skip_confirmation", false);
        } else {
            pr2.putBoolean("skip_confirmation", true);
        }
    });

    yes.addActionListener((ActionEvent e) -> {
        exitFinal(shutDown);
    });
    no.addActionListener((ActionEvent e) -> {
        shutDown.dispose();
    });

    if (false == skipConfirmation) {
        shutDown.addButton(yes);
        shutDown.addButton(no);
        shutDown.setVisible(true);
    } else {
        exitFinal(shutDown);
    }
}

From source file:org.domainmath.gui.MainFrame.java

public void saveCurrentDir() {
    String s = "";
    ArrayList<String> l = new ArrayList<>();

    for (int i = 0; i < dirComboBox.getItemCount(); i++) {
        // s+=dirComboBox.getItemAt(i).toString()+File.pathSeparator;
        l.add(dirComboBox.getItemAt(i).toString());
    }/*from   w ww.j av  a2 s.  co  m*/

    if (l.contains(worksDir.getAbsolutePath())) {
        l.remove(worksDir.getAbsolutePath());
    }

    System.out.println("Directory list:" + l);

    for (String st : l) {
        s += st + File.pathSeparator;
    }
    Preferences pr2 = Preferences.userNodeForPackage(this.getClass());
    if (s != null) {
        pr2.put("DomainMath_CurrentDir", s);
        System.out.println("Saved current directory list:" + s);
    } else {
        pr2.put("DomainMath_CurrentDir", worksDir.getAbsolutePath());

    }

    pr2.put("DomainMath_StartUpDir", worksDir.getAbsolutePath());

}

From source file:org.domainmath.gui.MainFrame.java

public void setDirComboContent() {
    Preferences pr2 = Preferences.userNodeForPackage(this.getClass());
    String s = pr2.get("DomainMath_CurrentDir", "");
    ArrayList<String> l = new ArrayList<>();
    if (s != null) {
        StringTokenizer t = new StringTokenizer(s, File.pathSeparator);
        while (t.hasMoreTokens()) {

            // System.out.println(t.nextToken());
            l.add(t.nextToken());//  www.  j a v a 2s.c o  m

        }
        System.out.println("Open:" + l);

        File _f;
        for (String st : l) {
            _f = new File(st);
            if (_f.exists()) {
                addDirList(st);
            }
        }
        if (worksDir.exists()) {
            addDirList(worksDir.getAbsolutePath());
            cd(worksDir.getAbsolutePath());
        } else {
            worksDir.mkdir();
            addDirList(worksDir.getAbsolutePath());
            cd(worksDir.getAbsolutePath());
        }

    }
    //    else{
    //        addDirList(worksDir.getAbsolutePath());
    //    }

}

From source file:org.domainmath.gui.MainFrame.java

public String getSavedCurrentDir() {

    Preferences pr2 = Preferences.userNodeForPackage(this.getClass());
    return pr2.get("DomainMath_CurrentDir", null);

}

From source file:com.mirth.connect.client.ui.ChannelPanel.java

private void switchBottomPane() {
    if (LoadedExtensions.getInstance().getChannelPanelPlugins().size() > 0) {
        splitPane.setBottomComponent(tabPane);
        splitPane.setDividerSize(6);/*from   w  w w . jav  a  2s  . c  om*/
        splitPane.setDividerLocation(
                3 * Preferences.userNodeForPackage(Mirth.class).getInt("height", UIConstants.MIRTH_HEIGHT) / 5);
        splitPane.setResizeWeight(0.5);
    } else {
        splitPane.setBottomComponent(null);
        splitPane.setDividerSize(0);
    }
}

From source file:de.innovationgate.wgpublisher.WGACore.java

private void setLastCharacterEncoding(String characterEncoding) {
    Preferences prefs = Preferences.userNodeForPackage(this.getClass());
    prefs.put("LastCharacterEncoding", characterEncoding);
    prefs.putLong("CharacterEncodingModified", System.currentTimeMillis());
}