use of org.talend.designer.core.ui.editor.properties.controllers.creator.SelectAllTextControlCreator 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.talend.designer.core.ui.editor.properties.controllers.creator.SelectAllTextControlCreator in project tdi-studio-se by Talend.
the class AbstractRepositoryController method addRepositoryChoice.
private Control addRepositoryChoice(Composite subComposite, Control lastControl, int numInRow, int nbInRow, int top, IElementParameter param) {
FormData data;
IElementParameter repositoryParameter = param.getChildParameters().get(getRepositoryChoiceParamName());
Text labelText;
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);
}
Control cLayout = dField.getLayoutControl();
labelText = (Text) dField.getControl();
labelText.setData(PARAMETER_NAME, param.getName());
cLayout.setBackground(subComposite.getBackground());
labelText.setEditable(false);
if (elem instanceof Node) {
labelText.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
}
// *********************
data = new FormData();
data.left = new FormAttachment(lastControl, 0);
data.right = new FormAttachment(lastControl, STANDARD_REPOSITORY_WIDTH, SWT.RIGHT);
// data.right = new FormAttachment((numInRow * MAX_PERCENT) / nbInRow, 0);
data.top = new FormAttachment(0, top);
cLayout.setLayoutData(data);
Button btn;
Point btnSize;
//$NON-NLS-1$
btn = getWidgetFactory().createButton(subComposite, "", SWT.PUSH);
btnSize = btn.computeSize(SWT.DEFAULT, SWT.DEFAULT);
btn.setImage(ImageProvider.getImage(CoreUIPlugin.getImageDescriptor(DOTS_BUTTON)));
btn.addSelectionListener(listenerSelection);
btn.setData(NAME, REPOSITORY_CHOICE);
btn.setData(PARAMETER_NAME, param.getName());
btn.setEnabled(!param.isReadOnly());
data = new FormData();
data.left = new FormAttachment(cLayout, 0);
data.right = new FormAttachment(cLayout, STANDARD_BUTTON_WIDTH, SWT.RIGHT);
data.top = new FormAttachment(0, top);
data.height = STANDARD_HEIGHT - 2;
btn.setLayoutData(data);
// **********************
//$NON-NLS-1$
hashCurControls.put(param.getName() + ":" + repositoryParameter.getName(), labelText);
return btn;
}
use of org.talend.designer.core.ui.editor.properties.controllers.creator.SelectAllTextControlCreator in project tdi-studio-se by Talend.
the class CommandController method createControl.
@Override
public Control createControl(Composite subComposite, final IElementParameter param, int numInRow, int nbInRow, int top, Control lastControl) {
this.curParameter = param;
this.paramFieldType = param.getFieldType();
FormData data;
// button
final Button btnCmd = getWidgetFactory().createButton(subComposite, null, SWT.PUSH);
btnCmd.setText(LAUNCH);
data = new FormData();
GC gc = new GC(btnCmd);
Point labelSize = gc.stringExtent(LAUNCH);
gc.dispose();
int currentLabelWidth = STANDARD_BUTTON_WIDTH;
if ((labelSize.x + ITabbedPropertyConstants.HSPACE * 2) > STANDARD_BUTTON_WIDTH) {
currentLabelWidth = labelSize.x + ITabbedPropertyConstants.HSPACE * 2;
}
data.left = new FormAttachment(((numInRow * MAX_PERCENT) / nbInRow), -currentLabelWidth);
data.right = new FormAttachment(((numInRow * MAX_PERCENT) / nbInRow), 0);
data.top = new FormAttachment(0, top);
data.height = STANDARD_HEIGHT + 2;
btnCmd.setLayoutData(data);
btnCmd.setData(PARAMETER_NAME, param.getName());
btnCmd.setData(NAME, COMMANDS);
btnCmd.setData(COMMANDS, checkQuotes((String) param.getValue()));
btnCmd.setEnabled(!param.isReadOnly());
btnCmd.addSelectionListener(btnListenerSelection);
// text
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);
}
Control cLayout = dField.getLayoutControl();
final Text commandText = (Text) dField.getControl();
commandText.setData(PARAMETER_NAME, param.getName());
cLayout.setBackground(subComposite.getBackground());
commandText.setEditable(!param.isReadOnly());
// init the commands from definded xml
commandText.setText(checkQuotes((String) param.getValue()));
commandText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
String string = checkQuotes(commandText.getText());
param.setValue(string);
btnCmd.setData(COMMANDS, param.getValue());
}
});
editionControlHelper.register(param.getName(), commandText);
addDragAndDropTarget(commandText);
if (elem instanceof Node) {
commandText.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
}
hashCurControls.put(param.getName(), commandText);
// label
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();
currentLabelWidth = STANDARD_LABEL_WIDTH;
gc = new GC(labelLabel);
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(btnCmd, 0);
data.top = new FormAttachment(btnCmd, 0, SWT.CENTER);
cLayout.setLayoutData(data);
Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
return btnCmd;
}
use of org.talend.designer.core.ui.editor.properties.controllers.creator.SelectAllTextControlCreator in project tdi-studio-se by Talend.
the class DirectoryController method createControl.
/*
* (non-Javadoc)
*
* @see org.talend.designer.core.ui.editor.properties2.editors.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 subComposite, final IElementParameter param, final int numInRow, final int nbInRow, final int top, final Control lastControl) {
this.curParameter = param;
FormData data;
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);
}
//$NON-NLS-1$
Button btnEdit = getWidgetFactory().createButton(subComposite, "", SWT.PUSH);
btnEdit.setImage(ImageProvider.getImage(CoreUIPlugin.getImageDescriptor(DOTS_BUTTON)));
data = new FormData();
data.left = new FormAttachment(((numInRow * MAX_PERCENT) / nbInRow), -STANDARD_BUTTON_WIDTH);
data.right = new FormAttachment(((numInRow * MAX_PERCENT) / nbInRow), 0);
data.top = new FormAttachment(labelLabel, 0, SWT.CENTER);
data.height = STANDARD_HEIGHT - 2;
btnEdit.setLayoutData(data);
btnEdit.setData(NAME, DIRECTORY);
btnEdit.setData(PARAMETER_NAME, param.getName());
btnEdit.setEnabled(!param.isReadOnly());
btnEdit.addSelectionListener(listenerSelection);
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);
}
Control cLayout = dField.getLayoutControl();
Text labelText = (Text) dField.getControl();
cLayout.setBackground(subComposite.getBackground());
if (!elem.isReadOnly()) {
if (param.isRepositoryValueUsed()) {
addRepositoryPropertyListener(labelText);
}
labelText.setEditable(!param.isReadOnly() && !param.isRepositoryValueUsed());
} else {
labelText.setEditable(false);
}
labelText.setData(PARAMETER_NAME, param.getName());
editionControlHelper.register(param.getName(), labelText);
addDragAndDropTarget(labelText);
if (elem instanceof Node) {
labelText.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
}
// **************************
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(btnEdit, 0);
data.top = new FormAttachment(labelLabel, 0, SWT.CENTER);
cLayout.setLayoutData(data);
hashCurControls.put(param.getName(), labelText);
Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
return btnEdit;
}
use of org.talend.designer.core.ui.editor.properties.controllers.creator.SelectAllTextControlCreator in project tdi-studio-se by Talend.
the class NameAndLabelsReferenceController method 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;
CLabel labelLabel = getWidgetFactory().createCLabel(subComposite, param.getDisplayName());
FormData 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);
}
//$NON-NLS-1$
Button btnEdit = getWidgetFactory().createButton(subComposite, "", SWT.PUSH);
btnEdit.setImage(ImageProvider.getImage(CoreUIPlugin.getImageDescriptor(DOTS_BUTTON)));
data = new FormData();
data.left = new FormAttachment(((numInRow * MAX_PERCENT) / nbInRow), -STANDARD_BUTTON_WIDTH);
data.right = new FormAttachment(((numInRow * MAX_PERCENT) / nbInRow), 0);
data.top = new FormAttachment(labelLabel, 0, SWT.CENTER);
data.height = STANDARD_HEIGHT - 2;
btnEdit.setLayoutData(data);
btnEdit.setData(NAME, MODULE);
btnEdit.setData(PARAM_OBJ, param);
btnEdit.setData(PARAMETER_NAME, param.getName());
btnEdit.setEnabled(!param.isRepositoryValueUsed());
// btnEdit.setEnabled(!param.isReadOnly());
btnEdit.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Command cmd = createCommand((Button) e.getSource());
executeCommand(cmd);
}
});
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 (param.isRepositoryValueUsed()) {
FieldDecoration decoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
//$NON-NLS-1$
decoration.setDescription(Messages.getString("FileController.decoration.description"));
dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.BOTTOM, false);
}
Control cLayout = dField.getLayoutControl();
Text moduleText = (Text) dField.getControl();
moduleText.setData(PARAMETER_NAME, param.getName());
moduleText.setEditable(false);
cLayout.setBackground(subComposite.getBackground());
addDragAndDropTarget(moduleText);
if (elem instanceof Node) {
moduleText.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
}
hashCurControls.put(param.getName(), moduleText);
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(btnEdit, 0);
data.top = new FormAttachment(labelLabel, 0, SWT.CENTER);
cLayout.setLayoutData(data);
Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
return btnEdit;
}
Aggregations