use of org.eclipse.gef.EditPart in project tdi-studio-se by Talend.
the class XmlDropTargetListener method selectAddedObject.
private void selectAddedObject() {
boolean added = false;
List newObjects = getCreateRequest().getNewObjects();
for (int i = 0; i < newObjects.size(); i++) {
Object model = newObjects.get(i);
EditPartViewer viewer = getViewer();
viewer.getControl().forceFocus();
Object editpart = viewer.getEditPartRegistry().get(model);
if (editpart instanceof EditPart) {
if (!added) {
// Force a layout first.
getViewer().flush();
viewer.select((EditPart) editpart);
added = true;
} else {
viewer.appendSelection((EditPart) editpart);
}
}
}
}
use of org.eclipse.gef.EditPart 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));
}
}
}
}
});
}
}
}
use of org.eclipse.gef.EditPart in project tdi-studio-se by Talend.
the class ErDiagramPartFactory method createEditPart.
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.EditPartFactory#createEditPart(org.eclipse.gef.EditPart, java.lang.Object)
*/
public EditPart createEditPart(EditPart context, Object model) {
EditPart part = null;
if (model instanceof ErDiagram) {
part = new ErDiagramPart();
} else if (model instanceof Column) {
part = new ColumnPart();
} else if (model instanceof Table) {
part = new TablePart();
} else if (model instanceof Relation) {
part = new RelationPart();
} else {
return null;
}
// tell the newly created part about the model object
part.setModel(model);
return part;
}
use of org.eclipse.gef.EditPart in project tdi-studio-se by Talend.
the class VarToolBarFigure method removeVar.
@Override
protected void removeVar() {
CommandStack commandStack = getTableManager().getGraphicalViewer().getEditDomain().getCommandStack();
commandStack.execute(new Command() {
@Override
public void execute() {
List selectedEditParts = getTableManager().getGraphicalViewer().getSelectedEditParts();
final List<VarNode> toRemove = new ArrayList<VarNode>();
int minIndex = parentTable.getNodes().size() - 1;
for (Object obj : selectedEditParts) {
if (obj instanceof VarNodeEditPart) {
VarNode model = (VarNode) ((VarNodeEditPart) obj).getModel();
toRemove.add(model);
XmlMapUtil.detachNodeConnections(model, (XmlMapData) parentTable.eContainer(), true);
int index = parentTable.getNodes().indexOf(model);
if (index < minIndex) {
minIndex = index;
}
}
}
parentTable.getNodes().removeAll(toRemove);
if (!tablePart.getChildren().isEmpty()) {
if (minIndex > tablePart.getChildren().size() - 1) {
minIndex = tablePart.getChildren().size() - 1;
}
tablePart.getViewer().select((EditPart) tablePart.getChildren().get(minIndex));
} else {
remove.setEnabled(false);
}
}
});
}
use of org.eclipse.gef.EditPart in project tdi-studio-se by Talend.
the class VarToolBarFigure method addVar.
@Override
protected void addVar() {
CommandStack commandStack = getTableManager().getGraphicalViewer().getEditDomain().getCommandStack();
commandStack.execute(new Command() {
@Override
public void execute() {
VarNode newNode = XmlmapFactory.eINSTANCE.createVarNode();
newNode.setType(XmlMapUtil.DEFAULT_DATA_TYPE);
newNode.setName(XmlMapUtil.findUniqueVarColumnName("Var", parentTable));
parentTable.getNodes().add(newNode);
parentTable.setMinimized(false);
EditPart toSelect = null;
int index = parentTable.getNodes().indexOf(newNode);
if (index < tablePart.getChildren().size()) {
toSelect = (EditPart) tablePart.getChildren().get(index);
tablePart.getViewer().select(toSelect);
}
if (!remove.isEnabled()) {
remove.setEnabled(true);
}
}
});
}
Aggregations