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:com.mirth.connect.client.ui.attachments.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   w  w  w  .  j  a v  a  2 s  .  co  m
    };

    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:hr.fer.zemris.vhdllab.platform.gui.dialog.save.SaveDialog.java

public SaveDialog(LocalizationSource source, SaveContext context) {
    super(source);
    Validate.notNull(context, "Save variant can't be null");
    // setup label
    JLabel label = new JLabel(getMainMessage(source, context));
    int width = DIALOG_WIDTH - 2 * BORDER;
    int height = LABEL_HEIGHT - 2 * BORDER;
    label.setPreferredSize(new Dimension(width, height));
    label.setBorder(BorderFactory.createEmptyBorder(BORDER, BORDER, BORDER, BORDER));

    // setup check box list
    list = new CheckBoxList();
    width = DIALOG_WIDTH - 2 * BORDER;//from w w w . j a  v  a 2 s .c  o m
    height = 0; // because list is a center component and it doesnt need
    // height
    list.setPreferredSize(new Dimension(width, height));
    list.setBorder(BorderFactory.createEmptyBorder(BORDER, BORDER, BORDER, BORDER));

    // setup select all and deselect all buttons
    JButton selectAll = new JButton(source.getMessage(SELECT_ALL_MESSAGE));
    selectAll.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT));
    selectAll.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            list.setSelectionToAll(true);
        }
    });

    JButton deselectAll = new JButton(source.getMessage(DESELECT_ALL_MESSAGE));
    deselectAll.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT));
    deselectAll.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            list.setSelectionToAll(false);
        }
    });

    Box selectBox = Box.createHorizontalBox();
    selectBox.add(selectAll);
    selectBox.add(Box.createRigidArea(new Dimension(BORDER, BUTTON_HEIGHT)));
    selectBox.add(deselectAll);
    selectBox.setBorder(BorderFactory.createEmptyBorder(0, 0, BORDER, 0));

    // setup ok and cancel buttons
    JButton ok = new JButton(source.getMessage(OK_MESSAGE));
    ok.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT));
    ok.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            closeDialog(new ArrayList<File>());
        }
    });

    JButton cancel = new JButton(source.getMessage(CANCEL_MESSAGE));
    cancel.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT));
    cancel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            closeDialog(null);
        }
    });

    Box actionBox = Box.createHorizontalBox();
    actionBox.add(ok);
    actionBox.add(Box.createRigidArea(new Dimension(BORDER, BUTTON_HEIGHT)));
    actionBox.add(cancel);
    actionBox.setBorder(BorderFactory.createEmptyBorder(BORDER, 0, BORDER, 0));

    JPanel selectPanel = new JPanel(new BorderLayout());
    selectPanel.add(selectBox, BorderLayout.EAST);
    JPanel actionPanel = new JPanel(new BorderLayout());
    actionPanel.add(actionBox, BorderLayout.EAST);

    JCheckBox alwaysSave = new JCheckBox(source.getMessage(ALWAYS_SAVE_MESSAGE));
    alwaysSave.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JCheckBox checkBox = (JCheckBox) e.getSource();
            Preferences preferences = Preferences.userNodeForPackage(SaveDialog.class);
            preferences.putBoolean(SHOULD_AUTO_SAVE, checkBox.isSelected());
        }
    });
    alwaysSave.setSelected(false);
    JPanel alwaysSavePanel = new JPanel(new BorderLayout());
    alwaysSavePanel.add(alwaysSave, BorderLayout.WEST);

    JPanel lowerPanel = new JPanel(new BorderLayout());
    lowerPanel.add(selectPanel, BorderLayout.NORTH);
    lowerPanel.add(alwaysSavePanel, BorderLayout.CENTER);
    lowerPanel.add(actionPanel, BorderLayout.SOUTH);

    this.setLayout(new BorderLayout());
    JPanel messagePanel = new JPanel(new BorderLayout());
    messagePanel.add(label, BorderLayout.NORTH);
    messagePanel.add(list, BorderLayout.CENTER);
    messagePanel.add(lowerPanel, BorderLayout.SOUTH);
    this.getContentPane().add(messagePanel, BorderLayout.CENTER);
    this.getRootPane().setDefaultButton(ok);
    this.setPreferredSize(new Dimension(DIALOG_WIDTH, DIALOG_HEIGHT));
    this.setTitle(getTitle(source, context));
}

From source file:burlov.ultracipher.swing.SwingGuiApplication.java

private void saveWindowState() {
    Preferences prefs = Preferences.userNodeForPackage(getClass());
    prefs.putInt("size.x", mainFrame.getWidth());
    prefs.putInt("size.y", mainFrame.getHeight());
    prefs.putInt("pos.x", mainFrame.getX());
    prefs.putInt("pos.y", mainFrame.getY());
}

From source file:verdandi.ui.settings.DefaultSettingsPanel.java

@Override
public void reset() {
    Preferences prefs = Preferences.userNodeForPackage(DurationFormatter.class);
    int displayMode = prefs.getInt(DurationFormatter.PREF_DISPLAY_MODE,
            DurationFormatter.DISPLAY_DURATION_HHMM);
    if (displayMode == DurationFormatter.DISPLAY_DURATION_HHMM) {
        radioFormatHHMM.setSelected(true);
    } else {//from  www.  ja  v  a  2s  .com
        radioFormatHHQuarters.setSelected(true);
    }
    storePasswordCheckBox.setSelected(conf.isStorePasswd());
    showTimerOnStartupCheckBox.setSelected(conf.isShowTimerOnStartup());
    for (Entry<String, JTextField> pt : persistenceFields.entrySet()) {
        pt.getValue().setText(conf.getConfigProperty(pt.getKey()));
    }
    workDaySettingsPanel.reset();
}

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

public void loadTabPlugins() {
    if (LoadedExtensions.getInstance().getDashboardTabPlugins().size() > 0) {
        for (DashboardTabPlugin plugin : LoadedExtensions.getInstance().getDashboardTabPlugins().values()) {
            if (plugin.getTabComponent() != null) {
                tabPane.addTab(plugin.getPluginPointName(), plugin.getTabComponent());
            }//from   w ww.jav a  2s .co m
        }

        splitPane.setBottomComponent(tabPane);
        splitPane.setDividerSize(6);
        splitPane.setDividerLocation(
                3 * Preferences.userNodeForPackage(Mirth.class).getInt("height", UIConstants.MIRTH_HEIGHT) / 5);
        splitPane.setResizeWeight(0.5);
    }
}

From source file:burlov.ultracipher.swing.SwingGuiApplication.java

private void restoreWindowState() {
    Preferences prefs = Preferences.userNodeForPackage(getClass());
    mainFrame.setSize(prefs.getInt("size.x", 600), prefs.getInt("size.y", 400));
    mainFrame.setLocationRelativeTo(null);
    mainFrame.setLocation(prefs.getInt("pos.x", 100), prefs.getInt("pos.y", 100));

}

From source file:org.apache.pdfbox.pdmodel.font.FileSystemFontProvider.java

private void saveCache() {
    // Get the preferences database for this package.
    Preferences prefs = Preferences.userNodeForPackage(FileSystemFontProvider.class);

    // To save, write the object to a byte array.
    try {//  w ww  . ja va  2  s  .c  om
        for (FSFontInfo fontInfo : fontInfoList) {
            ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
            ObjectOutputStream objectOut = new ObjectOutputStream(byteOut);
            // write it to the stream
            objectOut.writeObject(fontInfo);
            prefs.putByteArray(fontInfo.file.getAbsolutePath(), byteOut.toByteArray());
        }
    } catch (IOException e) {
        LOG.error("Could not write to font cache", e);
    }
    LOG.warn("Finished building font cache, found " + fontInfoList.size() + " fonts");
}

From source file:codeswarm.ui.MainView.java

/**
 * gets called when the user presses the "Go"-Button.<br />
 * It manages fetching the repository entries and serving it to
 * {@link code_swarm}. It starts code_swarm after fetching the repository
 * entries./*from w w w  .ja v a  2 s  .com*/
 * @param evt The ActionEvent from Swing
 */
private void goButtonActionPerformed(/*java.awt.event.ActionEvent evt*/) {//GEN-FIRST:event_goButtonActionPerformed
    Runnable run = new Runnable() {
        public void run() {
            goButton.setEnabled(false);
            clearCache.setEnabled(false);
            Preferences p = Preferences.userNodeForPackage(MainView.class);
            String username = userName.getText();
            String passwd = String.valueOf(password.getPassword());
            String url = repositoryURL.getText();
            p.put("username", username);
            p.put("repositoryURL", url);
            SVNHistory hist = new SVNHistory("realtime_sample");
            hist.run(url, username, passwd);
            try {
                CodeSwarmConfig cfg = new CodeSwarmConfig(args[0]);
                cfg.setInputFile(hist.getFilePath());
                code_swarm.start(cfg);
                dispose();
            } catch (IOException e) {
                System.err.println("Failed due to exception: " + e.getMessage());
                goButton.setEnabled(true);
                clearCache.setEnabled(true);
            }
        }
    };
    new Thread(run).start();
}

From source file:smarthome.FXMLDocumentController.java

public void getPreference() {
    Preferences prefs = Preferences.userNodeForPackage(SmartHome.class);
    ipaddress = prefs.get("ipaddress", null);
    videoLink = prefs.get("videolink", null);
    voiceFlag = prefs.get("voiceflag", null);
}

From source file:com.devbury.mkremote.server.QuickLaunchServiceImpl.java

protected Preferences findPreferences() {
    return Preferences.userNodeForPackage(getClass());
}