Author: dazarov
Date: 2012-03-21 14:43:57 -0400 (Wed, 21 Mar 2012)
New Revision: 39732
Added:
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
Removed:
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
Modified:
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
Log:
Make Quick fix for problem markers "Unknown tag" work on temporary WTP
annotations
https://issues.jboss.org/browse/JBIDE-10958
Modified:
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
===================================================================
---
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches... 2012-03-21
18:07:19 UTC (rev 39731)
+++
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches... 2012-03-21
18:43:57 UTC (rev 39732)
@@ -10,6 +10,7 @@
org.jboss.tools.common.text.xml.contentassist,
org.jboss.tools.common.text.xml.info,
org.jboss.tools.common.text.xml.internal.ui.preferencies,
+ org.jboss.tools.common.text.xml.quickfix,
org.jboss.tools.common.text.xml.ui,
org.jboss.tools.common.text.xml.ui.xpl,
org.jboss.tools.common.text.xml.xpl,
Modified:
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
===================================================================
---
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches... 2012-03-21
18:07:19 UTC (rev 39731)
+++
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches... 2012-03-21
18:43:57 UTC (rev 39732)
@@ -3,6 +3,7 @@
<plugin>
<extension-point id="contentAssistProcessor" name="Content Assist
Processor Extension Point Extension"
schema="schema/contentAssistProcessor.exsd"/>
+ <extension-point id="quickFix" name="Quick Fix Generator"
schema="schema/quickFix.exsd"/>
<!--
<extension-point id="foldingStructureProviders"
name="%foldingStructureProvidersExtensionPoint"
schema="schema/foldingStructureProviders.exsd"/>
Added:
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
===================================================================
---
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
(rev 0)
+++
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches... 2012-03-21
18:43:57 UTC (rev 39732)
@@ -0,0 +1,129 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.jboss.tools.common.text.xml"
xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.jboss.tools.common.text.xml"
id="quickFix" name="Quick Fix Generator"/>
+ </appInfo>
+ <documentation>
+ This extenion point is used to send information about Quick fix generators to
QuickFixManager.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="quick-fix-generator" minOccurs="1"
maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="quick-fix-generator">
+ <complexType>
+ <attribute name="id" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="identifier"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="generator-class" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java"
basedOn=":org.jboss.tools.common.text.xml.quickfix.IQuickFixGenerator"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ JBoss Tools 3.4
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ <extension
point="org.jboss.tools.common.text.xml.quickFix">
+ <quick-fix-generator id="seam.searcher"
generator-class="org.jboss.tools.jst.web.ui.action.JSPProblemMarkerResolutionGenerator"
/>
+</extension>
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiinfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ Copyright (c) 2009 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
+ </documentation>
+ </annotation>
+
+</schema>
Property changes on:
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
===================================================================
---
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches... 2012-03-21
18:07:19 UTC (rev 39731)
+++
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches... 2012-03-21
18:43:57 UTC (rev 39732)
@@ -22,7 +22,8 @@
import org.eclipse.jface.text.source.IAnnotationModel;
import org.eclipse.ui.texteditor.SimpleMarkerAnnotation;
import org.eclipse.wst.sse.ui.internal.reconcile.TemporaryAnnotation;
-import org.jboss.tools.common.text.xml.MarkerAnnotationInfo.AnnotationInfo;
+import org.jboss.tools.common.text.xml.quickfix.MarkerAnnotationInfo;
+import org.jboss.tools.common.text.xml.quickfix.MarkerAnnotationInfo.AnnotationInfo;
public class BaseQuickAssistProcessor implements IQuickAssistProcessor {
Deleted:
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
===================================================================
---
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches... 2012-03-21
18:07:19 UTC (rev 39731)
+++
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches... 2012-03-21
18:43:57 UTC (rev 39732)
@@ -1,134 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Exadel, Inc. and 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:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.common.text.xml;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.quickassist.IQuickAssistInvocationContext;
-import org.eclipse.jface.text.quickassist.IQuickAssistProcessor;
-import org.eclipse.jface.text.quickassist.IQuickFixableAnnotation;
-import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.ui.IMarkerResolution;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.ui.texteditor.SimpleMarkerAnnotation;
-import org.eclipse.wst.sse.ui.StructuredTextInvocationContext;
-import org.eclipse.wst.sse.ui.internal.correction.QuickFixRegistry;
-import org.eclipse.wst.sse.ui.internal.reconcile.TemporaryAnnotation;
-
-public class MarkerAnnotationInfo {
- public final List<AnnotationInfo> infos;
- public final ISourceViewer viewer;
-
- public MarkerAnnotationInfo(List<AnnotationInfo> infos, ISourceViewer textViewer)
{
- this.infos = infos;
- this.viewer = textViewer;
- }
-
- public List<ICompletionProposal> getCompletionProposals(AnnotationInfo info) {
-
- if(info.isTop())
- return getMarkerProposals(info);
- else
- return getProposals(info);
-
- }
-
- public List<ICompletionProposal> getMarkerProposals(AnnotationInfo info) {
- SimpleMarkerAnnotation annotation = (SimpleMarkerAnnotation)info.annotation;
-
- ArrayList<ICompletionProposal> proposals = new
ArrayList<ICompletionProposal>();
-
- IMarker marker = annotation.getMarker();
- IMarkerResolution[] resolutions = IDE.getMarkerHelpRegistry().getResolutions(marker);
- for (IMarkerResolution resolution : resolutions) {
- proposals.add(new QuickFixProposal(resolution, marker));
- }
-
- return proposals;
- }
-
- public List<ICompletionProposal> getProposals(AnnotationInfo info) {
- TemporaryAnnotation annotation = (TemporaryAnnotation)info.annotation;
-
- List<ICompletionProposal> allProposals = new
ArrayList<ICompletionProposal>();
- List<IQuickAssistProcessor> processors = new
ArrayList<IQuickAssistProcessor>();
- if (canFix(annotation)) {
- Object o = annotation.getAdditionalFixInfo();
- if (o instanceof IQuickAssistProcessor) {
- processors.add((IQuickAssistProcessor)o);
- }
-
- // get all relevant quick fixes for this annotation
- QuickFixRegistry registry = QuickFixRegistry.getInstance();
- processors.addAll(Arrays.asList(registry.getQuickFixProcessors(annotation)));
-
- // set up context
- Map attributes = null;
- attributes = annotation.getAttributes();
- StructuredTextInvocationContext sseContext = new
StructuredTextInvocationContext(viewer, info.position.getOffset(),
info.position.getLength(), attributes);
-
- // call each processor
- for (int i = 0; i < processors.size(); ++i) {
- List<ICompletionProposal> proposals = new
ArrayList<ICompletionProposal>();
- collectProposals((IQuickAssistProcessor) processors.get(i), annotation, sseContext,
proposals);
-
- if (proposals.size() > 0) {
- allProposals.addAll(proposals);
- }
- }
-
- }
-
- return allProposals;
- }
-
- private void collectProposals(IQuickAssistProcessor processor, Annotation annotation,
IQuickAssistInvocationContext invocationContext, List<ICompletionProposal>
proposalsList) {
- ICompletionProposal[] proposals =
processor.computeQuickAssistProposals(invocationContext);
- if (proposals != null && proposals.length > 0) {
- proposalsList.addAll(Arrays.asList(proposals));
- }
- }
-
- public boolean canFix(Annotation annotation) {
- if (annotation instanceof IQuickFixableAnnotation) {
- if (((IQuickFixableAnnotation) annotation).isQuickFixableStateSet()) {
- return ((IQuickFixableAnnotation) annotation).isQuickFixable();
- }
- }
- return false;
- }
-
- public static class AnnotationInfo {
- public Annotation annotation;
- public Position position;
-
- public AnnotationInfo(Annotation annotation, Position position){
- this.annotation = annotation;
- this.position = position;
- }
-
- public boolean isTop(){
- return annotation instanceof SimpleMarkerAnnotation;
- }
- }
-
- @Override
- public String toString() {
- return null;
- }
-}
\ No newline at end of file
Deleted:
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
===================================================================
---
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches... 2012-03-21
18:07:19 UTC (rev 39731)
+++
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches... 2012-03-21
18:43:57 UTC (rev 39732)
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Exadel, Inc. and 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:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.common.text.xml;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.contentassist.IContextInformation;
-import org.eclipse.ui.IMarkerResolution;
-import org.eclipse.ui.IMarkerResolution2;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-
-public class QuickFixProposal implements ICompletionProposal{
- private IMarkerResolution resolution;
- private IMarker marker;
-
- public QuickFixProposal(IMarkerResolution resolution, IMarker marker){
- this.resolution = resolution;
- this.marker = marker;
- }
-
- public void apply(IDocument document) {
- resolution.run(marker);
- }
-
- public Point getSelection(IDocument document) {
- return null;
- }
-
- public String getAdditionalProposalInfo() {
- if (resolution instanceof IMarkerResolution2)
- return ((IMarkerResolution2) resolution).getDescription();
-
- return (String)marker.getAttribute(IMarker.MESSAGE, ""); //$NON-NLS-1$
- }
-
- public String getDisplayString() {
- return resolution.getLabel();
- }
-
- public Image getImage() {
- if (resolution instanceof IMarkerResolution2)
- return ((IMarkerResolution2)resolution).getImage();
- return null;
- }
-
- public IContextInformation getContextInformation() {
- return null;
- }
-}
Added:
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
===================================================================
---
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
(rev 0)
+++
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches... 2012-03-21
18:43:57 UTC (rev 39732)
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.text.xml.quickfix;
+
+import java.util.List;
+
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.source.Annotation;
+
+public interface IQuickFixGenerator {
+
+ /**
+ * Returns whether there are any proposals for the given annotation.
+ *
+ * @param annotation the annotation
+ * @return <code>true</code> if there are proposals for the given
annotation,
+ * <code>false</code> if not
+ */
+ public boolean hasProposals(Annotation annotation);
+
+ /**
+ * Returns list of proposals for the given annotation (may
+ * be empty).
+ *
+ * @param annotation the annotation
+ * @return list of proposals for the given annotation
+ */
+ public List<ICompletionProposal> getProposals(Annotation annotation);
+}
Property changes on:
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
===================================================================
---
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
(rev 0)
+++
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches... 2012-03-21
18:43:57 UTC (rev 39732)
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Exadel, Inc. and 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.text.xml.quickfix;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.quickassist.IQuickAssistInvocationContext;
+import org.eclipse.jface.text.quickassist.IQuickAssistProcessor;
+import org.eclipse.jface.text.quickassist.IQuickFixableAnnotation;
+import org.eclipse.jface.text.source.Annotation;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.ui.IMarkerResolution;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.texteditor.SimpleMarkerAnnotation;
+import org.eclipse.wst.sse.ui.StructuredTextInvocationContext;
+import org.eclipse.wst.sse.ui.internal.correction.QuickFixRegistry;
+import org.eclipse.wst.sse.ui.internal.reconcile.TemporaryAnnotation;
+
+public class MarkerAnnotationInfo {
+ public final List<AnnotationInfo> infos;
+ public final ISourceViewer viewer;
+
+ public MarkerAnnotationInfo(List<AnnotationInfo> infos, ISourceViewer textViewer)
{
+ this.infos = infos;
+ this.viewer = textViewer;
+ }
+
+ public List<ICompletionProposal> getCompletionProposals(AnnotationInfo info) {
+
+ if(info.isTop())
+ return getMarkerProposals(info);
+ else
+ return getProposals(info);
+
+ }
+
+ public List<ICompletionProposal> getMarkerProposals(AnnotationInfo info) {
+ SimpleMarkerAnnotation annotation = (SimpleMarkerAnnotation)info.annotation;
+
+ ArrayList<ICompletionProposal> proposals = new
ArrayList<ICompletionProposal>();
+
+ IMarker marker = annotation.getMarker();
+ IMarkerResolution[] resolutions = IDE.getMarkerHelpRegistry().getResolutions(marker);
+ for (IMarkerResolution resolution : resolutions) {
+ proposals.add(new QuickFixProposal(resolution, marker));
+ }
+
+ return proposals;
+ }
+
+ public List<ICompletionProposal> getProposals(AnnotationInfo info) {
+ TemporaryAnnotation annotation = (TemporaryAnnotation)info.annotation;
+
+ List<ICompletionProposal> allProposals = new
ArrayList<ICompletionProposal>();
+ List<IQuickAssistProcessor> processors = new
ArrayList<IQuickAssistProcessor>();
+ //if (canFix(annotation)) {
+ Object o = annotation.getAdditionalFixInfo();
+ if (o instanceof IQuickAssistProcessor) {
+ processors.add((IQuickAssistProcessor)o);
+ }
+
+ // get all relevant quick fixes for this annotation
+ if(QuickFixManager.getInstance().hasProposals(annotation)){
+ List<ICompletionProposal> proposals =
QuickFixManager.getInstance().getProposals(annotation);
+ allProposals.addAll(proposals);
+ }
+
+ QuickFixRegistry registry = QuickFixRegistry.getInstance();
+ processors.addAll(Arrays.asList(registry.getQuickFixProcessors(annotation)));
+
+ // set up context
+ Map attributes = null;
+ attributes = annotation.getAttributes();
+ StructuredTextInvocationContext sseContext = new
StructuredTextInvocationContext(viewer, info.position.getOffset(),
info.position.getLength(), attributes);
+
+ // call each processor
+ for (int i = 0; i < processors.size(); ++i) {
+ List<ICompletionProposal> proposals = new
ArrayList<ICompletionProposal>();
+ collectProposals((IQuickAssistProcessor) processors.get(i), annotation, sseContext,
proposals);
+
+ if (proposals.size() > 0) {
+ allProposals.addAll(proposals);
+ }
+ }
+
+ //}
+
+ return allProposals;
+ }
+
+ private void collectProposals(IQuickAssistProcessor processor, Annotation annotation,
IQuickAssistInvocationContext invocationContext, List<ICompletionProposal>
proposalsList) {
+ ICompletionProposal[] proposals =
processor.computeQuickAssistProposals(invocationContext);
+ if (proposals != null && proposals.length > 0) {
+ proposalsList.addAll(Arrays.asList(proposals));
+ }
+ }
+
+ public boolean canFix(Annotation annotation) {
+ if (annotation instanceof IQuickFixableAnnotation) {
+ if (((IQuickFixableAnnotation) annotation).isQuickFixableStateSet()) {
+ return ((IQuickFixableAnnotation) annotation).isQuickFixable();
+ }
+ }
+ return false;
+ }
+
+ public static class AnnotationInfo {
+ public Annotation annotation;
+ public Position position;
+
+ public AnnotationInfo(Annotation annotation, Position position){
+ this.annotation = annotation;
+ this.position = position;
+ }
+
+ public boolean isTop(){
+ return annotation instanceof SimpleMarkerAnnotation;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return null;
+ }
+}
\ No newline at end of file
Property changes on:
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
===================================================================
---
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
(rev 0)
+++
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches... 2012-03-21
18:43:57 UTC (rev 39732)
@@ -0,0 +1,47 @@
+package org.jboss.tools.common.text.xml.quickfix;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.Platform;
+import org.jboss.tools.common.text.xml.XmlEditorPlugin;
+
+public class QuickFixExtension {
+ public static String EXTENSION_POINT =
"org.jboss.tools.common.text.xml.quickFix"; //$NON-NLS-1$
+
+ String id;
+ IQuickFixGenerator generator;
+
+ public QuickFixExtension() {}
+
+ public String getId() {
+ return id;
+ }
+
+ public IQuickFixGenerator getQuickFixGenerator() {
+ return generator;
+ }
+
+ static QuickFixExtension[] INSTANCES;
+
+ public static QuickFixExtension[] getInstances() {
+ if(INSTANCES != null) return INSTANCES;
+ List<QuickFixExtension> list = new ArrayList<QuickFixExtension>();
+ IExtensionPoint point =
Platform.getExtensionRegistry().getExtensionPoint(EXTENSION_POINT);
+ IConfigurationElement[] es = point.getConfigurationElements();
+ for (IConfigurationElement e: es) {
+ QuickFixExtension n = new QuickFixExtension();
+ n.id = e.getAttribute("id"); //$NON-NLS-1$
+ try{
+ n.generator =
(IQuickFixGenerator)e.createExecutableExtension("generator-class");
//$NON-NLS-1$
+ }catch(CoreException ex){
+ XmlEditorPlugin.getDefault().logError(ex);
+ }
+ list.add(n);
+ }
+ return INSTANCES = list.toArray(new QuickFixExtension[0]);
+ }
+}
Property changes on:
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
===================================================================
---
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
(rev 0)
+++
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches... 2012-03-21
18:43:57 UTC (rev 39732)
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.text.xml.quickfix;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.source.Annotation;
+
+public class QuickFixManager {
+ private static QuickFixManager instance = null;
+
+ private HashMap<String, IQuickFixGenerator> generators = new HashMap<String,
IQuickFixGenerator>();
+
+ public static QuickFixManager getInstance(){
+ if(instance == null){
+ instance = new QuickFixManager();
+ }
+ return instance;
+ }
+
+ public QuickFixManager(){
+ QuickFixExtension[] extensions = QuickFixExtension.getInstances();
+ for(QuickFixExtension extension : extensions){
+ IQuickFixGenerator generator = extension.getQuickFixGenerator();
+ if(generator != null){
+ addQuickFixGenerator(generator);
+ }
+ }
+ }
+
+ public void addQuickFixGenerator(IQuickFixGenerator generator){
+ if(!generators.containsKey(generator.getClass().toString())){
+ generators.put(generator.getClass().toString(), generator);
+ }
+ }
+
+ public void removeQuickFixGenerator(IQuickFixGenerator generator){
+ generators.remove(generator);
+ }
+
+ public boolean hasProposals(Annotation annotation){
+ for(IQuickFixGenerator generator : generators.values()){
+ if(generator.hasProposals(annotation)){
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public List<ICompletionProposal> getProposals(Annotation annotation){
+ ArrayList<ICompletionProposal> proposals = new
ArrayList<ICompletionProposal>();
+ for(IQuickFixGenerator generator : generators.values()){
+ List<ICompletionProposal> pp = generator.getProposals(annotation);
+ proposals.addAll(pp);
+ }
+
+ return proposals;
+ }
+}
Property changes on:
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
===================================================================
---
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
(rev 0)
+++
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches... 2012-03-21
18:43:57 UTC (rev 39732)
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Exadel, Inc. and 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.text.xml.quickfix;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.ui.IMarkerResolution;
+import org.eclipse.ui.IMarkerResolution2;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+
+public class QuickFixProposal implements ICompletionProposal{
+ private IMarkerResolution resolution;
+ private IMarker marker;
+
+ public QuickFixProposal(IMarkerResolution resolution, IMarker marker){
+ this.resolution = resolution;
+ this.marker = marker;
+ }
+
+ public void apply(IDocument document) {
+ resolution.run(marker);
+ }
+
+ public Point getSelection(IDocument document) {
+ return null;
+ }
+
+ public String getAdditionalProposalInfo() {
+ if (resolution instanceof IMarkerResolution2)
+ return ((IMarkerResolution2) resolution).getDescription();
+
+ return (String)marker.getAttribute(IMarker.MESSAGE, ""); //$NON-NLS-1$
+ }
+
+ public String getDisplayString() {
+ return resolution.getLabel();
+ }
+
+ public Image getImage() {
+ if (resolution instanceof IMarkerResolution2)
+ return ((IMarkerResolution2)resolution).getImage();
+ return null;
+ }
+
+ public IContextInformation getContextInformation() {
+ return null;
+ }
+}
Property changes on:
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
===================================================================
---
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches... 2012-03-21
18:07:19 UTC (rev 39731)
+++
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches... 2012-03-21
18:43:57 UTC (rev 39732)
@@ -63,8 +63,8 @@
import org.eclipse.ui.texteditor.SimpleMarkerAnnotation;
import org.eclipse.wst.sse.ui.internal.reconcile.TemporaryAnnotation;
import org.eclipse.wst.sse.ui.internal.taginfo.ProblemAnnotationHoverProcessor;
-import org.jboss.tools.common.text.xml.MarkerAnnotationInfo;
-import org.jboss.tools.common.text.xml.MarkerAnnotationInfo.AnnotationInfo;
+import org.jboss.tools.common.text.xml.quickfix.MarkerAnnotationInfo;
+import org.jboss.tools.common.text.xml.quickfix.MarkerAnnotationInfo.AnnotationInfo;
import org.jboss.tools.common.text.xml.TextXMLMessages;
public class MarkerProblemAnnotationHoverProcessor extends
ProblemAnnotationHoverProcessor implements ITextHoverExtension, ITextHoverExtension2{
Modified:
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
===================================================================
---
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches... 2012-03-21
18:07:19 UTC (rev 39731)
+++
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches... 2012-03-21
18:43:57 UTC (rev 39732)
@@ -753,4 +753,8 @@
<keywordReference id="org.eclipse.wst.html.ui.webcontent"/>
</page>
</extension>
+
+ <extension point="org.jboss.tools.common.text.xml.quickFix">
+ <quick-fix-generator
generator-class="org.jboss.tools.jst.web.ui.action.JSPProblemMarkerResolutionGenerator"
id="org.jboss.tools.jst.web.ui.action.JSPProblemMarkerResolutionGenerator"
/>
+ </extension>
</plugin>
Modified:
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
===================================================================
---
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches... 2012-03-21
18:07:19 UTC (rev 39731)
+++
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches... 2012-03-21
18:43:57 UTC (rev 39732)
@@ -17,12 +17,21 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.TextSelection;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
import org.eclipse.ui.IMarkerResolution2;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.texteditor.DocumentProviderRegistry;
import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.jboss.tools.common.model.ui.views.palette.PaletteInsertHelper;
+import org.jboss.tools.jst.jsp.jspeditor.dnd.JSPPaletteInsertHelper;
import org.jboss.tools.jst.jsp.jspeditor.dnd.PaletteTaglibInserter;
import org.jboss.tools.jst.web.ui.Messages;
import org.jboss.tools.jst.web.ui.WebUiPlugin;
@@ -33,21 +42,34 @@
* @author Daniel Azarov
*
*/
-public class AddTLDMarkerResolution implements IMarkerResolution2{
+public class AddTLDMarkerResolution implements IMarkerResolution2, ICompletionProposal{
private IFile file;
private Properties properties;
+
private String resolutionName;
+ private int start, end;
+ private String uri, prefix;
public AddTLDMarkerResolution(IFile file, String name, Properties properties){
this.file = file;
this.properties = properties;
this.resolutionName = name;
}
+
+ public AddTLDMarkerResolution(String name, int start, int end, String uri, String
prefix){
+ this.resolutionName = name;
+ this.start = start;
+ this.end = end;
+ this.uri = uri;
+ this.prefix = prefix;
+ }
+ @Override
public String getLabel() {
return NLS.bind(Messages.AddTLDMarkerResolution_Name, resolutionName);
}
+ @Override
public void run(IMarker marker) {
FileEditorInput input = new FileEditorInput(file);
IDocumentProvider provider =
DocumentProviderRegistry.getDefault().getDocumentProvider(input);
@@ -68,11 +90,68 @@
}
}
+ @Override
public String getDescription() {
return getLabel();
}
+ @Override
public Image getImage() {
return
null;//ImageDescriptor.createFromFile(AddTLDMarkerResolution.class, "images/xstudio/editors/taglibs_file.gif").createImage();
//$NON-NLS-1$
}
+
+ @Override
+ public void apply(IDocument document) {
+ properties = new Properties();
+ properties.put(JSPPaletteInsertHelper.PROPOPERTY_ADD_TAGLIB, "true");
//$NON-NLS-1$
+ properties.put(PaletteInsertHelper.PROPOPERTY_START_TEXT, ""); //$NON-NLS-1$
+ properties.put(JSPPaletteInsertHelper.PROPOPERTY_TAGLIBRARY_URI, uri);
+ properties.put(JSPPaletteInsertHelper.PROPOPERTY_DEFAULT_PREFIX, prefix);
+ properties.put(PaletteInsertHelper.PROPOPERTY_SELECTION_PROVIDER, new
ISelectionProvider() {
+
+ @Override
+ public void setSelection(ISelection selection) {
+ }
+
+ @Override
+ public void removeSelectionChangedListener(
+ ISelectionChangedListener listener) {
+ }
+
+ @Override
+ public ISelection getSelection() {
+ return new TextSelection(start, end-start);
+ }
+
+ @Override
+ public void addSelectionChangedListener(ISelectionChangedListener listener) {
+ }
+ });
+
+
+ Properties p = PaletteTaglibInserter.getPrefixes(document, properties);
+
+ PaletteTaglibInserter inserter = new PaletteTaglibInserter();
+ inserter.inserTaglib(document, properties);
+ }
+
+ @Override
+ public Point getSelection(IDocument document) {
+ return null;
+ }
+
+ @Override
+ public String getAdditionalProposalInfo() {
+ return getDescription();
+ }
+
+ @Override
+ public String getDisplayString() {
+ return getLabel();
+ }
+
+ @Override
+ public IContextInformation getContextInformation() {
+ return null;
+ }
}
\ No newline at end of file
Modified:
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches...
===================================================================
---
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches... 2012-03-21
18:07:19 UTC (rev 39731)
+++
branches/https:/svn.jboss.org/repos/jbosstools/workspace/dazarov/branches... 2012-03-21
18:43:57 UTC (rev 39732)
@@ -10,7 +10,10 @@
******************************************************************************/
package org.jboss.tools.jst.web.ui.action;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import java.util.Properties;
import org.eclipse.core.resources.IFile;
@@ -18,6 +21,9 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.TextSelection;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.source.Annotation;
+import org.eclipse.wst.sse.ui.internal.reconcile.TemporaryAnnotation;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
@@ -27,6 +33,7 @@
import org.eclipse.ui.texteditor.DocumentProviderRegistry;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.jboss.tools.common.model.ui.views.palette.PaletteInsertHelper;
+import org.jboss.tools.common.text.xml.quickfix.IQuickFixGenerator;
import org.jboss.tools.jst.jsp.jspeditor.dnd.JSPPaletteInsertHelper;
import org.jboss.tools.jst.jsp.jspeditor.dnd.PaletteTaglibInserter;
import org.jboss.tools.jst.web.ui.WebUiPlugin;
@@ -37,7 +44,7 @@
* @author Daniel Azarov
*
*/
-public class JSPProblemMarkerResolutionGenerator implements IMarkerResolutionGenerator2
{
+public class JSPProblemMarkerResolutionGenerator implements IMarkerResolutionGenerator2,
IQuickFixGenerator {
private static final String
HTML_VALIDATOR_MARKER="org.eclipse.wst.html.core.validationMarker";
//$NON-NLS-1$
private static final String
JSP_VALIDATOR_MARKER="org.eclipse.jst.jsp.core.validationMarker"; //$NON-NLS-1$
@@ -60,6 +67,7 @@
private Properties properties;
private String resolutionName;
+ @Override
public IMarkerResolution[] getResolutions(IMarker marker) {
try{
if(isOurCase(marker)){
@@ -73,6 +81,36 @@
return new IMarkerResolution[]{};
}
+ private ICompletionProposal isOurCase(Annotation annotation){
+ if(!(annotation instanceof TemporaryAnnotation)){
+ return null;
+ }
+ TemporaryAnnotation ta = (TemporaryAnnotation)annotation;
+ Map attrs = ta.getAttributes();
+
+ String message = annotation.getText();
+ if(ta.getPosition() == null)
+ return null;
+
+ final int start = ta.getPosition().getOffset();
+
+ final int end = ta.getPosition().getOffset()+ta.getPosition().getLength();
+
+ if(!message.startsWith(UNKNOWN_TAG))
+ return null;
+
+ String prefix = getPrifix(message);
+ if(prefix == null)
+ return null;
+
+ if(!libs.containsKey(prefix))
+ return null;
+
+ resolutionName = "xmlns: "+prefix+" =
\""+libs.get(prefix)+"\""; //$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-3$
+
+ return new AddTLDMarkerResolution(resolutionName, start, end, libs.get(prefix),
prefix);
+ }
+
private boolean isOurCase(IMarker marker) throws CoreException{
String message = (String)marker.getAttribute(IMarker.MESSAGE);
@@ -86,7 +124,7 @@
return false;
final int end = attribute.intValue();
- if(!message.startsWith(UNKNOWN_TAG)) //$NON-NLS-1$
+ if(!message.startsWith(UNKNOWN_TAG))
return false;
String prefix = getPrifix(message);
@@ -115,17 +153,21 @@
properties.put(JSPPaletteInsertHelper.PROPOPERTY_DEFAULT_PREFIX, prefix);
properties.put(PaletteInsertHelper.PROPOPERTY_SELECTION_PROVIDER, new
ISelectionProvider() {
+ @Override
public void setSelection(ISelection selection) {
}
+ @Override
public void removeSelectionChangedListener(
ISelectionChangedListener listener) {
}
+ @Override
public ISelection getSelection() {
return new TextSelection(start, end-start);
}
+ @Override
public void addSelectionChangedListener(ISelectionChangedListener listener) {
}
});
@@ -163,6 +205,7 @@
return prefix;
}
+ @Override
public boolean hasResolutions(IMarker marker) {
try{
String message = (String)marker.getAttribute(IMarker.MESSAGE);
@@ -172,4 +215,20 @@
}
return false;
}
+
+ @Override
+ public boolean hasProposals(Annotation annotation) {
+ String message = annotation.getText();
+ return message.startsWith(UNKNOWN_TAG);
+ }
+
+ @Override
+ public List<ICompletionProposal> getProposals(Annotation annotation) {
+ ArrayList<ICompletionProposal> proposals = new
ArrayList<ICompletionProposal>();
+ ICompletionProposal proposal = isOurCase(annotation);
+ if(proposal != null){
+ proposals.add(proposal);
+ }
+ return proposals;
+ }
}
\ No newline at end of file