Search in sources :

Example 1 with MapperTable

use of org.talend.designer.gefabstractmap.model.abstractmap.MapperTable in project tdi-studio-se by Talend.

the class XmlMapTableTree method createColumns.

@Override
protected void createColumns() {
    layoutManager.setAjustToTableWidth(false);
    // table column title
    MapperTable xmlTree = tableModelManager.getModel();
    boolean hasExpression = false;
    if (xmlTree instanceof InputXmlTree) {
        InputXmlTree inputTree = (InputXmlTree) xmlTree;
        if (inputTree.isLookup()) {
            expressionColumn = new TableColumn(ColumnKeyConstant.KEY_EXPRESSION);
            expressionColumn.setText("Exp.key");
            this.addColumn(expressionColumn);
            columnSash = new ColumnSash(this);
            columnSash.setLeftColumn(expressionColumn);
            this.addSeparator(columnSash);
            hasExpression = true;
        }
    } else {
        expressionColumn = new TableColumn(ColumnKeyConstant.KEY_EXPRESSION);
        expressionColumn.setText("Expression");
        this.addColumn(expressionColumn);
        columnSash = new ColumnSash(this);
        columnSash.setLeftColumn(expressionColumn);
        this.addSeparator(columnSash);
        hasExpression = true;
    }
    nameColumn = new TableColumn(ColumnKeyConstant.KEY_NAME);
    nameColumn.setText("Column");
    if (columnSash != null) {
        columnSash.setRightColumn(nameColumn);
    }
    this.addColumn(nameColumn);
    if (hasExpression) {
        layoutManager.setWeight(0, 0.5);
    }
}
Also used : InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) MapperTable(org.talend.designer.gefabstractmap.model.abstractmap.MapperTable) ColumnSash(org.talend.designer.gefabstractmap.figures.table.ColumnSash) TableColumn(org.talend.designer.gefabstractmap.figures.table.TableColumn)

Example 2 with MapperTable

use of org.talend.designer.gefabstractmap.model.abstractmap.MapperTable in project tdi-studio-se by Talend.

the class XmlMapFiguresManager method getInputTables.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.designer.newabstractmap.figures.manager.FiguresManager#getInputTables()
     */
@Override
protected List<MapperTable> getInputTables() {
    List<MapperTable> inputTables = new ArrayList<MapperTable>();
    XmlMapData mapData = (XmlMapData) getRootEditPart().getModel();
    inputTables.addAll(mapData.getInputTrees());
    return inputTables;
}
Also used : MapperTable(org.talend.designer.gefabstractmap.model.abstractmap.MapperTable) ArrayList(java.util.ArrayList) XmlMapData(org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)

Example 3 with MapperTable

use of org.talend.designer.gefabstractmap.model.abstractmap.MapperTable in project tdi-studio-se by Talend.

the class XmlMapFiguresManager method getOutputTables.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.designer.newabstractmap.figures.manager.FiguresManager#getOutputTables()
     */
@Override
protected List<MapperTable> getOutputTables() {
    List<MapperTable> outputTables = new ArrayList<MapperTable>();
    XmlMapData mapData = (XmlMapData) getRootEditPart().getModel();
    outputTables.addAll(mapData.getOutputTrees());
    return outputTables;
}
Also used : MapperTable(org.talend.designer.gefabstractmap.model.abstractmap.MapperTable) ArrayList(java.util.ArrayList) XmlMapData(org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)

Example 4 with MapperTable

use of org.talend.designer.gefabstractmap.model.abstractmap.MapperTable in project tdi-studio-se by Talend.

the class FiguresManager method selectionChanged.

@Override
public void selectionChanged(SelectionChangedEvent event) {
    mapDataEditPart = (MapperRootEditPart) graphicViewer.getContents();
    if (getRootEditPart() == null) {
        return;
    }
    List selectedEditParts = graphicViewer.getSelectedEditParts();
    if (selectedEditParts.isEmpty()) {
        return;
    }
    boolean outputRemoveEnable = false;
    boolean outputMoveUp = false;
    boolean outputMoveDown = false;
    boolean inputMoveUp = false;
    boolean inputMoveDown = false;
    List<MapperTable> outputTrees = getOutputTables();
    List<MapperTable> inputTrees = getInputTables();
    OutputZoneToolBar outputToolBar = mapDataEditPart.getOutputZoneToolBar();
    InputZoneToolBar inputToolBar = mapDataEditPart.getInputZoneToolBar();
    boolean selectNode = false;
    Object lastSelection = selectedEditParts.get(selectedEditParts.size() - 1);
    if (lastSelection instanceof TableEntityPart) {
        selectNode = true;
        MapperTablePart findTreePart = MapperUtils.getMapperTablePart((TableEntityPart) lastSelection);
        if (findTreePart instanceof InputTablePart) {
            currentSelectedInputTable = (InputTablePart) findTreePart;
        } else if (findTreePart instanceof OutputTablePart) {
            currentSelectedOutputTable = (OutputTablePart) findTreePart;
        }
        // only change connection figures for nodes in the same tree as the lastSelection
        List<TableEntityPart> nodes = new ArrayList<TableEntityPart>();
        for (int i = 0; i < selectedEditParts.size() - 1; i++) {
            Object obj = selectedEditParts.get(i);
            if (obj instanceof TableEntityPart) {
                MapperTablePart findOtherTreePart = MapperUtils.getMapperTablePart((TableEntityPart) obj);
                if (findOtherTreePart == findTreePart) {
                    nodes.add((TableEntityPart) obj);
                }
            }
        }
        nodes.add((TableEntityPart) lastSelection);
        onTreeSelected(nodes, findTreePart);
    // change color for other unselected node in the tree;
    } else if (lastSelection instanceof OutputTablePart) {
        currentSelectedOutputTable = (OutputTablePart) lastSelection;
        onTreeSelected(currentSelectedOutputTable.getChildren(), currentSelectedOutputTable);
    } else if (lastSelection instanceof InputTablePart) {
        currentSelectedInputTable = (InputTablePart) lastSelection;
        onTreeSelected(currentSelectedInputTable.getChildren(), currentSelectedInputTable);
    }
    if (currentSelectedOutputTable != null) {
        MapperTable model = (MapperTable) currentSelectedOutputTable.getModel();
        if (!isErrorRejectTable(model)) {
            outputRemoveEnable = true;
        }
        int index = outputTrees.indexOf(model);
        if (index != -1 && index != 0) {
            if (index != 1 || !isErrorRejectTable(outputTrees.get(0))) {
                outputMoveUp = true;
            }
        }
        if (index != -1 && index != outputTrees.size() - 1) {
            if (!isErrorRejectTable(model)) {
                outputMoveDown = true;
            }
        }
    }
    outputToolBar.setRemoveButtonEnable(outputRemoveEnable);
    outputToolBar.setMoveUpEnable(outputMoveUp);
    outputToolBar.setMoveDownEnable(outputMoveDown);
    if (currentSelectedInputTable != null) {
        MapperTable tree = (MapperTable) currentSelectedInputTable.getModel();
        if (!isLookup(tree)) {
            inputMoveUp = false;
            inputMoveDown = false;
        } else {
            int indexOf = inputTrees.indexOf(tree);
            if (indexOf != -1 && indexOf > 1) {
                inputMoveUp = true;
            }
            if (indexOf > 0 && indexOf != inputTrees.size() - 1) {
                inputMoveDown = true;
            }
        }
    }
    inputToolBar.setMoveDownEnable(inputMoveDown);
    inputToolBar.setMoveUpEnable(inputMoveUp);
}
Also used : OutputTablePart(org.talend.designer.gefabstractmap.part.OutputTablePart) OutputZoneToolBar(org.talend.designer.gefabstractmap.figures.treetools.zone.OutputZoneToolBar) TableEntityPart(org.talend.designer.gefabstractmap.part.TableEntityPart) ArrayList(java.util.ArrayList) MapperTablePart(org.talend.designer.gefabstractmap.part.MapperTablePart) InputTablePart(org.talend.designer.gefabstractmap.part.InputTablePart) InputZoneToolBar(org.talend.designer.gefabstractmap.figures.treetools.zone.InputZoneToolBar) MapperTable(org.talend.designer.gefabstractmap.model.abstractmap.MapperTable) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

MapperTable (org.talend.designer.gefabstractmap.model.abstractmap.MapperTable)4 ArrayList (java.util.ArrayList)3 XmlMapData (org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)2 List (java.util.List)1 ColumnSash (org.talend.designer.gefabstractmap.figures.table.ColumnSash)1 TableColumn (org.talend.designer.gefabstractmap.figures.table.TableColumn)1 InputZoneToolBar (org.talend.designer.gefabstractmap.figures.treetools.zone.InputZoneToolBar)1 OutputZoneToolBar (org.talend.designer.gefabstractmap.figures.treetools.zone.OutputZoneToolBar)1 InputTablePart (org.talend.designer.gefabstractmap.part.InputTablePart)1 MapperTablePart (org.talend.designer.gefabstractmap.part.MapperTablePart)1 OutputTablePart (org.talend.designer.gefabstractmap.part.OutputTablePart)1 TableEntityPart (org.talend.designer.gefabstractmap.part.TableEntityPart)1 InputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree)1