Search in sources :

Example 46 with ItemListener

use of java.awt.event.ItemListener in project jadx by skylot.

the class JadxSettingsWindow method makeDecompilationGroup.

private SettingsGroup makeDecompilationGroup() {
    JCheckBox fallback = new JCheckBox();
    fallback.setSelected(settings.isFallbackMode());
    fallback.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            settings.setFallbackMode(e.getStateChange() == ItemEvent.SELECTED);
            needReload();
        }
    });
    JCheckBox showInconsistentCode = new JCheckBox();
    showInconsistentCode.setSelected(settings.isShowInconsistentCode());
    showInconsistentCode.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            settings.setShowInconsistentCode(e.getStateChange() == ItemEvent.SELECTED);
            needReload();
        }
    });
    JCheckBox resourceDecode = new JCheckBox();
    resourceDecode.setSelected(settings.isSkipResources());
    resourceDecode.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            settings.setSkipResources(e.getStateChange() == ItemEvent.SELECTED);
            needReload();
        }
    });
    final JSpinner threadsCount = new JSpinner();
    threadsCount.setValue(settings.getThreadsCount());
    threadsCount.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            settings.setThreadsCount((Integer) threadsCount.getValue());
        }
    });
    JCheckBox autoStartJobs = new JCheckBox();
    autoStartJobs.setSelected(settings.isAutoStartJobs());
    autoStartJobs.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            settings.setAutoStartJobs(e.getStateChange() == ItemEvent.SELECTED);
        }
    });
    JCheckBox escapeUnicode = new JCheckBox();
    escapeUnicode.setSelected(settings.escapeUnicode());
    escapeUnicode.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            settings.setEscapeUnicode(e.getStateChange() == ItemEvent.SELECTED);
            needReload();
        }
    });
    JCheckBox replaceConsts = new JCheckBox();
    replaceConsts.setSelected(settings.isReplaceConsts());
    replaceConsts.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            settings.setReplaceConsts(e.getStateChange() == ItemEvent.SELECTED);
            needReload();
        }
    });
    SettingsGroup other = new SettingsGroup(NLS.str("preferences.decompile"));
    other.addRow(NLS.str("preferences.threads"), threadsCount);
    other.addRow(NLS.str("preferences.start_jobs"), autoStartJobs);
    other.addRow(NLS.str("preferences.showInconsistentCode"), showInconsistentCode);
    other.addRow(NLS.str("preferences.escapeUnicode"), escapeUnicode);
    other.addRow(NLS.str("preferences.replaceConsts"), replaceConsts);
    other.addRow(NLS.str("preferences.fallback"), fallback);
    other.addRow(NLS.str("preferences.skipResourcesDecode"), resourceDecode);
    return other;
}
Also used : JCheckBox(javax.swing.JCheckBox) ItemEvent(java.awt.event.ItemEvent) ChangeEvent(javax.swing.event.ChangeEvent) JSpinner(javax.swing.JSpinner) ItemListener(java.awt.event.ItemListener) ChangeListener(javax.swing.event.ChangeListener)

Example 47 with ItemListener

use of java.awt.event.ItemListener in project intellij-plugins by JetBrains.

the class MarkdownPreviewSettingsForm method createUIComponents.

private void createUIComponents() {
    //noinspection unchecked
    final List<MarkdownHtmlPanelProvider.ProviderInfo> providerInfos = ContainerUtil.mapNotNull(MarkdownHtmlPanelProvider.getProviders(), provider -> {
        if (provider.isAvailable() == MarkdownHtmlPanelProvider.AvailabilityInfo.UNAVAILABLE) {
            return null;
        }
        return provider.getProviderInfo();
    });
    myPreviewPanelModel = new CollectionComboBoxModel<>(providerInfos, providerInfos.get(0));
    myPreviewProvider = new ComboBox(myPreviewPanelModel);
    mySplitLayoutModel = new EnumComboBoxModel<>(SplitFileEditor.SplitEditorLayout.class);
    myDefaultSplitLayout = new ComboBox(mySplitLayoutModel);
    myLastItem = myPreviewProvider.getSelectedItem();
    myPreviewProvider.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            final Object item = e.getItem();
            if (e.getStateChange() != ItemEvent.SELECTED || !(item instanceof MarkdownHtmlPanelProvider.ProviderInfo)) {
                return;
            }
            final MarkdownHtmlPanelProvider provider = MarkdownHtmlPanelProvider.createFromInfo((MarkdownHtmlPanelProvider.ProviderInfo) item);
            final MarkdownHtmlPanelProvider.AvailabilityInfo availability = provider.isAvailable();
            if (!availability.checkAvailability(myMainPanel)) {
                myPreviewProvider.setSelectedItem(myLastItem);
            } else {
                myLastItem = item;
                updateUseGrayscaleEnabled();
            }
        }
    });
}
Also used : ItemEvent(java.awt.event.ItemEvent) ComboBox(com.intellij.openapi.ui.ComboBox) ItemListener(java.awt.event.ItemListener) MarkdownHtmlPanelProvider(org.intellij.plugins.markdown.ui.preview.MarkdownHtmlPanelProvider)

Example 48 with ItemListener

use of java.awt.event.ItemListener in project JMRI by JMRI.

the class RosterGroupsPanel method getButtons.

private JToolBar getButtons() {
    JToolBar controls = new JToolBar();
    controls.setLayout(new GridLayout(1, 0, 0, 0));
    controls.setFloatable(false);
    final JToggleButton addGroupBtn = new JToggleButton(new ImageIcon(FileUtil.findURL("resources/icons/misc/gui3/Add.png")), false);
    final JToggleButton actGroupBtn = new JToggleButton(new ImageIcon(FileUtil.findURL("resources/icons/misc/gui3/Action.png")), false);
    addGroupBtn.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            new CreateRosterGroupAction("", scrollPane.getTopLevelAncestor()).actionPerformed(e);
            addGroupBtn.setSelected(false);
        }
    });
    actGroupBtn.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent ie) {
            if (ie.getStateChange() == ItemEvent.SELECTED) {
                TreePath g = new TreePath(_model.getPathToRoot(_groups));
                if (_tree.getSelectionPath() != null) {
                    if (_tree.getSelectionPath().getLastPathComponent().toString().equals(Roster.ALLENTRIES)) {
                        allEntriesMenu.show((JComponent) ie.getSource(), actGroupBtn.getX() - actGroupBtn.getWidth(), actGroupBtn.getY() - allEntriesMenu.getPreferredSize().height);
                    } else if (g.isDescendant(_tree.getSelectionPath()) && !_tree.getSelectionPath().isDescendant(g)) {
                        groupsMenu.show((JComponent) ie.getSource(), actGroupBtn.getX() - actGroupBtn.getWidth(), actGroupBtn.getY() - groupsMenu.getPreferredSize().height);
                    }
                }
            }
        }
    });
    PopupMenuListener PML = new PopupMenuListener() {

        @Override
        public void popupMenuWillBecomeVisible(PopupMenuEvent pme) {
        // do nothing
        }

        @Override
        public void popupMenuWillBecomeInvisible(PopupMenuEvent pme) {
            actGroupBtn.setSelected(false);
        }

        @Override
        public void popupMenuCanceled(PopupMenuEvent pme) {
            actGroupBtn.setSelected(false);
        }
    };
    allEntriesMenu.addPopupMenuListener(PML);
    groupsMenu.addPopupMenuListener(PML);
    controls.add(addGroupBtn);
    controls.add(actGroupBtn);
    return controls;
}
Also used : ImageIcon(javax.swing.ImageIcon) ItemEvent(java.awt.event.ItemEvent) ActionEvent(java.awt.event.ActionEvent) PopupMenuListener(javax.swing.event.PopupMenuListener) JComponent(javax.swing.JComponent) JToolBar(javax.swing.JToolBar) PopupMenuEvent(javax.swing.event.PopupMenuEvent) GridLayout(java.awt.GridLayout) JToggleButton(javax.swing.JToggleButton) ActionListener(java.awt.event.ActionListener) TreePath(javax.swing.tree.TreePath) ItemListener(java.awt.event.ItemListener)

Example 49 with ItemListener

use of java.awt.event.ItemListener in project JMRI by JMRI.

the class AbstractNetworkConnectionConfig method loadDetails.

@Override
public void loadDetails(final JPanel details) {
    _details = details;
    setInstance();
    if (!init) {
        //Build up list of options
        //Hashtable<String, AbstractPortController.Option> adapterOptions = ((AbstractPortController)adapter).getOptionList();
        String[] optionsAvailable = adapter.getOptions();
        options = new Hashtable<String, Option>();
        for (String i : optionsAvailable) {
            JComboBox<String> opt = new JComboBox<String>(adapter.getOptionChoices(i));
            opt.setSelectedItem(adapter.getOptionState(i));
            // check that it worked
            if (!adapter.getOptionState(i).equals(opt.getSelectedItem())) {
                // no, set 1st option choice
                opt.setSelectedIndex(0);
                // log before setting new value to show old value
                log.warn("Loading found invalid value for option {}, found \"{}\", setting to \"{}\"", i, adapter.getOptionState(i), opt.getSelectedItem());
                adapter.setOptionState(i, (String) opt.getSelectedItem());
            }
            options.put(i, new Option(adapter.getOptionDisplayName(i), opt, adapter.isOptionAdvanced(i)));
        }
    }
    if (hostNameField.getActionListeners().length > 0) {
        hostNameField.removeActionListener(hostNameField.getActionListeners()[0]);
    }
    if (adapter.getSystemConnectionMemo() != null) {
        systemPrefixField.setText(adapter.getSystemConnectionMemo().getSystemPrefix());
        connectionNameField.setText(adapter.getSystemConnectionMemo().getUserName());
        NUMOPTIONS = NUMOPTIONS + 2;
    }
    NUMOPTIONS = NUMOPTIONS + options.size();
    hostNameField.setText(adapter.getHostName());
    hostNameFieldLabel = new JLabel(rb.getString("HostFieldLabel"));
    hostNameField.setToolTipText(rb.getString("HostFieldToolTip"));
    if (adapter.getHostName() == null || adapter.getHostName().equals("")) {
        hostNameField.setText(p.getComboBoxLastSelection(adapter.getClass().getName() + ".hostname"));
        adapter.setHostName(hostNameField.getText());
    }
    portField.setToolTipText(rb.getString("PortFieldToolTip"));
    portField.setEnabled(true);
    portField.setText("" + adapter.getPort());
    portFieldLabel = new JLabel(rb.getString("PortFieldLabel"));
    adNameField.setToolTipText(rb.getString("AdNameFieldToolTip"));
    adNameField.setEnabled(false);
    adNameField.setText("" + adapter.getAdvertisementName());
    adNameFieldLabel = new JLabel(rb.getString("AdNameFieldLabel"));
    adNameFieldLabel.setEnabled(false);
    serviceTypeField.setToolTipText(rb.getString("ServiceTypeFieldToolTip"));
    serviceTypeField.setEnabled(false);
    serviceTypeField.setText("" + adapter.getServiceType());
    serviceTypeFieldLabel = new JLabel(rb.getString("ServiceTypeFieldLabel"));
    serviceTypeFieldLabel.setEnabled(false);
    showAutoConfig.setFont(showAutoConfig.getFont().deriveFont(9f));
    showAutoConfig.setForeground(Color.blue);
    showAutoConfig.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            setAutoNetworkConfig();
        }
    });
    showAutoConfig.setSelected(adapter.getMdnsConfigure());
    setAutoNetworkConfig();
    showAdvanced.setFont(showAdvanced.getFont().deriveFont(9f));
    showAdvanced.setForeground(Color.blue);
    showAdvanced.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            showAdvancedItems();
        }
    });
    showAdvancedItems();
    // need to reload action listeners
    init = false;
    checkInitDone();
}
Also used : ItemEvent(java.awt.event.ItemEvent) JComboBox(javax.swing.JComboBox) JLabel(javax.swing.JLabel) ItemListener(java.awt.event.ItemListener)

Example 50 with ItemListener

use of java.awt.event.ItemListener in project JMRI by JMRI.

the class AbstractSimulatorConnectionConfig method loadDetails.

@Override
public void loadDetails(final JPanel details) {
    _details = details;
    setInstance();
    if (!init) {
        String[] optionsAvailable = adapter.getOptions();
        options = new Hashtable<String, Option>();
        for (String i : optionsAvailable) {
            JComboBox<String> opt = new JComboBox<String>(adapter.getOptionChoices(i));
            opt.setSelectedItem(adapter.getOptionState(i));
            // check that it worked
            if (!adapter.getOptionState(i).equals(opt.getSelectedItem())) {
                // no, set 1st option choice
                opt.setSelectedIndex(0);
                // log before setting new value to show old value
                log.warn("Loading found invalid value for option {}, found \"{}\", setting to \"{}\"", i, adapter.getOptionState(i), opt.getSelectedItem());
                adapter.setOptionState(i, (String) opt.getSelectedItem());
            }
            options.put(i, new Option(adapter.getOptionDisplayName(i), opt, adapter.isOptionAdvanced(i)));
        }
    }
    if (adapter.getSystemConnectionMemo() != null) {
        systemPrefixField.setText(adapter.getSystemConnectionMemo().getSystemPrefix());
        connectionNameField.setText(adapter.getSystemConnectionMemo().getUserName());
    }
    NUMOPTIONS = NUMOPTIONS + options.size();
    showAdvanced.setFont(showAdvanced.getFont().deriveFont(9f));
    showAdvanced.setForeground(Color.blue);
    showAdvanced.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            showAdvancedItems();
        }
    });
    showAdvancedItems();
    // need to reload action listeners
    init = false;
    checkInitDone();
}
Also used : ItemEvent(java.awt.event.ItemEvent) JComboBox(javax.swing.JComboBox) ItemListener(java.awt.event.ItemListener)

Aggregations

ItemListener (java.awt.event.ItemListener)162 ItemEvent (java.awt.event.ItemEvent)154 ActionEvent (java.awt.event.ActionEvent)45 ActionListener (java.awt.event.ActionListener)43 JCheckBox (javax.swing.JCheckBox)33 JPanel (javax.swing.JPanel)27 JLabel (javax.swing.JLabel)23 JComboBox (javax.swing.JComboBox)18 BoxLayout (javax.swing.BoxLayout)15 JTextField (javax.swing.JTextField)14 DocumentEvent (javax.swing.event.DocumentEvent)13 JButton (javax.swing.JButton)12 ChangeEvent (javax.swing.event.ChangeEvent)12 Dimension (java.awt.Dimension)11 ChangeListener (javax.swing.event.ChangeListener)11 GridBagConstraints (java.awt.GridBagConstraints)10 GridLayout (java.awt.GridLayout)10 Box (javax.swing.Box)10 GridBagLayout (java.awt.GridBagLayout)9 BorderLayout (java.awt.BorderLayout)8