Search in sources :

Example 1 with RepositoryNode

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

the class OpenDiagramAction 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) {
    boolean enabled = false;
    if (!selection.isEmpty() && selection.size() == 1) {
        Object object = selection.getFirstElement();
        if (object instanceof RepositoryNode) {
            RepositoryNode repositoryNode = (RepositoryNode) object;
            ERepositoryObjectType nodeType = (ERepositoryObjectType) repositoryNode.getProperties(EProperties.CONTENT_TYPE);
            if (repositoryNode.getType() == RepositoryNode.ENodeType.REPOSITORY_ELEMENT) {
                if (nodeType == ERepositoryObjectType.BUSINESS_PROCESS) {
                    enabled = true;
                }
            }
            if (enabled && (ProxyRepositoryFactory.getInstance().isUserReadOnlyOnCurrentProject() || !ProjectManager.getInstance().isInCurrentMainProject(repositoryNode) || !isLastVersion(repositoryNode))) {
                enabled = false;
            }
            RepositoryNode parent = repositoryNode.getParent();
            if (enabled && parent != null && parent.isBin()) {
                enabled = false;
            }
        }
    }
    setEnabled(enabled);
}
Also used : RepositoryObject(org.talend.core.model.repository.RepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject) RepositoryNode(org.talend.repository.model.RepositoryNode) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType)

Example 2 with RepositoryNode

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

the class OpenDiagramAction method doRun.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
@Override
protected void doRun() {
    ISelection selection = getSelectedObject();
    if (selection == null) {
        return;
    }
    Object obj = ((IStructuredSelection) selection).getFirstElement();
    if (obj instanceof RepositoryNode) {
        RepositoryNode repositoryNode = (RepositoryNode) obj;
        IRepositoryViewObject repositoryObject = repositoryNode.getObject();
        Property updatedProperty = null;
        if (repositoryObject instanceof RepositoryObject) {
            RepositoryViewObject abstractRepositoryObject = new RepositoryViewObject(repositoryObject.getProperty());
            updatedProperty = abstractRepositoryObject.getProperty();
        } else if (repositoryObject instanceof RepositoryViewObject) {
            updatedProperty = repositoryObject.getProperty();
        }
        if (updatedProperty != null) {
            BusinessProcessItem businessProcessItem = (BusinessProcessItem) updatedProperty.getItem();
            DiagramResourceManager diagramResourceManager = new DiagramResourceManager(getActivePage(), new NullProgressMonitor());
            IFile file = diagramResourceManager.createDiagramFile();
            diagramResourceManager.updateResource(businessProcessItem, file);
            IEditorPart part = diagramResourceManager.openEditor(businessProcessItem, file, false);
            if (part instanceof BusinessDiagramEditor) {
                ((BusinessDiagramEditor) part).setLastVersion(true);
            }
        // TDI-21143 : Studio repository view : remove all refresh call to repo view
        // IRepositoryView view = getViewPart();
        // if (view != null) {
        // view.refresh(repositoryNode);
        // }
        }
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) RepositoryObject(org.talend.core.model.repository.RepositoryObject) BusinessDiagramEditor(org.talend.designer.business.model.business.diagram.part.BusinessDiagramEditor) BusinessProcessItem(org.talend.core.model.properties.BusinessProcessItem) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IEditorPart(org.eclipse.ui.IEditorPart) RepositoryNode(org.talend.repository.model.RepositoryNode) ISelection(org.eclipse.jface.viewers.ISelection) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryObject(org.talend.core.model.repository.RepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject) Property(org.talend.core.model.properties.Property) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject)

Example 3 with RepositoryNode

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

the class ReadDiagramAction method doRun.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
protected void doRun() {
    if (repositoryNode == null && getSelection() != null) {
        Object firstElement = ((IStructuredSelection) getSelection()).getFirstElement();
        if (firstElement instanceof RepositoryNode) {
            repositoryNode = (RepositoryNode) firstElement;
        }
    }
    RepositoryNode node = repositoryNode;
    if (node != null) {
        IRepositoryViewObject repositoryObject = node.getObject();
        Property updatedProperty = repositoryObject.getProperty();
        if (updatedProperty != null) {
            BusinessProcessItem businessProcessItem = (BusinessProcessItem) updatedProperty.getItem();
            DiagramResourceManager diagramResourceManager = new DiagramResourceManager(getActivePage(), new NullProgressMonitor());
            IFile file = diagramResourceManager.createDiagramFile();
            diagramResourceManager.updateResource(businessProcessItem, file);
            IEditorPart part = diagramResourceManager.openEditor(businessProcessItem, file, true);
            if (part instanceof BusinessDiagramEditor) {
                ((BusinessDiagramEditor) part).setLastVersion(true);
            }
        }
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) BusinessDiagramEditor(org.talend.designer.business.model.business.diagram.part.BusinessDiagramEditor) BusinessProcessItem(org.talend.core.model.properties.BusinessProcessItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IEditorPart(org.eclipse.ui.IEditorPart) RepositoryNode(org.talend.repository.model.RepositoryNode) Property(org.talend.core.model.properties.Property)

Example 4 with RepositoryNode

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

the class GmfPastCommand method cloneAssignmentForModel.

private void cloneAssignmentForModel(List<BusinessItem> nodes, List pChildren) {
    if (nodes == null || pChildren == null) {
        return;
    }
    int i = nodes.size();
    for (BusinessItem businessItem : getSortedBusinessItems(nodes)) {
        BusinessItem newItem = (BusinessItem) getEObject(businessItem);
        if (!addNew) {
            newItem.setBusinessProcess(businessItem.getBusinessProcess());
        }
        newItem.setHAlignment(businessItem.getHAlignment());
        newItem.setName(businessItem.getName());
        newItem.setVAlignment(businessItem.getVAlignment());
        List assignments = new ArrayList();
        boolean execute = false;
        int n = 0;
        for (Object object : businessItem.getAssignments()) {
            BusinessAssignment older = (BusinessAssignment) object;
            BusinessAssignment newAssignment = (BusinessAssignment) getEObject(older);
            newAssignment.setBusinessItem(newItem);
            newAssignment.setComment(older.getComment());
            if (!addNew) {
                newAssignment.setTalendItem(older.getTalendItem());
            } else {
                TalendItem item = older.getTalendItem();
                String talendId = null;
                if (item != null) {
                    talendId = item.getId();
                } else {
                    List idList = (List) itemIds.get(businessItem);
                    if (n < idList.size()) {
                        talendId = (String) idList.get(n);
                    }
                    n++;
                }
                RepositoryNode node = null;
                if (talendId.split(" - ").length == 1) {
                    //$NON-NLS-1$
                    node = RepositoryNodeUtilities.getRepositoryNode(talendId);
                } else {
                    node = RepositoryNodeUtilities.getMetadataTableFromConnection(talendId);
                    if (node == null) {
                        node = RepositoryNodeUtilities.getQueryFromConnection(talendId);
                    }
                }
                RepositoryHelper repositoryHelper = new RepositoryHelper();
                Repository repository = process.getLocalRepositoryCopy();
                if (repository == null) {
                    repository = repositoryHelper.createLocalRepositoryCopy(process);
                }
                TalendItem talendItem = repositoryHelper.createTalendItem(repository, node);
                newAssignment.setTalendItem(talendItem);
            }
            assignments.add(newAssignment);
        }
        if (assignments.size() > 0) {
            newItem.getAssignments().addAll(assignments);
        }
        if (i <= pChildren.size()) {
            View node = (View) pChildren.get(pChildren.size() - i);
            node.setElement(newItem);
            i--;
        }
        if (addNew) {
            this.process.getBusinessItems().add(newItem);
        }
    }
}
Also used : BusinessAssignment(org.talend.designer.business.model.business.BusinessAssignment) ArrayList(java.util.ArrayList) RepositoryNode(org.talend.repository.model.RepositoryNode) View(org.eclipse.gmf.runtime.notation.View) Repository(org.talend.designer.business.model.business.Repository) ArrayList(java.util.ArrayList) List(java.util.List) EObject(org.eclipse.emf.ecore.EObject) TalendItem(org.talend.designer.business.model.business.TalendItem) InputBusinessItem(org.talend.designer.business.model.business.InputBusinessItem) TerminalBusinessItem(org.talend.designer.business.model.business.TerminalBusinessItem) ActorBusinessItem(org.talend.designer.business.model.business.ActorBusinessItem) DatabaseBusinessItem(org.talend.designer.business.model.business.DatabaseBusinessItem) BusinessItem(org.talend.designer.business.model.business.BusinessItem) GearBusinessItem(org.talend.designer.business.model.business.GearBusinessItem) EllipseBusinessItem(org.talend.designer.business.model.business.EllipseBusinessItem) DataBusinessItem(org.talend.designer.business.model.business.DataBusinessItem) DecisionBusinessItem(org.talend.designer.business.model.business.DecisionBusinessItem) DocumentBusinessItem(org.talend.designer.business.model.business.DocumentBusinessItem) ActionBusinessItem(org.talend.designer.business.model.business.ActionBusinessItem) ListBusinessItem(org.talend.designer.business.model.business.ListBusinessItem) RepositoryHelper(org.talend.designer.business.diagram.custom.util.RepositoryHelper)

Example 5 with RepositoryNode

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

the class FindAssignmentAction method doRun.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
@Override
protected void doRun() {
    RepositoryNode repositoryNode = (RepositoryNode) getFirstSelectedObject();
    IEditorPart activeEditor = getActiveEditor();
    // remove frames draw last time
    for (BusinessItemShapeFigure shapFigure : repaintedFigures) {
        shapFigure.setDrawFrame(false);
        shapFigure.revalidate();
        shapFigure.repaint();
    }
    if (activeEditor instanceof BusinessDiagramEditor) {
        BusinessDiagramEditor businessDiagramEditor = (BusinessDiagramEditor) activeEditor;
        Diagram diagram = (Diagram) businessDiagramEditor.getDiagramEditPart().getModel();
        BusinessProcess businessProcess = (BusinessProcess) diagram.getElement();
        // PTODO mhelleboid use OCL or using a visitor
        List list = new ArrayList();
        for (Iterator iter = businessProcess.getBusinessItems().iterator(); iter.hasNext(); ) {
            BusinessItem businessItem = (BusinessItem) iter.next();
            for (Iterator iterator = businessItem.getAssignments().iterator(); iterator.hasNext(); ) {
                BusinessAssignment businessAssignment = (BusinessAssignment) iterator.next();
                TalendItem talendItem = businessAssignment.getTalendItem();
                IRepositoryViewObject obj = repositoryNode.getObject();
                if (talendItem.getId().equals(repositoryNode.getId())) {
                    list.add(businessItem);
                } else if (talendItem instanceof SQLPattern || talendItem instanceof Routine || talendItem instanceof TableMetadata || talendItem instanceof Query || talendItem instanceof SapFunctionMetadata) {
                    if (talendItem.getLabel().equals(repositoryNode.getProperties(EProperties.LABEL))) {
                        list.add(businessItem);
                    }
                }
            }
        }
        IDiagramGraphicalViewer diagramGraphicalViewer = businessDiagramEditor.getDiagramGraphicalViewer();
        List editParts = new ArrayList();
        for (Iterator iter = list.iterator(); iter.hasNext(); ) {
            BusinessItem businessItem = (BusinessItem) iter.next();
            editParts.addAll(diagramGraphicalViewer.findEditPartsForElement(EMFCoreUtil.getProxyID(businessItem), BaseBusinessItemRelationShipEditPart.class));
            editParts.addAll(diagramGraphicalViewer.findEditPartsForElement(EMFCoreUtil.getProxyID(businessItem), BusinessItemShapeEditPart.class));
        }
        diagramGraphicalViewer.deselectAll();
        // add a frame when use findAassignment
        for (Iterator iter = editParts.iterator(); iter.hasNext(); ) {
            EditPart editPart = (EditPart) iter.next();
            if (editPart instanceof BusinessItemShapeEditPart) {
                BusinessItemShapeEditPart shapEditPart = (BusinessItemShapeEditPart) editPart;
                IFigure figure = shapEditPart.getFigure();
                for (Object child : figure.getChildren()) {
                    if (child instanceof BusinessItemShapeFigure) {
                        BusinessItemShapeFigure shapFigure = (BusinessItemShapeFigure) child;
                        shapFigure.setDrawFrame(true);
                        shapFigure.revalidate();
                        shapFigure.repaint();
                        repaintedFigures.add(shapFigure);
                    }
                }
            }
            diagramGraphicalViewer.getSelectionManager().appendSelection(editPart);
        }
        ZoomManager zoomManager = (ZoomManager) businessDiagramEditor.getAdapter(ZoomManager.class);
        zoomFitSelection(zoomManager, editParts, businessDiagramEditor.getDiagramEditPart(), true);
    }
}
Also used : IDiagramGraphicalViewer(org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramGraphicalViewer) SapFunctionMetadata(org.talend.designer.business.model.business.SapFunctionMetadata) BusinessDiagramEditor(org.talend.designer.business.model.business.diagram.part.BusinessDiagramEditor) BusinessAssignment(org.talend.designer.business.model.business.BusinessAssignment) Query(org.talend.designer.business.model.business.Query) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) TalendItem(org.talend.designer.business.model.business.TalendItem) IFigure(org.eclipse.draw2d.IFigure) TableMetadata(org.talend.designer.business.model.business.TableMetadata) SQLPattern(org.talend.designer.business.model.business.SQLPattern) BusinessItemShapeEditPart(org.talend.designer.business.diagram.custom.edit.parts.BusinessItemShapeEditPart) DiagramEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) BaseBusinessItemRelationShipEditPart(org.talend.designer.business.diagram.custom.edit.parts.BaseBusinessItemRelationShipEditPart) IEditorPart(org.eclipse.ui.IEditorPart) Routine(org.talend.designer.business.model.business.Routine) RepositoryNode(org.talend.repository.model.RepositoryNode) BaseBusinessItemRelationShipEditPart(org.talend.designer.business.diagram.custom.edit.parts.BaseBusinessItemRelationShipEditPart) Diagram(org.eclipse.gmf.runtime.notation.Diagram) BusinessItemShapeEditPart(org.talend.designer.business.diagram.custom.edit.parts.BusinessItemShapeEditPart) ZoomManager(org.eclipse.gef.editparts.ZoomManager) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) BusinessItemShapeFigure(org.talend.designer.business.diagram.custom.figures.BusinessItemShapeFigure) BusinessItem(org.talend.designer.business.model.business.BusinessItem) BusinessProcess(org.talend.designer.business.model.business.BusinessProcess)

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