Author: dazarov
Date: 2012-01-24 13:06:08 -0500 (Tue, 24 Jan 2012)
New Revision: 38112
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddTargetAnnotationMarkerResolution.java
Log:
Add the code which is supposed to be inserted by the Quick Fix into its description
https://issues.jboss.org/browse/JBIDE-10636
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddTargetAnnotationMarkerResolution.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddTargetAnnotationMarkerResolution.java 2012-01-24
17:56:14 UTC (rev 38111)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddTargetAnnotationMarkerResolution.java 2012-01-24
18:06:08 UTC (rev 38112)
@@ -15,7 +15,9 @@
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.refactoring.CompilationUnitChange;
+import org.eclipse.ltk.core.refactoring.TextChange;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.graphics.Image;
import org.eclipse.text.edits.MultiTextEdit;
@@ -25,11 +27,14 @@
import org.jboss.tools.cdi.internal.core.refactoring.CDIMarkerResolutionUtils;
import org.jboss.tools.cdi.ui.CDIUIMessages;
import org.jboss.tools.cdi.ui.CDIUIPlugin;
+import org.jboss.tools.common.refactoring.MarkerResolutionUtils;
+import org.jboss.tools.common.ui.CommonUIPlugin;
public class AddTargetAnnotationMarkerResolution implements
IMarkerResolution2 {
private IType type;
private String label;
+ private String description;
private String[] qualifiedNames;
private String[] shortNames;
private String totalList;
@@ -40,6 +45,7 @@
shortNames = CDIMarkerResolutionUtils.getShortNames(qualifiedNames);
totalList =
CDIMarkerResolutionUtils.OPEN_BRACE+CDIMarkerResolutionUtils.getTotalList(shortNames)+CDIMarkerResolutionUtils.CLOSE_BRACE;
label = NLS.bind(CDIUIMessages.ADD_TARGET_MARKER_RESOLUTION_TITLE, totalList,
type.getElementName());
+ description = getPreview();
}
@Override
@@ -74,11 +80,46 @@
}
}
+ private CompilationUnitChange getChange(ICompilationUnit compilationUnit) throws
JavaModelException{
+ CompilationUnitChange change = new CompilationUnitChange("",
compilationUnit);
+
+ MultiTextEdit edit = new MultiTextEdit();
+
+ change.setEdit(edit);
+ for(String qualifiedName : qualifiedNames){
+ CDIMarkerResolutionUtils.addImport(qualifiedName, compilationUnit, true, edit);
+ }
+
+ CDIMarkerResolutionUtils.addAnnotation(CDIConstants.TARGET_ANNOTATION_TYPE_NAME,
compilationUnit, type, "("+totalList+")", edit);
+
+ return change;
+ }
+ private CompilationUnitChange getPreviewChange(){
+ try{
+ ICompilationUnit original = type.getCompilationUnit();
+
+ return getChange(original);
+ }catch(CoreException ex){
+ CDIUIPlugin.getDefault().logError(ex);
+ }
+ return null;
+ }
+ private String getPreview(){
+ TextChange previewChange = getPreviewChange();
+
+ try {
+ return MarkerResolutionUtils.getPreview(previewChange);
+ } catch (CoreException e) {
+ CommonUIPlugin.getDefault().logError(e);
+ }
+ return label;
+ }
+
@Override
public String getDescription() {
- return label;
+ return description;
}
@Override