Search in sources :

Example 1 with InfixManipulator

use of org.knime.base.node.rules.engine.manipulator.InfixManipulator in project knime-core by knime.

the class RuleMainPanel method onSelectionInManipulatorList.

/**
 * {@inheritDoc}
 */
@Override
protected void onSelectionInManipulatorList(final Object selected) {
    if (selected instanceof InfixManipulator) {
        InfixManipulator infix = (InfixManipulator) selected;
        String textToInsert = infix.getName() + " ";
        try {
            if (m_textEditor.getCaretPosition() == 0 || m_textEditor.getText().isEmpty() || m_textEditor.getText(m_textEditor.getCaretPosition(), 1).charAt(0) != ' ') {
                textToInsert = " " + textToInsert;
            }
        } catch (BadLocationException e) {
            LOGGER.coding("Not fatal error, but should not happen, requires no action.", e);
        }
        m_textEditor.insert(textToInsert, m_textEditor.getCaretPosition());
        m_textEditor.requestFocus();
    } else if (selected instanceof PrefixUnaryManipulator || selected instanceof ConstantManipulator) {
        Manipulator prefix = (Manipulator) selected;
        m_textEditor.replaceSelection(prefix.getName() + " ");
        m_textEditor.requestFocus();
    } else {
        super.onSelectionInManipulatorList(selected);
    }
}
Also used : ConstantManipulator(org.knime.base.node.rules.engine.manipulator.ConstantManipulator) PrefixUnaryManipulator(org.knime.base.node.rules.engine.manipulator.PrefixUnaryManipulator) InfixManipulator(org.knime.base.node.rules.engine.manipulator.InfixManipulator) BadLocationException(javax.swing.text.BadLocationException) InfixManipulator(org.knime.base.node.rules.engine.manipulator.InfixManipulator) ConstantManipulator(org.knime.base.node.rules.engine.manipulator.ConstantManipulator) PrefixUnaryManipulator(org.knime.base.node.rules.engine.manipulator.PrefixUnaryManipulator) Manipulator(org.knime.base.node.preproc.stringmanipulation.manipulator.Manipulator)

Aggregations

BadLocationException (javax.swing.text.BadLocationException)1 Manipulator (org.knime.base.node.preproc.stringmanipulation.manipulator.Manipulator)1 ConstantManipulator (org.knime.base.node.rules.engine.manipulator.ConstantManipulator)1 InfixManipulator (org.knime.base.node.rules.engine.manipulator.InfixManipulator)1 PrefixUnaryManipulator (org.knime.base.node.rules.engine.manipulator.PrefixUnaryManipulator)1