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:net.chaosserver.timelord.swingui.Timelord.java

/**
 * Gets the annoyance mode from the perferences or returns the default.
 *
 * @return the annoyance mode/*from   ww w . j  a  va2  s  .c  o m*/
 */
public String getAnnoyanceMode() {
    Preferences preferences = Preferences.userNodeForPackage(this.getClass());

    return preferences.get(ANNOYANCE_MODE, ANNOYANCE_JORDAN);
}

From source file:com.mirth.connect.plugins.directoryresource.DirectoryResourcePropertiesPanel.java

private void initComponents() {
    setBackground(UIConstants.BACKGROUND_COLOR);
    setBorder(BorderFactory.createTitledBorder(
            BorderFactory.createMatteBorder(1, 0, 0, 0, new Color(204, 204, 204)), "Directory Settings",
            TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Tahoma", 1, 11)));

    directoryLabel = new JLabel("Directory:");

    directoryField = new MirthTextField();
    directoryField.setToolTipText("The directory to load libraries from.");

    includeSubdirectoriesCheckBox = new MirthCheckBox("Include All Subdirectories");
    includeSubdirectoriesCheckBox.setBackground(getBackground());
    includeSubdirectoriesCheckBox.setToolTipText(
            "<html>Select Yes to traverse directories recursively and search for files in each one.</html>");

    descriptionLabel = new JLabel("Description:");

    descriptionTextPane = new MirthTextPane();
    descriptionScrollPane = new JScrollPane(descriptionTextPane);

    libraryLabel = new JLabel("Loaded Libraries:");

    libraryTable = new MirthTable();
    libraryTable.setModel(new RefreshTableModel(new Object[] { "Library" }, 0));
    libraryTable.setDragEnabled(false);/* w  ww.  j  ava  2  s. co m*/
    libraryTable.setRowSelectionAllowed(false);
    libraryTable.setRowHeight(UIConstants.ROW_HEIGHT);
    libraryTable.setFocusable(false);
    libraryTable.setOpaque(true);
    libraryTable.getTableHeader().setReorderingAllowed(false);
    libraryTable.setEditable(false);
    libraryTable.setSortable(false);

    if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) {
        libraryTable.setHighlighters(HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR,
                UIConstants.BACKGROUND_COLOR));
    }

    libraryScrollPane = new JScrollPane(libraryTable);
}

From source file:com.mycompany.trafficimportfileconverter2.Main2Controller.java

/**
 * Initializes the controller class./*from ww w.jav  a2 s. c  o  m*/
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    prefs = Preferences.userNodeForPackage(this.getClass());

    initDateArrays();

    dirchooser = new DirectoryChooser();

    outputDir.addListener(new ChangeListener<File>() {
        @Override
        public void changed(ObservableValue<? extends File> observable, File oldValue, File newValue) {
            lblOutputLoc.setText(newValue.getAbsolutePath());
            prefs.put(OUTPUT_DIR_LOC, newValue.getAbsolutePath());
        }
    });
    setOutputDir(safeFileSet(new File(prefs.get(OUTPUT_DIR_LOC, "./"))));
    try {
        dirchooser.setInitialDirectory(getOutputDir());
    } catch (Exception e) {
        System.out.println("Error setting init dir: " + e);
        e.printStackTrace();
    }

    filechooser = new FileChooser();
    try {
        filechooser.setInitialDirectory(new File(prefs.get(INPUT_DIR_LOC, "./")));
    } catch (Exception e) {
        System.out.println("Error setting init directory of file chooser: " + e);
        e.printStackTrace();
    }
    setExtension(prefs.get(EXTENSION, ".gen"));

    /*
    Save in preferences default getting file location every time
    the input file is reselected.
     */
    inputFile.addListener(new ChangeListener<File>() {
        @Override
        public void changed(ObservableValue<? extends File> observable, File oldValue, File newValue) {
            lblInputFile.setText(newValue.getAbsolutePath());
            prefs.put(INPUT_DIR_LOC, newValue.getParent());
            reloadFileData(newValue);
        }
    });
    txtAreaOutput.textProperty().addListener(new ChangeListener<Object>() {
        @Override
        public void changed(ObservableValue<?> observable, Object oldValue, Object newValue) {
            txtAreaOutput.setScrollTop(Double.MAX_VALUE); //this will scroll to the bottom
            //use Double.MIN_VALUE to scroll to the top
        }
    });
    filechooser.getExtensionFilters().add(new ExtensionFilter("Tab Separated Values", "*.tsv", "*.TSV"));

    autoSearch();

    log("Help document located:");
    log(helpurl);
}

From source file:au.org.ala.delta.editor.EditorPreferences.java

/**
* Allows the supplied PreferenceChangeListener to be notified of changes made to preferences managed by this class.
* 
* @param listener/*  www  .j a  va 2 s  . co  m*/
*            the PreferenceChangeListener to add.
*/
public static void addPreferencesChangeListener(PreferenceChangeListener listener) {
    Preferences prefs = Preferences.userNodeForPackage(DeltaEditor.class);
    if (prefs != null) {
        prefs.addPreferenceChangeListener(listener);
    }
}

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

public DashboardPanel() {
    this.parent = PlatformUI.MIRTH_FRAME;

    haltableStates.add(DeployedState.DEPLOYING);
    haltableStates.add(DeployedState.UNDEPLOYING);
    haltableStates.add(DeployedState.STARTING);
    haltableStates.add(DeployedState.STOPPING);
    haltableStates.add(DeployedState.PAUSING);
    haltableStates.add(DeployedState.SYNCING);
    haltableStates.add(DeployedState.UNKNOWN);

    initComponents();/*from w  ww . j  av a2  s .c o m*/
    initLayout();

    loadTabPlugins();
    ChangeListener changeListener = new ChangeListener() {

        public void stateChanged(ChangeEvent changeEvent) {
            JTabbedPane sourceTabbedPane = (JTabbedPane) changeEvent.getSource();
            int index = sourceTabbedPane.getSelectedIndex();

            if (LoadedExtensions.getInstance().getDashboardTabPlugins().size() > 0) {
                loadPanelPlugin(LoadedExtensions.getInstance().getDashboardTabPlugins()
                        .get(sourceTabbedPane.getTitleAt(index)));
            }
        }
    };
    tabPane.addChangeListener(changeListener);

    defaultVisibleColumns = new LinkedHashSet<String>();

    makeStatusTable();
    loadTablePlugins();

    this.setDoubleBuffered(true);

    DashboardTreeTableModel model = (DashboardTreeTableModel) dashboardTable.getTreeTableModel();

    if (Preferences.userNodeForPackage(Mirth.class).getBoolean("channelGroupViewEnabled", true)) {
        tableModeGroupsButton.setSelected(true);
        tableModeGroupsButton.setContentFilled(true);
        tableModeChannelsButton.setContentFilled(false);
        model.setGroupModeEnabled(true);
    } else {
        tableModeChannelsButton.setSelected(true);
        tableModeChannelsButton.setContentFilled(true);
        tableModeGroupsButton.setContentFilled(false);
        model.setGroupModeEnabled(false);
    }
}

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

private void initOutboundReplacementTable() {
    DefaultTableModel model = new DefaultTableModel(new Object[][] {},
            new String[] { "Replace All", "Replace With" }) {
        public boolean isCellEditable(int rowIndex, int columnIndex) {
            return true;
        }//from   ww w .  j a v  a2  s  . c o  m

        @Override
        public void setValueAt(Object value, int row, int column) {
            if (!value.equals(getValueAt(row, column))) {
                parent.setSaveEnabled(true);
            }

            super.setValueAt(value, row, column);
        }
    };

    outboundReplacementTable.setSortable(false);
    outboundReplacementTable.getTableHeader().setReorderingAllowed(false);
    outboundReplacementTable.setModel(model);

    outboundReplacementTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent evt) {
            outboundDeleteButton.setEnabled(outboundReplacementTable.getSelectedRow() != -1);
        }
    });

    if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) {
        outboundReplacementTable.setHighlighters(HighlighterFactory
                .createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR));
    }

    outboundDeleteButton.setEnabled(false);
}

From source file:net.chaosserver.timelord.swingui.Timelord.java

/**
 * Sets the annoyance mode. This should be one of the constants else things
 * will behave erradically./*from  w w w .  j a va2s.  c o m*/
 *
 * @param annoyanceMode the annoyance mode
 */
public void setAnnoyanceMode(String annoyanceMode) {
    Preferences preferences = Preferences.userNodeForPackage(this.getClass());

    preferences.put(ANNOYANCE_MODE, annoyanceMode);
}

From source file:haven.Utils.java

static synchronized Preferences prefs() {
    if (prefs == null) {
        Preferences node = Preferences.userNodeForPackage(Utils.class);
        if (Config.prefspec != null)
            node = node.node(Config.prefspec);
        prefs = node;//from   w ww .  ja v  a  2  s .co m
    }
    return (prefs);
}

From source file:au.org.ala.delta.editor.EditorPreferences.java

public static void removePreferenceChangeListener(PreferenceChangeListener listener) {
    Preferences prefs = Preferences.userNodeForPackage(DeltaEditor.class);
    if (prefs != null) {
        prefs.removePreferenceChangeListener(listener);
    }//from  w  w  w  .jav  a  2s. com

}

From source file:com.alvermont.terraj.planet.ui.MainFrame.java

/** Creates new form MainFrame */
public MainFrame() {
    initComponents();//  w w  w  . ja va  2s . com

    boolean nativeLAF = true;

    try {
        prefs = Preferences.userNodeForPackage(MainFrame.class);

        nativeLAF = prefs.getBoolean(PREF_NAME_NATIVE_LAF, true);
    } catch (AccessControlException ace) {
        log.error("No access to preferences? JNLP?", ace);
    }

    if (!lafUtils.setSystemLookAndFeel(nativeLAF, this)) {
        JOptionPane.showMessageDialog(this, "Couldn't set look and feel", "Error", JOptionPane.ERROR_MESSAGE);
    }

    nativeLAFCheckbox.setSelected(nativeLAF);

    this.xmlChooser = new JNLPFileChooser(".xml");
    this.textChooser = new JNLPFileChooser(".txt");
    this.rgbChooser = new JNLPFileChooser(".rgb");

    this.params = new AllPlanetParameters();

    setListModel();

    latSpinner.setEditor(new JSpinner.NumberEditor(latSpinner, "00.000"));
    lonSpinner.setEditor(new JSpinner.NumberEditor(lonSpinner, "000.000"));
    vgridSpinner.setEditor(new JSpinner.NumberEditor(vgridSpinner, "00.000"));
    hgridSpinner.setEditor(new JSpinner.NumberEditor(hgridSpinner, "000.000"));

    // TODO: verify range of valid values for scale
    scaleSpinner.setEditor(new JSpinner.NumberEditor(scaleSpinner, "0.00"));

    seedField.setValue(0.0);
    seedField.setInputVerifier(new FormattedTextFieldVerifier());

    setComboNumericEditor(widthComboBox);
    setComboNumericEditor(heightComboBox);

    updateAllFromParameters();

    xmlChooser.addChoosableFileFilter(new XMLFileFilter());
}