Search in sources :

Example 1 with ExpressionTestMain

use of org.talend.expressionbuilder.test.shadow.ExpressionTestMain in project tdi-studio-se by Talend.

the class TestComposite method installListener.

private void installListener() {
    buttonAddVar.addMouseListener(new MouseAdapter() {

        /*
             * (non-Javadoc)
             * 
             * @see org.eclipse.swt.events.MouseAdapter#mouseUp(org.eclipse.swt.events.MouseEvent)
             */
        @Override
        public void mouseUp(MouseEvent e) {
            List<Variable> input = (List<Variable>) variableTableViewer.getInput();
            input.add(new Variable(input.size()));
            variableTableViewer.refresh();
        }
    });
    buttonRemoveVar.addMouseListener(new MouseAdapter() {

        /*
             * (non-Javadoc)
             * 
             * @see org.eclipse.swt.events.MouseAdapter#mouseUp(org.eclipse.swt.events.MouseEvent)
             */
        @Override
        public void mouseUp(MouseEvent e) {
            ISelection selection = variableTableViewer.getSelection();
            List<Variable> list = ((List<Variable>) variableTableViewer.getInput());
            if (!selection.isEmpty() && selection instanceof StructuredSelection) {
                Object[] vars = ((StructuredSelection) selection).toArray();
                for (Object var : vars) {
                    list.remove(var);
                    variableTableViewer.refresh();
                }
            } else if (!list.isEmpty()) {
                list.remove(list.size() - 1);
                variableTableViewer.refresh();
            }
        }
    });
    testButton.addMouseListener(new MouseAdapter() {

        /*
             * (non-Javadoc)
             * 
             * @see org.eclipse.swt.events.MouseAdapter#mouseUp(org.eclipse.swt.events.MouseEvent)
             */
        @Override
        public void mouseUp(MouseEvent e) {
            new ExpressionTestMain(CategoryComposite.getSelectedFunction(), testResultText);
        }
    });
    clearButton.addMouseListener(new MouseAdapter() {

        /*
             * (non-Javadoc)
             * 
             * @see org.eclipse.swt.events.MouseAdapter#mouseUp(org.eclipse.swt.events.MouseEvent)
             */
        @Override
        public void mouseUp(MouseEvent e) {
            //$NON-NLS-1$
            testResultText.setText("");
        }
    });
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) Variable(org.talend.commons.runtime.model.expressionbuilder.Variable) MouseAdapter(org.eclipse.swt.events.MouseAdapter) ISelection(org.eclipse.jface.viewers.ISelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ExpressionTestMain(org.talend.expressionbuilder.test.shadow.ExpressionTestMain) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List)

Aggregations

ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 ISelection (org.eclipse.jface.viewers.ISelection)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 MouseAdapter (org.eclipse.swt.events.MouseAdapter)1 MouseEvent (org.eclipse.swt.events.MouseEvent)1 Variable (org.talend.commons.runtime.model.expressionbuilder.Variable)1 ExpressionTestMain (org.talend.expressionbuilder.test.shadow.ExpressionTestMain)1