Search in sources :

Example 6 with Element

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

the class ProcessView method createPartControl.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
     */
@Override
public void createPartControl(Composite parent) {
    this.parent = parent;
    parent.setLayout(new FillLayout());
    sash = new SashForm(parent, SWT.HORIZONTAL | SWT.SMOOTH);
    sash.setLayoutData(new GridData(GridData.FILL_BOTH));
    sash.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    GridLayout layout = new GridLayout();
    sash.setLayout(layout);
    Composite left = new Composite(sash, SWT.NONE);
    left.setLayout(new FillLayout());
    Composite right = new Composite(sash, SWT.NONE);
    right.setLayout(new FormLayout());
    FormData layouDatag = new FormData();
    layouDatag.left = new FormAttachment(0, 0);
    layouDatag.width = 32;
    layouDatag.top = new FormAttachment(0, 0);
    layouDatag.bottom = new FormAttachment(100, 0);
    final Composite buttonComposite = new Composite(right, SWT.ERROR);
    buttonComposite.setLayoutData(layouDatag);
    buttonComposite.setLayout(new GridLayout());
    Composite cotextCom = new Composite(right, SWT.NONE);
    layouDatag = new FormData();
    layouDatag.left = new FormAttachment(0, 32);
    layouDatag.right = new FormAttachment(100, 0);
    layouDatag.top = new FormAttachment(0, 0);
    layouDatag.bottom = new FormAttachment(100, 0);
    cotextCom.setLayoutData(layouDatag);
    cotextCom.setLayout(new GridLayout());
    tabFactory.initComposite(left, false);
    moveButton = new Button(buttonComposite, SWT.PUSH);
    //$NON-NLS-1$
    moveButton.setText(">>");
    moveButton.setToolTipText(Messages.getString("ProcessComposite.hideContext"));
    final GridData layoutData = new GridData();
    layoutData.verticalAlignment = GridData.CENTER;
    layoutData.horizontalAlignment = GridData.CENTER;
    layoutData.grabExcessHorizontalSpace = true;
    layoutData.grabExcessVerticalSpace = true;
    moveButton.setLayoutData(layoutData);
    addListeners();
    sash.setSashWidth(5);
    sash.setWeights(new int[] { 18, 5 });
    contextComposite = new ProcessContextComposite(cotextCom, SWT.NONE);
    contextComposite.setBackground(right.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    // processComposite = new ProcessComposite(tabFactory.getTabComposite(), SWT.H_SCROLL | SWT.V_SCROLL |
    // SWT.NO_FOCUS);
    // dc = processComposite;
    // createBasicComposite(tabFactory.getTabComposite(), element, null);
    tabFactory.getTabComposite().layout();
    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 && (currentSelectedTab.getCategory() != descriptor.getCategory())) {
                for (Control curControl : tabFactory.getTabComposite().getChildren()) {
                    curControl.dispose();
                }
            }
            if (currentSelectedTab == null || currentSelectedTab.getCategory() != descriptor.getCategory() || selectedPrimary) {
                currentSelectedTab = descriptor;
                selectedPrimary = false;
                createDynamicComposite(tabFactory.getTabComposite(), (Element) descriptor.getData(), descriptor.getCategory());
            }
        }
    });
    setElement();
    IHandlerService handlerService = (IHandlerService) getSite().getService(IHandlerService.class);
    IHandler handler1;
    IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
    if (brandingService.getBrandingConfiguration().isAllowDebugMode()) {
        Action debugAction = new DebugAction();
        handler1 = new ActionHandler(debugAction);
        handlerService.activateHandler(debugAction.getActionDefinitionId(), handler1);
    }
    Action killAction = new KillAction();
    handler1 = new ActionHandler(killAction);
    handlerService.activateHandler(killAction.getActionDefinitionId(), handler1);
    FocusListener fl = new FocusListener() {

        @Override
        public void focusGained(FocusEvent e) {
            //$NON-NLS-1$
            log.trace(Messages.getString("ProcessView.gainFocusLog"));
            IContextService contextService = (IContextService) RunProcessPlugin.getDefault().getWorkbench().getAdapter(IContextService.class);
            //$NON-NLS-1$
            ca = contextService.activateContext("talend.runProcess");
        }

        @Override
        public void focusLost(FocusEvent e) {
            //$NON-NLS-1$
            log.trace(Messages.getString("ProcessView.lostFocusLog"));
            if (ca != null) {
                IContextService contextService = (IContextService) RunProcessPlugin.getDefault().getWorkbench().getAdapter(IContextService.class);
                contextService.deactivateContext(ca);
            }
        }
    };
    addListenerOnChildren(parent, fl);
    rubjobManager.setProcessShell(getSite().getShell());
    contextManagerListener = new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (RunProcessContextManager.PROP_ACTIVE.equals(evt.getPropertyName())) {
                // rubjobManager.setBooleanTrace(false);
                runningProcessChanged();
            }
        }
    };
    RunProcessPlugin.getDefault().getRunProcessContextManager().addPropertyChangeListener(contextManagerListener);
    runAction = new RunAction();
}
Also used : Action(org.eclipse.jface.action.Action) ClearPerformanceAction(org.talend.designer.runprocess.ui.actions.ClearPerformanceAction) PropertyChangeListener(java.beans.PropertyChangeListener) Element(org.talend.core.model.process.Element) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) FocusEvent(org.eclipse.swt.events.FocusEvent) GridLayout(org.eclipse.swt.layout.GridLayout) ProcessContextComposite(org.talend.designer.runprocess.ui.ProcessContextComposite) Control(org.eclipse.swt.widgets.Control) Button(org.eclipse.swt.widgets.Button) IContextService(org.eclipse.ui.contexts.IContextService) FormAttachment(org.eclipse.swt.layout.FormAttachment) FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) PropertyChangeEvent(java.beans.PropertyChangeEvent) TraceDebugProcessComposite(org.talend.designer.runprocess.ui.TraceDebugProcessComposite) Composite(org.eclipse.swt.widgets.Composite) TargetExecComposite(org.talend.designer.runprocess.ui.TargetExecComposite) MemoryRuntimeComposite(org.talend.designer.runprocess.ui.MemoryRuntimeComposite) AdvanceSettingComposite(org.talend.designer.runprocess.ui.AdvanceSettingComposite) MultipleThreadDynamicComposite(org.talend.designer.core.ui.views.properties.MultipleThreadDynamicComposite) ProcessComposite(org.talend.designer.runprocess.ui.ProcessComposite) ProcessContextComposite(org.talend.designer.runprocess.ui.ProcessContextComposite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) FillLayout(org.eclipse.swt.layout.FillLayout) TalendPropertyTabDescriptor(org.talend.core.ui.properties.tab.TalendPropertyTabDescriptor) IBrandingService(org.talend.core.ui.branding.IBrandingService) SashForm(org.eclipse.swt.custom.SashForm) IHandlerService(org.eclipse.ui.handlers.IHandlerService) GridData(org.eclipse.swt.layout.GridData) IHandler(org.eclipse.core.commands.IHandler) ActionHandler(org.eclipse.ui.commands.ActionHandler) FocusListener(org.eclipse.swt.events.FocusListener)

Example 7 with Element

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

the class ProcessView method createDynamicComposite.

public void createDynamicComposite(Composite parent, Element element, EComponentCategory category) {
    contextComposite.setVisible(true);
    moveButton.setVisible(true);
    if (moveButton.getText().equals(">>")) {
        //$NON-NLS-1$
        sash.setWeights(new int[] { 18, 5 });
    } else if (moveButton.getText().equals("<<")) {
        //$NON-NLS-1$
        sash.setWeights(new int[] { 23, 1 });
    }
    if (category == EComponentCategory.BASICRUN) {
        processComposite = new ProcessComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS);
        dc = processComposite;
    } else if (category == EComponentCategory.DEBUGRUN) {
        debugTisProcessComposite = this.debugViewHelper.getDebugComposite(parent);
        // CSS
        CoreUIPlugin.setCSSClass(debugTisProcessComposite, TraceDebugProcessComposite.class.getSimpleName());
        dc = debugTisProcessComposite;
    } else if (category == EComponentCategory.ADVANCESETTING) {
        advanceComposite = new AdvanceSettingComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS);
        dc = advanceComposite;
    } else if (category == EComponentCategory.TARGET) {
        targetComposite = new TargetExecComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS);
        dc = targetComposite;
    } else if (category == EComponentCategory.MEMORYRUN) {
        memoryRunComposite = new MemoryRuntimeComposite(findProcessView(), parent, processContext, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS);
        dc = memoryRunComposite;
        contextComposite.setVisible(false);
        moveButton.setVisible(false);
        sash.setWeights(new int[] { 90, 1 });
    }
    if (EComponentCategory.MAPREDUCE_JOB_CONFIG_FOR_HADOOP.equals(category) || EComponentCategory.STORM_JOB_CONFIG.equals(category) || EComponentCategory.SPARK_JOB_CONFIG.equals(category)) {
        if (processContext != null) {
            dc = new MultipleThreadDynamicComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, category, (Element) processContext.getProcess(), true, Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
            // CSS
            CoreUIPlugin.setCSSClass(dc, dc.getClass().getSimpleName());
        } else {
            dc = null;
        }
        sash.setWeights(new int[] { 24, 0 });
    }
    refresh();
    if (dc != null) {
        dc.refresh();
    }
}
Also used : AdvanceSettingComposite(org.talend.designer.runprocess.ui.AdvanceSettingComposite) MemoryRuntimeComposite(org.talend.designer.runprocess.ui.MemoryRuntimeComposite) Element(org.talend.core.model.process.Element) TargetExecComposite(org.talend.designer.runprocess.ui.TargetExecComposite) TraceDebugProcessComposite(org.talend.designer.runprocess.ui.TraceDebugProcessComposite) ProcessComposite(org.talend.designer.runprocess.ui.ProcessComposite) MultipleThreadDynamicComposite(org.talend.designer.core.ui.views.properties.MultipleThreadDynamicComposite)

Example 8 with Element

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

the class ComponentSettingsView method createPartControl.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
     */
@Override
public void createPartControl(Composite parent) {
    this.parent = parent;
    tabFactory.initComposite(parent, true);
    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 && (!currentSelectedTab.getData().equals(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) {
                element = (Element) descriptor.getData();
                currentSelectedTab = descriptor;
                if (descriptor.getData() instanceof ConnectionLabel) {
                    createDynamicComposite(tabFactory.getTabComposite(), ((ConnectionLabel) descriptor.getData()).getConnection(), descriptor.getCategory());
                } else {
                    createDynamicComposite(tabFactory.getTabComposite(), (Element) descriptor.getData(), descriptor.getCategory());
                }
                selectedPrimary = false;
            }
        }
    });
}
Also used : Control(org.eclipse.swt.widgets.Control) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Element(org.talend.core.model.process.Element) IElement(org.talend.core.model.process.IElement) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TalendPropertyTabDescriptor(org.talend.core.ui.properties.tab.TalendPropertyTabDescriptor) ConnectionLabel(org.talend.designer.core.ui.editor.connections.ConnectionLabel)

Example 9 with Element

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

the class MissingSettingsMultiThreadDynamicComposite method afterCreateMessagesComposite.

@Override
public void afterCreateMessagesComposite(MessagesComposite messComposite) {
    final Element ele = this.getElement();
    if (ele instanceof Node && isVisibleTopMessages()) {
        final IComponent component = ((Node) ele).getComponent();
        messComposite.updateTopMessages(//$NON-NLS-1$
        Messages.getString(//$NON-NLS-1$
        "MissingSettingsMultiThreadDynamicComposite_missingModulesMessages", component.getName()), IStatus.WARNING);
        if (messComposite instanceof MessagesWithActionComposite) {
            MessagesWithActionComposite messWithActionComposite = (MessagesWithActionComposite) messComposite;
            messWithActionComposite.updateActionButton(//$NON-NLS-1$
            Messages.getString("MissingSettingsMultiThreadDynamicComposite.installName") + "...", //$NON-NLS-1$
            null);
            messWithActionComposite.addActionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    if (!missModulesNeeded.isEmpty()) {
                        ModulesInstallerUtil.forceInstallModules(getShell(), component, missModulesNeeded);
                        checkVisibleTopMessages();
                    }
                }
            });
        }
    }
    super.afterCreateMessagesComposite(messComposite);
}
Also used : IComponent(org.talend.core.model.components.IComponent) Element(org.talend.core.model.process.Element) Node(org.talend.designer.core.ui.editor.nodes.Node) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MessagesWithActionComposite(org.talend.commons.ui.swt.composites.MessagesWithActionComposite)

Example 10 with Element

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

the class MissingSettingsMultiThreadDynamicComposite method checkVisibleTopMessages.

@Override
protected void checkVisibleTopMessages() {
    missModulesNeeded.clear();
    final Element ele = this.getElement();
    if (ele instanceof Node) {
        // get not installed modules
        List<ModuleNeeded> updatedModules = LibrariesManagerUtils.getNotInstalledModules(((Node) ele));
        missModulesNeeded.addAll(updatedModules);
    }
    setVisibleTopMessage(!missModulesNeeded.isEmpty());
}
Also used : Element(org.talend.core.model.process.Element) Node(org.talend.designer.core.ui.editor.nodes.Node) ModuleNeeded(org.talend.core.model.general.ModuleNeeded)

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