use of com.cubrid.cubridmanager.core.common.xml.XMLMemento in project cubrid-manager by CUBRID.
the class BrokerTblColumnSetHelp method saveSetting.
/**
*
* Save broker interval to plugin preference
*
* @param <T> the generic type which is the sub type of IColumnSetting
* @param statusColumn the instance of StatusColumn enumeration
* @param ts the instance of generic array
*/
public <T extends IColumnSetting> void saveSetting(StatusColumn statusColumn, T[] ts) {
synchronized (this) {
try {
XMLMemento memento = XMLMemento.createWriteRoot(statusColumn.name());
IXMLMemento child = memento.createChild(statusColumn.name());
for (T column : ts) {
child.putString(column.getNick(), String.valueOf(column.getValue()));
}
String xmlString = memento.saveToString();
IEclipsePreferences preference = new InstanceScope().getNode(CubridManagerUIPlugin.PLUGIN_ID);
preference.put(statusColumn.name(), xmlString);
preference.flush();
} catch (Exception e) {
LOGGER.error(e.getMessage());
}
}
}
use of com.cubrid.cubridmanager.core.common.xml.XMLMemento in project cubrid-manager by CUBRID.
the class BrokerIntervalSettingManager method saveBrokerIntervals.
/**
*
* Save broker interval to plugin preference
*
*/
public void saveBrokerIntervals() {
synchronized (this) {
if (!initialized) {
init();
}
try {
XMLMemento memento = XMLMemento.createWriteRoot("BrokerIntervalSettings");
Iterator<BrokerIntervalSetting> iterator = brokerIntervalSettingList.iterator();
while (iterator.hasNext()) {
BrokerIntervalSetting brokerInterval = (BrokerIntervalSetting) iterator.next();
IXMLMemento child = memento.createChild("BrokerIntervalSetting");
child.putString("serverName", brokerInterval.getServerName());
child.putString("brokerName", brokerInterval.getBrokerName());
child.putString("isOn", brokerInterval.isOn() ? "true" : "false");
child.putString("interval", brokerInterval.getInterval());
}
String xmlString = memento.saveToString();
IEclipsePreferences preference = new InstanceScope().getNode(CubridManagerUIPlugin.PLUGIN_ID);
preference.put(CUBRID_BROKER_INTERVAL_XML_CONTENT, xmlString);
preference.flush();
} catch (Exception e) {
LOGGER.error(e.getMessage());
}
}
}
use of com.cubrid.cubridmanager.core.common.xml.XMLMemento in project cubrid-manager by CUBRID.
the class CQBDBNodePersistManager method saveDatabases.
/**
*
* Save added database to plug-in preference
*
*/
public void saveDatabases() {
synchronized (this) {
XMLMemento memento = XMLMemento.createWriteRoot("databases");
Iterator<CubridDatabase> iterator = databaseList.iterator();
while (iterator.hasNext()) {
CubridDatabase database = (CubridDatabase) iterator.next();
DatabaseInfo dbInfo = database.getDatabaseInfo();
ServerInfo serverInfo = dbInfo.getServerInfo();
DbUserInfo dbUserInfo = dbInfo.getAuthLoginedDbUserInfo();
IXMLMemento child = memento.createChild("database");
child.putString("name", database.getLabel());
child.putString("dbName", dbInfo.getDbName());
child.putString("dbUser", dbUserInfo.getName());
if (database.isAutoSavePassword()) {
child.putString("dbPassword", CipherUtils.encrypt(dbUserInfo.getNoEncryptPassword()));
} else {
child.putString("dbPassword", "");
}
child.putString("savePassword", String.valueOf(database.isAutoSavePassword()));
// [TOOLS-2425]Support shard broker
child.putString("isShard", String.valueOf(dbInfo.isShard()));
child.putString("shardQueryType", String.valueOf(dbInfo.getShardQueryType()));
child.putString("jdbcDriver", serverInfo.getJdbcDriverVersion());
child.putString("brokerIp", dbInfo.getBrokerIP());
child.putString("brokerPort", dbInfo.getBrokerPort());
child.putString("charset", dbInfo.getCharSet());
child.putString("jdbcAttrs", dbInfo.getJdbcAttrs());
/*Save the database editor config*/
DatabaseEditorConfig editorConfig = QueryOptions.getEditorConfig(database, false);
if (editorConfig != null) {
IXMLMemento editorConfigChild = child.createChild("editorConfig");
editorConfigChild.putString("database-comment", editorConfig.getDatabaseComment() == null ? "" : editorConfig.getDatabaseComment());
if (editorConfig.getBackGround() != null) {
RGB background = editorConfig.getBackGround();
int bgPos = EditorConstance.getBGPos(background);
editorConfigChild.putInteger("purpose-code", bgPos);
}
}
}
PersistUtils.saveXMLMemento(ApplicationUtil.CQB_UI_PLUGIN_ID, DATABASE_XML_CONTENT, memento);
}
}
use of com.cubrid.cubridmanager.core.common.xml.XMLMemento in project cubrid-manager by CUBRID.
the class CMGroupNodePersistManager method saveAllGroupNode.
/**
* Save all group node.
*
*/
public void saveAllGroupNode() {
synchronized (this) {
XMLMemento memento = XMLMemento.createWriteRoot("groups");
for (CubridGroupNode group : groupNodeList) {
IXMLMemento child = memento.createChild("group");
child.putString("id", group.getId());
child.putString("name", group.getName());
for (ICubridNode cn : group.getChildren()) {
IXMLMemento childHost = child.createChild("item");
childHost.putString("id", cn.getId());
}
}
PersistUtils.saveXMLMemento(ApplicationUtil.CM_UI_PLUGIN_ID, COM_CUBRID_MANAGER_HOSTGROUP, memento);
}
}
use of com.cubrid.cubridmanager.core.common.xml.XMLMemento in project cubrid-manager by CUBRID.
the class CMHostNodePersistManager method saveServer.
public void saveServer(List<CubridServer> servers, String f) {
synchronized (this) {
XMLMemento memento = XMLMemento.createWriteRoot("hosts");
Iterator<CubridServer> iterator = servers.iterator();
while (iterator.hasNext()) {
CubridServer server = (CubridServer) iterator.next();
IXMLMemento child = memento.createChild("host");
child.putString("id", server.getId());
child.putString("name", server.getLabel());
child.putString("port", String.valueOf(server.getMonPort()));
child.putString("address", server.getHostAddress());
child.putString("user", server.getUserName());
// String pwd = server.isAutoSavePassword() ? CipherUtils.encrypt(server.getPassword())
// : "";
// child.putString("password", pwd);
// child.putBoolean("savePassword", false);
child.putString("jdbcDriver", server.getJdbcDriverVersion());
if (server.getServerInfo() != null) {
child.putInteger("soTimeOut", server.getServerInfo().getSoTimeOut());
}
}
FileOutputStream fout = null;
try {
fout = new FileOutputStream(f);
fout.write(memento.getContents());
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
fout.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
Aggregations