use of org.eclipse.swt.layout.FormData in project tdi-studio-se by Talend.
the class TableByRowController method createControl.
/*
* (non-Javadoc)
*
* @see org.talend.designer.core.ui.editor.properties2.editors.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(final Composite parentComposite, final IElementParameter param, final int numInRow, final int nbInRow, int top, final Control lastControlPrm) {
this.curParameter = param;
this.paramFieldType = param.getFieldType();
final Composite container = parentComposite;
PropertiesTableEditorModel<Map<String, Object>> tableEditorModel = new PropertiesTableEditorModel<Map<String, Object>>();
if (param.getValue() == null || param.getValue().equals("")) {
param.setValue(new ArrayList<Map<String, Object>>());
}
init(elem, param);
tableEditorModel.setData(elem, param, getProcess(elem, part));
PropertiesTableByRowEditorView<Map<String, Object>> tableEditorView = new PropertiesTableByRowEditorView<Map<String, Object>>(parentComposite, SWT.NONE, tableEditorModel, true, false);
tableEditorView.getExtendedTableViewer().setCommandStack(getCommandStack());
tableEditorView.setReadOnly(param.isReadOnly() || param.isRepositoryValueUsed());
tableEditorModel.setModifiedBeanListenable(tableEditorView.getTableViewerCreator());
tableEditorModel.addModifiedBeanListenerForAggregateComponent();
final Table table = tableEditorView.getTable();
table.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
// add listener to tableMetadata (listen the event of the toolbars)
tableEditorView.getExtendedTableModel().addAfterOperationListListener(new IListenableListListener() {
@Override
public void handleEvent(ListenableListEvent event) {
if (elem instanceof Node) {
Node node = (Node) elem;
node.checkAndRefreshNode();
}
}
});
final Composite mainComposite = tableEditorView.getMainComposite();
CLabel labelLabel2 = getWidgetFactory().createCLabel(container, param.getDisplayName());
FormData formData = new FormData();
if (lastControlPrm != null) {
formData.left = new FormAttachment(lastControlPrm, 0);
} else {
formData.left = new FormAttachment((((numInRow - 1) * MAX_PERCENT) / nbInRow), 0);
}
formData.top = new FormAttachment(0, top);
labelLabel2.setLayoutData(formData);
if (numInRow != 1) {
labelLabel2.setAlignment(SWT.RIGHT);
}
// *********************
formData = new FormData();
int currentLabelWidth2 = STANDARD_LABEL_WIDTH;
GC gc2 = new GC(labelLabel2);
Point labelSize2 = gc2.stringExtent(param.getDisplayName());
gc2.dispose();
boolean needOffset = true;
if ((labelSize2.x + ITabbedPropertyConstants.HSPACE) > currentLabelWidth2) {
currentLabelWidth2 = labelSize2.x + ITabbedPropertyConstants.HSPACE;
needOffset = false;
}
int tableHorizontalOffset = -5;
if (numInRow == 1) {
if (lastControlPrm != null) {
if (needOffset) {
formData.left = new FormAttachment(lastControlPrm, currentLabelWidth2 + tableHorizontalOffset);
} else {
formData.left = new FormAttachment(lastControlPrm, currentLabelWidth2);
}
} else {
if (needOffset) {
formData.left = new FormAttachment(0, currentLabelWidth2 + tableHorizontalOffset);
} else {
formData.left = new FormAttachment(0, currentLabelWidth2);
}
}
} else {
formData.left = new FormAttachment(labelLabel2, 0 + tableHorizontalOffset, SWT.RIGHT);
}
formData.right = new FormAttachment((numInRow * MAX_PERCENT) / nbInRow, 0);
formData.top = new FormAttachment(0, top);
int toolbarSize = 0;
if (!param.isBasedOnSchema()) {
Point size = tableEditorView.getExtendedToolbar().getToolbar().computeSize(SWT.DEFAULT, SWT.DEFAULT);
toolbarSize = size.y + 5;
}
int currentHeightEditor = table.getHeaderHeight() + 1 * table.getItemHeight() + table.getItemHeight() + toolbarSize;
int minHeightEditor = table.getHeaderHeight() + getNumberLines(param) * table.getItemHeight() + table.getItemHeight() + toolbarSize;
int ySize2 = Math.max(currentHeightEditor, minHeightEditor);
ySize2 = Math.min(ySize2, 500);
formData.bottom = new FormAttachment(0, top + ySize2);
mainComposite.setLayoutData(formData);
hashCurControls.put(param.getName(), tableEditorView.getExtendedTableViewer().getTableViewerCreator());
hashCurControls.put(TOOLBAR_NAME, tableEditorView.getToolBar());
updateTableValues(param);
this.dynamicProperty.setCurRowSize(ySize2 + ITabbedPropertyConstants.VSPACE);
top += this.dynamicProperty.getCurRowSize();
return null;
}
use of org.eclipse.swt.layout.FormData in project tdi-studio-se by Talend.
the class FooterComposite method createComponents.
/**
* DOC amaumont Comment method "createComponents".
*/
private void createComponents() {
FormLayout formLayout = new FormLayout();
formLayout.spacing = 15;
this.setLayout(formLayout);
Button applyButton = new Button(this, SWT.NONE);
applyButton.setEnabled(!mapperUi.getMapperComponent().isReadOnly());
//$NON-NLS-1$
applyButton.setText("Apply");
FormData applyFormData = new FormData();
applyFormData.width = 100;
applyButton.setLayoutData(applyFormData);
applyButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
mapperUi.closeMapperDialog(SWT.APPLICATION_MODAL);
}
});
statusBar = new StatusBar(this, SWT.NONE);
final ProblemsAnalyser problemsAnalyser = mapperUi.getMapperManager().getProblemsAnalyser();
if (!problemsAnalyser.getProblems().isEmpty()) {
statusBar.setValues(STATUS.ERROR, problemsAnalyser.getErrorMessage());
}
Button okButton = new Button(this, SWT.NONE);
okButton.setEnabled(!mapperUi.getMapperComponent().isReadOnly());
//$NON-NLS-1$
okButton.setText("OK");
FormData okFormData = new FormData();
okFormData.width = 100;
okButton.setLayoutData(okFormData);
okButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
mapperUi.closeMapperDialog(SWT.OK);
}
});
Button cancelButton = new Button(this, SWT.NONE);
//$NON-NLS-1$
cancelButton.setText("Cancel");
cancelButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
mapperUi.closeMapperDialog(SWT.CANCEL);
}
});
FormData cancelFormData = new FormData();
cancelFormData.width = 100;
cancelButton.setLayoutData(cancelFormData);
cancelFormData.right = new FormAttachment(100, -5);
okFormData.right = new FormAttachment(cancelButton, -5);
applyFormData.right = new FormAttachment(okButton, -5);
}
use of org.eclipse.swt.layout.FormData in project tdi-studio-se by Talend.
the class AbstractRepositoryController method addRepositoryChoice.
private Control addRepositoryChoice(Composite subComposite, Control lastControl, int numInRow, int nbInRow, int top, IElementParameter param) {
FormData data;
IElementParameter repositoryParameter = param.getChildParameters().get(getRepositoryChoiceParamName());
Text labelText;
final DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER, new SelectAllTextControlCreator());
if (param.isRequired()) {
FieldDecoration decoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED);
dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.TOP, false);
}
Control cLayout = dField.getLayoutControl();
labelText = (Text) dField.getControl();
labelText.setData(PARAMETER_NAME, param.getName());
cLayout.setBackground(subComposite.getBackground());
labelText.setEditable(false);
if (elem instanceof Node) {
labelText.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
}
// *********************
data = new FormData();
data.left = new FormAttachment(lastControl, 0);
data.right = new FormAttachment(lastControl, STANDARD_REPOSITORY_WIDTH, SWT.RIGHT);
// data.right = new FormAttachment((numInRow * MAX_PERCENT) / nbInRow, 0);
data.top = new FormAttachment(0, top);
cLayout.setLayoutData(data);
Button btn;
Point btnSize;
//$NON-NLS-1$
btn = getWidgetFactory().createButton(subComposite, "", SWT.PUSH);
btnSize = btn.computeSize(SWT.DEFAULT, SWT.DEFAULT);
btn.setImage(ImageProvider.getImage(CoreUIPlugin.getImageDescriptor(DOTS_BUTTON)));
btn.addSelectionListener(listenerSelection);
btn.setData(NAME, REPOSITORY_CHOICE);
btn.setData(PARAMETER_NAME, param.getName());
btn.setEnabled(!param.isReadOnly());
data = new FormData();
data.left = new FormAttachment(cLayout, 0);
data.right = new FormAttachment(cLayout, STANDARD_BUTTON_WIDTH, SWT.RIGHT);
data.top = new FormAttachment(0, top);
data.height = STANDARD_HEIGHT - 2;
btn.setLayoutData(data);
// **********************
//$NON-NLS-1$
hashCurControls.put(param.getName() + ":" + repositoryParameter.getName(), labelText);
return btn;
}
use of org.eclipse.swt.layout.FormData in project tdi-studio-se by Talend.
the class ComboController 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 (canAddRepositoryDecoration(param)) {
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());
int nbLines = param.getNbLines();
if (nbLines > 5) {
combo.setVisibleItemCount(nbLines);
}
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);
if (isInWizard()) {
labelLabel.setAlignment(SWT.RIGHT);
if (lastControl != null) {
data.right = new FormAttachment(lastControl, 0);
} else {
data.right = new FormAttachment(100, -ITabbedPropertyConstants.HSPACE);
}
if (nbInRow == 1) {
data.left = new FormAttachment(100, -initialSize.x);
} else {
data.left = new FormAttachment((((nbInRow - numInRow) * MAX_PERCENT) / nbInRow), currentLabelWidth + ITabbedPropertyConstants.HSPACE);
}
data = (FormData) labelLabel.getLayoutData();
data.right = new FormAttachment(cLayout, 0);
data.left = new FormAttachment((((nbInRow - numInRow) * MAX_PERCENT) / nbInRow), 0);
return labelLabel;
}
if (EnvironmentUtils.isMacOsSytem()) {
data = (FormData) labelLabel.getLayoutData();
data.top = new FormAttachment(cLayout, -3, SWT.TOP);
}
return cLayout;
}
use of org.eclipse.swt.layout.FormData in project tdi-studio-se by Talend.
the class CommandController method createControl.
@Override
public Control createControl(Composite subComposite, final IElementParameter param, int numInRow, int nbInRow, int top, Control lastControl) {
this.curParameter = param;
this.paramFieldType = param.getFieldType();
FormData data;
// button
final Button btnCmd = getWidgetFactory().createButton(subComposite, null, SWT.PUSH);
btnCmd.setText(LAUNCH);
data = new FormData();
GC gc = new GC(btnCmd);
Point labelSize = gc.stringExtent(LAUNCH);
gc.dispose();
int currentLabelWidth = STANDARD_BUTTON_WIDTH;
if ((labelSize.x + ITabbedPropertyConstants.HSPACE * 2) > STANDARD_BUTTON_WIDTH) {
currentLabelWidth = labelSize.x + ITabbedPropertyConstants.HSPACE * 2;
}
data.left = new FormAttachment(((numInRow * MAX_PERCENT) / nbInRow), -currentLabelWidth);
data.right = new FormAttachment(((numInRow * MAX_PERCENT) / nbInRow), 0);
data.top = new FormAttachment(0, top);
data.height = STANDARD_HEIGHT + 2;
btnCmd.setLayoutData(data);
btnCmd.setData(PARAMETER_NAME, param.getName());
btnCmd.setData(NAME, COMMANDS);
btnCmd.setData(COMMANDS, checkQuotes((String) param.getValue()));
btnCmd.setEnabled(!param.isReadOnly());
btnCmd.addSelectionListener(btnListenerSelection);
// text
DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER, new SelectAllTextControlCreator());
if (param.isRequired()) {
FieldDecoration decoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED);
dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.TOP, false);
}
Control cLayout = dField.getLayoutControl();
final Text commandText = (Text) dField.getControl();
commandText.setData(PARAMETER_NAME, param.getName());
cLayout.setBackground(subComposite.getBackground());
commandText.setEditable(!param.isReadOnly());
// init the commands from definded xml
commandText.setText(checkQuotes((String) param.getValue()));
commandText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
String string = checkQuotes(commandText.getText());
param.setValue(string);
btnCmd.setData(COMMANDS, param.getValue());
}
});
editionControlHelper.register(param.getName(), commandText);
addDragAndDropTarget(commandText);
if (elem instanceof Node) {
commandText.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
}
hashCurControls.put(param.getName(), commandText);
// label
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();
currentLabelWidth = STANDARD_LABEL_WIDTH;
gc = new GC(labelLabel);
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.right = new FormAttachment(btnCmd, 0);
data.top = new FormAttachment(btnCmd, 0, SWT.CENTER);
cLayout.setLayoutData(data);
Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
return btnCmd;
}
Aggregations