use of org.eclipse.swt.custom.CLabel 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.custom.CLabel in project tdi-studio-se by Talend.
the class TextController 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) {
this.curParameter = param;
this.paramFieldType = param.getFieldType();
FormData data;
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);
}
if (canAddRepositoryDecoration(param)) {
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();
Text labelText = (Text) dField.getControl();
labelText.setData(PARAMETER_NAME, param.getName());
editionControlHelper.register(param.getName(), labelText);
cLayout.setBackground(subComposite.getBackground());
if (elem instanceof Node) {
labelText.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
}
if (!isReadOnly()) {
if (param.isRepositoryValueUsed() && !(elem instanceof org.talend.designer.core.ui.editor.process.Process || elem instanceof StatsAndLogsElement || elem instanceof ImplicitContextLoadElement)) {
addRepositoryPropertyListener(labelText);
}
if (param.isRequired()) {
labelText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
checkTextError(param, labelText, labelText.getText());
}
});
}
boolean editable = !param.isReadOnly() && (elem instanceof FakeElement || !param.isRepositoryValueUsed());
labelText.setEditable(editable);
} else {
labelText.setEditable(false);
}
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);
// *********************
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 * 2)) > currentLabelWidth) {
currentLabelWidth = labelSize.x + (ITabbedPropertyConstants.HSPACE * 2);
}
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((numInRow * MAX_PERCENT) / nbInRow, 0);
data.top = new FormAttachment(0, top);
cLayout.setLayoutData(data);
// **********************
hashCurControls.put(param.getName(), labelText);
Point initialSize = cLayout.computeSize(SWT.DEFAULT, SWT.DEFAULT);
// curRowSize = initialSize.y + ITabbedPropertyConstants.VSPACE;
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);
}
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;
}
return cLayout;
}
use of org.eclipse.swt.custom.CLabel in project tdi-studio-se by Talend.
the class TreeTableController 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(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;
final TreeViewer viewer = new TreeViewer(container, SWT.FULL_SELECTION | SWT.BORDER);
viewer.getTree().setHeaderVisible(true);
// key column
TreeColumn column = new TreeColumn(viewer.getTree(), SWT.LEFT);
column.setText("Key");
column.setWidth(150);
// columns for values
if (param.getValue() != null) {
List<Map<String, Object>> values = (List<Map<String, Object>>) param.getValue();
for (int i = 0; i < values.size(); i++) {
column = new TreeColumn(viewer.getTree(), SWT.LEFT);
column.setText("Value" + i);
column.setWidth(100);
}
}
viewer.setContentProvider(new MyTreeContentProvider(param));
viewer.setLabelProvider(new MyTableLableProvider(param));
viewer.setInput(param);
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 = viewer.getTree().computeSize(SWT.DEFAULT, SWT.DEFAULT);
toolbarSize = size.y - 95;
}
int currentHeightEditor = viewer.getTree().getHeaderHeight() + param.getListItemsValue().length * viewer.getTree().getItemHeight() + viewer.getTree().getItemHeight() + toolbarSize;
int minHeightEditor = viewer.getTree().getHeaderHeight() + getNumberLines(param) * viewer.getTree().getItemHeight() + viewer.getTree().getItemHeight() + toolbarSize;
int ySize2 = Math.max(currentHeightEditor, minHeightEditor);
formData.bottom = new FormAttachment(0, top + ySize2);
viewer.getTree().setLayoutData(formData);
this.dynamicProperty.setCurRowSize(ySize2 + ITabbedPropertyConstants.VSPACE);
top += this.dynamicProperty.getCurRowSize();
return null;
}
use of org.eclipse.swt.custom.CLabel in project tdi-studio-se by Talend.
the class DateSection method createControls.
@Override
public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
super.createControls(parent, aTabbedPropertySheetPage);
Composite composite = getWidgetFactory().createFlatFormComposite(parent);
FormData data;
//$NON-NLS-1$
creationDate = getWidgetFactory().createText(composite, "");
data = new FormData();
data.left = new FormAttachment(0, STANDARD_LABEL_WIDTH);
data.right = new FormAttachment(33, 0);
data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE);
creationDate.setLayoutData(data);
creationDate.setEnabled(false);
//$NON-NLS-1$
CLabel creationLabel = getWidgetFactory().createCLabel(composite, Messages.getString("DateSection.creationLabel"));
data = new FormData();
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(creationDate, -ITabbedPropertyConstants.HSPACE);
data.top = new FormAttachment(creationDate, 0, SWT.CENTER);
creationLabel.setLayoutData(data);
//$NON-NLS-1$
modificationDate = getWidgetFactory().createText(composite, "");
data = new FormData();
data.left = new FormAttachment(creationDate, STANDARD_LABEL_WIDTH + 15);
data.right = new FormAttachment(66, 0);
data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE);
modificationDate.setLayoutData(data);
modificationDate.setEnabled(false);
CLabel modificationLabel = getWidgetFactory().createCLabel(composite, //$NON-NLS-1$
Messages.getString("DateSection.ModificationLabel"));
data = new FormData();
data.left = new FormAttachment(creationDate, ITabbedPropertyConstants.HSPACE * 3);
data.right = new FormAttachment(modificationDate, -ITabbedPropertyConstants.HSPACE);
data.top = new FormAttachment(modificationDate, 0, SWT.CENTER);
modificationLabel.setLayoutData(data);
//$NON-NLS-1$
commitDate = getWidgetFactory().createText(composite, "");
data = new FormData();
data.left = new FormAttachment(modificationDate, STANDARD_LABEL_WIDTH + 15);
data.right = new FormAttachment(100, 0);
data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE);
commitDate.setLayoutData(data);
commitDate.setEnabled(false);
//$NON-NLS-1$
commitLabel = getWidgetFactory().createCLabel(composite, Messages.getString("DateSection.commitLabel"));
data = new FormData();
data.left = new FormAttachment(modificationDate, ITabbedPropertyConstants.HSPACE * 3);
data.right = new FormAttachment(commitDate, -ITabbedPropertyConstants.HSPACE);
data.top = new FormAttachment(commitDate, 0, SWT.CENTER);
commitLabel.setLayoutData(data);
addFocusListenerToChildren(composite);
}
use of org.eclipse.swt.custom.CLabel in project tdi-studio-se by Talend.
the class DescriptionSection method createControls.
@Override
public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
super.createControls(parent, aTabbedPropertySheetPage);
Composite composite = getWidgetFactory().createFlatFormComposite(parent);
FormData data;
//$NON-NLS-1$
descriptionText = getWidgetFactory().createText(composite, "", SWT.MULTI);
data = new FormData();
data.left = new FormAttachment(0, STANDARD_LABEL_WIDTH);
data.right = new FormAttachment(100, 0);
data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE);
data.height = NB_LINES * descriptionText.getLineHeight();
descriptionText.setLayoutData(data);
addFocusListener(descriptionText);
//$NON-NLS-1$
CLabel labelLabel = getWidgetFactory().createCLabel(composite, Messages.getString("DescriptionSection.Label"));
data = new FormData();
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(descriptionText, -ITabbedPropertyConstants.HSPACE);
data.top = new FormAttachment(descriptionText, 0, SWT.TOP);
labelLabel.setLayoutData(data);
addFocusListenerToChildren(composite);
}
Aggregations