Search in sources :

Example 1 with IDiagramModelService

use of org.talend.designer.business.diagram.custom.IDiagramModelService 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 2 with IDiagramModelService

use of org.talend.designer.business.diagram.custom.IDiagramModelService 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)

Example 3 with IDiagramModelService

use of org.talend.designer.business.diagram.custom.IDiagramModelService in project tdi-studio-se by Talend.

the class BusinessAppearanceComposite method createTextAlignmentGroup.

private void createTextAlignmentGroup(Composite nearby) {
    Composite alignComposite = widgetFactory.createFlatFormComposite(this);
    alignComposite.setLayout(new GridLayout());
    FormData thisFormData = new FormData();
    thisFormData = new FormData();
    thisFormData.left = new FormAttachment(2, 0);
    thisFormData.right = new FormAttachment(100, 0);
    thisFormData.top = new FormAttachment(nearby, 2);
    thisFormData.bottom = new FormAttachment(100, 0);
    alignComposite.setLayoutData(thisFormData);
    Group textAlignment = widgetFactory.createGroup(alignComposite, Messages.getString(//$NON-NLS-1$
    "BusinessAppearanceComposite.textAlignmentGroup"));
    textAlignment.setBackground(getBackground());
    textAlignment.setLayout(new GridLayout(2, false));
    horizontalGroup = widgetFactory.createGroup(textAlignment, Messages.getString(//$NON-NLS-1$
    "BusinessAppearanceComposite.textAlignment.horizontal"));
    horizontalGroup.setLayout(new GridLayout(3, false));
    leftBtn = widgetFactory.createButton(horizontalGroup, Messages.getString("BusinessAppearanceComposite.textAlignment.horizontal.left"), //$NON-NLS-1$
    SWT.RADIO);
    hCentre = widgetFactory.createButton(horizontalGroup, Messages.getString("BusinessAppearanceComposite.textAlignment.horizontal.centre"), //$NON-NLS-1$
    SWT.RADIO);
    rightBtn = widgetFactory.createButton(horizontalGroup, Messages.getString("BusinessAppearanceComposite.textAlignment.horizontal.right"), //$NON-NLS-1$
    SWT.RADIO);
    verticalGroup = widgetFactory.createGroup(textAlignment, Messages.getString(//$NON-NLS-1$
    "BusinessAppearanceComposite.textAlignment.vertical"));
    verticalGroup.setLayout(new GridLayout(3, false));
    topBtn = widgetFactory.createButton(verticalGroup, Messages.getString("BusinessAppearanceComposite.textAlignment.vertical.top"), //$NON-NLS-1$
    SWT.RADIO);
    vCentre = widgetFactory.createButton(verticalGroup, Messages.getString("BusinessAppearanceComposite.textAlignment.vertical.centre"), //$NON-NLS-1$
    SWT.RADIO);
    bottomBtn = widgetFactory.createButton(verticalGroup, Messages.getString("BusinessAppearanceComposite.textAlignment.vertical.bottom"), //$NON-NLS-1$
    SWT.RADIO);
    Object obj = ((IStructuredSelection) selected).getFirstElement();
    IDiagramModelService service = CorePlugin.getDefault().getDiagramModelService();
    if (BusinessType.SHAP.equals(service.getBusinessModelType(obj))) {
        String horizontalAlignment = service.getBusinessItemAlignment(obj, BusinessAlignment.HORIZONTAL);
        if (horizontalAlignment == null) {
            horizontalAlignment = BusinessAlignment.LEFT.toString();
        }
        leftBtn.setSelection(BusinessAlignment.LEFT.toString().equals(horizontalAlignment));
        hCentre.setSelection(BusinessAlignment.HCENTRE.toString().equals(horizontalAlignment));
        rightBtn.setSelection(BusinessAlignment.RIGHT.toString().equals(horizontalAlignment));
        String verticalAlignment = service.getBusinessItemAlignment(obj, BusinessAlignment.VERTICAL);
        if (verticalAlignment == null) {
            verticalAlignment = BusinessAlignment.TOP.toString();
        }
        topBtn.setSelection(BusinessAlignment.TOP.toString().equals(verticalAlignment));
        vCentre.setSelection(BusinessAlignment.VCENTRE.toString().equals(verticalAlignment));
        bottomBtn.setSelection(BusinessAlignment.BOTTOM.toString().equals(verticalAlignment));
    }
    addListener();
}
Also used : FormData(org.eclipse.swt.layout.FormData) Group(org.eclipse.swt.widgets.Group) IDiagramModelService(org.talend.designer.business.diagram.custom.IDiagramModelService) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) AbstractTabComposite(org.talend.designer.core.ui.views.jobsettings.tabs.AbstractTabComposite) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 4 with IDiagramModelService

use of org.talend.designer.business.diagram.custom.IDiagramModelService in project tdi-studio-se by Talend.

the class BusinessAppearanceComposite method ChangModels.

private void ChangModels(BusinessAlignment alignment, BusinessAlignment type) {
    Object obj = ((IStructuredSelection) selected).getFirstElement();
    IDiagramModelService service = CorePlugin.getDefault().getDiagramModelService();
    if (BusinessType.SHAP.equals(service.getBusinessModelType(obj))) {
        service.setBusinessItemAlignment(alignment, type, obj);
    } else if (BusinessType.PROCESS.equals(service.getBusinessModelType(obj))) {
        service.setBusinessItemsAlignment(alignment, type, obj);
    }
}
Also used : IDiagramModelService(org.talend.designer.business.diagram.custom.IDiagramModelService) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Aggregations

IDiagramModelService (org.talend.designer.business.diagram.custom.IDiagramModelService)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 ISelection (org.eclipse.jface.viewers.ISelection)1 FormAttachment (org.eclipse.swt.layout.FormAttachment)1 FormData (org.eclipse.swt.layout.FormData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 Group (org.eclipse.swt.widgets.Group)1 IEditorPart (org.eclipse.ui.IEditorPart)1 IWorkbench (org.eclipse.ui.IWorkbench)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1 PartInitException (org.eclipse.ui.PartInitException)1 BusinessType (org.talend.core.model.business.BusinessType)1 Element (org.talend.core.model.process.Element)1 IProcess (org.talend.core.model.process.IProcess)1 EmptyRepositoryObject (org.talend.core.model.repository.EmptyRepositoryObject)1 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)1 AbstractMultiPageTalendEditor (org.talend.designer.core.ui.AbstractMultiPageTalendEditor)1 AbstractTalendEditor (org.talend.designer.core.ui.editor.AbstractTalendEditor)1 JobSettingsView (org.talend.designer.core.ui.views.jobsettings.JobSettingsView)1