Author: vrubezhny
Date: 2009-08-19 08:12:55 -0400 (Wed, 19 Aug 2009)
New Revision: 17157
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.properties
trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AbstractXMLContentAssistProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/JstUIMessages.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/messages.properties
Log:
JBIDE-4769: The Warning resource marker is to be added to the project indicating that the
KB-nature and KB-builder are not specified on the project.
Issue is fixed.
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.properties
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.properties 2009-08-19 11:02:00 UTC
(rev 17156)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.properties 2009-08-19 12:12:55 UTC
(rev 17157)
@@ -8,4 +8,6 @@
occurrenceStructureProvidersExtensionPoint= Occurrence Structure Providers
defaultOccurrenceStructureProviderName= Default Occurrence Provider
-Bundle-Name.0 = Jsp Editor Plug-in
\ No newline at end of file
+Bundle-Name.0 = Jsp Editor Plug-in
+
+KBProblemName=KB Problem
\ No newline at end of file
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml 2009-08-19 11:02:00 UTC (rev
17156)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml 2009-08-19 12:12:55 UTC (rev
17157)
@@ -530,4 +530,11 @@
sequence="Ctrl+Shift+C">
</key>
</extension>
+
+ <extension id="kbproblemmarker" name="%KBProblemName"
point="org.eclipse.core.resources.markers">
+ <super type="org.eclipse.core.resources.problemmarker">
+ </super>
+ <persistent value="true">
+ </persistent>
+ </extension>
</plugin>
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AbstractXMLContentAssistProcessor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AbstractXMLContentAssistProcessor.java 2009-08-19
11:02:00 UTC (rev 17156)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AbstractXMLContentAssistProcessor.java 2009-08-19
12:12:55 UTC (rev 17157)
@@ -10,12 +10,18 @@
******************************************************************************/
package org.jboss.tools.jst.jsp.contentassist;
+import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.filebuffers.FileBuffers;
+import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.text.IDocument;
@@ -31,8 +37,6 @@
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
-import org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal;
import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
@@ -42,8 +46,6 @@
import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
import org.eclipse.wst.xml.ui.internal.contentassist.AbstractContentAssistProcessor;
import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
-import org.eclipse.wst.xml.ui.internal.contentassist.XMLRelevanceConstants;
-import org.eclipse.wst.xml.ui.internal.editor.CMImageUtil;
import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
import org.jboss.tools.common.el.core.model.ELInstance;
@@ -56,8 +58,12 @@
import org.jboss.tools.common.el.core.resolver.ELResolver;
import org.jboss.tools.common.el.core.resolver.ELResolverFactoryManager;
import org.jboss.tools.common.text.TextProposal;
+import org.jboss.tools.jst.jsp.JspEditorPlugin;
+import org.jboss.tools.jst.jsp.messages.JstUIMessages;
+import org.jboss.tools.jst.web.kb.IKbProject;
import org.jboss.tools.jst.web.kb.KbQuery;
import org.jboss.tools.jst.web.kb.KbQuery.Type;
+import org.jboss.tools.jst.web.kb.internal.KbBuilder;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -86,10 +92,117 @@
this.fDocument = (viewer == null ? null : viewer.getDocument());
this.fDocumentPosition = offset;
this.fContext = createContext();
+
+ checkKBBuilderInstalled();
return super.computeCompletionProposals(viewer, offset);
}
+ private void checkKBBuilderInstalled() {
+ ELContext context = getContext();
+ IFile resource = context == null ? null : context.getResource();
+ IProject project = resource == null ? null : resource.getProject();
+ if (project == null)
+ return; // Cannot check anything
+
+ boolean kbNatureFound = false;
+ boolean kbBuilderFound = false;
+ try {
+ kbNatureFound = (project.getNature(IKbProject.NATURE_ID) != null);
+
+ IProjectDescription description = project.getDescription();
+ ICommand command = null;
+ ICommand commands[] = description.getBuildSpec();
+ for (int i = 0; i < commands.length && command == null; ++i) {
+ if (commands[i].getBuilderName().equals(KbBuilder.BUILDER_ID)) {
+ kbBuilderFound = true;
+ break;
+ }
+ }
+ } catch (CoreException ex) {
+ JspEditorPlugin.getPluginLog().logError(ex);
+ }
+
+ if (kbNatureFound && kbBuilderFound) {
+ // Find existing KBNATURE problem marker and kill it if exists
+ IMarker[] markers = getOwnedMarkers(project);
+ if (markers != null && markers.length > 0) {
+ for (IMarker m : markers) {
+ try {
+ project.deleteMarkers(KB_PROBLEM_MARKER_TYPE, true, IResource.DEPTH_ONE);
+ } catch (CoreException ex) {
+ JspEditorPlugin.getPluginLog().logError(ex);
+ }
+ }
+ }
+ return;
+ }
+
+ // Find existing KBNATURE problem marker and install it if doesn't exist
+ IMarker[] markers = getOwnedMarkers(project);
+
+ if (markers == null || markers.length == 0) {
+ try {
+ IMarker m = createOrUpdateKbProblemMarker(null, project, !kbNatureFound,
!kbBuilderFound);
+ } catch (CoreException ex) {
+ JspEditorPlugin.getPluginLog().logError(ex);
+ }
+ } else {
+ for (IMarker m : markers) {
+ try {
+ m = createOrUpdateKbProblemMarker(m, project, !kbNatureFound, !kbBuilderFound);
+ } catch (CoreException ex) {
+ JspEditorPlugin.getPluginLog().logError(ex);
+ }
+ }
+ }
+ return;
+
+ }
+
+ public static final String KB_PROBLEM_MARKER_TYPE =
"org.jboss.tools.jst.jsp.kbproblemmarker"; //$NON-NLS-1$
+
+ private IMarker createOrUpdateKbProblemMarker(IMarker m, IResource r, boolean
kbNatureIsAbsent, boolean kbBuilderIsAbsent) throws CoreException {
+ ArrayList<String> args = new ArrayList<String>();
+ if (kbNatureIsAbsent) {
+ args.add(JstUIMessages.KBNATURE_NOT_FOUND);
+ }
+ if (kbBuilderIsAbsent) {
+ args.add(JstUIMessages.KBBUILDER_NOT_FOUND);
+ }
+ String message = MessageFormat.format(JstUIMessages.KBPROBLEM, args.toArray());
+ if (m == null) m = r.createMarker(KB_PROBLEM_MARKER_TYPE);
+ m.setAttribute(IMarker.MESSAGE, message);
+ m.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
+ m.setAttribute(IMarker.PRIORITY, IMarker.PRIORITY_NORMAL);
+ return m;
+ }
+
+ private IMarker[] getOwnedMarkers(IResource r) {
+ ArrayList<IMarker> l = null;
+ try {
+ IMarker[] ms = r.findMarkers(null, false, 1);
+ if(ms != null) {
+ for (int i = 0; i < ms.length; i++) {
+ if(ms[i] == null) continue;
+
+ String _type = ms[i].getType();
+ if(_type == null) continue;
+ if(!_type.equals(KB_PROBLEM_MARKER_TYPE)) continue;
+ if(!ms[i].isSubtypeOf(IMarker.PROBLEM)) continue;
+
+ if(l == null)
+ l = new ArrayList<IMarker>();
+
+ l.add(ms[i]);
+ }
+ }
+ } catch (CoreException e) {
+ //ignore
+ }
+ return (l == null) ? null : l.toArray(new IMarker[0]);
+ }
+
/**
* The reason of overriding is that the method returns wrong region in case of
incomplete tag (a tag with no '>'-closing char)
* In this case we have to return that previous incomplete tag instead of the current
tag)
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/JstUIMessages.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/JstUIMessages.java 2009-08-19
11:02:00 UTC (rev 17156)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/JstUIMessages.java 2009-08-19
12:12:55 UTC (rev 17157)
@@ -115,4 +115,7 @@
public static String JSPDialogContentProposalProvider_NewELExpression;
public static String PROPERTY_NAME_COLUMN;
public static String PROPERTY_VALUE_COLUMN;
+ public static String KBNATURE_NOT_FOUND;
+ public static String KBBUILDER_NOT_FOUND;
+ public static String KBPROBLEM;
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/messages.properties
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/messages.properties 2009-08-19
11:02:00 UTC (rev 17156)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/messages.properties 2009-08-19
12:12:55 UTC (rev 17157)
@@ -92,3 +92,7 @@
PROPERTY_NAME_COLUMN=Attribute
PROPERTY_VALUE_COLUMN=Value
+
+KBNATURE_NOT_FOUND=KB Nature is not installed.
+KBBUILDER_NOT_FOUND=KB Builder is not installed.
+KBPROBLEM=KB Problem: {0} {1} Use Quick Fix to allow JSF Content Assistant.
Show replies by date