Search in sources :

Example 1 with ComponentSetting

use of org.talend.core.model.properties.ComponentSetting in project tdi-studio-se by Talend.

the class PaletteSettingsDialog method setComponentVisible.

private void setComponentVisible(String name, boolean visible, boolean restore) {
    String[] names = name.split(FAMILY_SPEARATOR);
    String family = names[0];
    String label = names[1];
    List<ComponentSetting> components = getComponentsFromProject();
    for (ComponentSetting componentSetting : components) {
        if (componentSetting.getFamily().equals(family) && componentSetting.getName().equals(label)) {
            componentSetting.setHidden(!visible);
            return;
        }
    }
    if (!restore) {
        ComponentSetting cs = PropertiesFactory.eINSTANCE.createComponentSetting();
        cs.setName(label);
        cs.setHidden(!visible);
        cs.setFamily(family);
        components.add(cs);
        statusBackup.put(label, !visible);
    }
}
Also used : ComponentSetting(org.talend.core.model.properties.ComponentSetting)

Example 2 with ComponentSetting

use of org.talend.core.model.properties.ComponentSetting in project tdi-studio-se by Talend.

the class PaletteSettingPage method setComponentVisible.

private void setComponentVisible(IPaletteItem item, boolean visible) {
    try {
        ComponentPaletteItem componentPaletteItem = (ComponentPaletteItem) item;
        List<ComponentSetting> components = getComponentsFromProject(project);
        List<ComponentSetting> toRemoveFromSettings = new ArrayList<ComponentSetting>();
        for (ComponentSetting componentSetting : components) {
            if (componentSetting.getFamily() != null && componentSetting.getFamily().equals(componentPaletteItem.getFamily()) && componentSetting.getName().equals(item.getPaletteType().getName() + "|" + componentPaletteItem.getLabel())) {
                if (visible == componentPaletteItem.getComponent().isVisibleInComponentDefinition()) {
                    toRemoveFromSettings.add(componentSetting);
                }
                componentSetting.setHidden(!visible);
            }
        }
        components.removeAll(toRemoveFromSettings);
        if (visible != componentPaletteItem.getComponent().isVisibleInComponentDefinition()) {
            ComponentSetting cs = PropertiesFactory.eINSTANCE.createComponentSetting();
            cs.setName(item.getPaletteType().getName() + "|" + item.getLabel());
            cs.setHidden(!visible);
            cs.setFamily(item.getFamily());
            components.add(cs);
        }
        ComponentsSettingsHelper.resetHiddenComponents();
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }
}
Also used : ComponentPaletteItem(org.talend.repository.preference.palettesettings.ComponentPaletteItem) ArrayList(java.util.ArrayList) ComponentSetting(org.talend.core.model.properties.ComponentSetting) InvocationTargetException(java.lang.reflect.InvocationTargetException) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 3 with ComponentSetting

use of org.talend.core.model.properties.ComponentSetting in project tdi-studio-se by Talend.

the class AddFamilyFieldProjectMigrationTask method execute.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.core.model.migration.IProjectMigrationTask#execute(org.talend.core.model.general.Project)
     */
public ExecutionResult execute(Project project) {
    boolean needReset = false;
    EList list = project.getEmfProject().getComponentsSettings();
    for (Object obj : list) {
        ComponentSetting componentSetting = (ComponentSetting) obj;
        if (componentSetting.getFamily() == null) {
            needReset = true;
            break;
        }
    }
    if (needReset) {
        resetFamily(list);
    }
    return ExecutionResult.SUCCESS_WITH_ALERT;
}
Also used : EList(org.eclipse.emf.common.util.EList) ComponentSetting(org.talend.core.model.properties.ComponentSetting)

Example 4 with ComponentSetting

use of org.talend.core.model.properties.ComponentSetting in project tdi-studio-se by Talend.

the class ImportProjectSettings method updateProjectSettings.

public void updateProjectSettings() throws ParserConfigurationException, SAXException, IOException {
    if (this.path == null) {
        return;
    }
    File file = new File(path);
    org.talend.core.model.properties.Project project = pro.getEmfProject();
    final DocumentBuilderFactory fabrique = DocumentBuilderFactory.newInstance();
    DocumentBuilder analyseur = fabrique.newDocumentBuilder();
    analyseur.setErrorHandler(new ErrorHandler() {

        @Override
        public void error(final SAXParseException exception) throws SAXException {
            throw exception;
        }

        @Override
        public void fatalError(final SAXParseException exception) throws SAXException {
            throw exception;
        }

        @Override
        public void warning(final SAXParseException exception) throws SAXException {
            throw exception;
        }
    });
    final Document document = analyseur.parse(file);
    // PTODO, if need, get the version from the imported file.
    // NodeList exportParametersNodes = document.getElementsByTagName("exportParameters");
    // String importStudioVersion=null;
    //$NON-NLS-1$
    final NodeList nodes = document.getElementsByTagName("exportParameter");
    List addedComponentSetting = new ArrayList();
    List technical = project.getTechnicalStatus();
    List documentation = project.getDocumentationStatus();
    technical.clear();
    documentation.clear();
    for (int i = 0; i < nodes.getLength(); i++) {
        final Node node = nodes.item(i);
        final NamedNodeMap attrMap = node.getAttributes();
        //$NON-NLS-1$
        final Node typeAttr = attrMap.getNamedItem("type");
        if ("technicalStatus".equals(typeAttr.getTextContent())) {
            //$NON-NLS-1$
            //$NON-NLS-1$
            updateStatus(node, attrMap, technical, "technicalStatus");
        } else if ("documentationStatus".equals(typeAttr.getTextContent())) {
            //$NON-NLS-1$
            //$NON-NLS-1$
            updateStatus(node, attrMap, documentation, "documentationStatus");
        } else if ("security".equals(typeAttr.getTextContent())) {
            //$NON-NLS-1$
            project.isHidePassword();
            project.setHidePassword(Boolean.valueOf(node.getTextContent()));
        } else if ("statAndLogs".equals(typeAttr.getTextContent())) {
            //$NON-NLS-1$
            if (project.getStatAndLogsSettings() == null) {
                TalendFileFactory talendF = TalendFileFactory.eINSTANCE;
                StatAndLogsSettings stats = PropertiesFactory.eINSTANCE.createStatAndLogsSettings();
                project.setStatAndLogsSettings(stats);
                stats.setParameters(talendF.createParametersType());
            }
            List statAndLogs = project.getStatAndLogsSettings().getParameters().getElementParameter();
            updateParameters(node, attrMap, statAndLogs);
        } else if ("implicitContext".equals(typeAttr.getTextContent())) {
            //$NON-NLS-1$
            if (project.getImplicitContextSettings() == null) {
                TalendFileFactory talendF = TalendFileFactory.eINSTANCE;
                ImplicitContextSettings implicit = PropertiesFactory.eINSTANCE.createImplicitContextSettings();
                project.setImplicitContextSettings(implicit);
                implicit.setParameters(talendF.createParametersType());
            }
            List implicitContexts = project.getImplicitContextSettings().getParameters().getElementParameter();
            updateParameters(node, attrMap, implicitContexts);
        } else if ("palette".equals(typeAttr.getTextContent())) {
            //$NON-NLS-1$
            List componentSettings = project.getComponentsSettings();
            boolean existed = false;
            //$NON-NLS-1$
            String name = attrMap.getNamedItem("name").getTextContent();
            //$NON-NLS-1$
            final Node familyAttr = attrMap.getNamedItem("family");
            Boolean hide = Boolean.valueOf(node.getTextContent());
            for (Object obj : componentSettings) {
                ComponentSetting setting = (ComponentSetting) obj;
                if (setting.getName().equals(name)) {
                    if (familyAttr != null && familyAttr.getTextContent().equals(setting.getFamily())) {
                        existed = true;
                        setting.setHidden(hide);
                    }
                }
            }
            if (!existed && familyAttr != null) {
                ComponentSetting setting = PropertiesFactory.eINSTANCE.createComponentSetting();
                setting.setFamily(familyAttr.getTextContent());
                setting.setName(name);
                setting.setHidden(hide);
                addedComponentSetting.add(setting);
            }
        }
    }
    project.getComponentsSettings().addAll(addedComponentSetting);
}
Also used : DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) Node(org.w3c.dom.Node) ArrayList(java.util.ArrayList) Document(org.w3c.dom.Document) SAXException(org.xml.sax.SAXException) TalendFileFactory(org.talend.designer.core.model.utils.emf.talendfile.TalendFileFactory) SAXParseException(org.xml.sax.SAXParseException) StatAndLogsSettings(org.talend.core.model.properties.StatAndLogsSettings) ArrayList(java.util.ArrayList) NodeList(org.w3c.dom.NodeList) List(java.util.List) ErrorHandler(org.xml.sax.ErrorHandler) NamedNodeMap(org.w3c.dom.NamedNodeMap) NodeList(org.w3c.dom.NodeList) ComponentSetting(org.talend.core.model.properties.ComponentSetting) ImplicitContextSettings(org.talend.core.model.properties.ImplicitContextSettings) DocumentBuilder(javax.xml.parsers.DocumentBuilder) File(java.io.File)

Example 5 with ComponentSetting

use of org.talend.core.model.properties.ComponentSetting in project tdi-studio-se by Talend.

the class ExportProjectSettings method savePalette.

/**
     * wchen Comment method "saveParameters".
     * 
     * @param document
     * @param root
     * @param list
     */
private void savePalette(Document document, Element root, List list) {
    for (Object obj : list) {
        //$NON-NLS-1$
        Element exportParameter = document.createElement("exportParameter");
        root.appendChild(exportParameter);
        //$NON-NLS-1$
        Attr typeAttr = document.createAttribute("type");
        //$NON-NLS-1$
        typeAttr.setNodeValue("palette");
        exportParameter.setAttributeNode(typeAttr);
        //$NON-NLS-1$
        Attr name = document.createAttribute("name");
        name.setNodeValue(((ComponentSetting) obj).getName());
        exportParameter.setAttributeNode(name);
        //$NON-NLS-1$
        Attr family = document.createAttribute("family");
        family.setNodeValue(((ComponentSetting) obj).getFamily());
        exportParameter.setAttributeNode(family);
        exportParameter.setTextContent(String.valueOf(((ComponentSetting) obj).isHidden()));
    }
}
Also used : Element(org.w3c.dom.Element) ComponentSetting(org.talend.core.model.properties.ComponentSetting) Attr(org.w3c.dom.Attr)

Aggregations

ComponentSetting (org.talend.core.model.properties.ComponentSetting)9 ArrayList (java.util.ArrayList)3 List (java.util.List)2 EList (org.eclipse.emf.common.util.EList)2 IComponent (org.talend.core.model.components.IComponent)2 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)2 File (java.io.File)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)1 PersistenceException (org.talend.commons.exception.PersistenceException)1 RepositoryContext (org.talend.core.context.RepositoryContext)1 IComponentsFactory (org.talend.core.model.components.IComponentsFactory)1 Project (org.talend.core.model.general.Project)1 ImplicitContextSettings (org.talend.core.model.properties.ImplicitContextSettings)1 StatAndLogsSettings (org.talend.core.model.properties.StatAndLogsSettings)1 IDesignerCoreService (org.talend.designer.core.IDesignerCoreService)1 NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)1 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)1 TalendFileFactory (org.talend.designer.core.model.utils.emf.talendfile.TalendFileFactory)1