Search in sources :

Example 1 with ChangeConnTextCommand

use of org.talend.designer.core.ui.editor.cmd.ChangeConnTextCommand in project tdi-studio-se by Talend.

the class ConnTextEditPolicy method getDirectEditCommand.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.eclipse.gef.editpolicies.DirectEditPolicy#getDirectEditCommand(org.eclipse.gef.requests.DirectEditRequest)
     */
protected Command getDirectEditCommand(DirectEditRequest edit) {
    String labelText = (String) edit.getCellEditor().getValue();
    ConnLabelEditPart labelPart = (ConnLabelEditPart) getHost();
    Connection connec = (Connection) getHost().getParent().getModel();
    // if the user enter the same name as the current connection, we just ignore it.
    if (!connec.getName().equalsIgnoreCase(labelText)) {
        if (!ConnectionManager.canRename(connec.getSource(), connec.getTarget(), connec.getLineStyle(), labelText)) {
            //$NON-NLS-1$
            String message = Messages.getString("ConnectionCreateAction.errorCreateConnectionName", labelText);
            MessageDialog.openError(getHost().getViewer().getControl().getShell(), Messages.getString("ConnTextEditPolicy.ErrorTitle"), //$NON-NLS-1$
            message);
            return null;
        } else {
            final IMetadataTable metadataTable = connec.getMetadataTable();
            if (connec.getSource() != null && connec.getSource().getComponent() != null && metadataTable != null) {
                IComponent comp = connec.getSource().getComponent();
                if ("tMap".equals(comp.getName()) && metadataTable.getTableName().endsWith("ErrorReject")) {
                    //$NON-NLS-1$//$NON-NLS-1$
                    MessageDialog.openInformation(getHost().getViewer().getControl().getShell(), "Infor", "Can't rename tMap ErrorReject");
                    return null;
                }
            }
        }
    }
    ChangeConnTextCommand command = new ChangeConnTextCommand((Connection) labelPart.getParent().getModel(), labelText);
    return command;
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) ChangeConnTextCommand(org.talend.designer.core.ui.editor.cmd.ChangeConnTextCommand) IComponent(org.talend.core.model.components.IComponent)

Aggregations

IComponent (org.talend.core.model.components.IComponent)1 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)1 ChangeConnTextCommand (org.talend.designer.core.ui.editor.cmd.ChangeConnTextCommand)1