Example usage for java.util.prefs BackingStoreException toString

List of usage examples for java.util.prefs BackingStoreException toString

Introduction

In this page you can find the example usage for java.util.prefs BackingStoreException toString.

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:de.ailis.oneinstance.OneInstance.java

/**
 * Remembers an active port number in the preferences.
 * /*from w w  w  .  j  av  a 2 s. co  m*/
 * @param mainClass
 *            The main class of the application.
 * @param port
 *            The port number.
 */
private void setActivePort(Class<?> mainClass, int port) {
    Preferences prefs = Preferences.userNodeForPackage(mainClass);
    prefs.putInt(PORT_KEY, port);
    try {
        prefs.flush();
    } catch (BackingStoreException e) {
        LOG.error(e.toString(), e);
    }

}

From source file:de.ailis.oneinstance.OneInstance.java

/**
 * Unregisters this instance of the application. If this is the first
 * instance then the server is closed and the port is removed from
 * the preferences. If this is not the first instance then this method
 * does nothing.//ww w .ja  v  a  2 s. c  o m
 * 
 * This method should be called when the application exits. But it is
 * not a requirement. When you don't do this then the port number will
 * stay in the preferences so on next start of the application this port
 * number must be validated. So by calling this method on application exit
 * you just save the time for this port validation.
 * 
 * @param mainClass
 *            The main class of the application. Must not be null.
 *            This is used as the user node key for the preferences.
 */
public void unregister(Class<?> mainClass) {
    if (mainClass == null)
        throw new IllegalArgumentException("mainClass must be set");

    // Nothing to do when no server socket is present
    if (this.server == null)
        return;

    // Close the server socket
    this.server.stop();
    this.server = null;

    // Remove the port from the preferences
    Preferences prefs = Preferences.userNodeForPackage(mainClass);
    prefs.remove(PORT_KEY);
    try {
        prefs.flush();
    } catch (BackingStoreException e) {
        LOG.error(e.toString(), e);
    }
}

From source file:org.kuali.test.creator.TestCreator.java

private void loadPreferences() {
    try {/*from  ww w  .j  a v  a  2 s  .  com*/
        Preferences proot = Preferences.userRoot();
        Preferences node = proot.node(Constants.PREFS_ROOT_NODE);
        int left = node.getInt(Constants.PREFS_MAINFRAME_LEFT, Constants.MAINFRAME_DEFAULT_LEFT);
        int top = node.getInt(Constants.PREFS_MAINFRAME_TOP, Constants.MAINFRAME_DEFAULT_TOP);
        int width = node.getInt(Constants.PREFS_MAINFRAME_WIDTH, Constants.MAINFRAME_DEFAULT_WIDTH);
        int height = node.getInt(Constants.PREFS_MAINFRAME_HEIGHT, Constants.MAINFRAME_DEFAULT_HEIGHT);
        setState(node.getInt(Constants.PREFS_MAINFRAME_WINDOW_STATE, Frame.NORMAL));

        setBounds(left, top, width, height);

        node.flush();
    }

    catch (BackingStoreException ex) {
        LOG.error(ex.toString(), ex);
    }
}

From source file:org.kuali.test.creator.TestCreator.java

private void savePreferences() {
    try {/*from w w  w .  j a v a 2  s.co m*/
        Preferences proot = Preferences.userRoot();
        Preferences node = proot.node(Constants.PREFS_ROOT_NODE);

        Rectangle rect = getBounds();

        node.putInt(Constants.PREFS_MAINFRAME_LEFT, rect.x);
        node.putInt(Constants.PREFS_MAINFRAME_TOP, rect.y);
        node.putInt(Constants.PREFS_MAINFRAME_WIDTH, rect.width);
        node.putInt(Constants.PREFS_MAINFRAME_HEIGHT, rect.height);
        node.putInt(Constants.PREFS_HORIZONTAL_DIVIDER_LOCATION, hsplitPane.getDividerLocation());
        node.putInt(Constants.PREFS_VERTICAL_DIVIDER_LOCATION, vsplitPane.getDividerLocation());
        node.putInt(Constants.PREFS_MAINFRAME_WINDOW_STATE, getState());

        node.flush();
    }

    catch (BackingStoreException ex) {
        LOG.error(ex.toString(), ex);
    }

}

From source file:org.kuali.test.ui.components.dialogs.EmailDlg.java

/**
 *
 * @return//from w ww . j  a v a2  s.c om
 */
@Override
protected boolean save() {
    boolean retval = false;
    boolean oktosave = true;
    if (StringUtils.isNotBlank(mailHost.getText()) && StringUtils.isNotBlank(subject.getText())
            && StringUtils.isNotBlank(fromAddress.getText()) && StringUtils.isNotBlank(toAddresses.getText())) {
    } else {
        displayRequiredFieldsMissingAlert("Email Setup", "mail host, subject, from address, to addreses");
        oktosave = false;
    }

    if (oktosave) {
        emailSetup.setMailHost(mailHost.getText());
        emailSetup.setSubject(subject.getText());
        emailSetup.setFromAddress(fromAddress.getText());
        emailSetup.setToAddresses(toAddresses.getText());

        Preferences proot = Preferences.userRoot();
        Preferences node = proot.node(Constants.PREFS_ROOT_NODE);
        node.put(Constants.LOCAL_RUN_EMAIL, localRunAddress.getText());

        try {
            node.flush();
        } catch (BackingStoreException ex) {
            LOG.warn(ex.toString(), ex);
        }

        setSaved(true);
        getConfiguration().setModified(true);
        dispose();
        retval = true;
    }

    return retval;
}