use of org.eclipse.swt.widgets.Control 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.swt.widgets.Control in project tdi-studio-se by Talend.
the class GenericHiddenTextController method addButton.
protected Control addButton(Composite subComposite, IElementParameter param, Control lastControl, int numInRow, int nbInRow, int top) {
Button btn;
Control lastControlUsed = lastControl;
Point btnSize;
FormData data;
//$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, HIDDEN_TEXT);
btn.setData(PARAMETER_NAME, param.getName());
lastControlUsed = btn;
data = new FormData();
// data.right = new FormAttachment(lastControl, -5, SWT.LEFT);
// data.left = new FormAttachment(lastControl, -(15 + STANDARD_BUTTON_WIDTH), SWT.LEFT);
// data.right = new FormAttachment(((numInRow * MAX_PERCENT) / nbInRow), 0);
// data.left = new FormAttachment(((numInRow * MAX_PERCENT) / nbInRow), -STANDARD_BUTTON_WIDTH);
data.left = new FormAttachment(lastControl, 0);
data.right = new FormAttachment(lastControl, STANDARD_BUTTON_WIDTH, SWT.RIGHT);
data.top = new FormAttachment(0, top);
data.height = STANDARD_HEIGHT - 2;
btn.setLayoutData(data);
// dynamicProperty.setCurRowSize(btnSize.y + ITabbedPropertyConstants.VSPACE);
int buttonHeight = btnSize.y + ITabbedPropertyConstants.VSPACE;
if (dynamicProperty.getCurRowSize() < buttonHeight) {
dynamicProperty.setCurRowSize(buttonHeight);
}
return lastControlUsed;
}
use of org.eclipse.swt.widgets.Control in project tdi-studio-se by Talend.
the class GenericHiddenTextController method createButtonCommand.
protected Command createButtonCommand(final Button button) {
if (button.getData(NAME).equals(HIDDEN_TEXT)) {
InputDialog dlg = new InputDialog(button.getShell(), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Messages.getString("GenericHiddenTextController.NewPassword"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Messages.getString("GenericHiddenTextController.NoteConvention"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"\"\"", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
null) {
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.dialogs.InputDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
Control control = super.createDialogArea(parent);
String paramName = (String) button.getData(PARAMETER_NAME);
getText().setData(PARAMETER_NAME, paramName);
// editionControlHelper.register(paramName, getText());
return control;
}
};
if (dlg.open() == Window.OK) {
String paramName = (String) button.getData(PARAMETER_NAME);
elem.setPropertyValue(EParameterName.UPDATE_COMPONENTS.getName(), new Boolean(true));
return new PropertyChangeCommand(elem, paramName, dlg.getValue());
}
}
return null;
}
use of org.eclipse.swt.widgets.Control in project tdi-studio-se by Talend.
the class GenericHiddenTextController method createControl.
@Override
public Control createControl(Composite subComposite, IElementParameter param, int numInRow, int nbInRow, int top, Control lastControl) {
Control lastControlUsed = super.createControl(subComposite, param, numInRow, nbInRow, top, lastControl);
Text labelText = (Text) hashCurControls.get(param.getName());
if (labelText != null && param != null && isPasswordParam(param)) {
labelText.setEchoChar('*');
}
FormData data = (FormData) lastControlUsed.getLayoutData();
if (!param.isRepositoryValueUsed() && !isInWizard()) {
data.right = new FormAttachment((numInRow * MAX_PERCENT) / nbInRow, -STANDARD_BUTTON_WIDTH);
lastControlUsed = addButton(subComposite, param, lastControlUsed, numInRow, nbInRow, top);
}
return lastControlUsed;
}
use of org.eclipse.swt.widgets.Control in project tdi-studio-se by Talend.
the class PropertyTypeController method addButton.
/**
*
* DOC wzhang Comment method "addButton".
*
* @param subComposite
* @param param
* @param lastControl
* @param numInRow
* @param top
* @return
*/
private Control addButton(Composite subComposite, final IElementParameter param, Control lastControl, int numInRow, int top) {
Button button;
Button resetBtn = null;
Control lastControlUsed = lastControl;
Point buttonSize;
FormData data;
// if (!createFile) {
//$NON-NLS-1$
button = getWidgetFactory().createButton(subComposite, "", SWT.PUSH);
buttonSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT);
button.setImage(ImageProvider.getImage(EImage.SAVE_ICON));
//$NON-NLS-1$
button.setToolTipText(Messages.getString("PropertyTypeController.saveToMetadata"));
button.setData(PARAMETER_NAME, param.getName());
button.setEnabled(!param.isReadOnly());
if (!param.isReadOnly()) {
if (param.getFieldType() == EParameterFieldType.PROPERTY_TYPE) {
button.setEnabled(ExtractMetaDataUtils.getInstance().haveLoadMetadataNode());
}
}
lastControlUsed = button;
button.addSelectionListener(listenerSelection);
//$NON-NLS-1$
CLabel labelLabel = getWidgetFactory().createCLabel(subComposite, "");
data = new FormData();
data.left = new FormAttachment(lastControl, 0);
data.right = new FormAttachment(lastControl, labelLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).x + (ITabbedPropertyConstants.HSPACE * 2), SWT.RIGHT);
if (resetBtn != null) {
data.top = new FormAttachment(resetBtn, 0, SWT.CENTER);
} else {
data.top = new FormAttachment(0, top);
}
labelLabel.setLayoutData(data);
if (numInRow != 1) {
labelLabel.setAlignment(SWT.RIGHT);
}
data = new FormData();
data.left = new FormAttachment(labelLabel, -1);
data.right = new FormAttachment(labelLabel, STANDARD_BUTTON_WIDTH, SWT.RIGHT);
if (resetBtn != null) {
data.top = new FormAttachment(resetBtn, 0, SWT.CENTER);
} else {
data.top = new FormAttachment(0, top);
}
data.height = STANDARD_HEIGHT - 2;
button.setLayoutData(data);
int buttonHeight = buttonSize.y + ITabbedPropertyConstants.VSPACE;
if (dynamicProperty.getCurRowSize() < buttonHeight) {
dynamicProperty.setCurRowSize(buttonHeight);
}
// }
return lastControlUsed;
}
Aggregations