use of org.eclipse.swt.layout.FormData in project tdi-studio-se by Talend.
the class ComponentListController method createControl.
@Override
public Control createControl(Composite subComposite, IElementParameter param, int numInRow, int nbInRow, int top, Control lastControl) {
this.curParameter = param;
boolean isJobletOk = false;
// IJobletProviderService service = getJobletProviderService(param);
// if (service == null) { // not joblet
// param.setDisplayName(EParameterName.COMPONENT_LIST.getDisplayName());
// }
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);
}
Control cLayout = dField.getLayoutControl();
CCombo combo = (CCombo) dField.getControl();
FormData data;
combo.setEditable(false);
cLayout.setBackground(subComposite.getBackground());
combo.setEnabled(!param.isReadOnly());
combo.addSelectionListener(listenerSelection);
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);
Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
// **********************
hashCurControls.put(getParameterName(param), combo);
dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
return cLayout;
}
use of org.eclipse.swt.layout.FormData in project tdi-studio-se by Talend.
the class ConnectionListController 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) {
if (param.getDisplayName().startsWith(Messages.KEY_NOT_FOUND_PREFIX)) {
param.setDisplayName(EParameterName.CONNECTION_LIST.getDisplayName());
}
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);
}
Control cLayout = dField.getLayoutControl();
CCombo combo = (CCombo) dField.getControl();
FormData data;
if (param.getParentParameter() != null) {
//$NON-NLS-1$
combo.setData(PARAMETER_NAME, param.getParentParameter().getName() + ":" + param.getName());
} else {
combo.setData(PARAMETER_NAME, param.getName());
}
combo.setEditable(false);
cLayout.setBackground(subComposite.getBackground());
combo.setEnabled(!param.isReadOnly());
combo.addSelectionListener(listenerSelection);
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);
Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
// **********************
hashCurControls.put(param.getName(), combo);
dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
updateConnectionList(elem, param);
combo.setItems(param.getListItemsDisplayName());
if (param.getValue() != null) {
combo.setText((String) param.getValue());
}
return cLayout;
}
use of org.eclipse.swt.layout.FormData in project tdi-studio-se by Talend.
the class AbstractLanguageMemoController 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) {
IControlCreator txtCtrl = new IControlCreator() {
@Override
public Control createControl(final Composite parent, final int style) {
final ColorStyledText colorText = new ColorStyledText(parent, style, CorePlugin.getDefault().getPreferenceStore(), language);
Display display = Display.getCurrent();
if (display == null) {
display = Display.getDefault();
}
if (display != null) {
display.syncExec(new Runnable() {
@Override
public void run() {
IPreferenceStore preferenceStore = CorePlugin.getDefault().getPreferenceStore();
String fontType = preferenceStore.getString(TalendDesignerPrefConstants.MEMO_TEXT_FONT);
FontData fontData = new FontData(fontType);
Font font = new Font(parent.getDisplay(), fontData);
addResourceDisposeListener(colorText, font);
colorText.setFont(font);
}
});
}
return colorText;
}
};
DecoratedField dField = null;
if (param.getNbLines() != 1) {
dField = new DecoratedField(subComposite, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.WRAP, txtCtrl);
} else {
dField = new DecoratedField(subComposite, SWT.BORDER | SWT.WRAP, txtCtrl);
}
StyledText text = (StyledText) dField.getControl();
FormData d = (FormData) text.getLayoutData();
d.height = text.getLineHeight();
text.getParent().setSize(subComposite.getSize().x, text.getLineHeight());
rowSizeByLine = text.getLineHeight();
Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
dField.getLayoutControl().dispose();
rowSizeFixed = ITabbedPropertyConstants.VSPACE + (initialSize.y - rowSizeByLine);
estimateInitialized = true;
}
return rowSizeFixed + (rowSizeByLine * param.getNbLines());
}
use of org.eclipse.swt.layout.FormData in project tdi-studio-se by Talend.
the class BasicNotePropertyComposite method createTextControl.
/**
* DOC qwei Comment method "createTextcontrol".
*/
private void createTextControl(Composite parent) {
//$NON-NLS-1$
CLabel textLabel = getWidgetFactory().createCLabel(composite, Messages.getString("TextNoteSection.Label"));
//$NON-NLS-1$
FormData data = new FormData();
data.left = new FormAttachment(0, 0);
data.top = new FormAttachment(colorsAndFontsGroup, 30);
textLabel.setLayoutData(data);
//$NON-NLS-1$
text = getWidgetFactory().createText(composite, "", SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
//$NON-NLS-1$
data = new FormData();
data.left = new FormAttachment(0, STANDARD_LABEL_WIDTH);
data.right = new FormAttachment(textLabel, 560);
data.top = new FormAttachment(textLabel, 0, SWT.TOP);
// 5 lines
data.height = 5 * text.getLineHeight();
text.setLayoutData(data);
text.setForeground(new Color(null, ColorUtils.stringToRGB((String) note.getPropertyValue(EParameterName.NOTETXT_COLOR.getName()))));
text.setText(note.getText());
text.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
if (!text.getText().equals(note.getText())) {
ChangeNoteTextCommand command = new ChangeNoteTextCommand(note, text.getText());
getCommandStack().execute(command);
}
}
});
text.addKeyListener(new KeyListener() {
@Override
public void keyPressed(org.eclipse.swt.events.KeyEvent e) {
// TODO Auto-generated method stub
}
@Override
public void keyReleased(org.eclipse.swt.events.KeyEvent e) {
// TODO Auto-generated method stub
if (!text.getText().equals(note.getText())) {
ChangeNoteTextCommand command = new ChangeNoteTextCommand(note, text.getText());
getCommandStack().execute(command);
}
}
});
textChanged();
}
use of org.eclipse.swt.layout.FormData in project tdi-studio-se by Talend.
the class BasicNotePropertyComposite method createFontsAndColorsGroups.
/**
* DOC qwei Comment method "createFontsAndColorsGroups".
*/
protected Group createFontsAndColorsGroups(Composite parent) {
//$NON-NLS-1$
colorsAndFontsGroup = getWidgetFactory().createGroup(parent, "Fonts and Colors");
FormData data = new FormData();
data.left = new FormAttachment(0, 0);
data.top = new FormAttachment(check, 10);
GridLayout layout = new GridLayout(1, false);
colorsAndFontsGroup.setLayout(layout);
colorsAndFontsGroup.setLayoutData(data);
createFontsGroup(colorsAndFontsGroup);
return colorsAndFontsGroup;
}
Aggregations