Search in sources :

Example 26 with RepositoryNode

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

the class ProcessVersionComposite method addPopUpMenu.

/**
     * DOC Administrator Comment method "addPoppuMenu".
     */
private void addPopUpMenu() {
    //$NON-NLS-1$
    MenuManager menuMgr = new MenuManager("#PopUp");
    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener(new IMenuListener() {

        @Override
        public void menuAboutToShow(IMenuManager mgr) {
            if (getParentWizard() == null) {
                ISelection selection = tableViewer.getSelection();
                if (selection instanceof IStructuredSelection) {
                    IStructuredSelection structuredSelection = (IStructuredSelection) selection;
                    List<ITreeContextualAction> contextualsActions = ActionsHelper.getRepositoryContextualsActions();
                    for (ITreeContextualAction action : contextualsActions) {
                        if (action instanceof OpenExistVersionProcessAction) {
                            continue;
                        }
                        if (action.isReadAction() || action.isEditAction() || action.isPropertiesAction()) {
                            action.init(null, structuredSelection);
                            Object o = structuredSelection.getFirstElement();
                            if (o instanceof RepositoryNode) {
                                ((AContextualAction) action).setAvoidUnloadResources(true);
                            }
                            if (action.isVisible()) {
                                mgr.add(action);
                            }
                        }
                    }
                }
            }
        }
    });
    Menu menu = menuMgr.createContextMenu(tableViewer.getControl());
    tableViewer.getControl().setMenu(menu);
}
Also used : MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) ISelection(org.eclipse.jface.viewers.ISelection) List(java.util.List) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IRepositoryObject(org.talend.core.model.repository.IRepositoryObject) IMenuManager(org.eclipse.jface.action.IMenuManager) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ITreeContextualAction(org.talend.commons.ui.swt.actions.ITreeContextualAction) Menu(org.eclipse.swt.widgets.Menu) RepositoryNode(org.talend.repository.model.RepositoryNode) OpenExistVersionProcessAction(org.talend.designer.core.ui.action.OpenExistVersionProcessAction) IMenuListener(org.eclipse.jface.action.IMenuListener)

Example 27 with RepositoryNode

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

the class OpenDocumentationAction method init.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.repository.ui.actions.ITreeContextualAction#init(org.eclipse.jface.viewers.TreeViewer,
     * org.eclipse.jface.viewers.IStructuredSelection)
     */
@Override
public void init(TreeViewer viewer, IStructuredSelection selection) {
    boolean canWork = !selection.isEmpty() && selection.size() == 1;
    RepositoryNode node = (RepositoryNode) selection.getFirstElement();
    if (canWork) {
        canWork = node.getType() == ENodeType.REPOSITORY_ELEMENT && node.getObject().getRepositoryObjectType() == ERepositoryObjectType.DOCUMENTATION;
    }
    RepositoryNode parent = null;
    if (node != null) {
        parent = node.getParent();
    }
    if (canWork && parent != null && parent instanceof BinRepositoryNode) {
        canWork = false;
    }
    setEnabled(canWork);
}
Also used : BinRepositoryNode(org.talend.repository.model.BinRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) BinRepositoryNode(org.talend.repository.model.BinRepositoryNode)

Example 28 with RepositoryNode

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

the class OpenDocumentationAction method doRun.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
@Override
protected void doRun() {
    RepositoryNode node = (RepositoryNode) ((IStructuredSelection) getSelection()).getFirstElement();
    Item item = node.getObject().getProperty().getItem();
    if (item == null) {
        return;
    }
    URL url = null;
    // String extension = null;
    if (item instanceof DocumentationItem) {
        DocumentationItem documentationItem = (DocumentationItem) item;
        // if (documentationItem.getExtension() != null) {
        // extension = documentationItem.getExtension();
        // }
        IFile file = LinkDocumentationHelper.getTempFile(documentationItem.getName(), documentationItem.getExtension());
        try {
            documentationItem.getContent().setInnerContentToFile(file.getLocation().toFile());
            url = file.getLocationURI().toURL();
        } catch (Exception e) {
            showErrorMessage();
            return;
        }
    } else if (item instanceof LinkDocumentationItem) {
        // link documenation
        LinkDocumentationItem linkDocItem = (LinkDocumentationItem) item;
        if (!LinkUtils.validateLink(linkDocItem.getLink())) {
            showErrorMessage();
            return;
        }
        // if (linkDocItem.getExtension() != null) {
        // extension = linkDocItem.getExtension();
        // }
        String uri = linkDocItem.getLink().getURI();
        if (LinkUtils.isRemoteFile(uri)) {
            try {
                url = new URL(uri);
            } catch (MalformedURLException e) {
            //
            }
        } else if (LinkUtils.existedFile(uri)) {
            try {
                url = new File(uri).toURL();
            } catch (MalformedURLException e) {
            //
            }
        }
    }
    openedByBrowser(item, url);
// progress(item, extension);
}
Also used : Item(org.talend.core.model.properties.Item) DocumentationItem(org.talend.core.model.properties.DocumentationItem) LinkDocumentationItem(org.talend.core.model.properties.LinkDocumentationItem) MalformedURLException(java.net.MalformedURLException) IFile(org.eclipse.core.resources.IFile) LinkDocumentationItem(org.talend.core.model.properties.LinkDocumentationItem) RepositoryNode(org.talend.repository.model.RepositoryNode) BinRepositoryNode(org.talend.repository.model.BinRepositoryNode) DocumentationItem(org.talend.core.model.properties.DocumentationItem) LinkDocumentationItem(org.talend.core.model.properties.LinkDocumentationItem) IFile(org.eclipse.core.resources.IFile) File(java.io.File) URL(java.net.URL) PartInitException(org.eclipse.ui.PartInitException) MalformedURLException(java.net.MalformedURLException)

Example 29 with RepositoryNode

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

the class UpdateDocumentationAction method getPath.

private IPath getPath() {
    RepositoryNode node = (RepositoryNode) ((IStructuredSelection) getSelection()).getFirstElement();
    IPath path;
    if (node.getType() == ENodeType.SIMPLE_FOLDER || node.getType() == ENodeType.SYSTEM_FOLDER) {
        path = RepositoryNodeUtilities.getPath(node);
    } else {
        path = RepositoryNodeUtilities.getPath(node);
    }
    return path;
}
Also used : IPath(org.eclipse.core.runtime.IPath) RepositoryNode(org.talend.repository.model.RepositoryNode)

Example 30 with RepositoryNode

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

the class UpdateDocumentationAction method init.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.repository.ui.actions.ITreeContextualAction#init(org.eclipse.jface.viewers.TreeViewer,
     * org.eclipse.jface.viewers.IStructuredSelection)
     */
@Override
public void init(TreeViewer viewer, IStructuredSelection selection) {
    boolean canWork = !selection.isEmpty() && selection.size() == 1;
    if (canWork) {
        IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
        RepositoryNode node = (RepositoryNode) selection.getFirstElement();
        canWork = (node.getType() == ENodeType.REPOSITORY_ELEMENT && node.getObject().getRepositoryObjectType() == ERepositoryObjectType.DOCUMENTATION && factory.isPotentiallyEditable(node.getObject()));
    }
    setEnabled(canWork);
}
Also used : RepositoryNode(org.talend.repository.model.RepositoryNode) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

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