Search in sources :

Example 1 with EmptyRepositoryObject

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

the class AbstractSection method setInput.

@Override
public void setInput(IWorkbenchPart part, ISelection selection) {
    super.setInput(part, selection);
    Assert.isTrue(selection instanceof IStructuredSelection);
    Object input = ((IStructuredSelection) selection).getFirstElement();
    if (!(input instanceof RepositoryNode)) {
        if (input instanceof IAdaptable) {
            // see ProcessPart.getAdapter()
            IAdaptable adaptable = (IAdaptable) input;
            input = adaptable.getAdapter(RepositoryNode.class);
        }
    }
    Assert.isTrue(input instanceof RepositoryNode);
    repositoryNode = (RepositoryNode) input;
    repositoryObject = repositoryNode.getObject();
    if (repositoryObject == null) {
        repositoryObject = new EmptyRepositoryObject();
        enableControls(false);
        showControls(false);
        return;
    }
    manageLock();
    ERepositoryObjectType type = repositoryObject.getRepositoryObjectType();
    showControls(type != ERepositoryObjectType.METADATA_CON_TABLE);
}
Also used : IAdaptable(org.eclipse.core.runtime.IAdaptable) EmptyRepositoryObject(org.talend.core.model.repository.EmptyRepositoryObject) EmptyRepositoryObject(org.talend.core.model.repository.EmptyRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RepositoryNode(org.talend.repository.model.RepositoryNode) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType)

Example 2 with EmptyRepositoryObject

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

the class JobSettingsView method selectionChanged.

/*
     * (non-Javadoc)
     *
     * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.
     * SelectionChangedEvent )
     */
@Override
public void selectionChanged(SelectionChangedEvent event) {
    ISelection selection = event.getSelection();
    if (selection instanceof StructuredSelection) {
        Object input = ((IStructuredSelection) selection).getFirstElement();
        if (!(input instanceof RepositoryNode)) {
            if (input instanceof IAdaptable) {
                // see ProcessPart.getAdapter()
                IAdaptable adaptable = (IAdaptable) input;
                input = adaptable.getAdapter(RepositoryNode.class);
            }
        }
        if (input instanceof RepositoryNode) {
            RepositoryNode repositoryNode = (RepositoryNode) input;
            Object obj = repositoryNode.getProperties(EProperties.CONTENT_TYPE);
            String type = null;
            if (obj != null) {
                type = obj.toString();
                if (obj instanceof ERepositoryObjectType) {
                    ERepositoryObjectType objType = (ERepositoryObjectType) obj;
                    if (objType == ERepositoryObjectType.PROCESS) {
                        type = getViewNameLable();
                    } else if (objType == ERepositoryObjectType.JOBLET) {
                        type = VIEW_NAME_JOBLET;
                    }
                }
            } else {
                return;
            }
            IRepositoryViewObject repositoryObject = repositoryNode.getObject();
            if (repositoryObject == null) {
                repositoryObject = new EmptyRepositoryObject();
                return;
            }
            String title = repositoryObject.getLabel();
            if (allowVerchange) {
                if (repositoryObject.getVersion() != null) {
                    //$NON-NLS-1$
                    title = repositoryObject.getLabel() + " " + repositoryObject.getVersion();
                }
            }
            Image jobSettingImage = null;
            ERepositoryObjectType repositoryObjectType = repositoryNode.getObjectType();
            if (repositoryObjectType == ERepositoryObjectType.PROCESS_MR || repositoryObjectType == ERepositoryObjectType.PROCESS_STORM) {
                jobSettingImage = getImage(repositoryObject);
            }
            if (jobSettingImage == null) {
                jobSettingImage = getImageFromFramework(repositoryObjectType);
            }
            if (jobSettingImage == null) {
                jobSettingImage = ImageProvider.getImage(repositoryNode.getIcon());
            }
            setElement(repositoryObject, type + SEPARATOR + title, jobSettingImage);
        }
    }
}
Also used : IAdaptable(org.eclipse.core.runtime.IAdaptable) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) EmptyRepositoryObject(org.talend.core.model.repository.EmptyRepositoryObject) EmptyRepositoryObject(org.talend.core.model.repository.EmptyRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RepositoryNode(org.talend.repository.model.RepositoryNode) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) IImage(org.talend.commons.ui.runtime.image.IImage) ECoreImage(org.talend.commons.ui.runtime.image.ECoreImage) Image(org.eclipse.swt.graphics.Image)

Aggregations

IAdaptable (org.eclipse.core.runtime.IAdaptable)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)2 EmptyRepositoryObject (org.talend.core.model.repository.EmptyRepositoryObject)2 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)2 RepositoryNode (org.talend.repository.model.RepositoryNode)2 ISelection (org.eclipse.jface.viewers.ISelection)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 Image (org.eclipse.swt.graphics.Image)1 ECoreImage (org.talend.commons.ui.runtime.image.ECoreImage)1 IImage (org.talend.commons.ui.runtime.image.IImage)1