use of org.talend.designer.xmlmap.ui.tabs.MapperManager 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.ui.tabs.MapperManager in project tdi-studio-se by Talend.
the class XmlMapFilterContainer method addButtonListener.
@Override
protected void addButtonListener() {
IService expressionBuilderDialogService = GlobalServiceRegister.getDefault().getService(IExpressionBuilderDialogService.class);
final IExpressionBuilderDialogController dialog = ((IExpressionBuilderDialogService) expressionBuilderDialogService).getExpressionBuilderInstance(parent, null, null);
button.addMouseListener(new MouseListener() {
@Override
public void mousePressed(MouseEvent me) {
if (dialog instanceof TrayDialog) {
TrayDialog parentDialog = (TrayDialog) dialog;
// if press the button ,should apply ExpressionCellEditor value
MapperManager mapperManger = (MapperManager) tableManager.getMapperManger();
mapperManger.fireCurrentDirectEditApply();
dialog.setDefaultExpression(tableManager.getExpressionFilter());
if (Window.OK == parentDialog.open()) {
String expressionForTable = dialog.getExpressionForTable();
tableManager.setExpressionFilter(expressionForTable);
tableManager.getEditPart().getViewer().getEditDomain().getCommandStack().execute(getFilterChangeCommand(tableManager.getModel(), expressionForTable));
}
}
}
@Override
public void mouseReleased(MouseEvent me) {
// TODO Auto-generated method stub
}
@Override
public void mouseDoubleClicked(MouseEvent me) {
// TODO Auto-generated method stub
}
});
}
use of org.talend.designer.xmlmap.ui.tabs.MapperManager in project tdi-studio-se by Talend.
the class XmlMapOutputZoneToolBar method addTable.
/*
* (non-Javadoc)
*
* @see org.talend.designer.newabstractmap.figures.treetools.zone.OutputZoneToolBar#addTable()
*/
@Override
protected void addTable() {
final OutputXmlTree createOutputXmlTree = XmlmapFactory.eINSTANCE.createOutputXmlTree();
CommandStack commandStack = externalPart.getViewer().getEditDomain().getCommandStack();
commandStack.execute(new Command() {
@Override
public void execute() {
if (externalPart.getViewer() instanceof XmlMapGraphicViewer) {
XmlMapGraphicViewer viewer = (XmlMapGraphicViewer) externalPart.getViewer();
MapperManager manager = viewer.getMapperManager();
String outputName = manager.getMapperUI().openNewOutputCreationDialog();
if (outputName == null) {
return;
}
createOutputXmlTree.setName(outputName);
externalData.getOutputTrees().add(createOutputXmlTree);
MetadataTable metadataTable = new MetadataTable();
metadataTable.setLabel(outputName);
metadataTable.setTableName(outputName);
mapperComponent.getMetadataList().add(metadataTable);
mapperComponent.getProcess().addUniqueConnectionName(outputName);
int indexOf = externalPart.getModelChildren().indexOf(createOutputXmlTree);
if (indexOf != -1) {
externalPart.getViewer().select((EditPart) externalPart.getChildren().get(indexOf));
}
if (!min_size.isEnabled()) {
min_size.setEnabled(true);
}
// check problem for created output incase input main is multiloop
mapperManger.getProblemsAnalyser().checkProblems(createOutputXmlTree);
mapperManger.getMapperUI().updateStatusBar();
}
}
});
}
use of org.talend.designer.xmlmap.ui.tabs.MapperManager in project tdi-studio-se by Talend.
the class XmlDropTargetListener method handleDrop.
@Override
protected void handleDrop() {
final Object object = TemplateTransfer.getInstance().getObject();
if (object == null || !(object instanceof TransferedObject)) {
return;
}
updateTargetRequest();
updateTargetEditPart();
DropContextAnalyzer analyzer = new DropContextAnalyzer((TransferedObject) object, (AbstractGraphicalEditPart) getTargetEditPart(), getDropLocation());
if (analyzer.isDropValid()) {
NodeType selectedNodeType = NodeType.ELEMENT;
DropType dropType = analyzer.getDropType();
if (dropType == DropType.DROP_OUTPUT_DOC_CHILD && getTargetEditPart() instanceof OutputTreeNodeEditPart) {
OutputTreeNode targetOutputNode = (OutputTreeNode) ((OutputTreeNodeEditPart) getTargetEditPart()).getModel();
Shell shell = getViewer().getControl().getShell();
// if allNamespace , create output as namespace , if allsubTree , create output subtree , no need prompt
boolean needPrompt = false;
boolean hasSubTree = false;
for (Object o : ((TransferedObject) object).getToTransfer()) {
if (o instanceof VarNodeEditPart) {
needPrompt = true;
} else if (o instanceof TreeNodeEditPart) {
TreeNode treeNode = (TreeNode) ((TreeNodeEditPart) o).getModel();
if (NodeType.ATTRIBUT.equals(treeNode.getNodeType())) {
needPrompt = true;
}
if (NodeType.ELEMENT.equals(treeNode.getNodeType())) {
if (treeNode.getChildren().isEmpty()) {
needPrompt = true;
} else {
hasSubTree = true;
}
}
}
}
if (needPrompt) {
DragAndDrogDialog selectDialog = new DragAndDrogDialog(shell, !targetOutputNode.getChildren().isEmpty());
int open = selectDialog.open();
if (open == Window.OK) {
if (DragAndDrogDialog.CREATE_AS_SUBELEMENT.equals(selectDialog.getSelectValue())) {
selectedNodeType = NodeType.ELEMENT;
} else if (DragAndDrogDialog.CREATE_AS_ATTRIBUTE.equals(selectDialog.getSelectValue())) {
selectedNodeType = NodeType.ATTRIBUT;
} else if (DragAndDrogDialog.CREATE_AS_SUBELEMENT.equals(selectDialog.getSelectValue())) {
selectedNodeType = NodeType.NAME_SPACE;
} else if (DragAndDrogDialog.CREATE_AS_TEXT.equals(selectDialog.getSelectValue())) {
dropType = DropType.DROP_EXPRESSION;
}
} else {
return;
}
}
if (dropType != DropType.DROP_EXPRESSION) {
if (!targetOutputNode.getIncomingConnections().isEmpty() && ((selectedNodeType != NodeType.ATTRIBUT && selectedNodeType != NodeType.NAME_SPACE) || hasSubTree)) {
boolean canContinue = MessageDialog.openConfirm(null, "Warning", "Do you want to disconnect the existing linker and then add an sub element for the selected element ?");
if (canContinue) {
MapperManager mapperManager = ((XmlMapGraphicViewer) getViewer()).getMapperManager();
if (mapperManager != null && mapperManager.getExternalData() != null) {
XmlMapUtil.detachNodeConnections(targetOutputNode, mapperManager.getExternalData(), false);
}
} else {
return;
}
}
}
}
NewNodeCreationFactory factory = new NewNodeCreationFactory(dropType, selectedNodeType);
getCreateRequest().setFactory(factory);
}
if (getTargetEditPart() != null) {
Command command = getCommand();
if (command != null && command.canExecute()) {
getViewer().getEditDomain().getCommandStack().execute(command);
} else {
getCurrentEvent().detail = DND.DROP_NONE;
}
} else {
getCurrentEvent().detail = DND.DROP_NONE;
}
selectAddedObject();
}
Aggregations