KickJava   Java API By Example, From Geeks To Geeks.

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


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 import java.util.Collection JavaDoc;
14 import java.util.Hashtable JavaDoc;
15 import java.util.Map JavaDoc;
16
17 import org.eclipse.core.runtime.Assert;
18 import org.eclipse.core.runtime.CoreException;
19
20 import org.eclipse.swt.graphics.Image;
21
22 import org.eclipse.jdt.internal.corext.fix.CleanUpConstants;
23 import org.eclipse.jdt.internal.corext.fix.IFix;
24 import org.eclipse.jdt.internal.corext.fix.PotentialProgrammingProblemsFix;
25
26 import org.eclipse.jdt.ui.text.java.IInvocationContext;
27 import org.eclipse.jdt.ui.text.java.IProblemLocation;
28
29 import org.eclipse.jdt.internal.ui.JavaPluginImages;
30 import org.eclipse.jdt.internal.ui.fix.PotentialProgrammingProblemsCleanUp;
31
32 /**
33  * Subprocessor for serial version quickfix proposals.
34  *
35  * @since 3.1
36  */

37 public final class SerialVersionSubProcessor {
38
39     /**
40      * Determines the serial version quickfix proposals.
41      *
42      * @param context
43      * the invocation context
44      * @param location
45      * the problem location
46      * @param proposals
47      * the proposal collection to extend
48      * @throws CoreException
49      */

50     public static final void getSerialVersionProposals(final IInvocationContext context, final IProblemLocation location, final Collection JavaDoc proposals) throws CoreException {
51
52         Assert.isNotNull(context);
53         Assert.isNotNull(location);
54         Assert.isNotNull(proposals);
55         
56         IFix[] fixes= PotentialProgrammingProblemsFix.createMissingSerialVersionFixes(context.getASTRoot(), location);
57         if (fixes != null) {
58             Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_ADD);
59             Map JavaDoc options= new Hashtable JavaDoc();
60             options.put(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID, CleanUpConstants.TRUE);
61             options.put(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_DEFAULT, CleanUpConstants.TRUE);
62             FixCorrectionProposal prop1= new SerialVersionDefaultProposal(fixes[0], new PotentialProgrammingProblemsCleanUp(options), 9, image, context);
63             proposals.add(prop1);
64             options= new Hashtable JavaDoc();
65             options.put(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID, CleanUpConstants.TRUE);
66             options.put(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_GENERATED, CleanUpConstants.TRUE);
67             FixCorrectionProposal prop2= new SerialVersionHashProposal(fixes[1], new PotentialProgrammingProblemsCleanUp(options), 9, image, context);
68             proposals.add(prop2);
69         }
70     }
71 }
72
Popular Tags