KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > aspectj > ajde > ui > internal > BrowserViewProperties


1
2 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
3  *
4  * This file is part of the IDE support for the AspectJ(tm)
5  * programming language; see http://aspectj.org
6  *
7  * The contents of this file are subject to the Mozilla Public License
8  * Version 1.1 (the "License"); you may not use this file except in
9  * compliance with the License. You may obtain a copy of the License at
10  * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
11  *
12  * Software distributed under the License is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14  * for the specific language governing rights and limitations under the
15  * License.
16  *
17  * The Original Code is AspectJ.
18  *
19  * The Initial Developer of the Original Code is Xerox Corporation. Portions
20  * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation.
21  * All Rights Reserved.
22  *
23  * Contributor(s):
24  */

25  
26  
27 package org.aspectj.ajde.ui.internal;
28
29 import java.util.*;
30 import java.io.*;
31 import org.aspectj.ajde.Ajde;
32 import org.aspectj.asm.associations.*;
33
34 /**
35  * @deprecated this class should be removed from the source tree
36  */

37 public class BrowserViewProperties {
38     public static final String JavaDoc FILE_NAME = "/.ajbrowser";
39     private final String JavaDoc VALUE_SEP = ";";
40     private Properties properties = new Properties();
41
42     public BrowserViewProperties() {
43         try {
44             if (new File(getPropertiesFilePath()).exists()) {
45                 properties.load(new FileInputStream(getPropertiesFilePath()));
46             }
47         } catch (IOException ioe) {
48             Ajde.getDefault().getErrorHandler().handleError("Could not read properties", ioe);
49         }
50     }
51     
52     public List getStructureViewOrdering() {
53         return getPropertyValues("structureView.ordering");
54     }
55
56     public void setStructureViewOrdering(List ordering) {
57         storeProperty("structureView.ordering", ordering);
58     }
59
60 // /**
61
// * Returns default values if no associations are saved.
62
// */
63
// public List getActiveAssociations() {
64
// List associations = getPropertyValues("structureView.associations");
65
// if (associations.size() == 0) {
66
// associations.add(Advice.METHOD_CALL_SITE_RELATION.toString());
67
// associations.add(Advice.METHOD_RELATION.toString());
68
// associations.add(Advice.CONSTRUCTOR_CALL_SITE_RELATION.toString());
69
// associations.add(Advice.CONSTRUCTOR_RELATION.toString());
70
// associations.add(Advice.FIELD_ACCESS_RELATION.toString());
71
// associations.add(Advice.INITIALIZER_RELATION.toString());
72
// associations.add(Advice.HANDLER_RELATION.toString());
73
// associations.add(Advice.INTRODUCTION_RELATION.toString());
74
// associations.add(Introduction.INTRODUCES_RELATION.toString());
75
// associations.add(Inheritance.IMPLEMENTS_RELATION.toString());
76
// associations.add(Inheritance.INHERITS_RELATION.toString());
77
// associations.add(Inheritance.INHERITS_MEMBERS_RELATION.toString());
78
// associations.add(Reference.USES_POINTCUT_RELATION.toString());
79
// associations.add(Reference.IMPORTS_RELATION.toString());
80
// }
81
// return associations;
82
// }
83

84     public void setActiveAssociations(List associations) {
85         storeProperty("structureView.associations", associations);
86     }
87
88     public void setActiveFilteredMemberKinds(List associations) {
89         storeProperty("structureView.filtering.memberKinds", associations);
90     }
91
92     public String JavaDoc getActiveHierarchy() {
93        return getProperty("structureView.hierarchy");
94     }
95
96     public void setActiveHierarchy(String JavaDoc hierarchy) {
97         storeProperty("structureView.hierarchy", hierarchy);
98     }
99
100     public List getActiveVisibility() {
101         return getPropertyValues("structureView.filtering.accessibility");
102     }
103
104     public void setActiveVisiblity(List visibility) {
105         storeProperty("structureView.filtering.accessibility", visibility);
106     }
107
108     public List getActiveModifiers() {
109         return getPropertyValues("structureView.filtering.modifiers");
110     }
111
112     public List getActiveFilteredMemberKinds() {
113         return getPropertyValues("structureView.filtering.memberKinds");
114     }
115
116     public String JavaDoc getActiveGranularity() {
117         return getProperty("structureView.granularity");
118     }
119
120     public void setActiveGranularity(String JavaDoc granularity) {
121     storeProperty("structureView.granularity", granularity);
122     }
123
124     public void setActiveModifiers(List modifiers) {
125         storeProperty("structureView.filtering.modifiers", modifiers);
126     }
127
128     protected String JavaDoc getProperty(String JavaDoc name) {
129         return properties.getProperty(name);
130     }
131
132     protected List getPropertyValues(String JavaDoc name) {
133         List values = new ArrayList();
134         String JavaDoc valuesString = properties.getProperty(name);
135         if (valuesString != null && !valuesString.trim().equals("")) {
136             StringTokenizer st = new StringTokenizer(valuesString, VALUE_SEP);
137             while (st.hasMoreTokens()) {
138                 values.add(st.nextToken());
139             }
140         }
141         return values;
142     }
143
144     private void storeProperty(String JavaDoc name, String JavaDoc value) {
145         properties.setProperty(name, value);
146         saveProperties();
147     }
148
149     private void storeProperty(String JavaDoc name, List values) {
150         String JavaDoc valuesString = "";
151         for (Iterator it = values.iterator(); it.hasNext(); ) {
152             valuesString += (String JavaDoc)it.next() + ';';
153         }
154         properties.setProperty(name, valuesString);
155         saveProperties();
156     }
157
158     private void saveProperties() {
159         try {
160             properties.store(new FileOutputStream(getPropertiesFilePath()), "AJDE Settings");
161         } catch (IOException ioe) {
162             Ajde.getDefault().getErrorHandler().handleError("Could not write properties", ioe);
163         }
164     }
165
166     protected String JavaDoc getPropertiesFilePath() {
167         String JavaDoc path = System.getProperty("user.home");
168         if (path == null) {
169             path = ".";
170         }
171         return path + FILE_NAME;
172     }
173 }
174
Popular Tags