use of org.eclipse.titan.log.viewer.preferences.data.KeywordColor in project titan.EclipsePlug-ins by eclipse.
the class ImportExportUtils method exportKeywordColorsToXml.
protected static void exportKeywordColorsToXml(String pageID, Map<String, Object[]> settings, boolean useIndentation, OutputStream stream) throws TechnicalException {
try {
Document document = createDocument(pageID);
Element root = document.getDocumentElement();
root.setAttribute(VERSION_ATTRIBUTE_KEY, CURRENT_LV_VERSION);
SortedMap<String, Object[]> sortedMap = new TreeMap<String, Object[]>(settings);
for (Map.Entry<String, Object[]> entry : sortedMap.entrySet()) {
String currentKey = entry.getKey();
Element parent = document.createElement(currentKey);
if (useIndentation) {
root.appendChild(document.createTextNode(NEW_LINE + PARENT_INDENTATION));
}
root.appendChild(parent);
Object[] values = entry.getValue();
if (values instanceof String[]) {
String[] stringValues = (String[]) values;
for (int i = 0; i < stringValues.length; i++) {
addStringElement(useIndentation, document, parent, stringValues[i]);
addNewLineIfLast(document, parent, values, i);
}
} else if (values instanceof KeywordColor[]) {
KeywordColor[] colorValues = (KeywordColor[]) values;
for (int i = 0; i < colorValues.length; i++) {
addKeywordColor(useIndentation, document, parent, colorValues[i]);
addNewLineIfLast(document, parent, values, i);
}
}
}
// if last parent
if (useIndentation) {
root.appendChild(document.createTextNode(NEW_LINE));
}
writeDocument(stream, document);
} catch (ParserConfigurationException e) {
throw new TechnicalException(e);
} catch (TransformerException e) {
throw new TechnicalException(e);
}
}
use of org.eclipse.titan.log.viewer.preferences.data.KeywordColor in project titan.EclipsePlug-ins by eclipse.
the class HighlightKeywordsPage method getCurrentPreferencesSeparated.
/**
* Method for getting the current preferences in the preference store
* @return map of the preferences
*/
private Map<String, Object[]> getCurrentPreferencesSeparated() {
Map<String, Object[]> currentPrefs = new HashMap<String, Object[]>();
String[] highlight = new String[] { String.valueOf(this.useHighLight.getBooleanValue()) };
currentPrefs.put(PreferenceConstants.PREF_USE_HIGHLIGHT_ID, highlight);
String[] listItems = this.highLightEditor.getElements();
Map<String, RGB> colors = this.highLightEditor.getColors();
KeywordColor[] values = new KeywordColor[this.highLightEditor.getElements().length];
for (int i = 0; i < listItems.length; i++) {
String item = listItems[i];
RGB color = colors.get(item);
KeywordColor keywordColor = new KeywordColor(item, color);
values[i] = keywordColor;
}
currentPrefs.put(this.highLightEditor.getPreferenceName(), values);
return currentPrefs;
}
Aggregations