2011/08/05 - Jakarta Cactus has been retired.

For more information, please explore the Attic.

View Javadoc

1   /* 
2    * ========================================================================
3    * 
4    * Licensed to the Apache Software Foundation (ASF) under one or more
5    * contributor license agreements.  See the NOTICE file distributed with
6    * this work for additional information regarding copyright ownership.
7    * The ASF licenses this file to You under the Apache License, Version 2.0
8    * (the "License"); you may not use this file except in compliance with
9    * the License.  You may obtain a copy of the License at
10   * 
11   *   http://www.apache.org/licenses/LICENSE-2.0
12   * 
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   * 
19   * ========================================================================
20   */
21  package org.apache.cactus.eclipse.quickfix;
22  
23  import org.apache.cactus.eclipse.runner.ui.CactifyActionDelegate;
24  import org.apache.cactus.eclipse.runner.ui.CactusMessages;
25  import org.apache.cactus.eclipse.runner.ui.CactusPlugin;
26  import org.eclipse.jdt.core.IJavaProject;
27  import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
28  import org.eclipse.jface.text.IDocument;
29  import org.eclipse.jface.text.contentassist.IContextInformation;
30  import org.eclipse.swt.graphics.Image;
31  import org.eclipse.swt.graphics.Point;
32  
33  /**
34   * CompletionProposal for adding the Cactus classes to the Project's classpath.
35   * 
36   * @version $Id: CactusQuickFixProcessor.java 238816 2008-03-18 16:36:46Z ptahchiev $
37   */
38  public class AddCactusClassesCompletionProposal  implements IJavaCompletionProposal  {
39      /**
40       * The name of the proposal
41       */
42  	private final String name;
43      /**
44       * The buffer for the proposal.
45       */
46  	private final String proposalInfo;
47      /**
48       * The relevance of the proposal;
49       */
50  	private final int relevance;
51      /**
52       * The project in which we have the error.
53       */
54  	private IJavaProject project;
55    
56      /**
57       * Constructor.
58       */
59  	public AddCactusClassesCompletionProposal(
60  			String name,
61  			int relevance, 
62  			IJavaProject theWorkingProject) {
63  		this.name = name;
64  		this.relevance = relevance;
65  		this.project = theWorkingProject;
66  
67  		final StringBuffer buffer = new StringBuffer(80);
68  		buffer.append(CactusMessages.getString("Cactus.quickFix.description"));
69  		this.proposalInfo = buffer.toString();
70  	}
71  	
72      /**
73       * Get the relevance of the proposal.
74       */
75  	public int getRelevance() {
76  		return relevance;
77  	}
78  	
79      /**
80       * Apply the proposal. Actually we only call the CactifyActionDelegate
81       * and he does the whole 'magic'.
82       */
83  	public void apply(IDocument document) {
84  		CactifyActionDelegate cactifyDelegate = new CactifyActionDelegate();
85  		cactifyDelegate.setSelectedProject(project);
86  		//We add null and empty string because CactifyActionDelegate does not need these.
87  		cactifyDelegate.run(null);
88  	}
89  	
90      /**
91       * Get the selection.
92       */
93  	public Point getSelection(IDocument document) {
94  		return null;
95  	}
96  	
97      /**
98       * Get the proposal info.
99       */
100 	public String getAdditionalProposalInfo() {
101 		return proposalInfo;
102 	}
103 	
104     /**
105      * Get the display string.
106      */
107 	public String getDisplayString() {
108 		return name;
109 	}
110 	
111     /**
112      * Get the icon image for the proposal.
113      */
114 	public Image getImage() {
115 		return CactusPlugin.getDefault().getImageRegistry().get(CactusPlugin.CACTUS_RUN_IMAGE);
116 	}
117     /**
118      * Get the context information.
119      */
120 	public IContextInformation getContextInformation() {
121 		return null;
122 	}
123     /**
124      * Create a type-proposal.
125      */
126 	public IJavaCompletionProposal createTypeProposal() {
127 		return null;
128 	}
129 }
130