Author: akazakov
Date: 2012-06-04 19:42:39 -0400 (Mon, 04 Jun 2012)
New Revision: 41705
Added:
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/AbstractTemporaryAnnotation.java
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationAnnotation.java
Modified:
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/DisabledAnnotation.java
Log:
https://issues.jboss.org/browse/JBIDE-10738 As-you-type EL validation
Added:
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/AbstractTemporaryAnnotation.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/AbstractTemporaryAnnotation.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/AbstractTemporaryAnnotation.java 2012-06-04
23:42:39 UTC (rev 41705)
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * 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.validation;
+
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.text.source.Annotation;
+import org.eclipse.jface.text.source.IAnnotationAccessExtension;
+import org.eclipse.jface.text.source.IAnnotationPresentation;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.ui.editors.text.EditorsUI;
+import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
+import org.eclipse.ui.internal.util.BundleUtility;
+import org.eclipse.ui.texteditor.AnnotationPreference;
+import org.eclipse.ui.texteditor.AnnotationPreferenceLookup;
+import org.eclipse.ui.texteditor.ImageUtilities;
+
+/**
+ * @author Alexey Kazakov
+ */
+public abstract class AbstractTemporaryAnnotation extends Annotation implements
IAnnotationPresentation {
+
+ private static final int WARNING_LAYER;
+ private static final int ERROR_LAYER;
+
+ private Map<String, Object> fAttributes = new HashMap<String, Object>();
+
+ private int seveirty = WARNING_LAYER;
+
+ static {
+ AnnotationPreferenceLookup lookup = EditorsUI.getAnnotationPreferenceLookup();
+ WARNING_LAYER = computeLayer("org.eclipse.wst.sse.ui.temp.warning",
lookup); //$NON-NLS-1$
+ ERROR_LAYER = computeLayer("org.eclipse.wst.sse.ui.temp.error",
lookup); //$NON-NLS-1$
+ }
+
+ private static int computeLayer(String annotationType, AnnotationPreferenceLookup
lookup) {
+ Annotation annotation = new Annotation(annotationType, false, null);
+ AnnotationPreference preference= lookup.getAnnotationPreference(annotation);
+ if (preference != null) {
+ return preference.getPresentationLayer() + 1;
+ } else {
+ return IAnnotationAccessExtension.DEFAULT_LAYER + 1;
+ }
+ }
+
+ public AbstractTemporaryAnnotation(String type, boolean isPersistent, String text,
boolean warning) {
+ super(type, isPersistent, text);
+ this.seveirty = warning?WARNING_LAYER:ERROR_LAYER;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.text.source.IAnnotationPresentation#getLayer()
+ */
+ @Override
+ public int getLayer() {
+ return seveirty;
+ }
+
+ protected abstract String getWarningIconPath();
+
+ protected abstract String getErrorIconPath();
+
+ @Override
+ public void paint(GC gc, Canvas canvas, Rectangle bounds) {
+ String path = seveirty==WARNING_LAYER? getWarningIconPath() : getErrorIconPath();
+ URL url = BundleUtility.find(IDEWorkbenchPlugin.IDE_WORKBENCH, path);
+ ImageDescriptor descriptor = ImageDescriptor.createFromURL(url);
+ Image image = descriptor.createImage(false);
+ ImageUtilities.drawImage(image, gc, canvas, bounds, SWT.CENTER, SWT.TOP);
+ }
+
+ public Object getAttribute(String key) {
+ return fAttributes.get(key);
+ }
+
+ public void setAttribute(String key, Object value) {
+ fAttributes.put(key, value);
+ }
+}
\ No newline at end of file
Property changes on:
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/AbstractTemporaryAnnotation.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/DisabledAnnotation.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/DisabledAnnotation.java 2012-06-04
22:32:58 UTC (rev 41704)
+++
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/DisabledAnnotation.java 2012-06-04
23:42:39 UTC (rev 41705)
@@ -10,79 +10,35 @@
******************************************************************************/
package org.jboss.tools.common.validation;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.jface.text.source.IAnnotationAccessExtension;
-import org.eclipse.jface.text.source.IAnnotationPresentation;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.ui.editors.text.EditorsUI;
import org.eclipse.ui.internal.WorkbenchImages;
-import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
-import org.eclipse.ui.internal.util.BundleUtility;
-import org.eclipse.ui.texteditor.AnnotationPreference;
-import org.eclipse.ui.texteditor.AnnotationPreferenceLookup;
-import org.eclipse.ui.texteditor.ImageUtilities;
/**
* @author Alexey Kazakov
*/
-public class DisabledAnnotation extends Annotation implements IAnnotationPresentation {
+public class DisabledAnnotation extends AbstractTemporaryAnnotation {
- private static final int WARNING_LAYER;
- private static final int ERROR_LAYER;
+ private static final String warningPath = WorkbenchImages.ICONS_PATH +
"dlcl16/showwarn_tsk.gif";
+ private static final String errorPath = WorkbenchImages.ICONS_PATH +
"dlcl16/showerr_tsk.gif";
- private Map<String, Object> fAttributes = new HashMap<String, Object>();
-
- private int seveirty = WARNING_LAYER;
-
- static {
- AnnotationPreferenceLookup lookup = EditorsUI.getAnnotationPreferenceLookup();
- WARNING_LAYER = computeLayer("org.eclipse.wst.sse.ui.temp.warning",
lookup); //$NON-NLS-1$
- ERROR_LAYER = computeLayer("org.eclipse.wst.sse.ui.temp.error",
lookup); //$NON-NLS-1$
- }
-
- private static int computeLayer(String annotationType, AnnotationPreferenceLookup
lookup) {
- Annotation annotation = new Annotation(annotationType, false, null);
- AnnotationPreference preference= lookup.getAnnotationPreference(annotation);
- if (preference != null) {
- return preference.getPresentationLayer() + 1;
- } else {
- return IAnnotationAccessExtension.DEFAULT_LAYER + 1;
- }
- }
-
- public DisabledAnnotation(String type, boolean isPersistent, String text, boolean
warning) {
- super(type, isPersistent, text);
- this.seveirty = warning?WARNING_LAYER:ERROR_LAYER;
+ public DisabledAnnotation(String type, boolean isPersistent, String text, boolean
warning) {
+ super(type, isPersistent, text, warning);
}
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.common.validation.AbstractTemporaryAnnotation#getWarningIconPath()
+ */
@Override
- public int getLayer() {
- return seveirty;
+ protected String getWarningIconPath() {
+ return warningPath;
}
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.common.validation.AbstractTemporaryAnnotation#getErrorIconPath()
+ */
@Override
- public void paint(GC gc, Canvas canvas, Rectangle bounds) {
- String path = seveirty==WARNING_LAYER? (WorkbenchImages.ICONS_PATH +
"dlcl16/showwarn_tsk.gif") : (WorkbenchImages.ICONS_PATH +
"dlcl16/showerr_tsk.gif"); //$NON-NLS-1$
- URL url = BundleUtility.find(IDEWorkbenchPlugin.IDE_WORKBENCH, path);
- ImageDescriptor descriptor = ImageDescriptor.createFromURL(url);
- Image image = descriptor.createImage(false);
- ImageUtilities.drawImage(image, gc, canvas, bounds, SWT.CENTER, SWT.TOP);
+ protected String getErrorIconPath() {
+ return errorPath;
}
-
- public Object getAttribute(String key) {
- return fAttributes.get(key);
- }
-
- public void setAttribute(String key, Object value) {
- fAttributes.put(key, value);
- }
}
\ No newline at end of file
Added:
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationAnnotation.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationAnnotation.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationAnnotation.java 2012-06-04
23:42:39 UTC (rev 41705)
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * 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.validation;
+
+import org.eclipse.ui.internal.WorkbenchImages;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class ValidationAnnotation extends AbstractTemporaryAnnotation {
+
+ private static final String warningPath = WorkbenchImages.ICONS_PATH +
"elcl16/showwarn_tsk.gif";
+ private static final String errorPath = WorkbenchImages.ICONS_PATH +
"elcl16/showerr_tsk.gif";
+
+ /**
+ * @param type
+ * @param isPersistent
+ * @param text
+ * @param warning
+ */
+ public ValidationAnnotation(String type, boolean isPersistent, String text, boolean
warning) {
+ super(type, isPersistent, text, warning);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.common.validation.AbstractTemporaryAnnotation#getWarningIconPath()
+ */
+ @Override
+ protected String getWarningIconPath() {
+ return warningPath;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.common.validation.AbstractTemporaryAnnotation#getErrorIconPath()
+ */
+ @Override
+ protected String getErrorIconPath() {
+ return errorPath;
+ }
+}
\ No newline at end of file
Property changes on:
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationAnnotation.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain