use of org.talend.designer.gefabstractmap.part.directedit.DirectEditType 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.talend.designer.gefabstractmap.part.directedit.DirectEditType in project tdi-studio-se by Talend.
the class XmlMapNodeDirectEditManager method commit.
@Override
public void commit() {
DirectEditType directEditType = cellAndType.get(getCellEditor());
if (directEditType != null) {
switch(directEditType) {
case SERACH:
VarNodeTextLabel figure = null;
if (this.locator instanceof XmlMapNodeCellEditorLocator) {
XmlMapNodeCellEditorLocator lo = (XmlMapNodeCellEditorLocator) locator;
if (lo.getFigure() != null && lo.getFigure() instanceof VarNodeTextLabel) {
figure = (VarNodeTextLabel) lo.getFigure();
Object searchTextObject = getDirectEditRequest().getCellEditor().getValue();
if (searchTextObject != null) {
if (figure.getParent() != null && figure.getParent() instanceof XmlMapSearchZoneToolBar) {
XmlMapSearchZoneToolBar searchZone = (XmlMapSearchZoneToolBar) figure.getParent();
searchZone.search(searchTextObject.toString());
figure.setText(searchTextObject.toString());
}
}
}
}
}
}
super.commit();
}
use of org.talend.designer.gefabstractmap.part.directedit.DirectEditType in project tdi-studio-se by Talend.
the class XmlDirectEditPolicy method getDirectEditCommand.
@Override
protected Command getDirectEditCommand(DirectEditRequest request) {
Command command = null;
CellEditor editor = request.getCellEditor();
Object directEditFeature = request.getDirectEditFeature();
if (directEditFeature instanceof DirectEditType) {
DirectEditType type = (DirectEditType) directEditFeature;
if (getHost().getModel() instanceof AbstractNode) {
AbstractNode model = (AbstractNode) getHost().getModel();
switch(type) {
case EXPRESSION:
case NODE_NAME:
command = new DirectEditCommand(getHost(), model, type, request.getCellEditor().getValue());
break;
case VAR_NODE_TYPE:
if (editor instanceof ComboBoxCellEditor) {
ComboBoxCellEditor combo = (ComboBoxCellEditor) editor;
int selectIndex = (Integer) combo.getValue();
command = new DirectEditCommand(getHost(), model, type, combo.getItems()[selectIndex]);
}
break;
case LOOKUP_MODEL:
case MATCH_MODEL:
case JOIN_MODEL:
case PERSISTENT_MODEL:
case OUTPUT_REJECT:
case LOOK_UP_INNER_JOIN_REJECT:
if (editor instanceof ComboBoxCellEditor) {
ComboBoxCellEditor combo = (ComboBoxCellEditor) editor;
int selectIndex = (Integer) combo.getValue();
command = new TreeSettingDirectEditCommand(model, type, combo.getItems()[selectIndex]);
}
break;
case EXPRESSION_FILTER:
if (editor instanceof TextCellEditor) {
command = new TreeSettingDirectEditCommand(model, type, request.getCellEditor().getValue());
}
default:
break;
}
} else {
switch(type) {
case LOOKUP_MODEL:
case MATCH_MODEL:
case JOIN_MODEL:
case PERSISTENT_MODEL:
case OUTPUT_REJECT:
case LOOK_UP_INNER_JOIN_REJECT:
case ALL_IN_ONE:
case ENABLE_EMPTY_ELEMENT:
if ((editor instanceof ComboBoxCellEditor)) {
ComboBoxCellEditor combo = (ComboBoxCellEditor) editor;
int selectIndex = (Integer) combo.getValue();
command = new TreeSettingDirectEditCommand(getHost().getModel(), type, combo.getItems()[selectIndex]);
}
break;
case EXPRESSION_FILTER:
command = new TreeSettingDirectEditCommand(getHost().getModel(), type, request.getCellEditor().getValue());
}
}
}
return command;
}
Aggregations