use of org.talend.designer.xmlmap.dnd.CreateNodeConnectionRequest in project tdi-studio-se by Talend.
the class DragAndDropEditPolicy method getCommand.
@Override
public Command getCommand(Request request) {
if (request instanceof CreateNodeConnectionRequest) {
CreateNodeConnectionRequest rq = (CreateNodeConnectionRequest) request;
EditPart targetEditPart = rq.getTargetEditPart();
Command command = null;
if (targetEditPart != null && TemplateTransfer.getInstance().getObject() instanceof TransferedObject) {
TransferedObject toDrop = (TransferedObject) TemplateTransfer.getInstance().getObject();
MapperManager manager = ((XmlMapGraphicViewer) targetEditPart.getViewer()).getMapperManager();
if (manager != null && manager.getExternalData() != null) {
DropType dropType = rq.getNewObjectType();
if (dropType != null) {
switch(dropType) {
case DROP_FILTER:
if (targetEditPart instanceof MapperTablePart) {
command = new UpdateFilterExpressionCommand(toDrop, (MapperTablePart) targetEditPart, manager.getExternalData());
}
break;
case DROP_EXPRESSION:
if (targetEditPart instanceof TableEntityPart) {
command = new UpdateExpressionCommand(toDrop, (TableEntityPart) targetEditPart, manager);
}
break;
case DROP_OUTPUT_DOC_CHILD:
if (targetEditPart instanceof OutputTreeNodeEditPart && rq.getNewObject() instanceof OutputTreeNode) {
command = new CreateDocChildrenCommand(toDrop, (OutputTreeNodeEditPart) targetEditPart, rq, manager);
}
break;
case DROP_INSERT_OUTPUT:
case DROP_INSERT_VAR:
case DROP_INSERT_INPUT:
command = new InsertNewColumnCommand(toDrop, targetEditPart, rq, manager, dropType);
default:
break;
}
}
}
}
if (command != null) {
return command;
}
// drop expression
// boolean update = rq.getDropType() == CreateNodeConnectionRequest.DROP_EXPRESSION ? true : false;
// return new CreateNodeAndConnectionCommand(rq.getNewObject(), rq.getTargetEditPart(), update);
}
return super.getCommand(request);
}
use of org.talend.designer.xmlmap.dnd.CreateNodeConnectionRequest in project tdi-studio-se by Talend.
the class DragAndDropEditPolicy method eraseTargetFeedback.
@Override
public void eraseTargetFeedback(Request request) {
if (indicator != null) {
if (request instanceof CreateNodeConnectionRequest) {
CreateNodeConnectionRequest rq = (CreateNodeConnectionRequest) request;
AbstractGraphicalEditPart targetEditPart = (AbstractGraphicalEditPart) rq.getTargetEditPart();
if (targetEditPart != null && getFeedbackLayer() != null && indicator.getParent() == getFeedbackLayer()) {
try {
getFeedbackLayer().remove(indicator);
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
}
}
}
use of org.talend.designer.xmlmap.dnd.CreateNodeConnectionRequest in project tdi-studio-se by Talend.
the class DragAndDropEditPolicy method showTargetFeedback.
@Override
public void showTargetFeedback(Request request) {
if (request instanceof CreateNodeConnectionRequest) {
CreateNodeConnectionRequest rq = (CreateNodeConnectionRequest) request;
AbstractGraphicalEditPart targetEditPart = (AbstractGraphicalEditPart) rq.getTargetEditPart();
// show feedback when insert new column
if (rq.getNewObjectType() != null && targetEditPart != null) {
Object model = targetEditPart.getModel();
switch(rq.getNewObjectType()) {
case DROP_INSERT_OUTPUT:
case DROP_INSERT_VAR:
if (model instanceof OutputTreeNode || model instanceof VarNode) {
IFigure targetFigure = targetEditPart.getFigure();
if (targetFigure != null) {
if (indicator == null) {
indicator = new InsertionIndicator();
}
Rectangle copy = targetFigure.getBounds().getCopy();
Rectangle bounds = new Rectangle();
bounds.x = copy.x - 5;
bounds.y = copy.y - 5;
bounds.width = copy.width + 10;
bounds.height = 10;
indicator.setBounds(bounds);
getFeedbackLayer().add(indicator);
}
} else {
if (indicator != null && getFeedbackLayer() != null && indicator.getParent() == getFeedbackLayer()) {
getFeedbackLayer().remove(indicator);
}
}
break;
}
}
}
}
Aggregations