use of org.eclipse.swt.layout.FormData in project tdi-studio-se by Talend.
the class JavaCommandController 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) {
Button btnEdit;
//$NON-NLS-1$
btnEdit = getWidgetFactory().createButton(subComposite, "", SWT.PUSH);
btnEdit.setImage(ImageProvider.getImage(CoreUIPlugin.getImageDescriptor(DOTS_BUTTON)));
FormData data;
btnEdit.setData(NAME, JAVA_COMMAND);
btnEdit.setData(PARAMETER_NAME, param.getName());
btnEdit.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
@Override
public void widgetSelected(SelectionEvent e) {
// execute Java Command
ElementParameter fullParam = (ElementParameter) param;
File jar;
URL url;
try {
List<URL> listURL = new ArrayList<URL>();
ILibraryManagerService libManager = (ILibraryManagerService) GlobalServiceRegister.getDefault().getService(ILibraryManagerService.class);
IFolder javaLibFolder = null;
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
IRunProcessService processService = (IRunProcessService) GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
ITalendProcessJavaProject talendProcessJavaProject = processService.getTalendProcessJavaProject();
if (talendProcessJavaProject != null) {
javaLibFolder = talendProcessJavaProject.getLibFolder();
}
}
if (javaLibFolder == null) {
return;
}
for (String jarString : fullParam.getJar().split(";")) {
IPath libPath = javaLibFolder.getLocation();
libManager.retrieve(jarString, libPath.toPortableString(), new NullProgressMonitor());
jar = libPath.append(jarString).toFile();
url = jar.toURL();
listURL.add(url);
}
URLClassLoader urlClassLoader = new URLClassLoader(listURL.toArray(new URL[0]));
Class<?> classLoaded = Class.forName(fullParam.getJavaClass(), true, urlClassLoader);
Object object = classLoaded.newInstance();
List<String> args = new ArrayList<String>();
for (String arg : fullParam.getArgs()) {
args.add(ElementParameterParser.parse(elem, arg));
}
for (Method method : classLoaded.getDeclaredMethods()) {
if (method.getName().equals(fullParam.getJavaFunction())) {
Object[] arglist = new Object[1];
arglist[0] = args.toArray(new String[0]);
method.invoke(object, arglist);
}
}
} catch (Exception e1) {
MessageBoxExceptionHandler.process(e1);
}
}
});
if (elem instanceof Node) {
btnEdit.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
}
CLabel labelLabel = getWidgetFactory().createCLabel(subComposite, param.getDisplayName());
data = new FormData();
if (lastControl != null) {
data.left = new FormAttachment(lastControl, 0);
} else {
data.left = new FormAttachment((((numInRow - 1) * MAX_PERCENT) / nbInRow), 0);
}
data.top = new FormAttachment(0, top);
labelLabel.setLayoutData(data);
if (numInRow != 1) {
labelLabel.setAlignment(SWT.RIGHT);
}
// **************************
data = new FormData();
int currentLabelWidth = STANDARD_LABEL_WIDTH;
GC gc = new GC(labelLabel);
Point labelSize = gc.stringExtent(param.getDisplayName());
gc.dispose();
if ((labelSize.x + ITabbedPropertyConstants.HSPACE) > currentLabelWidth) {
currentLabelWidth = labelSize.x + ITabbedPropertyConstants.HSPACE;
}
if (numInRow == 1) {
if (lastControl != null) {
data.left = new FormAttachment(lastControl, currentLabelWidth);
data.right = new FormAttachment(lastControl, currentLabelWidth + STANDARD_BUTTON_WIDTH);
} else {
data.left = new FormAttachment(0, currentLabelWidth);
data.right = new FormAttachment(0, currentLabelWidth + STANDARD_BUTTON_WIDTH);
}
} else {
data.left = new FormAttachment(labelLabel, 0, SWT.RIGHT);
data.right = new FormAttachment(labelLabel, STANDARD_BUTTON_WIDTH, SWT.RIGHT);
}
data.top = new FormAttachment(0, top);
btnEdit.setLayoutData(data);
// **************************
hashCurControls.put(param.getName(), btnEdit);
Point initialSize = btnEdit.computeSize(SWT.DEFAULT, SWT.DEFAULT);
dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
return btnEdit;
}
use of org.eclipse.swt.layout.FormData in project tdi-studio-se by Talend.
the class MappingTypeController method createControl.
/*
* (non-Javadoc)
*
* @see org.talend.designer.core.ui.editor.properties2.editors.AbstractElementPropertySectionController#createControl()
*/
@Override
public Control createControl(final Composite subComposite, final IElementParameter param, final int numInRow, final int nbInRow, final int top, final Control lastControl) {
DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER, cbCtrl);
if (param.isRequired()) {
FieldDecoration decoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED);
dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.TOP, false);
}
if (param.isRepositoryValueUsed()) {
FieldDecoration decoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
//$NON-NLS-1$
decoration.setDescription(Messages.getString("ComboController.valueFromRepository"));
dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.BOTTOM, false);
}
Control cLayout = dField.getLayoutControl();
CCombo combo = (CCombo) dField.getControl();
FormData data;
// initialize the data with the mappings list
updateMappingList(param);
String[] originalList = param.getListItemsDisplayName();
combo.setItems(originalList);
combo.setEditable(false);
cLayout.setBackground(subComposite.getBackground());
combo.setEnabled(!param.isReadOnly());
combo.addSelectionListener(listenerSelection);
combo.setData(PARAMETER_NAME, param.getName());
if (elem instanceof Node) {
combo.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
}
CLabel labelLabel = getWidgetFactory().createCLabel(subComposite, param.getDisplayName());
data = new FormData();
if (lastControl != null) {
data.left = new FormAttachment(lastControl, 0);
} else {
data.left = new FormAttachment((((numInRow - 1) * MAX_PERCENT) / nbInRow), 0);
}
data.top = new FormAttachment(0, top);
labelLabel.setLayoutData(data);
if (numInRow != 1) {
labelLabel.setAlignment(SWT.RIGHT);
}
// *********************
data = new FormData();
int currentLabelWidth = STANDARD_LABEL_WIDTH;
GC gc = new GC(labelLabel);
Point labelSize = gc.stringExtent(param.getDisplayName());
gc.dispose();
if ((labelSize.x + ITabbedPropertyConstants.HSPACE) > currentLabelWidth) {
currentLabelWidth = labelSize.x + ITabbedPropertyConstants.HSPACE;
}
if (numInRow == 1) {
if (lastControl != null) {
data.left = new FormAttachment(lastControl, currentLabelWidth);
} else {
data.left = new FormAttachment(0, currentLabelWidth);
}
} else {
data.left = new FormAttachment(labelLabel, 0, SWT.RIGHT);
}
data.top = new FormAttachment(0, top);
cLayout.setLayoutData(data);
// **********************
hashCurControls.put(param.getName(), combo);
Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
return cLayout;
}
use of org.eclipse.swt.layout.FormData in project tdi-studio-se by Talend.
the class ProcessController method addJobVersionCombo.
/**
* ftang Comment method "addContextCombo".
*
* @param subComposite
* @param param
* @param lastControl
* @param numInRow
* @param nbInRow
* @param top
* @return
*/
private Control addJobVersionCombo(Composite subComposite, IElementParameter param, Control lastControl, int numInRow, int nbInRow, int top) {
DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER, cbCtrl);
if (param.isRequired()) {
FieldDecoration decoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED);
dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.TOP, false);
}
if (param.isRepositoryValueUsed()) {
FieldDecoration decoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
//$NON-NLS-1$
decoration.setDescription(Messages.getString("ComboController.valueFromRepository"));
dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.BOTTOM, false);
}
Control cLayout = dField.getLayoutControl();
CCombo combo = (CCombo) dField.getControl();
FormData data;
combo.setItems(getListToDisplay(param));
combo.setEditable(false);
cLayout.setBackground(subComposite.getBackground());
combo.setEnabled(!param.isReadOnly());
combo.addSelectionListener(listenerSelection);
combo.setData(PARAMETER_NAME, param.getName());
if (elem instanceof Node) {
combo.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
// feature 19312
if (isSelectUseDynamic) {
combo.setEnabled(false);
}
}
CLabel labelLabel = getWidgetFactory().createCLabel(subComposite, param.getDisplayName());
data = new FormData();
if (lastControl != null) {
data.left = new FormAttachment(lastControl, 0);
} else {
data.left = new FormAttachment((((numInRow - 1) * MAX_PERCENT) / nbInRow), 0);
}
data.top = new FormAttachment(0, top);
labelLabel.setLayoutData(data);
if (numInRow != 1) {
labelLabel.setAlignment(SWT.RIGHT);
}
// *********************
data = new FormData();
int currentLabelWidth = STANDARD_LABEL_WIDTH;
GC gc = new GC(labelLabel);
Point labelSize = gc.stringExtent(param.getDisplayName());
gc.dispose();
if ((labelSize.x + ITabbedPropertyConstants.HSPACE) > currentLabelWidth) {
currentLabelWidth = labelSize.x + ITabbedPropertyConstants.HSPACE;
}
if (numInRow == 1) {
if (lastControl != null) {
data.left = new FormAttachment(lastControl, currentLabelWidth);
} else {
data.left = new FormAttachment(0, currentLabelWidth);
}
} else {
data.left = new FormAttachment(labelLabel, 0, SWT.RIGHT);
}
data.top = new FormAttachment(0, top);
cLayout.setLayoutData(data);
// **********************
hashCurControls.put(param.getName(), combo);
return cLayout;
}
use of org.eclipse.swt.layout.FormData in project tdi-studio-se by Talend.
the class QueryTypeController method addGuessQueryButton.
private Control addGuessQueryButton(Composite subComposite, IElementParameter param, Control lastControl, int numInRow, int top) {
final DecoratedField dField1 = new DecoratedField(subComposite, SWT.PUSH, new IControlCreator() {
@Override
public Control createControl(Composite parent, int style) {
return new Button(parent, style);
}
});
Button guessQueryButton = null;
Control buttonControl = dField1.getLayoutControl();
guessQueryButton = (Button) dField1.getControl();
guessQueryButton.computeSize(SWT.DEFAULT, SWT.DEFAULT);
buttonControl.setBackground(subComposite.getBackground());
guessQueryButton.setEnabled(!param.isReadOnly() || !ExtractMetaDataUtils.getInstance().haveLoadMetadataNode());
guessQueryButton.setData(NAME, GUESS_QUERY_NAME);
guessQueryButton.setData(PARAMETER_NAME, param.getName());
guessQueryButton.setText(GUESS_QUERY_NAME);
FormData data1 = new FormData();
data1.left = new FormAttachment(lastControl, 0);
data1.top = new FormAttachment(0, top);
data1.height = STANDARD_HEIGHT + 2;
buttonControl.setLayoutData(data1);
guessQueryButton.addSelectionListener(listenerSelection);
return buttonControl;
}
use of org.eclipse.swt.layout.FormData in project tdi-studio-se by Talend.
the class AbstractJobSettingsPage method createContents.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createContents(Composite parent) {
Composite composite = widgetFactory.createComposite(parent, SWT.NONE);
composite.setLayout(new FormLayout());
FormData data = createFormData();
composite.setLayoutData(data);
//
checkSettingExisted();
elem = checkAndCreateElement();
if (getParametersType() != null) {
ElementParameter2ParameterType.loadElementParameters(elem, getParametersType(), getPropertyTypeName());
}
// update connection from repository if needed
updateProjectSetting();
mComposite = new ProjectSettingMultipleThreadDynamicComposite(composite, SWT.V_SCROLL | SWT.BORDER, getCategory(), elem, true, getRepositoryPropertyName());
mComposite.setLayoutData(createFormData());
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
if (factory.isUserReadOnlyOnCurrentProject()) {
composite.setEnabled(false);
}
return composite;
}
Aggregations