|
Lines 12-17
Link Here
|
| 12 |
|
12 |
|
| 13 |
package org.eclipse.tptp.monitoring.logui.internal.wizards; |
13 |
package org.eclipse.tptp.monitoring.logui.internal.wizards; |
| 14 |
|
14 |
|
|
|
15 |
import java.io.ByteArrayOutputStream; |
| 16 |
import java.io.IOException; |
| 17 |
import java.io.StringWriter; |
| 15 |
import java.net.URL; |
18 |
import java.net.URL; |
| 16 |
import java.util.ArrayList; |
19 |
import java.util.ArrayList; |
| 17 |
import java.util.HashMap; |
20 |
import java.util.HashMap; |
|
Lines 20-36
Link Here
|
| 20 |
import java.util.Map; |
23 |
import java.util.Map; |
| 21 |
import java.util.Set; |
24 |
import java.util.Set; |
| 22 |
|
25 |
|
|
|
26 |
import org.apache.xml.serialize.OutputFormat; |
| 27 |
import org.apache.xml.serialize.XMLSerializer; |
| 23 |
import org.eclipse.core.runtime.IConfigurationElement; |
28 |
import org.eclipse.core.runtime.IConfigurationElement; |
| 24 |
import org.eclipse.core.runtime.IStatus; |
29 |
import org.eclipse.core.runtime.IStatus; |
| 25 |
import org.eclipse.core.runtime.Platform; |
30 |
import org.eclipse.core.runtime.Platform; |
| 26 |
import org.eclipse.core.runtime.Status; |
31 |
import org.eclipse.core.runtime.Status; |
| 27 |
import org.eclipse.emf.common.util.URI; |
32 |
import org.eclipse.emf.common.util.URI; |
| 28 |
import org.eclipse.emf.ecore.util.EcoreUtil; |
33 |
import org.eclipse.emf.ecore.util.EcoreUtil; |
|
|
34 |
import org.eclipse.emf.ecore.xmi.XMLResource; |
| 29 |
import org.eclipse.hyades.internal.execution.local.common.Constants; |
35 |
import org.eclipse.hyades.internal.execution.local.common.Constants; |
| 30 |
import org.eclipse.hyades.models.hierarchy.TRCAgentProxy; |
36 |
import org.eclipse.hyades.models.hierarchy.TRCAgentProxy; |
| 31 |
import org.eclipse.hyades.ui.filters.IFilterScopes; |
37 |
import org.eclipse.hyades.ui.filters.IFilterScopes; |
| 32 |
import org.eclipse.hyades.ui.filters.internal.util.FilterInformationManager; |
38 |
import org.eclipse.hyades.ui.filters.internal.util.FilterInformationManager; |
| 33 |
import org.eclipse.hyades.ui.filters.internal.util.FilterQueries; |
39 |
import org.eclipse.hyades.ui.filters.internal.util.FilterQueries; |
|
|
40 |
import org.eclipse.hyades.ui.filters.internal.util.FilterResourceFileHandler; |
| 41 |
import org.eclipse.hyades.ui.filters.internal.util.FilterResourceHandler; |
| 34 |
import org.eclipse.hyades.ui.internal.util.XMLUtil; |
42 |
import org.eclipse.hyades.ui.internal.util.XMLUtil; |
| 35 |
|
43 |
|
| 36 |
import org.eclipse.jface.preference.IPreferenceStore; |
44 |
import org.eclipse.jface.preference.IPreferenceStore; |
|
Lines 38-44
Link Here
|
| 38 |
import org.eclipse.tptp.monitoring.logui.internal.LogUIMessages; |
46 |
import org.eclipse.tptp.monitoring.logui.internal.LogUIMessages; |
| 39 |
import org.eclipse.tptp.monitoring.logui.internal.MonitoringLogUIPlugin; |
47 |
import org.eclipse.tptp.monitoring.logui.internal.MonitoringLogUIPlugin; |
| 40 |
import org.eclipse.tptp.platform.common.ui.trace.internal.helpers.TraceUIManager; |
48 |
import org.eclipse.tptp.platform.common.ui.trace.internal.helpers.TraceUIManager; |
|
|
49 |
import org.w3c.dom.Document; |
| 41 |
import org.w3c.dom.Element; |
50 |
import org.w3c.dom.Element; |
|
|
51 |
import org.w3c.dom.Node; |
| 42 |
import org.w3c.dom.NodeList; |
52 |
import org.w3c.dom.NodeList; |
| 43 |
|
53 |
|
| 44 |
import com.ibm.icu.util.StringTokenizer; |
54 |
import com.ibm.icu.util.StringTokenizer; |
|
Lines 50-56
Link Here
|
| 50 |
public static final String LOGSET_TAG = "logset"; |
60 |
public static final String LOGSET_TAG = "logset"; |
| 51 |
public static final String LOGELEMENT_TAG = "LogFileElement"; |
61 |
public static final String LOGELEMENT_TAG = "LogFileElement"; |
| 52 |
public static final String DEFAULT_LOGSET = LogUIMessages._54; |
62 |
public static final String DEFAULT_LOGSET = LogUIMessages._54; |
| 53 |
|
63 |
public static final String FILTER_TAG = "filters"; |
|
|
64 |
public static final String EXPORT_URI="/temp.txt"; |
| 65 |
public static final Map RESOURCE_OPTIONS = new HashMap(); |
| 66 |
{ |
| 67 |
RESOURCE_OPTIONS.put(XMLResource.OPTION_DECLARE_XML, Boolean.FALSE); |
| 68 |
} |
| 54 |
private IPreferenceStore preferenceStore = MonitoringLogUIPlugin.getDefault().getPreferenceStore(); |
69 |
private IPreferenceStore preferenceStore = MonitoringLogUIPlugin.getDefault().getPreferenceStore(); |
| 55 |
private String defaultLogSet; |
70 |
private String defaultLogSet; |
| 56 |
private Map logSetsList = new HashMap(); |
71 |
private Map logSetsList = new HashMap(); |
|
Lines 87-93
Link Here
|
| 87 |
loadParserRegistry(); |
102 |
loadParserRegistry(); |
| 88 |
|
103 |
|
| 89 |
} |
104 |
} |
| 90 |
|
105 |
public void saveLogSetFilters(List logSetFilterList) { |
|
|
106 |
FilterResourceHandler rTarget = FilterResourceHandler.instance(); //list of all existing filters |
| 107 |
Object[] targetFilterQueries = rTarget.toArray(); |
| 108 |
if(targetFilterQueries.length > 0){ |
| 109 |
for (int i = 0; i < targetFilterQueries.length; i++) |
| 110 |
{ |
| 111 |
FilterQueries existingFQ = (FilterQueries) targetFilterQueries[i]; |
| 112 |
if(existingFQ != null){ |
| 113 |
String targetFilterName = (existingFQ).name(); |
| 114 |
for (Iterator iter = logSetFilterList.iterator(); iter.hasNext();) { |
| 115 |
FilterQueries fq = (FilterQueries) iter.next(); |
| 116 |
if(fq != null){ |
| 117 |
if(targetFilterName.equals(fq.name())){ |
| 118 |
rTarget.removeFilter(existingFQ); |
| 119 |
} |
| 120 |
rTarget.addFilter(fq); |
| 121 |
} |
| 122 |
} |
| 123 |
} |
| 124 |
} |
| 125 |
} |
| 126 |
else{ |
| 127 |
for (Iterator iter = logSetFilterList.iterator(); iter.hasNext();) { |
| 128 |
FilterQueries fq = (FilterQueries) iter.next(); |
| 129 |
if(fq != null){ |
| 130 |
rTarget.addFilter(fq); |
| 131 |
} |
| 132 |
} |
| 133 |
} |
| 134 |
rTarget.save(); |
| 135 |
} |
| 136 |
public static String toString(Node xml) { |
| 137 |
return toString(xml, true); |
| 138 |
} |
| 139 |
|
| 140 |
public static String toString(Node xml, boolean printHeader) { |
| 141 |
return toString(xml, printHeader, true); |
| 142 |
} |
| 143 |
|
| 144 |
public static String toString(Node xml, boolean printHeader, |
| 145 |
boolean printIndents) { |
| 146 |
short type = xml.getNodeType(); |
| 147 |
if (type == 3) { |
| 148 |
return xml.getNodeValue(); |
| 149 |
} |
| 150 |
XMLSerializer serializer = new XMLSerializer(); |
| 151 |
serializer.setNamespaces(true); |
| 152 |
OutputFormat formatter = new OutputFormat(); |
| 153 |
formatter.setOmitXMLDeclaration(!printHeader); |
| 154 |
formatter.setIndenting(printIndents); |
| 155 |
serializer.setOutputFormat(formatter); |
| 156 |
StringWriter writer = new StringWriter(); |
| 157 |
serializer.setOutputCharStream(writer); |
| 158 |
try { |
| 159 |
if (type == 9) { |
| 160 |
serializer.serialize((Document) xml); |
| 161 |
} else { |
| 162 |
serializer.serialize((Element) xml); |
| 163 |
} |
| 164 |
} catch (IOException error) { |
| 165 |
throw new RuntimeException(error.getMessage(), error); |
| 166 |
} |
| 167 |
return writer.toString(); |
| 168 |
} |
| 169 |
public String generateLogSetFilterDefEntry(List logSetFilterList){ |
| 170 |
if (logSetFilterList != null && (logSetFilterList.size() > 0)) { |
| 171 |
StringBuffer xmlString = new StringBuffer(); |
| 172 |
xmlString.append(" <"); |
| 173 |
xmlString.append(FILTER_TAG); |
| 174 |
xmlString.append("> "); |
| 175 |
FilterResourceFileHandler rtarget = FilterResourceFileHandler.instance(URI.createFileURI(EXPORT_URI)); |
| 176 |
rtarget.clear(); |
| 177 |
for (Iterator iter = logSetFilterList.iterator(); iter.hasNext();) { |
| 178 |
FilterQueries fq = (FilterQueries)iter.next(); |
| 179 |
if(fq != null){ |
| 180 |
rtarget.addFilter(fq.copy()); |
| 181 |
} |
| 182 |
} |
| 183 |
if (rtarget instanceof XMLResource) { |
| 184 |
((XMLResource) rtarget).setEncoding("UTF-8"); |
| 185 |
} |
| 186 |
ByteArrayOutputStream oStream = new ByteArrayOutputStream(); |
| 187 |
rtarget.save(oStream, RESOURCE_OPTIONS); |
| 188 |
byte[] b = oStream.toByteArray(); |
| 189 |
String filterStr = new String(b); |
| 190 |
xmlString.append(filterStr); |
| 191 |
xmlString.append(" </"); |
| 192 |
xmlString.append(FILTER_TAG); |
| 193 |
xmlString.append("> "); |
| 194 |
return xmlString.toString(); |
| 195 |
|
| 196 |
} |
| 197 |
return ""; |
| 198 |
} |
| 199 |
|
| 91 |
public void loadLogSets(){ |
200 |
public void loadLogSets(){ |
| 92 |
|
201 |
|
| 93 |
String prefXML = preferenceStore.getString(LOGSETS_KEY); |
202 |
String prefXML = preferenceStore.getString(LOGSETS_KEY); |