Search in sources :

Example 81 with RepositoryNode

use of org.talend.repository.model.RepositoryNode in project tdi-studio-se by Talend.

the class SQLBuilderDialog method close.

@Override
public boolean close() {
    try {
        SqlBuilderPlugin.getDefault().getRepositoryService().removeRepositoryChangedListener(this);
        if (this.nodeInEditor != null) {
            RepositoryNode root = SQLBuilderRepositoryNodeManager.getRoot(this.nodeInEditor);
            if (root != null) {
                DatabaseConnection connection = (DatabaseConnection) ((ConnectionItem) root.getObject().getProperty().getItem()).getConnection();
                shutDownDb(connection);
            }
        }
        clean();
        SQLBuilderRepositoryNodeManager.removeAllRepositoryNodes();
    } catch (Exception e) {
        ExceptionHandler.process(e);
    } finally {
        super.close();
    }
    return true;
}
Also used : DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) InvocationTargetException(java.lang.reflect.InvocationTargetException) SQLException(java.sql.SQLException)

Example 82 with RepositoryNode

use of org.talend.repository.model.RepositoryNode in project tesb-studio-se by Talend.

the class RunCamelProcess method doRun.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
protected void doRun() {
    ISelection selection = getSelection();
    Object obj = ((IStructuredSelection) selection).getFirstElement();
    if (!(obj instanceof RepositoryNode)) {
        return;
    }
    // Add this job to running history list.
    JobLaunchShortcutManager.run(selection);
}
Also used : ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) BinRepositoryNode(org.talend.repository.model.BinRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode)

Example 83 with RepositoryNode

use of org.talend.repository.model.RepositoryNode in project tesb-studio-se by Talend.

the class CamelEditorDropTargetListener method checkSelectionSource.

/**
     * Routelet and context types are validated
     * 
     * @return true if validated
     */
private boolean checkSelectionSource() {
    isContextSource = false;
    selectSourceList.clear();
    boolean isRouteletSource = false;
    LocalSelectionTransfer transfer = (LocalSelectionTransfer) getTransfer();
    IStructuredSelection selection = (IStructuredSelection) transfer.getSelection();
    Iterator iterator = selection.iterator();
    while (iterator.hasNext()) {
        Object obj = iterator.next();
        if (obj instanceof RepositoryNode) {
            RepositoryNode sourceNode = (RepositoryNode) obj;
            if (sourceNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.PROCESS_ROUTELET) {
                selectSourceList.add(obj);
                isRouteletSource = true;
            }
            Item item = sourceNode.getObject().getProperty().getItem();
            if (item instanceof ContextItem) {
                selectSourceList.add(obj);
                isContextSource = true;
            }
        } else if (obj instanceof PaletteEditPart) {
            selectSourceList.add(obj);
            Object newObject = ((CreateRequest) getTargetRequest()).getNewObject();
            if (newObject != null && newObject instanceof INode) {
                if (((INode) newObject).getComponent().getComponentType() == EComponentType.JOBLET) {
                    selectSourceList.add(newObject);
                    isRouteletSource = true;
                }
            }
        }
    }
    if (selectSourceList.size() == 0) {
        return false;
    }
    if (isRouteletSource) {
        List<String> routeletList = new ArrayList<String>();
        for (INode node : editor.getProcess().getGraphicalNodes()) {
            if (node.getComponent().getComponentType() == EComponentType.JOBLET) {
                routeletList.add(node.getComponent().getName());
            }
        }
        boolean isDuplicateRoutelet = false;
        String duplicatesName = "";
        for (Object object : selectSourceList) {
            if (object instanceof RepositoryNode) {
                RepositoryNode sourceNode = (RepositoryNode) object;
                if (sourceNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.PROCESS_ROUTELET) {
                    if (routeletList.contains(sourceNode.getProperties(EProperties.LABEL))) {
                        isDuplicateRoutelet = true;
                        //$NON-NLS-1$
                        duplicatesName += " ," + sourceNode.getProperties(EProperties.LABEL);
                    }
                }
            } else if (object instanceof INode) {
                INode node = (INode) object;
                if (node.getComponent().getComponentType() == EComponentType.JOBLET) {
                    if (routeletList.contains(node.getComponent().getName())) {
                        isDuplicateRoutelet = true;
                        //$NON-NLS-1$                            
                        duplicatesName += " ," + node.getComponent().getName();
                    }
                }
            }
        }
        if (isDuplicateRoutelet) {
            //$NON-NLS-1$
            MessageDialog.openInformation(//$NON-NLS-1$
            editor.getEditorSite().getShell(), //$NON-NLS-1$
            "Adding Routelet", //$NON-NLS-1$
            "Do not allow duplicate Routelets\nRoutelet \"" + duplicatesName.substring(2) + "\" already exist.");
            return false;
        }
    }
    return true;
}
Also used : ContextItem(org.talend.core.model.properties.ContextItem) INode(org.talend.core.model.process.INode) ArrayList(java.util.ArrayList) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RepositoryNode(org.talend.repository.model.RepositoryNode) PaletteEditPart(org.eclipse.gef.ui.palette.editparts.PaletteEditPart) ContextItem(org.talend.core.model.properties.ContextItem) Item(org.talend.core.model.properties.Item) ProcessItem(org.talend.core.model.properties.ProcessItem) Iterator(java.util.Iterator) LocalSelectionTransfer(org.eclipse.jface.util.LocalSelectionTransfer)

Example 84 with RepositoryNode

use of org.talend.repository.model.RepositoryNode in project tesb-studio-se by Talend.

the class EditCamelBean method init.

@Override
public void init(TreeViewer viewer, IStructuredSelection selection) {
    super.init(viewer, selection);
    boolean canWork = !selection.isEmpty() && selection.size() == 1;
    IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    if (factory.isUserReadOnlyOnCurrentProject()) {
        canWork = false;
    }
    RepositoryNode node = (RepositoryNode) selection.getFirstElement();
    if (canWork && (node.getObjectType() != CamelRepositoryNodeType.repositoryBeansType || !ProjectManager.getInstance().isInCurrentMainProject(node) || !isLastVersion(node))) {
        canWork = false;
    }
    if (canWork) {
        canWork = factory.getStatus(node.getObject()) != ERepositoryStatus.DELETED;
    }
    setEnabled(canWork);
}
Also used : RepositoryNode(org.talend.repository.model.RepositoryNode) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 85 with RepositoryNode

use of org.talend.repository.model.RepositoryNode in project tesb-studio-se by Talend.

the class ReadCamelBean method init.

@Override
public void init(TreeViewer viewer, IStructuredSelection selection) {
    boolean canWork = !selection.isEmpty() && selection.size() == 1;
    if (canWork) {
        Object o = selection.getFirstElement();
        RepositoryNode node = (RepositoryNode) o;
        switch(node.getType()) {
            case REPOSITORY_ELEMENT:
                if (node.getObjectType() != CamelRepositoryNodeType.repositoryBeansType) {
                    canWork = false;
                }
                break;
            default:
                canWork = false;
        }
        if (canWork && node.getObject() != null && ProxyRepositoryFactory.getInstance().getStatus(node.getObject()) == ERepositoryStatus.LOCK_BY_USER) {
            canWork = false;
        }
    }
    setEnabled(canWork);
}
Also used : RepositoryNode(org.talend.repository.model.RepositoryNode)

Aggregations

RepositoryNode (org.talend.repository.model.RepositoryNode)250 IRepositoryNode (org.talend.repository.model.IRepositoryNode)94 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)74 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)44 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)44 ProjectRepositoryNode (org.talend.core.repository.model.ProjectRepositoryNode)42 Item (org.talend.core.model.properties.Item)38 ArrayList (java.util.ArrayList)33 PersistenceException (org.talend.commons.exception.PersistenceException)27 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)27 ProcessItem (org.talend.core.model.properties.ProcessItem)23 RepositoryObject (org.talend.core.model.repository.RepositoryObject)22 ISelection (org.eclipse.jface.viewers.ISelection)20 ConnectionItem (org.talend.core.model.properties.ConnectionItem)20 IProjectRepositoryNode (org.talend.repository.model.nodes.IProjectRepositoryNode)20 List (java.util.List)18 Property (org.talend.core.model.properties.Property)18 DatabaseConnectionItem (org.talend.core.model.properties.DatabaseConnectionItem)17 MetadataColumnRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)16 WizardDialog (org.eclipse.jface.wizard.WizardDialog)13