Search in sources :

Example 1 with VarEntityFigure

use of org.talend.designer.gefabstractmap.figures.var.VarEntityFigure in project tdi-studio-se by Talend.

the class SearchZoneMapper method setEntryState.

public void setEntryState(MapperManager mapperManager, EntryState entryState, Figure entry) {
    if (entry != null) {
        if (entry instanceof XmlmapTreeNodeFigure) {
            XmlmapTreeNodeFigure xmlMapTreeNodeFigure = (XmlmapTreeNodeFigure) entry;
            if (xmlMapTreeNodeFigure != null) {
                if (xmlMapTreeNodeFigure.getExpressionFigure() != null && matcher.matches(xmlMapTreeNodeFigure.getExpressionFigure().getText())) {
                    xmlMapTreeNodeFigure.getExpressionFigure().setOpaque(true);
                    xmlMapTreeNodeFigure.getExpressionFigure().setBackgroundColor(entryState.getColor());
                }
                if (xmlMapTreeNodeFigure.getTreeNode() != null && matcher.matches(xmlMapTreeNodeFigure.getTreeNode().getName())) {
                    if (XmlMapUtil.isSubElementOfDocument(xmlMapTreeNodeFigure.getTreeNode())) {
                        if (!xmlMapTreeNodeFigure.getTreeNode().getName().endsWith("(choice)")) {
                            xmlMapTreeNodeFigure.getBranchContent().setOpaque(true);
                            xmlMapTreeNodeFigure.getBranchContent().setBackgroundColor(entryState.getColor());
                        }
                    } else {
                        xmlMapTreeNodeFigure.setOpaque(true);
                        xmlMapTreeNodeFigure.setBackgroundColor(entryState.getColor());
                        xmlMapTreeNodeFigure.setOpaque(false);
                        if (xmlMapTreeNodeFigure.getExpressionFigure() != null && !matcher.matches(xmlMapTreeNodeFigure.getExpressionFigure().getText())) {
                        // xmlMapTreeNodeFigure.getExpressionFigure().setOpaque(true);
                        // xmlMapTreeNodeFigure.getExpressionFigure().setBackgroundColor(EntryState.NONE.getColor());
                        }
                    }
                }
            }
        } else if (entry instanceof VarEntityFigure) {
            VarEntityFigure varEntityFigure = (VarEntityFigure) entry;
            if (varEntityFigure != null) {
                if (varEntityFigure.getExpression() != null && matcher.matches(varEntityFigure.getExpression().getText())) {
                    varEntityFigure.getExpression().setOpaque(true);
                    varEntityFigure.getExpression().setBackgroundColor(entryState.getColor());
                }
                if (varEntityFigure.getVarName() != null && matcher.matches(varEntityFigure.getVarName())) {
                    varEntityFigure.setOpaque(true);
                    varEntityFigure.setBackgroundColor(entryState.getColor());
                    if (varEntityFigure.getExpression() == null || !matcher.matches(varEntityFigure.getExpression().getText())) {
                        varEntityFigure.getExpression().setOpaque(true);
                        varEntityFigure.getExpression().setBackgroundColor(EntryState.NONE.getColor());
                    }
                    varEntityFigure.getTypeFigure().setOpaque(true);
                    varEntityFigure.getTypeFigure().setBackgroundColor(EntryState.NONE.getColor());
                }
            }
        } else if (entry instanceof XmlMapFilterContainer) {
            XmlMapFilterContainer filterText = (XmlMapFilterContainer) entry;
            if (filterText != null && filterText.getTextArea() != null) {
                filterText.getTextArea().setOpaque(true);
                filterText.getTextArea().setBackgroundColor(entryState.getColor());
            }
        }
    }
}
Also used : VarEntityFigure(org.talend.designer.gefabstractmap.figures.var.VarEntityFigure) XmlmapTreeNodeFigure(org.talend.designer.xmlmap.figures.treeNode.XmlmapTreeNodeFigure) XmlMapFilterContainer(org.talend.designer.xmlmap.figures.treesettings.XmlMapFilterContainer)

Example 2 with VarEntityFigure

use of org.talend.designer.gefabstractmap.figures.var.VarEntityFigure in project tdi-studio-se by Talend.

the class RowSelectionEditPolicy method getLocatorFigure.

private IFigure getLocatorFigure(GraphicalEditPart owner) {
    IFigure figure = owner.getFigure();
    if (owner instanceof TableEntityPart) {
        TableEntityFigure treeNodeFigure = (TableEntityFigure) figure;
        // table figure to restrict the width
        MapperTablePart abstractInOutTreePart = MapperUtils.getMapperTablePart((TableEntityPart) owner);
        IFigure parentFigure = ((GraphicalEditPart) abstractInOutTreePart).getFigure();
        Rectangle treeBounds = parentFigure.getBounds();
        Rectangle rowBounds = treeNodeFigure.getElement().getBounds();
        Rectangle treeNodeBounds = figure.getBounds();
        figure = new Figure();
        if (treeBounds.x + 1 != treeNodeBounds.x || treeNodeBounds.width > treeBounds.width) {
            figure.setBounds(new Rectangle(treeBounds.x + 1, treeNodeBounds.y, treeBounds.width - 2, rowBounds.height));
            return figure;
        } else {
            figure.setBounds(owner.getFigure().getBounds().getCopy());
            figure.getBounds().height = rowBounds.height;
            return figure;
        }
    } else if (figure instanceof VarEntityFigure) {
        Rectangle copy = figure.getBounds().getCopy();
        figure = new Figure();
        figure.setBounds(copy);
        return figure;
    }
    return owner.getFigure();
}
Also used : VarEntityFigure(org.talend.designer.gefabstractmap.figures.var.VarEntityFigure) TableEntityPart(org.talend.designer.gefabstractmap.part.TableEntityPart) Rectangle(org.eclipse.draw2d.geometry.Rectangle) MapperTablePart(org.talend.designer.gefabstractmap.part.MapperTablePart) TableEntityFigure(org.talend.designer.gefabstractmap.figures.table.entity.TableEntityFigure) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) IFigure(org.eclipse.draw2d.IFigure) TableEntityFigure(org.talend.designer.gefabstractmap.figures.table.entity.TableEntityFigure) IFigure(org.eclipse.draw2d.IFigure) VarEntityFigure(org.talend.designer.gefabstractmap.figures.var.VarEntityFigure) Figure(org.eclipse.draw2d.Figure)

Example 3 with VarEntityFigure

use of org.talend.designer.gefabstractmap.figures.var.VarEntityFigure in project tdi-studio-se by Talend.

the class VarColumnAnchor method getReferencePoint.

@Override
public Point getReferencePoint() {
    Point ref = null;
    final VarTablePart varTablePart = (VarTablePart) MapperUtils.getMapperTablePart(entityManager.getEditPart());
    if (entityManager.isTableMinimized()) {
        if (isSource) {
            ref = varTablePart.getFigure().getBounds().getRight();
        } else {
            ref = varTablePart.getFigure().getBounds().getLeft();
        }
    } else if (getOwner() instanceof TableTreeEntityFigure) {
        TableTreeEntityFigure nodeFigure = (TableTreeEntityFigure) getOwner();
        // normal column
        if (nodeFigure.getTreeBranch() == null) {
            if (isSource) {
                ref = getOwner().getBounds().getRight();
            } else {
                if (nodeFigure.getElement() != null) {
                    ref = nodeFigure.getElement().getBounds().getLeft();
                } else {
                    ref = getOwner().getBounds().getLeft();
                }
            }
            getOwner().translateToAbsolute(ref);
        }
    } else if (getOwner() instanceof VarEntityFigure) {
        VarEntityFigure varNodeFigure = (VarEntityFigure) getOwner();
        if (isSource) {
            ref = getOwner().getBounds().getRight();
            ref.x = varTablePart.getFigure().getBounds().getRight().x;
        } else {
            if (varNodeFigure.getExpression() != null) {
                ref = varNodeFigure.getExpression().getBounds().getLeft();
            } else {
                ref = getOwner().getBounds().getLeft();
            }
        }
        getOwner().translateToAbsolute(ref);
    } else {
        ref = getOwner().getBounds().getCenter();
        getOwner().translateToAbsolute(ref);
    }
    return ref;
}
Also used : VarEntityFigure(org.talend.designer.gefabstractmap.figures.var.VarEntityFigure) TableTreeEntityFigure(org.talend.designer.gefabstractmap.figures.table.entity.TableTreeEntityFigure) VarTablePart(org.talend.designer.gefabstractmap.part.VarTablePart) Point(org.eclipse.draw2d.geometry.Point)

Example 4 with VarEntityFigure

use of org.talend.designer.gefabstractmap.figures.var.VarEntityFigure in project tdi-studio-se by Talend.

the class VarNodeEditPart method performRequest.

@Override
public void performRequest(Request req) {
    IFigure figure = null;
    Figure selectedFigure = null;
    if (RequestConstants.REQ_DIRECT_EDIT.equals(req.getType())) {
        DirectEditRequest drequest = (DirectEditRequest) req;
        Point figureLocation = drequest.getLocation();
        if (getFigure() instanceof VarEntityFigure) {
            figure = ((VarEntityFigure) getFigure()).findFigureAt(figureLocation);
        }
        // if (figure != null ) {
        if (figure != null) {
            // if (figure instanceof VariableContainerFigure) {
            // figure = ((VariableContainerFigure) figure).getVariableLabel();
            // }
            selectedFigure = (Figure) figure;
            directEditManager = new XmlMapNodeDirectEditManager(this, new XmlMapNodeCellEditorLocator(selectedFigure));
        }
        // }
        if (directEditManager != null) {
            directEditManager.show();
            ((XmlMapGraphicViewer) getViewer()).getMapperManager().setCurrentDirectEditManager(directEditManager);
        }
    }
}
Also used : VarEntityFigure(org.talend.designer.gefabstractmap.figures.var.VarEntityFigure) XmlMapNodeDirectEditManager(org.talend.designer.xmlmap.parts.directedit.XmlMapNodeDirectEditManager) XmlMapNodeCellEditorLocator(org.talend.designer.gefabstractmap.part.directedit.XmlMapNodeCellEditorLocator) DirectEditRequest(org.eclipse.gef.requests.DirectEditRequest) Point(org.eclipse.draw2d.geometry.Point) IFigure(org.eclipse.draw2d.IFigure) IFigure(org.eclipse.draw2d.IFigure) ImageFigure(org.eclipse.draw2d.ImageFigure) VarNodeFigure(org.talend.designer.xmlmap.figures.varnode.VarNodeFigure) VarEntityFigure(org.talend.designer.gefabstractmap.figures.var.VarEntityFigure) Figure(org.eclipse.draw2d.Figure)

Example 5 with VarEntityFigure

use of org.talend.designer.gefabstractmap.figures.var.VarEntityFigure in project tdi-studio-se by Talend.

the class VarNodeEditPart method notifyChanged.

@Override
public void notifyChanged(Notification notification) {
    int type = notification.getEventType();
    int featureId = notification.getFeatureID(XmlmapPackage.class);
    switch(type) {
        case Notification.SET:
            switch(featureId) {
                case XmlmapPackage.VAR_NODE__EXPRESSION:
                    ((VarEntityFigure) getFigure()).getExpression().setText(((VarNode) getModel()).getExpression());
                    break;
                case XmlmapPackage.VAR_NODE__NULLABLE:
                    boolean newBoolean = notification.getNewBooleanValue();
                    ImageFigure checkImage = ((VarEntityFigure) getFigure()).getCheckImage();
                    if (newBoolean) {
                        checkImage.setImage(ImageProvider.getImage(EImage.CHECKED_ICON));
                    } else if (!newBoolean) {
                        checkImage.setImage(ImageProvider.getImage(EImage.UNCHECKED_ICON));
                    }
                    break;
                case XmlmapPackage.VAR_NODE__NAME:
                    ((VarEntityFigure) getFigure()).getVariableLabel().setText(((VarNode) getModel()).getName());
                    break;
                case XmlmapPackage.VAR_NODE__TYPE:
                    ((VarEntityFigure) getFigure()).updateVarNodeType(((VarNode) getModel()).getType(), ((VarNode) getModel()).isNullable());
                    // refreshVisuals();
                    break;
                default:
            }
        case Notification.ADD:
            switch(featureId) {
                case XmlmapPackage.VAR_NODE__INCOMING_CONNECTIONS:
                    refreshTargetConnections();
                    break;
                case XmlmapPackage.VAR_NODE__OUTGOING_CONNECTIONS:
                case XmlmapPackage.VAR_NODE__FILTER_OUT_GOING_CONNECTIONS:
                    refreshSourceConnections();
                    break;
            }
        case Notification.REMOVE:
        case Notification.REMOVE_MANY:
            switch(featureId) {
                case XmlmapPackage.VAR_NODE__INCOMING_CONNECTIONS:
                    refreshTargetConnections();
                    break;
                case XmlmapPackage.VAR_NODE__OUTGOING_CONNECTIONS:
                case XmlmapPackage.VAR_NODE__FILTER_OUT_GOING_CONNECTIONS:
                    refreshSourceConnections();
                    break;
            }
    }
}
Also used : VarEntityFigure(org.talend.designer.gefabstractmap.figures.var.VarEntityFigure) ImageFigure(org.eclipse.draw2d.ImageFigure) Point(org.eclipse.draw2d.geometry.Point)

Aggregations

VarEntityFigure (org.talend.designer.gefabstractmap.figures.var.VarEntityFigure)5 Point (org.eclipse.draw2d.geometry.Point)3 Figure (org.eclipse.draw2d.Figure)2 IFigure (org.eclipse.draw2d.IFigure)2 ImageFigure (org.eclipse.draw2d.ImageFigure)2 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)1 DirectEditRequest (org.eclipse.gef.requests.DirectEditRequest)1 TableEntityFigure (org.talend.designer.gefabstractmap.figures.table.entity.TableEntityFigure)1 TableTreeEntityFigure (org.talend.designer.gefabstractmap.figures.table.entity.TableTreeEntityFigure)1 MapperTablePart (org.talend.designer.gefabstractmap.part.MapperTablePart)1 TableEntityPart (org.talend.designer.gefabstractmap.part.TableEntityPart)1 VarTablePart (org.talend.designer.gefabstractmap.part.VarTablePart)1 XmlMapNodeCellEditorLocator (org.talend.designer.gefabstractmap.part.directedit.XmlMapNodeCellEditorLocator)1 XmlmapTreeNodeFigure (org.talend.designer.xmlmap.figures.treeNode.XmlmapTreeNodeFigure)1 XmlMapFilterContainer (org.talend.designer.xmlmap.figures.treesettings.XmlMapFilterContainer)1 VarNodeFigure (org.talend.designer.xmlmap.figures.varnode.VarNodeFigure)1 XmlMapNodeDirectEditManager (org.talend.designer.xmlmap.parts.directedit.XmlMapNodeDirectEditManager)1