Search in sources :

Example 1 with TalendCreateConnectionTool

use of org.talend.designer.core.ui.action.TalendCreateConnectionTool in project tdi-studio-se by Talend.

the class TalendConnectionHandle method createDragTracker.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.handles.AbstractHandle#createDragTracker()
     */
@Override
protected DragTracker createDragTracker() {
    if (this.mainConnector == null) {
        this.mainConnector = new NodeConnectorTool(nodePart).getConnector();
    }
    if (this.mainConnector == null) {
        return null;
    }
    final List<Object> listArgs = new ArrayList<Object>();
    listArgs.add(null);
    listArgs.add(null);
    listArgs.add(null);
    TalendCreateConnectionTool myConnectTool = new TalendCreateConnectionTool(new CreationFactory() {

        @Override
        public Object getNewObject() {
            return listArgs;
        }

        @Override
        public Object getObjectType() {
            // should get the connector at realtime
            mainConnector = new NodeConnectorTool(nodePart).getConnector();
            if (mainConnector == null) {
                // if no connector is available, maybe can return "on componnet ok" connector to avoid NPE
                Node node = (Node) nodePart.getModel();
                mainConnector = node.getConnectorFromType(EConnectionType.ON_COMPONENT_OK);
                // specify the connection name
                listArgs.set(1, mainConnector.getLinkName());
            } else {
                // no need to specify the connection name
                listArgs.set(1, null);
            }
            return mainConnector.getName();
        }
    }, nodePart);
    return myConnectTool;
}
Also used : TalendCreateConnectionTool(org.talend.designer.core.ui.action.TalendCreateConnectionTool) Node(org.talend.designer.core.ui.editor.nodes.Node) ArrayList(java.util.ArrayList) CreationFactory(org.eclipse.gef.requests.CreationFactory)

Aggregations

ArrayList (java.util.ArrayList)1 CreationFactory (org.eclipse.gef.requests.CreationFactory)1 TalendCreateConnectionTool (org.talend.designer.core.ui.action.TalendCreateConnectionTool)1 Node (org.talend.designer.core.ui.editor.nodes.Node)1