Example usage for org.apache.commons.configuration DataConfiguration getInt

List of usage examples for org.apache.commons.configuration DataConfiguration getInt

Introduction

In this page you can find the example usage for org.apache.commons.configuration DataConfiguration getInt.

Prototype

public int getInt(String key, int defaultValue) 

Source Link

Usage

From source file:pl.otros.logview.exceptionshandler.ShowErrorDialogExceptionHandler.java

protected JComponent createDialogView() {
    JPanel jPanel = new JPanel(new MigLayout());
    JLabel label = new JLabel("Do you want to send error report?");
    label.setFont(label.getFont().deriveFont(Font.BOLD));
    jPanel.add(label, "span 4, wrap, center");
    jPanel.add(new JLabel("Comment:"));
    commentTextArea = new JTextArea(10, 30);
    commentTextArea.setWrapStyleWord(true);
    commentTextArea.setLineWrap(true);/* w ww  .  j a va  2  s .  c o m*/
    JScrollPane jScrollPane = new JScrollPane(commentTextArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    jPanel.add(jScrollPane, "span 3, wrap");
    jPanel.add(new JLabel("Email (optional):"));
    emailTextField = new JTextField(30);
    jPanel.add(emailTextField, "span 3, wrap");

    jPanel.add(new JSeparator(), "span 4, wrap, grow");
    checkBoxUseProxy = new JCheckBox("Use HTTP proxy");
    proxyTf = new JTextField();
    proxyPortModel = new SpinnerNumberModel(80, 1, 256 * 256 - 1, 1);
    proxyUser = new JTextField();
    proxyPasswordField = new JPasswordField();
    proxySpinner = new JSpinner(proxyPortModel);

    jPanel.add(checkBoxUseProxy, "wrap");
    labelProxyHost = new JLabel("Proxy address");
    jPanel.add(labelProxyHost);
    jPanel.add(proxyTf, "wrap, span 3, grow");
    labelProxyPort = new JLabel("Proxy port");
    jPanel.add(labelProxyPort);
    jPanel.add(proxySpinner, "wrap");
    labelProxyUser = new JLabel("User");
    jPanel.add(labelProxyUser);
    jPanel.add(proxyUser, "grow");
    labelProxyPassword = new JLabel("Password");
    jPanel.add(labelProxyPassword);
    jPanel.add(proxyPasswordField, "grow");

    checkBoxUseProxy.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            setProxyEnabled(checkBoxUseProxy.isSelected());
        }
    });
    DataConfiguration c = otrosApplication.getConfiguration();
    proxyTf.setText(c.getString(ConfKeys.HTTP_PROXY_HOST, ""));
    proxyUser.setText(c.getString(ConfKeys.HTTP_PROXY_USER, ""));
    proxyPortModel.setValue(Integer.valueOf(c.getInt(ConfKeys.HTTP_PROXY_PORT, 80)));
    boolean useProxy = c.getBoolean(ConfKeys.HTTP_PROXY_USE, false);
    checkBoxUseProxy.setSelected(useProxy);
    setProxyEnabled(useProxy);

    return jPanel;
}

From source file:pl.otros.logview.gui.actions.ConnectToSocketHubAppenderAction.java

private boolean chooseLogImporter() {
    DataConfiguration configuration = getOtrosApplication().getConfiguration();
    List<Object> list1 = configuration.getList(ConfKeys.SOCKET_HUB_APPENDER_ADDRESSES);
    configuration.getInt(ConfKeys.SOCKET_HUB_APPENDER_ADDRESSES_MAX_COUNT, 20);

    Vector<String> recent = new Vector<String>();
    for (Object o : list1) {
        recent.add(o.toString());//from w  w  w  .j  a v a  2 s. com
    }

    JXComboBox box = new JXComboBox(recent);
    box.setEditable(true);
    AutoCompleteDecorator.decorate(box);

    MigLayout migLayout = new MigLayout();
    JPanel panel = new JPanel(migLayout);
    panel.add(new JLabel("Host name:port"));
    panel.add(box, "wrap, width 200:220:440");

    while (true) {
        String[] options = { "Connect", "Cancel" };
        int showConfirmDialog = JOptionPane.showOptionDialog(getOtrosApplication().getApplicationJFrame(),
                panel, "Enter host name and port", JOptionPane.OK_CANCEL_OPTION,
                JOptionPane.INFORMATION_MESSAGE, null, options, options[0]);
        if (showConfirmDialog != JOptionPane.OK_OPTION) {

            return false;
        }

        try {
            String hostAndPortString = box.getSelectedItem().toString().trim();
            socket = tryToConnectToSocket(configuration, hostAndPortString, SocketFactory.getDefault());
        } catch (UnknownHostException e) {
            JOptionPane.showMessageDialog(panel, host + " is unknown host name", "Error",
                    JOptionPane.ERROR_MESSAGE);
            continue;
        } catch (IOException e) {
            JOptionPane.showMessageDialog(panel, "Cannot connect to host " + host + ":" + port, "Error",
                    JOptionPane.ERROR_MESSAGE);
            continue;
        } catch (NumberFormatException e) {
            JOptionPane.showMessageDialog(panel, "Can't parse port number.", "Error",
                    JOptionPane.ERROR_MESSAGE);
            continue;
        }
        return true;
    }

}

From source file:pl.otros.logview.gui.actions.search.SearchAction.java

private void updateList(String configurationKey, DataConfiguration configuration, String text) {
    List<Object> list = configuration.getList(configurationKey);
    if (list.contains(text)) {
        list.remove(text);/*  ww w . ja v  a 2s.c o  m*/
    }
    list.add(0, text);
    if (list.size() > configuration.getInt(ConfKeys.SEARCH_LAST_COUNT, 30)) {
        list.remove(list.size() - 1);
    }
    configuration.setProperty(configurationKey, list);
}

From source file:pl.otros.vfs.browser.favorit.FavoritesUtils.java

public static List<Favorite> loadFromProperties(DataConfiguration conf) {
    ArrayList<Favorite> list = new ArrayList<Favorite>();
    int count = conf.getInt("favorites.count", 0);
    LOGGER.info("Loading favorites {}", count);
    for (int i = 0; i < count; i++) {
        String name = conf.getString(String.format("favorite.item_%d.name", i));
        String url = conf.getString(String.format("favorite.item_%d.url", i));
        Favorite favorite = new Favorite(name, url, Type.USER);
        list.add(favorite);/*www. j av a  2  s. co  m*/
    }
    return list;
}