[jbosstools-commits] JBoss Tools SVN: r41991 - in trunk: jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action and 1 other directory.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Thu Jun 14 16:17:52 EDT 2012
Author: dazarov
Date: 2012-06-14 16:17:51 -0400 (Thu, 14 Jun 2012)
New Revision: 41991
Added:
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/quickfix/IBaseMarkerResolution.java
Modified:
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/quickfix/MarkerAnnotationInfo.java
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/AddTLDMarkerResolution.java
Log:
Quick-fixes are duplicated in VPE editor https://issues.jboss.org/browse/JBIDE-12178
Added: trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/quickfix/IBaseMarkerResolution.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/quickfix/IBaseMarkerResolution.java (rev 0)
+++ trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/quickfix/IBaseMarkerResolution.java 2012-06-14 20:17:51 UTC (rev 41991)
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * 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 org.eclipse.ui.IMarkerResolution2;
+
+public interface IBaseMarkerResolution extends IMarkerResolution2 {
+
+}
Property changes on: trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/quickfix/IBaseMarkerResolution.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/quickfix/MarkerAnnotationInfo.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/quickfix/MarkerAnnotationInfo.java 2012-06-14 18:55:17 UTC (rev 41990)
+++ trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/quickfix/MarkerAnnotationInfo.java 2012-06-14 20:17:51 UTC (rev 41991)
@@ -23,7 +23,11 @@
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.IEditorPart;
import org.eclipse.ui.IMarkerResolution;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.texteditor.SimpleMarkerAnnotation;
import org.eclipse.wst.sse.ui.StructuredTextInvocationContext;
@@ -56,7 +60,9 @@
IMarker marker = annotation.getMarker();
IMarkerResolution[] resolutions = IDE.getMarkerHelpRegistry().getResolutions(marker);
for (IMarkerResolution resolution : resolutions) {
- proposals.add(new QuickFixProposal(resolution, marker));
+ if(!isDirty() || !(resolution instanceof IBaseMarkerResolution)){
+ proposals.add(new QuickFixProposal(resolution, marker));
+ }
}
return proposals;
@@ -74,7 +80,8 @@
}
// get all relevant quick fixes for this annotation
- if(QuickFixManager.getInstance().hasProposals(annotation)){
+
+ if(isDirty() && QuickFixManager.getInstance().hasProposals(annotation)){
annotation.setAdditionalFixInfo(viewer.getDocument());
List<ICompletionProposal> proposals = QuickFixManager.getInstance().getProposals(annotation);
allProposals.addAll(proposals);
@@ -103,6 +110,20 @@
return allProposals;
}
+ private static boolean isDirty(){
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if(window != null){
+ IWorkbenchPage page = window.getActivePage();
+ if(page != null){
+ IEditorPart editor = page.getActiveEditor();
+ if(editor != null){
+ return editor.isDirty();
+ }
+ }
+ }
+ return true;
+ }
+
private void collectProposals(IQuickAssistProcessor processor, Annotation annotation, IQuickAssistInvocationContext invocationContext, List<ICompletionProposal> proposalsList) {
ICompletionProposal[] proposals = processor.computeQuickAssistProposals(invocationContext);
if (proposals != null && proposals.length > 0) {
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/AddTLDMarkerResolution.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/AddTLDMarkerResolution.java 2012-06-14 18:55:17 UTC (rev 41990)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/AddTLDMarkerResolution.java 2012-06-14 20:17:51 UTC (rev 41991)
@@ -31,6 +31,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.IBaseMarkerResolution;
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;
@@ -42,7 +43,7 @@
* @author Daniel Azarov
*
*/
-public class AddTLDMarkerResolution implements IMarkerResolution2, ICompletionProposal{
+public class AddTLDMarkerResolution implements IBaseMarkerResolution, ICompletionProposal{
private IFile file;
private Properties properties;
@@ -75,15 +76,20 @@
IDocumentProvider provider = DocumentProviderRegistry.getDefault().getDocumentProvider(input);
try {
provider.connect(input);
+
+ boolean dirty = provider.canSaveDocument(input);
IDocument document = provider.getDocument(input);
PaletteTaglibInserter inserter = new PaletteTaglibInserter();
inserter.inserTaglib(document, properties);
- provider.aboutToChange(input);
- provider.saveDocument(new NullProgressMonitor(), input, document, true);
- provider.changed(input);
+ if(!dirty){
+ provider.aboutToChange(input);
+ provider.saveDocument(new NullProgressMonitor(), input, document, true);
+ provider.changed(input);
+ }
+
provider.disconnect(input);
}catch(CoreException ex){
WebUiPlugin.getPluginLog().logError(ex);
More information about the jbosstools-commits
mailing list