Author: dazarov
Date: 2011-11-07 19:58:07 -0500 (Mon, 07 Nov 2011)
New Revision: 36212
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MarkerResolutionUtils.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/AbstractModifyInjectionPointWizard.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/xpl/AddQualifiersToBeanComposite.java
Log:
Quickfix and Wizard for fixing ambigious injection warning is confusing
https://issues.jboss.org/browse/JBIDE-9940
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MarkerResolutionUtils.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MarkerResolutionUtils.java 2011-11-08
00:14:18 UTC (rev 36211)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MarkerResolutionUtils.java 2011-11-08
00:58:07 UTC (rev 36212)
@@ -215,18 +215,21 @@
if(duplicateShortName)
shortName = qualifiedName;
- String str = AT+shortName+params;
+ String newValue = AT+shortName+params;
- if(rootEdit != null){
- TextEdit edit = new ReplaceEdit(annotation.getSourceRange().getOffset(),
annotation.getSourceRange().getLength(), str);
- rootEdit.addChild(edit);
- }else{
- buffer.replace(annotation.getSourceRange().getOffset(),
annotation.getSourceRange().getLength(), str);
-
- synchronized(compilationUnit) {
- compilationUnit.reconcile(ICompilationUnit.NO_AST, true, null, null);
+ if(!annotation.getSource().equals(newValue)){
+ if(rootEdit != null){
+ TextEdit edit = new ReplaceEdit(annotation.getSourceRange().getOffset(),
annotation.getSourceRange().getLength(), newValue);
+ rootEdit.addChild(edit);
+ }else{
+ buffer.replace(annotation.getSourceRange().getOffset(),
annotation.getSourceRange().getLength(), newValue);
+
+ synchronized(compilationUnit) {
+ compilationUnit.reconcile(ICompilationUnit.NO_AST, true, null, null);
+ }
}
}
+
}
public static void addAnnotation(String qualifiedName, ICompilationUnit compilationUnit,
IJavaElement element, String params) throws JavaModelException{
@@ -340,14 +343,18 @@
if(duplicateShortName)
shortName = qualifiedName;
- if(rootEdit != null){
- TextEdit edit = new ReplaceEdit(annotation.getSourceRange().getOffset(),
annotation.getSourceRange().getLength(), AT+shortName+value);
- rootEdit.addChild(edit);
- }else{
- buffer.replace(annotation.getSourceRange().getOffset(),
annotation.getSourceRange().getLength(), AT+shortName+value);
-
- synchronized(compilationUnit) {
- compilationUnit.reconcile(ICompilationUnit.NO_AST, true, null, null);
+ String newValue = AT+shortName+value;
+
+ if(!annotation.getSource().equals(newValue)){
+ if(rootEdit != null){
+ TextEdit edit = new ReplaceEdit(annotation.getSourceRange().getOffset(),
annotation.getSourceRange().getLength(), newValue);
+ rootEdit.addChild(edit);
+ }else{
+ buffer.replace(annotation.getSourceRange().getOffset(),
annotation.getSourceRange().getLength(), newValue);
+
+ synchronized(compilationUnit) {
+ compilationUnit.reconcile(ICompilationUnit.NO_AST, true, null, null);
+ }
}
}
}
@@ -482,14 +489,19 @@
}
b.append(Signature.getSignatureSimpleName(parameters[index].getTypeSignature())+SPACE);
b.append(parameters[index].getElementName());
- if(rootEdit != null){
- TextEdit edit = new ReplaceEdit(parameters[index].getSourceRange().getOffset(),
parameters[index].getSourceRange().getLength(), b.toString());
- rootEdit.addChild(edit);
- }else{
- buffer.replace(parameters[index].getSourceRange().getOffset(),
parameters[index].getSourceRange().getLength(), b.toString());
-
- synchronized(compilationUnit) {
- compilationUnit.reconcile(ICompilationUnit.NO_AST, true, null, null);
+
+ String newValue = b.toString();
+
+ if(!parameters[index].getSource().equals(newValue)){
+ if(rootEdit != null){
+ TextEdit edit = new ReplaceEdit(parameters[index].getSourceRange().getOffset(),
parameters[index].getSourceRange().getLength(), b.toString());
+ rootEdit.addChild(edit);
+ }else{
+ buffer.replace(parameters[index].getSourceRange().getOffset(),
parameters[index].getSourceRange().getLength(), b.toString());
+
+ synchronized(compilationUnit) {
+ compilationUnit.reconcile(ICompilationUnit.NO_AST, true, null, null);
+ }
}
}
}
@@ -735,7 +747,7 @@
// delete annotation
if(rootEdit != null){
- TextEdit edit = new DeleteEdit(annotation.getSourceRange().getOffset(),
annotation.getSourceRange().getLength()+numberOfSpaces);
+ TextEdit edit = new DeleteEdit(annotation.getSourceRange().getOffset(),
annotation.getSourceRange().getLength());
rootEdit.addChild(edit);
}else{
buffer.replace(annotation.getSourceRange().getOffset(),
annotation.getSourceRange().getLength()+numberOfSpaces, "");
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/AbstractModifyInjectionPointWizard.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/AbstractModifyInjectionPointWizard.java 2011-11-08
00:14:18 UTC (rev 36211)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/AbstractModifyInjectionPointWizard.java 2011-11-08
00:58:07 UTC (rev 36212)
@@ -13,8 +13,8 @@
import java.util.List;
import org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring;
-import org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog;
import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
+import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.jboss.tools.cdi.core.IBean;
@@ -28,8 +28,12 @@
public boolean showWizard() {
final IWorkbenchWindow win = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- RefactoringWizardDialog dialog = new RefactoringWizardDialog(win.getShell(),this);
- dialog.open();
+ RefactoringWizardOpenOperation op = new RefactoringWizardOpenOperation(this);
+ try {
+ op.run(win.getShell(), getWindowTitle());
+ } catch (final InterruptedException irex) {
+ return false;
+ }
return true;
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/xpl/AddQualifiersToBeanComposite.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/xpl/AddQualifiersToBeanComposite.java 2011-11-08
00:14:18 UTC (rev 36211)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/xpl/AddQualifiersToBeanComposite.java 2011-11-08
00:58:07 UTC (rev 36212)
@@ -20,6 +20,8 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.jobs.IJobManager;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.jdt.core.Flags;
@@ -48,6 +50,7 @@
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.ModifyEvent;
@@ -431,31 +434,34 @@
createQualifier.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
- Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
- NewQualifierCreationWizard wizard = new NewQualifierCreationWizard();
- StructuredSelection selection = new StructuredSelection(new
Object[]{bean.getBeanClass()});
-
- wizard.init(PlatformUI.getWorkbench(), selection);
- WizardDialog dialog = new WizardDialog(shell, wizard);
- int status = dialog.open();
- if(status == WizardDialog.OK){
- // reload qualifiers
- if (Display.getCurrent() != null) {
- try{
- PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new
IRunnableWithProgress(){
- public void run(IProgressMonitor monitor)
- throws InvocationTargetException, InterruptedException {
+ final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ final IJobManager manager= Job.getJobManager();
+ // reload qualifiers
+ if (Display.getCurrent() != null) {
+ BusyIndicator.showWhile(Display.getCurrent(), new Runnable(){
+ public void run(){
+ manager.endRule(ResourcesPlugin.getWorkspace().getRoot());
+
+ NewQualifierCreationWizard wizard = new NewQualifierCreationWizard();
+ StructuredSelection selection = new StructuredSelection(new
Object[]{bean.getBeanClass()});
+
+ wizard.init(PlatformUI.getWorkbench(), selection);
+ WizardDialog dialog = new WizardDialog(shell, wizard);
+ int status = dialog.open();
+ if(status == WizardDialog.OK){
+ try {
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
+ } catch (OperationCanceledException e) {
+ CDICorePlugin.getDefault().logError(e);
+ } catch (InterruptedException e) {
+ CDICorePlugin.getDefault().logError(e);
}
- });
- }catch(InterruptedException ie){
- CDICorePlugin.getDefault().logError(ie);
- }catch(InvocationTargetException ite){
- CDICorePlugin.getDefault().logError(ite);
+ loadAvailableQualifiers();
+ }
+ manager.beginRule(ResourcesPlugin.getWorkspace().getRoot(), null);
}
- }
-
- loadAvailableQualifiers();
+
+ });
}
}
});