use of org.eclipse.jface.fieldassist.DecoratedField in project tdi-studio-se by Talend.
the class ComponentRefController method estimateRowSize.
@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 ComponentRefController method 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;
combo.setEditable(false);
cLayout.setBackground(subComposite.getBackground());
combo.setEnabled(!param.isReadOnly());
GenericElementParameter gParam = (GenericElementParameter) param;
ComponentReferenceProperties props = (ComponentReferenceProperties) gParam.getWidget().getContent();
combo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
if (!(event.getSource() instanceof CCombo)) {
return;
}
Command cmd = createComboCommand(event, gParam, props);
executeCommand(cmd);
}
});
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, Messages.getString("ComponentRefController.connectionLabel"));
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(Messages.getString("ComponentRefController.connectionLabel"));
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.jface.fieldassist.DecoratedField in project tdi-studio-se by Talend.
the class MemoController 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) {
if (!estimateInitialized) {
DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.WRAP, new TextControlCreator());
Text text = (Text) dField.getControl();
FormData d = (FormData) text.getLayoutData();
d.height = text.getLineHeight();
text.getParent().setSize(subComposite.getSize().x, text.getLineHeight());
Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
rowSizeByLine = text.getLineHeight();
dField.getLayoutControl().dispose();
rowSizeFixed = ITabbedPropertyConstants.VSPACE + (initialSize.y - rowSizeByLine);
estimateInitialized = true;
}
return rowSizeFixed + (rowSizeByLine * param.getNbLines());
}
use of org.eclipse.jface.fieldassist.DecoratedField in project tdi-studio-se by Talend.
the class MessageMemoController 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, IElementParameter param, int numInRow, int nbInRow, int top, Control lastControl) {
this.curParameter = param;
this.paramFieldType = param.getFieldType();
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();
messageEditorButton = (Button) dField1.getControl();
messageEditorButton.computeSize(SWT.DEFAULT, SWT.DEFAULT);
messageEditorButton.setImage(ImageProvider.getImage(CoreUIPlugin.getImageDescriptor(DOTS_BUTTON)));
buttonControl.setBackground(subComposite.getBackground());
messageEditorButton.setEnabled(true);
messageEditorButton.setData(NAME, SQLEDITOR);
messageEditorButton.setData(PARAMETER_NAME, param.getName());
messageEditorButton.setEnabled(!param.isReadOnly());
messageEditorButton.addSelectionListener(listenerSelection);
FormData data1 = new FormData();
data1.right = new FormAttachment(100, -ITabbedPropertyConstants.HSPACE);
data1.left = new FormAttachment(100, -(ITabbedPropertyConstants.HSPACE + STANDARD_BUTTON_WIDTH));
data1.top = new FormAttachment(0, top);
buttonControl.setLayoutData(data1);
int nbLines = param.getNbLines();
IControlCreator txtCtrl = new IControlCreator() {
@Override
public Control createControl(final Composite parent, final int style) {
return createColorStyledText(parent, style);
}
};
DecoratedField dField = null;
if (param.getNbLines() != 1) {
dField = new DecoratedField(subComposite, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, txtCtrl);
} else {
dField = new DecoratedField(subComposite, SWT.BORDER, txtCtrl);
}
if (param.isRequired()) {
FieldDecoration decoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED);
dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.TOP, false);
}
Control cLayout = dField.getLayoutControl();
messageText = (ColorStyledText) dField.getControl();
messageText.setText(getCurrentMessage());
messageText.setData(PARAMETER_NAME, param.getName());
editionControlHelper.register(param.getName(), messageText);
FormData d = (FormData) messageText.getLayoutData();
if (getAdditionalHeightSize() != 0) {
nbLines += this.getAdditionalHeightSize() / messageText.getLineHeight();
}
d.height = messageText.getLineHeight() * nbLines;
FormData data;
messageText.getParent().setSize(subComposite.getSize().x, messageText.getLineHeight() * nbLines);
cLayout.setBackground(subComposite.getBackground());
messageText.setEnabled(!param.isReadOnly());
if (elem instanceof Node) {
messageText.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
}
addDragAndDropTarget(messageText);
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.right = new FormAttachment(buttonControl, -5, SWT.LEFT);
data.top = new FormAttachment(0, top);
cLayout.setLayoutData(data);
// **********************
hashCurControls.put(param.getName(), messageText);
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 ProcessController method addContextCombo.
private Control addContextCombo(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());
}
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;
}
Aggregations