Search in sources :

Example 1 with Element

use of org.talend.core.model.process.Element in project tdi-studio-se by Talend.

the class JobSettingsView method createPartControl.

@Override
public void createPartControl(Composite parent) {
    // tabFactory = new HorizontalTabFactory();
    this.parent = parent;
    tabFactory.initComposite(parent, false);
    tabFactory.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            TalendPropertyTabDescriptor descriptor = (TalendPropertyTabDescriptor) selection.getFirstElement();
            if (descriptor == null) {
                return;
            }
            if (currentSelectedTab != null) {
                if ((!currentSelectedTab.getData().equals(descriptor.getData()) || currentSelectedTab.getData() != descriptor.getData() || currentSelectedTab.getCategory() != descriptor.getCategory())) {
                    for (Control curControl : tabFactory.getTabComposite().getChildren()) {
                        curControl.dispose();
                    }
                }
            }
            if (element == null || !element.equals(descriptor.getData()) || currentSelectedTab == null || currentSelectedTab.getCategory() != descriptor.getCategory() || selectedPrimary) {
                Object data = descriptor.getData();
                if (data instanceof Element) {
                    element = (Element) data;
                    currentSelectedTab = descriptor;
                    IDynamicProperty propertyComposite = createTabComposite(tabFactory.getTabComposite(), element, descriptor.getCategory());
                } else if (data instanceof IRepositoryViewObject) {
                    IRepositoryViewObject viewObject = (IRepositoryViewObject) data;
                    IProcess process = getProcess(viewObject);
                    if (process != null && process instanceof Element && process.getId().equals(viewObject.getId()) && process.getVersion().equals(viewObject.getVersion())) {
                        data = process;
                    }
                    currentSelectedTab = descriptor;
                    IDynamicProperty propertyComposite = createTabComposite(tabFactory.getTabComposite(), data, descriptor.getCategory());
                } else if (data instanceof IEditorPart) {
                    currentSelectedTab = descriptor;
                    IRepositoryViewObject repObj = retrieveBusiness((IEditorPart) data);
                    if (repObj != null) {
                        IDynamicProperty propertyComposite = createTabComposite(tabFactory.getTabComposite(), repObj, descriptor.getCategory());
                    }
                } else {
                    currentSelectedTab = descriptor;
                    IDynamicProperty propertyComposite = createTabComposite(tabFactory.getTabComposite(), null, descriptor.getCategory());
                }
                selectedPrimary = false;
            }
        }
    });
}
Also used : Control(org.eclipse.swt.widgets.Control) IDynamicProperty(org.talend.core.ui.properties.tab.IDynamicProperty) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Element(org.talend.core.model.process.Element) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) EmptyRepositoryObject(org.talend.core.model.repository.EmptyRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TalendPropertyTabDescriptor(org.talend.core.ui.properties.tab.TalendPropertyTabDescriptor) IEditorPart(org.eclipse.ui.IEditorPart) IProcess(org.talend.core.model.process.IProcess)

Example 2 with Element

use of org.talend.core.model.process.Element in project tdi-studio-se by Talend.

the class JobSettingsView method refresh.

public void refresh(boolean force, Object obj) {
    if (force) {
        cleanDisplay();
    }
    final IEditorPart activeEditor = getSite().getPage().getActiveEditor();
    if (obj == null) {
        if (activeEditor != null && activeEditor instanceof AbstractMultiPageTalendEditor) {
            AbstractTalendEditor talendEditor = ((AbstractMultiPageTalendEditor) activeEditor).getTalendEditor();
            IProcess process = talendEditor.getProcess();
            if (process != null && process instanceof Element) {
                this.selectedPrimary = true;
                this.cleaned = force;
                this.element = (Element) process;
                // remove "Job" or "Joblet" from title
                String title = activeEditor.getTitle();
                if (title.startsWith(VIEW_NAME_JOBLET)) {
                    title = title.substring(VIEW_NAME_JOBLET.length() + 1);
                } else if (title.startsWith(getViewNameLable())) {
                    title = title.substring(getViewNameLable().length() + 1);
                }
                setElement(element, title, null);
                return;
            }
        } else {
            IDiagramModelService diagramModelService = CorePlugin.getDefault().getDiagramModelService();
            if (diagramModelService != null && diagramModelService.isBusinessDiagramEditor(activeEditor)) {
                this.selectedPrimary = true;
                this.cleaned = force;
                IRepositoryViewObject object = retrieveBusiness(activeEditor);
                if (object != null) {
                    //$NON-NLS-1$
                    String title = object.getLabel() + " " + object.getVersion();
                    Object type = object.getRepositoryObjectType();
                    setElement(activeEditor, type + SEPARATOR + title, null);
                }
                return;
            }
        }
    } else {
        this.selectedPrimary = true;
        this.cleaned = force;
        IRepositoryViewObject object = retrieveBusiness(activeEditor);
        if (object != null) {
            //$NON-NLS-1$
            String title = object.getLabel() + " " + object.getVersion();
            Object type = object.getRepositoryObjectType();
            setElement(obj, type + SEPARATOR + title, null);
        }
        return;
    }
    cleanDisplay();
}
Also used : IDiagramModelService(org.talend.designer.business.diagram.custom.IDiagramModelService) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) AbstractTalendEditor(org.talend.designer.core.ui.editor.AbstractTalendEditor) Element(org.talend.core.model.process.Element) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) EmptyRepositoryObject(org.talend.core.model.repository.EmptyRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IEditorPart(org.eclipse.ui.IEditorPart) IProcess(org.talend.core.model.process.IProcess)

Example 3 with Element

use of org.talend.core.model.process.Element in project tdi-studio-se by Talend.

the class JobSettingsView method createTabComposite.

private IDynamicProperty createTabComposite(Composite parent, Object data, EComponentCategory category) {
    final int style = SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS;
    IDynamicProperty dynamicComposite = null;
    if (EComponentCategory.EXTRA.equals(category)) {
        // achen modify to fix bug 0006241
        Process process = getElement();
        boolean isJoblet = AbstractProcessProvider.isExtensionProcessForJoblet(process);
        if (isJoblet) {
            dynamicComposite = new MultipleThreadDynamicComposite(parent, style, category, (Element) data, true);
        } else {
            dynamicComposite = new ExtraComposite(parent, style, category, (Element) data, true);
            CoreUIPlugin.setCSSId(dynamicComposite.getComposite(), //$NON-NLS-1$
            "org-talend-designer-core-ui-views-jobsettings-JobSettingsView-ExtraComposite");
        }
    } else if (EComponentCategory.STATSANDLOGS.equals(category)) {
        dynamicComposite = new StatsAndLogsComposite(parent, style, category, (Element) data);
        CoreUIPlugin.setCSSId(dynamicComposite.getComposite(), //$NON-NLS-1$
        "org-talend-designer-core-ui-views-jobsettings-JobSettingsView-StatsAndLogsComposite");
    } else if (EComponentCategory.CONTEXT.equals(category)) {
    // TODO
    // dynamicComposite = new ContextDynamicComposite(parent, style, category, element);
    } else if (EComponentCategory.MAIN.equals(category)) {
        dynamicComposite = new MainComposite(parent, SWT.NONE, tabFactory, (IRepositoryViewObject) data);
    } else if (EComponentCategory.VERSIONS.equals(category)) {
        if (allowVerchange) {
            dynamicComposite = new ProcessVersionComposite(parent, SWT.NONE, tabFactory.getWidgetFactory(), (IRepositoryViewObject) data);
        }
    } else if (EComponentCategory.HEADERFOOTER.equals(category)) {
        if (GlobalServiceRegister.getDefault().isServiceRegistered(IHeaderFooterProviderService.class)) {
            IHeaderFooterProviderService headerFooterService = (IHeaderFooterProviderService) GlobalServiceRegister.getDefault().getService(IHeaderFooterProviderService.class);
            if (headerFooterService.isVisible()) {
                dynamicComposite = new HeaderFooterComposite(parent, SWT.NONE, tabFactory.getWidgetFactory(), (IRepositoryViewObject) data);
            }
        }
    } else if (EComponentCategory.SVNHISTORY.equals(category) && svnUIService != null) {
        dynamicComposite = svnUIService.createProcessSVNHistoryComposite(parent, tabFactory.getWidgetFactory(), (IRepositoryViewObject) data);
    } else if (EComponentCategory.GITHISTORY.equals(category) && gitUIService != null) {
        dynamicComposite = gitUIService.createProcessGitHistoryComposite(parent, this, tabFactory.getWidgetFactory(), (IRepositoryViewObject) data);
    } else if (EComponentCategory.APPEARANCE.equals(category)) {
        dynamicComposite = (IDynamicProperty) CorePlugin.getDefault().getDiagramModelService().getBusinessAppearanceComposite(parent, SWT.NONE, tabFactory.getWidgetFactory(), selectedModel);
    } else if (EComponentCategory.RULERS_AND_GRID.equals(category)) {
        dynamicComposite = (IDynamicProperty) CorePlugin.getDefault().getDiagramModelService().getBusinessRulersAndGridComposite(parent, SWT.NONE, tabFactory.getWidgetFactory(), null);
    } else if (EComponentCategory.ASSIGNMENT.equals(category)) {
        dynamicComposite = (IDynamicProperty) CorePlugin.getDefault().getDiagramModelService().getBusinessAssignmentComposite(parent, SWT.NONE, tabFactory.getWidgetFactory(), selectedModel);
    } else if (EComponentCategory.DEPLOYMENT.equals(category)) {
        dynamicComposite = new DeploymentComposite(parent, SWT.NONE, tabFactory.getWidgetFactory(), (IRepositoryViewObject) data);
    }
    if (dynamicComposite != null) {
        dynamicComposite.refresh();
    }
    currentSelectedTab.setPropertyComposite(dynamicComposite);
    return dynamicComposite;
}
Also used : IDynamicProperty(org.talend.core.ui.properties.tab.IDynamicProperty) Element(org.talend.core.model.process.Element) IProcess(org.talend.core.model.process.IProcess) Process(org.talend.designer.core.ui.editor.process.Process) StatsAndLogsComposite(org.talend.designer.core.ui.views.statsandlogs.StatsAndLogsComposite) MultipleThreadDynamicComposite(org.talend.designer.core.ui.views.properties.MultipleThreadDynamicComposite) ProcessVersionComposite(org.talend.designer.core.ui.views.jobsettings.tabs.ProcessVersionComposite) HeaderFooterComposite(org.talend.designer.core.ui.views.jobsettings.tabs.HeaderFooterComposite) DeploymentComposite(org.talend.designer.core.ui.views.jobsettings.tabs.DeploymentComposite) IHeaderFooterProviderService(org.talend.core.ui.IHeaderFooterProviderService) MainComposite(org.talend.designer.core.ui.views.jobsettings.tabs.MainComposite) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject)

Example 4 with Element

use of org.talend.core.model.process.Element 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 5 with Element

use of org.talend.core.model.process.Element in project tdi-studio-se by Talend.

the class AbstractPreferenceComposite method refresh.

@Override
public void refresh() {
    super.refresh();
    Element element = getElement();
    if (element != null && element instanceof IProcess) {
        IProcess process = (IProcess) element;
        if (reloadBtn != null && !reloadBtn.isDisposed()) {
            reloadBtn.setEnabled(!process.isReadOnly());
        }
        if (saveBtn != null && !saveBtn.isDisposed()) {
            saveBtn.setEnabled(!process.isReadOnly());
        }
        if (applyToChildrenJob != null && !applyToChildrenJob.isDisposed()) {
            applyToChildrenJob.setEnabled(!process.isReadOnly());
        }
    }
}
Also used : Element(org.talend.core.model.process.Element) IElement(org.talend.core.model.process.IElement) IProcess(org.talend.core.model.process.IProcess)

Aggregations

Element (org.talend.core.model.process.Element)37 IProcess (org.talend.core.model.process.IProcess)11 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)11 IElementParameter (org.talend.core.model.process.IElementParameter)6 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)5 IElement (org.talend.core.model.process.IElement)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 TalendPropertyTabDescriptor (org.talend.core.ui.properties.tab.TalendPropertyTabDescriptor)4 FakeElement (org.talend.designer.core.model.FakeElement)4 Process (org.talend.designer.core.ui.editor.process.Process)4 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)3 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)3 Control (org.eclipse.swt.widgets.Control)3 IEditorPart (org.eclipse.ui.IEditorPart)3 Test (org.junit.Test)3 IProcess2 (org.talend.core.model.process.IProcess2)3 EmptyRepositoryObject (org.talend.core.model.repository.EmptyRepositoryObject)3 Form (org.talend.daikon.properties.presentation.Form)3 ChangeValuesFromRepository (org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository)3