Search in sources :

Example 1 with BinRepositoryNode

use of org.talend.repository.model.BinRepositoryNode 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 2 with BinRepositoryNode

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

the class ExtractDocumentationAction 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 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 3 with BinRepositoryNode

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

the class RunCamelProcess 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 canWork = !selection.isEmpty() && selection.size() == 1;
    // }
    if (canWork) {
        Object o = selection.getFirstElement();
        RepositoryNode node = (RepositoryNode) o;
        switch(node.getType()) {
            case REPOSITORY_ELEMENT:
                if (node.getParent() == null || node.getParent().getContentType() != CamelRepositoryNodeType.repositoryRoutesType) {
                    canWork = false;
                }
                // Avoid showing in route test case
                if (node.getObjectType().getType().equals(TEST_CONTAINER)) {
                    canWork = false;
                }
                break;
            default:
                canWork = false;
        }
        RepositoryNode parent = node.getParent();
        if (canWork && parent != null && parent instanceof BinRepositoryNode) {
            canWork = false;
        }
    }
    setEnabled(canWork);
}
Also used : BinRepositoryNode(org.talend.repository.model.BinRepositoryNode) BinRepositoryNode(org.talend.repository.model.BinRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode)

Example 4 with BinRepositoryNode

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

the class OpenDefaultEditorAction method init.

//	private ISelection getSelectedObject() {
//		if (params == null) {
//			return getSelection();
//		}
//		else {
//			RepositoryNode repositoryNode = RepositoryNodeUtilities
//					.getRepositoryNode(params.getProperty("nodeId"), false); //$NON-NLS-1$
//			IRepositoryView viewPart = getViewPart();
//			if (repositoryNode != null && viewPart != null) {
//				RepositoryNodeUtilities.expandParentNode(viewPart,
//						repositoryNode);
//				return new StructuredSelection(repositoryNode);
//			}
//			return null;
//		}
//	}
/*
	 * (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 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.repositoryRouteResourceType) {
                    canWork = false;
                } else {
                    IRepositoryService service = DesignerPlugin.getDefault().getRepositoryService();
                    IProxyRepositoryFactory repFactory = service.getProxyRepositoryFactory();
                    IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
                    if (!factory.isUserReadOnlyOnCurrentProject() && repFactory.isPotentiallyEditable(node.getObject())) {
                        //$NON-NLS-1$
                        this.setText(Messages.getString("OpenDefaultEditorAction_title"));
                    } else {
                        //$NON-NLS-1$
                        this.setText(Messages.getString("OpenDefaultEditorAction_title_read"));
                    }
                }
                break;
            default:
                canWork = false;
        }
        RepositoryNode parent = node.getParent();
        if (canWork && parent != null && parent instanceof BinRepositoryNode) {
            canWork = false;
        }
        // job version is the latest verison or not.
        if (canWork) {
            canWork = isLastVersion(node);
        }
    }
    setEnabled(canWork);
    //$NON-NLS-1$
    this.setToolTipText(Messages.getString("OpenDefaultEditorAction_tooltip"));
    this.setImageDescriptor(RouteResourceActivator.createImageDesc(//$NON-NLS-1$
    "icons/edit-resource.png"));
}
Also used : BinRepositoryNode(org.talend.repository.model.BinRepositoryNode) BinRepositoryNode(org.talend.repository.model.BinRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) IRepositoryService(org.talend.repository.model.IRepositoryService)

Aggregations

BinRepositoryNode (org.talend.repository.model.BinRepositoryNode)4 RepositoryNode (org.talend.repository.model.RepositoryNode)4 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)1 IRepositoryService (org.talend.repository.model.IRepositoryService)1