Search in sources :

Example 6 with VarTable

use of org.talend.designer.xmlmap.model.emf.xmlmap.VarTable in project tdi-studio-se by Talend.

the class DropContextAnalyzer method checkDropIsValid.

private boolean checkDropIsValid() {
    if (objects == null || objects.getToTransfer().isEmpty() || targetEditPart == null) {
        return false;
    }
    Object targetModel = targetEditPart.getModel();
    targetFigure = targetEditPart.getFigure().findFigureAt(dropLocation.x, dropLocation.y);
    boolean isTragetOutputNode = targetModel instanceof OutputTreeNode;
    boolean isTragetInputNode = targetModel instanceof TreeNode && !(targetModel instanceof OutputTreeNode);
    boolean isVar = targetModel instanceof VarNode;
    boolean isDropInputTree = targetModel instanceof InputXmlTree;
    boolean isDropOutputTree = targetModel instanceof OutputXmlTree;
    boolean isDropVarTable = targetModel instanceof VarTable;
    // drop expression
    if (targetFigure instanceof ExpressionFigure) {
        dropType = DropType.DROP_EXPRESSION;
        if (isTragetOutputNode) {
            // INPUT => OUTPUT
            return XmlMapUtil.isExpressionEditable((TreeNode) targetModel);
        } else if (isTragetInputNode) {
            // INPUT => INPUT ,can't dnd in the same tree
            boolean isValid = checkDropInputValid(targetModel);
            if (isValid) {
                isValid = XmlMapUtil.isExpressionEditable((TreeNode) targetModel);
            }
            return isValid;
        }
        return true;
    } else // drop tree filter
    if (targetFigure instanceof FilterTextArea) {
        dropType = DropType.DROP_FILTER;
        return true;
    } else {
        if (objects.getType() == TransferdType.INPUT) {
            if (isTragetOutputNode) {
                return checkDropOutputDocChildValid(targetModel);
            } else if (isVar || isDropVarTable) {
                dropType = DropType.DROP_INSERT_VAR;
                return true;
            } else if (isDropInputTree) {
                dropType = DropType.DROP_INSERT_INPUT;
                return checkDropInputValid(targetModel);
            } else if (isDropOutputTree) {
                dropType = DropType.DROP_INSERT_OUTPUT;
                return true;
            }
        } else if (objects.getType() == TransferdType.VAR) {
            if (isTragetOutputNode) {
                return checkDropOutputDocChildValid(targetModel);
            } else if (isDropOutputTree) {
                dropType = DropType.DROP_INSERT_OUTPUT;
                return true;
            }
        }
    }
    return false;
}
Also used : VarNode(org.talend.designer.xmlmap.model.emf.xmlmap.VarNode) InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) VarTable(org.talend.designer.xmlmap.model.emf.xmlmap.VarTable) ExpressionFigure(org.talend.designer.gefabstractmap.figures.ExpressionFigure) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) TransferedObject(org.talend.designer.gefabstractmap.dnd.TransferedObject) FilterTextArea(org.talend.designer.gefabstractmap.figures.treesettings.FilterTextArea) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree)

Example 7 with VarTable

use of org.talend.designer.xmlmap.model.emf.xmlmap.VarTable in project tdi-studio-se by Talend.

the class MapperUI method createWindow.

public Shell createWindow(final Display display) {
    Shell activeShell = display.getActiveShell();
    int style = SWT.DIALOG_TRIM | SWT.MIN | SWT.MAX | SWT.APPLICATION_MODAL | SWT.RESIZE;
    if (activeShell == null) {
        mapperShell = new Shell(mapperShell, style);
    } else {
        mapperShell = new Shell(activeShell, style);
    }
    mapperShell.addShellListener(new ShellListener() {

        @Override
        public void shellActivated(ShellEvent e) {
        }

        @Override
        public void shellClosed(ShellEvent e) {
            if (editor != null && editor.isDirty() && !closeWithoutPrompt) {
                boolean closeWindow = MessageDialog.openConfirm(mapperShell, "Close without save", Messages.getString("MapperUI.CloseWindow.Message"));
                if (!closeWindow) {
                    e.doit = false;
                } else {
                    prepareClosing(SWT.CANCEL);
                }
            }
        }

        @Override
        public void shellDeactivated(ShellEvent e) {
        }

        @Override
        public void shellDeiconified(ShellEvent e) {
        }

        @Override
        public void shellIconified(ShellEvent e) {
        }
    });
    mapperShell.setMaximized(true);
    mapperShell.setImage(CoreImageProvider.getComponentIcon(mapperComponent.getComponent(), ICON_SIZE.ICON_32));
    IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
    String productName = brandingService.getFullProductName();
    mapperShell.setText(productName + " - " + mapperComponent.getComponent().getName() + " - " + //$NON-NLS-1$
    mapperComponent.getUniqueName());
    GridLayout parentLayout = new GridLayout(1, true);
    mapperShell.setLayout(parentLayout);
    // Composite composite = new Composite(mapperShell, SWT.NONE);
    // composite.setBackground(display.getSystemColor(SWT.COLOR_YELLOW));
    mainSashForm = new SashForm(mapperShell, SWT.SMOOTH | SWT.VERTICAL);
    GridData mainSashFormGridData = new GridData(GridData.FILL_BOTH);
    mainSashForm.setLayoutData(mainSashFormGridData);
    datasViewSashForm = new SashForm(mainSashForm, SWT.SMOOTH | SWT.HORIZONTAL | SWT.BORDER);
    editor = new XmlMapEditor(mapperManager);
    editor.createPartControl(datasViewSashForm);
    if (copyOfMapData.getVarTables().isEmpty()) {
        VarTable varTable1 = XmlmapFactory.eINSTANCE.createVarTable();
        varTable1.setName("Var");
        varTable1.setMinimized(true);
        copyOfMapData.getVarTables().add(varTable1);
    }
    editor.setContent(copyOfMapData);
    tabFolderEditors = new TabFolderEditors(mainSashForm, mapperManager, SWT.BORDER);
    // selectFirstInOutTree();
    mainSashForm.setWeights(new int[] { 70, 30 });
    footerComposite = new FooterComposite(mapperShell, this);
    footerComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    mapperShell.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            ColorProviderMapper.releaseColors();
            FontProviderMapper.releaseFonts();
            ImageProviderMapper.releaseImages();
        }
    });
    editor.makeDefaultSelection();
    mapperShell.open();
    return mapperShell;
}
Also used : TabFolderEditors(org.talend.designer.xmlmap.ui.tabs.TabFolderEditors) DisposeListener(org.eclipse.swt.events.DisposeListener) FooterComposite(org.talend.designer.xmlmap.ui.footer.FooterComposite) ShellEvent(org.eclipse.swt.events.ShellEvent) IBrandingService(org.talend.core.ui.branding.IBrandingService) DisposeEvent(org.eclipse.swt.events.DisposeEvent) XmlMapEditor(org.talend.designer.xmlmap.editor.XmlMapEditor) VarTable(org.talend.designer.xmlmap.model.emf.xmlmap.VarTable) SashForm(org.eclipse.swt.custom.SashForm) Shell(org.eclipse.swt.widgets.Shell) GridLayout(org.eclipse.swt.layout.GridLayout) ShellListener(org.eclipse.swt.events.ShellListener) GridData(org.eclipse.swt.layout.GridData)

Example 8 with VarTable

use of org.talend.designer.xmlmap.model.emf.xmlmap.VarTable 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;
            }
        }
    }
}
Also used : VarNode(org.talend.designer.xmlmap.model.emf.xmlmap.VarNode) ModifyListener(org.eclipse.swt.events.ModifyListener) AbstractNode(org.talend.designer.xmlmap.model.emf.xmlmap.AbstractNode) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) Text(org.eclipse.swt.widgets.Text) ExtendedTextCellEditor(org.talend.commons.ui.runtime.swt.tableviewer.celleditor.ExtendedTextCellEditor) VarTable(org.talend.designer.xmlmap.model.emf.xmlmap.VarTable) InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) ModifyEvent(org.eclipse.swt.events.ModifyEvent) DirectEditType(org.talend.designer.gefabstractmap.part.directedit.DirectEditType) CCombo(org.eclipse.swt.custom.CCombo) List(java.util.List) ArrayList(java.util.ArrayList) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree) XmlMapData(org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)

Example 9 with VarTable

use of org.talend.designer.xmlmap.model.emf.xmlmap.VarTable in project tdi-studio-se by Talend.

the class XmlMapVarTablePart method createFigure.

@Override
protected IFigure createFigure() {
    /* Center var figure */
    VarTable model = (VarTable) getModel();
    VarTableManager manager = new VarTableManager(model, this);
    centerVarFigure = new VarTableContainer(manager);
    return centerVarFigure;
}
Also used : VarTable(org.talend.designer.xmlmap.model.emf.xmlmap.VarTable) VarTableManager(org.talend.designer.xmlmap.figures.table.VarTableManager) VarTableContainer(org.talend.designer.xmlmap.figures.VarTableContainer)

Example 10 with VarTable

use of org.talend.designer.xmlmap.model.emf.xmlmap.VarTable in project tdi-studio-se by Talend.

the class XmlMapComponent method checkNeededRoutines.

@Override
public List<String> checkNeededRoutines(List<String> possibleRoutines, String additionalString) {
    List<String> routinesToAdd = new ArrayList<String>();
    XmlMapData xmlMapData = (XmlMapData) getExternalEmfData();
    for (String routine : possibleRoutines) {
        List<OutputXmlTree> listOutput = xmlMapData.getOutputTrees();
        for (OutputXmlTree outTable : listOutput) {
            List<OutputTreeNode> listOutEntry = outTable.getNodes();
            if (listOutEntry != null && !listOutEntry.isEmpty()) {
                for (OutputTreeNode outEntry : listOutEntry) {
                    String expression = outEntry.getExpression();
                    if (expression != null && !routinesToAdd.contains(routine) && expression.contains(routine + additionalString)) {
                        routinesToAdd.add(routine);
                    }
                }
            }
            String filter = outTable.getExpressionFilter();
            if (filter != null && !routinesToAdd.contains(routine) && filter.contains(routine + additionalString)) {
                routinesToAdd.add(routine);
            }
        }
        List<InputXmlTree> listInput = xmlMapData.getInputTrees();
        for (InputXmlTree inputTable : listInput) {
            List<TreeNode> listInEntry = inputTable.getNodes();
            if (listInEntry != null && !listInEntry.isEmpty()) {
                for (TreeNode inEntry : listInEntry) {
                    String expression = inEntry.getExpression();
                    if (expression != null && !routinesToAdd.contains(routine) && expression.contains(routine + additionalString)) {
                        routinesToAdd.add(routine);
                    }
                }
            }
            String filter = inputTable.getExpressionFilter();
            if (filter != null && !routinesToAdd.contains(routine) && filter.contains(routine + additionalString)) {
                routinesToAdd.add(routine);
            }
        }
        List<VarTable> listVar = xmlMapData.getVarTables();
        for (VarTable varTable : listVar) {
            List<VarNode> listVarEntry = varTable.getNodes();
            if (listVarEntry != null && !listVarEntry.isEmpty()) {
                for (VarNode varEntry : listVarEntry) {
                    String expression = varEntry.getExpression();
                    if (expression != null && !routinesToAdd.contains(routine) && expression.contains(routine + additionalString)) {
                        routinesToAdd.add(routine);
                    }
                }
            }
        }
    }
    return routinesToAdd;
}
Also used : VarNode(org.talend.designer.xmlmap.model.emf.xmlmap.VarNode) ArrayList(java.util.ArrayList) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) VarTable(org.talend.designer.xmlmap.model.emf.xmlmap.VarTable) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree) XmlMapData(org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)

Aggregations

VarTable (org.talend.designer.xmlmap.model.emf.xmlmap.VarTable)16 VarNode (org.talend.designer.xmlmap.model.emf.xmlmap.VarNode)13 TreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)12 OutputTreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)11 InputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree)9 OutputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree)9 AbstractNode (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractNode)7 TransferedObject (org.talend.designer.gefabstractmap.dnd.TransferedObject)6 TreeNodeEditPart (org.talend.designer.xmlmap.parts.TreeNodeEditPart)6 VarNodeEditPart (org.talend.designer.xmlmap.parts.VarNodeEditPart)6 FilterConnection (org.talend.designer.xmlmap.model.emf.xmlmap.FilterConnection)5 XmlMapData (org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)5 Connection (org.talend.designer.xmlmap.model.emf.xmlmap.Connection)4 AbstractInOutTree (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree)3 OutputTreeNodeEditPart (org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Shell (org.eclipse.swt.widgets.Shell)2 IConnection (org.talend.designer.xmlmap.model.emf.xmlmap.IConnection)2 LookupConnection (org.talend.designer.xmlmap.model.emf.xmlmap.LookupConnection)2