Search in sources :

Example 26 with IXMLMemento

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);
    }
}
Also used : IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento)

Example 27 with IXMLMemento

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;
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) IOException(java.io.IOException) PreferenceStore(org.eclipse.jface.preference.PreferenceStore)

Example 28 with IXMLMemento

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);
    }
}
Also used : IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento)

Example 29 with IXMLMemento

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);
    }
}
Also used : Entry(java.util.Map.Entry) XMLMemento(com.cubrid.cubridmanager.core.common.xml.XMLMemento) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) HashMap(java.util.HashMap) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento)

Example 30 with IXMLMemento

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);
        }
    }
}
Also used : QueryRecordProject(com.cubrid.common.ui.query.tuner.QueryRecordProject) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) DateFormat(java.text.DateFormat) QueryRecord(com.cubrid.common.ui.query.tuner.QueryRecord) ParseException(java.text.ParseException) Date(java.util.Date)

Aggregations

IXMLMemento (com.cubrid.cubridmanager.core.common.xml.IXMLMemento)54 XMLMemento (com.cubrid.cubridmanager.core.common.xml.XMLMemento)18 ByteArrayInputStream (java.io.ByteArrayInputStream)10 IOException (java.io.IOException)10 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)8 ArrayList (java.util.ArrayList)7 DatabaseEditorConfig (com.cubrid.common.ui.spi.model.DatabaseEditorConfig)6 HashMap (java.util.HashMap)6 RGB (org.eclipse.swt.graphics.RGB)6 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)5 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)5 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)5 InstanceScope (org.eclipse.core.runtime.preferences.InstanceScope)5 PreferenceStore (org.eclipse.jface.preference.PreferenceStore)5 CubridGroupNode (com.cubrid.common.ui.spi.model.CubridGroupNode)4 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)4 SQLHistoryDetail (com.cubrid.common.ui.query.control.SQLHistoryDetail)3 QueryRecord (com.cubrid.common.ui.query.tuner.QueryRecord)3 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)3 MonitorStatistic (com.cubrid.common.ui.spi.model.MonitorStatistic)3