Search in sources :

Example 11 with IXMLMemento

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

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

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

the class ImportExportConnectionDialog method parseFile.

protected void parseFile(String fileName) {
    int repeatCount = 0;
    List<CubridServer> newServerList = new ArrayList<CubridServer>();
    File file = new File(fileName);
    if (!file.exists()) {
        return;
    }
    FileInputStream fis = null;
    try {
        fis = new FileInputStream(file);
        IXMLMemento xmlContent = XMLMemento.loadMemento(fis);
        List<CubridServer> list = new ArrayList<CubridServer>();
        CMHostNodePersistManager.getInstance().loadServers(xmlContent, false, EMPTY_STR, list);
        for (CubridServer server : list) {
            if (!isContainSameHost(server)) {
                newServerList.add(server);
            } else {
                repeatCount++;
            }
        }
    } catch (Exception e) {
        LOGGER.error("", e);
    } finally {
        FileUtil.close(fis);
    }
    if (repeatCount > 0) {
        setMessage(Messages.bind(Messages.msgInfoSame, repeatCount), IMessageProvider.WARNING);
    } else {
        setMessage(null);
    }
    hostListView.setInput(newServerList);
    hostListView.refresh();
}
Also used : IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) ArrayList(java.util.ArrayList) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) File(java.io.File) FileInputStream(java.io.FileInputStream) IOException(java.io.IOException)

Example 14 with IXMLMemento

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

the class BrokerIntervalSettingManager method loadBrokerIntervalSettings.

/**
	 *
	 * Load broker interval settings from plugin preference
	 *
	 */
protected void loadBrokerIntervalSettings() {
    synchronized (this) {
        IEclipsePreferences preference = new InstanceScope().getNode(CubridManagerUIPlugin.PLUGIN_ID);
        String xmlString = preference.get(CUBRID_BROKER_INTERVAL_XML_CONTENT, "");
        if (xmlString != null && xmlString.length() > 0) {
            try {
                ByteArrayInputStream in = new ByteArrayInputStream(xmlString.getBytes("UTF-8"));
                IXMLMemento memento = XMLMemento.loadMemento(in);
                IXMLMemento[] children = memento.getChildren("BrokerIntervalSetting");
                for (int i = 0; i < children.length; i++) {
                    String serverName = children[i].getString("serverName");
                    String brokerName = children[i].getString("brokerName");
                    String isOn = children[i].getString("isOn");
                    String interval = children[i].getString("interval");
                    BrokerIntervalSetting brokerInterval = new BrokerIntervalSetting(serverName, brokerName, interval, isOn != null && isOn.equals("true"));
                    brokerIntervalSettingList.add(brokerInterval);
                }
            } 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)

Example 15 with IXMLMemento

use of com.cubrid.cubridmanager.core.common.xml.IXMLMemento 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)

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