Author: dazarov
Date: 2011-11-23 15:48:38 -0500 (Wed, 23 Nov 2011)
New Revision: 36585
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/marker/
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/marker/DisableFaceletHTMLValidatorMarkerResolution.java
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/marker/DisableFaceletHTMLValidatorResolutionGenerator.java
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/META-INF/MANIFEST.MF
trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.xml
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/JsfUIMessages.java
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/messages.properties
Log:
"Disable Facelet HTML Validator" quick fix
https://issues.jboss.org/browse/JBIDE-9366
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.ui/META-INF/MANIFEST.MF 2011-11-23 19:59:59 UTC
(rev 36584)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.ui/META-INF/MANIFEST.MF 2011-11-23 20:48:38 UTC
(rev 36585)
@@ -58,7 +58,8 @@
org.eclipse.jst.jsf.core;bundle-version="1.3.3",
org.eclipse.wst.common.project.facet.core;bundle-version="1.4.200",
org.eclipse.wst.xml.ui;bundle-version="1.1.200",
- org.eclipse.wst.common.project.facet.ui
+ org.eclipse.wst.common.project.facet.ui,
+ org.eclipse.wst.validation;bundle-version="1.2.300"
Bundle-Version: 3.3.0.qualifier
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.xml 2011-11-23 19:59:59 UTC (rev
36584)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.xml 2011-11-23 20:48:38 UTC (rev
36585)
@@ -465,5 +465,11 @@
locationURI="popup:org.eclipse.ui.popup.any?after=save">
</menuContribution>
</extension>
-
+
+ <extension point="org.eclipse.ui.ide.markerResolution">
+ <markerResolutionGenerator
+
class="org.jboss.tools.jsf.ui.marker.DisableFaceletHTMLValidatorResolutionGenerator"
+
markerType="org.eclipse.jst.jsf.facelet.ui.FaceletValidationMarker"/>
+ </extension>
+
</plugin>
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/JsfUIMessages.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/JsfUIMessages.java 2011-11-23
19:59:59 UTC (rev 36584)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/JsfUIMessages.java 2011-11-23
20:48:38 UTC (rev 36585)
@@ -48,6 +48,9 @@
public static String MESSAGES_FILE_RENAME_PARTICIPANT_UPDATE_MESSAGE_BUNDLE_REFERENCES;
public static String
MESSAGES_FILE_RENAME_PARTICIPANT_FILE_NAME_SHOULD_BE_WITH_THE_SAME_EXTENSION;
+ public static String DISABLE_FACELET_HTML_VALIDATOR_MARKER_RESOLUTION_FOR_WORKSPACE;
+ public static String DISABLE_FACELET_HTML_VALIDATOR_MARKER_RESOLUTION_FOR_PROJECT;
+
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, JsfUIMessages.class);
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/marker/DisableFaceletHTMLValidatorMarkerResolution.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/marker/DisableFaceletHTMLValidatorMarkerResolution.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/marker/DisableFaceletHTMLValidatorMarkerResolution.java 2011-11-23
20:48:38 UTC (rev 36585)
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * 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.jsf.ui.marker;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.IMarkerResolution2;
+import org.eclipse.wst.validation.IMutableValidator;
+import org.eclipse.wst.validation.MutableProjectSettings;
+import org.eclipse.wst.validation.MutableWorkspaceSettings;
+import org.eclipse.wst.validation.ValidationFramework;
+import org.jboss.tools.jsf.ui.JsfUIMessages;
+import org.jboss.tools.jsf.ui.JsfUiPlugin;
+
+/**
+ * @author Daniel Azarov
+ */
+public class DisableFaceletHTMLValidatorMarkerResolution implements
+ IMarkerResolution2 {
+ private static final String MARKER_TYPE =
"org.eclipse.jst.jsf.facelet.ui.FaceletValidationMarker";
+ private IFile file;
+ private boolean global;
+ private String label;
+
+ public DisableFaceletHTMLValidatorMarkerResolution(IFile file, boolean global){
+ this.file = file;
+ this.global = global;
+ if(global){
+ label = JsfUIMessages.DISABLE_FACELET_HTML_VALIDATOR_MARKER_RESOLUTION_FOR_WORKSPACE;
+ }else{
+ label =
NLS.bind(JsfUIMessages.DISABLE_FACELET_HTML_VALIDATOR_MARKER_RESOLUTION_FOR_PROJECT,
file.getProject().getName());
+ }
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void run(IMarker marker) {
+ IMutableValidator[] validators;
+ if(global){
+ try {
+ MutableWorkspaceSettings workspaceSettings =
ValidationFramework.getDefault().getWorkspaceSettings();
+ validators = workspaceSettings.getValidators();
+ if(disableValidator(validators,
DisableFaceletHTMLValidatorResolutionGenerator.VALIDATOR_ID)){
+ ValidationFramework.getDefault().applyChanges(workspaceSettings, true);
+ try {
+ file.getProject().getParent().deleteMarkers(MARKER_TYPE, true,
IResource.DEPTH_INFINITE);
+ } catch (CoreException e) {
+ JsfUiPlugin.getPluginLog().logError(e);
+ }
+ }
+ } catch (InvocationTargetException e) {
+ JsfUiPlugin.getPluginLog().logError(e);
+ }
+ }else{
+ MutableProjectSettings projectSettings =
ValidationFramework.getDefault().getProjectSettings(file.getProject());
+ validators = projectSettings.getValidators();
+ if(disableValidator(validators,
DisableFaceletHTMLValidatorResolutionGenerator.VALIDATOR_ID)){
+ ValidationFramework.getDefault().applyChanges(projectSettings, true);
+ try {
+ file.getProject().deleteMarkers(MARKER_TYPE, true, IResource.DEPTH_INFINITE);
+ } catch (CoreException e) {
+ JsfUiPlugin.getPluginLog().logError(e);
+ }
+ }
+ }
+ }
+
+ public static boolean disableValidator(IMutableValidator[] validators, String id){
+ IMutableValidator validator = findValidator(validators, id);
+ if(validator != null){
+ validator.setBuildValidation(false);
+ validator.setManualValidation(false);
+ return true;
+ }
+ return false;
+ }
+
+ public static IMutableValidator findValidator(IMutableValidator[] validators, String
id){
+ for(IMutableValidator validator : validators){
+ if(validator.getId().equals(id))
+ return validator;
+ }
+ return null;
+ }
+
+ public String getDescription() {
+ return label;
+ }
+
+ public Image getImage() {
+ return null;
+ }
+
+}
Property changes on:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/marker/DisableFaceletHTMLValidatorMarkerResolution.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/marker/DisableFaceletHTMLValidatorResolutionGenerator.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/marker/DisableFaceletHTMLValidatorResolutionGenerator.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/marker/DisableFaceletHTMLValidatorResolutionGenerator.java 2011-11-23
20:48:38 UTC (rev 36585)
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * 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.jsf.ui.marker;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.ui.IMarkerResolution;
+import org.eclipse.ui.IMarkerResolutionGenerator2;
+import org.eclipse.wst.validation.IMutableValidator;
+import org.eclipse.wst.validation.MutableProjectSettings;
+import org.eclipse.wst.validation.MutableWorkspaceSettings;
+import org.eclipse.wst.validation.ValidationFramework;
+import org.jboss.tools.jsf.ui.JsfUiPlugin;
+
+/**
+ * @author Daniel Azarov
+ */
+public class DisableFaceletHTMLValidatorResolutionGenerator implements
+ IMarkerResolutionGenerator2 {
+ private static final String ATTRIBUTE_NAME = "ValidationId";
+ public static final String VALIDATOR_ID =
"org.eclipse.jst.jsf.facelet.ui.FaceletHTMLValidator";
+
+ public IMarkerResolution[] getResolutions(IMarker marker) {
+ ArrayList<IMarkerResolution> resolutions = new
ArrayList<IMarkerResolution>();
+ if(isNeedToCreate(marker)){
+ IFile file = (IFile)marker.getResource();
+ IMutableValidator[] validators;
+
+ try {
+ MutableWorkspaceSettings workspaceSettings =
ValidationFramework.getDefault().getWorkspaceSettings();
+ validators = workspaceSettings.getValidators();
+ if(DisableFaceletHTMLValidatorMarkerResolution.findValidator(validators,
VALIDATOR_ID) != null){
+ resolutions.add(new
DisableFaceletHTMLValidatorMarkerResolution((IFile)marker.getResource(), true));
+ }
+ } catch (InvocationTargetException e) {
+ JsfUiPlugin.getPluginLog().logError(e);
+ }
+ MutableProjectSettings projectSettings =
ValidationFramework.getDefault().getProjectSettings(file.getProject());
+ validators = projectSettings.getValidators();
+ if(DisableFaceletHTMLValidatorMarkerResolution.findValidator(validators, VALIDATOR_ID)
!= null){
+ resolutions.add(new
DisableFaceletHTMLValidatorMarkerResolution((IFile)marker.getResource(), false));
+ }
+ }
+ return resolutions.toArray(new IMarkerResolution[] {});
+ }
+
+ private boolean isNeedToCreate(IMarker marker){
+ String attribute = marker.getAttribute(ATTRIBUTE_NAME, "");
+ if(attribute.equals(VALIDATOR_ID) && marker.getResource() instanceof IFile){
+ return true;
+ }
+ return false;
+ }
+
+ public boolean hasResolutions(IMarker marker) {
+ return isNeedToCreate(marker);
+ }
+
+}
Property changes on:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/marker/DisableFaceletHTMLValidatorResolutionGenerator.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/messages.properties
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/messages.properties 2011-11-23
19:59:59 UTC (rev 36584)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/messages.properties 2011-11-23
20:48:38 UTC (rev 36585)
@@ -35,4 +35,6 @@
MISSING_NATURES_INFO_MESSAGE_TITLE=Missing Natures
SKIP_BUTTON_LABEL=Skip
MESSAGES_FILE_RENAME_PARTICIPANT_UPDATE_MESSAGE_BUNDLE_REFERENCES=Update Message Bundle
References
-MESSAGES_FILE_RENAME_PARTICIPANT_FILE_NAME_SHOULD_BE_WITH_THE_SAME_EXTENSION=New file
name should be with the same extension
\ No newline at end of file
+MESSAGES_FILE_RENAME_PARTICIPANT_FILE_NAME_SHOULD_BE_WITH_THE_SAME_EXTENSION=New file
name should be with the same extension
+DISABLE_FACELET_HTML_VALIDATOR_MARKER_RESOLUTION_FOR_WORKSPACE=Disable Facelet HTML
Validator for Workspace
+DISABLE_FACELET_HTML_VALIDATOR_MARKER_RESOLUTION_FOR_PROJECT=Disable Facelet HTML
Validator for ''{0}'' project
\ No newline at end of file