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

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

Introduction

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

Prototype

public void setProperty(String key, Object value) 

Source Link

Usage

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

@Override
protected void uncaughtExceptionInSwingEDT(Thread thread, Throwable throwable) {
    String stackTraceAsString = Throwables.getStackTraceAsString(throwable);
    if (caughtStackTraces.contains(stackTraceAsString)) {
        LOGGER.info("Not sending the same error report twice");
        return;/*  w w w  .j  a v  a2  s  .c  o m*/
    }
    caughtStackTraces.add(stackTraceAsString);
    JPanel message = new JPanel(new BorderLayout());
    message.add(new JLabel("Error in thread " + thread.getName()), BorderLayout.NORTH);

    String stackTrace = getStackTrace(throwable);
    JTextArea textArea = new JTextArea(10, 70);
    textArea.setText(stackTrace);
    textArea.setCaretPosition(0);
    message.add(new JScrollPane(textArea));

    JOptionPane.showMessageDialog(null, message, "Error", JOptionPane.ERROR_MESSAGE);

    Map<String, String> errorReportData = generateReportData(thread, throwable, otrosApplication);
    JComponent jComponent = createDialogView();
    String[] options = { "Send", "Do not send" };
    int sendReport = JOptionPane.showOptionDialog(otrosApplication.getApplicationJFrame(), jComponent,
            "Send error report confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,
            Icons.MEGAPHONE_24, options, options[0]);
    errorReportData.put("USER:email", emailTextField.getText());
    errorReportData.put("USER:comment", commentTextArea.getText());

    if (sendReport == JOptionPane.YES_OPTION) {
        DataConfiguration c = otrosApplication.getConfiguration();
        c.setProperty(ConfKeys.HTTP_PROXY_USE, checkBoxUseProxy.isSelected());
        c.setProperty(ConfKeys.HTTP_PROXY_HOST, proxyTf.getText());
        c.setProperty(ConfKeys.HTTP_PROXY_PORT, proxyPortModel.getNumber().intValue());
        c.setProperty(ConfKeys.HTTP_PROXY_USER, proxyUser.getText());
        sendReportInNewBackground(errorReportData);
    } else {
        LOGGER.info("Not sending error report");
    }

    logErrorReport(errorReportData);

}

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

protected Socket tryToConnectToSocket(DataConfiguration configuration, String hostAndPortString,
        SocketFactory socketFactory) throws IOException {
    List<Object> list1 = configuration.getList(ConfKeys.SOCKET_HUB_APPENDER_ADDRESSES);
    String[] hostPort = hostAndPortString.split(":");
    host = hostPort[0];/*from ww w .j a v  a2 s . co  m*/
    if (hostPort.length > 1) {
        port = Integer.parseInt(hostPort[1]);
    } else {
        port = 4560;
    }

    Socket socket = socketFactory.createSocket(host, port);
    if (list1.contains(hostAndPortString)) {
        list1.remove(hostAndPortString);
    }
    list1.add(0, hostAndPortString);
    if (list1.size() > 30) {
        list1.remove(list1.size() - 1);
    }
    configuration.setProperty(ConfKeys.SOCKET_HUB_APPENDER_ADDRESSES, list1);
    return socket;
}

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

protected void askAndExit() {
    final DataConfiguration configuration = getOtrosApplication().getConfiguration();
    boolean doConfirm = configuration.getBoolean(ConfKeys.CONFIRM_QUIT, true);
    JPanel panel = new JPanel(new MigLayout("left"));
    panel.add(new JLabel("Do you want to exit OtrosLogViewer and parse logs with 'grep'?"), "growx, wrap");
    getOtrosApplication().getConfiguration().getBoolean(ConfKeys.CONFIRM_QUIT, true);
    final JCheckBox box = new JCheckBox("Always ask before exit", doConfirm);
    box.addActionListener(e -> configuration.setProperty(ConfKeys.CONFIRM_QUIT, box.isSelected()));
    panel.add(box, "growx, wrap");

    if (!doConfirm || JOptionPane.showConfirmDialog(frame, panel, "Are you sure?",
            JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
        frame.setVisible(false);/*from  ww w.  j a  v a 2 s  .c om*/
        frame.dispose();
        System.exit(0);
    }
}

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  .  j av a 2 s  .  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 void storeFavorites(DataConfiguration configuration, List<Favorite> favoriteList) {
    int i = 0;//  w  w w. j ava 2  s  .  c  o m
    for (Favorite favorite : favoriteList) {
        if (favorite.getType().equals(Type.USER)) {
            configuration.setProperty(String.format("favorite.item_%d.name", i), favorite.getName());
            configuration.setProperty(String.format("favorite.item_%d.url", i), favorite.getUrl());
            i++;
        }
    }
    configuration.setProperty("favorites.count", i);
}