Search in sources :

Example 1 with BusinessType

use of org.talend.core.model.business.BusinessType in project tdi-studio-se by Talend.

the class JobSettingsView method getCategories.

/**
     * set the category.
     */
private EComponentCategory[] getCategories(Object obj) {
    List<EComponentCategory> category = new ArrayList<EComponentCategory>();
    boolean isOfflineMode = CorePlugin.getDefault().getProxyRepositoryFactory().getRepositoryContext().isOffline();
    if (obj instanceof Process) {
        Process process = (Process) obj;
        category.add(EComponentCategory.MAIN);
        boolean isJoblet = AbstractProcessProvider.isExtensionProcessForJoblet(process);
        if (process.getComponentsType().equals(ComponentCategory.CATEGORY_4_DI.getName())) {
            category.add(EComponentCategory.EXTRA);
        }
        if (!isJoblet && process.getComponentsType().equals(ComponentCategory.CATEGORY_4_DI.getName())) {
            category.add(EComponentCategory.STATSANDLOGS);
        }
        if (allowVerchange) {
            category.add(EComponentCategory.VERSIONS);
        }
        if (!isJoblet && !ProcessUtils.isTestContainer(process) && ERepositoryObjectType.getItemType(process.getProperty().getItem()) != ERepositoryObjectType.PROCESS_ROUTELET) {
            category.add(EComponentCategory.DEPLOYMENT);
        }
        if (GlobalServiceRegister.getDefault().isServiceRegistered(IHeaderFooterProviderService.class)) {
            IHeaderFooterProviderService headerFooterService = (IHeaderFooterProviderService) GlobalServiceRegister.getDefault().getService(IHeaderFooterProviderService.class);
            if (headerFooterService.isVisible()) {
                category.add(EComponentCategory.HEADERFOOTER);
            }
        }
        // if svn remote connection, added by nma
        if (svnService != null && svnService.isProjectInSvnMode() && !isOfflineMode) {
            category.add(EComponentCategory.SVNHISTORY);
        }
        if (gitService != null && gitService.isProjectInGitMode() && !isOfflineMode) {
            category.add(EComponentCategory.GITHISTORY);
        }
    } else if (obj instanceof IRepositoryViewObject) {
        category.add(EComponentCategory.MAIN);
        if (allowVerchange) {
            category.add(EComponentCategory.VERSIONS);
        }
        if (svnService != null && svnService.isProjectInSvnMode() && !isOfflineMode && (((IRepositoryViewObject) obj).getRepositoryObjectType() == ERepositoryObjectType.JOBLET || ERepositoryObjectType.getAllTypesOfProcess().contains(((IRepositoryViewObject) obj).getRepositoryObjectType()))) {
            category.add(EComponentCategory.SVNHISTORY);
        } else if (gitService != null && gitService.isProjectInGitMode() && !isOfflineMode && (((IRepositoryViewObject) obj).getRepositoryObjectType() == ERepositoryObjectType.JOBLET || ERepositoryObjectType.getAllTypesOfProcess().contains(((IRepositoryViewObject) obj).getRepositoryObjectType()))) {
            category.add(EComponentCategory.GITHISTORY);
        }
    } else if (obj instanceof IEditorPart) {
        if (CorePlugin.getDefault().getDiagramModelService().isBusinessDiagramEditor((IEditorPart) obj)) {
            category.add(EComponentCategory.MAIN);
            category.add(EComponentCategory.APPEARANCE);
            category.add(EComponentCategory.RULERS_AND_GRID);
            if (allowVerchange) {
                category.add(EComponentCategory.VERSIONS);
            }
        }
    } else {
        BusinessType type = CorePlugin.getDefault().getDiagramModelService().getBusinessModelType(obj);
        if (BusinessType.SHAP.equals(type) || BusinessType.CONNECTION.equals(type)) {
            category.add(EComponentCategory.APPEARANCE);
            category.add(EComponentCategory.ASSIGNMENT);
        } else if (BusinessType.NOTE.equals(type)) {
            category.add(EComponentCategory.APPEARANCE);
        }
    }
    return category.toArray(new EComponentCategory[0]);
}
Also used : IHeaderFooterProviderService(org.talend.core.ui.IHeaderFooterProviderService) ArrayList(java.util.ArrayList) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) BusinessType(org.talend.core.model.business.BusinessType) IProcess(org.talend.core.model.process.IProcess) Process(org.talend.designer.core.ui.editor.process.Process) IEditorPart(org.eclipse.ui.IEditorPart) EComponentCategory(org.talend.core.model.process.EComponentCategory)

Example 2 with BusinessType

use of org.talend.core.model.business.BusinessType in project tdi-studio-se by Talend.

the class JobSettingsView method setElement.

/**
     *
     * DOC ggu Comment method "setElement".
     *
     * @param obj
     */
private void setElement(Object obj, final String title, Image image) {
    EComponentCategory[] categories = null;
    if (obj != null && obj instanceof Process) {
        process = (Process) obj;
        if (currentSelectedTab != null && currentSelectedTab.getData().equals(process) && !cleaned) {
            return;
        }
        categories = getCategories(process);
    } else if (obj != null && obj instanceof IRepositoryViewObject) {
        categories = getCategories(obj);
        IRepositoryViewObject viewObject = (IRepositoryViewObject) obj;
        IProcess process = getProcess(viewObject);
        if (process != null && process instanceof Element && process.getId().equals(viewObject.getId()) && process.getVersion().equals(viewObject.getVersion())) {
            categories = getCategories(process);
        }
    } else if (obj instanceof IEditorPart) {
        if (CorePlugin.getDefault().getDiagramModelService().isBusinessDiagramEditor((IEditorPart) obj)) {
            categories = getCategories(obj);
        }
    } else {
        BusinessType type = CorePlugin.getDefault().getDiagramModelService().getBusinessModelType(obj);
        if (BusinessType.NOTE.equals(type) || BusinessType.SHAP.equals(type) || BusinessType.CONNECTION.equals(type)) {
            categories = getCategories(obj);
        } else {
            cleanDisplay();
            return;
        }
    }
    final List<TalendPropertyTabDescriptor> descriptors = new ArrayList<TalendPropertyTabDescriptor>();
    for (EComponentCategory category : categories) {
        TalendPropertyTabDescriptor d = new TalendPropertyTabDescriptor(category);
        d.setData(obj);
        descriptors.add(d);
    }
    tabFactory.setInput(descriptors);
    setPartName(title, image);
    cleaned = false;
    tabFactory.setSelection(new IStructuredSelection() {

        @Override
        public Object getFirstElement() {
            return null;
        }

        @Override
        public Iterator iterator() {
            return null;
        }

        @Override
        public int size() {
            return 0;
        }

        @Override
        public Object[] toArray() {
            return null;
        }

        @Override
        public List toList() {
            List<TalendPropertyTabDescriptor> d = new ArrayList<TalendPropertyTabDescriptor>();
            if (descriptors.size() > 0) {
                if (currentSelectedTab != null) {
                    for (TalendPropertyTabDescriptor ds : descriptors) {
                        if (ds.getCategory() == currentSelectedTab.getCategory()) {
                            d.add(ds);
                            return d;
                        }
                    }
                }
                d.add(descriptors.get(0));
            }
            return d;
        }

        @Override
        public boolean isEmpty() {
            return false;
        }
    });
}
Also used : Element(org.talend.core.model.process.Element) BusinessType(org.talend.core.model.business.BusinessType) ArrayList(java.util.ArrayList) IProcess(org.talend.core.model.process.IProcess) Process(org.talend.designer.core.ui.editor.process.Process) IEditorPart(org.eclipse.ui.IEditorPart) TalendPropertyTabDescriptor(org.talend.core.ui.properties.tab.TalendPropertyTabDescriptor) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Iterator(java.util.Iterator) EmptyRepositoryObject(org.talend.core.model.repository.EmptyRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) List(java.util.List) ArrayList(java.util.ArrayList) IProcess(org.talend.core.model.process.IProcess) EComponentCategory(org.talend.core.model.process.EComponentCategory)

Example 3 with BusinessType

use of org.talend.core.model.business.BusinessType in project tdi-studio-se by Talend.

the class ShowJobSettingsViewAction method run.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
public void run() {
    IWorkbench workbench = PlatformUI.getWorkbench();
    IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
    try {
        page.showView(getViewId());
        JobSettingsView view = (JobSettingsView) page.findView(getViewId());
        IDiagramModelService service = CorePlugin.getDefault().getDiagramModelService();
        ISelection selection = service.getBusinessEditorSelection(page.getActiveEditor());
        if (selection instanceof IStructuredSelection) {
            Object firstElement = ((IStructuredSelection) selection).getFirstElement();
            if (firstElement != null) {
                BusinessType type = service.getBusinessModelType(firstElement);
                if (type == BusinessType.CONNECTION || type == BusinessType.NOTE || type == BusinessType.SHAP) {
                    view.refresh(false, firstElement);
                } else if (type == BusinessType.PROCESS || service.isInstanceOfCompartmentEditPart(firstElement)) {
                    view.refresh(false, PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor());
                }
            }
        }
    } catch (PartInitException e) {
        // e.printStackTrace();
        ExceptionHandler.process(e);
    }
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) JobSettingsView(org.talend.designer.core.ui.views.jobsettings.JobSettingsView) IDiagramModelService(org.talend.designer.business.diagram.custom.IDiagramModelService) ISelection(org.eclipse.jface.viewers.ISelection) BusinessType(org.talend.core.model.business.BusinessType) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) PartInitException(org.eclipse.ui.PartInitException)

Aggregations

BusinessType (org.talend.core.model.business.BusinessType)3 ArrayList (java.util.ArrayList)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 IEditorPart (org.eclipse.ui.IEditorPart)2 EComponentCategory (org.talend.core.model.process.EComponentCategory)2 IProcess (org.talend.core.model.process.IProcess)2 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)2 Process (org.talend.designer.core.ui.editor.process.Process)2 Iterator (java.util.Iterator)1 List (java.util.List)1 ISelection (org.eclipse.jface.viewers.ISelection)1 IWorkbench (org.eclipse.ui.IWorkbench)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1 PartInitException (org.eclipse.ui.PartInitException)1 Element (org.talend.core.model.process.Element)1 EmptyRepositoryObject (org.talend.core.model.repository.EmptyRepositoryObject)1 IHeaderFooterProviderService (org.talend.core.ui.IHeaderFooterProviderService)1 TalendPropertyTabDescriptor (org.talend.core.ui.properties.tab.TalendPropertyTabDescriptor)1 IDiagramModelService (org.talend.designer.business.diagram.custom.IDiagramModelService)1 JobSettingsView (org.talend.designer.core.ui.views.jobsettings.JobSettingsView)1