Search in sources :

Example 91 with IComponent

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

the class DownloadComponenentsAction method confirmInstallation.

private void confirmInstallation() {
    IComponent emfcomponent = null;
    FileFilter propertiesFilter = new FileFilter() {

        // gcui:search xml file.
        @Override
        public boolean accept(File file) {
            //$NON-NLS-1$
            return file.getName().endsWith("_java.xml");
        }
    };
    String location = getComponentsFolder().getAbsolutePath();
    File folder = ExchangeComponentsProvider.searchComponentFolder(new File(location));
    File[] files = folder.listFiles(propertiesFilter);
    if (files == null || files.length == 0) {
        return;
    }
    IComponentsFactory componentsFactory = ComponentsFactoryProvider.getInstance();
    emfcomponent = componentsFactory.get(files[0].getParentFile().getName());
    if (emfcomponent == null) {
        return;
    }
    String componentName = null;
    StringBuilder message = new StringBuilder();
    String name = null;
    String family = null;
    if (emfcomponent != null) {
        name = emfcomponent.getName();
        family = emfcomponent.getOriginalFamilyName();
    }
    //String family = prop.getProperty("FAMILY"); //$NON-NLS-1$
    if (StringUtils.isNotEmpty(name) && StringUtils.isNotEmpty(family)) {
        componentName = name;
        //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        message.append("Component ").append(name).append(" installed at ").append(family).append(".\n");
    }
    if (componentName != null) {
        // see 0005051: [exchange view] select component in the palette once component is installed
        selectPaletteEntry(componentName);
    }
    MessageDialog.openInformation(null, Messages.getString("DownloadComponenentsAction.installExchange"), //$NON-NLS-1$ //$NON-NLS-2$
    Messages.getString("ExchangeWebService.downloadingExtensionSuccessful"));
    ComponentManager.saveResource();
}
Also used : IComponent(org.talend.core.model.components.IComponent) IComponentsFactory(org.talend.core.model.components.IComponentsFactory) FileFilter(java.io.FileFilter) File(java.io.File)

Example 92 with IComponent

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

the class JobSettingsManager method createExtraContextLoadNodes.

public static List<DataNode> createExtraContextLoadNodes(IProcess process) {
    List<DataNode> nodeList = new ArrayList<DataNode>();
    String paramName = EParameterName.IMPLICIT_TCONTEXTLOAD.getName();
    boolean useContextLoad = ((Boolean) process.getElementParameter(paramName).getValue()) && process.getElementParameter(paramName).isShow(process.getElementParameters());
    if (!useContextLoad) {
        // not used
        return Collections.emptyList();
    }
    // file
    paramName = JobSettingsConstants.getExtraParameterName(EParameterName.FROM_FILE_FLAG.getName());
    boolean fileFlag = ((Boolean) process.getElementParameter(paramName).getValue()) && process.getElementParameter(paramName).isShow(process.getElementParameters());
    // db
    String dbInput = null;
    paramName = JobSettingsConstants.getExtraParameterName(EParameterName.FROM_DATABASE_FLAG.getName());
    boolean dbFlag = ((Boolean) process.getElementParameter(paramName).getValue()) && process.getElementParameter(paramName).isShow(process.getElementParameters());
    if (!dbFlag) {
        dbInput = null;
    } else {
        dbInput = (String) process.getElementParameter(JobSettingsConstants.getExtraParameterName(EParameterName.DB_TYPE.getName())).getValue();
        dbInput = OracleComponentHelper.filterOracleComponentName(dbInput);
        if (dbInput == null || dbInput.equals("")) {
            //$NON-NLS-1$
            dbInput = null;
            dbFlag = false;
        }
    }
    if (!fileFlag && !dbFlag) {
        // not used
        return Collections.emptyList();
    }
    IComponent tContextLoadComponent = new JobContextLoadComponent(fileFlag, dbInput);
    //$NON-NLS-1$
    final String uniqueName = "Implicit_Context";
    DataNode tContextLoadNode = new DataNode(tContextLoadComponent, uniqueName);
    tContextLoadNode.setStart(true);
    tContextLoadNode.setSubProcessStart(true);
    tContextLoadNode.setActivate(true);
    IMetadataTable table = getSchemaTablefromComponent(JobContextLoadComponent.CONTEXTLOAD_COMPONENT, uniqueName);
    if (table != null) {
        tContextLoadNode.getMetadataList().clear();
        tContextLoadNode.getMetadataList().add(table);
    }
    // set parameters
    IElementParameter param = null;
    if (fileFlag) {
        // is file
        String inputFile = (String) process.getElementParameter(EParameterName.IMPLICIT_TCONTEXTLOAD_FILE.getName()).getValue();
        String fileSparator = (String) process.getElementParameter(EParameterName.FIELDSEPARATOR.getName()).getValue();
        tContextLoadNode.getElementParameter(EParameterName.IMPLICIT_TCONTEXTLOAD_FILE.getName()).setValue(inputFile);
        String regex = FileSeparator.getSeparatorsRegexp(TalendQuoteUtils.removeQuotes(fileSparator));
        tContextLoadNode.getElementParameter(JobSettingsConstants.IMPLICIT_TCONTEXTLOAD_REGEX).setValue(regex);
    } else {
        // is db
        paramName = JobSettingsConstants.getExtraParameterName(EParameterName.URL.getName());
        param = process.getElementParameter(paramName);
        if (param != null) {
            tContextLoadNode.getElementParameter(paramName).setValue(param.getValue());
        }
        paramName = JobSettingsConstants.getExtraParameterName(EParameterName.DRIVER_JAR.getName());
        param = process.getElementParameter(paramName);
        if (param != null) {
            tContextLoadNode.getElementParameter(paramName).setValue(param.getValue());
        }
        paramName = JobSettingsConstants.getExtraParameterName(EParameterName.DRIVER_CLASS.getName());
        param = process.getElementParameter(paramName);
        if (param != null) {
            tContextLoadNode.getElementParameter(paramName).setValue(param.getValue());
        }
        paramName = JobSettingsConstants.getExtraParameterName(EParameterName.HOST.getName());
        tContextLoadNode.getElementParameter(paramName).setValue(process.getElementParameter(paramName).getValue());
        paramName = JobSettingsConstants.getExtraParameterName(EParameterName.PORT.getName());
        tContextLoadNode.getElementParameter(paramName).setValue(process.getElementParameter(paramName).getValue());
        paramName = JobSettingsConstants.getExtraParameterName(EParameterName.DBNAME.getName());
        tContextLoadNode.getElementParameter(paramName).setValue(process.getElementParameter(paramName).getValue());
        paramName = JobSettingsConstants.getExtraParameterName(EParameterName.DB_VERSION.getName());
        tContextLoadNode.getElementParameter(paramName).setValue(process.getElementParameter(paramName).getValue());
        paramName = JobSettingsConstants.getExtraParameterName(EParameterName.PROPERTIES.getName());
        param = process.getElementParameter(paramName);
        if (param != null) {
            tContextLoadNode.getElementParameter(paramName).setValue(param.getValue());
        }
        paramName = JobSettingsConstants.getExtraParameterName(EParameterName.SCHEMA_DB.getName());
        param = process.getElementParameter(paramName);
        if (param != null) {
            tContextLoadNode.getElementParameter(paramName).setValue(param.getValue());
        }
        String schema = (String) process.getElementParameter(paramName).getValue();
        if (schema != null) {
            schema = TalendTextUtils.removeQuotes(schema);
        }
        paramName = JobSettingsConstants.getExtraParameterName(EParameterName.USER.getName());
        tContextLoadNode.getElementParameter(paramName).setValue(process.getElementParameter(paramName).getValue());
        paramName = JobSettingsConstants.getExtraParameterName(EParameterName.PASS.getName());
        tContextLoadNode.getElementParameter(paramName).setValue(process.getElementParameter(paramName).getValue());
        paramName = JobSettingsConstants.getExtraParameterName(EParameterName.CONNECTION_TYPE.getName());
        tContextLoadNode.getElementParameter(paramName).setValue(OracleComponentHelper.filterOracleConnectionType((String) process.getElementParameter(JobSettingsConstants.getExtraParameterName(EParameterName.DB_TYPE.getName())).getValue()));
        paramName = JobSettingsConstants.getExtraParameterName(EParameterName.DBTABLE.getName());
        tContextLoadNode.getElementParameter(paramName).setValue(process.getElementParameter(paramName).getValue());
        // query
        String dbTableName = (String) process.getElementParameter(paramName).getValue();
        String realTableName = getCurrentTableName(dbTableName);
        if (realTableName == null) {
            realTableName = QueryUtil.DEFAULT_TABLE_NAME;
        }
        String dbType = getDatabaseTypeFromParameter(process);
        if (dbType != null) {
            // TDI-18161:the SQL script's syntax is not right because of the implicit context of General JDBC.
            if (dbType.equals(EDatabaseTypeName.GENERAL_JDBC.getDisplayName())) {
                dbType = findRealDbTypeForJDBC(process, dbType);
            }
            EDatabaseTypeName dbTypeName = EDatabaseTypeName.getTypeFromDbType(dbType);
            if (EDatabaseTypeName.ORACLE_OCI.equals(dbTypeName) || EDatabaseTypeName.ORACLEFORSID.equals(dbTypeName) || EDatabaseTypeName.ORACLESN.equals(dbTypeName)) {
                for (IMetadataColumn column : table.getListColumns()) {
                    column.setOriginalDbColumnName(column.getOriginalDbColumnName().toUpperCase());
                }
            }
            if (realTableName.startsWith(TalendTextUtils.QUOTATION_MARK) && realTableName.endsWith(TalendTextUtils.QUOTATION_MARK) && realTableName.length() > 2) {
                realTableName = realTableName.substring(1, realTableName.length() - 1);
            }
            String query = TalendTextUtils.addSQLQuotes(QueryUtil.generateNewQuery(null, table, dbType, schema, realTableName));
            paramName = JobSettingsConstants.getExtraParameterName(EParameterName.QUERY_CONDITION.getName());
            String conditionStatement = (String) process.getElementParameter(paramName).getValue();
            if (conditionStatement != null) {
                String tmp = TalendTextUtils.removeQuotes(conditionStatement);
                if (!"".equals(tmp)) {
                    //$NON-NLS-1$
                    //$NON-NLS-1$
                    query = query + CONNECTOR + QUOTE + " WHERE " + QUOTE + CONNECTOR + conditionStatement;
                }
            }
            final String quoteByDBType = TalendTextUtils.getQuoteByDBType(dbType, false);
            if (dbTypeName == EDatabaseTypeName.MSSQL) {
                query = //$NON-NLS-1$
                query.replaceAll(//$NON-NLS-1$
                "(?i)\bkey\b", //$NON-NLS-1$  //$NON-NLS-2$
                "\\\\" + quoteByDBType + "key\\\\" + quoteByDBType);
            }
            tContextLoadNode.getElementParameter(JobSettingsConstants.QUERY).setValue(query);
        }
    }
    // tContextLoad
    paramName = EParameterName.LOAD_NEW_VARIABLE.getName();
    param = process.getElementParameter(paramName);
    if (param != null) {
        tContextLoadNode.getElementParameter(paramName).setValue(param.getValue());
    }
    paramName = EParameterName.NOT_LOAD_OLD_VARIABLE.getName();
    param = process.getElementParameter(paramName);
    if (param != null) {
        tContextLoadNode.getElementParameter(paramName).setValue(param.getValue());
    }
    paramName = EParameterName.PRINT_OPERATIONS.getName();
    tContextLoadNode.getElementParameter(paramName).setValue(process.getElementParameter(paramName).getValue());
    paramName = EParameterName.DISABLE_ERROR.getName();
    param = process.getElementParameter(paramName);
    if (param != null) {
        tContextLoadNode.getElementParameter(paramName).setValue(param.getValue());
    }
    paramName = EParameterName.DISABLE_INFO.getName();
    param = process.getElementParameter(paramName);
    if (param != null) {
        tContextLoadNode.getElementParameter(paramName).setValue(param.getValue());
    }
    paramName = EParameterName.DISABLE_WARNINGS.getName();
    tContextLoadNode.getElementParameter(paramName).setValue(process.getElementParameter(paramName).getValue());
    tContextLoadNode.setProcess(process);
    nodeList.add(tContextLoadNode);
    return nodeList;
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) 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) EDatabaseTypeName(org.talend.core.database.EDatabaseTypeName) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn)

Example 93 with IComponent

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

the class FOXMain method createUI.

/**
     * qzhang Comment method "createUI".
     * 
     * @param display
     * @return
     */
public Shell createUI(Display display) {
    Shell shell = new Shell(display, SWT.APPLICATION_MODAL | SWT.BORDER | SWT.RESIZE | SWT.CLOSE | SWT.MIN | SWT.MAX | SWT.TITLE);
    IComponent component = connector.getComponent();
    Image createImage = CoreImageProvider.getComponentIcon(component, ICON_SIZE.ICON_32);
    shell.setImage(createImage);
    shell.setText(connector.getUniqueName());
    Rectangle boundsRG = new Rectangle(50, 50, 800, 600);
    shell.setBounds(boundsRG);
    createUI(shell);
    if (!shell.isDisposed()) {
        shell.open();
    }
    return shell;
}
Also used : Shell(org.eclipse.swt.widgets.Shell) IComponent(org.talend.core.model.components.IComponent) Rectangle(org.eclipse.swt.graphics.Rectangle) Image(org.eclipse.swt.graphics.Image)

Example 94 with IComponent

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

the class RowGenMain method createUI.

/**
     * qzhang Comment method "createUI".
     * 
     * @param display
     * @return
     */
public Shell createUI(Display display) {
    Shell shell = new Shell(display, SWT.APPLICATION_MODAL | SWT.BORDER | SWT.RESIZE | SWT.CLOSE | SWT.MIN | SWT.MAX | SWT.TITLE);
    IComponent component = connector.getComponent();
    shell.setImage(CoreImageProvider.getComponentIcon(component, ICON_SIZE.ICON_32));
    IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
    String productName = brandingService.getFullProductName();
    //$NON-NLS-1$
    shell.setText(Messages.getString("RowGenMain.ShellTitle", productName, connector.getUniqueName()));
    Rectangle boundsRG = ExternalRowGeneratorUiProperties.getBoundsRowGen();
    if (ExternalRowGeneratorUiProperties.isShellMaximized()) {
        shell.setMaximized(ExternalRowGeneratorUiProperties.isShellMaximized());
    } else {
        boundsRG = ExternalRowGeneratorUiProperties.getBoundsRowGen();
        if (boundsRG.x < 0) {
            boundsRG.x = 0;
        }
        if (boundsRG.y < 0) {
            boundsRG.y = 0;
        }
        shell.setBounds(boundsRG);
    }
    createUI(shell, false);
    updateComponentsSize();
    updateTableTitleColumn();
    shell.open();
    shell.addControlListener(new ControlListener() {

        public void controlMoved(ControlEvent e) {
            generatorUI.getDataTableView().attachLabelPosition();
        }

        public void controlResized(ControlEvent e) {
            generatorUI.getDataTableView().attachLabelPosition();
            generatorUI.getDataTableView().fixedLabelSize();
        }
    });
    addAllControlForKeyListener(shell);
    // shell.moveAbove(null);
    generatorUI.getDataTableView().updateHeader(ExternalRowGeneratorUiProperties.getShowColumnsList());
    return shell;
}
Also used : Shell(org.eclipse.swt.widgets.Shell) IComponent(org.talend.core.model.components.IComponent) Rectangle(org.eclipse.swt.graphics.Rectangle) ControlListener(org.eclipse.swt.events.ControlListener) IBrandingService(org.talend.core.ui.branding.IBrandingService) ControlEvent(org.eclipse.swt.events.ControlEvent)

Example 95 with IComponent

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

the class TalendEditorComponentCreationUtil method readComponentsInCategory.

/**
     * read all components belongs to some category (DI, CAMEL etc.) then store it into a map which can be reused
     * 
     * @param categoryName
     * @param entries
     */
/*
     * TODO this can be improved after refactoring org.talend.core.model.components.IComponentsHandler implementation in
     * each editor
     */
private static void readComponentsInCategory(String categoryName, Map<String, IComponent> entries) {
    IComponentsFactory componentsFactory = ComponentsFactoryProvider.getInstance();
    Set<IComponent> allComponents = componentsFactory.getComponents();
    for (IComponent component : allComponents) {
        String compType = component.getPaletteType();
        if (!component.isTechnical() && compType != null && categoryName.equals(compType)) {
            entries.put(component.getName(), component);
        }
    }
    DummyComponent noteComponent = new DummyComponent("Note");
    noteComponent.setIcon16(ImageProvider.getImageDesc(ECoreImage.CODE_ICON));
    noteComponent.setOriginalFamilyName("Misc");
    entries.put("Note", noteComponent);
}
Also used : DummyComponent(org.talend.designer.core.model.components.DummyComponent) IComponentsFactory(org.talend.core.model.components.IComponentsFactory) IComponent(org.talend.core.model.components.IComponent)

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