Example usage for javax.swing JCheckBox setSelected

List of usage examples for javax.swing JCheckBox setSelected

Introduction

In this page you can find the example usage for javax.swing JCheckBox setSelected.

Prototype

public void setSelected(boolean b) 

Source Link

Document

Sets the state of the button.

Usage

From source file:org.zaproxy.zap.extension.cmss.CMSSFrame.java

/** Create the frame. */
public CMSSFrame() {
    setTitle("Fingerprinting tools");
    setResizable(false);/* www . j  ava2s.  c om*/
    setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
    setBounds(100, 100, 756, 372);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    contentPane.setLayout(new BorderLayout(0, 0));
    setContentPane(contentPane);

    JLayeredPane layeredPane = new JLayeredPane();
    contentPane.add(layeredPane, BorderLayout.CENTER);

    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    tabbedPane.setBounds(0, 0, 725, 323);
    layeredPane.add(tabbedPane);

    JLayeredPane layeredPane_1 = new JLayeredPane();
    tabbedPane.addTab("Fingerprint", null, layeredPane_1, null);

    JLabel label = new JLabel("App name:");
    label.setBounds(35, 188, 76, 14);
    layeredPane_1.add(label);

    JLabel label_1 = new JLabel("Version:");
    label_1.setBounds(35, 230, 76, 14);
    layeredPane_1.add(label_1);

    textField = new JTextField();
    textField.setColumns(10);
    textField.setBounds(121, 188, 109, 29);
    layeredPane_1.add(textField);

    textField_1 = new JTextField();
    textField_1.setColumns(10);
    textField_1.setBounds(121, 223, 109, 29);
    layeredPane_1.add(textField_1);

    JSeparator separator = new JSeparator();
    separator.setBounds(35, 72, 665, 2);
    layeredPane_1.add(separator);

    JSeparator separator_1 = new JSeparator();
    separator_1.setBounds(196, 11, 1, 201);
    layeredPane_1.add(separator_1);

    JSeparator separator_2 = new JSeparator();
    separator_2.setOrientation(SwingConstants.VERTICAL);
    separator_2.setBounds(260, 81, 1, 201);
    layeredPane_1.add(separator_2);

    final JCheckBox chckbxGetVersion = new JCheckBox("Get version");
    chckbxGetVersion.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            if (textField_1.isEnabled() && !chckbxGetVersion.isSelected())
                textField_1.setEnabled(false);
            if (!textField_1.isEnabled() && chckbxGetVersion.isSelected())
                textField_1.setEnabled(true);
        }
    });
    chckbxGetVersion.setBounds(35, 81, 195, 23);
    layeredPane_1.add(chckbxGetVersion);

    final JCheckBox chckbxPassiveFingerprinting = new JCheckBox("Passive");
    chckbxPassiveFingerprinting.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
        }
    });
    chckbxPassiveFingerprinting.setBounds(35, 107, 195, 23);
    chckbxPassiveFingerprinting.setSelected(true); //
    layeredPane_1.add(chckbxPassiveFingerprinting);

    final JCheckBox chckbxAgressive = new JCheckBox("Agressive");
    chckbxAgressive.setBounds(35, 133, 195, 23);
    layeredPane_1.add(chckbxAgressive);

    JLabel lblWhatToFingerprint = new JLabel("What to fingerprint ?");
    lblWhatToFingerprint.setBounds(287, 81, 109, 14);
    layeredPane_1.add(lblWhatToFingerprint);

    JCheckBox chckbxCms = new JCheckBox("cms");
    chckbxCms.setBounds(280, 102, 134, 23);
    layeredPane_1.add(chckbxCms);

    JCheckBox chckbxMessageboards = new JCheckBox("message-boards");
    chckbxMessageboards.setBounds(280, 128, 134, 23);
    layeredPane_1.add(chckbxMessageboards);

    JCheckBox chckbxJavascriptframeworks = new JCheckBox("javascript-frameworks");
    chckbxJavascriptframeworks.setBounds(281, 154, 133, 23);
    layeredPane_1.add(chckbxJavascriptframeworks);

    JCheckBox chckbxWebframeworks = new JCheckBox("web-frameworks");
    chckbxWebframeworks.setBounds(281, 178, 133, 23);
    layeredPane_1.add(chckbxWebframeworks);

    JCheckBox chckbxWebservers = new JCheckBox("web-servers");
    chckbxWebservers.setBounds(281, 204, 133, 23);
    layeredPane_1.add(chckbxWebservers);

    JSeparator separator_4 = new JSeparator();
    separator_4.setOrientation(SwingConstants.VERTICAL);
    separator_4.setBounds(435, 81, 1, 201);
    layeredPane_1.add(separator_4);

    JCheckBox chckbxDatabases = new JCheckBox("databases");
    chckbxDatabases.setBounds(281, 228, 133, 23);
    layeredPane_1.add(chckbxDatabases);

    JButton btnMore = new JButton("More");
    btnMore.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            wtfpFrame = new WhatToFingerPrintFrame();
            wtfpFrame.setLocationRelativeTo(null);
            wtfpFrame.setVisible(true);
        }
    });
    btnMore.setBounds(291, 261, 123, 23);
    layeredPane_1.add(btnMore);

    JLabel lblFingerprintingTimeAnd = new JLabel("Fingerprinting time and occuracy settings:");
    lblFingerprintingTimeAnd.setBounds(490, 81, 210, 14);
    layeredPane_1.add(lblFingerprintingTimeAnd);

    JButton btnFingerprint = new JButton("Fingerprint");
    btnFingerprint.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (!chckbxPassiveFingerprinting.isSelected() && !chckbxAgressive.isSelected())
                chckbxPassiveFingerprinting.setSelected(true);
            if (chckbxPassiveFingerprinting.isSelected() && !chckbxAgressive.isSelected())
                POrAOption = 1;
            else if (!chckbxPassiveFingerprinting.isSelected() && chckbxAgressive.isSelected())
                POrAOption = 2;
            else if (chckbxPassiveFingerprinting.isSelected() && chckbxAgressive.isSelected())
                POrAOption = 3;

            try {
                targetUrl = new URL(txtHttp.getText());
            } catch (MalformedURLException e2) {
                // TODO Auto-generated catch block
                e2.printStackTrace();
            }

            System.out.println("POrAOption : " + POrAOption);

            // we concatenate the two ArrayLists
            ArrayList<String> wtfpList = getWhatToFingerprint();
            for (String wtfp : wtfpFrame.getWhatToFingerprint()) {
                wtfpList.add(wtfp);
            }
            // we call FastFingerprinter.filterResults on the global whatToFingerPrint
            // List

            fpThread = new FingerPrintingThread(targetUrl, wtfpList, POrAOption);
            fpThread.start();
            while (fpThread.isAlive()) {
                // waiting;

            }
            ArrayList<String> resultList = fpThread.getFingerPrintingResult();
            for (String app : resultList) {
                textField.setText(textField.getText() + app + " , ");
            }

            if (chckbxGetVersion.isSelected()) {
                System.out.println("wiw");
                ArrayList<String> versions = new ArrayList<String>();

                if (resultList.contains("wordpress")) {
                    textField_1.setText(textField_1.getText() + "wordpress :");
                    for (String version : FastFingerprinter.WordpressFastFingerprint(targetUrl)) {
                        textField_1.setText(textField_1.getText() + version + " ; ");
                    }
                }

                if (resultList.contains("joomla")) {
                    textField_1.setText(textField_1.getText() + "joomla :");
                    for (String version : FastFingerprinter.JoomlaFastFingerprint(targetUrl)) {
                        textField_1.setText(textField_1.getText() + version + " ; ");
                    }
                }

                // blindelephant
                for (String app : resultList) {
                    System.out.println("---->" + app);
                    try {
                        versions = WebAppGuesser.fingerPrintFile(app);
                        textField_1.setText(textField_1.getText() + app + " : ");
                        for (String version : versions) {
                            textField_1.setText(textField_1.getText() + version + " ; ");
                        }
                    } catch (NoSuchAlgorithmException | IOException | DecoderException e1) {
                        e1.printStackTrace();
                    }
                }
            }
        }
    });

    btnFingerprint.setBounds(35, 154, 195, 23);
    layeredPane_1.add(btnFingerprint);

    JButton btnDetailedView = new JButton("Detailed view ");
    btnDetailedView.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
        }
    });
    btnDetailedView.setBounds(35, 259, 195, 23);
    layeredPane_1.add(btnDetailedView);
    this.checkBoxesList.add(chckbxCms);
    this.checkBoxesList.add(chckbxJavascriptframeworks);
    this.checkBoxesList.add(chckbxWebframeworks);
    this.checkBoxesList.add(chckbxWebservers);
    this.checkBoxesList.add(chckbxDatabases);
    this.checkBoxesList.add(chckbxMessageboards);

    txtHttp = new JTextField();
    txtHttp.setText("http://");
    txtHttp.setBounds(128, 22, 568, 29);
    layeredPane_1.add(txtHttp);
    txtHttp.setColumns(10);

    JLabel lblTarget = new JLabel("Target : ");
    lblTarget.setBounds(51, 29, 46, 14);
    layeredPane_1.add(lblTarget);

    JLayeredPane layeredPane_2 = new JLayeredPane();
    tabbedPane.addTab("Details", null, layeredPane_2, null);

    JTabbedPane tabbedPane_1 = new JTabbedPane(JTabbedPane.TOP);
    tabbedPane_1.setBounds(0, 0, 720, 223);
    layeredPane_2.add(tabbedPane_1);

    JLayeredPane layeredPane_4 = new JLayeredPane();
    tabbedPane_1.addTab("Detailed result", null, layeredPane_4, null);

    JLayeredPane layeredPane_3 = new JLayeredPane();
    tabbedPane_1.addTab("Passive fingerprint", null, layeredPane_3, null);

    JTabbedPane tabbedPane_2 = new JTabbedPane(JTabbedPane.TOP);
    tabbedPane_1.addTab("Agressive fingerprint", null, tabbedPane_2, null);
}

From source file:org.zaproxy.zap.extension.customFire.CustomFireDialog.java

/**
 * /*from   www  . ja  v  a  2s . com*/
 * @param node void `
 */
private void populateRequestField(SiteNode node) {
    try {
        if (node == null || node.getHistoryReference() == null
                || node.getHistoryReference().getHttpMessage() == null) {
            this.getRequestField().setText("");

        } else {
            // Populate the custom vectors http pane
            HttpMessage msg = node.getHistoryReference().getHttpMessage();
            String header = msg.getRequestHeader().toString();
            StringBuilder sb = new StringBuilder();
            sb.append(header);
            this.headerLength = header.length();
            this.urlPathStart = header.indexOf("/", header.indexOf("://") + 2) + 1; // Ignore <METHOD> http(s)://host:port/
            sb.append(msg.getRequestBody().toString());
            this.getRequestField().setText(sb.toString());

            // Only set the recurse option if the node has children, and disable it otherwise
            JCheckBox recurseChk = (JCheckBox) this.getField(FIELD_RECURSE);
            recurseChk.setEnabled(node.getChildCount() > 0);
            recurseChk.setSelected(node.getChildCount() > 0);
        }
        this.setFieldStates();
    } catch (HttpMalformedHeaderException | DatabaseException e) {
        this.getRequestField().setText("");
    }

}

From source file:pcgen.gui2.PCGenFrame.java

private void showLicenseDialog(String title, String htmlString) {
    if (htmlString == null) {
        htmlString = LanguageBundle.getString("in_licNoInfo"); //$NON-NLS-1$
    }/*from  ww  w .  j a v  a 2s  .  com*/
    final PropertyContext context = PCGenSettings.OPTIONS_CONTEXT;
    final JDialog aFrame = new JDialog(this, title, true);
    final JButton jClose = new JButton(LanguageBundle.getString("in_close")); //$NON-NLS-1$
    jClose.setMnemonic(LanguageBundle.getMnemonic("in_mn_close")); //$NON-NLS-1$
    final JPanel jPanel = new JPanel();
    final JCheckBox jCheckBox = new JCheckBox(LanguageBundle.getString("in_licShowOnLoad")); //$NON-NLS-1$
    jPanel.add(jCheckBox);
    jCheckBox.setSelected(context.getBoolean(PCGenSettings.OPTION_SHOW_LICENSE));
    jCheckBox.addItemListener(
            evt -> context.setBoolean(PCGenSettings.OPTION_SHOW_LICENSE, jCheckBox.isSelected()));
    jPanel.add(jClose);
    jClose.addActionListener(evt -> aFrame.dispose());

    HtmlPanel htmlPanel = new HtmlPanel();
    HtmlRendererContext theRendererContext = new SimpleHtmlRendererContext(htmlPanel,
            new SimpleUserAgentContext());
    htmlPanel.setHtml(htmlString, "", theRendererContext);

    aFrame.getContentPane().setLayout(new BorderLayout());
    aFrame.getContentPane().add(htmlPanel, BorderLayout.CENTER);
    aFrame.getContentPane().add(jPanel, BorderLayout.SOUTH);
    aFrame.setSize(new Dimension(700, 500));
    aFrame.setLocationRelativeTo(this);
    Utility.setComponentRelativeLocation(this, aFrame);
    aFrame.getRootPane().setDefaultButton(jClose);
    Utility.installEscapeCloseOperation(aFrame);
    aFrame.setVisible(true);
}

From source file:pcgen.gui2.PCGenFrame.java

private void showMatureDialog(String text) {
    Logging.errorPrint("Warning: The following datasets contains mature themes. User discretion is advised.");
    Logging.errorPrint(text);//from  w  w w  . j a  va2 s  . co  m

    final JDialog aFrame = new JDialog(this, LanguageBundle.getString("in_matureTitle"), true);

    final JPanel jPanel1 = new JPanel();
    final JPanel jPanel3 = new JPanel();
    final JLabel jLabel1 = new JLabel(LanguageBundle.getString("in_matureWarningLine1"), //$NON-NLS-1$
            SwingConstants.CENTER);
    final JLabel jLabel2 = new JLabel(LanguageBundle.getString("in_matureWarningLine2"), //$NON-NLS-1$
            SwingConstants.CENTER);
    final JCheckBox jCheckBox1 = new JCheckBox(LanguageBundle.getString("in_licShowOnLoad")); //$NON-NLS-1$
    final JButton jClose = new JButton(LanguageBundle.getString("in_close")); //$NON-NLS-1$
    jClose.setMnemonic(LanguageBundle.getMnemonic("in_mn_close")); //$NON-NLS-1$

    jPanel1.setLayout(new BorderLayout());
    jPanel1.add(jLabel1, BorderLayout.NORTH);
    jPanel1.add(jLabel2, BorderLayout.SOUTH);

    HtmlPanel htmlPanel = new HtmlPanel();
    HtmlRendererContext theRendererContext = new SimpleHtmlRendererContext(htmlPanel,
            new SimpleUserAgentContext());
    htmlPanel.setHtml(text, "", theRendererContext);

    jPanel3.add(jCheckBox1);
    jPanel3.add(jClose);

    final PropertyContext context = PCGenSettings.OPTIONS_CONTEXT;
    jCheckBox1.setSelected(context.getBoolean(PCGenSettings.OPTION_SHOW_MATURE_ON_LOAD));

    jClose.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            aFrame.dispose();
        }

    });

    jCheckBox1.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent evt) {
            context.setBoolean(PCGenSettings.OPTION_SHOW_MATURE_ON_LOAD, jCheckBox1.isSelected());
        }

    });

    aFrame.getContentPane().setLayout(new BorderLayout());
    aFrame.getContentPane().add(jPanel1, BorderLayout.NORTH);
    aFrame.getContentPane().add(htmlPanel, BorderLayout.CENTER);
    aFrame.getContentPane().add(jPanel3, BorderLayout.SOUTH);

    aFrame.setSize(new Dimension(456, 176));
    Utility.setComponentRelativeLocation(this, aFrame);
    aFrame.setVisible(true);
}

From source file:pl.edu.agh.lib.FileInfo.java

public void getInfoFromFS(List<Entity> entities, JTable aclList, JLabel jPath, JLabel jType, JLabel jMask,
        JLabel jFlags, JLabel jInodeNumer, JCheckBox jReadMask, JCheckBox jWriteMask, JCheckBox jExecuteMask,
        String currentPath) {//from   w  w w  . j av a 2s  . c  om
    if (isReadeable(currentPath)) {
        String type = getType(currentPath);
        String mask = getMask(currentPath);
        String flags = getFlags(currentPath);
        String inode = getInodeNumber(currentPath);

        entities.clear();
        entities.addAll(aclOperator.getAclList(currentPath));

        if (currentPath.length() > 50) {
            jPath.setText("..." + currentPath.substring(currentPath.lastIndexOf("/")));
        } else {
            jPath.setText(currentPath);
        }
        if (type.length() > 60) {
            jType.setText(type.substring(0, 56) + "...");
        } else {
            jType.setText(type);
        }
        jMask.setText(mask);
        jFlags.setText(flags);
        jInodeNumer.setText(inode);

        if (mask.equals("")) {
            jReadMask.setSelected(false);
            jReadMask.setEnabled(false);
            jWriteMask.setSelected(false);
            jWriteMask.setEnabled(false);
            jExecuteMask.setSelected(false);
            jExecuteMask.setEnabled(false);
        } else {
            jWriteMask.setEnabled(true);
            jReadMask.setEnabled(true);
            jExecuteMask.setEnabled(true);
            if (mask.contains("r")) {
                jReadMask.setSelected(true);
            } else {
                columnBacklight(PermissionType.READ, true, aclList, entities);
            }
            if (mask.contains("w")) {
                jWriteMask.setSelected(true);
            } else {
                columnBacklight(PermissionType.WRITE, true, aclList, entities);
            }
            if (mask.contains("x")) {
                jExecuteMask.setSelected(true);
            } else {
                columnBacklight(PermissionType.EXECUTE, true, aclList, entities);
            }
        }
    }
}

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

private void initToolbar() {
    toolBar = new JToolBar();
    final JComboBox searchMode = new JComboBox(
            new String[] { "String contains search: ", "Regex search: ", "Query search: " });
    final SearchAction searchActionForward = new SearchAction(otrosApplication, SearchDirection.FORWARD);
    final SearchAction searchActionBackward = new SearchAction(otrosApplication, SearchDirection.REVERSE);
    searchFieldCbxModel = new DefaultComboBoxModel();
    searchField = new JXComboBox(searchFieldCbxModel);
    searchField.setEditable(true);/*from  w w  w .  j  a  va2  s  . c  om*/
    AutoCompleteDecorator.decorate(searchField);
    searchField.setMinimumSize(new Dimension(150, 10));
    searchField.setPreferredSize(new Dimension(250, 10));
    searchField.setToolTipText(
            "<HTML>Enter text to search.<BR/>" + "Enter - search next,<BR/>Alt+Enter search previous,<BR/>"
                    + "Ctrl+Enter - mark all found</HTML>");
    final DelayedSwingInvoke delayedSearchResultUpdate = new DelayedSwingInvoke() {
        @Override
        protected void performActionHook() {
            JTextComponent editorComponent = (JTextComponent) searchField.getEditor().getEditorComponent();
            int stringEnd = editorComponent.getSelectionStart();
            if (stringEnd < 0) {
                stringEnd = editorComponent.getText().length();
            }
            try {
                String selectedText = editorComponent.getText(0, stringEnd);
                if (StringUtils.isBlank(selectedText)) {
                    return;
                }
                OtrosJTextWithRulerScrollPane<JTextPane> logDetailWithRulerScrollPane = otrosApplication
                        .getSelectedLogViewPanel().getLogDetailWithRulerScrollPane();
                MessageUpdateUtils.highlightSearchResult(logDetailWithRulerScrollPane,
                        otrosApplication.getAllPluginables().getMessageColorizers());
                RulerBarHelper.scrollToFirstMarker(logDetailWithRulerScrollPane);
            } catch (BadLocationException e) {
                LOGGER.log(Level.SEVERE, "Can't update search highlight", e);
            }
        }
    };
    JTextComponent searchFieldTextComponent = (JTextComponent) searchField.getEditor().getEditorComponent();
    searchFieldTextComponent.getDocument().addDocumentListener(new DocumentInsertUpdateHandler() {
        @Override
        protected void documentChanged(DocumentEvent e) {
            delayedSearchResultUpdate.performAction();
        }
    });
    final MarkAllFoundAction markAllFoundAction = new MarkAllFoundAction(otrosApplication);
    final SearchModeValidatorDocumentListener searchValidatorDocumentListener = new SearchModeValidatorDocumentListener(
            (JTextField) searchField.getEditor().getEditorComponent(), observer, SearchMode.STRING_CONTAINS);
    SearchMode searchModeFromConfig = configuration.get(SearchMode.class, "gui.searchMode",
            SearchMode.STRING_CONTAINS);
    final String lastSearchString;
    int selectedSearchMode = 0;
    if (searchModeFromConfig.equals(SearchMode.STRING_CONTAINS)) {
        selectedSearchMode = 0;
        lastSearchString = configuration.getString(ConfKeys.SEARCH_LAST_STRING, "");
    } else if (searchModeFromConfig.equals(SearchMode.REGEX)) {
        selectedSearchMode = 1;
        lastSearchString = configuration.getString(ConfKeys.SEARCH_LAST_REGEX, "");
    } else if (searchModeFromConfig.equals(SearchMode.QUERY)) {
        selectedSearchMode = 2;
        lastSearchString = configuration.getString(ConfKeys.SEARCH_LAST_QUERY, "");
    } else {
        LOGGER.warning("Unknown search mode " + searchModeFromConfig);
        lastSearchString = "";
    }
    Component editorComponent = searchField.getEditor().getEditorComponent();
    if (editorComponent instanceof JTextField) {
        final JTextField sfTf = (JTextField) editorComponent;
        sfTf.getDocument().addDocumentListener(searchValidatorDocumentListener);
        sfTf.getDocument().addDocumentListener(new DocumentInsertUpdateHandler() {
            @Override
            protected void documentChanged(DocumentEvent e) {
                try {
                    int length = e.getDocument().getLength();
                    if (length > 0) {
                        searchResultColorizer.setSearchString(e.getDocument().getText(0, length));
                    }
                } catch (BadLocationException e1) {
                    LOGGER.log(Level.SEVERE, "Error: ", e1);
                }
            }
        });
        sfTf.addKeyListener(new SearchFieldKeyListener(searchActionForward, sfTf));
        sfTf.setText(lastSearchString);
    }
    searchMode.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            SearchMode mode = null;
            boolean validationEnabled = false;
            String confKey = null;
            String lastSearch = ((JTextField) searchField.getEditor().getEditorComponent()).getText();
            if (searchMode.getSelectedIndex() == 0) {
                mode = SearchMode.STRING_CONTAINS;
                searchValidatorDocumentListener.setSearchMode(mode);
                validationEnabled = false;
                searchMode.setToolTipText("Checking if log message contains string (case is ignored)");
                confKey = ConfKeys.SEARCH_LAST_STRING;
            } else if (searchMode.getSelectedIndex() == 1) {
                mode = SearchMode.REGEX;
                validationEnabled = true;
                searchMode
                        .setToolTipText("Checking if log message matches regular expression (case is ignored)");
                confKey = ConfKeys.SEARCH_LAST_REGEX;
            } else if (searchMode.getSelectedIndex() == 2) {
                mode = SearchMode.QUERY;
                validationEnabled = true;
                String querySearchTooltip = "<HTML>" + //
                "Advance search using SQL-like quries (i.e. level>=warning && msg~=failed && thread==t1)<BR/>" + //
                "Valid operator for query search is ==, ~=, !=, LIKE, EXISTS, <, <=, >, >=, &&, ||, ! <BR/>" + //
                "See wiki for more info<BR/>" + //
                "</HTML>";
                searchMode.setToolTipText(querySearchTooltip);
                confKey = ConfKeys.SEARCH_LAST_QUERY;
            }
            searchValidatorDocumentListener.setSearchMode(mode);
            searchValidatorDocumentListener.setEnable(validationEnabled);
            searchActionForward.setSearchMode(mode);
            searchActionBackward.setSearchMode(mode);
            markAllFoundAction.setSearchMode(mode);
            configuration.setProperty("gui.searchMode", mode);
            searchResultColorizer.setSearchMode(mode);
            List<Object> list = configuration.getList(confKey);
            searchFieldCbxModel.removeAllElements();
            for (Object o : list) {
                searchFieldCbxModel.addElement(o);
            }
            searchField.setSelectedItem(lastSearch);
        }
    });
    searchMode.setSelectedIndex(selectedSearchMode);
    final JCheckBox markFound = new JCheckBox("Mark search result");
    markFound.setMnemonic(KeyEvent.VK_M);
    searchField.addKeyListener(markAllFoundAction);
    configuration.addConfigurationListener(markAllFoundAction);
    JButton markAllFoundButton = new JButton(markAllFoundAction);
    final JComboBox markColor = new JComboBox(MarkerColors.values());
    markFound.setSelected(configuration.getBoolean("gui.markFound", true));
    markFound.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            boolean selected = markFound.isSelected();
            searchActionForward.setMarkFound(selected);
            searchActionBackward.setMarkFound(selected);
            configuration.setProperty("gui.markFound", markFound.isSelected());
        }
    });
    markColor.setRenderer(new MarkerColorsComboBoxRenderer());
    //      markColor.addActionListener(new ActionListener() {
    //
    //         @Override
    //         public void actionPerformed(ActionEvent e) {
    //            MarkerColors markerColors = (MarkerColors) markColor.getSelectedItem();
    //            searchActionForward.setMarkerColors(markerColors);
    //            searchActionBackward.setMarkerColors(markerColors);
    //            markAllFoundAction.setMarkerColors(markerColors);
    //            configuration.setProperty("gui.markColor", markColor.getSelectedItem());
    //            otrosApplication.setSelectedMarkColors(markerColors);
    //         }
    //      });
    markColor.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            MarkerColors markerColors = (MarkerColors) markColor.getSelectedItem();
            searchActionForward.setMarkerColors(markerColors);
            searchActionBackward.setMarkerColors(markerColors);
            markAllFoundAction.setMarkerColors(markerColors);
            configuration.setProperty("gui.markColor", markColor.getSelectedItem());
            otrosApplication.setSelectedMarkColors(markerColors);
        }
    });
    markColor.getModel()
            .setSelectedItem(configuration.get(MarkerColors.class, "gui.markColor", MarkerColors.Aqua));
    buttonSearch = new JButton(searchActionForward);
    buttonSearch.setMnemonic(KeyEvent.VK_N);
    JButton buttonSearchPrev = new JButton(searchActionBackward);
    buttonSearchPrev.setMnemonic(KeyEvent.VK_P);
    enableDisableComponetsForTabs.addComponet(buttonSearch);
    enableDisableComponetsForTabs.addComponet(buttonSearchPrev);
    enableDisableComponetsForTabs.addComponet(searchField);
    enableDisableComponetsForTabs.addComponet(markFound);
    enableDisableComponetsForTabs.addComponet(markAllFoundButton);
    enableDisableComponetsForTabs.addComponet(searchMode);
    enableDisableComponetsForTabs.addComponet(markColor);
    toolBar.add(searchMode);
    toolBar.add(searchField);
    toolBar.add(buttonSearch);
    toolBar.add(buttonSearchPrev);
    toolBar.add(markFound);
    toolBar.add(markAllFoundButton);
    toolBar.add(markColor);
    JButton nextMarked = new JButton(new JumpToMarkedAction(otrosApplication, Direction.FORWARD));
    nextMarked.setToolTipText(nextMarked.getText());
    nextMarked.setText("");
    nextMarked.setMnemonic(KeyEvent.VK_E);
    enableDisableComponetsForTabs.addComponet(nextMarked);
    toolBar.add(nextMarked);
    JButton prevMarked = new JButton(new JumpToMarkedAction(otrosApplication, Direction.BACKWARD));
    prevMarked.setToolTipText(prevMarked.getText());
    prevMarked.setText("");
    prevMarked.setMnemonic(KeyEvent.VK_R);
    enableDisableComponetsForTabs.addComponet(prevMarked);
    toolBar.add(prevMarked);
    enableDisableComponetsForTabs.addComponet(toolBar.add(new SearchByLevel(otrosApplication, 1, Level.INFO)));
    enableDisableComponetsForTabs
            .addComponet(toolBar.add(new SearchByLevel(otrosApplication, 1, Level.WARNING)));
    enableDisableComponetsForTabs
            .addComponet(toolBar.add(new SearchByLevel(otrosApplication, 1, Level.SEVERE)));
    enableDisableComponetsForTabs.addComponet(toolBar.add(new SearchByLevel(otrosApplication, -1, Level.INFO)));
    enableDisableComponetsForTabs
            .addComponet(toolBar.add(new SearchByLevel(otrosApplication, -1, Level.WARNING)));
    enableDisableComponetsForTabs
            .addComponet(toolBar.add(new SearchByLevel(otrosApplication, -1, Level.SEVERE)));
}

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

private void initExperimental() {
    JMenu menu = new JMenu("Experimental");
    menu.add(new JLabel("Experimental features, can have bugs", Icons.LEVEL_WARNING, SwingConstants.LEADING));
    menu.add(new JSeparator());
    boolean storeOnDisk = StringUtils.equalsIgnoreCase(System.getProperty("cacheEvents"), "true");
    JRadioButtonMenuItem radioButtonMemory = new JRadioButtonMenuItem("Memory - faster, more memory required",
            !storeOnDisk);//w ww.  j  a  v a  2s  .  co  m
    radioButtonMemory.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            System.setProperty("cacheEvents", Boolean.FALSE.toString());
        }
    });
    JRadioButtonMenuItem radioButtonDisk = new JRadioButtonMenuItem(
            "Disk with caching - slower, less memory required", storeOnDisk);
    radioButtonDisk.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            System.setProperty("cacheEvents", Boolean.TRUE.toString());
        }
    });
    final ButtonGroup buttonGroup = new ButtonGroup();
    buttonGroup.add(radioButtonDisk);
    buttonGroup.add(radioButtonMemory);
    menu.add(new JSeparator(JSeparator.VERTICAL));
    menu.add(new JLabel("Keep parsed log events store:"));
    menu.add(radioButtonMemory);
    menu.add(radioButtonDisk);
    final JCheckBox soapFormatterRemoveMultirefsCbx = new JCheckBox();
    soapFormatterRemoveMultirefsCbx
            .setSelected(configuration.getBoolean(ConfKeys.FORMATTER_SOAP_REMOVE_MULTIREFS, false));
    AbstractAction enableMultiRefRemoveFeature = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            SoapMessageFormatter soapMessageFormatter = (SoapMessageFormatter) AllPluginables.getInstance()
                    .getMessageFormatters().getElement(SoapMessageFormatter.class.getName());
            soapMessageFormatter.setRemoveMultiRefs(soapFormatterRemoveMultirefsCbx.isSelected());
            configuration.setProperty(ConfKeys.FORMATTER_SOAP_REMOVE_MULTIREFS,
                    soapFormatterRemoveMultirefsCbx.isSelected());
        }
    };
    enableMultiRefRemoveFeature.putValue(Action.NAME, "Remove mulitRefs from SOAP messages");
    soapFormatterRemoveMultirefsCbx.setAction(enableMultiRefRemoveFeature);
    enableMultiRefRemoveFeature.actionPerformed(null);
    final JCheckBox soapFormatterRemoveXsiForNilElementsCbx = new JCheckBox();
    soapFormatterRemoveXsiForNilElementsCbx
            .setSelected(configuration.getBoolean(FORMATTER_SOAP_REMOVE_XSI_FOR_NIL, false));
    AbstractAction soapFormatterRemoveXsiFromNilAction = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            SoapMessageFormatter soapMessageFormatter = (SoapMessageFormatter) AllPluginables.getInstance()
                    .getMessageFormatters().getElement(SoapMessageFormatter.class.getName());
            soapMessageFormatter
                    .setRemoveXsiForNilElements(soapFormatterRemoveXsiForNilElementsCbx.isSelected());
            configuration.setProperty(FORMATTER_SOAP_REMOVE_XSI_FOR_NIL,
                    soapFormatterRemoveXsiForNilElementsCbx.isSelected());
        }
    };
    soapFormatterRemoveXsiFromNilAction.putValue(Action.NAME,
            "Remove xsi for for NIL elements from SOAP messages");
    soapFormatterRemoveXsiForNilElementsCbx.setAction(soapFormatterRemoveXsiFromNilAction);
    soapFormatterRemoveXsiFromNilAction.actionPerformed(null);
    menu.add(soapFormatterRemoveMultirefsCbx);
    menu.add(soapFormatterRemoveXsiForNilElementsCbx);
    getJMenuBar().add(menu);
    QueryFilter queryFilter = new QueryFilter();
    allPluginables.getLogFiltersContainer().addElement(queryFilter);
    JButton b = new JButton("Throw exception");
    b.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (System.currentTimeMillis() % 2 == 0) {
                throw new RuntimeException("Exception swing action!");
            } else {
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        throw new RuntimeException("Exception from tread!");
                    }
                }).start();
            }
        }
    });
    menu.add(b);
}

From source file:pt.lsts.neptus.plugins.sunfish.awareness.SituationAwareness.java

@Override
public void mouseClicked(MouseEvent event, final StateRenderer2D source) {

    if (event.getButton() == MouseEvent.BUTTON3) {
        final LinkedHashMap<String, Vector<AssetPosition>> positions = positionsByType();
        JPopupMenu popup = new JPopupMenu();
        for (String type : positions.keySet()) {
            JMenu menu = new JMenu(type + "s");
            for (final AssetPosition p : positions.get(type)) {

                if (p.getTimestamp() < oldestTimestampSelection || p.getTimestamp() > newestTimestampSelection)
                    continue;

                Color c = cmap.getColor(1 - (p.getAge() / (7200000.0)));
                String htmlColor = String.format("#%02X%02X%02X", c.getRed(), c.getGreen(), c.getBlue());
                menu.add("<html><b>" + p.getAssetName() + "</b> <font color=" + htmlColor + ">" + getAge(p)
                        + "</font>").addActionListener(new ActionListener() {
                            @Override
                            public void actionPerformed(ActionEvent e) {
                                source.focusLocation(p.getLoc());
                            }/*  ww w  .j  a va  2  s .  c om*/
                        });
            }
            popup.add(menu);
        }

        popup.addSeparator();
        popup.add("Settings").addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                PluginUtils.editPluginProperties(SituationAwareness.this, true);
            }
        });

        popup.add("Fetch asset properties").addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                //                    for (AssetTrack track : assets.values()) {
                //                        track.setColor(new Color(random.nextInt(255), random.nextInt(255), random.nextInt(255)));
                //                    }
                fetchAssetProperties();
            }
        });

        popup.add("Select location sources").addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

                JPanel p = new JPanel();
                p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS));

                for (ILocationProvider l : localizers) {
                    JCheckBox check = new JCheckBox(l.getName());
                    check.setSelected(true);
                    p.add(check);
                    check.setSelected(updateMethodNames.contains(l.getName()));
                }

                int op = JOptionPane.showConfirmDialog(getConsole(), p, "Location update sources",
                        JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
                if (op == JOptionPane.CANCEL_OPTION)
                    return;

                Vector<String> methods = new Vector<String>();
                for (int i = 0; i < p.getComponentCount(); i++) {

                    if (p.getComponent(i) instanceof JCheckBox) {
                        JCheckBox sel = (JCheckBox) p.getComponent(i);
                        if (sel.isSelected())
                            methods.add(sel.getText());
                    }
                }
                updateMethods = StringUtils.join(methods, ", ");
                propertiesChanged();
            }
        });

        popup.add("Select hidden positions types").addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

                JPanel p = new JPanel();
                p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS));

                for (String type : positions.keySet()) {
                    JCheckBox check = new JCheckBox(type);
                    check.setSelected(true);
                    p.add(check);
                    check.setSelected(hiddenPosTypes.contains(type));
                }

                int op = JOptionPane.showConfirmDialog(getConsole(), p, "Position types to be hidden",
                        JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
                if (op == JOptionPane.CANCEL_OPTION)
                    return;

                Vector<String> types = new Vector<String>();
                for (int i = 0; i < p.getComponentCount(); i++) {

                    if (p.getComponent(i) instanceof JCheckBox) {
                        JCheckBox sel = (JCheckBox) p.getComponent(i);
                        if (sel.isSelected())
                            types.add(sel.getText());
                    }
                }
                hiddenTypes = StringUtils.join(types, ", ");
                propertiesChanged();
            }
        });

        popup.addSeparator();
        popup.add("Decision Support").addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                if (dialogDecisionSupport == null) {
                    dialogDecisionSupport = new JDialog(getConsole());
                    dialogDecisionSupport.setModal(false);
                    dialogDecisionSupport.setAlwaysOnTop(true);
                    dialogDecisionSupport.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
                }
                ArrayList<AssetPosition> tags = new ArrayList<AssetPosition>();
                LinkedHashMap<String, Vector<AssetPosition>> positions = positionsByType();
                Vector<AssetPosition> spots = positions.get("SPOT Tag");
                Vector<AssetPosition> argos = positions.get("Argos Tag");
                if (spots != null)
                    tags.addAll(spots);
                if (argos != null)
                    tags.addAll(argos);
                if (!assets.containsKey(getConsole().getMainSystem())) {
                    GuiUtils.errorMessage(getConsole(), "Decision Support", "UUV asset position is unknown");
                    return;
                }
                supportTable.setAssets(assets.get(getConsole().getMainSystem()).getLatest(), tags);
                JXTable table = new JXTable(supportTable);
                dialogDecisionSupport.setContentPane(new JScrollPane(table));
                dialogDecisionSupport.invalidate();
                dialogDecisionSupport.validate();
                dialogDecisionSupport.setSize(600, 300);
                dialogDecisionSupport.setTitle("Decision Support Table");
                dialogDecisionSupport.setVisible(true);
                dialogDecisionSupport.toFront();
                GuiUtils.centerOnScreen(dialogDecisionSupport);
            }
        });
        popup.show(source, event.getX(), event.getY());
    }
    super.mouseClicked(event, source);
}

From source file:pt.ua.dicoogle.rGUI.client.windows.MainWindow.java

/** Creates new form MainWindow */
private MainWindow() {
    this.ranges = new ArrayList<javax.swing.JCheckBox>();
    List<String> names = null;
    try {//from w w w. j a va 2s .c  o m
        names = PluginController4user.getInstance().getPluginNames();
        for (String name : names) {
            JCheckBox newJCB = new JCheckBox(name);
            if (PluginController4user.getInstance().isLocalPlugin(name)) {
                newJCB.setSelected(true);
            }
            this.ranges.add(newJCB);
        }
    } catch (RemoteException ex) {
        Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
    }

    initComponents();

    javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
    jPanel6.setLayout(jPanel6Layout);
    SequentialGroup groupBoxesH = jPanel6Layout.createSequentialGroup().addComponent(jLabel2);
    ParallelGroup groupBoxesV = jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
            .addComponent(jLabel2);

    for (JCheckBox cbox : this.ranges) {
        groupBoxesH.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(cbox);
        groupBoxesV.addComponent(cbox);
    }

    Group groupH = jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(groupBoxesH.addContainerGap(10, Short.MAX_VALUE));

    Group groupV = jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
            jPanel6Layout.createSequentialGroup().addGroup(groupBoxesV).addContainerGap(5, Short.MAX_VALUE));

    jPanel6Layout.setHorizontalGroup(groupH);
    jPanel6Layout.setVerticalGroup(groupV);

    Image image = Toolkit.getDefaultToolkit()
            .getImage(Main.class.getResource("/pt/ua/dicoogle/gfx/trayicon.gif"));
    this.setIconImage(image);

    clientCore = ClientCore.getInstance();

    if (!clientCore.isAdmin()) {
        jMenu10.setVisible(false);
        jMenuItemShutdown.setVisible(false);
        jMenuDirScan2.setVisible(false);

        //jPanel8.setVisible(false);
        jButtonServices.setVisible(false);
        jButtonPreferences.setVisible(false);
        jButtonLogs.setVisible(false);
    }

    if (!clientCore.isUser()) {
        jPanel5.setVisible(false);
        jButtonClientPreferences.setVisible(false);
    } else {
        searchTree = Result2Tree.getInstance();
    }

    if (Main.isFixedClient()) {
        jMenuItemShutdown.setVisible(false);

    } else {
        jMenuItem7.setVisible(false);
    }

    jLabelResults.setText("Enter your terms and hit the button.");
    SelectDefaultSearch.setSelected(true);
    SelectAdvancedSearch.setSelected(false);
    jPanel2.setVisible(false);
    ModalSelectNone.setSelected(false);
    ModalSelectAll.setSelected(true);
    ModalCR.setSelected(true);
    ModalCT.setSelected(true);
    ModalDX.setSelected(true);
    ModalES.setSelected(true);
    ModalMG.setSelected(true);
    ModalMR.setSelected(true);
    ModalNM.setSelected(true);
    ModalOT.setSelected(true);
    ModalPT.setSelected(true);
    ModalRF.setSelected(true);
    ModalSC.setSelected(true);
    ModalUS.setSelected(true);
    ModalXA.setSelected(true);

    StudyDateRangeInitialBoundary.setEnabled(false);
    StudyDateRangeTerminalBoundary.setEnabled(false);
    DateRange.setSelected(false);
    ExactDate.setSelected(true);

    StudyDateRangeInitialBoundaryActivation.setEnabled(false);
    StudyDateRangeTerminalBoundaryActivation.setEnabled(false);
    StudyDateRangeInitialBoundary.setEnabled(false);
    StudyDateRangeTerminalBoundary.setEnabled(false);

    //tree view init
    jTreeResults.setModel(new DefaultTreeModel(Result2Tree.getInstance().getTop()));
    jTreeResults.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    jButtonDownload.setEnabled(false);
    jButtonView.setEnabled(false);
    jButtonDump.setEnabled(false);
    this.resizeWindow();
    registerForMacOSXEvents();
    centerWindow();

    //////////////////////////////////////////////////////////////
    /**
     * This search is needed to autocomplete
     */
    /*
    QueryResults q = new QueryResults("*:*");
            
            
    List<String> items = q.getFields();
            
            
            
    boolean strictMatching = false;
    AutoCompleteDecorator.decorate(jTextFieldQuery, items, strictMatching);
     *
     */

}

From source file:ro.nextreports.designer.querybuilder.RuntimeParametersPanel.java

private void setParameterIgnore(Map<String, Boolean> paramIgnore) {

    if (paramIgnore == null) {
        return;/*from   ww w .j  ava 2 s  .com*/
    }

    for (int i = 0; i < paramList.size(); i++) {
        QueryParameter qp = paramList.get(i);
        if (qp.isHidden()) {
            continue;
        }
        String paramName = qp.getName();
        JCheckBox cb = checks.get(i);

        Boolean value = paramIgnore.get(paramName);
        if (value == null) {
            cb.setSelected(false);
            continue;
        }

        if (value) {
            cb.setSelected(true);
        } else {
            cb.setSelected(false);
        }
    }

}