use of org.talend.designer.xmlmap.ui.dialog.PropertySetDialog in project tdi-studio-se by Talend.
the class XmlMapInputZoneToolBar method changProperty.
/*
* (non-Javadoc)
*
* @see org.talend.designer.newabstractmap.figures.treetools.zone.InputZoneTooBar#changProperty()
*/
@Override
public void changProperty() {
boolean dieOnError = mapperManger.isDieOnError();
PropertySetDialog propertySet = new PropertySetDialog(null, dieOnError);
if (propertySet.open() == Window.OK) {
if (graphicViewer != null && propertySet.isValueChanged()) {
final boolean newValue = !dieOnError;
CommandStack commandStack = graphicViewer.getEditDomain().getCommandStack();
commandStack.execute(new Command() {
@Override
public void execute() {
mapperManger.setDieOnError(newValue);
if (newValue) {
if (!externalData.getOutputTrees().isEmpty()) {
OutputXmlTree outputTree = externalData.getOutputTrees().get(0);
if (outputTree.isErrorReject()) {
// mapperComponent.getMetadataList().add(metadataTable);
externalData.getOutputTrees().remove(0);
mapperComponent.getProcess().removeUniqueConnectionName(outputTree.getName());
removeMetadataTableByName(outputTree.getName());
if (!externalData.getOutputTrees().isEmpty()) {
int indexOf = externalPart.getModelChildren().indexOf(externalData.getOutputTrees().get(0));
if (indexOf != -1) {
graphicViewer.select((EditPart) externalPart.getChildren().get(indexOf));
}
}
}
}
} else {
boolean hasRejectTable = false;
if (!externalData.getOutputTrees().isEmpty()) {
OutputXmlTree outputTree = externalData.getOutputTrees().get(0);
if (outputTree.isErrorReject()) {
hasRejectTable = true;
}
}
if (!hasRejectTable) {
String baseName = MapperManager.ERROR_REJECT;
IProcess process = mapperComponent.getProcess();
String tableName = baseName;
if (!process.checkValidConnectionName(baseName) && process instanceof IProcess2) {
final String uniqueName = ((IProcess2) process).generateUniqueConnectionName("row", baseName);
tableName = uniqueName;
((IProcess2) process).addUniqueConnectionName(uniqueName);
} else if (process instanceof IProcess2) {
tableName = baseName;
((IProcess2) process).addUniqueConnectionName(baseName);
}
OutputXmlTree outputXmlTree = XmlmapFactory.eINSTANCE.createOutputXmlTree();
outputXmlTree.setErrorReject(true);
outputXmlTree.setName(tableName);
externalData.getOutputTrees().add(0, outputXmlTree);
MetadataTable metadataTable = new MetadataTable();
metadataTable.setLabel(tableName);
metadataTable.setTableName(tableName);
MetadataColumn errorMessageCol = new MetadataColumn();
errorMessageCol.setLabel(MapperManager.ERROR_REJECT_MESSAGE);
errorMessageCol.setTalendType(DesignerPlugin.getDefault().getPreferenceStore().getString(MetadataTypeLengthConstants.FIELD_DEFAULT_TYPE));
errorMessageCol.setNullable(true);
errorMessageCol.setOriginalDbColumnName(MapperManager.ERROR_REJECT_MESSAGE);
errorMessageCol.setReadOnly(true);
errorMessageCol.setCustom(true);
metadataTable.getListColumns().add(errorMessageCol);
MetadataColumn errorStackTrace = new MetadataColumn();
errorStackTrace.setLabel(MapperManager.ERROR_REJECT_STACK_TRACE);
errorStackTrace.setTalendType(DesignerPlugin.getDefault().getPreferenceStore().getString(MetadataTypeLengthConstants.FIELD_DEFAULT_TYPE));
errorStackTrace.setNullable(true);
errorStackTrace.setOriginalDbColumnName(MapperManager.ERROR_REJECT_STACK_TRACE);
errorStackTrace.setReadOnly(true);
errorStackTrace.setCustom(true);
metadataTable.getListColumns().add(errorStackTrace);
mapperComponent.getMetadataList().add(metadataTable);
OutputTreeNode errorMessageNode = XmlmapFactory.eINSTANCE.createOutputTreeNode();
errorMessageNode.setName(MapperManager.ERROR_REJECT_MESSAGE);
errorMessageNode.setType(errorMessageCol.getTalendType());
errorMessageNode.setNullable(true);
outputXmlTree.getNodes().add(errorMessageNode);
OutputTreeNode errorStackTraceNode = XmlmapFactory.eINSTANCE.createOutputTreeNode();
errorStackTraceNode.setName(MapperManager.ERROR_REJECT_STACK_TRACE);
errorStackTraceNode.setType(errorStackTrace.getTalendType());
errorStackTraceNode.setNullable(true);
outputXmlTree.getNodes().add(errorStackTraceNode);
int indexOf = externalPart.getModelChildren().indexOf(outputXmlTree);
if (indexOf != -1) {
graphicViewer.select((EditPart) externalPart.getChildren().get(indexOf));
}
}
}
}
});
}
}
}
Aggregations