KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > text > correction > AddImportCorrectionProposal


1 /*******************************************************************************
2  * Copyright (c) 2000, 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.jdt.internal.ui.text.correction;
12
13
14
15 import org.eclipse.core.runtime.CoreException;
16
17 import org.eclipse.swt.graphics.Image;
18
19 import org.eclipse.jface.text.IDocument;
20
21 import org.eclipse.ui.IEditorPart;
22
23 import org.eclipse.jdt.core.ICompilationUnit;
24 import org.eclipse.jdt.core.dom.SimpleName;
25 import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
26
27 import org.eclipse.jdt.internal.corext.util.QualifiedTypeNameHistory;
28
29 public class AddImportCorrectionProposal extends ASTRewriteCorrectionProposal {
30     
31     private final String JavaDoc fTypeName;
32     private final String JavaDoc fQualifierName;
33
34     public AddImportCorrectionProposal(String JavaDoc name, ICompilationUnit cu, int relevance, Image image, String JavaDoc qualifierName, String JavaDoc typeName, SimpleName node) {
35         super(name, cu, ASTRewrite.create(node.getAST()), relevance, image);
36         fTypeName= typeName;
37         fQualifierName= qualifierName;
38     }
39     
40     public String JavaDoc getQualifiedTypeName() {
41         return fQualifierName + '.' + fTypeName;
42     }
43     
44     /* (non-Javadoc)
45      * @see org.eclipse.jdt.internal.ui.text.correction.ChangeCorrectionProposal#performChange(org.eclipse.ui.IEditorPart, org.eclipse.jface.text.IDocument)
46      */

47     protected void performChange(IEditorPart activeEditor, IDocument document) throws CoreException {
48         super.performChange(activeEditor, document);
49         rememberSelection();
50     }
51     
52
53     private void rememberSelection() throws CoreException {
54         QualifiedTypeNameHistory.remember(getQualifiedTypeName());
55     }
56
57 }
58
Popular Tags