KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > help > ui > internal > views > HistoryScopeSet


1 /*******************************************************************************
2  * Copyright (c) 2005, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.help.ui.internal.views;
12
13 import org.eclipse.jface.preference.IPreferenceStore;
14
15 public class HistoryScopeSet extends ScopeSet {
16     private static final String JavaDoc KEY_EXPRESSION = "expression"; //$NON-NLS-1$
17
public static final String JavaDoc EXT = ".hist"; //$NON-NLS-1$
18

19     public HistoryScopeSet(String JavaDoc expression) {
20         this(expression, expression);
21     }
22
23     public HistoryScopeSet(String JavaDoc name, String JavaDoc expression) {
24         super(name);
25         if (expression!=null)
26             setExpression(expression);
27     }
28
29     public HistoryScopeSet(HistoryScopeSet set) {
30         super(set);
31         setExpression(set.getExpression());
32     }
33     
34     public void copyFrom(ScopeSet set) {
35         String JavaDoc expression = getExpression();
36         super.copyFrom(set);
37         setExpression(expression);
38     }
39
40     public String JavaDoc getExpression() {
41         IPreferenceStore store = getPreferenceStore();
42         return store.getString(KEY_EXPRESSION);
43     }
44     
45     public boolean isImplicit() {
46         return true;
47     }
48     
49     protected String JavaDoc getExtension() {
50         return EXT;
51     }
52
53     protected String JavaDoc encodeFileName(String JavaDoc name) {
54         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
55         for (int i = 0; i < name.length(); i++) {
56             char c = name.charAt(i);
57             switch (c) {
58             case '\"':
59                 buf.append("QUOTE"); //$NON-NLS-1$
60
break;
61             case ' ':
62                 buf.append("_"); //$NON-NLS-1$
63
break;
64             case '?':
65                 buf.append("QUESTION"); //$NON-NLS-1$
66
break;
67             case '*':
68                 buf.append("STAR"); //$NON-NLS-1$
69
break;
70             default:
71                 buf.append(c);
72                 break;
73             }
74         }
75         return buf.toString();
76     }
77
78     public void setExpression(String JavaDoc expression) {
79         IPreferenceStore store = getPreferenceStore();
80         store.setValue(KEY_EXPRESSION, expression);
81     }
82 }
83
Popular Tags