Search in sources :

Example 56 with ItemListener

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

the class CPUSnapshotView method setupUI.

private void setupUI() {
    myHotSpotsTreeTable.setRootVisible(false);
    myTracesTreeTable.setRootVisible(false);
    setColumnWidth(myHotSpotsTreeTable.getColumnModel().getColumn(1), MS_COLUMN_WIDTH);
    setColumnWidth(myHotSpotsTreeTable.getColumnModel().getColumn(2), MS_COLUMN_WIDTH);
    setColumnWidth(myTracesTreeTable.getColumnModel().getColumn(1), MS_COLUMN_WIDTH);
    setColumnWidth(myTracesTreeTable.getColumnModel().getColumn(2), MS_COLUMN_WIDTH);
    scopeLabel.setLabelFor(filterScope.getComboBox());
    invokedFunctionsLabel.setLabelFor(myHotSpotsTreeTable);
    mergedCalleesLabel.setLabelFor(myTracesTreeTable);
    new TreeTableSpeedSearch(myHotSpotsTreeTable).setComparator(new SpeedSearchComparator(false));
    new TreeTableSpeedSearch(myTracesTreeTable).setComparator(new SpeedSearchComparator(false));
    PopupHandler.installPopupHandler(myHotSpotsTreeTable, PROFILER_VIEW_GROUP_ID, ActionPlaces.UNKNOWN);
    PopupHandler.installPopupHandler(myTracesTreeTable, PROFILER_VIEW_GROUP_ID, ActionPlaces.UNKNOWN);
    final ComboBoxModel model = filterScope.getComboBox().getModel();
    if (model instanceof DefaultComboBoxModel) {
        ((DefaultComboBoxModel) model).insertElementAt(new ScopeDescriptor(new AllSearchScope(getProject())), 0);
    }
    myHotSpotsTreeTable.getTree().setCellRenderer(new FrameInfoCellRenderer(projectScope) {

        @Override
        public void customizeCellRenderer(Object value, boolean selected) {
            setPaintFocusBorder(false);
            setScopeIcon(FlexProfilerIcons.CallerArrow);
            setNonScopeIcon(FlexProfilerIcons.CallerLeafArrow);
            super.customizeCellRenderer(value, selected);
        }
    });
    myTracesTreeTable.getTree().setCellRenderer(new FrameInfoCellRenderer(projectScope) {

        @Override
        public void customizeCellRenderer(Object value, boolean selected) {
            setPaintFocusBorder(false);
            setScopeIcon(FlexProfilerIcons.CalleeArrow);
            setNonScopeIcon(FlexProfilerIcons.CalleeLeafArrow);
            super.customizeCellRenderer(value, selected);
        }
    });
    myFilterSystemStuff.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            buildPerformanceSamples(myHotSpotsTreeTable.getSortableTreeTableModel());
            TreeUtil.expand(myHotSpotsTreeTable.getTree(), 1);
        }
    });
    filterScope.getComboBox().addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            myAlarm.cancelAllRequests();
            myAlarm.addRequest(() -> {
                buildPerformanceSamples(myHotSpotsTreeTable.getSortableTreeTableModel());
                TreeUtil.expand(myHotSpotsTreeTable.getTree(), 1);
            }, 100);
        }
    });
}
Also used : TreeTableSpeedSearch(com.intellij.ui.TreeTableSpeedSearch) ScopeDescriptor(com.intellij.ide.util.scopeChooser.ScopeDescriptor) FrameInfoCellRenderer(com.jetbrains.actionscript.profiler.render.FrameInfoCellRenderer) ItemEvent(java.awt.event.ItemEvent) AllSearchScope(com.jetbrains.actionscript.profiler.util.AllSearchScope) ItemListener(java.awt.event.ItemListener) SpeedSearchComparator(com.intellij.ui.SpeedSearchComparator)

Example 57 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 58 with ItemListener

use of java.awt.event.ItemListener in project beast-mcmc by beast-dev.

the class HierarchicalPriorDialog method showDialog.

public int showDialog(final java.util.List<Parameter> parameterList) {
    this.parameterList = parameterList;
    this.parameter = parameterList.get(0);
    PriorType priorType = parameter.priorType;
    // Set-up combo box depending on parameters
    priorCombo.removeAllItems();
    if (parameter.isNonNegative) {
        priorCombo.addItem(PriorType.LOGNORMAL_HPM_PRIOR);
    }
    priorCombo.addItem(PriorType.NORMAL_HPM_PRIOR);
    priorCombo.setSelectedItem(priorType);
    double lower = Double.NEGATIVE_INFINITY;
    double upper = Double.POSITIVE_INFINITY;
    if (parameter.isZeroOne) {
        lower = 0.0;
        upper = 1.0;
    } else if (parameter.isNonNegative) {
        lower = 0.0;
    }
    initialField.setRange(lower, upper);
    initialField.setValue(parameter.getInitial());
    panel = new JPanel(new GridBagLayout());
    setupComponents();
    JScrollPane scrollPane = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setBorder(null);
    scrollPane.getViewport().setOpaque(false);
    JOptionPane optionPane = new JOptionPane(scrollPane, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, null, null);
    optionPane.setBorder(new EmptyBorder(12, 12, 12, 12));
    final JDialog dialog = optionPane.createDialog(frame, "Phylogenetic Hierarchical Model Setup");
    priorCombo.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            setupComponents();
            dialog.validate();
            dialog.repaint();
            dialog.pack();
        }
    });
    for (PriorOptionsPanel optionsPanel : optionsPanels.values()) {
        optionsPanel.addListener(new PriorOptionsPanel.Listener() {

            public void optionsPanelChanged() {
                setupChart();
                dialog.validate();
                dialog.repaint();
            }
        });
    }
    dialog.pack();
    if (OSType.isMac()) {
        dialog.setMinimumSize(new Dimension(dialog.getBounds().width, 300));
    } else {
        Toolkit tk = Toolkit.getDefaultToolkit();
        Dimension d = tk.getScreenSize();
        if (d.height < 700 && panel.getHeight() > 450) {
            dialog.setSize(new Dimension(panel.getWidth() + 100, 550));
        } else {
            // setSize because optionsPanel is shrunk in dialog
            dialog.setSize(new Dimension(panel.getWidth() + 100, panel.getHeight() + 100));
        }
    //            System.out.println("panel width = " + panel.getWidth());
    //            System.out.println("panel height = " + panel.getHeight());
    }
    dialog.setResizable(true);
    dialog.setVisible(true);
    int result = JOptionPane.CANCEL_OPTION;
    Integer value = (Integer) optionPane.getValue();
    if (value != null && value != -1) {
        result = value;
    }
    return result;
}
Also used : ItemEvent(java.awt.event.ItemEvent) PriorType(dr.app.beauti.types.PriorType) ItemListener(java.awt.event.ItemListener) EmptyBorder(javax.swing.border.EmptyBorder)

Example 59 with ItemListener

use of java.awt.event.ItemListener in project beast-mcmc by beast-dev.

the class PriorSettingsPanel method setParameter.

/**
     * Set the parameter to be controlled
     *                                                                                                       q
     * @param parameter
     */
public void setParameter(final Parameter parameter) {
    this.parameter = parameter;
    priorCombo = new JComboBox();
    for (PriorType priorType : PriorType.getPriorTypes(parameter)) {
        priorCombo.addItem(priorType);
    }
    if (parameter.priorType != null) {
        priorCombo.setSelectedItem(parameter.priorType);
    }
    // setArguments here
    setupComponents();
    priorCombo.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            setupComponents();
            dialog.pack();
            dialog.repaint();
        }
    });
    for (PriorOptionsPanel optionsPanel : optionsPanels.values()) {
        optionsPanel.removeAllListeners();
        optionsPanel.addListener(new PriorOptionsPanel.Listener() {

            public void optionsPanelChanged() {
                setupChart();
                dialog.pack();
                dialog.repaint();
            }
        });
    }
}
Also used : ItemEvent(java.awt.event.ItemEvent) ItemListener(java.awt.event.ItemListener) PriorType(dr.app.beauti.types.PriorType)

Example 60 with ItemListener

use of java.awt.event.ItemListener in project beast-mcmc by beast-dev.

the class StatisticsPanel method createStatistic.

public TreeSummaryStatistic createStatistic(TreeSummaryStatistic.Factory factory) {
    if (!factory.allowsTaxonList() && !factory.allowsDouble() && !factory.allowsInteger() && !factory.allowsString()) {
        return factory.createStatistic();
    }
    OptionsPanel optionPanel = new OptionsPanel();
    optionPanel.addSpanningComponent(new JLabel(factory.getSummaryStatisticDescription()));
    final JRadioButton wholeTreeRadio = new JRadioButton("For the whole tree", false);
    final JRadioButton taxonSetRadio = new JRadioButton("Using a given taxon set", false);
    final JComboBox taxonSetCombo = new JComboBox();
    final JTextField valueField;
    if (factory.allowsTaxonList()) {
        for (Object taxonSet : treeStatData.taxonSets) {
            taxonSetCombo.addItem(taxonSet);
        }
        ButtonGroup group = new ButtonGroup();
        ItemListener listener = new ItemListener() {

            public void itemStateChanged(ItemEvent e) {
                taxonSetCombo.setEnabled(taxonSetRadio.isSelected());
            }
        };
        if (factory.allowsWholeTree()) {
            group.add(wholeTreeRadio);
            wholeTreeRadio.addItemListener(listener);
            optionPanel.addSpanningComponent(wholeTreeRadio);
            optionPanel.addSeparator();
        }
        if (factory.allowsTaxonList()) {
            group.add(taxonSetRadio);
            taxonSetRadio.addItemListener(listener);
            optionPanel.addSpanningComponent(taxonSetRadio);
            optionPanel.addComponentWithLabel("Taxon Set: ", taxonSetCombo);
            optionPanel.addSeparator();
        }
        if (factory.allowsTaxonList()) {
            taxonSetRadio.setSelected(true);
        }
        if (factory.allowsWholeTree()) {
            wholeTreeRadio.setSelected(true);
        }
    }
    if (factory.allowsDouble() || factory.allowsInteger() || factory.allowsString()) {
        if (factory.allowsDouble()) {
            valueField = new RealNumberField();
            valueField.setColumns(12);
            optionPanel.addComponentWithLabel(factory.getValueName(), valueField);
        } else if (factory.allowsInteger()) {
            valueField = new WholeNumberField();
            valueField.setColumns(12);
            optionPanel.addComponentWithLabel(factory.getValueName(), valueField);
        } else {
            // allowsString
            valueField = new JTextField();
            valueField.setColumns(24);
            optionPanel.addComponentWithLabel(factory.getValueName(), valueField);
        }
    } else {
        valueField = null;
    }
    JOptionPane optionPane = new JOptionPane(optionPanel, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, null, null);
    optionPane.setBorder(new EmptyBorder(12, 12, 12, 12));
    JDialog dialog = optionPane.createDialog(frame, factory.getSummaryStatisticName());
    //		dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    dialog.pack();
    dialog.setVisible(true);
    if (optionPane.getValue() == null) {
        return null;
    }
    int result = (Integer) optionPane.getValue();
    if (result == -1 || result == JOptionPane.CANCEL_OPTION) {
        return null;
    }
    TreeSummaryStatistic statistic = factory.createStatistic();
    if (wholeTreeRadio.isSelected()) {
        statistic = factory.createStatistic();
    } else if (taxonSetRadio.isSelected()) {
        TreeStatData.TaxonSet t = (TreeStatData.TaxonSet) taxonSetCombo.getSelectedItem();
        Taxa taxa = new Taxa();
        taxa.setId(t.name);
        //Iterator iter = t.taxa.iterator();
        for (Object aTaxa : t.taxa) {
            String id = (String) aTaxa;
            Taxon taxon = new Taxon(id);
            taxa.addTaxon(taxon);
        }
        statistic.setTaxonList(taxa);
    } else {
        return null;
    }
    if (factory.allowsDouble()) {
        assert valueField instanceof RealNumberField;
        Double value = ((RealNumberField) valueField).getValue();
        statistic.setDouble(value);
    } else if (factory.allowsInteger()) {
        assert valueField instanceof WholeNumberField;
        Integer value = ((WholeNumberField) valueField).getValue();
        statistic.setInteger(value);
    } else if (factory.allowsString()) {
        String value = valueField.getText();
        statistic.setString(value);
    }
    return statistic;
}
Also used : ItemEvent(java.awt.event.ItemEvent) WholeNumberField(dr.app.gui.components.WholeNumberField) Taxon(dr.evolution.util.Taxon) RealNumberField(dr.app.gui.components.RealNumberField) Taxa(dr.evolution.util.Taxa) ItemListener(java.awt.event.ItemListener) EmptyBorder(javax.swing.border.EmptyBorder) OptionsPanel(jam.panels.OptionsPanel)

Aggregations

ItemListener (java.awt.event.ItemListener)120 ItemEvent (java.awt.event.ItemEvent)119 ActionEvent (java.awt.event.ActionEvent)34 ActionListener (java.awt.event.ActionListener)31 JCheckBox (javax.swing.JCheckBox)21 JPanel (javax.swing.JPanel)14 JComboBox (javax.swing.JComboBox)10 JLabel (javax.swing.JLabel)10 DocumentEvent (javax.swing.event.DocumentEvent)10 JButton (javax.swing.JButton)9 ArrayList (java.util.ArrayList)8 ChangeEvent (javax.swing.event.ChangeEvent)8 ChangeListener (javax.swing.event.ChangeListener)8 DocumentAdapter (com.intellij.ui.DocumentAdapter)7 GridBagConstraints (java.awt.GridBagConstraints)7 BorderLayout (java.awt.BorderLayout)6 GridBagLayout (java.awt.GridBagLayout)6 Insets (java.awt.Insets)5 List (java.util.List)5 BoxLayout (javax.swing.BoxLayout)5