Example usage for java.util.prefs Preferences get

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

Introduction

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

Prototype

public abstract String get(String key, String def);

Source Link

Document

Returns the value associated with the specified key in this preference node.

Usage

From source file:org.javaswift.cloudie.login.CredentialsStore.java

/**
 * converts a preferences node to credentials.
 * @param node the node./*from w ww .  ja  v  a  2 s  .  c  om*/
 * @return the credentials.
 */
private Credentials toCredentials(Preferences node) {
    Credentials cr = new Credentials();
    cr.method = AuthenticationMethod.valueOf(node.get("method", AuthenticationMethod.KEYSTONE.name()));
    cr.authUrl = node.get("authUrl", "");
    cr.tenantName = node.get("tenantName", "");
    cr.tenantId = node.get("tenantId", "");
    cr.username = node.get("username", "");
    cr.password = garble(node.get("password", ""));
    return cr;
}

From source file:com.esri.geoevent.test.performance.ui.ProducerController.java

@Override
protected void loadState() {
    Preferences preferences = Preferences.userNodeForPackage(ProducerController.class);
    Protocol selectedProtocol = Protocol.fromValue(preferences.get("protocol", Protocol.TCP.toString()));
    int portNumber = NumberUtils.toInt(preferences.get("port", String.valueOf(DEFAULT_COMMAND_PORT)));
    int serverPortNumber = NumberUtils
            .toInt(preferences.get("serverPort", String.valueOf(DEFAULT_SERVER_PORT)));

    protocol.setValue(selectedProtocol);
    port.setText(String.valueOf(portNumber));
    serverPort.setText(String.valueOf(serverPortNumber));
}

From source file:org.pdfsam.ui.PreferencesRecentWorkspacesService.java

private void populateCache() {
    Preferences prefs = Preferences.userRoot().node(WORKSPACES_PATH);
    try {//from   w  w  w . j  a  va 2s  . com
        Arrays.stream(prefs.keys()).sorted().forEach(k -> {
            String currentValue = prefs.get(k, EMPTY);
            if (isNotBlank(currentValue)) {
                cache.put(currentValue, k);
            }
        });
    } catch (BackingStoreException e) {
        LOG.error("Error retrieving recently used workspaces", e);
    }
}

From source file:edu.umich.robot.ViewerApplication.java

public ViewerApplication(String[] args) {
    JPopupMenu.setDefaultLightWeightPopupEnabled(false);
    ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);

    Config config = (args.length > 0) ? ConfigUtil.getDefaultConfig(args) : promptForConfig();
    if (config == null)
        System.exit(1);//from  www .  j  a va2 s . c o m

    setupViewerConfig(config);
    viewer = new Viewer(config);
    viewer.getVisCanvas().getViewManager().setInterfaceMode(3);

    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosed(WindowEvent e) {
            frame.dispose();

            try {
                Thread.sleep(500);
            } catch (InterruptedException ignored) {
            }
            System.exit(0); // No way to shut down april threads
        }
    });
    frame.setLayout(new BorderLayout());

    viewerView = new ViewerView(viewer.getVisCanvas());

    // TODO SoarApril
    // viewer.getVisCanvas().setDrawGround(true);

    frame.add(viewerView, BorderLayout.CENTER);

    Preferences windowPrefs = getWindowPreferences();
    if (windowPrefs.get("x", null) != null) {
        frame.setBounds(windowPrefs.getInt("x", 0), windowPrefs.getInt("y", 0),
                windowPrefs.getInt("width", 800), windowPrefs.getInt("height", 800));
    } else {
        frame.setBounds(windowPrefs.getInt("x", 0), windowPrefs.getInt("y", 0),
                windowPrefs.getInt("width", 600), windowPrefs.getInt("height", 600));
        frame.setLocationRelativeTo(null); // center
    }

    frame.getRootPane().registerKeyboardAction(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            frame.dispose();
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);

    frame.pack();

    frame.setVisible(true);

    String[] splinters = config.getStrings("splinters", new String[0]);
    for (String s : splinters) {
        addViewRobot(s);
        addViewLidars(s);
        addViewWaypoints(s);

        // TODO SoarApril
        addViewTrajectory(s);
    }
}

From source file:com.esri.geoevent.test.performance.ui.ConsumerController.java

@Override
protected void loadState() {
    Preferences preferences = Preferences.userNodeForPackage(ConsumerController.class);
    Protocol selectedProtocol = Protocol.fromValue(preferences.get("protocol", Protocol.TCP.toString()));
    int portNumber = NumberUtils.toInt(preferences.get("port", String.valueOf(DEFAULT_COMMAND_PORT)));
    int serverPortNumber = NumberUtils
            .toInt(preferences.get("serverPort", String.valueOf(DEFAULT_SERVER_PORT)));

    protocol.setValue(selectedProtocol);
    port.setText(String.valueOf(portNumber));
    serverPort.setText(String.valueOf(serverPortNumber));
}

From source file:de._692b8c32.cdlauncher.MainController.java

public MainController(Application application, Preferences preferences) {
    this.application = application;
    this.preferences = preferences;

    if (preferences.get("basedir", null) == null) {
        while (new OptionsController(application, preferences).selectDirectory() == null) {
            new Alert(Alert.AlertType.ERROR,
                    "The launcher needs a directory to store temporary files. Press cancel if you want to close the application.",
                    ButtonType.CANCEL, ButtonType.PREVIOUS).showAndWait().ifPresent(button -> {
                        if (button == ButtonType.CANCEL) {
                            throw new RuntimeException("User requested abort.");
                        }/*www  .  j a va 2s .c o m*/
                    });
        }

        new Alert(Alert.AlertType.INFORMATION,
                "Do you want to use a prebuilt version of OpenRA? This is recommended unless you are an OpenRA developer.",
                ButtonType.NO, ButtonType.YES).showAndWait().ifPresent(button -> {
                    if (button == ButtonType.YES) {
                        preferences.putBoolean("buildFromSources", false);
                    }
                    if (button == ButtonType.NO) {
                        preferences.putBoolean("buildFromSources", true);
                    }
                });

        if (System.getProperty("os.name").toLowerCase().contains("win")) {
            preferences.put("commandMono", "");
            preferences.put("commandMake", "");
        }
    }
}

From source file:org.pentaho.reporting.designer.extensions.pentaho.repository.util.PublishSettings.java

private String[] getList(final String key) {
    final Preferences preferences = properties.node(key);
    final ArrayList<String> data = new ArrayList<String>();
    for (;;) {/*ww  w.j a  v a2s. co  m*/
        final String s = preferences.get(String.valueOf(data.size()), null);
        if (s == null) {
            break;
        }
        data.add(s);
    }
    return data.toArray(new String[data.size()]);
}

From source file:de.fhg.igd.mapviewer.server.wms.wizard.pages.BasicConfigurationWithWMSListPage.java

@Override
public void createComponent() {
    super.createComponent();

    Button storeWMS = new Button(getComposite(), SWT.PUSH);
    storeWMS.setText(Messages.WMSListConfigurationPage_2);

    // add new WMS to list and refresh
    storeWMS.addSelectionListener(new SelectionAdapter() {

        @Override//from   w  ww.  j  av  a2 s . c  o  m
        public void widgetSelected(SelectionEvent e) {
            // store WMS i UI list
            map.put(getServiceName(), getServiceURL());
            getListForUI(listUI);
            comboViewer.refresh();
        }
    });

    // free line
    new Text(getComposite(), SWT.NONE).setEditable(false);
    new Text(getComposite(), SWT.NONE).setEditable(false);
    new Text(getComposite(), SWT.NONE).setEditable(false);
    new Text(getComposite(), SWT.NONE).setEditable(false);
    new Text(getComposite(), SWT.NONE).setEditable(false);

    // add text and combo viewer
    Text text = new Text(getComposite(), SWT.NONE);
    text.setEditable(false);
    text.setText(Messages.WMSListConfigurationPage_0);

    // get a list of all WMS

    // get all WMS, storing as WMS Map Server
    Preferences PREF_SERVERS = new WMSMapServer().getPreferences();

    String[] prefs = null;
    try {
        prefs = PREF_SERVERS.childrenNames();

        // put all in map
        for (String current : prefs) {

            Preferences child = PREF_SERVERS.node(current);
            map.put(current, child.get("baseUrl", "baseUrl"));
        }

    } catch (BackingStoreException e) {
        log.warn(Messages.WMSListConfigurationPage_1, e); // $NON-NLS-1$
    }

    // get all WMS, storing as extension points
    IConfigurationElement[] allER = Platform.getExtensionRegistry()
            .getConfigurationElementsFor("de.fhg.igd.mapviewer.server.MapServer");

    for (IConfigurationElement current : allER) {
        String name = "";
        String url = "";

        // name is stored directly as attribute
        name = current.getAttribute("name");

        // url is stored as child
        for (IConfigurationElement child : current.getChildren()) {
            if (child.getAttribute("name").equals("baseUrl")) {
                url = child.getAttribute("value");
            }
        }
        // store everything into map
        if (name != null && !name.isEmpty() && url != null && !url.isEmpty()) {
            map.put(name, url);
        }
    }

    // show stored WMS as DropDown
    comboViewer = new ComboViewer(getComposite(), SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY);
    comboViewer.setContentProvider(new ArrayContentProvider());
    getListForUI(listUI);
    comboViewer.setInput(listUI);
    comboViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            if (selection.size() > 0) {
                String currentSelection = (String) selection.getFirstElement();
                name.setStringValue(currentSelection);
                location.setStringValue(map.get(currentSelection));
            }
        }
    });
}

From source file:maltcms.ui.nb.pipelineRunner.actions.ImportMaltcmsPipelinesAction.java

@Override
public void actionPerformed(ActionEvent ev) {
    Preferences prefs = NbPreferences.forModule(PipelineRunnerTopComponent.class);
    prefs.addPreferenceChangeListener(this);
    String installationPath = prefs.get("maltcmsInstallationPath", "");
    if (installationPath.isEmpty()) {
        Logger.getLogger(getClass().getName()).info("Installation path is empty, opening settings!");
        boolean b = OptionsDisplayer.getDefault().open("maltcmsOptions");
    } else {// www. j  a va  2s  .  com
        importPipelines();
    }

}

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);
}