Author: dazarov
Date: 2010-12-23 10:55:04 -0500 (Thu, 23 Dec 2010)
New Revision: 27712
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/DeleteAllDisposerAnnotationsProcessor.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/DeleteAllInjectedConstructorsProcessor.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MarkerResolutionRefactoringProcessor.java
Log:
https://issues.jboss.org/browse/JBIDE-7988
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/DeleteAllDisposerAnnotationsProcessor.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/DeleteAllDisposerAnnotationsProcessor.java 2010-12-23
14:53:19 UTC (rev 27711)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/DeleteAllDisposerAnnotationsProcessor.java 2010-12-23
15:55:04 UTC (rev 27712)
@@ -18,11 +18,8 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.jdt.core.IMethod;
-import org.eclipse.ltk.core.refactoring.CompositeChange;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.core.refactoring.TextFileChange;
import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
-import org.eclipse.text.edits.MultiTextEdit;
import org.eclipse.text.edits.ReplaceEdit;
import org.eclipse.text.edits.TextEdit;
import org.jboss.tools.cdi.core.CDIConstants;
@@ -71,13 +68,8 @@
CheckConditionsContext context) throws CoreException,
OperationCanceledException {
- rootChange = new CompositeChange(label);
- change = new TextFileChange(file.getName(), file);
- change.setSaveMode(TextFileChange.LEAVE_DIRTY);
- MultiTextEdit root = new MultiTextEdit();
- change.setEdit(root);
- rootChange.add(change);
-
+ createRootChange();
+
if(bean != null)
changeDisposers(bean);
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/DeleteAllInjectedConstructorsProcessor.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/DeleteAllInjectedConstructorsProcessor.java 2010-12-23
14:53:19 UTC (rev 27711)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/DeleteAllInjectedConstructorsProcessor.java 2010-12-23
15:55:04 UTC (rev 27712)
@@ -10,7 +10,6 @@
******************************************************************************/
package org.jboss.tools.cdi.ui.marker;
-import java.text.MessageFormat;
import java.util.HashSet;
import java.util.Set;
@@ -19,11 +18,8 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.jdt.core.IMethod;
-import org.eclipse.ltk.core.refactoring.CompositeChange;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.core.refactoring.TextFileChange;
import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
-import org.eclipse.text.edits.MultiTextEdit;
import org.eclipse.text.edits.ReplaceEdit;
import org.eclipse.text.edits.TextEdit;
import org.jboss.tools.cdi.core.CDIConstants;
@@ -63,12 +59,7 @@
CheckConditionsContext context) throws CoreException,
OperationCanceledException {
- rootChange = new CompositeChange(label);
- change = new TextFileChange(file.getName(), file);
- change.setSaveMode(TextFileChange.LEAVE_DIRTY);
- MultiTextEdit root = new MultiTextEdit();
- change.setEdit(root);
- rootChange.add(change);
+ createRootChange();
if(bean != null)
changeConstructors(bean);
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MarkerResolutionRefactoringProcessor.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MarkerResolutionRefactoringProcessor.java 2010-12-23
14:53:19 UTC (rev 27711)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MarkerResolutionRefactoringProcessor.java 2010-12-23
15:55:04 UTC (rev 27712)
@@ -18,6 +18,7 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;
import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.CompositeChange;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
@@ -26,12 +27,17 @@
import org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor;
import org.eclipse.ltk.core.refactoring.participants.SharableParticipants;
import org.eclipse.ltk.internal.core.refactoring.Messages;
+import org.eclipse.text.edits.MultiTextEdit;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchWindow;
import org.jboss.tools.cdi.core.CDICoreMessages;
import org.jboss.tools.cdi.core.CDICoreNature;
import org.jboss.tools.cdi.core.CDICorePlugin;
import org.jboss.tools.cdi.core.IBean;
import org.jboss.tools.cdi.core.ICDIProject;
import org.jboss.tools.cdi.core.IClassBean;
+import org.jboss.tools.cdi.ui.CDIUIPlugin;
public abstract class MarkerResolutionRefactoringProcessor extends RefactoringProcessor
{
protected static final RefactoringParticipant[] EMPTY_REF_PARTICIPANT = new
RefactoringParticipant[0];
@@ -51,6 +57,33 @@
this.label = label;
}
+ protected void createRootChange(){
+ rootChange = new CompositeChange(label);
+ change = new TextFileChange(file.getName(), file);
+
+ if(isEditorOpened())
+ change.setSaveMode(TextFileChange.LEAVE_DIRTY);
+ else
+ change.setSaveMode(TextFileChange.FORCE_SAVE);
+
+ MultiTextEdit root = new MultiTextEdit();
+ change.setEdit(root);
+ rootChange.add(change);
+ rootChange.markAsSynthetic();
+ }
+
+ private boolean isEditorOpened(){
+ IEditorInput ii = EditorUtility.getEditorInput(file);
+
+ IWorkbenchWindow[] windows =
CDIUIPlugin.getDefault().getWorkbench().getWorkbenchWindows();
+ for(IWorkbenchWindow window : windows){
+ IEditorPart editor = window.getActivePage().findEditor(ii);
+ if(editor != null)
+ return true;
+ }
+ return false;
+ }
+
private IClassBean findClassBean(){
CDICoreNature cdiNature = CDICorePlugin.getCDI(file.getProject(), true);
if(cdiNature == null)