Search in sources :

Example 21 with IRepositoryNode

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

the class CreateNewJobAction method createNewProcess.

private boolean createNewProcess(RepositoryNode nodeOperation, final ProcessItem process) {
    if (process == null) {
        return false;
    }
    try {
        // Set readonly to false since created job will always be editable.
        ProcessEditorInput fileEditorInput = new ProcessEditorInput(process, false, true, false);
        IRepositoryNode repositoryNode = RepositorySeekerManager.getInstance().searchRepoViewNode(fileEditorInput.getItem().getProperty().getId());
        fileEditorInput.setRepositoryNode(repositoryNode);
        IEditorPart openEditor = getActivePage().openEditor(fileEditorInput, MultiPageTalendEditor.ID, true);
        CommandStack commandStack = (CommandStack) openEditor.getAdapter(CommandStack.class);
        final Node nodeProviderRequest = new Node(ComponentsFactoryProvider.getInstance().get(T_ESB_PROVIDER_REQUEST, ComponentCategory.CATEGORY_4_DI.getName()), fileEditorInput.getLoadedProcess());
        final RepositoryNode portNode = nodeOperation.getParent();
        ServiceItem serviceItem = (ServiceItem) portNode.getParent().getObject().getProperty().getItem();
        IFile wsdlPath = WSDLUtils.getWsdlFile(serviceItem);
        Map<String, String> serviceParameters = WSDLUtils.getServiceOperationParameters(wsdlPath, ((OperationRepositoryObject) nodeOperation.getObject()).getName(), portNode.getObject().getLabel());
        setProviderRequestComponentConfiguration(nodeProviderRequest, serviceParameters);
        CreateNodeContainerCommand cNcc = new CreateNodeContainerCommand(fileEditorInput.getLoadedProcess(), new NodeContainer(nodeProviderRequest), new Point(3 * Node.DEFAULT_SIZE, 4 * Node.DEFAULT_SIZE));
        commandStack.execute(cNcc);
        if (!WSDLUtils.ONE_WAY.equals(serviceParameters.get(WSDLUtils.COMMUNICATION_STYLE))) {
            Node node = new Node(ComponentsFactoryProvider.getInstance().get(T_ESB_PROVIDER_RESPONSE, ComponentCategory.CATEGORY_4_DI.getName()), fileEditorInput.getLoadedProcess());
            cNcc = new CreateNodeContainerCommand(fileEditorInput.getLoadedProcess(), new NodeContainer(node), new Point(9 * Node.DEFAULT_SIZE, 4 * Node.DEFAULT_SIZE));
            commandStack.execute(cNcc);
        }
        String faults = serviceParameters.get(WSDLUtils.FAULTS);
        if (null != faults) {
            int horMultiplier = 15;
            for (String fault : faults.split(",")) {
                Node node = new Node(ComponentsFactoryProvider.getInstance().get(T_ESB_PROVIDER_FAULT, ComponentCategory.CATEGORY_4_DI.getName()), fileEditorInput.getLoadedProcess());
                cNcc = new CreateNodeContainerCommand(fileEditorInput.getLoadedProcess(), new NodeContainer(node), new Point(horMultiplier * Node.DEFAULT_SIZE, 4 * Node.DEFAULT_SIZE));
                commandStack.execute(cNcc);
                //$NON-NLS-1$
                node.getElementParameter("ESB_FAULT_TITLE").setValue('\"' + fault + '\"');
                horMultiplier += 6;
            }
        }
        ServiceConnection serviceConnection = (ServiceConnection) serviceItem.getConnection();
        final String parentPortName = portNode.getObject().getLabel();
        for (ServicePort port : serviceConnection.getServicePort()) {
            if (port.getName().equals(parentPortName)) {
                for (ServiceOperation operation : port.getServiceOperation()) {
                    if (operation.getLabel().equals(nodeOperation.getObject().getLabel())) {
                        String jobName = process.getProperty().getLabel();
                        String jobID = process.getProperty().getId();
                        operation.setReferenceJobId(jobID);
                        operation.setLabel(operation.getName() + "-" + jobName);
                        break;
                    }
                }
                break;
            }
        }
        repositoryChange(nodeOperation, nodeProviderRequest);
        ProxyRepositoryFactory.getInstance().save(serviceItem);
        return true;
    } catch (PartInitException e) {
        ExceptionHandler.process(e);
    } catch (PersistenceException e) {
        MessageBoxExceptionHandler.process(e);
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }
    return false;
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) ServicePort(org.talend.repository.services.model.services.ServicePort) ServiceConnection(org.talend.repository.services.model.services.ServiceConnection) IFile(org.eclipse.core.resources.IFile) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) IEditorPart(org.eclipse.ui.IEditorPart) Point(org.eclipse.draw2d.geometry.Point) ServiceOperation(org.talend.repository.services.model.services.ServiceOperation) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Point(org.eclipse.draw2d.geometry.Point) PartInitException(org.eclipse.ui.PartInitException) PersistenceException(org.talend.commons.exception.PersistenceException) ProcessEditorInput(org.talend.designer.core.ui.editor.ProcessEditorInput) CreateNodeContainerCommand(org.talend.designer.core.ui.editor.cmd.CreateNodeContainerCommand) PersistenceException(org.talend.commons.exception.PersistenceException) ServiceItem(org.talend.repository.services.model.services.ServiceItem) PartInitException(org.eclipse.ui.PartInitException)

Example 22 with IRepositoryNode

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

the class OpenJobAction method init.

@Override
public void init(TreeViewer viewer, IStructuredSelection selection) {
    if (selection.size() != 1) {
        setEnabled(false);
        return;
    }
    IRepositoryNode node = (IRepositoryNode) selection.getFirstElement();
    if (!ERepositoryObjectType.SERVICESOPERATION.equals((ERepositoryObjectType) node.getProperties(EProperties.CONTENT_TYPE)) || !WSDLUtils.isOperationInBinding(node)) {
        // not enabled if the operation doesn't define in binding
        setEnabled(false);
        return;
    }
    String jobId = getReferenceJobId(node);
    if (jobId == null) {
        setEnabled(false);
        return;
    }
    IRepositoryNode repoNode = RepositorySeekerManager.getInstance().searchRepoViewNode(jobId, false);
    jobNode = repoNode == null ? null : (RepositoryNode) repoNode;
    if (jobNode == null) {
        removeReferenecJobId(node);
        setEnabled(false);
        return;
    }
    final IStructuredSelection jobSelection = new StructuredSelection(jobNode);
    setSpecialSelection(new ISelectionProvider() {

        public void setSelection(ISelection arg0) {
        }

        public void removeSelectionChangedListener(ISelectionChangedListener arg0) {
        }

        public ISelection getSelection() {
            return jobSelection;
        }

        public void addSelectionChangedListener(ISelectionChangedListener arg0) {
        }
    });
    super.init(viewer, jobSelection);
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode)

Example 23 with IRepositoryNode

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

the class SaveAsRoutesAction method run.

@Override
public void run() {
    SaveAsRoutesWizard processWizard = new SaveAsRoutesWizard((JobEditorInput) editorPart.getEditorInput());
    WizardDialog dlg = new WizardDialog(editorPart.getSite().getShell(), processWizard);
    if (dlg.open() == Window.OK) {
        try {
            // Set readonly to false since created routes will always be editable.
            JobEditorInput newRoutesEditorInput = new CamelProcessEditorInput(processWizard.getProcess(), true, true, false);
            IWorkbenchPage page = editorPart.getSite().getPage();
            IRepositoryNode repositoryNode = RepositorySeekerManager.getInstance().searchRepoViewNode(newRoutesEditorInput.getItem().getProperty().getId(), false);
            newRoutesEditorInput.setRepositoryNode(repositoryNode);
            // close the old editor
            page.closeEditor(editorPart, false);
            // open the new editor, because at the same time, there will update the routes view
            page.openEditor(newRoutesEditorInput, CamelMultiPageTalendEditor.ID, true);
        } catch (Exception e) {
            MessageDialog.openError(editorPart.getSite().getShell(), "Error", "Routes could not be saved" + " : " + e.getMessage());
            ExceptionHandler.process(e);
        }
    }
}
Also used : JobEditorInput(org.talend.core.ui.editor.JobEditorInput) IRepositoryNode(org.talend.repository.model.IRepositoryNode) CamelProcessEditorInput(org.talend.camel.designer.ui.editor.CamelProcessEditorInput) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) SaveAsRoutesWizard(org.talend.camel.designer.ui.wizards.SaveAsRoutesWizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 24 with IRepositoryNode

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

the class ExporCameltJobScriptAction method init.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.repository.ui.actions.ITreeContextualAction#init(org.eclipse.jface.viewers.TreeViewer,
     * org.eclipse.jface.viewers.IStructuredSelection)
     */
public void init(TreeViewer viewer, IStructuredSelection selection) {
    setEnabled(false);
    if (selection.isEmpty() || selection.size() != 1) {
        return;
    }
    IRepositoryNode node = (IRepositoryNode) selection.getFirstElement();
    if (node.getType() == ENodeType.REPOSITORY_ELEMENT && node.getProperties(EProperties.CONTENT_TYPE) == CamelRepositoryNodeType.repositoryRoutesType && ERepositoryStatus.DELETED != ProxyRepositoryFactory.getInstance().getStatus(node.getObject())) {
        shell = viewer.getTree().getShell();
        setEnabled(true);
    }
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode)

Example 25 with IRepositoryNode

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

the class OpenCamelExistVersionProcessAction method doRun.

@Override
protected void doRun() {
    ISelection selection = getSelection();
    Object obj = ((IStructuredSelection) selection).getFirstElement();
    IRepositoryNode node = (IRepositoryNode) obj;
    IPath path = RepositoryNodeUtilities.getPath(node);
    String originalName = node.getObject().getLabel();
    RepositoryObject repositoryObj = new RepositoryObject(node.getObject().getProperty());
    repositoryObj.setRepositoryNode(node.getObject().getRepositoryNode());
    OpenCamelExistVersionProcessWizard wizard = new OpenCamelExistVersionProcessWizard(repositoryObj);
    WizardDialog dialog = new WizardDialog(Display.getCurrent().getActiveShell(), wizard);
    dialog.setHelpAvailable(false);
    dialog.setPageSize(300, 250);
    //$NON-NLS-1$
    dialog.setTitle(Messages.getString("OpenExistVersionProcess.open.dialog"));
    if (dialog.open() == Dialog.OK) {
        refresh(node);
        // refresh the corresponding editor's name
        IEditorPart part = getCorrespondingEditor(node);
        if (part != null && part instanceof IUIRefresher) {
            ((IUIRefresher) part).refreshName();
        } else {
            processRoutineRenameOperation(originalName, node, path);
        }
    }
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) IPath(org.eclipse.core.runtime.IPath) RepositoryObject(org.talend.core.model.repository.RepositoryObject) ISelection(org.eclipse.jface.viewers.ISelection) RepositoryObject(org.talend.core.model.repository.RepositoryObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IEditorPart(org.eclipse.ui.IEditorPart) OpenCamelExistVersionProcessWizard(org.talend.camel.designer.ui.wizards.OpenCamelExistVersionProcessWizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog) IUIRefresher(org.talend.core.services.IUIRefresher)

Aggregations

IRepositoryNode (org.talend.repository.model.IRepositoryNode)73 RepositoryNode (org.talend.repository.model.RepositoryNode)24 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)21 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)13 PersistenceException (org.talend.commons.exception.PersistenceException)13 ArrayList (java.util.ArrayList)12 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)12 WizardDialog (org.eclipse.jface.wizard.WizardDialog)10 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)8 IEditorPart (org.eclipse.ui.IEditorPart)8 ProjectRepositoryNode (org.talend.core.repository.model.ProjectRepositoryNode)8 ISelection (org.eclipse.jface.viewers.ISelection)6 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)6 ProcessItem (org.talend.core.model.properties.ProcessItem)6 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)6 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)6 IRepositoryView (org.talend.repository.ui.views.IRepositoryView)6 IPath (org.eclipse.core.runtime.IPath)5 PartInitException (org.eclipse.ui.PartInitException)5 Item (org.talend.core.model.properties.Item)5