Author: dazarov
Date: 2011-11-28 21:13:46 -0500 (Mon, 28 Nov 2011)
New Revision: 36715
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/marker/DisableFaceletHTMLValidatorMarkerResolution.java
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/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/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-29
00:25:23 UTC (rev 36714)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/JsfUIMessages.java 2011-11-29
02:13:46 UTC (rev 36715)
@@ -48,8 +48,10 @@
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;
+ public static String DISABLE_FACELET_HTML_VALIDATOR_MARKER_RESOLUTION_TITLE;
+ public static String DISABLE_FACELET_HTML_VALIDATOR_MARKER_RESOLUTION_MESSAGE;
+ public static String
DISABLE_FACELET_HTML_VALIDATOR_MARKER_RESOLUTION_WORKSPACE_QUESTION;
+ public static String DISABLE_FACELET_HTML_VALIDATOR_MARKER_RESOLUTION_PROJECT_QUESTION;
static {
// initialize resource bundle
Modified:
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 2011-11-29
00:25:23 UTC (rev 36714)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/marker/DisableFaceletHTMLValidatorMarkerResolution.java 2011-11-29
02:13:46 UTC (rev 36715)
@@ -16,9 +16,13 @@
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IMarkerResolution2;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.wst.validation.IMutableValidator;
import org.eclipse.wst.validation.MutableProjectSettings;
import org.eclipse.wst.validation.MutableWorkspaceSettings;
@@ -33,54 +37,90 @@
IMarkerResolution2 {
private static final String MARKER_TYPE =
"org.eclipse.jst.jsf.facelet.ui.FaceletValidationMarker";
private IFile file;
- private boolean global;
+ private boolean forProject;
private String label;
- public DisableFaceletHTMLValidatorMarkerResolution(IFile file, boolean global){
+ public DisableFaceletHTMLValidatorMarkerResolution(IFile file, boolean forProject){
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());
- }
+ this.forProject = forProject;
+ label = JsfUIMessages.DISABLE_FACELET_HTML_VALIDATOR_MARKER_RESOLUTION_TITLE;
}
public String getLabel() {
return label;
}
+
+ public static Shell getShell() {
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (window == null) {
+ IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
+ if (windows.length > 0) {
+ return windows[0].getShell();
+ }
+ }
+ else {
+ return window.getShell();
+ }
+ return null;
+ }
public void run(IMarker marker) {
+ MessageDialog dialog = null;
+ if(forProject){
+ dialog = new MessageDialog(getShell(), label, null,
+ NLS.bind(JsfUIMessages.DISABLE_FACELET_HTML_VALIDATOR_MARKER_RESOLUTION_MESSAGE,
file.getName())+
+ NLS.bind(JsfUIMessages.DISABLE_FACELET_HTML_VALIDATOR_MARKER_RESOLUTION_PROJECT_QUESTION,
file.getProject().getName()),
+ MessageDialog.QUESTION_WITH_CANCEL,
+ new String[]{"Cancel", "Workspace",
file.getProject().getName()},
+ 0);
+ }else{
+ dialog = new MessageDialog(getShell(), label, null,
+ NLS.bind(JsfUIMessages.DISABLE_FACELET_HTML_VALIDATOR_MARKER_RESOLUTION_MESSAGE,
file.getName())+
+ JsfUIMessages.DISABLE_FACELET_HTML_VALIDATOR_MARKER_RESOLUTION_WORKSPACE_QUESTION,
+ MessageDialog.QUESTION_WITH_CANCEL,
+ new String[]{"Cancel", "Ok"},
+ 0);
+
+ }
+ int result = dialog.open();
+ if(result == 1){
+ disableOnWorkspace();
+ }else if(result == 2){
+ disableOnProject();
+ }
+ }
+
+ private void disableOnWorkspace(){
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();
+ try {
+ MutableWorkspaceSettings workspaceSettings =
ValidationFramework.getDefault().getWorkspaceSettings();
+ validators = workspaceSettings.getValidators();
if(disableValidator(validators,
DisableFaceletHTMLValidatorResolutionGenerator.VALIDATOR_ID)){
- ValidationFramework.getDefault().applyChanges(projectSettings, true);
+ ValidationFramework.getDefault().applyChanges(workspaceSettings, true);
try {
- file.getProject().deleteMarkers(MARKER_TYPE, true, IResource.DEPTH_INFINITE);
+ file.getProject().getParent().deleteMarkers(MARKER_TYPE, true,
IResource.DEPTH_INFINITE);
} catch (CoreException e) {
JsfUiPlugin.getPluginLog().logError(e);
}
}
+ } catch (InvocationTargetException e) {
+ JsfUiPlugin.getPluginLog().logError(e);
}
}
+ private void disableOnProject(){
+ MutableProjectSettings projectSettings =
ValidationFramework.getDefault().getProjectSettings(file.getProject());
+ IMutableValidator[] 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){
Modified:
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 2011-11-29
00:25:23 UTC (rev 36714)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/marker/DisableFaceletHTMLValidatorResolutionGenerator.java 2011-11-29
02:13:46 UTC (rev 36715)
@@ -11,7 +11,6 @@
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;
@@ -32,27 +31,27 @@
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)){
+ boolean forProject = false;
IFile file = (IFile)marker.getResource();
IMutableValidator[] validators;
-
+ MutableProjectSettings projectSettings =
ValidationFramework.getDefault().getProjectSettings(file.getProject());
+ validators = projectSettings.getValidators();
+ if(DisableFaceletHTMLValidatorMarkerResolution.findValidator(validators, VALIDATOR_ID)
!= null){
+ forProject = true;
+ }
try {
MutableWorkspaceSettings workspaceSettings =
ValidationFramework.getDefault().getWorkspaceSettings();
validators = workspaceSettings.getValidators();
if(DisableFaceletHTMLValidatorMarkerResolution.findValidator(validators,
VALIDATOR_ID) != null){
- resolutions.add(new
DisableFaceletHTMLValidatorMarkerResolution((IFile)marker.getResource(), true));
+ return new IMarkerResolution[] {new
DisableFaceletHTMLValidatorMarkerResolution((IFile)marker.getResource(), forProject)};
}
} 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[] {});
+ return new IMarkerResolution[] {};
}
private boolean isNeedToCreate(IMarker marker){
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-29
00:25:23 UTC (rev 36714)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/messages.properties 2011-11-29
02:13:46 UTC (rev 36715)
@@ -36,5 +36,7 @@
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
-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
+DISABLE_FACELET_HTML_VALIDATOR_MARKER_RESOLUTION_TITLE=Disable Facelet HTML Validator
+DISABLE_FACELET_HTML_VALIDATOR_MARKER_RESOLUTION_MESSAGE=The Facelet HTML Validator has a
problem validating file ''{0}''.\nThis might happen, because you are using
a new framework or framework specific features that the validator does not yet
support.\nIf that''s the case and you do not wish to see these markers and you are
ok with no other validation to occur the validator can be disabled.\n\n
+DISABLE_FACELET_HTML_VALIDATOR_MARKER_RESOLUTION_WORKSPACE_QUESTION=Do you wish to
disable the validator on the Workspace?
+DISABLE_FACELET_HTML_VALIDATOR_MARKER_RESOLUTION_PROJECT_QUESTION=Do you wish to disable
the validator on the Workspace or only on the project ''{1}''?
\ No newline at end of file