use of org.eclipse.jface.fieldassist.DecoratedField in project tdi-studio-se by Talend.
the class DirectoryController method estimateRowSize.
/*
* (non-Javadoc)
*
* @see org.talend.designer.core.ui.editor.properties.controllers.AbstractElementPropertySectionController#
* estimateRowSize (org.eclipse.swt.widgets.Composite, org.talend.core.model.process.IElementParameter)
*/
@Override
public int estimateRowSize(Composite subComposite, IElementParameter param) {
DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER, new TextControlCreator());
Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
dField.getLayoutControl().dispose();
return initialSize.y + ITabbedPropertyConstants.VSPACE;
}
use of org.eclipse.jface.fieldassist.DecoratedField in project tdi-studio-se by Talend.
the class EncodingTypeController method addCustomEncodingTypeText.
/**
* DOC ftang Comment method "addCustomEncodingTypeText".
*
* @param subComposite
* @param param
* @param lastControl
* @param numInRow
* @param nbInRow
* @param top
* @return
*/
private Control addCustomEncodingTypeText(Composite subComposite, IElementParameter param, Control lastControl, int numInRow, int nbInRow, int top) {
FormData data;
Text labelText;
IElementParameter encodingTypeParameter = param.getChildParameters().get(EParameterName.ENCODING_TYPE.getName());
final DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER, new SelectAllTextControlCreator());
if (param.isRequired() || EmfComponent.ENCODING_TYPE_CUSTOM.equals(encodingTypeParameter.getValue())) {
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("TextController.decoration.description"));
dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.BOTTOM, false);
}
Control cLayout = dField.getLayoutControl();
labelText = (Text) dField.getControl();
labelText.setData(PARAMETER_NAME, param.getName());
editionControlHelper.register(param.getName(), labelText);
if (param.isRepositoryValueUsed()) {
addRepositoryPropertyListener(labelText);
}
addDragAndDropTarget(labelText);
cLayout.setBackground(subComposite.getBackground());
labelText.setEditable(!param.isReadOnly() && !param.isRepositoryValueUsed());
labelText.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
data = new FormData();
data.left = new FormAttachment(lastControl, 0);
data.right = new FormAttachment((numInRow * MAX_PERCENT) / nbInRow, 0);
data.top = new FormAttachment(0, top);
cLayout.setLayoutData(data);
hashCurControls.put(param.getName(), labelText);
Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
return null;
}
use of org.eclipse.jface.fieldassist.DecoratedField in project tdi-studio-se by Talend.
the class DbTableController method addOpenSqlBulderButton.
/**
* qzhang Comment method "addOpenSqlBulderButton".
*
* @param subComposite
* @param param
* @param top
* @param numInRow
* @param nbInRow
* @return
*/
private Control addOpenSqlBulderButton(Composite subComposite, IElementParameter param, int top, int numInRow, int nbInRow) {
final DecoratedField dField1 = new DecoratedField(subComposite, SWT.PUSH, new IControlCreator() {
@Override
public Control createControl(Composite parent, int style) {
return new Button(parent, style);
}
});
Control buttonControl = dField1.getLayoutControl();
Button openSQLEditorButton = (Button) dField1.getControl();
openSQLEditorButton.computeSize(SWT.DEFAULT, SWT.DEFAULT);
openSQLEditorButton.setImage(ImageProvider.getImage(ImageProvider.getImageDesc(EImage.READ_ICON)));
buttonControl.setBackground(subComposite.getBackground());
openSQLEditorButton.setEnabled(!param.isReadOnly());
openSQLEditorButton.setData(NAME, SQLEDITOR);
openSQLEditorButton.setData(PARAMETER_NAME, param.getName());
if (param.getFieldType() == EParameterFieldType.DBTABLE) {
openSQLEditorButton.setEnabled(ExtractMetaDataUtils.getInstance().haveLoadMetadataNode());
}
openSQLEditorButton.addSelectionListener(openSQLListener);
return buttonControl;
}
use of org.eclipse.jface.fieldassist.DecoratedField in project tdi-studio-se by Talend.
the class DbTypeListController method estimateRowSize.
/*
* (non-Javadoc)
*
* @see
* org.talend.designer.core.ui.editor.properties.controllers.AbstractElementPropertySectionController#estimateRowSize
* (org.eclipse.swt.widgets.Composite, org.talend.core.model.process.IElementParameter)
*/
@Override
public int estimateRowSize(Composite subComposite, IElementParameter param) {
DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER, cbCtrl);
Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
dField.getLayoutControl().dispose();
return initialSize.y + ITabbedPropertyConstants.VSPACE;
}
use of org.eclipse.jface.fieldassist.DecoratedField in project tdi-studio-se by Talend.
the class DCSchemaController method createControl.
@Override
public Control createControl(Composite subComposite, IElementParameter param, int numInRow, int nbInRow, int top, Control lastControl) {
this.curParameter = param;
this.paramFieldType = param.getFieldType();
FormData data = new FormData();
Control lastDbControl = null;
Button openListTable = addButton(subComposite, param, top, numInRow, nbInRow);
lastDbControl = openListTable;
data.top = new FormAttachment(0, top);
data.height = STANDARD_HEIGHT - 2;
if (openListTable != null) {
openListTable.setLayoutData(data);
openListTable.setData(PARAMETER_NAME, param.getName());
openListTable.setEnabled(!param.isReadOnly());
openListTable.addSelectionListener(schemaListener);
//$NON-NLS-1$
openListTable.setToolTipText("Edit Schema");
}
Text labelText;
final DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER, new SelectAllTextControlCreator());
Control cLayout = dField.getLayoutControl();
labelText = (Text) dField.getControl();
labelText.setData(PARAMETER_NAME, param.getName());
labelText.setText(PARAMETER_NAME);
cLayout.setBackground(subComposite.getBackground());
labelText.setEditable(!param.isReadOnly());
if (elem instanceof Node) {
labelText.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
}
addDragAndDropTarget(labelText);
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);
}
if (openListTable != null) {
data.right = new FormAttachment(openListTable, -5, SWT.LEFT);
} else {
data.right = new FormAttachment((numInRow * MAX_PERCENT) / nbInRow, 0);
lastDbControl = labelText;
}
data.top = new FormAttachment(0, top);
cLayout.setLayoutData(data);
hashCurControls.put(param.getName(), labelText);
Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
return lastDbControl;
}
Aggregations