1 /*******************************************************************************
2 * Copyright (c) 2010 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Patrick Tasse - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.filter
;
15 import java
.io
.FileNotFoundException
;
16 import java
.io
.IOException
;
18 import javax
.xml
.parsers
.ParserConfigurationException
;
20 import org
.eclipse
.linuxtools
.tmf
.core
.filter
.model
.ITmfFilterTreeNode
;
21 import org
.eclipse
.linuxtools
.tmf
.core
.filter
.model
.TmfFilterRootNode
;
22 import org
.eclipse
.linuxtools
.tmf
.core
.filter
.xml
.TmfFilterXMLParser
;
23 import org
.eclipse
.linuxtools
.tmf
.core
.filter
.xml
.TmfFilterXMLWriter
;
24 import org
.eclipse
.linuxtools
.tmf
.ui
.TmfUiPlugin
;
25 import org
.xml
.sax
.SAXException
;
27 public class FilterManager
{
29 private static final String SAVED_FILTERS_FILE_NAME
= "saved_filters.xml"; //$NON-NLS-1$
30 private static final String SAVED_FILTERS_PATH_NAME
=
31 TmfUiPlugin
.getDefault().getStateLocation().addTrailingSeparator().append(SAVED_FILTERS_FILE_NAME
).toString();
33 private static ITmfFilterTreeNode fRoot
= new TmfFilterRootNode();
36 fRoot
= new TmfFilterXMLParser(SAVED_FILTERS_PATH_NAME
).getTree();
37 } catch (FileNotFoundException e
) {
38 } catch (SAXException e
) {
40 } catch (IOException e
) {
45 public static ITmfFilterTreeNode
[] getSavedFilters() {
46 return fRoot
.clone().getChildren();
49 public static void setSavedFilters(ITmfFilterTreeNode
[] filters
) {
50 fRoot
= new TmfFilterRootNode();
51 for (ITmfFilterTreeNode filter
: filters
) {
52 fRoot
.addChild(filter
.clone());
55 TmfFilterXMLWriter writerXML
= new TmfFilterXMLWriter(fRoot
);
56 writerXML
.saveTree(SAVED_FILTERS_PATH_NAME
);
57 } catch (IOException e
) {
59 } catch (ParserConfigurationException e
) {