Search in sources :

Example 1 with HadoopCustomVersionDefineDialog

use of org.talend.core.hadoop.version.custom.HadoopCustomVersionDefineDialog in project tdi-studio-se by Talend.

the class HadoopJarSetupController method createControl.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.designer.core.ui.editor.properties.controllers.AbstractElementPropertySectionController#createControl
     * (org.eclipse.swt.widgets.Composite, org.talend.core.model.process.IElementParameter, int, int, int,
     * org.eclipse.swt.widgets.Control)
     */
@Override
public Control createControl(Composite subComposite, final IElementParameter param, int numInRow, int nbInRow, int top, Control lastControl) {
    final Composite container = subComposite;
    //$NON-NLS-1$
    Button subButton = getWidgetFactory().createButton(container, "", SWT.PUSH);
    subButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            initHadoopVersionType();
            boolean readonly = false;
            String readOnlyIfString = param.getReadOnlyIf();
            if (StringUtils.isNotEmpty(readOnlyIfString)) {
                if (param.isReadOnly(elem.getElementParameters())) {
                    readonly = true;
                }
            }
            // if readonly is true, then needn't to do this check, since it's aim is check readonly also
            if (readonly == false) {
                IElementParameter propertyParameter = elem.getElementParameter(EParameterName.PROPERTY_TYPE.getName());
                if (propertyParameter != null) {
                    if (EmfComponent.REPOSITORY.equals(propertyParameter.getValue())) {
                        readonly = true;
                    }
                }
            }
            HadoopCustomVersionDefineDialog customVersionDialog = new HadoopCustomVersionDefineDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), getCustomVersionMap()) {

                @Override
                protected ECustomVersionType[] getDisplayTypes() {
                    return new ECustomVersionType[] { versionType };
                }
            };
            IElementParameter sparkLocalParam = elem.getElementParameter(HadoopConstants.SPARK_LOCAL_MODE);
            IElementParameter sparkParam = elem.getElementParameter(HadoopConstants.SPARK_MODE);
            boolean isSparkLocalMode = false;
            if (sparkLocalParam != null) {
                isSparkLocalMode = (Boolean) sparkLocalParam.getValue();
            }
            if (sparkParam != null) {
                String sparkMode = null;
                if (isSparkLocalMode) {
                    //$NON-NLS-1$
                    sparkMode = "LOCAL";
                } else {
                    //$NON-NLS-1$
                    sparkMode = "" + sparkParam.getValue();
                }
                customVersionDialog.setSparkMode(sparkMode);
                customVersionDialog.setSparkStreamingMode(sparkMode);
            }
            customVersionDialog.setReadonly(readonly);
            Set<String> oldLibList = customVersionDialog.getLibList(versionType.getGroup());
            if (customVersionDialog.open() == Window.OK) {
                Set<String> newLibList = customVersionDialog.getLibList(versionType.getGroup());
                if (oldLibList != null && newLibList != null && oldLibList.size() == newLibList.size() && oldLibList.containsAll(newLibList)) {
                // means nothing changes, so nothing need to do
                } else {
                    // changed
                    String customJars = customVersionDialog.getLibListStr(versionType.getGroup());
                    executeCommand(new PropertyChangeCommand(elem, EParameterName.HADOOP_CUSTOM_JARS.getName(), StringUtils.trimToEmpty(customJars)));
                }
            }
        }
    });
    subButton.setImage(ImageProvider.getImage(CoreUIPlugin.getImageDescriptor(DOTS_BUTTON)));
    FormData data = new FormData();
    data.left = new FormAttachment(lastControl, 0);
    data.right = new FormAttachment(lastControl, STANDARD_BUTTON_WIDTH, SWT.RIGHT);
    data.top = new FormAttachment(0, top);
    data.height = STANDARD_HEIGHT - 2;
    subButton.setLayoutData(data);
    return container;
}
Also used : FormData(org.eclipse.swt.layout.FormData) HashSet(java.util.HashSet) Set(java.util.Set) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) HadoopCustomVersionDefineDialog(org.talend.core.hadoop.version.custom.HadoopCustomVersionDefineDialog) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IElementParameter(org.talend.core.model.process.IElementParameter) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Aggregations

HashSet (java.util.HashSet)1 Set (java.util.Set)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 FormAttachment (org.eclipse.swt.layout.FormAttachment)1 FormData (org.eclipse.swt.layout.FormData)1 Button (org.eclipse.swt.widgets.Button)1 Composite (org.eclipse.swt.widgets.Composite)1 HadoopCustomVersionDefineDialog (org.talend.core.hadoop.version.custom.HadoopCustomVersionDefineDialog)1 IElementParameter (org.talend.core.model.process.IElementParameter)1 PropertyChangeCommand (org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand)1