use of com.cubrid.cubridmanager.core.common.xml.IXMLMemento in project cubrid-manager by CUBRID.
the class DBParameter method loadDatabases.
/**
*
* Load added databases from plugin preference
*
*/
protected void loadDatabases() {
synchronized (this) {
IXMLMemento memento = PersistUtils.getXMLMemento(ApplicationUtil.CM_UI_PLUGIN_ID, DATABASE_XML_CONTENT);
loadDatabases(memento);
}
}
use of com.cubrid.cubridmanager.core.common.xml.IXMLMemento in project cubrid-manager by CUBRID.
the class CMGroupNodePersistManager method loadGroupNode.
/**
* Load group nodes from file preference.
*
* @param workspacePath String
* @return boolean whether import
*/
public boolean loadGroupNode(String workspacePath) {
synchronized (this) {
String filePath = workspacePath + File.separator + ".metadata" + File.separator + ".plugins" + File.separator + "org.eclipse.core.runtime" + File.separator + ".settings" + File.separator + "com.cubrid.cubridmanager.ui.prefs";
PreferenceStore preference = new PreferenceStore(filePath);
int size = groupNodeList.size();
try {
preference.load();
String xmlString = preference.getString(COM_CUBRID_MANAGER_HOSTGROUP);
if (xmlString == null || xmlString.trim().length() == 0) {
return false;
}
ByteArrayInputStream in = new ByteArrayInputStream(xmlString.getBytes("UTF-8"));
IXMLMemento memento = XMLMemento.loadMemento(in);
loadGroupNode(memento);
} catch (IOException e) {
LOGGER.error(e.getMessage());
}
boolean isImported = size != groupNodeList.size();
if (isImported) {
saveAllGroupNode();
}
return isImported;
}
}
use of com.cubrid.cubridmanager.core.common.xml.IXMLMemento in project cubrid-manager by CUBRID.
the class CQBGroupNodePersistManager method loadGroupNode.
/**
* Load group nodes from local preference.
*
*/
private void loadGroupNode() {
synchronized (this) {
IXMLMemento memento = PersistUtils.getXMLMemento(ApplicationUtil.CQB_UI_PLUGIN_ID, COM_CUBRID_QB_DBGROUP);
loadGroupNode(memento);
}
}
use of com.cubrid.cubridmanager.core.common.xml.IXMLMemento in project cubrid-manager by CUBRID.
the class CubridJdbcManager method resetCubridJdbcSetting.
/**
* Add or delete CUBRID JDBC driver
*
* @param map the CUBRID JDBC driver
*/
public void resetCubridJdbcSetting(Map<String, String> map) {
synchronized (CubridJdbcManager.class) {
XMLMemento memento = XMLMemento.createWriteRoot("cubridJdbcSetting");
Iterator<Entry<String, String>> iterator = map.entrySet().iterator();
while (iterator.hasNext()) {
IXMLMemento child = memento.createChild("cubridJdbcSetting");
Entry<String, String> next = iterator.next();
child.putString("jdbcURL", next.getValue());
}
// register the jdbc to the jdbc factory
Map<String, String> loaderMap = getSortedMap();
loaderMap.putAll(defaultVersion2FileMap);
loaderMap.putAll(externalVersion2FileMap);
Map<String, String> noLoadedMap = new HashMap<String, String>();
iterator = map.entrySet().iterator();
while (iterator.hasNext()) {
Entry<String, String> next = iterator.next();
String key = next.getKey();
String value = next.getValue();
//delete the loader that already loaded
if (loaderMap.containsKey(key) && StringUtil.isEqual(loaderMap.get(key), value)) {
loaderMap.remove(key);
} else {
noLoadedMap.put(key, value);
}
}
for (String version : loaderMap.keySet()) {
if (externalVersion2FileMap.containsKey(version)) {
String driverFile = externalVersion2FileMap.get(version);
externalVersion2FileMap.remove(version);
JdbcClassLoaderFactory.removeClassLoader(version);
fireRemoveJdbcDriver(driverFile);
}
}
for (Entry<String, String> entry : noLoadedMap.entrySet()) {
externalVersion2FileMap.put(entry.getKey(), entry.getValue());
JdbcClassLoaderFactory.registerClassLoader(entry.getValue());
fireAddJdbcDriver(entry.getValue());
}
PersistUtils.saveXMLMemento(CommonUIPlugin.PLUGIN_ID, CUBRID_JDBC_SETTING, memento);
}
}
use of com.cubrid.cubridmanager.core.common.xml.IXMLMemento in project cubrid-manager by CUBRID.
the class ApplicationPersistUtil method loadQueryRecordList.
/**
* Load query record list
*
* @param element
*/
private void loadQueryRecordList(IXMLMemento element) {
DateFormat formater = DateUtil.getDateFormat(DATE_PATTERN, Locale.ENGLISH);
IXMLMemento[] dataArray = element.getChildren("query_redord_list");
if (dataArray != null && dataArray.length > 0) {
for (int i = 0; i < dataArray.length; i++) {
IXMLMemento child = dataArray[i];
String key = child.getString("database_key");
String dateStr = child.getString("create_date");
String name = child.getString("name");
QueryRecordProject recordList = new QueryRecordProject();
recordList.setDatabaseKey(key);
recordList.setName(name);
try {
recordList.setCreateDate(formater.parse(dateStr));
} catch (ParseException e) {
recordList.setCreateDate(new Date());
}
IXMLMemento[] queryRecordArray = child.getChildren("query_record");
if (queryRecordArray != null && queryRecordArray.length > 0) {
for (int j = 0; j < queryRecordArray.length; j++) {
IXMLMemento memen = queryRecordArray[j];
QueryRecord queryRecord = loadQueryRecord(memen);
recordList.addQueryRecord(queryRecord);
}
}
List<QueryRecordProject> list = queryRecordMap.get(key);
if (list == null) {
list = new ArrayList<QueryRecordProject>();
queryRecordMap.put(key, list);
}
list.add(recordList);
}
}
}
Aggregations