Search in sources :

Example 6 with Relation

use of org.talend.sqlbuilder.erdiagram.ui.nodes.Relation in project tdi-studio-se by Talend.

the class RelationCreateCommand method canExecute.

@Override
public boolean canExecute() {
    if (target != null) {
        if (//$NON-NLS-1$
        source.equals(target) || target.getElementName().equals("*") || source.getTable().equals(target.getTable())) {
            return false;
        }
        List<Relation> relations = this.source.getOutputs();
        for (Relation rel : relations) {
            if (rel.getTarget().equals(target)) {
                return false;
            }
        }
        relations = this.target.getInputs();
        for (Relation rel : relations) {
            if (rel.getSource().equals(source)) {
                return false;
            }
        }
    }
    return true;
}
Also used : Relation(org.talend.sqlbuilder.erdiagram.ui.nodes.Relation)

Example 7 with Relation

use of org.talend.sqlbuilder.erdiagram.ui.nodes.Relation in project tdi-studio-se by Talend.

the class ErDiagramPartFactory method createEditPart.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.EditPartFactory#createEditPart(org.eclipse.gef.EditPart, java.lang.Object)
     */
public EditPart createEditPart(EditPart context, Object model) {
    EditPart part = null;
    if (model instanceof ErDiagram) {
        part = new ErDiagramPart();
    } else if (model instanceof Column) {
        part = new ColumnPart();
    } else if (model instanceof Table) {
        part = new TablePart();
    } else if (model instanceof Relation) {
        part = new RelationPart();
    } else {
        return null;
    }
    // tell the newly created part about the model object
    part.setModel(model);
    return part;
}
Also used : RelationPart(org.talend.sqlbuilder.erdiagram.ui.parts.RelationPart) Relation(org.talend.sqlbuilder.erdiagram.ui.nodes.Relation) Table(org.talend.sqlbuilder.erdiagram.ui.nodes.Table) ErDiagram(org.talend.sqlbuilder.erdiagram.ui.nodes.ErDiagram) Column(org.talend.sqlbuilder.erdiagram.ui.nodes.Column) EditPart(org.eclipse.gef.EditPart) TablePart(org.talend.sqlbuilder.erdiagram.ui.parts.TablePart) ColumnPart(org.talend.sqlbuilder.erdiagram.ui.parts.ColumnPart) ErDiagramPart(org.talend.sqlbuilder.erdiagram.ui.parts.ErDiagramPart)

Aggregations

Relation (org.talend.sqlbuilder.erdiagram.ui.nodes.Relation)7 Column (org.talend.sqlbuilder.erdiagram.ui.nodes.Column)5 Table (org.talend.sqlbuilder.erdiagram.ui.nodes.Table)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 RelationReconnectionCommand (org.talend.sqlbuilder.erdiagram.ui.commands.RelationReconnectionCommand)2 ColumnPart (org.talend.sqlbuilder.erdiagram.ui.parts.ColumnPart)2 ErDiagramPart (org.talend.sqlbuilder.erdiagram.ui.parts.ErDiagramPart)2 TablePart (org.talend.sqlbuilder.erdiagram.ui.parts.TablePart)2 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 CheckBox (org.eclipse.draw2d.CheckBox)1 EditPart (org.eclipse.gef.EditPart)1 Command (org.eclipse.gef.commands.Command)1 ConnectionEditPolicy (org.eclipse.gef.editpolicies.ConnectionEditPolicy)1 ConnectionEndpointEditPolicy (org.eclipse.gef.editpolicies.ConnectionEndpointEditPolicy)1 GroupRequest (org.eclipse.gef.requests.GroupRequest)1 EDatabaseTypeName (org.talend.core.database.EDatabaseTypeName)1 Connection (org.talend.core.model.metadata.builder.connection.Connection)1 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)1