Example usage for java.awt.event ItemListener ItemListener

List of usage examples for java.awt.event ItemListener ItemListener

Introduction

In this page you can find the example usage for java.awt.event ItemListener ItemListener.

Prototype

ItemListener

Source Link

Usage

From source file:op.controlling.PnlControlling.java

private JPanel createContentPanel4Drugs() {
    JPanel pnlContent = new JPanel(new VerticalLayout());

    /***//from   ww  w  .jav  a 2 s.  c  om
     *      ____                      ____            _             _   _     _     _
     *     |  _ \ _ __ _   _  __ _   / ___|___  _ __ | |_ _ __ ___ | | | |   (_)___| |_
     *     | | | | '__| | | |/ _` | | |   / _ \| '_ \| __| '__/ _ \| | | |   | / __| __|
     *     | |_| | |  | |_| | (_| | | |__| (_) | | | | |_| | | (_) | | | |___| \__ \ |_
     *     |____/|_|   \__,_|\__, |  \____\___/|_| |_|\__|_|  \___/|_| |_____|_|___/\__|
     *                       |___/
     */
    JPanel pnlDrugControl = new JPanel(new BorderLayout());
    final JButton btnDrugControl = GUITools.createHyperlinkButton("opde.controlling.drugs.controllist", null,
            null);
    final JComboBox cmbStation = new JComboBox(StationTools.getAll4Combobox(false));
    btnDrugControl.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            OPDE.getMainframe().setBlocked(true);
            SwingWorker worker = new SwingWorker() {
                @Override
                protected Object doInBackground() throws Exception {
                    return MedStockTools.getListForMedControl((Station) cmbStation.getSelectedItem(),
                            progressClosure);
                }

                @Override
                protected void done() {
                    try {
                        SYSFilesTools.print(get().toString(), true);
                    } catch (ExecutionException ee) {
                        OPDE.fatal(ee);
                    } catch (InterruptedException ie) {
                        // nop
                    }

                    OPDE.getDisplayManager().setProgressBarMessage(null);
                    OPDE.getMainframe().setBlocked(false);
                }
            };
            worker.execute();
        }
    });
    pnlDrugControl.add(btnDrugControl, BorderLayout.WEST);
    pnlDrugControl.add(cmbStation, BorderLayout.EAST);
    pnlContent.add(pnlDrugControl);

    /***
     *     __        __   _       _     _    ____            _             _   _   _                     _   _
     *     \ \      / /__(_) __ _| |__ | |_ / ___|___  _ __ | |_ _ __ ___ | | | \ | | __ _ _ __ ___ ___ | |_(_) ___ ___
     *      \ \ /\ / / _ \ |/ _` | '_ \| __| |   / _ \| '_ \| __| '__/ _ \| | |  \| |/ _` | '__/ __/ _ \| __| |/ __/ __|
     *       \ V  V /  __/ | (_| | | | | |_| |__| (_) | | | | |_| | | (_) | | | |\  | (_| | | | (_| (_) | |_| | (__\__ \
     *        \_/\_/ \___|_|\__, |_| |_|\__|\____\___/|_| |_|\__|_|  \___/|_| |_| \_|\__,_|_|  \___\___/ \__|_|\___|___/
     *                      |___/
     */
    JPanel pnlWeightControllNarcotics = new JPanel(new BorderLayout());
    final JButton btnWeightControl = GUITools
            .createHyperlinkButton("opde.controlling.prescription.narcotics.weightcontrol", null, null);

    //               final JComboBox cmbStation = new JComboBox(StationTools.getAll4Combobox(false));
    btnWeightControl.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            OPDE.getMainframe().setBlocked(true);
            SwingWorker worker = new SwingWorker() {
                @Override
                protected Object doInBackground() throws Exception {

                    return MedStockTools.getNarcoticsWeightList(new LocalDate().minusMonths(1),
                            new LocalDate());
                }

                @Override
                protected void done() {

                    try {
                        SYSFilesTools.print(get().toString(), true);
                    } catch (ExecutionException ee) {
                        OPDE.fatal(ee);
                    } catch (InterruptedException ie) {
                        // nop
                    }

                    OPDE.getDisplayManager().setProgressBarMessage(null);
                    OPDE.getMainframe().setBlocked(false);
                }
            };
            worker.execute();
        }
    });

    final JToggleButton btnNotify = new JToggleButton(SYSConst.icon22mailOFF);
    btnNotify.setSelectedIcon(SYSConst.icon22mailON);
    btnNotify.setSelected(NotificationTools.find(OPDE.getLogin().getUser(),
            NotificationTools.NKEY_DRUG_WEIGHT_CONTROL) != null);
    btnNotify.setToolTipText(SYSTools.xx("opde.notification.enable.for.this.topic"));

    btnNotify.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {

            EntityManager em = OPDE.createEM();
            try {
                em.getTransaction().begin();
                Users user = em.merge(OPDE.getLogin().getUser());
                em.lock(user, LockModeType.OPTIMISTIC_FORCE_INCREMENT);

                if (e.getStateChange() == ItemEvent.SELECTED) {
                    Notification myNotification = em
                            .merge(new Notification(NotificationTools.NKEY_DRUG_WEIGHT_CONTROL, user));
                    user.getNotifications().add(myNotification);
                } else {
                    Notification myNotification = em.merge(NotificationTools.find(OPDE.getLogin().getUser(),
                            NotificationTools.NKEY_DRUG_WEIGHT_CONTROL));
                    user.getNotifications().remove(myNotification);
                    em.remove(myNotification);
                }

                em.getTransaction().commit();
                OPDE.getLogin().setUser(user);
            } catch (OptimisticLockException ole) {
                OPDE.warn(ole);
                if (em.getTransaction().isActive()) {
                    em.getTransaction().rollback();
                }
                if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) {
                    OPDE.getMainframe().emptyFrame();
                    OPDE.getMainframe().afterLogin();
                }
                OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage());
            } catch (Exception ex) {
                if (em.getTransaction().isActive()) {
                    em.getTransaction().rollback();
                }
                OPDE.fatal(ex);
            } finally {
                em.close();
            }

        }
    });

    pnlWeightControllNarcotics.add(btnWeightControl, BorderLayout.WEST);
    pnlWeightControllNarcotics.add(btnNotify, BorderLayout.EAST);
    pnlContent.add(pnlWeightControllNarcotics);

    return pnlContent;
}

From source file:org.nuclos.client.common.NuclosCollectController.java

protected void setupSearchToolBar() {

    final Action actSaveFilter = new CommonAbstractAction(
            getSpringLocaleDelegate().getMessage("NuclosCollectController.9", "Filter speichern"),
            Icons.getInstance().getIconSave16(), getSpringLocaleDelegate().getMessage(
                    "NuclosCollectController.5", "Eingestelltes Suchkriterium als Filter speichern")) {
        @Override//from  w  ww.j a  v  a 2  s.  c o  m
        public void actionPerformed(ActionEvent ev) {
            cmdSaveFilter();
        }
    };

    final Action actRemoveFilter = new CommonAbstractAction(
            getSpringLocaleDelegate().getMessage("NuclosCollectController.8", "Filter l\u00f6schen"),
            Icons.getInstance().getIconDelete16(), getSpringLocaleDelegate()
                    .getMessage("NuclosCollectController.2", "Ausgew\u00e4hlten Filter l\u00f6schen")) {
        @Override
        public void actionPerformed(ActionEvent ev) {
            cmdRemoveFilter();
        }
    };

    //result.add(Box.createHorizontalStrut(5));

    CenteringPanel cpSearchFilter = new CenteringPanel(getSearchPanel().cmbbxSearchFilter) {

        @Override
        public Dimension getMinimumSize() {
            return this.getCenteredComponent().getMinimumSize();
        }

        @Override
        public Dimension getMaximumSize() {
            return this.getCenteredComponent().getPreferredSize();
        }

    };
    cpSearchFilter.setOpaque(false);
    ColoredLabel bl = new ColoredLabel(cpSearchFilter,
            getSpringLocaleDelegate().getMessage("CollectController.Search.Filter", "Filter"));
    bl.setName("blChooseFilter");
    this.getSearchPanel().addToolBarComponent(bl);

    //result.add(cpSearchFilter);
    //result.add(Box.createHorizontalStrut(2));

    this.getSearchPanel().addPopupExtraSeparator();
    JMenuItem btnSaveFilter = this.getSearchPanel().addPopupExtraMenuItem(new JMenuItem(actSaveFilter));
    JMenuItem btnRemoveFilter = this.getSearchPanel().addPopupExtraMenuItem(new JMenuItem(actRemoveFilter));
    //final JButton btnSaveFilter = result.add(actSaveFilter);
    //final JButton btnRemoveFilter = result.add(actRemoveFilter);

    // disable the remove filter action initially:
    actRemoveFilter.setEnabled(false);

    btnSaveFilter.setName("btnSaveFilter");
    btnRemoveFilter.setName("btnRemoveFilter");
    getSearchPanel().cmbbxSearchFilter.setName("cmbbxSearchFilter");
    getSearchPanel().cmbbxSearchFilter.setToolTipText(getSpringLocaleDelegate()
            .getMessage("NuclosCollectController.15", "W\u00e4hlen Sie hier einen Suchfilter aus"));
    getSearchPanel().cmbbxSearchFilter.addActionListener(this.alSearchFilter);

    // set tool tips dynamically:
    getSearchPanel().cmbbxSearchFilter.setRenderer(new DefaultListCellRenderer() {

        @Override
        public Component getListCellRendererComponent(JList lst, Object oValue, int index, boolean bSelected,
                boolean bCellHasFocus) {
            final JComponent result = (JComponent) super.getListCellRendererComponent(lst, oValue, index,
                    bSelected, bCellHasFocus);
            String sToolTip = null;
            if (oValue != null) {
                final SearchFilter filter = (SearchFilter) oValue;

                if (result instanceof JLabel && !StringUtils.isNullOrEmpty(filter.getLabelResourceId())) {
                    ((JLabel) result).setText(getSpringLocaleDelegate()
                            .getTextFallback(filter.getLabelResourceId(), filter.getName()));
                }

                if (!StringUtils.isNullOrEmpty(filter.getDescriptionResourceId())) {
                    sToolTip = getSpringLocaleDelegate().getTextFallback(filter.getDescriptionResourceId(),
                            filter.getDescriptionResourceId());
                } else {
                    sToolTip = filter.getDescription();
                }

                if (filter.getOwner() != null
                        && !(filter.getOwner().equals(Main.getInstance().getMainController().getUserName()))) {
                    sToolTip = sToolTip + " (" + filter.getOwner() + ")";
                }

                result.setToolTipText(sToolTip);
            }
            return result;
        }
    });

    // set the tool tip for the combobox also, as the tool tip for the renderer seems to be
    // taken in dropped down items only:
    getSearchPanel().cmbbxSearchFilter.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent ev) {
            final boolean bSelected = (ev.getStateChange() == ItemEvent.SELECTED);
            boolean bRegularFilterSelected = bSelected;

            String sToolTip = null;
            if (bSelected) {
                final SearchFilter filter = (SearchFilter) ev.getItem();
                assert filter != null;
                sToolTip = filter.getDescription();
                LOG.debug("Filter selected: " + filter.getName());
                bRegularFilterSelected = !filter.isDefaultFilter();
            }
            getSearchPanel().cmbbxSearchFilter.setToolTipText(sToolTip);

            // enable/disable remove filter action - the empty filter cannot be removed:
            actRemoveFilter.setEnabled(bRegularFilterSelected);
        }
    });

    //return result;
}

From source file:org.fhaes.jsea.JSEAFrame.java

/**
 * Setup the GUI components/*from   w  w  w .j  a  va2s. co  m*/
 */
private void setupGui() {

    setTitle("jSEA - Superposed Epoch Analysis");

    getContentPane().setLayout(new MigLayout("", "[1200px,grow,fill]", "[][600px,grow,fill]"));

    initActions();
    setupMenu();
    setupToolbar();

    this.setIconImage(Builder.getApplicationIcon());
    {
        JSplitPane splitPane = new JSplitPane();
        splitPane.setOneTouchExpandable(true);
        getContentPane().add(splitPane, "cell 0 1,alignx left,aligny top");
        splitPane.setLeftComponent(contentPanel);
        contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
        contentPanel.setLayout(new MigLayout("", "[grow,fill]", "[78.00][][][grow][]"));
        {
            JPanel panel = new JPanel();
            panel.setBorder(
                    new TitledBorder(null, "Input Files", TitledBorder.LEADING, TitledBorder.TOP, null, null));
            contentPanel.add(panel, "cell 0 0,grow");
            panel.setLayout(new MigLayout("", "[][][grow][]", "[][]"));
            {
                JLabel lblContinuousTimeSeries = new JLabel("Continuous time series file:");
                panel.add(lblContinuousTimeSeries, "cell 0 0,alignx trailing");
            }
            {
                HelpTipButton label = new HelpTipButton(
                        "Continuous time series data files should be two column comma seperated (CSV) text files.  Column one should contains the years (in sequence), and column two should contain the data values.  If there are header lines or comments in the file, these lines should beginning with a *");
                panel.add(label, "cell 1 0,alignx trailing");
            }
            {
                txtTimeSeriesFile = new JTextField();
                txtwrapper = new TextComponentWrapper(txtTimeSeriesFile,
                        PrefKey.JSEA_CONTINUOUS_TIME_SERIES_FILE, "");
                txtTimeSeriesFile.setEditable(true);
                panel.add(txtTimeSeriesFile, "cell 2 0,growx");
                txtTimeSeriesFile.setColumns(10);
            }
            {
                btnTimeSeriesFile = new JButton();
                btnTimeSeriesFile.setIcon(Builder.getImageIcon("fileopen16.png"));
                btnTimeSeriesFile.setActionCommand("TimeSeriesFileBrowse");
                btnTimeSeriesFile.addActionListener(this);
                btnTimeSeriesFile.setPreferredSize(new Dimension(25, 25));
                btnTimeSeriesFile.setMaximumSize(new Dimension(25, 25));
                btnTimeSeriesFile.putClientProperty("JButton.buttonType", "segmentedTextured");
                btnTimeSeriesFile.putClientProperty("JButton.segmentPosition", "middle");

                panel.add(btnTimeSeriesFile, "cell 3 0");
            }
            {
                JLabel lblEventListFile = new JLabel("Event list file:");
                panel.add(lblEventListFile, "cell 0 1,alignx trailing");
            }
            {
                HelpTipButton helpTipButton = new HelpTipButton(
                        "Event data files should be a text file with a single column of integer year values.  If there are any header or comment lines, these should begin with a *");
                panel.add(helpTipButton, "cell 1 1,alignx trailing");
            }
            {
                txtEventListFile = new JTextField();
                new TextComponentWrapper(txtEventListFile, PrefKey.JSEA_EVENT_LIST_FILE, "");
                txtEventListFile.setEditable(false);
                panel.add(txtEventListFile, "cell 2 1,growx");
                txtEventListFile.setColumns(10);
            }
            {
                btnEventListFile = new JButton();
                btnEventListFile.setIcon(Builder.getImageIcon("fileopen16.png"));
                btnEventListFile.setActionCommand("EventListFileBrowse");
                btnEventListFile.addActionListener(this);
                btnEventListFile.setPreferredSize(new Dimension(25, 25));
                btnEventListFile.setMaximumSize(new Dimension(25, 25));
                btnEventListFile.putClientProperty("JButton.buttonType", "segmentedTextured");
                btnEventListFile.putClientProperty("JButton.segmentPosition", "middle");
                panel.add(btnEventListFile, "cell 3 1");
            }
        }
        {
            JPanel panel = new JPanel();
            panel.setBorder(new TitledBorder(null, "Window, Simulation and Statistics", TitledBorder.LEADING,
                    TitledBorder.TOP, null, null));
            contentPanel.add(panel, "cell 0 1,grow");
            panel.setLayout(new MigLayout("", "[right][][fill][10px:10px:10px][right][][90.00,grow,fill]",
                    "[grow][][][]"));
            {
                JLabel lblYears = new JLabel("Years to analyse:");
                panel.add(lblYears, "cell 0 0");
            }
            {
                HelpTipButton helpTipButton = new HelpTipButton(
                        "Specify which years from the dataset to analyse.");
                panel.add(helpTipButton, "cell 1 0");
            }
            {
                JPanel panel_1 = new JPanel();
                panel.add(panel_1, "cell 2 0 5 1,grow");
                panel_1.setLayout(new MigLayout("fill, insets 0", "[80px:80px][][80px:80px,fill][grow]", "[]"));
                {
                    spnFirstYear = new JSpinner();
                    spnFirstYear.setEnabled(false);
                    panel_1.add(spnFirstYear, "cell 0 0,growx");
                    spnFirstYear.setModel(new SpinnerNumberModel(new Integer(0), null, null, new Integer(1)));
                    spnFirstYear.setEditor(new JSpinner.NumberEditor(spnFirstYear, "#"));
                    new SpinnerWrapper(spnFirstYear, PrefKey.JSEA_FIRST_YEAR, 0);
                }
                {
                    JLabel lblTo = new JLabel("-");
                    panel_1.add(lblTo, "cell 1 0");
                }
                {
                    spnLastYear = new JSpinner();
                    spnLastYear.setEnabled(false);
                    panel_1.add(spnLastYear, "cell 2 0");
                    spnLastYear.setModel(new SpinnerNumberModel(new Integer(2020), null, null, new Integer(1)));
                    spnLastYear.setEditor(new JSpinner.NumberEditor(spnLastYear, "#"));
                    new SpinnerWrapper(spnLastYear, PrefKey.JSEA_LAST_YEAR, 2020);
                }
                {
                    chkAllYears = new JCheckBox("all years in series");
                    chkAllYears.setSelected(true);
                    chkAllYears.setActionCommand("AllYearsCheckbox");
                    chkAllYears.addActionListener(this);
                    panel_1.add(chkAllYears, "cell 3 0");
                }
            }
            {
                JLabel lblLagsPriorTo = new JLabel("Lags prior to event:");
                panel.add(lblLagsPriorTo, "cell 0 1");
            }
            {
                HelpTipButton helpTipButton = new HelpTipButton("");
                panel.add(helpTipButton, "cell 1 1");
            }
            {
                spnLagsPrior = new JSpinner();
                new SpinnerWrapper(spnLagsPrior, PrefKey.JSEA_LAGS_PRIOR_TO_EVENT, 6);
                panel.add(spnLagsPrior, "cell 2 1,growx");
                // spnLagsPrior.setModel(new SpinnerNumberModel(6, 1, 100, 1));
                spnLagsPrior.addChangeListener(new ChangeListener() {

                    @Override
                    public void stateChanged(ChangeEvent e) {

                        segmentationPanel.table.tableModel.clearSegments();
                        validateForm();
                    }
                });
            }
            {
                JLabel lblSimulationsToRun = new JLabel("Simulations:");
                panel.add(lblSimulationsToRun, "cell 4 1");
            }
            {
                HelpTipButton helpTipButton = new HelpTipButton(
                        "Number of simulations to run.  Increasing the number of simulations increases the analysis time.");
                panel.add(helpTipButton, "cell 5 1");
            }
            {
                spnSimulationsToRun = new JSpinner();
                new SpinnerWrapper(spnSimulationsToRun, PrefKey.JSEA_SIMULATION_COUNT, 1000);
                panel.add(spnSimulationsToRun, "cell 6 1");
                spnSimulationsToRun.setModel(new SpinnerNumberModel(1000, 1, 10096, 1));
            }
            {
                JLabel lblLagsFollowingThe = new JLabel("Lags following the event:");
                panel.add(lblLagsFollowingThe, "cell 0 2");
            }
            {
                HelpTipButton helpTipButton = new HelpTipButton("");
                panel.add(helpTipButton, "cell 1 2");
            }
            {
                spnLagsAfter = new JSpinner();
                new SpinnerWrapper(spnLagsAfter, PrefKey.JSEA_LAGS_AFTER_EVENT, 4);
                panel.add(spnLagsAfter, "cell 2 2,growx");
                spnLagsAfter.addChangeListener(new ChangeListener() {

                    @Override
                    public void stateChanged(ChangeEvent e) {

                        segmentationPanel.table.tableModel.clearSegments();
                        validateForm();
                    }
                });
            }
            {
                JLabel lblSeedNumber = new JLabel("Seed number:");
                panel.add(lblSeedNumber, "cell 4 2");
            }
            {
                HelpTipButton helpTipButton = new HelpTipButton(
                        "The analysis requires a pseudo-random component which is seeded with the seed number (a large integer value).  Running analyses with the same seed number enables produces the same results.  You can leave the seed as the default number unless you specifically want to generate results from a different randomised pool.");
                panel.add(helpTipButton, "cell 5 2");
            }
            {
                spnSeedNumber = new JSpinner();
                new SpinnerWrapper(spnSeedNumber, PrefKey.JSEA_SEED_NUMBER, 30188);
                panel.add(spnSeedNumber, "cell 6 2");
                spnSeedNumber.setModel(new SpinnerNumberModel(30188, 10000, 1000000, 1));
            }
            {
                JLabel lblIncludeIncompleteWindow = new JLabel("Include incomplete epoch:");
                panel.add(lblIncludeIncompleteWindow, "cell 0 3");
            }
            {
                HelpTipButton helpTipButton = new HelpTipButton("");
                panel.add(helpTipButton, "cell 1 3");
            }
            {
                chkIncludeIncompleteWindow = new JCheckBox("");
                new CheckBoxWrapper(chkIncludeIncompleteWindow, PrefKey.JSEA_INCLUDE_INCOMPLETE_WINDOW, false);

                panel.add(chkIncludeIncompleteWindow, "cell 2 3");
            }
            {
                JLabel lblPvalue = new JLabel("p-value:");
                panel.add(lblPvalue, "cell 4 3");
            }
            {
                HelpTipButton helpTipButton = new HelpTipButton(
                        "The cutoff value to use for statistical significance");
                panel.add(helpTipButton, "cell 5 3,alignx trailing");
            }
            {
                cbxPValue = new JComboBox();
                panel.add(cbxPValue, "cell 6 3");
                cbxPValue.setModel(new DefaultComboBoxModel(new Double[] { 0.05, 0.01, 0.001 }));
            }
        }
        {
            JPanel panel = new JPanel();
            panel.setBorder(new TitledBorder(null, "Chart Options", TitledBorder.LEADING, TitledBorder.TOP,
                    null, null));
            contentPanel.add(panel, "cell 0 2,grow");

            panel.setLayout(new MigLayout("", "[right][][grow]", "[][]"));
            {
                JLabel lblTitleOfChart = new JLabel("Title of chart:");
                panel.add(lblTitleOfChart, "cell 0 0,alignx trailing");
            }
            {
                HelpTipButton helpTipButton = new HelpTipButton(
                        "Title to use on the chart.  The placeholder {segment} is replaced with the years of the segment being plotted.");
                panel.add(helpTipButton, "cell 1 0,alignx trailing");
            }
            {
                txtChartTitle = new JTextField();
                txtChartTitle.setToolTipText("<html>Title to be displayed on the<br/>" + "chart output");
                new TextComponentWrapper(txtChartTitle, PrefKey.JSEA_CHART_TITLE, "Chart title {segment}");
                panel.add(txtChartTitle, "cell 2 0,growx,aligny top");
                txtChartTitle.setColumns(10);
            }
            {
                JLabel lblYaxisLabel = new JLabel("Continuous series (y-axis) label");
                panel.add(lblYaxisLabel, "cell 0 1,alignx trailing");
            }
            {
                txtYAxisLabel = new JTextField();
                txtYAxisLabel
                        .setToolTipText("<html>Label to be displayed on the<br/> " + "continuous series axis");
                new TextComponentWrapper(txtYAxisLabel, PrefKey.JSEA_YAXIS_LABEL, "Y Axis");
                panel.add(txtYAxisLabel, "cell 2 1,growx");
                txtYAxisLabel.setColumns(10);
            }
        }
        {
            // Segmentation implementation used from FHSampleSize
            segmentationPanel = new SegmentationPanel();
            segmentationPanel.chkSegmentation.setText("Process subset or segments of events?");
            segmentationPanel.chkSegmentation.setActionCommand("SegmentationMode");
            segmentationPanel.chkSegmentation.addActionListener(this);
            contentPanel.add(segmentationPanel, "cell 0 3,grow");
        }
        {
            tabbedPane = new JTabbedPane(JTabbedPane.BOTTOM);
            splitPane.setRightComponent(tabbedPane);
            {
                summaryPanel = new JPanel();
                tabbedPane.addTab("Summary ", Builder.getImageIcon("info.png"), summaryPanel, null);
                summaryPanel.setLayout(new BorderLayout(0, 0));
                {
                    scrollPane = new JScrollPane();
                    summaryPanel.add(scrollPane);
                    {
                        txtSummary = new JTextArea();
                        txtSummary.setEditable(false);
                        scrollPane.setViewportView(txtSummary);
                        JMenuItem mntmCopy = new JMenuItem(actionCopy);
                        JPopupMenu popup = new JPopupMenu();
                        addPopup(scrollPane, popup);
                        popup.add(mntmCopy);
                    }
                }
            }
            {
                dataPanel = new JPanel();
                tabbedPane.addTab("Data ", Builder.getImageIcon("table.png"), dataPanel, null);
                dataPanel.setLayout(new MigLayout("", "[grow,fill]", "[grow]"));
                {
                    JSplitPane splitPaneDataTables = new JSplitPane();
                    splitPaneDataTables.setResizeWeight(0.5);
                    splitPaneDataTables.setOneTouchExpandable(true);
                    splitPaneDataTables.setOrientation(JSplitPane.VERTICAL_SPLIT);
                    dataPanel.add(splitPaneDataTables, "cell 0 0,grow");
                    {
                        JPanel panel = new JPanel();
                        splitPaneDataTables.setLeftComponent(panel);
                        panel.setBorder(new TitledBorder(null, "Actual key events", TitledBorder.LEADING,
                                TitledBorder.TOP, null, null));
                        panel.setLayout(new MigLayout("", "[227.00px,grow,fill]", "[68.00px,grow,fill]"));
                        {
                            JScrollPane scrollPane = new JScrollPane();
                            panel.add(scrollPane, "cell 0 0,grow");
                            {
                                tblActual = new JXTable();
                                adapterActualTable = new JTableSpreadsheetByRowAdapter(tblActual);
                                scrollPane.setViewportView(tblActual);
                                tblActual.setSortable(false);
                                JMenuItem mntmCopy = new JMenuItem(actionCopy);
                                JPopupMenu popup = new JPopupMenu();
                                addPopup(tblActual, popup);
                                popup.add(mntmCopy);
                            }
                        }
                    }
                    {
                        JPanel panel = new JPanel();
                        splitPaneDataTables.setRightComponent(panel);
                        panel.setBorder(new TitledBorder(null, "Simulation results", TitledBorder.LEADING,
                                TitledBorder.TOP, null, null));
                        panel.setLayout(new MigLayout("", "[grow,fill]", "[grow,fill]"));
                        {
                            JScrollPane scrollPane = new JScrollPane();
                            panel.add(scrollPane, "cell 0 0,grow");
                            {
                                tblSimulation = new JXTable();
                                adapterSimulationTable = new JTableSpreadsheetByRowAdapter(tblSimulation);
                                scrollPane.setViewportView(tblSimulation);
                                tblSimulation.setSortable(false);
                                JMenuItem mntmCopy = new JMenuItem(actionCopy);
                                JPopupMenu popup = new JPopupMenu();
                                addPopup(tblSimulation, popup);
                                popup.add(mntmCopy);
                            }
                        }
                    }
                    splitPaneDataTables.setDividerLocation(0.5f);
                }
            }
            {
                chartPanel = new JPanel();
                tabbedPane.addTab("Chart ", Builder.getImageIcon("barchart.png"), chartPanel, null);
                chartPanel.setLayout(new MigLayout("", "[][grow]", "[][grow]"));
                {
                    segmentComboBox = new JComboBox();
                    segmentComboBox.addItemListener(new ItemListener() {

                        @Override
                        public void itemStateChanged(ItemEvent arg0) {

                            if (segmentComboBox.getItemCount() > 0) {
                                barChart = new JSEABarChart(
                                        jsea.getChartList().get(segmentComboBox.getSelectedIndex()));
                                barChart.setMaximumDrawHeight(MAX_DRAW_HEIGHT);
                                barChart.setMaximumDrawWidth(MAX_DRAW_WIDTH);
                                chartPanel.removeAll();
                                chartPanel.add(plotSegmentLabel, "cell 0 0,alignx center,aligny center");
                                chartPanel.add(segmentComboBox, "cell 1 0,growx,aligny center");
                                chartPanel.add(barChart, "cell 0 1 2 1,grow");
                                chartPanel.revalidate();
                                chartPanel.repaint();
                            }
                        }
                    });
                    {
                        plotSegmentLabel = new JLabel("Plot Segment: ");
                        chartPanel.add(plotSegmentLabel, "cell 0 0,alignx center,aligny center");
                    }
                    chartPanel.add(segmentComboBox, "cell 1 0,growx,aligny center");
                }
            }
        }
    }

    pack();
    validateForm();
    setAnalysisAvailable(false);
    setExtendedState(this.getExtendedState() | JFrame.MAXIMIZED_BOTH);
}

From source file:pcgen.gui2.PCGenFrame.java

@Override
public Boolean maybeShowWarningConfirm(String title, String message, String checkBoxText,
        final PropertyContext context, final String contextProp) {
    if (!context.getBoolean(contextProp, true)) {
        return null;
    }//from w ww.j  a v a2s . co  m
    final JCheckBox checkBox = new JCheckBox(checkBoxText, true);
    checkBox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            context.setBoolean(contextProp, checkBox.isSelected());
        }

    });
    JPanel panel = buildMessageLabelPanel(message, checkBox);
    int ret = JOptionPane.showConfirmDialog(this, panel, title, JOptionPane.YES_NO_OPTION,
            JOptionPane.WARNING_MESSAGE);
    return ret == JOptionPane.YES_OPTION;
}

From source file:edu.ku.brc.specify.tasks.subpane.qb.QueryFieldPanel.java

/**
 * @param iconSize// w  ww  .  j  av a 2s .  co m
 * @param returnWidths
 * @return
 */
protected int[] buildControlLayout(final IconManager.IconSize iconSize, final boolean returnWidths,
        final Component saveBtn) {
    FocusListener focusListener = new FocusListener() {

        /*
         * (non-Javadoc)
         * 
         * @see java.awt.event.FocusListener#focusGained(java.awt.event.FocusEvent)
         */
        // @Override
        public void focusGained(FocusEvent e) {
            //Checking oppositeComponent to work around
            //weird behavior after addBtn is clicked which
            //causes top queryFieldPanel to be selected.
            if (ownerQuery.getAddBtn() != null && e.getOppositeComponent() != ownerQuery.getAddBtn()) {
                ownerQuery.selectQFP(QueryFieldPanel.this);
            }

        }

        /*
         * (non-Javadoc)
         * 
         * @see java.awt.event.FocusListener#focusLost(java.awt.event.FocusEvent)
         */
        // @Override
        public void focusLost(FocusEvent e) {
            // nada
        }

    };

    KeyListener enterListener = new KeyListener() {

        @Override
        public void keyPressed(KeyEvent arg0) {
            //nuthin
        }

        @Override
        public void keyReleased(KeyEvent arg0) {
            //nuthin
        }

        @Override
        public void keyTyped(KeyEvent arg0) {
            if (arg0.getKeyChar() == KeyEvent.VK_ENTER && ownerQuery != null) {
                ownerQuery.doSearch();
            }

        }

    };

    comparators = getComparatorList(fieldQRI);
    //XXX need to build schemaItem for header panel too...
    if (schemaMapping != null) {
        schemaItemCBX = edu.ku.brc.ui.UIHelper.createComboBox();
        schemaItemCBX.addItem("empty"); //to work around validator blow up for empty lists.
        DataChangeNotifier dcnsi = validator.hookupComponent(schemaItemCBX, "sicbx", UIValidator.Type.Changed,
                "", true);
        schemaItemCBX.addActionListener(dcnsi);

        schemaItemCBX.addItemListener(new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
                if (!QueryFieldPanel.this.ownerQuery.isUpdatingAvailableConcepts()) {
                    if (e.getStateChange() == ItemEvent.SELECTED) {
                        if (e.getItem() instanceof SpExportSchemaItem) {
                            QueryFieldPanel.this.schemaItem = (SpExportSchemaItem) e.getItem();
                        } else {
                            SpExportSchemaItemMapping m = QueryFieldPanel.this.getItemMapping();
                            SpExportSchemaItem si = QueryFieldPanel.this.schemaItem;
                            String item = e.getItem().toString();
                            if (StringUtils.isNotBlank(item)
                                    && ownerQuery.isAvailableExportFieldName(QueryFieldPanel.this, item)) {
                                if (m != null) {
                                    m.setExportedFieldName(e.getItem().toString());
                                }
                                if (si != null) {
                                    si.setFieldName(e.getItem().toString());
                                }
                            } else {
                                if (StringUtils.isBlank(item)) {
                                    UIRegistry.displayErrorDlgLocalized(
                                            "QueryFieldPanel.ExportFieldNameInvalid", item);
                                } else {
                                    UIRegistry.displayErrorDlgLocalized(
                                            "QueryFieldPanel.ExportFieldNameAlreadyUsed", item);
                                }
                                schemaItemCBX.setSelectedIndex(0);
                            }
                        }
                        ownerQuery.updateAvailableConcepts();
                    }
                }
            }
        });
    } else {
        schemaItemCBX = null;
    }

    iconLabel = new JLabel(icon);
    iconLabel.addFocusListener(focusListener);
    String fieldLabelText = fieldQRI != null ? fieldQRI.getTitle() : "WXYZ";
    if (fieldQRI instanceof RelQRI) {
        DBRelationshipInfo.RelationshipType relType = ((RelQRI) fieldQRI).getRelationshipInfo().getType();
        if (relType.equals(DBRelationshipInfo.RelationshipType.OneToMany)
                || relType.equals(DBRelationshipInfo.RelationshipType.ManyToMany)) {
            fieldLabelText += " " + UIRegistry.getResourceString("QB_AGGREGATED");
        } else {
            fieldLabelText += " " + UIRegistry.getResourceString("QB_FORMATTED");
        }

    }
    fieldLabel = createLabel(fieldLabelText);
    fieldLabel.addFocusListener(focusListener);
    fieldLabel.addKeyListener(enterListener);
    isNotCheckbox = createCheckBox("isNotCheckbox");
    isNotCheckbox.addFocusListener(focusListener);
    isNotCheckbox.addKeyListener(enterListener);
    operatorCBX = createComboBox(comparators);
    operatorCBX.addFocusListener(focusListener);
    operatorCBX.addKeyListener(enterListener);
    boolean isBool = fieldQRI != null && fieldQRI.getDataClass().equals(Boolean.class);
    if (!isBool) {
        operatorCBX.addItemListener(new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                    criteria.setVisible(!operatorCBX.getSelectedItem().equals(SpQueryField.OperatorType.EMPTY));
                }
            }
        });
    }
    if (pickList == null) {
        boolean hasBetweenOp = false;
        for (int o = 0; o < comparators.length; o++) {
            if (comparators[o].equals(OperatorType.BETWEEN)) {
                hasBetweenOp = true;
                break;
            }
        }
        if (hasBetweenOp) {
            criteria = new CriteriaPair(enterListener);
            operatorCBX.addActionListener(this);
        } else {
            criteria = createTextField("1");
            criteria.addKeyListener(enterListener);
        }
    } else {
        criteria = createPickList(saveBtn);
        if (!ownerQuery.isPromptMode()) {
            ((PickListCriteriaCombo) criteria)
                    .setCurrentOp((SpQueryField.OperatorType) operatorCBX.getModel().getElementAt(0));
        }
        criteria.addKeyListener(enterListener);
        operatorCBX.addItemListener(new ItemListener() {

            /*
             * (non-Javadoc)
             * 
             * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
             */
            //@Override
            public void itemStateChanged(ItemEvent e) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                    // System.out.println("setting curront op");
                    ((PickListCriteriaCombo) criteria)
                            .setCurrentOp((SpQueryField.OperatorType) operatorCBX.getSelectedItem());
                }
            }

        });
    }
    //criteria.addFocusListener(focusListener);

    sortCheckbox = new MultiStateIconButon(
            new ImageIcon[] { IconManager.getImage("GrayDot", IconManager.IconSize.Std16),
                    IconManager.getImage("UpArrow", IconManager.IconSize.Std16),
                    IconManager.getImage("DownArrow", IconManager.IconSize.Std16) });
    DataChangeNotifier dcn = validator.hookupComponent(sortCheckbox, "scb", UIValidator.Type.Changed, "", true);
    sortCheckbox.addFocusListener(focusListener);
    sortCheckbox.addActionListener(dcn);
    sortCheckbox.addKeyListener(enterListener);
    if (!this.ownerQuery.isPromptMode()) {
        isEnforcedCkbx = createCheckBox("isEnforcedCkbx");
        dcn = validator.hookupComponent(isEnforcedCkbx, "iecb", UIValidator.Type.Changed, "", true);
        isEnforcedCkbx.addActionListener(dcn);
        isEnforcedCkbx.addFocusListener(focusListener);
        isEnforcedCkbx.addKeyListener(enterListener);
    }
    if (!this.ownerQuery.isPromptMode()) {
        isDisplayedCkbx = createCheckBox("isDisplayedCkbx");
        dcn = validator.hookupComponent(isDisplayedCkbx, "idcb", UIValidator.Type.Changed, "", true);
        isDisplayedCkbx.addFocusListener(focusListener);
        isDisplayedCkbx.addKeyListener(enterListener);
        isDisplayedCkbx.addActionListener(dcn);
        isDisplayedCkbx.addActionListener(new ActionListener() {

            /* (non-Javadoc)
             * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
             */
            @Override
            public void actionPerformed(ActionEvent arg0) {
                SwingUtilities.invokeLater(new Runnable() {

                    /* (non-Javadoc)
                     * @see java.lang.Runnable#run()
                     */
                    @Override
                    public void run() {
                        sortCheckbox.setEnabled(isDisplayedCkbx.isSelected());
                        ownerQuery.changeNotification(QueryFieldPanel.this);
                    }
                });
            }
        });
        isPromptCkbx = createCheckBox("isPromptCkbx");
        dcn = validator.hookupComponent(isPromptCkbx, "ipcb", UIValidator.Type.Changed, "", true);
        isPromptCkbx.addActionListener(dcn);
        isPromptCkbx.addFocusListener(focusListener);
        isPromptCkbx.addKeyListener(enterListener);
        closeBtn = edu.ku.brc.ui.UIHelper.createIconBtn("Close", "QB_REMOVE_FLD", new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                boolean clearIt = schemaItem != null;
                ownerQuery.removeQueryFieldItem((QueryFieldPanel) ((JComponent) ae.getSource()).getParent());
                if (clearIt) {
                    setField(null, null);
                }
            }
        });
        closeBtn.setEnabled(true);
        closeBtn.setFocusable(false);
        closeBtn.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseEntered(MouseEvent e) {
                ((JButton) e.getSource()).setIcon(IconManager.getIcon("CloseHover"));
                super.mouseEntered(e);
            }

            @Override
            public void mouseExited(MouseEvent e) {
                ((JButton) e.getSource()).setIcon(IconManager.getIcon("Close"));
                super.mouseExited(e);
            }

        });
    } else {
        isDisplayedCkbx = null;
        this.isPromptCkbx = null;
        this.isEnforcedCkbx = null;
        this.closeBtn = null;
    }

    JComponent[] qComps = { iconLabel, fieldLabel, isNotCheckbox, operatorCBX, criteria, sortCheckbox,
            isDisplayedCkbx, isPromptCkbx, isEnforcedCkbx, closeBtn, null };
    JComponent[] sComps = { schemaItemCBX, iconLabel, fieldLabel, isNotCheckbox, operatorCBX, criteria,
            sortCheckbox, isDisplayedCkbx, isEnforcedCkbx, closeBtn, null };
    // 0 1 2 3 4 5 6 7 8 9
    if (schemaMapping == null) {
        comps = qComps;
    } else {
        comps = sComps;
    }

    StringBuilder sb = new StringBuilder();
    Integer[] qFixedCmps = { 300 };
    Integer[] sFixedCmps = { 268, 300 };
    Integer[] fixedCmps;
    if (schemaMapping != null) {
        fixedCmps = sFixedCmps;
    } else {
        fixedCmps = qFixedCmps;
    }
    if (columnDefStr == null) {
        for (int i = 0; i < comps.length; i++) {
            sb.append(i == 0 ? "" : ",");
            if (isCenteredComp(i))
                sb.append("c:");
            if (i >= fixedCmps.length) {
                sb.append("p");
            } else {
                sb.append(fixedCmps[i] + "px");
            }
            if (isGrowComp(i))
                sb.append(":g");
            sb.append(",4px");
        }
    } else {
        sb.append(columnDefStr);
    }

    PanelBuilder builder = new PanelBuilder(new FormLayout("3px, " + sb.toString() + ", 3px", "3px, p, 3px"),
            this);
    CellConstraints cc = new CellConstraints();

    int col = 1;
    for (JComponent comp : comps) {
        if (comp != null) {
            builder.add(comp, cc.xy(col + 1, 2));
        }
        col += 2;
    }

    if (fieldQRI != null) {
        icon = IconManager.getIcon(fieldQRI.getTableInfo().getName(), iconSize);
        setIcon(icon);
    }
    if (!ownerQuery.isPromptMode()) {
        isDisplayedCkbx.setSelected(true);
        isPromptCkbx.setSelected(!(fieldQRI instanceof RelQRI));
        isEnforcedCkbx.setSelected(false);
    }

    if (fieldQRI == null && !returnWidths) {
        for (int c = 1; c < comps.length; c++) {
            if (comps[c] != null) {
                comps[c].setVisible(false);
            }
        }
    } else {
        // for now
        boolean isRel = fieldQRI != null && fieldQRI instanceof RelQRI;
        boolean isTreeLevel = fieldQRI instanceof TreeLevelQRI;
        isNotCheckbox.setVisible(!isRel || pickList != null);
        operatorCBX.setVisible(!isRel || pickList != null);
        criteria.setVisible((!isRel && !isBool) || pickList != null);
        if (schemaMapping != null) {
            this.sortCheckbox.setVisible(!(isTreeLevel || isRel));
        } else {
            if (!isRel) {
                this.sortCheckbox.setVisible(true);
            } else {
                this.sortCheckbox.setVisible(
                        ((RelQRI) fieldQRI).getRelationshipInfo().getType() != RelationshipType.OneToMany);
            }
        }

        if (!ownerQuery.isPromptMode()) {
            isDisplayedCkbx.setVisible(!isRel);
            isPromptCkbx.setVisible(!isRel);
            isEnforcedCkbx.setVisible(!isRel);
        }
    }
    validate();
    doLayout();

    int[] widths = null;
    if (returnWidths) {
        widths = new int[comps.length];
        for (int i = 0; i < comps.length; i++) {
            widths[i] = comps[i] != null ? comps[i].getSize().width : 0;
        }
        if (this.schemaMapping == null) {
            widths[0] = iconSize.size();
            widths[1] = 200;
        } else {
            widths[1] = iconSize.size();
            widths[2] = 200;
        }
    }
    return widths;
}

From source file:org.bigwiv.blastgraph.gui.BlastGraphFrame.java

private void refreshColorControl() {
    // find the minimal taxon length and attribute key collection
    Collection<HitVertex> hvs = Global.graph.getVertices();
    int minTaxon = 0;
    Collection<String> minKeySet = new HashSet<String>();
    for (HitVertex hitVertex : hvs) {
        int value = hitVertex.getTaxon().getLevels();
        Set<String> keySet = hitVertex.getAllAttributes().keySet();
        if (minTaxon == 0) {
            minTaxon = value;/*from   ww  w.j  a va  2 s .c  om*/
            minKeySet = keySet;
        } else {
            minTaxon = value < minTaxon ? value : minTaxon;
            minKeySet = CollectionUtils.intersection(minKeySet, keySet);
        }
    }

    // clear taxons and attrs
    // final int seleceted = colorComboBox.getSelectedIndex();
    for (int i = colorComboBox.getItemCount() - 1; i >= 5; i--) {
        colorComboBox.removeItemAt(i);
    }

    // add taxons
    for (int i = 0; i < minTaxon; i++) {
        colorComboBox.addItem("taxon" + i);
    }

    // add attrs
    for (String string : minKeySet) {
        colorComboBox.addItem(string);
    }

    colorComboBox.setSelectedIndex(0);

    final int min = minTaxon;

    if (colorItemListener != null) {
        colorComboBox.removeItemListener(colorItemListener);
    }

    colorItemListener = new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            int index = colorComboBox.getSelectedIndex();
            String attr = (String) colorComboBox.getSelectedItem();
            ArrayList<String> attrValues = new ArrayList<String>();
            Map<String, Color> colorMap = new HashMap<String, Color>();
            Collection<HitVertex> hvs = Global.graph.getVertices();

            String value = "";
            if (index != 0) {
                for (HitVertex hitVertex : hvs) {
                    if (index < 5) {
                        switch (index) {
                        case 1:
                            value = hitVertex.getIndex() + "";
                            break;
                        case 2:
                            value = hitVertex.getStrand() + "";
                            break;
                        case 3:
                            value = hitVertex.getGenomeAcc();
                            break;
                        case 4:
                            value = hitVertex.getOrganism();
                            break;
                        default:
                            break;
                        }
                    } else if (index < (5 + min)) {
                        value = hitVertex.getTaxon().getTaxon(index - 5);
                    } else {
                        value = hitVertex.getAttribute((String) colorComboBox.getItemAt(index));

                        System.out.println(index + " " + "attr");
                    }

                    if (!attrValues.contains(value)) {
                        attrValues.add(value);
                    }
                }
            }

            float hue = 0;
            int size = attrValues.size();
            for (int i = 0; i < size; i++) {
                Color c = Color.getHSBColor(hue, 0.85f, 1.0f);
                colorMap.put(attrValues.get(i), c);
                hue += 1.0f / size;
            }

            if (index < (5 + min)) {
                rc.setVertexFillPaintTransformer(new VertexPainter(index, colorMap));
            } else {
                rc.setVertexFillPaintTransformer(new AttrVertexPainter(attr, colorMap));
            }
            vv.repaint();
        }
    };

    colorComboBox.addItemListener(colorItemListener);
}

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 www  .j av a2  s .c o  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:org.forester.archaeopteryx.ControlPanel.java

public void setSequenceRelationQueries(final Collection<Sequence> sequenceRelationQueries) {
    final JComboBox box = getSequenceRelationBox();
    while (box.getItemCount() > 1) {
        box.removeItemAt(1);//from   ww  w.  ja  va2  s. c o m
    }
    final HashMap<String, Sequence> sequencesByName = new HashMap<String, Sequence>();
    final SequenceRelation.SEQUENCE_RELATION_TYPE relationType = (SequenceRelation.SEQUENCE_RELATION_TYPE) _sequence_relation_type_box
            .getSelectedItem();
    if (relationType == null) {
        return;
    }
    final ArrayList<String> sequenceNamesToAdd = new ArrayList<String>();
    for (final Sequence seq : sequenceRelationQueries) {
        if (seq.hasSequenceRelations()) {
            boolean fFoundForCurrentType = false;
            for (final SequenceRelation sq : seq.getSequenceRelations()) {
                if (sq.getType().equals(relationType)) {
                    fFoundForCurrentType = true;
                    break;
                }
            }
            if (fFoundForCurrentType) {
                sequenceNamesToAdd.add(seq.getName());
                sequencesByName.put(seq.getName(), seq);
            }
        }
    }
    // sort sequences by name before adding them to the combo
    final String[] sequenceNameArray = sequenceNamesToAdd.toArray(new String[sequenceNamesToAdd.size()]);
    Arrays.sort(sequenceNameArray, String.CASE_INSENSITIVE_ORDER);
    for (final String seqName : sequenceNameArray) {
        box.addItem(seqName);
    }
    for (final ItemListener oldItemListener : box.getItemListeners()) {
        box.removeItemListener(oldItemListener);
    }
    box.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(final ItemEvent e) {
            _selected_query_seq = sequencesByName.get(e.getItem());
            _mainpanel.getCurrentTreePanel().repaint();
        }
    });
}

From source file:HW3.java

private void showMainCategory(ResultSet result) throws SQLException {
    int i = 1;/*from   w  w  w  .  j a va2s .com*/
    while (result.next()) {
        String catName = result.getString(1);
        JCheckBox check = new JCheckBox(catName, false);
        mainCategoryPanel.add(check);
        check.addItemListener(new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
                HashMap<JCheckBox, String> returnList = new HashMap<JCheckBox, String>();
                if (check.isSelected()) {
                    selectMainCat.add(catName);
                    showSubCat(catName, returnList);
                    mapList[mapListCount] = returnList;
                    finalDisplaySubCategory(catName);
                } else {
                    clearBusinessTable();
                    selectMainCat.remove(catName);
                    finalRemoveSubCategory(catName);
                }
            }
        });
        i = i + 1;
    }
    mainCategoryPanel.setLayout(new GridLayout(i, 1));
    mainCategoryPanel.repaint();
    setFocusable(true);
    pack();
}

From source file:op.controlling.PnlControlling.java

private java.util.List<Component> addFilters() {
    java.util.List<Component> list = new ArrayList<Component>();

    if (tabMain.getSelectedIndex() == TAB_QMSPLAN) {

        final JToggleButton tbClosedOnes2 = GUITools
                .getNiceToggleButton(SYSTools.xx("misc.filters.showclosed"));

        ArrayList<Commontags> listTags = CommontagsTools.getAllUsedInQMSPlans(true);
        if (!listTags.isEmpty()) {

            JPanel pnlTags = new JPanel();
            pnlTags.setLayout(new BoxLayout(pnlTags, BoxLayout.PAGE_AXIS));
            pnlTags.setOpaque(false);/*  w w w .  j a v  a 2  s.  co  m*/

            final JButton btnReset = GUITools.createHyperlinkButton("misc.commands.resetFilter",
                    SYSConst.icon16tagPurpleDelete4, new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {

                            //                        init = true;
                            //                        tbClosedOnes2.setSelected(false);
                            //                        init = false;

                            //                        pnlQMSPlan.reload();
                            //
                            //                        pnlQMSPlan.cleanup();
                            //                        pnlQMSPlan = new PnlQMSPlan(null);
                            //                        tabMain.setComponentAt(TAB_QMSPLAN, pnlQMSPlan);

                            filterTag = null;
                            tbClosedOnes2.setSelected(false);

                        }
                    });
            pnlTags.add(btnReset, RiverLayout.LEFT);

            for (final Commontags commontag : listTags) {

                final JButton btnTag = GUITools.createHyperlinkButton(commontag.getText(),
                        SYSConst.icon16tagPurple, new ActionListener() {
                            @Override
                            public void actionPerformed(ActionEvent e) {
                                //                            init = true;
                                //                            tbClosedOnes2.setSelected(true);
                                //                            init = false;
                                //
                                //                            pnlQMSPlan.cleanup();
                                //                            pnlQMSPlan = new PnlQMSPlan(null);
                                //                            tabMain.setComponentAt(TAB_QMSPLAN, pnlQMSPlan);
                                //                            //TODO: mark the filter when it is used. maybe a yellow background

                                filterTag = commontag;
                                tbClosedOnes2.setSelected(true);
                            }
                        });
                pnlTags.add(btnTag);

            }
            list.add(pnlTags);
        }

        tbClosedOnes2.addItemListener(new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent itemEvent) {
                //                    if (init) return;
                pnlQMSPlan.reload(filterTag, itemEvent.getStateChange() == ItemEvent.SELECTED);
            }
        });
        list.add(tbClosedOnes2);
        tbClosedOnes2.setHorizontalAlignment(SwingConstants.LEFT);

    }

    return list;
}