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;
}
Aggregations