Example usage for java.awt.event ItemEvent getStateChange

List of usage examples for java.awt.event ItemEvent getStateChange

Introduction

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

Prototype

public int getStateChange() 

Source Link

Document

Returns the type of state change (selected or deselected).

Usage

From source file:edu.purdue.cc.bionet.ui.CorrelationDisplayPanel.java

/**
 * The itemStateChanged method of the ItemListener interface.
 * @see ItemListener#itemStateChanged(ItemEvent)
 * /*from   ww w  .  j av a2s. com*/
 * @param e The event which triggered this action.
 */
public void itemStateChanged(ItemEvent e) {
    if (e.getStateChange() == ItemEvent.SELECTED) {
        Object item = e.getSource();
        if (item == this.highContrastColorMenuItem) {
            graph.setBackground(Color.BLACK);
            graph.setForeground(Color.WHITE);
            graph.setPickedLabelColor(Color.WHITE);
            graph.setVertexPaint(Color.ORANGE.darker());
            graph.setPickedVertexPaint(Color.RED);
            graph.setPickedEdgePaint(Color.WHITE);
            heatMapPanel.setBackground(Color.BLACK);
            heatMapPanel.setForeground(Color.WHITE);
        } else if (item == this.normalColorMenuItem) {
            graph.setBackground(Color.WHITE);
            graph.setForeground(Color.BLACK);
            graph.setPickedLabelColor(Color.BLUE);
            graph.setVertexPaint(Color.ORANGE);
            graph.setPickedVertexPaint(Color.YELLOW);
            graph.setPickedEdgePaint(Color.BLACK);
            heatMapPanel.setForeground(Color.BLACK);
            heatMapPanel.setBackground(Color.WHITE);
        } else if (item == pearsonCalculationMenuItem) {
            correlationMethod.setValue(Correlation.PEARSON);
        } else if (item == spearmanCalculationMenuItem) {
            correlationMethod.setValue(Correlation.SPEARMAN);
        } else if (item == kendallCalculationMenuItem) {
            correlationMethod.setValue(Correlation.KENDALL);
        }
        graph.filterEdges();
        graph.repaint();
    }
}

From source file:org.multibit.viewsystem.swing.view.panels.ShowPreferencesPanel.java

private JPanel createTickerPanel(int stentWidth) {
    // Load up the original values.
    originalShowTicker = !Boolean.FALSE.toString()
            .equals(controller.getModel().getUserPreference(ExchangeModel.TICKER_SHOW));
    originalExchange1 = controller.getModel().getUserPreference(ExchangeModel.TICKER_FIRST_ROW_EXCHANGE);
    originalCurrency1 = controller.getModel().getUserPreference(ExchangeModel.TICKER_FIRST_ROW_CURRENCY);
    // Map MtGox to Bitstamp + USD
    if (ExchangeData.MT_GOX_EXCHANGE_NAME.equalsIgnoreCase(originalExchange1)) {
        originalExchange1 = ExchangeData.BITSTAMP_EXCHANGE_NAME;
        controller.getModel().setUserPreference(ExchangeModel.TICKER_FIRST_ROW_EXCHANGE,
                ExchangeData.BITSTAMP_EXCHANGE_NAME);

        originalCurrency1 = "USD";
        controller.getModel().setUserPreference(ExchangeModel.TICKER_FIRST_ROW_CURRENCY, "USD");
    }/*from  w  w w.ja  v a2s .c  o  m*/
    originalShowSecondRow = Boolean.TRUE.toString()
            .equals(controller.getModel().getUserPreference(ExchangeModel.TICKER_SHOW_SECOND_ROW));
    originalExchange2 = controller.getModel().getUserPreference(ExchangeModel.TICKER_SECOND_ROW_EXCHANGE);
    originalCurrency2 = controller.getModel().getUserPreference(ExchangeModel.TICKER_SECOND_ROW_CURRENCY);
    // Map MtGox to Bitstamp
    if (ExchangeData.MT_GOX_EXCHANGE_NAME.equalsIgnoreCase(originalExchange2)) {
        originalExchange2 = ExchangeData.BITSTAMP_EXCHANGE_NAME;
        controller.getModel().setUserPreference(ExchangeModel.TICKER_SECOND_ROW_EXCHANGE,
                ExchangeData.BITSTAMP_EXCHANGE_NAME);

        originalCurrency2 = "USD";
        controller.getModel().setUserPreference(ExchangeModel.TICKER_SECOND_ROW_CURRENCY, "USD");
    }

    MultiBitTitledPanel tickerPanel = new MultiBitTitledPanel(
            controller.getLocaliser().getString("showPreferencesPanel.ticker.title2"),
            ComponentOrientation.getOrientation(controller.getLocaliser().getLocale()));
    GridBagConstraints constraints = new GridBagConstraints();

    constraints.fill = GridBagConstraints.BOTH;
    constraints.gridx = 3;
    constraints.gridy = 3;
    constraints.weightx = 0.05;
    constraints.weighty = 0.3;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.CENTER;
    tickerPanel.add(MultiBitTitledPanel.createStent(MultiBitTitledPanel.SEPARATION_BETWEEN_NAME_VALUE_PAIRS),
            constraints);

    String showTickerText = controller.getLocaliser().getString("multiBitFrame.ticker.show.text");
    if (showTickerText != null && showTickerText.length() >= 1) {
        // Capitalise text (this is to save adding a new I18n term.
        showTickerText = Character.toUpperCase(showTickerText.charAt(0))
                + showTickerText.toLowerCase().substring(1);
    }
    showTicker = new JCheckBox(showTickerText);
    showTicker.setOpaque(false);
    showTicker.setFont(FontSizer.INSTANCE.getAdjustedDefaultFont());
    showTicker.setSelected(originalShowTicker);

    exchangeInformationLabel = new MultiBitLabel(
            controller.getLocaliser().getString("showPreferencesPanel.ticker.exchangeInformation"));
    exchangeInformationLabel.setVisible(originalShowBitcoinConvertedToFiat);

    showBitcoinConvertedToFiat = new JCheckBox(
            controller.getLocaliser().getString("showPreferencesPanel.ticker.showBitcoinConvertedToFiat"));
    showBitcoinConvertedToFiat.setOpaque(false);
    showBitcoinConvertedToFiat.setFont(FontSizer.INSTANCE.getAdjustedDefaultFont());
    showBitcoinConvertedToFiat.setSelected(originalShowBitcoinConvertedToFiat);

    showBitcoinConvertedToFiat.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            boolean selectedChange = (e.getStateChange() == ItemEvent.SELECTED);
            boolean unSelectedChange = (e.getStateChange() == ItemEvent.DESELECTED);
            if (exchangeInformationLabel != null) {
                if (selectedChange) {
                    exchangeInformationLabel.setVisible(true);
                }
                if (unSelectedChange) {
                    exchangeInformationLabel.setVisible(false);
                }
            }
        }
    });

    showExchange = new JCheckBox(controller.getLocaliser().getString("tickerTableModel.exchange"));
    showExchange.setOpaque(false);
    showExchange.setFont(FontSizer.INSTANCE.getAdjustedDefaultFont());

    showCurrency = new JCheckBox(controller.getLocaliser().getString("tickerTableModel.currency"));
    showCurrency.setOpaque(false);
    showCurrency.setFont(FontSizer.INSTANCE.getAdjustedDefaultFont());

    showLastPrice = new JCheckBox(controller.getLocaliser().getString("tickerTableModel.lastPrice"));
    showLastPrice.setOpaque(false);
    showLastPrice.setFont(FontSizer.INSTANCE.getAdjustedDefaultFont());

    showBid = new JCheckBox(controller.getLocaliser().getString("tickerTableModel.bid"));
    showBid.setOpaque(false);
    showBid.setFont(FontSizer.INSTANCE.getAdjustedDefaultFont());

    showAsk = new JCheckBox(controller.getLocaliser().getString("tickerTableModel.ask"));
    showAsk.setOpaque(false);
    showAsk.setFont(FontSizer.INSTANCE.getAdjustedDefaultFont());

    String tickerColumnsToShow = controller.getModel().getUserPreference(ExchangeModel.TICKER_COLUMNS_TO_SHOW);
    if (tickerColumnsToShow == null || tickerColumnsToShow.equals("")) {
        tickerColumnsToShow = TickerTableModel.DEFAULT_COLUMNS_TO_SHOW;
    }

    originalShowCurrency = tickerColumnsToShow.contains(TickerTableModel.TICKER_COLUMN_CURRENCY);
    showCurrency.setSelected(originalShowCurrency);

    originalShowRate = tickerColumnsToShow.contains(TickerTableModel.TICKER_COLUMN_LAST_PRICE);
    showLastPrice.setSelected(originalShowRate);

    originalShowBid = tickerColumnsToShow.contains(TickerTableModel.TICKER_COLUMN_BID);
    showBid.setSelected(originalShowBid);

    originalShowAsk = tickerColumnsToShow.contains(TickerTableModel.TICKER_COLUMN_ASK);
    showAsk.setSelected(originalShowAsk);

    originalShowExchange = tickerColumnsToShow.contains(TickerTableModel.TICKER_COLUMN_EXCHANGE);
    showExchange.setSelected(originalShowExchange);

    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 1;
    constraints.gridy = 4;
    constraints.weightx = 0.2;
    constraints.weighty = 0.3;
    constraints.gridwidth = 4;
    constraints.anchor = GridBagConstraints.LINE_START;
    tickerPanel.add(showTicker, constraints);

    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 1;
    constraints.gridy = 5;
    constraints.weightx = 0.2;
    constraints.weighty = 0.3;
    constraints.gridwidth = 4;
    constraints.anchor = GridBagConstraints.LINE_START;
    tickerPanel.add(showBitcoinConvertedToFiat, constraints);

    constraints.fill = GridBagConstraints.VERTICAL;
    constraints.gridx = 0;
    constraints.gridy = 6;
    constraints.weightx = 0.2;
    constraints.weighty = 0.3;
    constraints.gridwidth = 3;
    constraints.anchor = GridBagConstraints.LINE_START;
    tickerPanel.add(MultiBitTitledPanel.createStent(1, 12), constraints);

    MultiBitTitledPanel.addLeftJustifiedTextAtIndent(
            controller.getLocaliser().getString("showPreferencesPanel.ticker.columnsToShow"), 7, tickerPanel);

    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 1;
    constraints.gridy = 8;
    constraints.weightx = 0.2;
    constraints.weighty = 0.3;
    constraints.gridwidth = 3;
    constraints.anchor = GridBagConstraints.LINE_START;
    tickerPanel.add(showExchange, constraints);

    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 1;
    constraints.gridy = 9;
    constraints.weightx = 0.2;
    constraints.weighty = 0.3;
    constraints.gridwidth = 3;
    constraints.anchor = GridBagConstraints.LINE_START;
    tickerPanel.add(showCurrency, constraints);

    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 1;
    constraints.gridy = 10;
    constraints.weightx = 0.2;
    constraints.weighty = 0.3;
    constraints.gridwidth = 3;
    constraints.anchor = GridBagConstraints.LINE_START;
    tickerPanel.add(showLastPrice, constraints);

    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 1;
    constraints.gridy = 11;
    constraints.weightx = 0.2;
    constraints.weighty = 0.3;
    constraints.gridwidth = 3;
    constraints.anchor = GridBagConstraints.LINE_START;
    tickerPanel.add(showBid, constraints);

    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 1;
    constraints.gridy = 12;
    constraints.weightx = 0.2;
    constraints.weighty = 0.3;
    constraints.gridwidth = 3;
    constraints.anchor = GridBagConstraints.LINE_START;
    tickerPanel.add(showAsk, constraints);

    constraints.fill = GridBagConstraints.VERTICAL;
    constraints.gridx = 1;
    constraints.gridy = 13;
    constraints.weightx = 0.3;
    constraints.weighty = 0.3;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.LINE_START;
    tickerPanel.add(MultiBitTitledPanel.createStent(1, 13), constraints);

    MultiBitTitledPanel.addLeftJustifiedTextAtIndent(
            controller.getLocaliser().getString("showPreferencesPanel.ticker.firstRow"), 14, tickerPanel);

    MultiBitLabel exchangeLabel1 = new MultiBitLabel(
            controller.getLocaliser().getString("showPreferencesPanel.ticker.exchange"));
    exchangeLabel1.setHorizontalAlignment(JLabel.TRAILING);
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 1;
    constraints.gridy = 15;
    constraints.weightx = 0.3;
    constraints.weighty = 1;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.LINE_END;
    tickerPanel.add(exchangeLabel1, constraints);

    String exchangeToUse1;
    if (originalExchange1 == null | "".equals(originalExchange1)) {
        exchangeToUse1 = ExchangeData.DEFAULT_EXCHANGE;
    } else {
        exchangeToUse1 = originalExchange1;
    }

    String exchangeToUse2;
    if (originalExchange2 == null | "".equals(originalExchange2)) {
        exchangeToUse2 = ExchangeData.DEFAULT_EXCHANGE;
    } else {
        exchangeToUse2 = originalExchange2;
    }

    exchangeComboBox1 = new JComboBox(ExchangeData.getAvailableExchanges());
    exchangeComboBox1.setSelectedItem(exchangeToUse1);

    exchangeComboBox1.setFont(FontSizer.INSTANCE.getAdjustedDefaultFont());
    exchangeComboBox1.setOpaque(false);

    FontMetrics fontMetrics = getFontMetrics(FontSizer.INSTANCE.getAdjustedDefaultFont());
    int textWidth = Math.max(fontMetrics.stringWidth(ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME),
            fontMetrics.stringWidth("USD")) + COMBO_WIDTH_DELTA;
    Dimension preferredSize = new Dimension(textWidth + TICKER_COMBO_WIDTH_DELTA,
            fontMetrics.getHeight() + EXCHANGE_COMBO_HEIGHT_DELTA);
    exchangeComboBox1.setPreferredSize(preferredSize);

    constraints.fill = GridBagConstraints.BOTH;
    constraints.gridx = 1;
    constraints.gridy = 15;
    constraints.weightx = 0.3;
    constraints.weighty = 0.3;
    constraints.gridwidth = 2;
    constraints.anchor = GridBagConstraints.LINE_START;
    JPanel stent = MultiBitTitledPanel.createStent(stentWidth);
    tickerPanel.add(stent, constraints);

    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 4;
    constraints.gridy = 15;
    constraints.weightx = 0.8;
    constraints.weighty = 0.6;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.LINE_START;
    tickerPanel.add(exchangeComboBox1, constraints);

    oerMessageLabel1 = new MultiBitLabel(
            "    " + controller.getLocaliser().getString("showPreferencesPanel.getAppId.label"));
    oerMessageLabel1.setForeground(Color.GREEN.darker().darker());
    boolean showMessageLabel1 = isBrowserSupported()
            && ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME.equalsIgnoreCase(exchangeToUse1)
            && (originalOERApiCode == null || originalOERApiCode.trim().length() == 0);
    oerMessageLabel1.setVisible(showMessageLabel1);
    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 5;
    constraints.gridy = 15;
    constraints.weightx = 0.8;
    constraints.weighty = 0.6;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.LINE_START;
    tickerPanel.add(oerMessageLabel1, constraints);

    MultiBitLabel currencyLabel1 = new MultiBitLabel(
            controller.getLocaliser().getString("showPreferencesPanel.ticker.currency"));
    currencyLabel1.setHorizontalAlignment(JLabel.TRAILING);
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 1;
    constraints.gridy = 16;
    constraints.weightx = 0.3;
    constraints.weighty = 1;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.LINE_END;
    tickerPanel.add(currencyLabel1, constraints);

    // Make sure the exchange1 has been created and initialised the list of
    // currencies.
    if (mainFrame != null && mainFrame.getTickerTimerTask1() != null) {
        TickerTimerTask tickerTimerTask = mainFrame.getTickerTimerTask1();
        synchronized (tickerTimerTask) {
            if (tickerTimerTask.getExchange() == null) {
                tickerTimerTask.createExchangeObjects(exchangeToUse1);
            }
        }
    }

    currencyComboBox1 = new JComboBox();
    Collection<String> currenciesToUse = ExchangeData.getAvailableCurrenciesForExchange(exchangeToUse1);
    if (currenciesToUse != null) {
        for (String currency : currenciesToUse) {
            String item = currency;
            String description = CurrencyConverter.INSTANCE.getCurrencyCodeToDescriptionMap().get(currency);
            if (description != null && description.trim().length() > 0) {
                item = item + " (" + description + ")";
            }
            currencyComboBox1.addItem(item);
            if (currency.equals(originalCurrency1)) {
                currencyComboBox1.setSelectedItem(item);
            }
        }
    }

    currencyComboBox1.setFont(FontSizer.INSTANCE.getAdjustedDefaultFont());
    currencyComboBox1.setOpaque(false);
    currencyComboBox1.setPreferredSize(preferredSize);

    exchangeComboBox1.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent event) {
            if (event.getStateChange() == ItemEvent.SELECTED) {
                Object item = event.getItem();
                String exchangeShortName = item.toString();
                // Make sure the exchange1 has been created and initialised
                // the list of currencies.
                if (mainFrame != null && mainFrame.getTickerTimerTask1() != null) {
                    TickerTimerTask tickerTimerTask = mainFrame.getTickerTimerTask1();
                    synchronized (tickerTimerTask) {
                        tickerTimerTask.createExchangeObjects(exchangeShortName);
                        currencyComboBox1.removeAllItems();
                        Collection<String> currenciesToUse = ExchangeData
                                .getAvailableCurrenciesForExchange(exchangeShortName);
                        if (currenciesToUse != null) {
                            for (String currency : currenciesToUse) {
                                String loopItem = currency;
                                String description = CurrencyConverter.INSTANCE
                                        .getCurrencyCodeToDescriptionMap().get(currency);
                                if (description != null && description.trim().length() > 0) {
                                    loopItem = loopItem + " (" + description + ")";
                                }
                                currencyComboBox1.addItem(loopItem);
                            }
                        }
                    }
                }

                // Enable the OpenExchangeRates App ID if required.
                boolean showOER = ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME
                        .equalsIgnoreCase(exchangeShortName)
                        || ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME
                                .equalsIgnoreCase((String) exchangeComboBox2.getSelectedItem());
                oerStent.setVisible(showOER);
                oerApiCodeLabel.setVisible(showOER);
                oerApiCodeTextField.setVisible(showOER);
                getOerAppIdButton.setVisible(showOER);

                boolean showMessageLabel = isBrowserSupported()
                        && ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME.equalsIgnoreCase(exchangeShortName)
                        && (oerApiCodeTextField.getText() == null
                                || oerApiCodeTextField.getText().trim().length() == 0);
                oerMessageLabel1.setVisible(showMessageLabel);
            }
        }
    });

    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 4;
    constraints.gridy = 16;
    constraints.weightx = 0.8;
    constraints.weighty = 0.6;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.LINE_START;
    tickerPanel.add(currencyComboBox1, constraints);

    constraints.fill = GridBagConstraints.BOTH;
    constraints.gridx = 1;
    constraints.gridy = 17;
    constraints.weightx = 0.3;
    constraints.weighty = 0.3;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.LINE_START;
    tickerPanel.add(MultiBitTitledPanel.createStent(12, 12), constraints);

    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 4;
    constraints.gridy = 18;
    constraints.weightx = 0.8;
    constraints.weighty = 0.6;
    constraints.gridwidth = 2;
    constraints.anchor = GridBagConstraints.LINE_START;
    tickerPanel.add(MultiBitTitledPanel.createStent(fontMetrics.stringWidth(exchangeInformationLabel.getText()),
            fontMetrics.getHeight()), constraints);
    tickerPanel.add(exchangeInformationLabel, constraints);

    constraints.fill = GridBagConstraints.BOTH;
    constraints.gridx = 1;
    constraints.gridy = 19;
    constraints.weightx = 0.3;
    constraints.weighty = 0.3;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.LINE_START;
    tickerPanel.add(MultiBitTitledPanel.createStent(12, 12), constraints);

    MultiBitTitledPanel.addLeftJustifiedTextAtIndent(
            controller.getLocaliser().getString("showPreferencesPanel.ticker.secondRow"), 20, tickerPanel);

    showSecondRowCheckBox = new JCheckBox(
            controller.getLocaliser().getString("showPreferencesPanel.ticker.showSecondRow"));
    showSecondRowCheckBox.setOpaque(false);
    showSecondRowCheckBox.setFont(FontSizer.INSTANCE.getAdjustedDefaultFont());
    showSecondRowCheckBox.addItemListener(new ChangeTickerShowSecondRowListener());

    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 1;
    constraints.gridy = 21;
    constraints.weightx = 0.3;
    constraints.weighty = 1;
    constraints.gridwidth = 3;
    constraints.anchor = GridBagConstraints.LINE_START;
    tickerPanel.add(showSecondRowCheckBox, constraints);

    exchangeLabel2 = new MultiBitLabel(
            controller.getLocaliser().getString("showPreferencesPanel.ticker.exchange"));
    exchangeLabel2.setHorizontalAlignment(JLabel.TRAILING);
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 1;
    constraints.gridy = 22;
    constraints.weightx = 0.3;
    constraints.weighty = 1;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.LINE_END;
    tickerPanel.add(exchangeLabel2, constraints);

    exchangeComboBox2 = new JComboBox(ExchangeData.getAvailableExchanges());
    exchangeComboBox2.setSelectedItem(exchangeToUse2);

    exchangeComboBox2.setFont(FontSizer.INSTANCE.getAdjustedDefaultFont());
    exchangeComboBox2.setOpaque(false);
    exchangeComboBox2.setPreferredSize(preferredSize);

    exchangeComboBox2.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent event) {
            if (event.getStateChange() == ItemEvent.SELECTED) {
                Object item = event.getItem();
                String exchangeShortName = item.toString();
                // Make sure the exchange2 has been created and initialised
                // the list of currencies.
                if (mainFrame != null && mainFrame.getTickerTimerTask2() != null) {
                    TickerTimerTask tickerTimerTask = mainFrame.getTickerTimerTask2();
                    synchronized (tickerTimerTask) {
                        tickerTimerTask.createExchangeObjects(exchangeShortName);
                        currencyComboBox2.removeAllItems();
                        Collection<String> currenciesToUse = ExchangeData
                                .getAvailableCurrenciesForExchange(exchangeShortName);
                        if (currenciesToUse != null) {
                            for (String currency : currenciesToUse) {
                                String loopItem = currency;
                                String description = CurrencyConverter.INSTANCE
                                        .getCurrencyCodeToDescriptionMap().get(currency);
                                if (description != null && description.trim().length() > 0) {
                                    loopItem = loopItem + " (" + description + ")";
                                }
                                currencyComboBox2.addItem(loopItem);
                            }
                        }
                    }
                }

                // Enable the OpenExchangeRates App ID if required.
                boolean showOER = ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME
                        .equalsIgnoreCase(exchangeShortName)
                        || ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME
                                .equalsIgnoreCase((String) exchangeComboBox1.getSelectedItem());
                oerStent.setVisible(showOER);
                oerApiCodeLabel.setVisible(showOER);
                oerApiCodeTextField.setVisible(showOER);
                getOerAppIdButton.setVisible(showOER);

                boolean showMessageLabel = isBrowserSupported()
                        && ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME.equalsIgnoreCase(exchangeShortName)
                        && (oerApiCodeTextField.getText() == null
                                || oerApiCodeTextField.getText().trim().length() == 0);
                oerMessageLabel2.setVisible(showMessageLabel);
            }
        }
    });

    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 4;
    constraints.gridy = 22;
    constraints.weightx = 0.8;
    constraints.weighty = 0.6;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.LINE_START;
    tickerPanel.add(exchangeComboBox2, constraints);

    oerMessageLabel2 = new MultiBitLabel(
            "    " + controller.getLocaliser().getString("showPreferencesPanel.getAppId.label"));
    oerMessageLabel2.setForeground(Color.GREEN.darker().darker());
    boolean showMessageLabel2 = isBrowserSupported()
            && ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME.equalsIgnoreCase(exchangeToUse2)
            && (originalOERApiCode == null || originalOERApiCode.trim().length() == 0);
    oerMessageLabel2.setVisible(showMessageLabel2);
    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 5;
    constraints.gridy = 22;
    constraints.weightx = 0.8;
    constraints.weighty = 0.6;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.LINE_START;
    tickerPanel.add(oerMessageLabel2, constraints);

    currencyLabel2 = new MultiBitLabel(
            controller.getLocaliser().getString("showPreferencesPanel.ticker.currency"));
    currencyLabel2.setHorizontalAlignment(JLabel.TRAILING);
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 1;
    constraints.gridy = 23;
    constraints.weightx = 0.3;
    constraints.weighty = 1;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.LINE_END;
    tickerPanel.add(currencyLabel2, constraints);

    // Make sure the exchange2 has been created and initialised the list of
    // currencies.
    if (mainFrame != null && mainFrame.getTickerTimerTask2() != null) {
        TickerTimerTask tickerTimerTask = mainFrame.getTickerTimerTask2();
        synchronized (tickerTimerTask) {
            if (tickerTimerTask.getExchange() == null) {
                tickerTimerTask.createExchangeObjects(exchangeToUse2);
            }
        }
    }
    currencyComboBox2 = new JComboBox();
    currenciesToUse = ExchangeData.getAvailableCurrenciesForExchange(exchangeToUse2);
    if (currenciesToUse != null) {
        for (String currency : currenciesToUse) {
            String loopItem = currency;
            String description = CurrencyConverter.INSTANCE.getCurrencyCodeToDescriptionMap().get(currency);
            if (description != null && description.trim().length() > 0) {
                loopItem = loopItem + " (" + description + ")";
            }
            currencyComboBox2.addItem(loopItem);
            if (currency.equals(originalCurrency2)) {
                currencyComboBox2.setSelectedItem(loopItem);
            }
        }
    }

    currencyComboBox2.setFont(FontSizer.INSTANCE.getAdjustedDefaultFont());
    currencyComboBox2.setOpaque(false);
    currencyComboBox2.setPreferredSize(preferredSize);

    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 4;
    constraints.gridy = 23;
    constraints.weightx = 0.8;
    constraints.weighty = 0.6;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.LINE_START;
    tickerPanel.add(currencyComboBox2, constraints);

    showSecondRowCheckBox.setSelected(originalShowSecondRow);
    enableTickerSecondRow(originalShowSecondRow);

    constraints.fill = GridBagConstraints.BOTH;
    constraints.gridx = 1;
    constraints.gridy = 24;
    constraints.weightx = 0.3;
    constraints.weighty = 0.3;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.LINE_START;
    tickerPanel.add(MultiBitTitledPanel.createStent(12, 12), constraints);

    JPanel fill1 = new JPanel();
    fill1.setOpaque(false);
    constraints.fill = GridBagConstraints.BOTH;
    constraints.gridx = 5;
    constraints.gridy = 25;
    constraints.weightx = 20;
    constraints.weighty = 1;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.LINE_END;
    tickerPanel.add(fill1, constraints);

    boolean showOerSignup = ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME.equalsIgnoreCase(exchangeToUse1)
            || ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME.equalsIgnoreCase(exchangeToUse2);

    oerStent = MultiBitTitledPanel.createStent(12, 12);
    constraints.fill = GridBagConstraints.BOTH;
    constraints.gridx = 1;
    constraints.gridy = 26;
    constraints.weightx = 0.3;
    constraints.weighty = 0.3;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.LINE_START;
    oerStent.setVisible(showOerSignup);
    tickerPanel.add(oerStent, constraints);

    oerApiCodeLabel = new MultiBitLabel(
            controller.getLocaliser().getString("showPreferencesPanel.oerLabel.text"));
    oerApiCodeLabel.setToolTipText(HelpContentsPanel
            .createTooltipText(controller.getLocaliser().getString("showPreferencesPanel.oerLabel.tooltip")));
    oerApiCodeLabel.setVisible(showOerSignup);

    oerApiCodeTextField = new MultiBitTextField("", 25, controller);
    oerApiCodeTextField.setHorizontalAlignment(JLabel.LEADING);
    oerApiCodeTextField.setMinimumSize(new Dimension(API_CODE_FIELD_WIDTH, API_CODE_FIELD_HEIGHT));
    oerApiCodeTextField.setPreferredSize(new Dimension(API_CODE_FIELD_WIDTH, API_CODE_FIELD_HEIGHT));
    oerApiCodeTextField.setMaximumSize(new Dimension(API_CODE_FIELD_WIDTH, API_CODE_FIELD_HEIGHT));
    oerApiCodeTextField.setVisible(showOerSignup);
    oerApiCodeTextField.setText(originalOERApiCode);
    oerApiCodeTextField.addFocusListener(new FocusListener() {
        @Override
        public void focusGained(FocusEvent arg0) {
        }

        @Override
        public void focusLost(FocusEvent arg0) {
            String apiCode = oerApiCodeTextField.getText();
            if (apiCode != null && !(WhitespaceTrimmer.trim(apiCode).length() == 0) && !apiCode.equals(
                    controller.getModel().getUserPreference(ExchangeModel.OPEN_EXCHANGE_RATES_API_CODE))) {
                // New API code.
                // Check its length
                if (!(apiCode.trim().length() == LENGTH_OF_OPEN_EXCHANGE_RATE_APP_ID)
                        && !apiCode.equals(haveShownErrorMessageForApiCode)) {
                    haveShownErrorMessageForApiCode = apiCode;
                    // Give user a message that App ID is not in the correct format.
                    JOptionPane.showMessageDialog(null,
                            new String[] { controller
                                    .getLocaliser().getString("showPreferencesPanel.oerValidationError.text1"),
                                    " ",
                                    controller.getLocaliser()
                                            .getString("showPreferencesPanel.oerValidationError.text2"),
                                    controller.getLocaliser()
                                            .getString("showPreferencesPanel.oerValidationError.text3") },
                            controller.getLocaliser().getString(
                                    "showPreferencesPanel.oerValidationError.title"),
                            JOptionPane.ERROR_MESSAGE,
                            ImageLoader.createImageIcon(ImageLoader.EXCLAMATION_MARK_ICON_FILE));
                    return;
                }
            }
            updateApiCode();
        }
    });
    oerApiCodeTextField.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            String apiCode = oerApiCodeTextField.getText();
            if (apiCode != null && !(WhitespaceTrimmer.trim(apiCode).length() == 0) && !apiCode.equals(
                    controller.getModel().getUserPreference(ExchangeModel.OPEN_EXCHANGE_RATES_API_CODE))) {
                // New API code.
                // Check its length
                if (!(apiCode.trim().length() == LENGTH_OF_OPEN_EXCHANGE_RATE_APP_ID)
                        && !apiCode.equals(haveShownErrorMessageForApiCode)) {
                    haveShownErrorMessageForApiCode = apiCode;
                    // Give user a message that App ID is not in the correct format.
                    JOptionPane.showMessageDialog(null,
                            new String[] {
                                    controller.getLocaliser()
                                            .getString("showPreferencesPanel.oerValidationError.text1"),
                                    controller.getLocaliser()
                                            .getString("showPreferencesPanel.oerValidationError.text2"),
                                    controller.getLocaliser()
                                            .getString("showPreferencesPanel.oerValidationError.text3") },
                            controller.getLocaliser().getString(
                                    "showPreferencesPanel.oerValidationError.title"),
                            JOptionPane.ERROR_MESSAGE,
                            ImageLoader.createImageIcon(ImageLoader.EXCLAMATION_MARK_ICON_FILE));
                    return;
                }
            }
            updateApiCode();
        }
    });

    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 1;
    constraints.gridy = 27;
    constraints.weightx = 0.3;
    constraints.weighty = 0.3;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.LINE_END;
    tickerPanel.add(oerApiCodeLabel, constraints);

    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 4;
    constraints.gridy = 27;
    constraints.weightx = 0.3;
    constraints.weighty = 0.3;
    constraints.gridwidth = 2;
    constraints.anchor = GridBagConstraints.LINE_START;
    tickerPanel.add(oerApiCodeTextField, constraints);

    if (isBrowserSupported()) {
        getOerAppIdButton = new MultiBitButton(
                controller.getLocaliser().getString("showPreferencesPanel.getAppId.text"));
        getOerAppIdButton
                .setToolTipText(controller.getLocaliser().getString("showPreferencesPanel.getAppId.tooltip"));
        getOerAppIdButton.setVisible(showOerSignup);

        getOerAppIdButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                try {
                    openURI(new URI(OPEN_EXCHANGE_RATES_SIGN_UP_URI));
                } catch (URISyntaxException e) {
                    log.debug(e.getMessage());
                }
            }
        });

        constraints.fill = GridBagConstraints.NONE;
        constraints.gridx = 4;
        constraints.gridy = 28;
        constraints.weightx = 1;
        constraints.weighty = 1;
        constraints.gridwidth = 1;
        constraints.anchor = GridBagConstraints.LINE_START;
        tickerPanel.add(getOerAppIdButton, constraints);
    }

    return tickerPanel;
}

From source file:ru.goodfil.catalog.ui.forms.FiltersPanel.java

public FiltersPanel() {
    initComponents();/*www .  jav a2s .c  om*/

    filterTypeResolver = createFilterTypeResolver();
    filterFormResolver = createFilterFormResolver();

    ManufactorModelAdapter manufactorModelAdapter = new ManufactorModelAdapter();
    List<Manufactor> theManufactors = carsService.getAllManufactors();
    for (Manufactor manufactor : theManufactors) {
        manufactorModelAdapter.addManufactor(manufactor);
    }
    manufactors = new SelectionInList<ManufactorModel>(manufactorModelAdapter.getList());

    series = new SelectionInList<SeriaModel>();

    cbManufactors.setModel(new ComboBoxAdapter<ManufactorModel>(manufactors));
    cbManufactors.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                ManufactorModel manufactorModel = (ManufactorModel) e.getItem();
                reReadSeries(manufactorModel.getManufactorIds());
            }
        }
    });

    cbSeria.setModel(new ComboBoxAdapter<SeriaModel>(series));
    tblAllMotors.setModel(new BigMotorTableAdapter(allMotors));
    tblAllMotors.setRowSorter(new BigMotorTableSorter((BigMotorTableAdapter) tblAllMotors.getModel()));
    tblAllMotors.setRowHeight(20);
    tblAllMotors.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            adjustButtonsEnabled();
        }
    });

    tblMotors.setModel(new BigMotorTableAdapter(motors));
    tblMotors.setRowSorter(new BigMotorTableSorter((BigMotorTableAdapter) tblMotors.getModel()));
    tblMotors.setRowHeight(20);
    tblMotors.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            adjustButtonsEnabled();
        }
    });

    final BigFilterTableAdapter tblFiltersAdapter = new BigFilterTableAdapter(filters, filterTypeResolver,
            filterFormResolver);

    tblFiltersAdapter.addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent e) {
            if (e.getType() == TableModelEvent.UPDATE) {
                BigFilterTableAdapter adapter = (BigFilterTableAdapter) e.getSource();
                int row = e.getFirstRow();

                Filter filter = adapter.getRow(row);
                filtersService.updateFilter(filter);
            }
        }
    });

    tblFilters.setUpdateSelectionOnSort(true);
    tblFilters.setModel(tblFiltersAdapter);
    tblFilters.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting()) {
                return;
            }

            adjustButtonsEnabled();

            Long filterId = getSelectedFilterId();
            reReadMotors(filterId);
            reReadOes(filterId);
        }
    });
    tblFilters.setRowHeight(20);

    tblAllOes.setModel(new OeModelTableModel(allOes));
    tblAllOes.setRowHeight(20);
    tblAllOes.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            adjustButtonsEnabled();
        }
    });

    tblOes.setModel(new OeModelTableModel(oes));
    tblOes.setRowHeight(20);
    tblOes.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            adjustButtonsEnabled();
        }
    });
    // ??   ?   ?  
    if (System.getProperty("catalog.mode.fromMann") != null
            && System.getProperty("catalog.mode.fromMann").equals("1")) {
        tblFilters.setDefaultRenderer(Object.class, new MannTablesCellRenderer(MannTablesCellRenderer.FILTER));
        tblMotors.setDefaultRenderer(Object.class, new MannTablesCellRenderer(MannTablesCellRenderer.AMOTOR));
        tblAllMotors.setDefaultRenderer(Object.class,
                new MannTablesCellRenderer(MannTablesCellRenderer.AMOTOR));
        tblOes.setDefaultRenderer(Object.class, new MannTablesCellRenderer(MannTablesCellRenderer.OE));
        tblAllOes.setDefaultRenderer(Object.class, new MannTablesCellRenderer(MannTablesCellRenderer.OE));
    } else {
        tblFilters.setDefaultRenderer(Object.class, new FilterTableCellRenderer());
    }
    adjustButtonsEnabled();
    //        globalHotkeys();
}

From source file:com.osparking.attendant.AttListForm.java

private void searchCriteriaComboBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_searchCriteriaComboBoxItemStateChanged
    if (evt.getStateChange() == SELECTED) {
        changeSearchButtonEnabled();/*from  w ww.ja  va2 s . c o  m*/
    }
}

From source file:de.tor.tribes.ui.windows.DSWorkbenchMainFrame.java

private void fireROISelectedEvent(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_fireROISelectedEvent
    if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED) {
        try {//from   w ww . ja va  2  s.  c  om
            String item = (String) jROIBox.getSelectedItem();
            item = item.substring(item.lastIndexOf("(") + 1, item.lastIndexOf(")"));
            String[] pos = item.trim().split("\\|");
            jCenterX.setText(pos[0]);
            jCenterY.setText(pos[1]);
            fireReloadMapKoordinatesEvent(null);
        } catch (Exception ignored) {
        }
    }
}

From source file:stainingestimation.StainingEstimation.java

private void jComboBox1ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboBox1ItemStateChanged
    if (previewOriginal != null && evt.getStateChange() == java.awt.event.ItemEvent.SELECTED) {
        if (((String) jComboBox1.getSelectedItem()).equalsIgnoreCase("User values")) {
            Colour_Deconvolution.getUserColors(this, manager.getVisibleTMAspot());
        }/*from   ww w  .  j a v  a2  s  .  co m*/
        setParam_ColorChannel((String) jComboBox1.getSelectedItem());
        calculatePreviewConvolution(
                new ImagePlus("", previewOriginal.getScaledInstance(-1, -1, Image.SCALE_DEFAULT)));
        displayPreviewImages();
    }
}

From source file:com.diversityarrays.kdxplore.curate.TrialDataEditor.java

public TrialDataEditor(CurationData cd, WindowOpener<JFrame> windowOpener, MessageLogger messageLogger,
        KdxploreDatabase kdxdb, IntFunction<Trait> traitProvider, SampleType[] sampleTypes) throws IOException {
    super(new BorderLayout());

    this.traitProvider = traitProvider;
    this.windowOpener = windowOpener;

    this.curationData = cd;
    this.curationData.setChangeManager(changeManager);
    this.curationData.setKDSmartDatabase(kdxdb.getKDXploreKSmartDatabase());

    inactiveTagFilterIcon = KDClientUtils.getIcon(ImageId.TAG_FILTER_24);
    activeTagFilterIcon = KDClientUtils.getIcon(ImageId.TAG_FILTER_ACTIVE_24);

    inactivePlotOrSpecimenFilterIcon = KDClientUtils.getIcon(ImageId.FILTER_PLOT_SPEC_INACTIVE);
    activePlotFilterIcon = KDClientUtils.getIcon(ImageId.FILTER_PLOT_ACTIVE);
    activeSpecimenFilterIcon = KDClientUtils.getIcon(ImageId.FILTER_SPEC_ACTIVE);

    updatePlotSpecimenIcon();/*from w w  w  .  ja  v  a 2s .  c o m*/

    TraitColorProvider traitColourProvider = new TraitColorProvider(false);
    this.curationData.setTraitColorProvider(traitColourProvider);

    curationData.addCurationDataChangeListener(new CurationDataChangeListener() {
        @Override
        public void plotActivationChanged(Object source, boolean activated, List<Plot> plots) {
            updateRowFilter();
            if (toolController != null) {
                toolController.plotActivationsChanged(activated, plots);
            }
        }

        @Override
        public void editedSamplesChanged(Object source, List<CurationCellId> curationCellIds) {
            if (toolController != null) {
                toolController.editedSamplesChanged();
            }
        }
    });

    this.selectedValueStore = new SelectedValueStore(curationData.getTrial().getTrialName());

    this.messageLogger = messageLogger;

    smallFont = KDClientUtils.makeSmallFont(this);

    // undockViewAction.putValue(Action.SHORT_DESCRIPTION, "Click to undock
    // this view");

    KDClientUtils.initAction(ImageId.HELP_24, curationHelpAction, Msg.TOOLTIP_HELP_DATA_CURATION(), false);

    KDClientUtils.initAction(ImageId.SAVE_24, saveChangesAction, Msg.TOOLTIP_SAVE_CHANGES(), true);
    KDClientUtils.initAction(ImageId.EXPORT_24, exportCuratedData, Msg.TOOLTIP_EXPORT(), true);

    KDClientUtils.initAction(ImageId.UNDO_24, undoAction, Msg.TOOLTIP_UNDO(), true);
    KDClientUtils.initAction(ImageId.REDO_24, redoAction, Msg.TOOLTIP_REDO(), true);

    KDClientUtils.initAction(ImageId.FIELD_VIEW_24, showFieldViewAction, Msg.TOOLTIP_FIELD_VIEW(), false);

    KDClientUtils.initAction(ImageId.GET_TRIALINFO_24, importCuratedData, Msg.TOOLTIP_IMPORT_DATA(), true);

    Function<TraitInstance, List<KdxSample>> sampleProvider = new Function<TraitInstance, List<KdxSample>>() {
        @Override
        public List<KdxSample> apply(TraitInstance ti) {
            return curationData.getSampleMeasurements(ti);
        }
    };
    tivrByTi = VisToolUtil.buildTraitInstanceValueRetrieverMap(curationData.getTrial(),
            curationData.getTraitInstances(), sampleProvider);

    // = = = = = = = =

    boolean readOnly = false;
    // FIXME work out if the Trial can be edited or not
    curationTableModel = new CurationTableModel(curationData, readOnly);
    // See FIXME comment in CurationTableModel.isReadOnly()

    curationTableSelectionModel = new CurationTableSelectionModelImpl(selectedValueStore, curationTableModel);

    curationTableSelectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

    curationTable = new CurationTable("CurationTable-" + (++UNIQUE_CURATION_TABLE_ID), //$NON-NLS-1$
            curationTableModel, curationTableSelectionModel);
    curationTable.setCellSelectionEnabled(true);
    curationTable.setAutoCreateRowSorter(true);

    // = = = = = = = =
    this.sampleSourcesTablePanel = new SampleSourcesTablePanel(curationData, curationTableModel, handler);

    @SuppressWarnings("unchecked")
    TableRowSorter<CurationTableModel> rowSorter = (TableRowSorter<CurationTableModel>) curationTable
            .getRowSorter();
    rowSorter.setSortsOnUpdates(true);
    rowSorter.addRowSorterListener(rowSorterListener);

    curationCellRenderer = new CurationTableCellRenderer(curationTableModel, colorProviderFactory,
            curationTableSelectionModel);

    curationTable.setDefaultRenderer(Object.class, curationCellRenderer);
    curationTable.setDefaultRenderer(Integer.class, curationCellRenderer);
    curationTable.setDefaultRenderer(String.class, curationCellRenderer);
    curationTable.setDefaultRenderer(CurationCellValue.class, curationCellRenderer);
    curationTable.setDefaultRenderer(Double.class, curationCellRenderer);
    curationTable.setDefaultRenderer(TraitValue.class, curationCellRenderer);

    // If either the rows selected change or the columns selected change
    // then we
    // need to inform the visualisation tools.
    curationTable.getSelectionModel().addListSelectionListener(curationTableCellSelectionListener);
    curationTable.getColumnModel().addColumnModelListener(curationTableCellSelectionListener);

    fieldLayoutView = new InterceptFieldLayoutView();

    this.curationCellEditor = new CurationCellEditorImpl(curationTableModel, fieldLayoutView, curationData,
            refreshFieldLayoutView, kdxdb, traitProvider, sampleTypes);

    SuppressionInfoProvider suppressionInfoProvider = new SuppressionInfoProvider(curationData,
            curationTableModel, curationTable);

    suppressionHandler = new SuppressionHandler(curationContext, curationData, curationCellEditor,
            suppressionInfoProvider);

    loadVisualisationTools();

    curationMenuProvider = new CurationMenuProvider(curationContext, curationData, messages, visualisationTools,
            suppressionHandler);

    curationMenuProvider.setSuppressionInfoProvider(suppressionInfoProvider);

    fieldLayoutView.addTraitInstanceSelectionListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (ItemEvent.SELECTED == e.getStateChange()) {
                TraitInstance traitInstance = fieldLayoutView.getActiveTraitInstance(true);
                if (traitInstance == null) {
                    curationCellEditor.setCurationCellValue(null);
                } else {
                    // startEdit(HowStarted.FIELD_VIEW_CHANGED_ACTIVE_TRAIT_INSTANCE);
                }
                fieldLayoutView.updateSamplesSelectedInTable();
            }
        }
    });

    // = = = = = = =

    curationData.addUnsavedChangesListener(new UnsavedChangesListener() {
        @Override
        public void unsavedChangesExist(Object source, int nChanges) {
            int unsavedCount = curationData.getUnsavedChangesCount();
            saveChangesAction.setEnabled(unsavedCount > 0);

            if (unsavedCount > 0) {
                statusInfoLine.setMessage("Unsaved changes: " + unsavedCount);
            } else {
                statusInfoLine.setMessage("No Unsaved changes");
            }
        }
    });

    // curationData.addEditedSampleChangeListener(new ChangeListener() {
    // @Override
    // public void stateChanged(ChangeEvent e) {
    // handleEditedSampleChanges();
    // }
    // });
    saveChangesAction.setEnabled(false);
    changeManager.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            updateUndoRedoActions();
        }
    });
    undoAction.setEnabled(false);
    redoAction.setEnabled(false);

    // = = = = = = = =

    // TODO provide one of these for each relevant device type
    DeviceType deviceTypeForSamples = null;

    StatsData statsData = curationData.getStatsData(deviceTypeForSamples);

    TIStatsTableModel statsTableModel = new TIStatsTableModel2(curationData, statsData, deviceTypeForSamples);

    traitColourProvider.generateColorMap(statsData.getTraitInstancesWithData());

    Set<Integer> instanceNumbers = statsData.getInstanceNumbers();
    String nonHtmlLabel;
    if (instanceNumbers.size() > 1) {
        tAndIpanelLabel = "<HTML><i>Plot Info</i> &amp; Trait Instances";
        nonHtmlLabel = "Plot Info & Trait Instances";
    } else {
        tAndIpanelLabel = "<HTML><i>Plot Info</i> &amp; Traits";
        nonHtmlLabel = "Plot Info & Traits";
    }

    traitsAndInstancesPanel = new TraitsAndInstancesPanel2(curationContext, smallFont, statsTableModel,
            instanceNumbers.size() > 1, statsData.getInvalidRuleCount(), nonHtmlLabel, curationMenuProvider,
            outlierConsumer);

    traitsAndInstancesPanel.addTraitInstanceStatsItemListener(new ItemListener() {
        boolean busy;

        @Override
        public void itemStateChanged(ItemEvent e) {
            // NOTE: we want to process both SELECTED and DESELECTED
            // variants
            if (busy) {
                Shared.Log.d(TAG, "***** LOOPED in traitsAndInstancesPanel.ItemListener"); //$NON-NLS-1$
            } else {
                Shared.Log.d(TAG, "traitsAndInstancesPanel.ItemListener BEGIN"); //$NON-NLS-1$
                busy = true;
                try {
                    updateViewedTraitInstances(e); // !!!!!
                } finally {
                    busy = false;
                    Shared.Log.d(TAG, "traitsAndInstancesPanel.ItemListener END\n"); //$NON-NLS-1$
                }
            }
        }
    });

    // = = = = = = = =

    plotCellChoicesPanel = new PlotCellChoicesPanel(curationContext, curationData, deviceTypeForSamples,
            tAndIpanelLabel, curationMenuProvider, colorProviderFactory);

    // plotCellChoicesPanel.setData(
    // curationData.getPlotAttributes(),
    // traitsAndInstancesPanel.getTraitInstancesWithData());

    plotCellChoicesPanel.addPlotCellChoicesListener(new PlotCellChoicesListener() {
        @Override
        public void traitInstanceChoicesChanged(Object source, boolean choiceAdded, TraitInstance[] choice,
                Map<Integer, Set<TraitInstance>> traitInstancesByTraitId) {
            traitsAndInstancesPanel.changeTraitInstanceChoice(choiceAdded, choice);
        }

        @Override
        public void plotAttributeChoicesChanged(Object source, List<ValueRetriever<?>> vrList) {
            curationTableModel.setSelectedPlotAttributes(vrList);
        }
    });

    // = = = = = = = =

    statsAndSamplesSplit = createStatsAndSamplesTable(traitsAndInstancesPanel.getComponent());

    mainTabbedPane.addTab(TAB_SAMPLES, samplesTableIcon, statsAndSamplesSplit, Msg.TOOLTIP_SAMPLES_TABLE());

    // = = = = = = = =

    checkForInvalidTraits();

    leftSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, createCurationCellEditorComponent(),
            plotCellChoicesPanel);
    leftSplit.setResizeWeight(0.5);
    // traitToDoTaskPaneContainer);

    // rightSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
    // traitsAndInstancesPanel, fieldViewAndPlots);
    // rightSplit.setResizeWeight(0.5);
    // rightSplit.setOneTouchExpandable(true);

    leftAndRightSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftSplit, mainTabbedPane);
    leftAndRightSplit.setOneTouchExpandable(true);

    mainVerticalSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, messages, leftAndRightSplit);
    mainVerticalSplit.setOneTouchExpandable(true);
    mainVerticalSplit.setResizeWeight(0.0);

    add(statusInfoLine, BorderLayout.NORTH);
    add(mainVerticalSplit, BorderLayout.CENTER);

    fieldLayoutView.addCellSelectionListener(fieldViewCellSelectionListener);

    curationTable.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent me) {
            if (SwingUtilities.isRightMouseButton(me) && 1 == me.getClickCount()) {
                me.consume();
                displayPopupMenu(me);
            }

        }
    });
}

From source file:org.domainmath.gui.MainFrame.java

public void exitApp() {
    int j = fileTab.getTabCount() - 1;
    while (j != -1) {

        askSave(j);//from   w w w. j  av  a2  s.com
        j--;
    }
    ShutDown shutDown = new ShutDown(this, "DomainMath IDE", "Really do you want to exit?");
    JButton yes = new JButton("Yes");
    JButton no = new JButton("No");
    JCheckBox confirmation = shutDown.getCheckBox();
    Preferences pr2 = Preferences.userNodeForPackage(this.getClass());
    boolean skipConfirmation = pr2.getBoolean("skip_confirmation", false);

    confirmation.addItemListener((ItemEvent e) -> {
        if (ItemEvent.DESELECTED == e.getStateChange()) {
            pr2.putBoolean("skip_confirmation", false);
        } else {
            pr2.putBoolean("skip_confirmation", true);
        }
    });

    yes.addActionListener((ActionEvent e) -> {
        exitFinal(shutDown);
    });
    no.addActionListener((ActionEvent e) -> {
        shutDown.dispose();
    });

    if (false == skipConfirmation) {
        shutDown.addButton(yes);
        shutDown.addButton(no);
        shutDown.setVisible(true);
    } else {
        exitFinal(shutDown);
    }
}

From source file:org.domainmath.gui.MainFrame.java

private void dirComboBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_dirComboBoxItemStateChanged
    if (evt.getStateChange() == ItemEvent.SELECTED) {
        Object s = this.dirComboBox.getSelectedItem();
        int n = dirComboBox.getItemCount();

        if (dirComboBox.getSelectedIndex() <= -1) {
            if (n == 0) {
                dirComboBox.addItem(s);/* w  w  w  . j a v  a2  s .co  m*/
                cd(s.toString());
            } else {
                for (int i = 0; i < dirComboBox.getItemCount(); i++) {
                    if (s == dirComboBox.getItemAt(i)) {
                        System.out.println("Repeated");
                    } else {
                        dirComboBox.removeItem(s);
                        dirComboBox.insertItemAt(s, 0);
                        dirComboBox.setSelectedIndex(0);
                        cd(s.toString());
                        break;
                    }
                }
            }
        } else {
            if (dirComboBox.getSelectedIndex() > 0) {
                Object item = dirComboBox.getSelectedItem();
                dirComboBox.removeItem(item);
                dirComboBox.insertItemAt(item, 0);

                dirComboBox.setSelectedIndex(0);
                cd(item.toString());
            }
        }
    }
}

From source file:com.mirth.connect.client.ui.ChannelSetup.java

private void attachmentStoreCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_attachmentStoreCheckBoxItemStateChanged
    attachmentWarningLabel.setVisible(evt.getStateChange() != ItemEvent.SELECTED
            && attachmentComboBox.getSelectedItem() != AttachmentHandlerType.NONE);
}