Search in sources :

Example 6 with ContextParameterType

use of org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType in project tdi-studio-se by Talend.

the class JobScriptsExportWizardPage method createOptions.

/**
     * Create the buttons for the group that determine if the entire or selected directory structure should be created.
     * 
     * @param optionsGroup
     * @param font
     */
/**
     * DOC Administrator Comment method "createOptions".
     * 
     * @param optionsGroup
     * @param font
     */
public void createOptions(final Composite optionsGroup, Font font) {
    Composite parentComposite = new Composite(optionsGroup, SWT.NONE);
    parentComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    GridLayout layout = new GridLayout(3, false);
    layout.marginHeight = 0;
    layout.verticalSpacing = 3;
    parentComposite.setLayout(layout);
    optionTypeCombo = new Combo(parentComposite, SWT.PUSH);
    GridData optionTypeGD = new GridData();
    optionTypeGD.horizontalSpan = 3;
    optionTypeCombo.setLayoutData(optionTypeGD);
    optionTypeCombo.setItems(OPTION_TYPES);
    optionTypeCombo.select(0);
    optionTypeCombo.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            updateOptionStates();
        }
    });
    shellLauncherButton = new Button(parentComposite, SWT.CHECK | SWT.LEFT);
    //$NON-NLS-1$
    shellLauncherButton.setText(Messages.getString("JobScriptsExportWizardPage.shellLauncher"));
    shellLauncherButton.setSelection(true);
    shellLauncherButton.setFont(font);
    launcherCombo = new Combo(parentComposite, SWT.PUSH);
    GridData launcherGD = new GridData();
    launcherGD.horizontalSpan = 2;
    launcherCombo.setLayoutData(launcherGD);
    contextButton = new Button(parentComposite, SWT.CHECK | SWT.LEFT);
    //$NON-NLS-1$
    contextButton.setText(Messages.getString("JobScriptsExportWizardPage.contextPerlScripts"));
    contextButton.setSelection(true);
    contextButton.setFont(font);
    contextButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            boolean selectContext = contextButton.getSelection();
            contextCombo.setEnabled(selectContext);
            applyToChildrenButton.setEnabled(selectContext);
        }
    });
    contextCombo = new Combo(parentComposite, SWT.PUSH);
    contextCombo.setLayoutData(new GridData());
    Composite contextConfigComp = new Composite(parentComposite, SWT.NONE);
    GridData contextConfigGridData = new GridData(GridData.FILL_HORIZONTAL);
    contextConfigGridData.verticalSpan = 2;
    contextConfigComp.setLayoutData(contextConfigGridData);
    GridLayout contextConfigLayout = new GridLayout(2, false);
    contextConfigComp.setLayout(contextConfigLayout);
    applyToChildrenButton = new Button(contextConfigComp, SWT.CHECK | SWT.LEFT);
    //$NON-NLS-1$
    applyToChildrenButton.setText(Messages.getString("JobScriptsExportWizardPage.ApplyContextToChildren"));
    GridData applyToChildrenGD = new GridData();
    applyToChildrenGD.horizontalSpan = 2;
    applyToChildrenButton.setLayoutData(applyToChildrenGD);
    setParametersValueButton = new Button(contextConfigComp, SWT.NONE);
    //$NON-NLS-1$
    setParametersValueButton.setText(Messages.getString("JobScriptsExportWizardPage.OverrideParameterValues"));
    setParametersValueButton.setSelection(false);
    setParametersValueButton2 = new Button(contextConfigComp, SWT.CHECK);
    setParametersValueButton2.setVisible(false);
    setParametersValueButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (manager == null) {
                manager = createJobScriptsManager();
            }
            List<ContextParameterType> contextEditableResultValuesList = manager.getContextEditableResultValuesList();
            List<ContextParameterType> contextValueList = new ArrayList<ContextParameterType>();
            if (contextEditableResultValuesList == null) {
                contextValueList = ExportJobUtil.getJobContextValues(getProcessItem(), contextCombo.getText());
            }
            ParametersValuesDialog dialog = new ParametersValuesDialog(getShell(), contextValueList, contextEditableResultValuesList);
            int open = dialog.open();
            if (open == Dialog.OK) {
                List<ContextParameterType> contextResultValuesList = dialog.getContextResultValuesList();
                manager.setContextEditableResultValuesList(contextResultValuesList);
                setParametersValueButton2.setSelection(true);
            } else {
                setParametersValueButton2.setSelection(false);
            }
        }
    });
    new Label(parentComposite, SWT.NONE);
    new Label(parentComposite, SWT.NONE);
    if (isEnterprise) {
        log4jButton = new Button(parentComposite, SWT.CHECK | SWT.LEFT);
        //$NON-NLS-1$
        log4jButton.setText(Messages.getString("JavaJobScriptsExportWSWizardPage.LOG4jLEVEL"));
        log4jButton.setFont(font);
        log4jButton.setEnabled(Log4jPrefsSettingManager.getInstance().isLog4jEnable());
        log4jButton.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                if (log4jButton.getSelection()) {
                    log4jLevelCombo.setEnabled(true);
                } else {
                    log4jLevelCombo.setEnabled(false);
                }
            }
        });
        log4jLevelCombo = new Combo(parentComposite, SWT.PUSH);
        GridData log4jLevelGD = new GridData();
        log4jLevelGD.horizontalSpan = 2;
        log4jLevelCombo.setLayoutData(log4jLevelGD);
        log4jLevelCombo.setEnabled(false);
    }
    jobItemButton = new Button(parentComposite, SWT.CHECK | SWT.LEFT);
    //$NON-NLS-1$
    jobItemButton.setText(Messages.getString("JobScriptsExportWizardPage.jobItems"));
    jobItemButton.setFont(font);
    GridData jobItemGD = new GridData();
    jobItemGD.horizontalSpan = 3;
    jobItemButton.setLayoutData(jobItemGD);
    executeTestsButton = new Button(parentComposite, SWT.CHECK | SWT.LEFT);
    //$NON-NLS-1$
    executeTestsButton.setText(Messages.getString("JobScriptsExportWizardPage.executeTests"));
    executeTestsButton.setFont(font);
    GridData executeTestsGD = new GridData();
    executeTestsGD.horizontalSpan = 3;
    executeTestsButton.setLayoutData(executeTestsGD);
    addTestSourcesButton = new Button(parentComposite, SWT.CHECK | SWT.LEFT);
    //$NON-NLS-1$
    addTestSourcesButton.setText(Messages.getString("JobScriptsExportWizardPage.addTestSources"));
    addTestSourcesButton.setFont(font);
    GridData addTestSourcesGD = new GridData();
    addTestSourcesGD.horizontalSpan = 3;
    addTestSourcesButton.setLayoutData(addTestSourcesGD);
    addTestSourcesButton.setSelection(true);
    includeLibsButton = new Button(parentComposite, SWT.CHECK | SWT.LEFT);
    //$NON-NLS-1$
    includeLibsButton.setText(Messages.getString("JobScriptsExportWizardPage.includeLibs"));
    includeLibsButton.setFont(font);
    GridData includeLibsGD = new GridData();
    includeLibsGD.horizontalSpan = 3;
    includeLibsButton.setLayoutData(includeLibsGD);
    jobScriptButton = new Button(parentComposite, SWT.CHECK | SWT.LEFT);
    //$NON-NLS-1$
    jobScriptButton.setText(Messages.getString("JobScriptsExportWizardPage.jobJavaSources"));
    jobScriptButton.setFont(font);
    GridData jobScriptGD = new GridData();
    jobScriptGD.horizontalSpan = 3;
    jobScriptButton.setLayoutData(jobScriptGD);
    updateOptionStates();
}
Also used : Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) List(java.util.List) ArrayList(java.util.ArrayList) ContextParameterType(org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType)

Example 7 with ContextParameterType

use of org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType in project tdi-studio-se by Talend.

the class AddContextCommentValueMigrationTaskTest method testAddContextCommentValue.

@Test
public void testAddContextCommentValue() {
    testItem.setDefaultContext("Default");
    String[] paramNames = new String[] { "p1", "p2", "p3" };
    String[] comments = new String[] { "c1", "c2", "c3" };
    // context item before 5.6.1
    // comments always in the first group of context no matter it's default group or not.
    testItem.getContext().add(createContextType("DEV", paramNames, comments));
    testItem.getContext().add(createContextType("PROD", paramNames, null));
    testItem.getContext().add(createContextType("Default", paramNames, null));
    AddContextCommentValueMigrationTask task = new AddContextCommentValueMigrationTask();
    task.execute(testItem);
    List<ContextType> contexts = testItem.getContext();
    for (ContextType context : contexts) {
        List<ContextParameterType> params = context.getContextParameter();
        for (ContextParameterType param : params) {
            if (param.getName().equals("p1")) {
                assertEquals("c1", param.getComment());
            } else if (param.getName().equals("p2")) {
                assertEquals("c2", param.getComment());
            } else if (param.getName().equals("p3")) {
                assertEquals("c3", param.getComment());
            }
        }
    }
}
Also used : ContextType(org.talend.designer.core.model.utils.emf.talendfile.ContextType) ContextParameterType(org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType) Test(org.junit.Test)

Example 8 with ContextParameterType

use of org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType in project tdi-studio-se by Talend.

the class AddContextCommentValueMigrationTaskTest method createContextType.

private ContextType createContextType(String contextName, String[] paramNames, String[] comments) {
    ContextType context = TalendFileFactory.eINSTANCE.createContextType();
    context.setName(contextName);
    for (int i = 0; i < paramNames.length; i++) {
        ContextParameterType param = TalendFileFactory.eINSTANCE.createContextParameterType();
        param.setName(paramNames[i]);
        param.setType("id_String");
        if (comments != null) {
            param.setComment(comments[i]);
        } else {
            param.setComment("");
        }
        context.getContextParameter().add(param);
    }
    return context;
}
Also used : ContextType(org.talend.designer.core.model.utils.emf.talendfile.ContextType) ContextParameterType(org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType)

Example 9 with ContextParameterType

use of org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType in project tdi-studio-se by Talend.

the class FixUnevenItemContextParametersMigrationTaskTest method testChangeType.

@Test
public void testChangeType() {
    testItem.getProcess().setDefaultContext("Default");
    String[] paramNames = new String[] { "new1", "new2", "new3" };
    // default
    ContextType defaultGroup = createContextType("Default", paramNames);
    testItem.getProcess().getContext().add(defaultGroup);
    ((ContextParameterType) defaultGroup.getContextParameter().get(0)).setType("id_Date");
    // group1
    ContextType group1 = createContextType("group1", paramNames);
    testItem.getProcess().getContext().add(group1);
    FixUnevenItemContextParametersMigrationTask migration = new FixUnevenItemContextParametersMigrationTask();
    migration.execute(testItem);
    Assert.assertEquals(((ContextParameterType) group1.getContextParameter().get(0)).getType(), "id_Date");
}
Also used : ContextType(org.talend.designer.core.model.utils.emf.talendfile.ContextType) ContextParameterType(org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType) Test(org.junit.Test)

Example 10 with ContextParameterType

use of org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType in project tdi-studio-se by Talend.

the class JobScriptsManager method getSettingContextParametersValue.

private String getSettingContextParametersValue() {
    //$NON-NLS-1$
    String contextParameterValues = "";
    List<ContextParameterType> jobContextValues = getContextEditableResultValuesList();
    for (int i = 0; i < jobContextValues.size(); i++) {
        ContextParameterType contextParameterType = jobContextValues.get(i);
        String name = contextParameterType.getName();
        String value = contextParameterType.getRawValue();
        // value = TalendTextUtils.removeQuotes(value);
        if (value == null) {
            //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ 
            contextParameterValues += " " + TalendProcessArgumentConstant.CMD_ARG_CONTEXT_PARAMETER + " " + name + "=" + null;
        } else if (value != null && !"".equals(value)) {
            //$NON-NLS-1$
            if (value.contains(" ") && !value.startsWith("\"")) {
                //$NON-NLS-1$ //$NON-NLS-2$
                // Changed by Marvin Wang on Nov.13, 2012 for bug TDI-23253 to add double quotation marks for value.
                contextParameterValues += //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ 
                " " + TalendProcessArgumentConstant.CMD_ARG_CONTEXT_PARAMETER + " " + name + "=" + TalendQuoteUtils.addQuotes(value);
            } else {
                contextParameterValues += //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ 
                " " + TalendProcessArgumentConstant.CMD_ARG_CONTEXT_PARAMETER + " " + name + "=" + value;
            }
        }
    }
    //$NON-NLS-1$
    contextParameterValues = contextParameterValues + " ";
    return contextParameterValues;
}
Also used : ContextParameterType(org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType)

Aggregations

ContextParameterType (org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType)25 ContextType (org.talend.designer.core.model.utils.emf.talendfile.ContextType)19 ContextItem (org.talend.core.model.properties.ContextItem)8 PersistenceException (org.talend.commons.exception.PersistenceException)7 ArrayList (java.util.ArrayList)6 ProcessItem (org.talend.core.model.properties.ProcessItem)5 HashMap (java.util.HashMap)4 EList (org.eclipse.emf.common.util.EList)4 List (java.util.List)3 JobletProcessItem (org.talend.core.model.properties.JobletProcessItem)3 File (java.io.File)2 Test (org.junit.Test)2 IContext (org.talend.core.model.process.IContext)2 IContextParameter (org.talend.core.model.process.IContextParameter)2 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Map (java.util.Map)1 Properties (java.util.Properties)1 Element (org.dom4j.Element)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1