Search in sources :

Example 6 with XMLMemento

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());
        }
    }
}
Also used : IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) XMLMemento(com.cubrid.cubridmanager.core.common.xml.XMLMemento) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope)

Example 7 with XMLMemento

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());
        }
    }
}
Also used : IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) XMLMemento(com.cubrid.cubridmanager.core.common.xml.XMLMemento) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope)

Example 8 with XMLMemento

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);
    }
}
Also used : DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) XMLMemento(com.cubrid.cubridmanager.core.common.xml.XMLMemento) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) RGB(org.eclipse.swt.graphics.RGB) DatabaseEditorConfig(com.cubrid.common.ui.spi.model.DatabaseEditorConfig)

Example 9 with XMLMemento

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);
    }
}
Also used : CubridGroupNode(com.cubrid.common.ui.spi.model.CubridGroupNode) XMLMemento(com.cubrid.cubridmanager.core.common.xml.XMLMemento) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode)

Example 10 with XMLMemento

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();
            }
        }
    }
}
Also used : XMLMemento(com.cubrid.cubridmanager.core.common.xml.XMLMemento) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) IOException(java.io.IOException)

Aggregations

IXMLMemento (com.cubrid.cubridmanager.core.common.xml.IXMLMemento)19 XMLMemento (com.cubrid.cubridmanager.core.common.xml.XMLMemento)19 DatabaseEditorConfig (com.cubrid.common.ui.spi.model.DatabaseEditorConfig)3 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)3 HashMap (java.util.HashMap)3 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)3 InstanceScope (org.eclipse.core.runtime.preferences.InstanceScope)3 RGB (org.eclipse.swt.graphics.RGB)3 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)2 CubridGroupNode (com.cubrid.common.ui.spi.model.CubridGroupNode)2 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)2 MonitorStatistic (com.cubrid.common.ui.spi.model.MonitorStatistic)2 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)2 FileOutputStream (java.io.FileOutputStream)2 IOException (java.io.IOException)2 Map (java.util.Map)2 PstmtParameter (com.cubrid.common.ui.cubrid.table.dialog.PstmtParameter)1 ExportConfig (com.cubrid.common.ui.cubrid.table.progress.ExportConfig)1 SQLHistoryDetail (com.cubrid.common.ui.query.control.SQLHistoryDetail)1 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)1