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

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

Introduction

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

Prototype

public boolean getBoolean(String key, boolean 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);//from w  w w .java  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.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 www. j  a  v  a 2 s .  c  o  m*/
        frame.dispose();
        System.exit(0);
    }
}

From source file:pl.otros.logview.gui.LogViewMainFrame.java

public LogViewMainFrame(DataConfiguration c) throws InitializationException {
    super();/*from ww  w .j a  v a  2 s.  com*/
    this.configuration = c;
    this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    String title = "OtrosLogViewer";
    try {
        title += ' ' + VersionUtil.getRunningVersion();
    } catch (Exception e) {
        LOGGER.warning("Can't load version of running OLV");
    }
    this.setTitle(title);
    try {
        String iconPath = "img/otros/logo16.png";
        if (System.getProperty("os.name").contains("Linux")) {
            iconPath = "img/otros/logo64.png";
        }
        BufferedImage icon = ImageIO.read(this.getClass().getClassLoader().getResourceAsStream(iconPath));
        this.setIconImage(icon);
    } catch (Exception e1) {
        LOGGER.warning("Can't load icon: " + e1.getMessage());
    }
    Exception modalDisplayException = null;
    // If non-terminal load problem occurs, queue to display for user on
    // top of the app UI.
    try {
        OtrosSplash.setMessage("Loading plugins");
        LvDynamicLoader.getInstance().setStatusObserver(OtrosSplash.getSplashStatusObserver());
        LvDynamicLoader.getInstance().loadAll();
        OtrosSplash.setMessage("Loading plugins loaded");
    } catch (IOException e) {
        LOGGER.severe("Problem with loading automatic markers, filter or log importers: " + e.getMessage());
        modalDisplayException = e;
    } catch (InitializationException ie) {
        // Details should have been logged at lower level
        modalDisplayException = ie;
    }
    OtrosSplash.setMessage("Initializing GUI");
    allPluginables = AllPluginables.getInstance();
    logImportersContainer = allPluginables.getLogImportersContainer();
    messageColorizercontainer = allPluginables.getMessageColorizers();
    searchResultColorizer = (SearchResultColorizer) messageColorizercontainer
            .getElement(SearchResultColorizer.class.getName());
    cardLayout = new CardLayout();
    cardLayoutPanel = new JPanel(cardLayout);
    JLabel statusLabel = new JLabel(" ");
    observer = new JLabelStatusObserver(statusLabel);
    logsTabbedPane = new JTabbedPane();
    enableDisableComponetsForTabs = new EnableDisableComponetsForTabs(logsTabbedPane);
    logsTabbedPane.addChangeListener(enableDisableComponetsForTabs);

    otrosApplication = new OtrosApplication();
    otrosApplication.setAllPluginables(AllPluginables.getInstance());
    otrosApplication.setApplicationJFrame(this);
    otrosApplication.setConfiguration(configuration);
    otrosApplication.setjTabbedPane(logsTabbedPane);
    otrosApplication.setStatusObserver(observer);
    otrosApplication.setOtrosVfsBrowserDialog(new JOtrosVfsBrowserDialog(getVfsFavoritesConfiguration()));
    otrosApplication.setServices(new ServicesImpl(otrosApplication));
    SingleInstanceRequestResponseDelegate.getInstance().setOtrosApplication(otrosApplication);
    ToolTipManager.sharedInstance().setDismissDelay(5000);

    JProgressBar heapBar = new JProgressBar();
    heapBar.setPreferredSize(new Dimension(190, 15));
    new Thread(new MemoryUsedStatsUpdater(heapBar, 1500), "MemoryUsedUpdater").start();
    JPanel statusPanel = new JPanel(new MigLayout("fill", "[fill, push, grow][right][right]", "[]"));
    statusPanel.add(statusLabel);
    final JButton ideConnectedLabel = new JButton(Ide.IDEA.getIconDiscounted());
    statusPanel.add(ideConnectedLabel);
    statusPanel.add(new JButton(new SwitchAutoJump(otrosApplication)));
    statusPanel.add(heapBar);

    initMenu();
    initToolbar();
    addEmptyViewListener();
    addMenuBarReloadListener();
    otrosApplication.setSearchField(searchField);
    cardLayoutPanel.add(logsTabbedPane, CARD_LAYOUT_LOGS_TABLE);
    EmptyViewPanel emptyViewPanel = new EmptyViewPanel(otrosApplication);
    final JScrollPane jScrollPane = new JScrollPane(emptyViewPanel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            jScrollPane.getVerticalScrollBar().setValue(0);
        }
    });
    cardLayoutPanel.add(jScrollPane, CARD_LAYOUT_EMPTY);
    cardLayout.show(cardLayoutPanel, CARD_LAYOUT_EMPTY);
    enableDisableComponetsForTabs.stateChanged(null);
    Container cp = getContentPane();
    cp.setLayout(new BorderLayout());
    cp.add(toolBar, BorderLayout.NORTH);
    cp.add(cardLayoutPanel, BorderLayout.CENTER);
    cp.add(statusPanel, BorderLayout.SOUTH);
    initGlobalHotKeys();
    initPosition();
    if (configuration.getBoolean(ConfKeys.LOAD_EXPERIMENTAL_FEATURES, false)) {
        initExperimental();
    }
    setTransferHandler(new DragAndDropFilesHandler(otrosApplication));
    initPlugins();
    OtrosSplash.hide();
    setVisible(true);
    if (modalDisplayException != null)
        JOptionPane.showMessageDialog(this,
                "Problem with loading automatic markers," + "filter or log importers:\n"
                        + modalDisplayException.getMessage(),
                "Initialization Error", JOptionPane.ERROR_MESSAGE);
    // Check new version on start
    if (c.getBoolean(ConfKeys.VERSION_CHECK_ON_STARTUP, true)) {
        new ChekForNewVersionOnStartupAction(otrosApplication).actionPerformed(null);
    }
    new TipOfTheDay(c).showTipOfTheDayIfNotDisabled(this);
    Toolkit.getDefaultToolkit().getSystemEventQueue().push(new EventQueueProxy());
    ListUncaughtExceptionHandlers listUncaughtExceptionHandlers = new ListUncaughtExceptionHandlers(//
            new LoggingExceptionHandler(), //
            new ShowErrorDialogExceptionHandler(otrosApplication), //
            new StatusObserverExceptionHandler(observer));
    Thread.setDefaultUncaughtExceptionHandler(listUncaughtExceptionHandlers);
    ListeningScheduledExecutorService listeningScheduledExecutorService = otrosApplication.getServices()
            .getTaskSchedulerService().getListeningScheduledExecutorService();
    listeningScheduledExecutorService.scheduleAtFixedRate(
            new IdeAvailabilityCheck(ideConnectedLabel, otrosApplication.getServices().getJumpToCodeService()),
            5, 5, TimeUnit.SECONDS);
    ideConnectedLabel.addActionListener(new IdeIntegrationConfigAction(otrosApplication));
}