use of org.eclipse.swt.layout.FormAttachment 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.FormAttachment 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.FormAttachment 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.FormAttachment in project tdi-studio-se by Talend.
the class AssignmentPropertySection method handleLayout.
private void handleLayout(Composite parent, Table table, TableColumn column1, TableColumn column2, TableColumn column3) {
Object layoutData = parent.getLayoutData();
if (layoutData instanceof GridData) {
GridData gridData = (GridData) layoutData;
gridData.grabExcessVerticalSpace = true;
gridData.verticalAlignment = SWT.FILL;
}
FormData formData = new FormData();
formData.left = new FormAttachment(0);
formData.top = new FormAttachment(0);
formData.right = new FormAttachment(100);
formData.bottom = new FormAttachment(100);
table.setLayoutData(formData);
}
use of org.eclipse.swt.layout.FormAttachment in project cubrid-manager by CUBRID.
the class ExportSettingForLoadDBPage method createControl.
/**
* Create the page content
*
* @param parent Composite
*/
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
container.setLayout(new FormLayout());
Composite leftComposite = new Composite(container, SWT.NONE);
leftComposite.setLayout(new GridLayout());
FormData leftData = new FormData();
leftData.top = new FormAttachment(0, 5);
leftData.bottom = new FormAttachment(100, 0);
leftData.left = new FormAttachment(0, 5);
leftData.right = new FormAttachment(45, 0);
leftComposite.setLayoutData(leftData);
Composite rightComposite = new Composite(container, SWT.NONE);
FormData rightData = new FormData();
rightData.top = new FormAttachment(0, 5);
rightData.bottom = new FormAttachment(100, 0);
rightData.left = new FormAttachment(45, 0);
rightData.right = new FormAttachment(100, -5);
rightComposite.setLayoutData(rightData);
GridLayout rightCompositeLayout = new GridLayout();
rightCompositeLayout.verticalSpacing = 10;
rightComposite.setLayout(rightCompositeLayout);
Label tableInfoLabel = new Label(leftComposite, SWT.None);
tableInfoLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
tableInfoLabel.setText(Messages.exportWizardSourceTableLable);
ctv = new CheckboxTreeViewer(leftComposite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
ctv.getTree().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
ctv.setContentProvider(new FilterTreeContentProvider());
ctv.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
updateDialogStatus();
}
});
final TreeViewerColumn dbObjectCol = new TreeViewerColumn(ctv, SWT.NONE);
dbObjectCol.setLabelProvider(new ExportObjectLabelProvider());
final TreeViewerColumn whereCnd = new TreeViewerColumn(ctv, SWT.NONE);
whereCnd.setLabelProvider(new ExportObjectLabelProvider());
whereCnd.setEditingSupport(new EditingSupport(ctv) {
TextCellEditor textCellEditor;
protected boolean canEdit(Object element) {
if (element instanceof ICubridNode) {
ICubridNode node = (ICubridNode) element;
if (node.getType() == NodeType.TABLE_COLUMN_FOLDER) {
return true;
}
}
return false;
}
protected CellEditor getCellEditor(Object element) {
if (textCellEditor == null) {
textCellEditor = new TextCellEditor(ctv.getTree());
}
return textCellEditor;
}
protected Object getValue(Object element) {
final ICubridNode node = (ICubridNode) element;
String condition = (String) node.getData(ExportObjectLabelProvider.CONDITION);
if (condition == null) {
return "";
} else {
return condition;
}
}
protected void setValue(Object element, Object value) {
final ICubridNode node = (ICubridNode) element;
node.setData(ExportObjectLabelProvider.CONDITION, value);
ctv.refresh();
}
});
dbObjectCol.getColumn().setWidth(160);
dbObjectCol.getColumn().setText(Messages.tableLabel);
whereCnd.getColumn().setWidth(120);
whereCnd.getColumn().setText(Messages.conditionLabel);
final Button selectAllBtn = new Button(leftComposite, SWT.CHECK);
{
selectAllBtn.setText(Messages.btnSelectAll);
GridData gridData = new GridData();
gridData.grabExcessHorizontalSpace = true;
gridData.horizontalIndent = 0;
gridData.horizontalSpan = 3;
selectAllBtn.setLayoutData(gridData);
}
selectAllBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
boolean selection = selectAllBtn.getSelection();
for (ICubridNode node : tablesOrViewLst) {
ctv.setGrayed(node, false);
ctv.setChecked(node, selection);
}
updateDialogStatus();
}
});
Group fileOptionGroup = new Group(rightComposite, SWT.None);
fileOptionGroup.setText(Messages.exportWizardWhereExport);
fileOptionGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
fileOptionGroup.setLayout(new GridLayout(3, false));
schemaButton = new Button(fileOptionGroup, SWT.CHECK);
schemaButton.setText("Schema");
schemaButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
schemaButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (schemaButton.getSelection()) {
schemaPathText.setEnabled(true);
schemaBrowseButton.setEnabled(true);
startValueButton.setEnabled(true);
} else {
schemaPathText.setEnabled(false);
schemaBrowseButton.setEnabled(false);
startValueButton.setEnabled(false);
}
updateDialogStatus();
}
});
schemaPathText = new Text(fileOptionGroup, SWT.BORDER);
schemaPathText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
schemaPathText.setEnabled(true);
schemaPathText.setEditable(false);
schemaPathText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
updateDialogStatus();
}
});
schemaBrowseButton = new Button(fileOptionGroup, SWT.None);
schemaBrowseButton.setText(Messages.btnBrowse);
schemaBrowseButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
schemaBrowseButton.setEnabled(true);
schemaBrowseButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
DatabaseInfo databaseInfo = getDatabase().getDatabaseInfo();
String databaseName = databaseInfo.getDbName();
String fileNameForLoaddbSchema = databaseName + "_schema";
File savedFile = TableUtil.getSavedFile(getShell(), new String[] { "*.*" }, new String[] { "All Files" }, fileNameForLoaddbSchema, null, null);
if (savedFile != null) {
schemaPathText.setText(savedFile.getAbsolutePath());
}
updateDialogStatus();
}
});
indexButton = new Button(fileOptionGroup, SWT.CHECK);
indexButton.setText("Index");
indexButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
indexButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (indexButton.getSelection()) {
indexPathText.setEnabled(true);
indexBrowseButton.setEnabled(true);
} else {
indexPathText.setEnabled(false);
indexBrowseButton.setEnabled(false);
}
updateDialogStatus();
}
});
indexPathText = new Text(fileOptionGroup, SWT.BORDER);
indexPathText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
indexPathText.setEnabled(true);
indexPathText.setEditable(false);
indexPathText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
updateDialogStatus();
}
});
indexBrowseButton = new Button(fileOptionGroup, SWT.None);
indexBrowseButton.setText(Messages.btnBrowse);
indexBrowseButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
indexBrowseButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
DatabaseInfo databaseInfo = getDatabase().getDatabaseInfo();
String databaseName = databaseInfo.getDbName();
String fileNameForLoaddbIndex = databaseName + "_indexes";
File savedFile = TableUtil.getSavedFile(getShell(), new String[] { "*.*" }, new String[] { "All Files" }, fileNameForLoaddbIndex, null, null);
if (savedFile != null) {
indexPathText.setText(savedFile.getAbsolutePath());
}
updateDialogStatus();
}
});
dataButton = new Button(fileOptionGroup, SWT.CHECK);
dataButton.setText("Data");
dataButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
dataButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (dataButton.getSelection()) {
dataPathText.setEnabled(true);
dataBrowseButton.setEnabled(true);
} else {
dataPathText.setEnabled(false);
dataBrowseButton.setEnabled(false);
}
updateDialogStatus();
}
});
dataPathText = new Text(fileOptionGroup, SWT.BORDER);
dataPathText.setEditable(false);
dataPathText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
dataPathText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
updateDialogStatus();
}
});
dataBrowseButton = new Button(fileOptionGroup, SWT.None);
dataBrowseButton.setText(Messages.btnBrowse);
dataBrowseButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
dataBrowseButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
DatabaseInfo databaseInfo = getDatabase().getDatabaseInfo();
String databaseName = databaseInfo.getDbName();
String fileNameForLoaddbData = databaseName + "_objects";
File savedFile = TableUtil.getSavedFile(getShell(), new String[] { "*.*" }, new String[] { "All Files" }, fileNameForLoaddbData, null, null);
if (savedFile != null) {
dataPathText.setText(savedFile.getAbsolutePath());
}
updateDialogStatus();
}
});
Group enCodingOptionGroup = new Group(rightComposite, SWT.None);
enCodingOptionGroup.setText(Messages.exportWizardDataOption);
enCodingOptionGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
enCodingOptionGroup.setLayout(new GridLayout(4, false));
Label dbCharsetLabel = new Label(enCodingOptionGroup, SWT.None);
dbCharsetLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
dbCharsetLabel.setText(Messages.lblJDBCCharset);
dbCharsetCombo = new Combo(enCodingOptionGroup, SWT.BORDER);
dbCharsetCombo.setLayoutData(CommonUITool.createGridData(1, 1, 50, 21));
dbCharsetCombo.setItems(QueryOptions.getAllCharset(null));
dbCharsetCombo.setEnabled(false);
Label fileCharsetLabel = new Label(enCodingOptionGroup, SWT.None);
fileCharsetLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
fileCharsetLabel.setText(Messages.lblFileCharset);
fileCharsetCombo = new Combo(enCodingOptionGroup, SWT.BORDER);
fileCharsetCombo.setLayoutData(CommonUITool.createGridData(1, 1, 50, 21));
fileCharsetCombo.setItems(QueryOptions.getAllCharset(null));
fileCharsetCombo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
updateDialogStatus();
}
});
startValueButton = new Button(enCodingOptionGroup, SWT.CHECK);
startValueButton.setText(Messages.lblExportTargetStartValue);
startValueButton.setLayoutData(CommonUITool.createGridData(4, 1, -1, -1));
startValueButton.setToolTipText(Messages.tipExportTargetStartValue);
setControl(container);
}
Aggregations