Search in sources :

Example 1 with FlowVariableListCellRenderer

use of org.knime.core.node.util.FlowVariableListCellRenderer in project knime-core by knime.

the class JSnippetPanel method initComponents.

private void initComponents() {
    m_colList = new JList(new DefaultListModel());
    m_colList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    m_colList.addKeyListener(new KeyAdapter() {

        /**
         * {@inheritDoc}
         */
        @Override
        public void keyTyped(final KeyEvent e) {
            if (e.getKeyChar() == KeyEvent.VK_ENTER) {
                Object selected = m_colList.getSelectedValue();
                if (selected != null) {
                    onSelectionInColumnList(selected);
                }
            }
        }
    });
    m_colList.addMouseListener(new MouseAdapter() {

        /**
         * {@inheritDoc}
         */
        @Override
        public void mouseClicked(final MouseEvent e) {
            if (e.getClickCount() == 2) {
                Object selected = m_colList.getSelectedValue();
                if (selected != null) {
                    onSelectionInColumnList(selected);
                }
            }
        }
    });
    m_colList.setCellRenderer(new ListRenderer());
    m_flowVarsList = new JList(new DefaultListModel());
    m_flowVarsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    // enable tooltip
    m_flowVarsList.setToolTipText("");
    m_flowVarsList.addKeyListener(new KeyAdapter() {

        /**
         * {@inheritDoc}
         */
        @Override
        public void keyTyped(final KeyEvent e) {
            if (e.getKeyChar() == KeyEvent.VK_ENTER) {
                Object selected = m_flowVarsList.getSelectedValue();
                if (selected != null) {
                    onSelectionInVariableList(selected);
                }
            }
        }
    });
    m_flowVarsList.addMouseListener(new MouseAdapter() {

        /**
         * {@inheritDoc}
         */
        @Override
        public void mouseClicked(final MouseEvent e) {
            if (e.getClickCount() == 2) {
                Object selected = m_flowVarsList.getSelectedValue();
                if (selected != null) {
                    onSelectionInVariableList(selected);
                }
            }
        }
    });
    m_flowVarsList.setCellRenderer(new FlowVariableListCellRenderer());
    m_categories = new JComboBox(m_manipProvider.getCategories().toArray());
    m_categories.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            JComboBox cb = (JComboBox) e.getSource();
            String category = (String) cb.getSelectedItem();
            updateManipulatorList(category);
        }
    });
    m_manipulators = new JList(new DefaultListModel());
    m_manipulators.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    m_manipulators.setCellRenderer(new ManipulatorListCellRenderer());
    m_manipulators.addKeyListener(new KeyAdapter() {

        /**
         * {@inheritDoc}
         */
        @Override
        public void keyTyped(final KeyEvent e) {
            if (e.getKeyChar() == KeyEvent.VK_ENTER) {
                Object selected = m_manipulators.getSelectedValue();
                if (selected != null) {
                    onSelectionInManipulatorList(selected);
                }
            }
        }
    });
    m_manipulators.addMouseListener(new MouseAdapter() {

        /**
         * {@inheritDoc}
         */
        @Override
        public void mouseClicked(final MouseEvent e) {
            if (e.getClickCount() == 2) {
                Object selected = m_manipulators.getSelectedValue();
                if (selected != null) {
                    onSelectionInManipulatorList(selected);
                }
            }
        }
    });
    m_manipulators.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(final ListSelectionEvent e) {
            Object selected = m_manipulators.getSelectedValue();
            if (selected != null) {
                Manipulator manipulator = (Manipulator) selected;
                m_description.setText(manipulator.getDescription());
                m_description.setCaretPosition(0);
            } else {
                m_description.setText("");
            }
        }
    });
    HTMLEditorKit kit = new HTMLEditorKit();
    StyleSheet css = new StyleSheet();
    css.addRule("* { font-family: sans-serif; }");
    kit.setStyleSheet(css);
    m_description = new JTextPane();
    m_description.setEditorKit(kit);
    m_description.setEditable(false);
    m_description.setBackground(getBackground());
    updateManipulatorList(ManipulatorProvider.ALL_CATEGORY);
    initSubComponents();
}
Also used : MouseEvent(java.awt.event.MouseEvent) JComboBox(javax.swing.JComboBox) ActionEvent(java.awt.event.ActionEvent) KeyAdapter(java.awt.event.KeyAdapter) MouseAdapter(java.awt.event.MouseAdapter) ListSelectionEvent(javax.swing.event.ListSelectionEvent) DefaultListModel(javax.swing.DefaultListModel) HTMLEditorKit(javax.swing.text.html.HTMLEditorKit) ListSelectionListener(javax.swing.event.ListSelectionListener) Manipulator(org.knime.base.node.preproc.stringmanipulation.manipulator.Manipulator) KeyEvent(java.awt.event.KeyEvent) FlowVariableListCellRenderer(org.knime.core.node.util.FlowVariableListCellRenderer) JTextPane(javax.swing.JTextPane) StyleSheet(javax.swing.text.html.StyleSheet) ActionListener(java.awt.event.ActionListener) JList(javax.swing.JList)

Example 2 with FlowVariableListCellRenderer

use of org.knime.core.node.util.FlowVariableListCellRenderer in project knime-core by knime.

the class AddOutFieldDialog method initKnimeNameComboBox.

/**
 * Initialize the selection list for the knime name.
 */
private void initKnimeNameComboBox() {
    m_replacedKnimeName.removeAllItems();
    if (m_fieldType.getSelectedItem().equals(FieldType.Column)) {
        for (DataColumnSpec colSpec : m_spec) {
            m_replacedKnimeName.addItem(colSpec);
        }
        m_replacedKnimeName.setRenderer(new DataColumnSpecListCellRenderer());
    } else {
        for (FlowVariable flowVar : m_flowVars.values()) {
            // created.
            if (FieldsTableUtil.verifyNameOfFlowVariable(flowVar.getName())) {
                m_replacedKnimeName.addItem(flowVar);
            }
        }
        m_replacedKnimeName.setRenderer(new FlowVariableListCellRenderer());
    }
    if (m_replacedKnimeName.getItemCount() <= 0) {
        m_replacedKnimeName.setEnabled(false);
        m_knimeName.setEnabled(true);
        m_replace.setEnabled(false);
        m_replace.setSelected(false);
        m_append.setSelected(true);
    } else {
        m_replacedKnimeName.setEnabled(true);
        m_replace.setEnabled(true);
    }
}
Also used : DataColumnSpecListCellRenderer(org.knime.core.node.util.DataColumnSpecListCellRenderer) FlowVariableListCellRenderer(org.knime.core.node.util.FlowVariableListCellRenderer) DataColumnSpec(org.knime.core.data.DataColumnSpec) FlowVariable(org.knime.core.node.workflow.FlowVariable)

Example 3 with FlowVariableListCellRenderer

use of org.knime.core.node.util.FlowVariableListCellRenderer in project knime-core by knime.

the class StringManipulationNodeDialog method createStringManipulationPanel.

/**
 * @return the controls for the string manipulation node
 * @since 3.3
 */
public Component createStringManipulationPanel() {
    m_snippetPanel = new JSnippetPanel(StringManipulatorProvider.getDefault(), createCompletionProvider(), !m_isOnlyVariables);
    m_newNameField = new JTextField(10);
    String radioButtonName;
    String radioButtonToolTip;
    radioButtonName = "Append " + WordUtils.capitalize(m_columnOrVariable) + ": ";
    radioButtonToolTip = "Appends a new " + m_columnOrVariable + " to the input with a given name.";
    m_appendRadio = new JRadioButton(radioButtonName);
    m_appendRadio.setToolTipText(radioButtonToolTip);
    radioButtonName = "Replace " + WordUtils.capitalize(m_columnOrVariable) + ": ";
    if (m_isOnlyVariables) {
        radioButtonToolTip = "Replaces the " + m_columnOrVariable + " if the type stays the same.";
    } else {
        radioButtonToolTip = "Replaces the " + m_columnOrVariable + " and changes the " + m_columnOrVariable + " type accordingly.";
    }
    m_replaceRadio = new JRadioButton(radioButtonName);
    m_replaceRadio.setToolTipText(radioButtonToolTip);
    if (m_isOnlyVariables) {
        // show all variables
        m_replaceVariableCombo = new JComboBox<FlowVariable>(new DefaultComboBoxModel<FlowVariable>());
        m_replaceVariableCombo.setRenderer(new FlowVariableListCellRenderer());
    } else {
        // show all columns
        m_replaceColumnCombo = new ColumnSelectionPanel((Border) null, DataValue.class);
        m_replaceColumnCombo.setRequired(false);
    }
    ButtonGroup buttonGroup = new ButtonGroup();
    buttonGroup.add(m_appendRadio);
    buttonGroup.add(m_replaceRadio);
    ActionListener actionListener = new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            if (m_isOnlyVariables) {
                m_replaceVariableCombo.setEnabled(m_replaceRadio.isSelected());
            } else {
                m_replaceColumnCombo.setEnabled(m_replaceRadio.isSelected());
            }
            m_newNameField.setEnabled(m_appendRadio.isSelected());
        }
    };
    m_appendRadio.addActionListener(actionListener);
    m_replaceRadio.addActionListener(actionListener);
    m_compileOnCloseChecker = new JCheckBox("Syntax check on close");
    m_compileOnCloseChecker.setToolTipText("Checks the syntax of the expression on close.");
    m_insertMissingAsNullChecker = new JCheckBox("Insert Missing As Null");
    m_insertMissingAsNullChecker.setToolTipText("If unselected, missing values in the input will produce a missing cell result");
    return createPanel();
}
Also used : JRadioButton(javax.swing.JRadioButton) DataValue(org.knime.core.data.DataValue) ActionEvent(java.awt.event.ActionEvent) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) JTextField(javax.swing.JTextField) JCheckBox(javax.swing.JCheckBox) FlowVariableListCellRenderer(org.knime.core.node.util.FlowVariableListCellRenderer) ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) ColumnSelectionPanel(org.knime.core.node.util.ColumnSelectionPanel) JSnippetPanel(org.knime.base.node.util.JSnippetPanel) Border(javax.swing.border.Border) FlowVariable(org.knime.core.node.workflow.FlowVariable)

Example 4 with FlowVariableListCellRenderer

use of org.knime.core.node.util.FlowVariableListCellRenderer in project knime-core by knime.

the class ParameterizedDBQueryPanel method createColumnsAndVariablesPanel.

private JComponent createColumnsAndVariablesPanel() {
    /* Create database column list */
    final JPanel dbColumnsPanel = new JPanel(new BorderLayout());
    dbColumnsPanel.setPreferredSize(new Dimension(200, 150));
    final JLabel dbColumnsLabel = new JLabel("Database Column List");
    dbColumnsLabel.setBorder(new EmptyBorder(5, 5, 5, 5));
    dbColumnsPanel.add(dbColumnsLabel, BorderLayout.NORTH);
    dbColumnsPanel.add(new JScrollPane(m_dbColumnsList), BorderLayout.CENTER);
    m_dbColumnsList.setCellRenderer(new DataColumnSpecListCellRenderer());
    m_dbColumnsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    m_dbColumnsList.addKeyListener(new KeyAdapter() {

        /**
         * {@inheritDoc}
         */
        @Override
        public void keyTyped(final KeyEvent evt) {
            if (evt.getKeyChar() == KeyEvent.VK_ENTER) {
                onSelectionInDatabaseList();
            }
        }
    });
    m_dbColumnsList.addMouseListener(new MouseAdapter() {

        /**
         * {@inheritDoc}
         */
        @Override
        public void mouseClicked(final MouseEvent evt) {
            if (evt.getClickCount() == 2) {
                onSelectionInDatabaseList();
            }
        }
    });
    /* Create Knime column list */
    final JPanel knimeColumnsPanel = new JPanel(new BorderLayout());
    knimeColumnsPanel.setPreferredSize(new Dimension(200, 150));
    final JLabel knimeColumnsLabel = new JLabel("Column List");
    knimeColumnsLabel.setBorder(new EmptyBorder(5, 5, 5, 5));
    knimeColumnsPanel.add(knimeColumnsLabel, BorderLayout.NORTH);
    knimeColumnsPanel.add(new JScrollPane(m_knimeColumnsList), BorderLayout.CENTER);
    m_knimeColumnsList.setCellRenderer(new DataColumnSpecListCellRenderer());
    m_knimeColumnsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    m_knimeColumnsList.addKeyListener(new KeyAdapter() {

        /**
         * {@inheritDoc}
         */
        @Override
        public void keyTyped(final KeyEvent evt) {
            if (evt.getKeyChar() == KeyEvent.VK_ENTER) {
                onSelectionInColumnList();
            }
        }
    });
    m_knimeColumnsList.addMouseListener(new MouseAdapter() {

        /**
         * {@inheritDoc}
         */
        @Override
        public void mouseClicked(final MouseEvent evt) {
            if (evt.getClickCount() == 2) {
                onSelectionInColumnList();
            }
        }
    });
    final JSplitPane columnsSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    columnsSplitPane.setResizeWeight(0.5);
    columnsSplitPane.setOneTouchExpandable(true);
    columnsSplitPane.setDividerSize(8);
    columnsSplitPane.setTopComponent(dbColumnsPanel);
    columnsSplitPane.setBottomComponent(knimeColumnsPanel);
    columnsSplitPane.setDividerLocation(150);
    /* Create flow variables list*/
    final JPanel variablesPanel = new JPanel(new BorderLayout());
    variablesPanel.setPreferredSize(new Dimension(200, 150));
    final JLabel variablesLabel = new JLabel("Flow Variable List");
    variablesLabel.setBorder(new EmptyBorder(5, 5, 5, 5));
    variablesPanel.add(variablesLabel, BorderLayout.NORTH);
    variablesPanel.add(new JScrollPane(m_flowVariablesList), BorderLayout.CENTER);
    m_flowVariablesList.setCellRenderer(new FlowVariableListCellRenderer());
    m_flowVariablesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    m_flowVariablesList.addKeyListener(new KeyAdapter() {

        /**
         * {@inheritDoc}
         */
        @Override
        public void keyTyped(final KeyEvent evt) {
            if (evt.getKeyChar() == KeyEvent.VK_ENTER) {
                onSelectionInFlowVariableList();
            }
        }
    });
    m_flowVariablesList.addMouseListener(new MouseAdapter() {

        /**
         * {@inheritDoc}
         */
        @Override
        public void mouseClicked(final MouseEvent evt) {
            if (evt.getClickCount() == 2) {
                onSelectionInFlowVariableList();
            }
        }
    });
    final JSplitPane columnsVariableSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    columnsVariableSplitPane.setResizeWeight(0.5);
    columnsVariableSplitPane.setOneTouchExpandable(true);
    columnsVariableSplitPane.setDividerSize(8);
    columnsVariableSplitPane.setTopComponent(columnsSplitPane);
    columnsVariableSplitPane.setBottomComponent(variablesPanel);
    columnsVariableSplitPane.setDividerLocation(300);
    return columnsVariableSplitPane;
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) DataColumnSpecListCellRenderer(org.knime.core.node.util.DataColumnSpecListCellRenderer) MouseEvent(java.awt.event.MouseEvent) KeyAdapter(java.awt.event.KeyAdapter) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) KeyEvent(java.awt.event.KeyEvent) FlowVariableListCellRenderer(org.knime.core.node.util.FlowVariableListCellRenderer) BorderLayout(java.awt.BorderLayout) EmptyBorder(javax.swing.border.EmptyBorder) JSplitPane(javax.swing.JSplitPane)

Example 5 with FlowVariableListCellRenderer

use of org.knime.core.node.util.FlowVariableListCellRenderer in project knime-core by knime.

the class AddOutFieldDialog method initKnimeNameComboBox.

/**
 * Initialize the selection list for the knime name.
 */
private void initKnimeNameComboBox() {
    m_replacedKnimeName.removeAllItems();
    if (m_fieldType.getSelectedItem().equals(FieldType.Column)) {
        for (DataColumnSpec colSpec : m_spec) {
            m_replacedKnimeName.addItem(colSpec);
        }
        m_replacedKnimeName.setRenderer(new DataColumnSpecListCellRenderer());
    } else {
        for (FlowVariable flowVar : m_flowVars.values()) {
            // created.
            if (OutFieldsTableModel.verifyNameOfFlowVariable(flowVar.getName())) {
                m_replacedKnimeName.addItem(flowVar);
            }
        }
        m_replacedKnimeName.setRenderer(new FlowVariableListCellRenderer());
    }
    if (m_replacedKnimeName.getItemCount() <= 0) {
        m_replacedKnimeName.setEnabled(false);
        m_knimeName.setEnabled(true);
        m_replace.setEnabled(false);
        m_replace.setSelected(false);
        m_append.setSelected(true);
    } else {
        m_replacedKnimeName.setEnabled(true);
        m_replace.setEnabled(true);
    }
}
Also used : DataColumnSpecListCellRenderer(org.knime.core.node.util.DataColumnSpecListCellRenderer) FlowVariableListCellRenderer(org.knime.core.node.util.FlowVariableListCellRenderer) DataColumnSpec(org.knime.core.data.DataColumnSpec) FlowVariable(org.knime.core.node.workflow.FlowVariable)

Aggregations

FlowVariableListCellRenderer (org.knime.core.node.util.FlowVariableListCellRenderer)6 DataColumnSpecListCellRenderer (org.knime.core.node.util.DataColumnSpecListCellRenderer)3 FlowVariable (org.knime.core.node.workflow.FlowVariable)3 Dimension (java.awt.Dimension)2 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 KeyAdapter (java.awt.event.KeyAdapter)2 KeyEvent (java.awt.event.KeyEvent)2 MouseAdapter (java.awt.event.MouseAdapter)2 MouseEvent (java.awt.event.MouseEvent)2 JCheckBox (javax.swing.JCheckBox)2 JComboBox (javax.swing.JComboBox)2 JLabel (javax.swing.JLabel)2 JPanel (javax.swing.JPanel)2 DataColumnSpec (org.knime.core.data.DataColumnSpec)2 BorderLayout (java.awt.BorderLayout)1 FocusAdapter (java.awt.event.FocusAdapter)1 FocusEvent (java.awt.event.FocusEvent)1 Box (javax.swing.Box)1 BoxLayout (javax.swing.BoxLayout)1