Search in sources :

Example 31 with IBrandingService

use of org.talend.core.ui.branding.IBrandingService in project tdi-studio-se by Talend.

the class CodeGeneratorEmittersPoolFactory method initComponent.

/**
     * initialization of the available components.
     * 
     * @param codeLanguage
     * @param jetBeans
     * @param codePart
     * @param component
     */
private static void initComponent(ECodeLanguage codeLanguage, List<JetBean> jetBeans, ECodePart codePart, IComponent component) {
    if (component.getAvailableCodeParts().contains(codePart)) {
        IComponentFileNaming fileNamingInstance = ComponentsFactoryProvider.getFileNamingInstance();
        String templateURI = component.getPathSource() + TemplateUtil.DIR_SEP + component.getName() + TemplateUtil.DIR_SEP + fileNamingInstance.getJetFileName(component, codeLanguage.getExtension(), codePart);
        String componentsPath = IComponentsFactory.COMPONENTS_LOCATION;
        IBrandingService breaningService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
        if (breaningService.isPoweredOnlyCamel()) {
            componentsPath = IComponentsFactory.CAMEL_COMPONENTS_LOCATION;
        }
        if (component instanceof EmfComponent) {
            componentsPath = ((EmfComponent) component).getSourceBundleName();
        }
        JetBean jetBean = new JetBean(componentsPath, templateURI, component.getName(), component.getVersion(), codeLanguage.getName(), codePart.getName());
        //$NON-NLS-1$ //$NON-NLS-2$
        jetBean.addClassPath("EMF_ECORE", "org.eclipse.emf.ecore");
        //$NON-NLS-1$ //$NON-NLS-2$
        jetBean.addClassPath("EMF_COMMON", "org.eclipse.emf.common");
        //$NON-NLS-1$ //$NON-NLS-2$
        jetBean.addClassPath("CORERUNTIME_LIBRARIES", "org.talend.core.runtime");
        //$NON-NLS-1$ //$NON-NLS-2$
        jetBean.addClassPath("MANAGEMENT_LIBRARIES", "org.talend.metadata.managment");
        //$NON-NLS-1$
        jetBean.addClassPath("CORE_LIBRARIES", CorePlugin.PLUGIN_ID);
        //$NON-NLS-1$
        jetBean.addClassPath("CODEGEN_LIBRARIES", CodeGeneratorActivator.PLUGIN_ID);
        //$NON-NLS-1$
        jetBean.addClassPath("COMMON_LIBRARIES", CommonsPlugin.PLUGIN_ID);
        //$NON-NLS-1$ //$NON-NLS-2$
        jetBean.addClassPath("COMPONENT_FRAMEWORK", "org.talend.components.api");
        //$NON-NLS-1$ //$NON-NLS-2$
        jetBean.addClassPath("DAIKON", "org.talend.daikon");
        //$NON-NLS-1$ //$NON-NLS-2$
        jetBean.addClassPath("COMPONENT_CORE", "org.talend.designer.core.generic");
        //$NON-NLS-1$ //$NON-NLS-2$
        jetBean.addClassPath("DESIGNER_CORE", "org.talend.designer.core");
        //$NON-NLS-1$ //$NON-NLS-2$
        jetBean.addClassPath("HADOOP_DISTRIBUTIONS", "org.talend.hadoop.distribution");
        //$NON-NLS-1$ //$NON-NLS-2$
        jetBean.addClassPath("HADOOP_CUSTOM_DISTRIBUTIONS", "org.talend.hadoop.distribution.custom");
        if (PluginChecker.isGEFAbstractMapLoaded()) {
            //$NON-NLS-1$ //$NON-NLS-2$
            jetBean.addClassPath("GEF_MAP", "org.talend.designer.gefabstractmap");
        }
        for (String pluginDependency : component.getPluginDependencies()) {
            //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            jetBean.addClassPath(pluginDependency.toUpperCase().replaceAll("\\.", "_") + "_LIBRARIES", pluginDependency);
        }
        String familyName = component.getOriginalFamilyName();
        if (familyName.contains("|")) {
            //$NON-NLS-1$
            //$NON-NLS-1$
            familyName = component.getOriginalFamilyName().substring(0, component.getOriginalFamilyName().indexOf("|"));
        }
        jetBean.setFamily(StringUtils.removeSpecialCharsForPackage(familyName.toLowerCase()));
        // Spark, M/R and Storm requires the plugin org.talend.designer.spark to be in the classpath in order to
        // generate the code.
        //$NON-NLS-1$
        String sparkUtilsPluginName = "org.talend.designer.spark";
        //$NON-NLS-1$
        String bigDataUtilsPluginName = "org.talend.designer.bigdata";
        if (PluginChecker.isPluginLoaded(sparkUtilsPluginName) && (//$NON-NLS-1$
        "SPARK".equals(component.getPaletteType()) || "MR".equals(component.getPaletteType()) || //$NON-NLS-1$ //$NON-NLS-2$
        "STORM".equals(component.getPaletteType()) || "SPARKSTREAMING".equals(component.getPaletteType()))) {
            //$NON-NLS-1$
            //$NON-NLS-1$
            jetBean.addClassPath("BIGDATA_LIBRARIES", bigDataUtilsPluginName);
            //$NON-NLS-1$
            jetBean.addClassPath("SPARK_LIBRARIES", sparkUtilsPluginName);
            jetBean.setClassLoader(createDelegateClassLoader(createDelegateClassLoader(new CodeGeneratorEmittersPoolFactory().getClass().getClassLoader(), bigDataUtilsPluginName, //$NON-NLS-1$
            "org.talend.designer.bigdata.common.BigDataDataProcess"), sparkUtilsPluginName, //$NON-NLS-1$
            "org.talend.designer.spark.SparkPlugin"));
            // spark as a secondary, delegate classloader.
            if (component.getPluginExtension() != null) {
                jetBean.addClassPath(//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                "EXTERNAL_COMPONENT_" + component.getPluginExtension().toUpperCase().replaceAll("\\.", "_"), component.getPluginExtension());
                jetBean.setClassLoader(new DelegateClassLoader(ExternalNodesFactory.getInstance(component.getPluginExtension()).getClass().getClassLoader(), jetBean.getClassLoader()));
            }
        } else if (component.getPluginExtension() != null) {
            //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            jetBean.addClassPath(//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            "EXTERNAL_COMPONENT_" + component.getPluginExtension().toUpperCase().replaceAll("\\.", "_"), component.getPluginExtension());
            jetBean.setClassLoader(ExternalNodesFactory.getInstance(component.getPluginExtension()).getClass().getClassLoader());
        } else {
            jetBean.setClassLoader(new CodeGeneratorEmittersPoolFactory().getClass().getClassLoader());
        }
        jetBeans.add(jetBean);
    }
    // When building the main part of the component, also attempt to build the other parts.
    if (codePart.compareTo(ECodePart.MAIN) == 0) {
        for (ECodePart otherPart : ECodePart.values()) {
            if (otherPart != ECodePart.MAIN && component.getAvailableCodeParts().contains(otherPart)) {
                initComponent(codeLanguage, jetBeans, otherPart, component);
            }
        }
    }
}
Also used : IComponentFileNaming(org.talend.core.model.components.IComponentFileNaming) JetBean(org.talend.designer.codegen.config.JetBean) LightJetBean(org.talend.designer.codegen.config.LightJetBean) EmfComponent(org.talend.designer.core.model.components.EmfComponent) IBrandingService(org.talend.core.ui.branding.IBrandingService) ECodePart(org.talend.core.model.temp.ECodePart)

Example 32 with IBrandingService

use of org.talend.core.ui.branding.IBrandingService in project tdi-studio-se by Talend.

the class MultiPageTalendEditor method setName.

/**
     * DOC smallet Comment method "setName".
     * 
     * @param label
     */
@Override
public void setName() {
    if (getEditorInput() == null) {
        return;
    }
    super.setName();
    IProcess2 process2 = this.getProcess();
    if (process2 == null) {
        return;
    }
    Property property = process2.getProperty();
    if (property == null) {
        return;
    }
    String label = property.getDisplayName();
    //$NON-NLS-1$
    String jobVersion = "0.1";
    if (process2 != null) {
        jobVersion = process2.getVersion();
    }
    // if (getActivePage() == 1) {
    ISVNProviderService service = null;
    if (PluginChecker.isSVNProviderPluginLoaded()) {
        service = (ISVNProviderService) GlobalServiceRegister.getDefault().getService(ISVNProviderService.class);
        if (revisionChanged && service.isProjectInSvnMode()) {
            revisionNumStr = service.getCurrentSVNRevision(process2);
            revisionChanged = false;
            if (revisionNumStr != null) {
                //$NON-NLS-1$
                revisionNumStr = ".r" + revisionNumStr;
            }
        }
    }
    //$NON-NLS-1$
    String title = "MultiPageTalendEditor.Job";
    if (process2 != null) {
        Item item = process2.getProperty().getItem();
        if (item instanceof JobletProcessItem) {
            //$NON-NLS-1$
            title = "MultiPageTalendEditor.Joblet";
        }
    }
    IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
    boolean allowVerchange = brandingService.getBrandingConfiguration().isAllowChengeVersion();
    if (allowVerchange) {
        if (revisionNumStr != null) {
            setPartName(Messages.getString(title, label, jobVersion) + revisionNumStr);
        } else {
            setPartName(Messages.getString(title, label, jobVersion));
        }
    } else {
        if (revisionNumStr != null) {
            //$NON-NLS-1$
            setPartName(Messages.getString(title, label, "") + revisionNumStr);
        } else {
            //$NON-NLS-1$
            setPartName(Messages.getString(title, label, ""));
        }
    }
}
Also used : Item(org.talend.core.model.properties.Item) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) IProcess2(org.talend.core.model.process.IProcess2) ISVNProviderService(org.talend.core.services.ISVNProviderService) IBrandingService(org.talend.core.ui.branding.IBrandingService) Property(org.talend.core.model.properties.Property)

Example 33 with IBrandingService

use of org.talend.core.ui.branding.IBrandingService in project tdi-studio-se by Talend.

the class PerformancePreferencePage method createFieldEditors.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
     */
@Override
protected void createFieldEditors() {
    IBrandingService breaningService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
    if (breaningService.isPoweredOnlyCamel()) {
        addField(new BooleanFieldEditor(ITalendCorePrefConstants.DEACTIVE_REPOSITORY_UPDATE, //$NON-NLS-1$
        Messages.getString("PerformancePreferencePage.display.deactiveRepositoryUpdate"), getFieldEditorParent()));
        addField(new BooleanFieldEditor(TalendDesignerPrefConstants.PROPERTY_CODE_CHECK, Messages.getString("PerformancePreferencePage.propertyCodeCheck"), //$NON-NLS-1$
        getFieldEditorParent()));
        addField(new BooleanFieldEditor(TalendDesignerPrefConstants.GENERATE_CODE_WHEN_OPEN_JOB, //$NON-NLS-1$
        Messages.getString("PerformancePreferencePage.generateCode"), getFieldEditorParent()));
        addField(new BooleanFieldEditor(TalendDesignerPrefConstants.CHECK_ONLY_LAST_VERSION, //$NON-NLS-1$
        Messages.getString("PerformancePreferencePage.checkVersion"), getFieldEditorParent()));
        addField(new BooleanFieldEditor(TalendDesignerPrefConstants.PROPAGATE_CONTEXT_VARIABLE, //$NON-NLS-1$
        Messages.getString("PerformancePreferencePage.addOrDeleteVariable"), getFieldEditorParent()));
        dbConnTimeoutActive = new CheckBoxFieldEditor(ITalendCorePrefConstants.DB_CONNECTION_TIMEOUT_ACTIVED, Messages.getString("PerformancePreferencePage.ActivedTimeoutSetting"), //$NON-NLS-1$
        getFieldEditorParent());
        dbConnTimeoutActive.getButton().addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                checkDBTimeout();
            }
        });
        dbConnTimeout = new IntegerFieldEditor(ITalendCorePrefConstants.DB_CONNECTION_TIMEOUT, //$NON-NLS-1$
        Messages.getString("PerformancePreferencePage.ConnectionTimeout"), getFieldEditorParent());
        Text textControl = dbConnTimeout.getTextControl(getFieldEditorParent());
        //$NON-NLS-1$
        textControl.setToolTipText(Messages.getString("PerformancePreferencePage.ConnectionTimeoutTip"));
        dbConnTimeout.setValidRange(0, Short.MAX_VALUE);
        textControl.setEnabled(getPreferenceStore().getBoolean(ITalendCorePrefConstants.DB_CONNECTION_TIMEOUT_ACTIVED));
        addField(dbConnTimeoutActive);
        addField(dbConnTimeout);
        addSVNInforAutoCheckFiled();
    } else {
        addField(new BooleanFieldEditor(ITalendCorePrefConstants.DEACTIVE_REPOSITORY_UPDATE, //$NON-NLS-1$
        Messages.getString("PerformancePreferencePage.display.deactiveRepositoryUpdate"), getFieldEditorParent()));
        addField(new BooleanFieldEditor(TalendDesignerPrefConstants.PROPERTY_CODE_CHECK, Messages.getString("PerformancePreferencePage.propertyCodeCheck"), //$NON-NLS-1$
        getFieldEditorParent()));
        addField(new BooleanFieldEditor(TalendDesignerPrefConstants.GENERATE_CODE_WHEN_OPEN_JOB, //$NON-NLS-1$
        Messages.getString("PerformancePreferencePage.generateCode"), getFieldEditorParent()));
        addField(new BooleanFieldEditor(TalendDesignerPrefConstants.CHECK_ONLY_LAST_VERSION, //$NON-NLS-1$
        Messages.getString("PerformancePreferencePage.checkVersion"), getFieldEditorParent()));
        addField(new BooleanFieldEditor(TalendDesignerPrefConstants.PROPAGATE_CONTEXT_VARIABLE, //$NON-NLS-1$
        Messages.getString("PerformancePreferencePage.addOrDeleteVariable"), getFieldEditorParent()));
        dbConnTimeoutActive = new CheckBoxFieldEditor(ITalendCorePrefConstants.DB_CONNECTION_TIMEOUT_ACTIVED, Messages.getString("PerformancePreferencePage.ActivedTimeoutSetting"), //$NON-NLS-1$
        getFieldEditorParent());
        dbConnTimeoutActive.getButton().addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                checkDBTimeout();
            }
        });
        dbConnTimeout = new IntegerFieldEditor(ITalendCorePrefConstants.DB_CONNECTION_TIMEOUT, //$NON-NLS-1$
        Messages.getString("PerformancePreferencePage.ConnectionTimeout"), getFieldEditorParent());
        Text textControl = dbConnTimeout.getTextControl(getFieldEditorParent());
        //$NON-NLS-1$
        textControl.setToolTipText(Messages.getString("PerformancePreferencePage.ConnectionTimeoutTip"));
        dbConnTimeout.setValidRange(0, Short.MAX_VALUE);
        textControl.setEnabled(getPreferenceStore().getBoolean(ITalendCorePrefConstants.DB_CONNECTION_TIMEOUT_ACTIVED));
        addField(dbConnTimeoutActive);
        addField(dbConnTimeout);
        addField(new BooleanFieldEditor(ITalendCorePrefConstants.ADD_USER_ROUTINES, //$NON-NLS-1$
        Messages.getString("PerformancePreferencePage.addAllUserRoutines"), getFieldEditorParent()));
        // TDI-8323:remove this one,we do not need this since we always add all system routines for new job
        // addField(new BooleanFieldEditor(ITalendCorePrefConstants.ADD_SYSTEM_ROUTINES, Messages
        // .getString("PerformancePreferencePage.addAllSystemRoutines"),//$NON-NLS-1$
        // getFieldEditorParent()));
        addSVNInforAutoCheckFiled();
    }
    IntegerFieldEditor codeFormatTimeout = new IntegerFieldEditor(ITalendCorePrefConstants.PERFORMANCE_JAVA_PROCESS_CODE_FORMATE_TIMEOUT, //$NON-NLS-1$
    Messages.getString("PerformancePreferencePage.CodeFormatTimeout"), getFieldEditorParent());
    codeFormatTimeout.setValidRange(1, Short.MAX_VALUE);
    addField(codeFormatTimeout);
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IntegerFieldEditor(org.eclipse.jface.preference.IntegerFieldEditor) BooleanFieldEditor(org.eclipse.jface.preference.BooleanFieldEditor) Text(org.eclipse.swt.widgets.Text) IBrandingService(org.talend.core.ui.branding.IBrandingService) CheckBoxFieldEditor(org.talend.commons.ui.swt.preferences.CheckBoxFieldEditor)

Example 34 with IBrandingService

use of org.talend.core.ui.branding.IBrandingService in project tdi-studio-se by Talend.

the class HTMLDocGenerator method saveLogoImage.

protected void saveLogoImage(int type, File file) throws IOException {
    boolean documentationPluginLoaded = PluginChecker.isDocumentationPluginLoaded();
    // get image from cache
    ByteArrayOutputStream result = logoImageCache.get(type);
    if (documentationPluginLoaded) {
        String userLogoPath = CorePlugin.getDefault().getPreferenceStore().getString(ITalendCorePrefConstants.DOC_USER_LOGO);
        if (userLogoPath != null && !"".equals(userLogoPath)) {
            //$NON-NLS-1$
            if (result == null || !userLogoPath.equals(userDocImageOldPath)) {
                userDocImageOldPath = userLogoPath;
                result = new ByteArrayOutputStream(3072);
                File userLogo = new File(userLogoPath);
                if (userLogo.exists()) {
                    Image image = new Image(Display.getCurrent(), userLogoPath);
                    ImageLoader imageLoader = new ImageLoader();
                    imageLoader.data = new ImageData[] { image.getImageData() };
                    imageLoader.save(result, type);
                    logoImageCache.put(type, result);
                    image.dispose();
                }
            }
            FileOutputStream fos = new FileOutputStream(file);
            fos.write(result.toByteArray());
            fos.close();
            return;
        }
    }
    // if (result == null) {
    result = new ByteArrayOutputStream(3072);
    IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
    ImageData imageData = brandingService.getLoginHImage().getImageData();
    new ByteArrayOutputStream();
    ImageLoader imageLoader = new ImageLoader();
    imageLoader.data = new ImageData[] { imageData };
    imageLoader.save(result, type);
    // put image to cache, no need to generate next time
    logoImageCache.put(type, result);
    // }
    FileOutputStream fos = new FileOutputStream(file);
    fos.write(result.toByteArray());
    fos.close();
}
Also used : ImageData(org.eclipse.swt.graphics.ImageData) FileOutputStream(java.io.FileOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IBrandingService(org.talend.core.ui.branding.IBrandingService) Image(org.eclipse.swt.graphics.Image) ImageLoader(org.eclipse.swt.graphics.ImageLoader) IFile(org.eclipse.core.resources.IFile) File(java.io.File)

Example 35 with IBrandingService

use of org.talend.core.ui.branding.IBrandingService in project tdi-studio-se by Talend.

the class VersionManagementProjectSettingPageTester method valid.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.core.runtime.preference.IProjectSettingPageTester#valid(org.eclipse.core.runtime.IConfigurationElement
     * , org.eclipse.jface.preference.IPreferenceNode)
     */
@Override
public boolean valid(IConfigurationElement element, IPreferenceNode node) {
    IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
    boolean allowChengeVersion = brandingService.getBrandingConfiguration().isAllowChengeVersion();
    return allowChengeVersion;
}
Also used : IBrandingService(org.talend.core.ui.branding.IBrandingService)

Aggregations

IBrandingService (org.talend.core.ui.branding.IBrandingService)49 GridData (org.eclipse.swt.layout.GridData)11 GridLayout (org.eclipse.swt.layout.GridLayout)10 Composite (org.eclipse.swt.widgets.Composite)9 File (java.io.File)8 Button (org.eclipse.swt.widgets.Button)7 Shell (org.eclipse.swt.widgets.Shell)7 Path (org.eclipse.core.runtime.Path)6 URL (java.net.URL)5 Point (org.eclipse.swt.graphics.Point)5 Rectangle (org.eclipse.swt.graphics.Rectangle)5 Bundle (org.osgi.framework.Bundle)5 Project (org.talend.core.model.general.Project)5 CoreException (org.eclipse.core.runtime.CoreException)4 Text (org.eclipse.swt.widgets.Text)4 BusinessException (org.talend.commons.exception.BusinessException)4 IComponent (org.talend.core.model.components.IComponent)4 ConnectionBean (org.talend.core.model.general.ConnectionBean)4 IOException (java.io.IOException)3 ResourceBundle (java.util.ResourceBundle)3