KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 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 package org.eclipse.jdt.internal.ui.text.spelling;
12
13 import org.eclipse.swt.graphics.Image;
14 import org.eclipse.swt.graphics.Point;
15
16 import org.eclipse.jface.preference.IPreferenceStore;
17
18 import org.eclipse.jface.text.IDocument;
19 import org.eclipse.jface.text.contentassist.IContextInformation;
20
21 import org.eclipse.ui.texteditor.spelling.SpellingService;
22
23 import org.eclipse.ui.editors.text.EditorsUI;
24
25 import org.eclipse.jdt.ui.text.java.IInvocationContext;
26 import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
27
28 import org.eclipse.jdt.internal.ui.JavaPluginImages;
29 import org.eclipse.jdt.internal.ui.JavaUIMessages;
30
31
32 /**
33  * Proposal to disable spell checking.
34  *
35  * @since 3.3
36  */

37 public class DisableSpellCheckingProposal implements IJavaCompletionProposal {
38     
39     /** The invocation context */
40     private IInvocationContext fContext;
41
42     /**
43      * Creates a new proposal.
44      *
45      * @param context the invocation context
46      */

47     public DisableSpellCheckingProposal(IInvocationContext context) {
48         fContext= context;
49     }
50
51     /*
52      * @see org.eclipse.jface.text.contentassist.ICompletionProposal#apply(org.eclipse.jface.text.IDocument)
53      */

54     public final void apply(final IDocument document) {
55         IPreferenceStore store= EditorsUI.getPreferenceStore();
56         store.setValue(SpellingService.PREFERENCE_SPELLING_ENABLED, false);
57     }
58
59     /*
60      * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getAdditionalProposalInfo()
61      */

62     public String JavaDoc getAdditionalProposalInfo() {
63         return JavaUIMessages.Spelling_disable_info;
64     }
65
66     /*
67      * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getContextInformation()
68      */

69     public final IContextInformation getContextInformation() {
70         return null;
71     }
72
73     /*
74      * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getDisplayString()
75      */

76     public String JavaDoc getDisplayString() {
77         return JavaUIMessages.Spelling_disable_label;
78     }
79
80     /*
81      * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getImage()
82      */

83     public Image getImage() {
84         return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_NLS_NEVER_TRANSLATE);
85     }
86     /*
87      * @see org.eclipse.jdt.ui.text.java.IJavaCompletionProposal#getRelevance()
88      */

89     public final int getRelevance() {
90         return Integer.MIN_VALUE + 1;
91     }
92
93     /*
94      * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getSelection(org.eclipse.jface.text.IDocument)
95      */

96     public final Point getSelection(final IDocument document) {
97         return new Point(fContext.getSelectionOffset(), fContext.getSelectionLength());
98     }
99 }
100
Popular Tags