Search in sources :

Example 1 with XMLMemento

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

the class NodeFilterManager method saveFilterSetting.

/**
	 * Save filter setting to plug-in preference
	 */
@SuppressWarnings("deprecation")
public void saveFilterSetting() {
    synchronized (this) {
        try {
            XMLMemento memento = XMLMemento.createWriteRoot("filters");
            if (memento == null) {
                LOGGER.error("XMLMemento.createWriteRoot('filters') is a null.");
                return;
            }
            Iterator<String> iterator = idFilterList.iterator();
            while (iterator.hasNext()) {
                String pattern = (String) iterator.next();
                IXMLMemento child = memento.createChild("idFilter");
                child.putString("id", pattern);
            }
            iterator = idGrayFilterList.iterator();
            while (iterator.hasNext()) {
                String pattern = (String) iterator.next();
                IXMLMemento child = memento.createChild("idGrayFilter");
                child.putString("id", pattern);
            }
            iterator = nameFilterList.iterator();
            while (iterator.hasNext()) {
                String pattern = (String) iterator.next();
                IXMLMemento child = memento.createChild("nameFilter");
                child.putString("pattern", pattern);
            }
            String xmlString = memento.saveToString();
            IEclipsePreferences preference = new InstanceScope().getNode(CommonUIPlugin.PLUGIN_ID);
            preference.put(FILTER_XML_CONTENT, xmlString);
            preference.flush();
        } catch (Exception e) {
            LOGGER.error("saveFilterSetting", e);
        }
    }
}
Also used : XMLMemento(com.cubrid.cubridmanager.core.common.xml.XMLMemento) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 2 with XMLMemento

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

the class ImportConfigManager method saveConfigs.

/**
	 *
	 * Save the import configs to plug-in preference
	 *
	 */
public void saveConfigs() {
    synchronized (this) {
        XMLMemento memento = XMLMemento.createWriteRoot("databases");
        Iterator<ImportConfig> iterator = importConfigList.iterator();
        while (iterator.hasNext()) {
            ImportConfig model = (ImportConfig) iterator.next();
            model.setHistory(true);
            IXMLMemento configMemento = memento.createChild("config");
            configMemento.putString("name", model.getName());
            configMemento.putString("id", model.getId());
            configMemento.putInteger("importType", model.getImportType());
            configMemento.putInteger("errorHandle", model.getErrorHandle());
            configMemento.putString("fileCharset", model.getFilesCharset());
            configMemento.putBoolean("isCreateTable", model.isCreateTableAccordingData());
            configMemento.putInteger("threadCount", model.getThreadCount());
            configMemento.putInteger("commitCount", model.getCommitLine());
            configMemento.putString("rowDelimiter", model.getRowDelimiter());
            configMemento.putString("columnDelimiter", model.getColumnDelimiter());
            configMemento.putBoolean("isHaMode", model.isHaMode());
            IXMLMemento nullValuesMemento = configMemento.createChild("nullValues");
            for (String nullValue : model.getNullValueList()) {
                IXMLMemento nullValueMemento = nullValuesMemento.createChild("nullValue");
                nullValueMemento.putTextData(nullValue);
            }
            IXMLMemento tableConfigsMemento = configMemento.createChild("tableConfigs");
            for (TableConfig tableConfig : model.getSelectedMap().values()) {
                IXMLMemento tableConfigMemento = tableConfigsMemento.createChild("tableConfig");
                for (PstmtParameter pstm : tableConfig.getPstmList()) {
                    IXMLMemento pstmMemento = tableConfigMemento.createChild("pstm");
                    pstmMemento.putString("paramName", pstm.getParamName());
                    pstmMemento.putString("paramType", pstm.getDataType());
                    pstmMemento.putString("paramValue", pstm.getStringParamValue());
                    pstmMemento.putInteger("paramIndex", pstm.getParamIndex());
                    pstmMemento.putString("fileColumnName", pstm.getFileColumnName());
                }
                tableConfigMemento.putString("name", tableConfig.getName());
                tableConfigMemento.putString("filePath", tableConfig.getFilePath());
                tableConfigMemento.putString("fileType", tableConfig.getFileType() == null ? "" : tableConfig.getFileType());
                tableConfigMemento.putInteger("lineCount", tableConfig.getLineCount());
                tableConfigMemento.putString("createDDL", tableConfig.getCreateDDL() == null ? "" : tableConfig.getCreateDDL());
                tableConfigMemento.putString("insertDML", tableConfig.getInsertDML() == null ? "" : tableConfig.getInsertDML());
                tableConfigMemento.putBoolean("isFirstRowAsColumn", tableConfig.isFirstRowAsColumn());
            }
        }
        PersistUtils.saveXMLMemento(CommonUIPlugin.PLUGIN_ID, COM_CUBRID_IMPORT_SETTING, memento);
    }
}
Also used : PstmtParameter(com.cubrid.common.ui.cubrid.table.dialog.PstmtParameter) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) XMLMemento(com.cubrid.cubridmanager.core.common.xml.XMLMemento) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento)

Example 3 with XMLMemento

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

the class ExportConfigManager method saveConfigs.

/**
	 *
	 * Save the export configs to plug-in preference
	 *
	 */
public void saveConfigs() {
    synchronized (this) {
        XMLMemento memento = XMLMemento.createWriteRoot("databases");
        Iterator<ExportConfig> iterator = exportConfigList.iterator();
        while (iterator.hasNext()) {
            ExportConfig model = (ExportConfig) iterator.next();
            IXMLMemento configMemento = memento.createChild("config");
            configMemento.putString("name", model.getName());
            configMemento.putInteger("exportType", model.getExportType());
            configMemento.putInteger("fileType", model.getExportFileType());
            configMemento.putBoolean("exportData", model.isExportData());
            configMemento.putBoolean("exportIndex", model.isExportIndex());
            configMemento.putBoolean("exportSchema", model.isExportSchema());
            configMemento.putBoolean("exportSerial", model.isExportSerial());
            configMemento.putBoolean("exportView", model.isExportView());
            configMemento.putBoolean("exportStartValue", model.isExportSerialStartValue());
            configMemento.putBoolean("exportLob", model.isExportLob());
            configMemento.putString("schemaFile", model.getSchemaFilePath());
            configMemento.putString("indexFile", model.getIndexFilePath());
            configMemento.putString("dataFile", model.getDataFileFolder());
            configMemento.putString("fileCharset", model.getFileCharset());
            configMemento.putInteger("threadCount", model.getThreadCount());
            configMemento.putBoolean("useFirstAsColumn", model.isFirstRowAsColumnName());
            configMemento.putString("nullValue", model.getNULLValueTranslation());
            configMemento.putString("rowDelimiter", model.getRowDelimeter());
            configMemento.putString("colDelimiter", model.getColumnDelimeter());
            List<String> tableList = model.getTableNameList();
            for (String tableName : tableList) {
                IXMLMemento tableMemento = configMemento.createChild("table");
                tableMemento.putString("name", tableName);
                String whereCondition = model.getWhereCondition(tableName);
                if (StringUtil.isNotEmpty(whereCondition)) {
                    tableMemento.putString("where", whereCondition);
                }
            }
        }
        PersistUtils.saveXMLMemento(CommonUIPlugin.PLUGIN_ID, COM_CUBRID_EXPORT_SETTING, memento);
    }
}
Also used : XMLMemento(com.cubrid.cubridmanager.core.common.xml.XMLMemento) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) ExportConfig(com.cubrid.common.ui.cubrid.table.progress.ExportConfig) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento)

Example 4 with XMLMemento

use of com.cubrid.cubridmanager.core.common.xml.XMLMemento 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 5 with XMLMemento

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

the class ApplicationWorkbenchWindowAdvisor method saveLastVersion.

public void saveLastVersion(String version) {
    XMLMemento memento = XMLMemento.createWriteRoot("settings");
    memento.putString("lastVersion", version);
    PersistUtils.saveXMLMemento(this.getClass().getName(), "startup", memento);
}
Also used : XMLMemento(com.cubrid.cubridmanager.core.common.xml.XMLMemento) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento)

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