Search in sources :

Example 1 with ISampleCodeFactory

use of org.talend.designer.core.utils.ISampleCodeFactory in project tdi-studio-se by Talend.

the class AbstractLanguageMemoController method addCodeGenerateButton.

/**
     * 
     * DOC YeXiaowei Comment method "addCodeGenerateButton".
     * 
     * @param parent
     */
private void addCodeGenerateButton(final Composite parent) {
    codeGenereateButton = new Button(parent, SWT.CENTER);
    //$NON-NLS-1$
    codeGenereateButton.setText(Messages.getString("AbstractLanguageMemoController.generateCode"));
    //$NON-NLS-1$
    codeGenereateButton.setToolTipText(Messages.getString("AbstractLanguageMemoController.generateSampleCode"));
    codeGenereateButton.setEnabled(!elem.isReadOnly());
    GridData layoutData = new GridData();
    layoutData.horizontalAlignment = SWT.CENTER;
    codeGenereateButton.setLayoutData(layoutData);
    codeGenereateButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (elem instanceof Node) {
                // generate code
                ISampleCodeFactory factory = JavaSampleCodeFactory.getInstance();
                executeCommand(factory.generateCodeForParameters((Node) elem));
                refresh(curParameter, false);
            }
        }
    });
}
Also used : ISampleCodeFactory(org.talend.designer.core.utils.ISampleCodeFactory) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Node(org.talend.designer.core.ui.editor.nodes.Node) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Aggregations

SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 GridData (org.eclipse.swt.layout.GridData)1 Button (org.eclipse.swt.widgets.Button)1 Node (org.talend.designer.core.ui.editor.nodes.Node)1 ISampleCodeFactory (org.talend.designer.core.utils.ISampleCodeFactory)1