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);
}
}
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);
}
}
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;
}
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