Search in sources :

Example 6 with IXMLMemento

use of com.cubrid.cubridmanager.core.common.xml.IXMLMemento in project cubrid-manager by CUBRID.

the class ApplicationPersistUtil method loadSQLTabItem.

/**
	 * loadSQLTabItem if has sql_tabItem node ,is new version old version not
	 * have this node
	 *
	 * @param element
	 * @return
	 */
private ArrayList<RestorableQueryEditorInfo> loadSQLTabItem(IXMLMemento element) {
    IXMLMemento[] sql_tabItemArray = element.getChildren("sql_tabItem");
    ArrayList<RestorableQueryEditorInfo> sql_tabItemList = new ArrayList<RestorableQueryEditorInfo>();
    if (sql_tabItemArray != null && sql_tabItemArray.length > 0) {
        for (int i = 0; sql_tabItemArray != null && i < sql_tabItemArray.length; i++) {
            IXMLMemento child = sql_tabItemArray[i];
            sql_tabItemList.add(loadRestorableQueryEditorInfo(child));
        }
    } else {
        if (element.getString("database") != null) {
            sql_tabItemList.add(loadRestorableQueryEditorInfo(element));
        }
    }
    return sql_tabItemList;
}
Also used : IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) ArrayList(java.util.ArrayList) RestorableQueryEditorInfo(com.cubrid.common.ui.spi.model.RestorableQueryEditorInfo)

Example 7 with IXMLMemento

use of com.cubrid.cubridmanager.core.common.xml.IXMLMemento in project cubrid-manager by CUBRID.

the class CubridJdbcManager method loadCubridJdbc.

/**
	 * Load CUBRID JDBC driver from plugin preference and register these class
	 * loaders
	 * 
	 * @param silence if true, the chaning event will not be triggered.
	 * 
	 * @return all CUBRID Jdbc driver
	 */
private void loadCubridJdbc(boolean silence) {
    synchronized (CubridJdbcManager.class) {
        IXMLMemento memento = PersistUtils.getXMLMemento(CommonUIPlugin.PLUGIN_ID, CUBRID_JDBC_SETTING);
        if (memento == null) {
            loadDefaultJdbcs();
        } else {
            IXMLMemento[] children = memento.getChildren("cubridJdbcSetting");
            if (children == null || children.length == 0) {
                loadDefaultJdbcs();
            } else {
                for (int i = 0; i < children.length; i++) {
                    String jdbcURL = children[i].getString("jdbcURL");
                    registerClassLoader(externalVersion2FileMap, jdbcURL);
                }
            }
        }
    }
}
Also used : IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento)

Example 8 with IXMLMemento

use of com.cubrid.cubridmanager.core.common.xml.IXMLMemento in project cubrid-manager by CUBRID.

the class FavoriteQueryPersistUtil method loadBatchRunList.

public void loadBatchRunList() {
    IXMLMemento memento = PersistUtils.getXMLMemento(BatchRunComposite.ID, LIST_ID);
    if (memento == null) {
        return;
    }
    try {
        listData.clear();
        for (IXMLMemento xmlMemento : memento.getChildren("BatchRun")) {
            Map<String, String> data = new HashMap<String, String>();
            data.put("0", "");
            data.put("1", xmlMemento.getString("filename"));
            data.put("2", xmlMemento.getString("memo"));
            data.put("3", xmlMemento.getString("regdate"));
            data.put("4", xmlMemento.getString("directory"));
            data.put("5", xmlMemento.getString("charset"));
            data.put("6", xmlMemento.getString("managed"));
            listData.add(data);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : HashMap(java.util.HashMap) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento)

Example 9 with IXMLMemento

use of com.cubrid.cubridmanager.core.common.xml.IXMLMemento in project cubrid-manager by CUBRID.

the class RecentlyUsedSQLDetailPersistUtils method saveToXML.

/**
	 * save the sql to preference
	 *
	 * @param id
	 * @param recentlyUsedSQLContentList
	 */
private static void saveToXML(String id, LinkedList<SQLHistoryDetail> sqlHistories) {
    if (sqlHistories == null) {
        return;
    }
    XMLMemento memento = XMLMemento.createWriteRoot("SQLHistoryDetails");
    for (int i = 0, len = sqlHistories.size(); i < len; i++) {
        IXMLMemento subNodes = memento.createChild("SQLHistoryDetail");
        SQLHistoryDetail historyDetail = (SQLHistoryDetail) sqlHistories.get(i);
        subNodes.putString("SQL", historyDetail.getSql());
        subNodes.putString("elapseTime", historyDetail.getElapseTime());
        subNodes.putString("executeTime", historyDetail.getExecuteTime());
        subNodes.putString("LOG", historyDetail.getExecuteInfo());
    }
    PersistUtils.saveXMLMemento(RecentlyUsedSQLComposite.ID, id, memento);
}
Also used : IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) XMLMemento(com.cubrid.cubridmanager.core.common.xml.XMLMemento) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) SQLHistoryDetail(com.cubrid.common.ui.query.control.SQLHistoryDetail)

Example 10 with IXMLMemento

use of com.cubrid.cubridmanager.core.common.xml.IXMLMemento in project cubrid-manager by CUBRID.

the class BrokerTblColumnSetHelp method loadSetting.

/**
	 * 
	 * Load broker interval settings from 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 loadSetting(StatusColumn statusColumn, T[] ts) {
    synchronized (this) {
        IEclipsePreferences preference = new InstanceScope().getNode(CubridManagerUIPlugin.PLUGIN_ID);
        String xmlString = preference.get(statusColumn.name(), "");
        if (xmlString != null && xmlString.length() > 0) {
            try {
                ByteArrayInputStream in = new ByteArrayInputStream(xmlString.getBytes("UTF-8"));
                IXMLMemento memento = XMLMemento.loadMemento(in);
                IXMLMemento[] children = memento.getChildren(statusColumn.name());
                for (IXMLMemento child : children) {
                    for (T t : ts) {
                        t.setValue(child.getInteger(t.getNick()));
                    }
                }
            } catch (Exception e) {
                LOGGER.error(e.getMessage());
            }
        }
    }
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) ByteArrayInputStream(java.io.ByteArrayInputStream) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope)

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