use of org.eclipse.swt.events.ModifyEvent in project tdi-studio-se by Talend.
the class XmlMapNodeDirectEditManager method initCellEditor.
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.tools.DirectEditManager#initCellEditor()
*/
@Override
protected void initCellEditor() {
DirectEditType directEditType = cellAndType.get(getCellEditor());
if (model instanceof AbstractNode) {
final AbstractNode abstractNode = (AbstractNode) model;
if (directEditType != null) {
switch(directEditType) {
case EXPRESSION:
String expression = abstractNode.getExpression() == null ? "" : abstractNode.getExpression();
getCellEditor().setValue(expression);
Text text = ((ExtendedTextCellEditor) getCellEditor()).getTextControl();
text.selectAll();
break;
case NODE_NAME:
String variable = abstractNode.getName();
if (variable == null) {
variable = "";
}
getCellEditor().setValue(variable);
final Text nametext = (Text) ((TextCellEditor) getCellEditor()).getControl();
nametext.selectAll();
if (model instanceof VarNode) {
nametext.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
List<VarNode> children = new ArrayList<VarNode>();
children.addAll(((VarTable) abstractNode.eContainer()).getNodes());
children.remove(model);
String message = XmlMapUtil.isValidColumnName(children, ((Text) e.widget).getText());
if (message != null) {
nametext.setBackground(ColorConstants.red);
} else {
nametext.setBackground(ColorConstants.white);
}
}
});
}
break;
case VAR_NODE_TYPE:
if (getCellEditor() instanceof ComboBoxCellEditor) {
CCombo combo = (CCombo) getCellEditor().getControl();
combo.setText(getTypeDisplayValue((VarNode) abstractNode));
}
break;
}
}
} else if (model instanceof InputXmlTree) {
InputXmlTree inputxmlTree = (InputXmlTree) model;
if (directEditType != null) {
switch(directEditType) {
case EXPRESSION_FILTER:
String expressionFilter = inputxmlTree.getExpressionFilter();
if (expressionFilter == null) {
expressionFilter = "";
}
getCellEditor().setValue(expressionFilter);
Text textarea = ((ExtendedTextCellEditor) getCellEditor()).getTextControl();
textarea.selectAll();
break;
case LOOKUP_MODEL:
if (getCellEditor() instanceof ComboBoxCellEditor) {
CCombo combo = (CCombo) getCellEditor().getControl();
combo.setText(getLookupDisplayName(inputxmlTree.getLookupMode()));
}
break;
case MATCH_MODEL:
if (getCellEditor() instanceof ComboBoxCellEditor) {
CCombo combo = (CCombo) getCellEditor().getControl();
combo.setText(getMatchModelDisplayName(inputxmlTree.getMatchingMode()));
}
break;
case JOIN_MODEL:
if (getCellEditor() instanceof ComboBoxCellEditor) {
CCombo combo = (CCombo) getCellEditor().getControl();
String join = "";
if (inputxmlTree.isInnerJoin()) {
join = joinModel[0];
} else {
join = joinModel[1];
}
combo.setText(join);
}
break;
case PERSISTENT_MODEL:
if (getCellEditor() instanceof ComboBoxCellEditor) {
CCombo combo = (CCombo) getCellEditor().getControl();
combo.setText(String.valueOf(inputxmlTree.isPersistent()));
}
break;
}
}
} else if (model instanceof OutputXmlTree) {
OutputXmlTree outputTree = (OutputXmlTree) model;
if (directEditType != null) {
switch(directEditType) {
case EXPRESSION_FILTER:
String expressionFilter = outputTree.getExpressionFilter();
if (expressionFilter == null) {
expressionFilter = "";
}
getCellEditor().setValue(expressionFilter);
Text textarea = ((ExtendedTextCellEditor) getCellEditor()).getTextControl();
textarea.selectAll();
break;
case OUTPUT_REJECT:
if (getCellEditor() instanceof ComboBoxCellEditor) {
CCombo combo = (CCombo) getCellEditor().getControl();
combo.setText(String.valueOf(outputTree.isReject()));
}
break;
case LOOK_UP_INNER_JOIN_REJECT:
if (getCellEditor() instanceof ComboBoxCellEditor) {
CCombo combo = (CCombo) getCellEditor().getControl();
combo.setText(String.valueOf(outputTree.isRejectInnerJoin()));
}
break;
case ALL_IN_ONE:
if (getCellEditor() instanceof ComboBoxCellEditor) {
CCombo combo = (CCombo) getCellEditor().getControl();
combo.setText(String.valueOf(outputTree.isAllInOne()));
}
break;
case ENABLE_EMPTY_ELEMENT:
if (getCellEditor() instanceof ComboBoxCellEditor) {
CCombo combo = (CCombo) getCellEditor().getControl();
combo.setText(String.valueOf(outputTree.isEnableEmptyElement()));
}
}
}
} else if (model instanceof XmlMapData) {
XmlMapData xmlMapData = (XmlMapData) model;
if (directEditType != null) {
switch(directEditType) {
case SERACH:
Text text = (Text) getCellEditor().getControl();
text.selectAll();
break;
}
}
}
}
use of org.eclipse.swt.events.ModifyEvent in project tdi-studio-se by Talend.
the class MavenVersionManagementProjectSettingPage method addItemElements.
@Override
protected void addItemElements(List<ItemVersionObject> elements) {
if (elements == null || elements.isEmpty()) {
return;
}
itemTable.setRedraw(false);
for (final ItemVersionObject object : elements) {
final TableItem tableItem = new TableItem(itemTable, SWT.CENTER);
tableItem.setData(object);
Item item = object.getItem();
IBaseLabelProvider labelProvider = treeViewer.getLabelProvider();
Image itemsImage = null;
if (labelProvider instanceof NavigatorDecoratingLabelProvider) {
NavigatorDecoratingLabelProvider navigatorProvider = (NavigatorDecoratingLabelProvider) labelProvider;
itemsImage = navigatorProvider.getImage(object.getRepositoryNode());
} else {
ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(item);
itemsImage = getItemsImage(CoreImageProvider.getIcon(itemType));
}
tableItem.setImage(itemsImage);
tableItem.setText(item.getProperty().getLabel());
// old version
tableItem.setText(1, MavenVersionUtils.getItemMavenVersion(item.getProperty()));
TableEditor versionEditor = null;
if (fixedVersionButton.getSelection()) {
tableItem.setText(2, appliedFixedVersion);
} else if (useJobVersionButton.getSelection()) {
String jobDefaultVersion = MavenVersionUtils.getDefaultVersion(item.getProperty().getVersion());
tableItem.setText(2, jobDefaultVersion);
object.setNewVersion(jobDefaultVersion);
} else {
// new version
versionEditor = new TableEditor(itemTable);
Composite versionComposite = new Composite(itemTable, SWT.NONE);
GridLayout layout = new GridLayout(1, false);
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.marginLeft = 0;
layout.marginRight = 1;
versionComposite.setLayout(layout);
final Text text = new Text(versionComposite, SWT.CENTER | SWT.BORDER);
GridData data = new GridData(GridData.FILL_BOTH);
text.setLayoutData(data);
String newVersion = object.getNewVersion();
if (newVersion == null || "".equals(newVersion.trim())) {
//$NON-NLS-1$
newVersion = appliedFixedVersion;
object.setNewVersion(newVersion);
}
text.setText(newVersion);
checkVersionPattern(text, newVersion);
text.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
String version = text.getText();
checkVersionPattern(text, version);
object.setNewVersion(version);
checkValid();
}
});
versionEditor.minimumWidth = itemTable.getColumn(2).getWidth();
versionEditor.setEditor(versionComposite, tableItem, 2);
}
TableEditor delEditor = new TableEditor(itemTable);
Label delLabel = new Label(itemTable, SWT.CENTER);
delLabel.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
delLabel.setImage(ImageProvider.getImage(EImage.DELETE_ICON));
//$NON-NLS-1$
delLabel.setToolTipText(Messages.getString("VersionManagementDialog.DeletedTip"));
delLabel.pack();
delLabel.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
checkedObjects.remove(object);
removeTableItem(tableItem);
refreshCheckedTreeView();
checkButtonsState();
checkButtonsState(false);
}
});
delEditor.minimumWidth = 25;
delEditor.horizontalAlignment = SWT.CENTER;
delEditor.setEditor(delLabel, tableItem, 3);
if (fixedVersionButton.getSelection() || useJobVersionButton.getSelection()) {
tableItem.setData(ITEM_EDITOR_KEY, new TableEditor[] { delEditor });
} else if (versionEditor != null) {
tableItem.setData(ITEM_EDITOR_KEY, new TableEditor[] { versionEditor, delEditor });
}
itemTable.setRedraw(true);
}
}
use of org.eclipse.swt.events.ModifyEvent in project tdi-studio-se by Talend.
the class MavenVersionManagementProjectSettingPage method addItemsOption.
@Override
protected void addItemsOption(Composite parent) {
Group option = new Group(parent, SWT.NONE);
option.setLayout(new GridLayout());
//$NON-NLS-1$
option.setText(Messages.getString("VersionManagementDialog.Options"));
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).applyTo(option);
fixedVersionButton = new Button(option, SWT.RADIO);
//$NON-NLS-1$
fixedVersionButton.setText(Messages.getString("VersionManagementDialog.FixedVersion"));
// default
fixedVersionButton.setSelection(true);
Composite versionComposit = new Composite(option, SWT.NONE);
GridLayout layout = new GridLayout(8, false);
layout.horizontalSpacing = 1;
layout.verticalSpacing = 0;
layout.marginHeight = 0;
layout.marginWidth = 0;
versionComposit.setLayout(layout);
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.BEGINNING).applyTo(versionComposit);
fixedVersionText = new Text(versionComposit, SWT.BORDER);
GridData data = new GridData();
data.widthHint = 120;
data.minimumWidth = 80;
data.horizontalIndent = 20;
fixedVersionText.setLayoutData(data);
fixedVersionText.setText(MavenVersionUtils.DEFAULT_MAVEN_VERSION);
applyVersionButton = new Button(versionComposit, SWT.NONE);
//$NON-NLS-1$
applyVersionButton.setText(Messages.getString("VersionManagementDialog.applyVersion"));
subjobs = new Button(versionComposit, SWT.NONE);
//$NON-NLS-1$
subjobs.setText(Messages.getString("VersionManagementDialog.subjob"));
subjobs.setEnabled(false);
eachVersionButton = new Button(option, SWT.RADIO);
//$NON-NLS-1$
eachVersionButton.setText(Messages.getString("VersionManagementDialog.EachVersion"));
useJobVersionButton = new Button(option, SWT.RADIO);
//$NON-NLS-1$
useJobVersionButton.setText(Messages.getString("VersionManagementDialog.useJobVersion"));
// event
fixedVersionButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
fixedVersionText.setEnabled(fixedVersionButton.getSelection());
applyVersionButton.setEnabled(fixedVersionButton.getSelection());
refreshTableItems();
}
});
fixedVersionText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
String version = fixedVersionText.getText();
if (MavenVersionUtils.isValidMavenVersion(version)) {
applyVersionButton.setEnabled(true);
fixedVersionText.setBackground(COLOR_WHITE);
//$NON-NLS-1$
fixedVersionText.setToolTipText("");
} else {
applyVersionButton.setEnabled(false);
fixedVersionText.setBackground(COLOR_RED);
//$NON-NLS-1$
fixedVersionText.setToolTipText(Messages.getString("VersionManagementDialog.valueWarning"));
}
}
});
applyVersionButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String version = fixedVersionText.getText();
if (version != null && !"".equals(version.trim())) {
//$NON-NLS-1$
appliedFixedVersion = version;
refreshTableItems();
}
}
});
subjobs.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
selectSubjob();
}
});
eachVersionButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
refreshTableItems();
}
});
useJobVersionButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
refreshTableItems();
}
});
}
use of org.eclipse.swt.events.ModifyEvent in project tdi-studio-se by Talend.
the class StatusDialog method createDialogArea.
/*
* (non-Javadoc) Method declared on Dialog.
*/
@Override
protected Control createDialogArea(Composite parent) {
// create composite
Composite composite = (Composite) super.createDialogArea(parent);
// create message
// if (message != null) {
// Label label = new Label(composite, SWT.WRAP);
// label.setText(message);
// GridData data = new GridData(GridData.GRAB_HORIZONTAL
// | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL
// | GridData.VERTICAL_ALIGN_CENTER);
// data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
// label.setLayoutData(data);
// label.setFont(parent.getFont());
// }
GridLayout layout = new GridLayout();
layout.numColumns = 3;
composite.setLayout(layout);
Label label1 = new Label(composite, SWT.None);
//$NON-NLS-1$
label1.setText(Messages.getString("StatusDialog.labelText.code"));
// label.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
GridData data = new GridData(GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER);
label1.setLayoutData(data);
label1.setFont(parent.getFont());
codeText = new Text(composite, SWT.SINGLE | SWT.BORDER);
data = new GridData();
data.widthHint = convertHorizontalDLUsToPixels(30);
codeText.setLayoutData(data);
codeText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
validateInput();
}
});
label1 = new Label(composite, SWT.WRAP);
data = new GridData(GridData.FILL_HORIZONTAL);
label1.setLayoutData(data);
label1 = new Label(composite, SWT.WRAP);
//$NON-NLS-1$
label1.setText(Messages.getString("StatusDialog.labelText.label"));
label1.setFont(parent.getFont());
labelText = new Text(composite, SWT.SINGLE | SWT.BORDER);
data = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
data.horizontalSpan = 2;
labelText.setLayoutData(data);
labelText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
validateInput();
}
});
errorMessageText = new Label(composite, SWT.NONE);
errorMessageText.setLayoutData(data);
errorMessageText.setBackground(errorMessageText.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
applyDialogFont(composite);
return composite;
}
use of org.eclipse.swt.events.ModifyEvent 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;
}
Aggregations