KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > text > spelling > TaskTagDictionary


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 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
12 package org.eclipse.jdt.internal.ui.text.spelling;
13
14 import java.net.URL JavaDoc;
15 import java.util.StringTokenizer JavaDoc;
16
17 import org.eclipse.core.runtime.Plugin;
18 import org.eclipse.core.runtime.Preferences.IPropertyChangeListener;
19 import org.eclipse.core.runtime.Preferences.PropertyChangeEvent;
20
21 import org.eclipse.jdt.core.JavaCore;
22
23 import org.eclipse.jdt.internal.ui.text.spelling.engine.AbstractSpellDictionary;
24
25 /**
26  * Dictionary for task tags.
27  *
28  * @since 3.0
29  */

30 public class TaskTagDictionary extends AbstractSpellDictionary implements IPropertyChangeListener {
31
32     /*
33      * @see org.eclipse.jdt.internal.ui.text.spelling.engine.AbstractSpellDictionary#getName()
34      */

35     protected final URL JavaDoc getURL() {
36         return null;
37     }
38
39     /*
40      * @see org.eclipse.jdt.ui.text.spelling.engine.AbstractSpellDictionary#load(java.net.URL)
41      */

42     protected synchronized boolean load(final URL JavaDoc url) {
43
44         final Plugin plugin= JavaCore.getPlugin();
45         if (plugin != null) {
46
47             plugin.getPluginPreferences().addPropertyChangeListener(this);
48             return updateTaskTags();
49         }
50         return false;
51     }
52
53     /*
54      * @see org.eclipse.core.runtime.Preferences.IPropertyChangeListener#propertyChange(org.eclipse.core.runtime.Preferences.PropertyChangeEvent)
55      */

56     public void propertyChange(final PropertyChangeEvent event) {
57
58         if (JavaCore.COMPILER_TASK_TAGS.equals(event.getProperty()))
59             updateTaskTags();
60     }
61
62     /*
63      * @see org.eclipse.jdt.ui.text.spelling.engine.ISpellDictionary#unload()
64      */

65     public synchronized void unload() {
66
67         final Plugin plugin= JavaCore.getPlugin();
68         if (plugin != null)
69             plugin.getPluginPreferences().removePropertyChangeListener(this);
70
71         super.unload();
72     }
73
74     /**
75      * Handles the compiler task tags property change event.
76      *
77      * @return <code>true</code> if the task tags got updated
78      */

79     protected boolean updateTaskTags() {
80
81         final String JavaDoc tags= JavaCore.getOption(JavaCore.COMPILER_TASK_TAGS);
82         if (tags != null) {
83
84             unload();
85
86             final StringTokenizer JavaDoc tokenizer= new StringTokenizer JavaDoc(tags, ","); //$NON-NLS-1$
87
while (tokenizer.hasMoreTokens())
88                 hashWord(tokenizer.nextToken());
89
90             return true;
91         }
92         return false;
93     }
94     
95     /*
96      * @see org.eclipse.jdt.internal.ui.text.spelling.engine.AbstractSpellDictionary#stripNonLetters(java.lang.String)
97      * @since 3.3
98      */

99     protected String JavaDoc stripNonLetters(String JavaDoc word) {
100         return word;
101     }
102 }
103
Popular Tags