Search in sources :

Example 96 with IComponent

use of org.talend.core.model.components.IComponent in project tdi-studio-se by Talend.

the class TalendEditorComponentCreationAssist method acceptProposal.

/**
     * create component at current position, according to select proposal label DOC talend2 Comment method
     * "createComponent".
     * 
     * @param componentName
     * @param location
     */
protected void acceptProposal() {
    String componentName = assistText.getText().trim();
    Iterator<IContentProposal> iter = proposalList.iterator();
    IComponent component = null;
    while (iter.hasNext()) {
        IContentProposal proposal = iter.next();
        if (proposal instanceof ComponentContentProposal && componentName.equals(proposal.getLabel())) {
            component = ((ComponentContentProposal) proposal).getComponent();
            break;
        }
    }
    acceptProposal(component);
}
Also used : IContentProposal(org.eclipse.jface.fieldassist.IContentProposal) IComponent(org.talend.core.model.components.IComponent)

Example 97 with IComponent

use of org.talend.core.model.components.IComponent in project tdi-studio-se by Talend.

the class TalendEditorComponentLabelProvider method getImage.

/*
     * return the icon of each proposal(non-Javadoc)
     * 
     * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
     */
@Override
public Image getImage(Object element) {
    if (element != null && element instanceof ComponentContentProposal) {
        ComponentContentProposal proposal = (ComponentContentProposal) element;
        IComponent iComponent = proposal.getComponent();
        if (iComponent != null && iComponent.getIcon16() != null) {
            return CoreImageProvider.getComponentImageFromDesc(iComponent.getIcon16());
        }
    }
    return super.getImage(element);
}
Also used : IComponent(org.talend.core.model.components.IComponent)

Example 98 with IComponent

use of org.talend.core.model.components.IComponent in project tdi-studio-se by Talend.

the class AbstractComponent method equals.

@Override
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }
    if (obj == null) {
        return false;
    }
    if (!(obj instanceof IComponent)) {
        return false;
    }
    final IComponent other = (IComponent) obj;
    String thisName = this.getName();
    String otherName = other.getName();
    if (thisName == null) {
        if (otherName != null) {
            return false;
        }
    } else if (!thisName.equals(otherName)) {
        return false;
    } else if (paletteType == null) {
        if (other.getPaletteType() != null) {
            return false;
        }
    } else if (!paletteType.equals(other.getPaletteType())) {
        return false;
    }
    return true;
}
Also used : IComponent(org.talend.core.model.components.IComponent)

Example 99 with IComponent

use of org.talend.core.model.components.IComponent in project tdi-studio-se by Talend.

the class ComponentSettingsView method createDynamicComposite.

/**
     * yzhang Comment method "createDynamicComposite".
     * 
     * @param parent
     * @param element
     * @param category
     */
private void createDynamicComposite(final Composite parent, Element element, EComponentCategory category) {
    // DynamicComposite dc = null;
    getParentMap().put(ComponentSettingsView.PARENT, parent);
    getCategoryMap().put(ComponentSettingsView.CATEGORY, category);
    if (element instanceof Node) {
        IComponent component = ((Node) element).getComponent();
        IGenericWizardService wizardService = null;
        boolean generic = false;
        if (EComponentType.GENERIC.equals(component.getComponentType())) {
            generic = true;
            if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
                wizardService = (IGenericWizardService) GlobalServiceRegister.getDefault().getService(IGenericWizardService.class);
            }
        }
        tabFactory.getTabbedPropertyComposite().setCompactViewVisible(false);
        if (category == EComponentCategory.BASIC) {
            // getElementMap().put(ComponentSettingsView.ELEMENT, element);
            createButtonListener();
            boolean isCompactView = true;
            if (ComponentSettingsView.TABLEVIEW.equals(getPreference().getString(TalendDesignerPrefConstants.VIEW_OPTIONS))) {
                isCompactView = false;
            }
            tabFactory.getTabbedPropertyComposite().setCompactViewVisible(true);
            tabFactory.getTabbedPropertyComposite().setCompactView(isCompactView);
            // Generic
            if (generic && wizardService != null) {
                Composite composite = wizardService.creatDynamicComposite(parent, element, EComponentCategory.BASIC, true);
                if (composite instanceof MultipleThreadDynamicComposite) {
                    dc = (MultipleThreadDynamicComposite) composite;
                }
            } else {
                dc = new MissingSettingsMultiThreadDynamicComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, category, element, isCompactView);
            }
        } else if (category == EComponentCategory.DYNAMICS_SETTINGS) {
            dc = new AdvancedContextComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, element);
        } else if (category == EComponentCategory.SQL_PATTERN) {
            dc = new SQLPatternComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, element);
        } else if (category == EComponentCategory.ADVANCED) {
            dc = new MissingSettingsMultiThreadDynamicComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, category, element, true);
            // Generic
            if (generic && wizardService != null) {
                Composite composite = wizardService.creatDynamicComposite(parent, element, EComponentCategory.ADVANCED, true);
                if (composite instanceof MultipleThreadDynamicComposite) {
                    dc = (MultipleThreadDynamicComposite) composite;
                }
            }
        } else {
            dc = new MultipleThreadDynamicComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, category, element, true);
        }
    } else if (element instanceof Connection) {
        dc = new MainConnectionComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, category, element);
    } else if (element instanceof Note) {
        if (category == EComponentCategory.BASIC) {
            if (parent.getLayout() instanceof FillLayout) {
                FillLayout layout = (FillLayout) parent.getLayout();
                layout.type = SWT.VERTICAL;
                layout.marginHeight = 0;
                layout.marginWidth = 0;
                layout.spacing = 0;
            }
            ScrolledComposite scrolled = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
            scrolled.setExpandHorizontal(true);
            scrolled.setExpandVertical(true);
            scrolled.setMinWidth(600);
            scrolled.setMinHeight(400);
            Composite composite = tabFactory.getWidgetFactory().createComposite(scrolled);
            scrolled.setContent(composite);
            composite.setLayout(new FormLayout());
            FormData d = new FormData();
            d.left = new FormAttachment(0, 0);
            d.right = new FormAttachment(100, 0);
            d.top = new FormAttachment(0, 0);
            d.bottom = new FormAttachment(100, 0);
            composite.setLayoutData(d);
            AbstractNotePropertyComposite c1 = new BasicNotePropertyComposite(composite, (Note) element, tabFactory);
            // AbstractNotePropertyComposite c2 = new TextNotePropertyComposite(composite, (Note) element,
            // tabFactory);
            // FormData data = new FormData();
            // data.top = new FormAttachment(c1.getComposite(), 20, SWT.DOWN);
            // data.left = new FormAttachment(0, 0);
            // data.right = new FormAttachment(100, 0);
            // c2.getComposite().setLayoutData(data);
            parent.layout();
        }
    } else if (element instanceof SubjobContainer) {
        if (category == EComponentCategory.BASIC) {
            dc = new SubjobBasicComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, element);
        }
    } else {
        tabFactory.getTabbedPropertyComposite().setCompactViewVisible(false);
        dc = new MultipleThreadDynamicComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, category, element, true);
    }
    if (parent.getChildren().length == 0) {
        if (parent.getLayout() instanceof FillLayout) {
            FillLayout layout = (FillLayout) parent.getLayout();
            layout.type = SWT.VERTICAL;
            layout.marginHeight = 0;
            layout.marginWidth = 0;
            layout.spacing = 0;
        }
        Composite composite = tabFactory.getWidgetFactory().createComposite(parent);
        composite.setLayout(new FormLayout());
        FormData d = new FormData();
        d.left = new FormAttachment(2, 0);
        d.right = new FormAttachment(100, 0);
        d.top = new FormAttachment(5, 0);
        d.bottom = new FormAttachment(100, 0);
        composite.setLayoutData(d);
        Label alertText = new Label(composite, SWT.NONE);
        //$NON-NLS-1$
        alertText.setText(Messages.getString("ComponentSettingsView.noAdvancedSetting"));
        alertText.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
        parent.layout();
    }
    if (dc != null) {
        dc.refresh();
    }
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) MainConnectionComposite(org.talend.designer.core.ui.editor.properties.connections.MainConnectionComposite) Composite(org.eclipse.swt.widgets.Composite) SubjobBasicComposite(org.talend.designer.core.ui.views.subjob.SubjobBasicComposite) AbstractNotePropertyComposite(org.talend.designer.core.ui.editor.properties.notes.AbstractNotePropertyComposite) MissingSettingsMultiThreadDynamicComposite(org.talend.designer.core.ui.views.properties.composites.MissingSettingsMultiThreadDynamicComposite) BasicNotePropertyComposite(org.talend.designer.core.ui.editor.properties.notes.BasicNotePropertyComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) IComponent(org.talend.core.model.components.IComponent) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) AbstractNotePropertyComposite(org.talend.designer.core.ui.editor.properties.notes.AbstractNotePropertyComposite) Connection(org.talend.designer.core.ui.editor.connections.Connection) IConnection(org.talend.core.model.process.IConnection) ConnectionLabel(org.talend.designer.core.ui.editor.connections.ConnectionLabel) Label(org.eclipse.swt.widgets.Label) MissingSettingsMultiThreadDynamicComposite(org.talend.designer.core.ui.views.properties.composites.MissingSettingsMultiThreadDynamicComposite) FillLayout(org.eclipse.swt.layout.FillLayout) SubjobBasicComposite(org.talend.designer.core.ui.views.subjob.SubjobBasicComposite) BasicNotePropertyComposite(org.talend.designer.core.ui.editor.properties.notes.BasicNotePropertyComposite) SubjobContainer(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer) Note(org.talend.designer.core.ui.editor.notes.Note) IGenericWizardService(org.talend.core.runtime.services.IGenericWizardService) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) MainConnectionComposite(org.talend.designer.core.ui.editor.properties.connections.MainConnectionComposite) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 100 with IComponent

use of org.talend.core.model.components.IComponent in project tdi-studio-se by Talend.

the class StatsAndLogsManager method getStatsAndLogsNodes.

public static List<DataNode> getStatsAndLogsNodes(IProcess process) {
    List<DataNode> nodeList = new ArrayList<DataNode>();
    String dbOutput = null;
    boolean dbFlag = ((Boolean) process.getElementParameter(EParameterName.ON_DATABASE_FLAG.getName()).getValue()) && process.getElementParameter(EParameterName.ON_DATABASE_FLAG.getName()).isShow(process.getElementParameters());
    if (!dbFlag) {
        dbOutput = null;
    } else {
        dbOutput = (String) process.getElementParameter(EParameterName.DB_TYPE.getName()).getValue();
        dbOutput = OracleComponentHelper.filterOracleComponentName(dbOutput);
        if (dbOutput == null || dbOutput.equals("")) {
            //$NON-NLS-1$
            dbOutput = null;
            dbFlag = false;
        }
    }
    boolean file = ((Boolean) process.getElementParameter(EParameterName.ON_FILES_FLAG.getName()).getValue()) && process.getElementParameter(EParameterName.ON_FILES_FLAG.getName()).isShow(process.getElementParameters());
    boolean console = ((Boolean) process.getElementParameter(EParameterName.ON_CONSOLE_FLAG.getName()).getValue()) && process.getElementParameter(EParameterName.ON_CONSOLE_FLAG.getName()).isShow(process.getElementParameters());
    if (!file && !dbFlag && !console) {
        return nodeList;
    }
    boolean useStats = ((Boolean) process.getElementParameter(EParameterName.ON_STATCATCHER_FLAG.getName()).getValue()) && process.getElementParameter(EParameterName.ON_STATCATCHER_FLAG.getName()).isShow(process.getElementParameters());
    boolean useLogs = ((Boolean) process.getElementParameter(EParameterName.ON_LOGCATCHER_FLAG.getName()).getValue()) && process.getElementParameter(EParameterName.ON_LOGCATCHER_FLAG.getName()).isShow(process.getElementParameters());
    boolean useMetter = ((Boolean) process.getElementParameter(EParameterName.ON_METERCATCHER_FLAG.getName()).getValue()) && process.getElementParameter(EParameterName.ON_METERCATCHER_FLAG.getName()).isShow(process.getElementParameters());
    String basePath = (String) process.getElementParameter(EParameterName.FILE_PATH.getName()).getValue();
    //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    basePath = basePath.replace("\\", "/") + "+ \"/\" +";
    DataNode connectionNode = null;
    //        String connectionUID = "connectionStatsLogs";//$NON-NLS-1$
    DataNode commitNode = null;
    String connectionUID2;
    IComponent commitComponent = null;
    String subString = null;
    /*
         * maybe, need create every of committing node for log/stat/metter.
         */
    // for bug 10453
    boolean isNotInformixDB = true;
    if (dbFlag) {
        String[] javaDbComponents = StatsAndLogsConstants.DB_OUTPUT_COMPONENTS;
        for (String dbComponent : javaDbComponents) {
            String commitComponentName = null;
            if (OracleComponentHelper.filterOracleConnectionType((String) process.getElementParameter(EParameterName.DB_TYPE.getName()).getValue()).equals(dbComponent)) {
                if (dbComponent.endsWith("Output")) {
                    //$NON-NLS-1$
                    //$NON-NLS-1$
                    subString = dbComponent.substring(0, dbComponent.lastIndexOf("Output"));
                    //$NON-NLS-1$
                    commitComponentName = subString + "Commit";
                } else {
                    //$NON-NLS-1$
                    commitComponentName = "tOracleCommit";
                }
                commitComponent = ComponentsFactoryProvider.getInstance().get(commitComponentName, ComponentCategory.CATEGORY_4_DI.getName());
                if (commitComponentName.indexOf("Informix") != -1) {
                    isNotInformixDB = false;
                }
                if (commitComponent != null) {
                    //$NON-NLS-1$
                    connectionUID2 = CONNECTION_UID + "_Commit";
                    commitNode = new DataNode(commitComponent, connectionUID2);
                    commitNode.setSubProcessStart(true);
                    commitNode.setActivate(true);
                    commitNode.getElementParameter(EParameterName.CONNECTION.getName()).setValue(CONNECTION_UID);
                    IElementParameter elementParameter = commitNode.getElementParameter("CLOSE");
                    if (elementParameter != null) {
                        elementParameter.setValue(Boolean.FALSE);
                    }
                    commitNode.setProcess(process);
                    nodeList.add(commitNode);
                }
            }
        }
    }
    if (useLogs) {
        DataNode logsNode = createLogsNode(file, console, dbOutput);
        if (LanguageManager.getCurrentLanguage().equals(ECodeLanguage.PERL)) {
            //$NON-NLS-1$
            logsNode.getElementParameter("FILENAME").setValue(//$NON-NLS-1$ //$NON-NLS-2$
            "File::Spec->catfile(" + basePath + "," + process.getElementParameter(EParameterName.FILENAME_LOGS.getName()).getValue() + //$NON-NLS-1$
            ")");
        } else {
            //$NON-NLS-1$
            logsNode.getElementParameter("FILENAME").setValue(basePath + process.getElementParameter(EParameterName.FILENAME_LOGS.getName()).getValue());
        }
        if (dbFlag) {
            if (commitNode != null && isNotInformixDB) {
                connectionNode = addConnection(connectionNode, process, CONNECTION_UID, logsNode, nodeList, commitNode);
            } else {
                useNoConnectionComponentDB(logsNode, process, CONNECTION_UID);
            }
            //$NON-NLS-1$
            logsNode.getElementParameter("TABLE").setValue(process.getElementParameter(EParameterName.TABLE_LOGS.getName()).getValue());
        }
        if (file) {
            IElementParameter encodingParameter = process.getElementParameter(EParameterName.ENCODING.getName());
            if (encodingParameter != null) {
                Object value = encodingParameter.getValue();
                if (value != null && !"".equals(value)) {
                    IElementParameter elementParameter = logsNode.getElementParameter(EParameterName.ENCODING.getName());
                    if (elementParameter != null) {
                        String encoding = value.toString();
                        if (!value.toString().startsWith(TalendTextUtils.getQuoteChar())) {
                            encoding = TalendTextUtils.addQuotes(encoding);
                        }
                        elementParameter.setValue(encoding);
                    }
                }
            }
        }
        logsNode.getElementParameter(EParameterName.CATCH_RUNTIME_ERRORS.getName()).setValue(process.getElementParameter(EParameterName.CATCH_RUNTIME_ERRORS.getName()).getValue());
        logsNode.getElementParameter(EParameterName.CATCH_USER_ERRORS.getName()).setValue(process.getElementParameter(EParameterName.CATCH_USER_ERRORS.getName()).getValue());
        logsNode.getElementParameter(EParameterName.CATCH_USER_WARNING.getName()).setValue(process.getElementParameter(EParameterName.CATCH_USER_WARNING.getName()).getValue());
        logsNode.setProcess(process);
        nodeList.add(logsNode);
    }
    if (useStats) {
        DataNode statsNode = createStatsNode(file, console, dbOutput);
        if (LanguageManager.getCurrentLanguage().equals(ECodeLanguage.PERL)) {
            //$NON-NLS-1$
            statsNode.getElementParameter("FILENAME").setValue(//$NON-NLS-1$ //$NON-NLS-2$
            "File::Spec->catfile(" + basePath + "," + process.getElementParameter(EParameterName.FILENAME_STATS.getName()).getValue() + //$NON-NLS-1$
            ")");
        } else {
            //$NON-NLS-1$
            statsNode.getElementParameter("FILENAME").setValue(basePath + process.getElementParameter(EParameterName.FILENAME_STATS.getName()).getValue());
        }
        if (dbFlag) {
            if (commitNode != null && isNotInformixDB) {
                connectionNode = addConnection(connectionNode, process, CONNECTION_UID, statsNode, nodeList, commitNode);
            } else {
                useNoConnectionComponentDB(statsNode, process, CONNECTION_UID);
            }
            //$NON-NLS-1$
            statsNode.getElementParameter("TABLE").setValue(process.getElementParameter(EParameterName.TABLE_STATS.getName()).getValue());
        }
        if (file) {
            IElementParameter encodingParameter = process.getElementParameter(EParameterName.ENCODING.getName());
            if (encodingParameter != null) {
                Object value = encodingParameter.getValue();
                if (value != null && !"".equals(value)) {
                    IElementParameter elementParameter = statsNode.getElementParameter(EParameterName.ENCODING.getName());
                    if (elementParameter != null) {
                        String encoding = value.toString();
                        if (!value.toString().startsWith(TalendTextUtils.getQuoteChar())) {
                            encoding = TalendTextUtils.addQuotes(encoding);
                        }
                        elementParameter.setValue(encoding);
                    }
                }
            }
        }
        statsNode.setProcess(process);
        nodeList.add(statsNode);
    }
    if (useMetter) {
        DataNode meterNode = createMetterNode(file, console, dbOutput);
        if (LanguageManager.getCurrentLanguage().equals(ECodeLanguage.PERL)) {
            //$NON-NLS-1$
            meterNode.getElementParameter("FILENAME").setValue(//$NON-NLS-1$ //$NON-NLS-2$
            "File::Spec->catfile(" + basePath + "," + process.getElementParameter(EParameterName.FILENAME_METTER.getName()).getValue() + //$NON-NLS-1$
            ")");
        } else {
            //$NON-NLS-1$
            meterNode.getElementParameter("FILENAME").setValue(basePath + process.getElementParameter(EParameterName.FILENAME_METTER.getName()).getValue());
        }
        if (dbFlag) {
            if (commitNode != null && isNotInformixDB) {
                connectionNode = addConnection(connectionNode, process, CONNECTION_UID, meterNode, nodeList, commitNode);
            } else {
                useNoConnectionComponentDB(meterNode, process, CONNECTION_UID);
            }
            //$NON-NLS-1$
            meterNode.getElementParameter("TABLE").setValue(process.getElementParameter(EParameterName.TABLE_METER.getName()).getValue());
        }
        if (file) {
            IElementParameter encodingParameter = process.getElementParameter(EParameterName.ENCODING.getName());
            if (encodingParameter != null) {
                Object value = encodingParameter.getValue();
                if (value != null && !"".equals(value)) {
                    IElementParameter elementParameter = meterNode.getElementParameter(EParameterName.ENCODING.getName());
                    if (elementParameter != null) {
                        String encoding = value.toString();
                        if (!value.toString().startsWith(TalendTextUtils.getQuoteChar())) {
                            encoding = TalendTextUtils.addQuotes(encoding);
                        }
                        elementParameter.setValue(encoding);
                    }
                }
            }
        }
        meterNode.setProcess(process);
        nodeList.add(meterNode);
    }
    return nodeList;
}
Also used : DataNode(org.talend.designer.core.model.process.DataNode) IComponent(org.talend.core.model.components.IComponent) ArrayList(java.util.ArrayList) IElementParameter(org.talend.core.model.process.IElementParameter)

Aggregations

IComponent (org.talend.core.model.components.IComponent)146 Node (org.talend.designer.core.ui.editor.nodes.Node)54 ArrayList (java.util.ArrayList)47 IElementParameter (org.talend.core.model.process.IElementParameter)36 Process (org.talend.designer.core.ui.editor.process.Process)36 Test (org.junit.Test)35 INode (org.talend.core.model.process.INode)33 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)22 List (java.util.List)15 Property (org.talend.core.model.properties.Property)15 FakePropertyImpl (org.talend.core.model.repository.FakePropertyImpl)15 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)13 IComponentsFactory (org.talend.core.model.components.IComponentsFactory)12 Connection (org.talend.designer.core.ui.editor.connections.Connection)12 HashMap (java.util.HashMap)11 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)10 DataNode (org.talend.designer.core.model.process.DataNode)10 HashSet (java.util.HashSet)9 IConnection (org.talend.core.model.process.IConnection)9 Rectangle (org.eclipse.swt.graphics.Rectangle)8