use of org.talend.core.model.properties.ComponentSetting in project tdi-studio-se by Talend.
the class ChangeComponentSettingNameMigrationTask method execute.
/*
* (non-Javadoc)
*
* @see org.talend.migration.IProjectMigrationTask#execute(org.talend.core.model.general.Project)
*/
@Override
public ExecutionResult execute(Project project) {
List<ComponentSetting> components = project.getEmfProject().getComponentsSettings();
List<ComponentSetting> newAdded = new ArrayList<ComponentSetting>();
Set<IComponent> componentList = ComponentsFactoryProvider.getInstance().getComponents();
for (ComponentSetting componentSetting : components) {
for (IComponent comp : componentList) {
if (comp != null && comp.getName().equals(componentSetting.getName())) {
componentSetting.setName(comp.getPaletteType() + "|" + comp.getName());
String family = componentSetting.getFamily();
if (family.contains("|")) {
String[] fams = family.split("\\|");
for (int i = 0; i < fams.length; i++) {
if (i == 0) {
componentSetting.setFamily(fams[0]);
} else {
ComponentSetting cs = PropertiesFactory.eINSTANCE.createComponentSetting();
cs.setName(comp.getPaletteType() + "|" + comp.getName());
cs.setHidden(componentSetting.isHidden());
cs.setFamily(fams[i]);
newAdded.add(cs);
}
}
}
break;
}
}
}
components.addAll(newAdded);
return ExecutionResult.SUCCESS_NO_ALERT;
}
use of org.talend.core.model.properties.ComponentSetting in project tdi-studio-se by Talend.
the class VisibleComponentSettingsMigrationTask method execute.
/*
* (non-Javadoc)
*
* @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
*/
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
IDesignerCoreService designerCoreService = CorePlugin.getDefault().getDesignerCoreService();
Project currentProject = ProjectManager.getInstance().getCurrentProject();
List<ComponentSetting> componentsSettings = (List<ComponentSetting>) currentProject.getEmfProject().getComponentsSettings();
boolean modified = false;
if (processType != null) {
EList nodes = processType.getNode();
for (Object node : nodes) {
NodeType nodeType = (NodeType) node;
for (ComponentSetting setting : componentsSettings) {
if (setting.getName().equals(nodeType.getComponentName())) {
if (setting.isHidden()) {
setting.setHidden(false);
modified = true;
}
}
}
}
}
if (modified) {
IProxyRepositoryFactory prf = CorePlugin.getDefault().getProxyRepositoryFactory();
try {
prf.saveProject(currentProject);
} catch (Exception ex) {
ExceptionHandler.process(ex);
return ExecutionResult.FAILURE;
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
return ExecutionResult.NOTHING_TO_DO;
}
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);
}
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()));
}
}
Aggregations