You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-dev@jakarta.apache.org by pt...@apache.org on 2008/03/18 12:24:03 UTC

svn commit: r638324 - in /jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src: conf/ main/java/org/apache/cactus/eclipse/quickfix/ main/resources/org/apache/cactus/eclipse/runner/ui/

Author: ptahchiev
Date: Tue Mar 18 04:24:01 2008
New Revision: 638324

URL: http://svn.apache.org/viewvc?rev=638324&view=rev
Log:
Mesasges extracted to the Message file and also comments added.

Modified:
    jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/conf/plugin.properties
    jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/quickfix/AddCactusClassesCompletionProposal.java
    jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/quickfix/CactusQuickFixProcessor.java
    jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/resources/org/apache/cactus/eclipse/runner/ui/CactusMessages.properties

Modified: jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/conf/plugin.properties
URL: http://svn.apache.org/viewvc/jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/conf/plugin.properties?rev=638324&r1=638323&r2=638324&view=diff
==============================================================================
--- jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/conf/plugin.properties (original)
+++ jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/conf/plugin.properties Tue Mar 18 04:24:01 2008
@@ -20,4 +20,4 @@
 PopupMenu.cactify = Cactify
 
 # Tool tip that appears in 'Cactify' popup menu
-PopupMenu.cactifyTip = Adds Cactus elements (jar classpath, folders) to this project
\ No newline at end of file
+PopupMenu.cactifyTip = Adds Cactus elements (jar classpath, folders) to this project

Modified: jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/quickfix/AddCactusClassesCompletionProposal.java
URL: http://svn.apache.org/viewvc/jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/quickfix/AddCactusClassesCompletionProposal.java?rev=638324&r1=638323&r2=638324&view=diff
==============================================================================
--- jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/quickfix/AddCactusClassesCompletionProposal.java (original)
+++ jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/quickfix/AddCactusClassesCompletionProposal.java Tue Mar 18 04:24:01 2008
@@ -19,26 +19,42 @@
  */
 package org.apache.cactus.eclipse.quickfix;
 
-import java.net.MalformedURLException;
-import java.net.URL;
-
 import org.apache.cactus.eclipse.runner.ui.CactifyActionDelegate;
+import org.apache.cactus.eclipse.runner.ui.CactusMessages;
 import org.apache.cactus.eclipse.runner.ui.CactusPlugin;
 import org.eclipse.jdt.core.IJavaProject;
 import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
-import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.jface.text.IDocument;
 import org.eclipse.jface.text.contentassist.IContextInformation;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.graphics.Point;
 
+/**
+ * CompletionProposal for adding the Cactus classes to the Project's classpath.
+ * 
+ * @version $Id: CactusQuickFixProcessor.java 238816 2008-03-18 16:36:46Z ptahchiev $
+ */
 public class AddCactusClassesCompletionProposal  implements IJavaCompletionProposal  {
-
+    /**
+     * The name of the proposal
+     */
 	private final String name;
+    /**
+     * The buffer for the proposal.
+     */
 	private final String proposalInfo;
+    /**
+     * The relevance of the proposal;
+     */
 	private final int relevance;
+    /**
+     * The project in which we have the error.
+     */
 	private IJavaProject project;
   
+    /**
+     * Constructor.
+     */
 	public AddCactusClassesCompletionProposal(
 			String name,
 			int relevance, 
@@ -48,42 +64,64 @@
 		this.project = theWorkingProject;
 
 		final StringBuffer buffer = new StringBuffer(80);
-		buffer.append("Cactify this project ...<br>" +
-						"Add the Cactus jars to the classpath <br/>");
+		buffer.append(CactusMessages.getString("Cactus.quickFix.description"));
 		this.proposalInfo = buffer.toString();
 	}
-
+	
+    /**
+     * Get the relevance of the proposal.
+     */
 	public int getRelevance() {
 		return relevance;
 	}
-
+	
+    /**
+     * Apply the proposal. Actually we only call the CactifyActionDelegate
+     * and he does the whole 'magic'.
+     */
 	public void apply(IDocument document) {
 		CactifyActionDelegate cactifyDelegate = new CactifyActionDelegate();
 		cactifyDelegate.setSelectedProject(project);
 		//We add null and empty string because CactifyActionDelegate does not need these.
 		cactifyDelegate.run(null);
 	}
-
+	
+    /**
+     * Get the selection.
+     */
 	public Point getSelection(IDocument document) {
 		return null;
 	}
-
+	
+    /**
+     * Get the proposal info.
+     */
 	public String getAdditionalProposalInfo() {
 		return proposalInfo;
 	}
-
+	
+    /**
+     * Get the display string.
+     */
 	public String getDisplayString() {
 		return name;
 	}
-
+	
+    /**
+     * Get the icon image for the proposal.
+     */
 	public Image getImage() {
 		return CactusPlugin.getDefault().getImageRegistry().get(CactusPlugin.CACTUS_RUN_IMAGE);
 	}
-
+    /**
+     * Get the context information.
+     */
 	public IContextInformation getContextInformation() {
 		return null;
 	}
-  
+    /**
+     * Create a type-proposal.
+     */
 	public IJavaCompletionProposal createTypeProposal() {
 		return null;
 	}

Modified: jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/quickfix/CactusQuickFixProcessor.java
URL: http://svn.apache.org/viewvc/jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/quickfix/CactusQuickFixProcessor.java?rev=638324&r1=638323&r2=638324&view=diff
==============================================================================
--- jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/quickfix/CactusQuickFixProcessor.java (original)
+++ jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/quickfix/CactusQuickFixProcessor.java Tue Mar 18 04:24:01 2008
@@ -21,6 +21,8 @@
 
 import java.util.ArrayList;
 
+import org.apache.cactus.eclipse.runner.ui.CactusMessages;
+import org.apache.cactus.eclipse.runner.ui.CactusPlugin;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.jdt.core.ICompilationUnit;
 import org.eclipse.jdt.core.IJavaProject;
@@ -29,22 +31,37 @@
 import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
 import org.eclipse.jdt.ui.text.java.IProblemLocation;
 import org.eclipse.jdt.ui.text.java.IQuickFixProcessor;
-
+/**
+ * QuickFix processor to propose cactifying of the project.
+ * 
+ * @version $Id: CactusQuickFixProcessor.java 238816 2008-03-18 16:36:46Z ptahchiev $
+ */
 public class CactusQuickFixProcessor implements IQuickFixProcessor {
-
+    /**
+     * Constant for error code when the import is not found
+     */
 	private static final int IMPORT_NOT_FOUND = 268435846;
-	
+    /**
+     * Constant for error code when the classpath is not correct
+     */
 	private static final int IS_CLASSPATH_CORRECT = 16777218;
-	
-	private static final int UNDEFINED_TYPE = 16777218;
-
+    /**
+     * The default relevance constant.
+     */
+	private static final int DEFAULT_RELEVANCE = 90;
+    /**
+     * A method for getting only the corrections we need.
+     */
 	public boolean hasCorrections(final ICompilationUnit unit, final int problemId) {
-		if (problemId == 1000) {
+		if (problemId == IMPORT_NOT_FOUND || problemId == IS_CLASSPATH_CORRECT) {
 			return true;
 		}
 		return false;
 	}
 
+    /**
+     * A method for getting the corrections.
+     */
 	public IJavaCompletionProposal[] getCorrections(
 			final IInvocationContext context,
 			final IProblemLocation[] locations) throws CoreException {
@@ -63,12 +80,15 @@
 		}
 		return proposals;
 	}
-
+	
+    /**
+     * Process when corrections found.
+     */
 	private void process(
 			final IInvocationContext context,
 			final IProblemLocation problem,
 			final ArrayList proposals) {
-		if (problem.getProblemId() == 0) { // no proposals for none-problem locations
+		if (problem.getProblemId() == 0) { // no proposals
 			return;
 		}
 		
@@ -77,7 +97,7 @@
 	      source = context.getCompilationUnit().getSource();
 	    }
 	    catch (final JavaModelException e) {
-	      //ignore
+	      CactusPlugin.log(e.getMessage());
 	      return;
 	    }
 	    final int offset = problem.getOffset();
@@ -93,11 +113,15 @@
 	    						(problem.getProblemId() == IS_CLASSPATH_CORRECT && isCactusPrefixesMatch(substring));
 	    
 		if(cactusProblem) {
-			final String name = "Cactify this project...";
-			proposals.add(new AddCactusClassesCompletionProposal(name, 1, theWorkingProject));
+			final String name = CactusMessages.getString("Cactus.quickFix.name");
+			proposals.add(new AddCactusClassesCompletionProposal(name, DEFAULT_RELEVANCE, theWorkingProject));
 		}
 	}
 	
+    /**
+     * If the error prefix matches some of the Cactus 'keywords'
+     * then we have to add the Cactus correction.
+     */
 	private boolean isCactusPrefixesMatch(String prefix) {
 		return (prefix.startsWith("ServletTestCase") || 
 				prefix.startsWith("JspTestCase") || 

Modified: jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/resources/org/apache/cactus/eclipse/runner/ui/CactusMessages.properties
URL: http://svn.apache.org/viewvc/jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/resources/org/apache/cactus/eclipse/runner/ui/CactusMessages.properties?rev=638324&r1=638323&r2=638324&view=diff
==============================================================================
--- jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/resources/org/apache/cactus/eclipse/runner/ui/CactusMessages.properties (original)
+++ jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/resources/org/apache/cactus/eclipse/runner/ui/CactusMessages.properties Tue Mar 18 04:24:01 2008
@@ -53,3 +53,7 @@
 ContainersPreferencePage.jettyxml.init = src/webapp/jetty.xml
 
 Cactify.message.error = Could not set the classpath of the project
+
+#Here comes the Quick-Fix related messages
+Cactus.quickFix.name = Cactify this project...
+Cactus.quickFix.description = Cactify this project ...<br> Add the Cactus jars to the classpath 



---------------------------------------------------------------------
To unsubscribe, e-mail: cactus-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: cactus-dev-help@jakarta.apache.org