Search in sources :

Example 56 with Command

use of org.eclipse.gef.commands.Command in project tdi-studio-se by Talend.

the class PropertyTypeController method processPattern.

// Added TDQ-13192 20170222
private Command processPattern(IElement elem) {
    CompoundCommand compoundCommand = new CompoundCommand();
    ITDQPatternService service = null;
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ITDQPatternService.class)) {
        service = (ITDQPatternService) GlobalServiceRegister.getDefault().getService(ITDQPatternService.class);
    }
    if (service != null && elem instanceof Node) {
        Node node = (Node) elem;
        //$NON-NLS-1$
        IElementParameter typeParam = node.getElementParameter("TYPE");
        boolean hadSelected = service.selectPattern(typeParam, elem);
        if (hadSelected) {
            // create the command
            //$NON-NLS-1$
            final String showId = (String) node.getElementParameter("PATTERN_ID").getValue();
            compoundCommand = new CompoundCommand();
            Command command = new PropertyChangeCommand(elem, EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), showId);
            compoundCommand.add(command);
            IElementParameter elementParameter = node.getElementParameter(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
            String[] displayName = new String[1];
            //$NON-NLS-1$
            displayName[0] = (String) node.getElementParameter("PATTERN_NAME").getValue();
            elementParameter.setListItemsDisplayName(displayName);
            elementParameter.setListItemsValue(new String[] { showId });
        }
    }
    return compoundCommand;
}
Also used : PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) Command(org.eclipse.gef.commands.Command) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) RepositoryNode(org.talend.repository.model.RepositoryNode) IElementParameter(org.talend.core.model.process.IElementParameter) ITDQPatternService(org.talend.core.ITDQPatternService) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 57 with Command

use of org.eclipse.gef.commands.Command in project tdi-studio-se by Talend.

the class PropertyTypeController method initCDC.

private void initCDC(CompoundCommand cc, ConnectionItem originalConnectionItem) {
    if (!(elem instanceof Node)) {
        return;
    }
    Node node = (Node) elem;
    // ConnectionItem originalConnectionItem = repositoryConnectionItem;
    ConnectionItem connectionItem = originalConnectionItem;
    Connection originalConnection = connectionItem.getConnection();
    Connection connection = connectionItem.getConnection();
    if (node.getComponent().getName().contains("CDC")) {
        // to replace by a flag CDC in component? //$NON-NLS-1$
        if (originalConnectionItem instanceof DatabaseConnectionItem) {
            final DatabaseConnection databaseConnection = (DatabaseConnection) connection;
            CDCConnection cdcConn = databaseConnection.getCdcConns();
            if (cdcConn != null) {
                EList cdcTypes = cdcConn.getCdcTypes();
                if (cdcTypes != null && !cdcTypes.isEmpty()) {
                    CDCType cdcType = (CDCType) cdcTypes.get(0);
                    // replace property by CDC property.
                    String propertyId = cdcType.getLinkDB();
                    try {
                        IRepositoryViewObject object = ProxyRepositoryFactory.getInstance().getLastVersion(propertyId);
                        if (object != null) {
                            if (object.getProperty().getItem() instanceof DatabaseConnectionItem) {
                                DatabaseConnectionItem dbConnItem = (DatabaseConnectionItem) object.getProperty().getItem();
                                // replace connection by CDC connection
                                connectionItem = dbConnItem;
                                connection = dbConnItem.getConnection();
                            }
                        }
                    } catch (PersistenceException e) {
                        ExceptionHandler.process(e);
                    }
                    // set cdc type mode.
                    IElementParameter logModeParam = node.getElementParameter(EParameterName.CDC_TYPE_MODE.getName());
                    if (logModeParam != null) {
                        String cdcTypeMode = ((DatabaseConnection) originalConnection).getCdcTypeMode();
                        Command logModeCmd = new PropertyChangeCommand(node, EParameterName.CDC_TYPE_MODE.getName(), CDCTypeMode.LOG_MODE.getName().equals(cdcTypeMode));
                        cc.add(logModeCmd);
                    }
                    // set lib for as400 so far.
                    //$NON-NLS-1$
                    final String name = "SOURCE_LIB";
                    IElementParameter libParam = node.getElementParameter(name);
                    if (libParam != null) {
                        Object propValue;
                        if (connection.isContextMode() && ContextParameterUtils.isContainContextParam(databaseConnection.getSID())) {
                            propValue = databaseConnection.getSID();
                        } else {
                            propValue = TalendTextUtils.addQuotes(databaseConnection.getSID());
                        }
                        Command libSettingCmd = new PropertyChangeCommand(node, name, propValue);
                        cc.add(libSettingCmd);
                    }
                }
            }
        }
    }
}
Also used : DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) RepositoryNode(org.talend.repository.model.RepositoryNode) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) CDCConnection(org.talend.core.model.metadata.builder.connection.CDCConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) CDCConnection(org.talend.core.model.metadata.builder.connection.CDCConnection) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) EList(org.eclipse.emf.common.util.EList) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) Command(org.eclipse.gef.commands.Command) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) IElementParameter(org.talend.core.model.process.IElementParameter) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) CDCType(org.talend.core.model.metadata.builder.connection.CDCType)

Example 58 with Command

use of org.eclipse.gef.commands.Command in project tdi-studio-se by Talend.

the class DocumentBusinessItemNameEditPart method createDefaultEditPolicies.

/**
     * @generated
     */
protected void createDefaultEditPolicies() {
    super.createDefaultEditPolicies();
    installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
    installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new NonResizableEditPolicy() {

        protected List createSelectionHandles() {
            List handles = new ArrayList();
            NonResizableHandleKit.addMoveHandle((GraphicalEditPart) getHost(), handles);
            return handles;
        }

        public Command getCommand(Request request) {
            return null;
        }

        public boolean understandsRequest(Request request) {
            return false;
        }
    });
}
Also used : LabelDirectEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy) Command(org.eclipse.gef.commands.Command) ArrayList(java.util.ArrayList) Request(org.eclipse.gef.Request) DirectEditRequest(org.eclipse.gef.requests.DirectEditRequest) List(java.util.List) ArrayList(java.util.ArrayList) NonResizableEditPolicy(org.eclipse.gef.editpolicies.NonResizableEditPolicy) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)

Example 59 with Command

use of org.eclipse.gef.commands.Command in project tdi-studio-se by Talend.

the class GearBusinessItemNameEditPart method createDefaultEditPolicies.

/**
     * @generated
     */
protected void createDefaultEditPolicies() {
    super.createDefaultEditPolicies();
    installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
    installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new NonResizableEditPolicy() {

        protected List createSelectionHandles() {
            List handles = new ArrayList();
            NonResizableHandleKit.addMoveHandle((GraphicalEditPart) getHost(), handles);
            return handles;
        }

        public Command getCommand(Request request) {
            return null;
        }

        public boolean understandsRequest(Request request) {
            return false;
        }
    });
}
Also used : LabelDirectEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy) Command(org.eclipse.gef.commands.Command) ArrayList(java.util.ArrayList) Request(org.eclipse.gef.Request) DirectEditRequest(org.eclipse.gef.requests.DirectEditRequest) List(java.util.List) ArrayList(java.util.ArrayList) NonResizableEditPolicy(org.eclipse.gef.editpolicies.NonResizableEditPolicy) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)

Example 60 with Command

use of org.eclipse.gef.commands.Command in project tdi-studio-se by Talend.

the class EllipseBusinessItemNameEditPart method createDefaultEditPolicies.

/**
     * @generated
     */
protected void createDefaultEditPolicies() {
    super.createDefaultEditPolicies();
    installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
    installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new NonResizableEditPolicy() {

        protected List createSelectionHandles() {
            List handles = new ArrayList();
            NonResizableHandleKit.addMoveHandle((GraphicalEditPart) getHost(), handles);
            return handles;
        }

        public Command getCommand(Request request) {
            return null;
        }

        public boolean understandsRequest(Request request) {
            return false;
        }
    });
}
Also used : LabelDirectEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy) Command(org.eclipse.gef.commands.Command) ArrayList(java.util.ArrayList) Request(org.eclipse.gef.Request) DirectEditRequest(org.eclipse.gef.requests.DirectEditRequest) List(java.util.List) ArrayList(java.util.ArrayList) NonResizableEditPolicy(org.eclipse.gef.editpolicies.NonResizableEditPolicy) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)

Aggregations

Command (org.eclipse.gef.commands.Command)100 ArrayList (java.util.ArrayList)38 List (java.util.List)35 PropertyChangeCommand (org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand)35 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)28 IElementParameter (org.talend.core.model.process.IElementParameter)22 Node (org.talend.designer.core.ui.editor.nodes.Node)20 INode (org.talend.core.model.process.INode)17 EditPart (org.eclipse.gef.EditPart)15 CommandStack (org.eclipse.gef.commands.CommandStack)15 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)15 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)14 IGraphicalEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)14 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)13 RepositoryNode (org.talend.repository.model.RepositoryNode)13 RepositoryChangeMetadataCommand (org.talend.designer.core.ui.editor.cmd.RepositoryChangeMetadataCommand)12 Request (org.eclipse.gef.Request)11 NonResizableEditPolicy (org.eclipse.gef.editpolicies.NonResizableEditPolicy)11 DirectEditRequest (org.eclipse.gef.requests.DirectEditRequest)11 LabelDirectEditPolicy (org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy)11