[jbosstools-commits] JBoss Tools SVN: r35427 - in trunk: cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker and 1 other directories.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Thu Oct 6 13:48:35 EDT 2011


Author: dazarov
Date: 2011-10-06 13:48:35 -0400 (Thu, 06 Oct 2011)
New Revision: 35427

Added:
   trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CreateCDIElementMarkerResolution.java
Modified:
   trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.java
   trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.properties
   trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddAnnotationMarkerResolution.java
   trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CDIProblemMarkerResolutionGenerator.java
   trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MarkerResolutionUtils.java
   trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/xpl/MarkerProblemAnnotationHoverProcessor.java
Log:


Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.java	2011-10-06 17:23:15 UTC (rev 35426)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.java	2011-10-06 17:48:35 UTC (rev 35427)
@@ -108,6 +108,10 @@
 	public static String ADD_ANNOTATION_MARKER_RESOLUTION_TITLE;
 	public static String DELETE_ANNOTATION_MARKER_RESOLUTION_TITLE;
 	public static String CHANGE_ANNOTATION_MARKER_RESOLUTION_TITLE;
+	public static String CREATE_BEAN_CLASS_TITLE;
+	public static String CREATE_STEREOTYPE_TITLE;
+	public static String CREATE_INTERCEPTOR_TITLE;
+	public static String CREATE_DECORATOR_TITLE;
 	
 	public static String QUESTION;
 	public static String DECREASING_FIELD_VISIBILITY_MAY_CAUSE_COMPILATION_PROBLEMS;

Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.properties
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.properties	2011-10-06 17:23:15 UTC (rev 35426)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.properties	2011-10-06 17:48:35 UTC (rev 35427)
@@ -92,6 +92,10 @@
 ADD_ANNOTATION_MARKER_RESOLUTION_TITLE=Add @{0} annotation to ''{1}'' {2}
 DELETE_ANNOTATION_MARKER_RESOLUTION_TITLE=Delete @{0} annotation from ''{1}'' {2}
 CHANGE_ANNOTATION_MARKER_RESOLUTION_TITLE=Change ''{0}'' annotation to {1}
+CREATE_BEAN_CLASS_TITLE=Create ''{0}'' Bean Class
+CREATE_STEREOTYPE_TITLE=Create ''{0}'' Stereotype
+CREATE_INTERCEPTOR_TITLE=Create ''{0}'' Interceptor
+CREATE_DECORATOR_TITLE=Create ''{0}'' Decorator
 
 QUESTION=Question
 DECREASING_FIELD_VISIBILITY_MAY_CAUSE_COMPILATION_PROBLEMS=Decreasing field visibility may cause compilation problems. Do you want to continue?

Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddAnnotationMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddAnnotationMarkerResolution.java	2011-10-06 17:23:15 UTC (rev 35426)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddAnnotationMarkerResolution.java	2011-10-06 17:48:35 UTC (rev 35427)
@@ -50,6 +50,11 @@
 			
 		label = NLS.bind(CDIUIMessages.ADD_ANNOTATION_MARKER_RESOLUTION_TITLE, new String[]{shortName, element.getElementName(), type});
 	}
+	
+	public AddAnnotationMarkerResolution(String classQualifiedName, String annotationQualifiedName){
+		this.qualifiedName = annotationQualifiedName;
+		
+	}
 
 	public String getLabel() {
 		return label;

Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CDIProblemMarkerResolutionGenerator.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CDIProblemMarkerResolutionGenerator.java	2011-10-06 17:23:15 UTC (rev 35426)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CDIProblemMarkerResolutionGenerator.java	2011-10-06 17:48:35 UTC (rev 35427)
@@ -29,8 +29,13 @@
 import org.eclipse.jdt.core.IMethod;
 import org.eclipse.jdt.core.IType;
 import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
 import org.eclipse.ui.IMarkerResolution;
 import org.eclipse.ui.IMarkerResolutionGenerator2;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.texteditor.DocumentProviderRegistry;
+import org.eclipse.ui.texteditor.IDocumentProvider;
 import org.jboss.tools.cdi.core.CDIConstants;
 import org.jboss.tools.cdi.core.CDICoreNature;
 import org.jboss.tools.cdi.core.CDIUtil;
@@ -47,6 +52,7 @@
 import org.jboss.tools.common.java.IAnnotationDeclaration;
 import org.jboss.tools.common.model.util.EclipseJavaUtil;
 import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.jst.web.ui.WebUiPlugin;
 
 /**
  * @author Daniel Azarov
@@ -54,6 +60,7 @@
 public class CDIProblemMarkerResolutionGenerator implements
 		IMarkerResolutionGenerator2 {
 	private static final String JAVA_EXTENSION = "java"; //$NON-NLS-1$
+	private static final String XML_EXTENSION = "xml"; //$NON-NLS-1$
 	private static final int MARKER_RESULUTION_NUMBER_LIMIT = 7;
 
 	public IMarkerResolution[] getResolutions(IMarker marker) {
@@ -92,6 +99,11 @@
 			return new IMarkerResolution[] {};
 		final int start = attribute.intValue();
 		
+		attribute = ((Integer) marker.getAttribute(IMarker.CHAR_END));
+		if (attribute == null)
+			return new IMarkerResolution[] {};
+		final int end = attribute.intValue();
+		
 		ICDIMarkerResolutionGeneratorExtension[] extensions = CDIQuickFixExtensionManager.getInstances();
 
 		if (JAVA_EXTENSION.equals(file.getFileExtension())) {
@@ -467,6 +479,49 @@
 					}
 				}
 			}
+		}else if (XML_EXTENSION.equals(file.getFileExtension())){
+			FileEditorInput input = new FileEditorInput(file);
+			IDocumentProvider provider = DocumentProviderRegistry.getDefault().getDocumentProvider(input);
+			try {
+				provider.connect(input);
+			} catch (CoreException e) {
+				CDIUIPlugin.getDefault().logError(e);
+			}
+			
+			IDocument document = provider.getDocument(input);
+			
+			String text="";
+			try {
+				text = document.get(start, end-start);
+			} catch (BadLocationException e) {
+				CDIUIPlugin.getDefault().logError(e);
+			}
+			
+			if(messageId == CDIValidationErrorManager.UNKNOWN_ALTERNATIVE_BEAN_CLASS_NAME_ID){
+				return new IMarkerResolution[] {
+					new CreateCDIElementMarkerResolution(file.getProject(), text, CreateCDIElementMarkerResolution.CREATE_BEAN_CLASS)
+				};
+			}else if(messageId == CDIValidationErrorManager.UNKNOWN_ALTERNATIVE_ANNOTATION_NAME_ID){
+				return new IMarkerResolution[] {
+					new CreateCDIElementMarkerResolution(file.getProject(), text, CreateCDIElementMarkerResolution.CREATE_STEREOTYPE)
+				};
+			}else if(messageId == CDIValidationErrorManager.ILLEGAL_ALTERNATIVE_BEAN_CLASS_ID){
+				return new IMarkerResolution[] {
+					new AddAnnotationMarkerResolution(text, CDIConstants.ALTERNATIVE_ANNOTATION_TYPE_NAME)
+				};
+			}else if(messageId == CDIValidationErrorManager.ILLEGAL_ALTERNATIVE_ANNOTATION_ID){
+				return new IMarkerResolution[] {
+					new AddAnnotationMarkerResolution(text, CDIConstants.ALTERNATIVE_ANNOTATION_TYPE_NAME)
+				};
+			}else if(messageId == CDIValidationErrorManager.UNKNOWN_DECORATOR_BEAN_CLASS_NAME_ID){
+				return new IMarkerResolution[] {
+					new CreateCDIElementMarkerResolution(file.getProject(), text, CreateCDIElementMarkerResolution.CREATE_DECORATOR)
+				};
+			}else if(messageId == CDIValidationErrorManager.UNKNOWN_INTERCEPTOR_CLASS_NAME_ID){
+				return new IMarkerResolution[] {
+					new CreateCDIElementMarkerResolution(file.getProject(), text, CreateCDIElementMarkerResolution.CREATE_INTERCEPTOR)
+				};
+			}
 		}
 		return new IMarkerResolution[] {};
 	}

Added: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CreateCDIElementMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CreateCDIElementMarkerResolution.java	                        (rev 0)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CreateCDIElementMarkerResolution.java	2011-10-06 17:48:35 UTC (rev 35427)
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.cdi.ui.marker;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IMarkerResolution2;
+import org.eclipse.ui.PlatformUI;
+import org.jboss.tools.cdi.core.CDIImages;
+import org.jboss.tools.cdi.ui.CDIUIMessages;
+import org.jboss.tools.cdi.ui.wizard.NewBeanCreationWizard;
+import org.jboss.tools.cdi.ui.wizard.NewCDIElementWizard;
+import org.jboss.tools.cdi.ui.wizard.NewDecoratorCreationWizard;
+import org.jboss.tools.cdi.ui.wizard.NewInterceptorCreationWizard;
+import org.jboss.tools.cdi.ui.wizard.NewStereotypeCreationWizard;
+import org.jboss.tools.common.model.ui.wizards.NewTypeWizardAdapter;
+
+public class CreateCDIElementMarkerResolution implements IMarkerResolution2{
+	private static final String OBJECT = "java.lang.Object";
+	
+	public static final int CREATE_BEAN_CLASS = 1;
+	public static final int CREATE_STEREOTYPE = 2;
+	public static final int CREATE_INTERCEPTOR = 3;
+	public static final int CREATE_DECORATOR = 4;
+	
+	private IProject project;
+	private String qualifiedName;
+	private int id;
+	
+	public CreateCDIElementMarkerResolution(IProject project, String text, int id){
+		this.project = project;
+		this.qualifiedName = text;
+		this.id = id;
+	}
+
+	@Override
+	public String getLabel() {
+		switch(id){
+		case CREATE_BEAN_CLASS:
+			return NLS.bind(CDIUIMessages.CREATE_BEAN_CLASS_TITLE, qualifiedName);
+		case CREATE_STEREOTYPE:
+			return NLS.bind(CDIUIMessages.CREATE_STEREOTYPE_TITLE, qualifiedName);
+		case CREATE_DECORATOR:
+			return NLS.bind(CDIUIMessages.CREATE_DECORATOR_TITLE, qualifiedName);
+		case CREATE_INTERCEPTOR:
+			return NLS.bind(CDIUIMessages.CREATE_INTERCEPTOR_TITLE, qualifiedName);
+		}
+		return "";
+	}
+
+	@Override
+	public void run(IMarker marker) {
+		Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+		NewCDIElementWizard wizard = null;
+		switch(id){
+		case CREATE_BEAN_CLASS:
+			wizard = new NewBeanCreationWizard();
+			break;
+		case CREATE_STEREOTYPE:
+			wizard = new NewStereotypeCreationWizard();
+			break;
+		case CREATE_DECORATOR:
+			wizard = new NewDecoratorCreationWizard();
+			break;
+		case CREATE_INTERCEPTOR:
+			wizard = new NewInterceptorCreationWizard();
+			break;
+		default: return;
+		}
+		
+		NewTypeWizardAdapter adapter = new NewTypeWizardAdapter(project);
+		adapter.setRawPackageName(MarkerResolutionUtils.getPackageName(qualifiedName));
+		adapter.setRawClassName(qualifiedName);
+		adapter.setRawSuperClassName(OBJECT);
+		wizard.setAdapter(adapter);
+		
+		wizard.init(PlatformUI.getWorkbench(), new StructuredSelection(new Object[]{}));
+		WizardDialog dialog = new WizardDialog(shell, wizard);
+		
+		dialog.open();
+	}
+
+	@Override
+	public String getDescription() {
+		return getLabel();
+	}
+
+	@Override
+	public Image getImage() {
+		return CDIImages.QUICKFIX_EDIT;
+	}
+
+}


Property changes on: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CreateCDIElementMarkerResolution.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

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-10-06 17:23:15 UTC (rev 35426)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MarkerResolutionUtils.java	2011-10-06 17:48:35 UTC (rev 35427)
@@ -301,6 +301,16 @@
 		return name;
 	}
 	
+	public static String getPackageName(String qualifiedName){
+		int lastDot = qualifiedName.lastIndexOf(DOT);
+		String name;
+		if(lastDot < 0)
+			name = "";
+		else
+			name = qualifiedName.substring(0, lastDot);
+		return name;
+	}
+	
 	public static String[] getShortNames(String[] qualifiedNames){
 		String[] shortNames = new String[qualifiedNames.length];
 		for(int i = 0; i < qualifiedNames.length; i++){

Modified: trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/xpl/MarkerProblemAnnotationHoverProcessor.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/xpl/MarkerProblemAnnotationHoverProcessor.java	2011-10-06 17:23:15 UTC (rev 35426)
+++ trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/xpl/MarkerProblemAnnotationHoverProcessor.java	2011-10-06 17:48:35 UTC (rev 35427)
@@ -46,6 +46,7 @@
 import org.eclipse.swt.events.PaintListener;
 import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.graphics.Point;
 import org.eclipse.swt.graphics.Rectangle;
 import org.eclipse.swt.layout.GridData;
@@ -274,6 +275,33 @@
 		}
 
 		private Link createLink(Composite parent, final ICompletionProposal proposal) {
+			new Label(parent, SWT.NONE);
+			parent= new Composite(parent, SWT.NONE);
+			GridLayout layout= new GridLayout(2, false);
+			layout.marginWidth= 0;
+			layout.marginHeight= 0;
+			parent.setLayout(layout);
+			
+			Label proposalImage= new Label(parent, SWT.NONE);
+			proposalImage.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
+			Image image= proposal.getImage();
+			if (image != null) {
+				proposalImage.setImage(image);
+
+				proposalImage.addMouseListener(new MouseListener() {
+
+					public void mouseDoubleClick(MouseEvent e) {
+					}
+
+					public void mouseDown(MouseEvent e) {
+						fix(proposal, info.viewer, info.infos.get(0).position.getOffset());
+					}
+
+					public void mouseUp(MouseEvent e) {
+					}
+
+				});
+			}
 			Link proposalLink = new Link(parent, SWT.WRAP);
 			GridData layoutData = new GridData(SWT.BEGINNING, SWT.CENTER, false, false);
 			String linkText = proposal.getDisplayString();



More information about the jbosstools-commits mailing list