Author: dazarov
Date: 2011-12-07 20:45:48 -0500 (Wed, 07 Dec 2011)
New Revision: 37086
Added:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/marker/AddSuppressWarningsMarkerResolution.java
Modified:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/CommonUIMessages.java
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/marker/ConfigureProblemSeverityResolutionGenerator.java
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/messages.properties
Log:
Add support for a @SuppressWarnings for CDI "No bean is eligible for injection"
warning
https://issues.jboss.org/browse/JBIDE-10187
Modified:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/CommonUIMessages.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/CommonUIMessages.java 2011-12-07
22:31:16 UTC (rev 37085)
+++
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/CommonUIMessages.java 2011-12-08
01:45:48 UTC (rev 37086)
@@ -75,6 +75,7 @@
public static String MANDATORYSTRING_VALIDATOR_MUST_PROVIDE_VALUE;
public static String CONFIGURE_PROBLEM_SEVERITY;
+ public static String ADD_SUPPRESS_WARNINGS;
static {
NLS.initializeMessages(BUNDLE_NAME, CommonUIMessages.class);
Added:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/marker/AddSuppressWarningsMarkerResolution.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/marker/AddSuppressWarningsMarkerResolution.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/marker/AddSuppressWarningsMarkerResolution.java 2011-12-08
01:45:48 UTC (rev 37086)
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.ui.marker;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.internal.ui.JavaPluginImages;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.IMarkerResolution2;
+import org.jboss.tools.common.ui.CommonUIMessages;
+import org.jboss.tools.common.ui.CommonUIPlugin;
+
+/**
+ * @author Daniel Azarov
+ */
+public class AddSuppressWarningsMarkerResolution implements
+ IMarkerResolution2 {
+ private IJavaElement element;
+ private String preferenceKey;
+
+ public AddSuppressWarningsMarkerResolution(IJavaElement element, String preferenceKey){
+ this.element = element;
+ this.preferenceKey = preferenceKey;
+ }
+
+ public String getLabel() {
+ return CommonUIMessages.CONFIGURE_PROBLEM_SEVERITY;
+ }
+
+ public void run(IMarker marker) {
+ }
+
+ public String getDescription() {
+ return NLS.bind(CommonUIMessages.CONFIGURE_PROBLEM_SEVERITY,
element.getElementName());
+ }
+
+ public Image getImage() {
+ String key = "DESC_OBJS_ANNOTATION";
+ ImageRegistry registry = CommonUIPlugin.getDefault().getImageRegistry();
+ Image image = registry.get(key);
+ if(image == null) {
+ image = JavaPluginImages.DESC_OBJS_ANNOTATION.createImage();
+ registry.put(key, image);
+ }
+ return image;
+ }
+
+}
Property changes on:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/marker/AddSuppressWarningsMarkerResolution.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/marker/ConfigureProblemSeverityResolutionGenerator.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/marker/ConfigureProblemSeverityResolutionGenerator.java 2011-12-07
22:31:16 UTC (rev 37085)
+++
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/marker/ConfigureProblemSeverityResolutionGenerator.java 2011-12-08
01:45:48 UTC (rev 37086)
@@ -10,8 +10,11 @@
******************************************************************************/
package org.jboss.tools.common.ui.marker;
+import java.util.ArrayList;
+
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.ui.IMarkerResolution;
import org.eclipse.ui.IMarkerResolutionGenerator2;
import org.jboss.tools.common.ui.CommonUIPlugin;
@@ -24,17 +27,26 @@
IMarkerResolutionGenerator2 {
public IMarkerResolution[] getResolutions(IMarker marker) {
+ ArrayList<IMarkerResolution> resolutions = new
ArrayList<IMarkerResolution>();
try {
String preferenceKey = getPreferenceKey(marker);
String preferencePageId = getPreferencePageId(marker);
if(preferenceKey != null && preferencePageId != null){
- return new IMarkerResolution[]{new
ConfigureProblemSeverityMarkerResolution(preferencePageId, preferenceKey)};
+ resolutions.add(new ConfigureProblemSeverityMarkerResolution(preferencePageId,
preferenceKey));
+ IJavaElement element = findJavaElement(marker);
+ if(element != null){
+ resolutions.add(new AddSuppressWarningsMarkerResolution(element, preferenceKey));
+ }
}
} catch (CoreException e) {
CommonUIPlugin.getDefault().logError(e);
}
- return new IMarkerResolution[] {};
+ return resolutions.toArray(new IMarkerResolution[] {});
}
+
+ private IJavaElement findJavaElement(IMarker marker){
+ return null;
+ }
public boolean hasResolutions(IMarker marker) {
try {
Modified:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/messages.properties
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/messages.properties 2011-12-07
22:31:16 UTC (rev 37085)
+++
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/messages.properties 2011-12-08
01:45:48 UTC (rev 37086)
@@ -33,4 +33,5 @@
URLSTRINGVALIDATOR_NOT_A_VALID_URL=\"{0}\" is not a valid url.
MANDATORYSTRING_VALIDATOR_MUST_PROVIDE_VALUE=You have to provide a {0}.
-CONFIGURE_PROBLEM_SEVERITY=Configure Problem Severity
\ No newline at end of file
+CONFIGURE_PROBLEM_SEVERITY=Configure Problem Severity
+ADD_SUPPRESS_WARNINGS=Add @SuppressWarnings to ''{0}''
\ No newline at end of file