dion 2004/09/05 08:32:55
Modified: jelly/jelly-tags/swt/src/java/org/apache/commons/jelly/tags/swt
SwtTagLibrary.java
Added: jelly/jelly-tags/swt/src/java/org/apache/commons/jelly/tags/swt
GCTag.java
Log:
Jelly-126
Revision Changes Path
1.12 +3 -2
jakarta-commons/jelly/jelly-tags/swt/src/java/org/apache/commons/jelly/tags/swt/SwtTagLibrary.java
Index: SwtTagLibrary.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/jelly/jelly-tags/swt/src/java/org/apache/commons/jelly/tags/swt/SwtTagLibrary.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- SwtTagLibrary.java 5 Sep 2004 15:25:18 -0000 1.11
+++ SwtTagLibrary.java 5 Sep 2004 15:32:54 -0000 1.12
@@ -142,10 +142,11 @@
registerTag("onEvent", OnEventTag.class);
// other tags
- registerTag("image", ImageTag.class);
- registerTag("font", FontTag.class);
registerTag("color", ColorTag.class);
registerTag("colour", FontTag.class);
+ registerTag("font", FontTag.class);
+ registerTag("gc", GCTag.class);
+ registerTag("image", ImageTag.class);
}
1.1
jakarta-commons/jelly/jelly-tags/swt/src/java/org/apache/commons/jelly/tags/swt/GCTag.java
Index: GCTag.java
===================================================================
/*
* Copyright 2002,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.jelly.tags.swt;
import org.apache.commons.jelly.JellyTagException;
import org.apache.commons.jelly.TagSupport;
import org.apache.commons.jelly.XMLOutput;
import org.eclipse.swt.graphics.Drawable;
import org.eclipse.swt.graphics.GC;
/**
* Class to create a [EMAIL PROTECTED] GC} instance within Jelly SWT.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a>
* @version CVS $Id: GCTag.java,v 1.1 2004/09/05 15:32:54 dion Exp $
*/
public class GCTag extends TagSupport {
/** Drawable name */
private Drawable drawable;
/** Variable name */
private String var;
/**
* Obtain the [EMAIL PROTECTED] Drawable} name for this [EMAIL PROTECTED] GC}.
*
* @return a [EMAIL PROTECTED] GC} [EMAIL PROTECTED] Drawable}
*/
public Drawable getDrawable() {
return this.drawable;
}
/**
* Set the [EMAIL PROTECTED] Drawable} name for this [EMAIL PROTECTED] GC}.
*
* @param drawable a [EMAIL PROTECTED] GC} [EMAIL PROTECTED] Drawable}
*/
public void setDrawable(final Drawable drawable) {
this.drawable = drawable;
}
/**
* Sets the variable name.
*
* @param var the variable name of this [EMAIL PROTECTED] GC} instance
*/
public void setVar(final String var) {
this.var = var;
}
/**
* Obtain the variable name.
*
* @return the variable name of this [EMAIL PROTECTED] GC} instance
*/
public String getVar() {
return this.var;
}
// Tag interface
//-------------------------------------------------------------------------
/**
* Creates a [EMAIL PROTECTED] GC} instance and stores it in the Context under a
* particular variable name. Note, [EMAIL PROTECTED] GC} objects can only be
created on
* [EMAIL PROTECTED] Drawable} objects.
*
* @param output [EMAIL PROTECTED] XMLOutput} reference
* @throws JellyTagException if an error occurs
* @see org.apache.commons.jelly.Tag#doTag(org.apache.commons.jelly.XMLOutput)
*/
public void doTag(final XMLOutput output) throws JellyTagException {
// invoke by body just in case some nested tag configures me
invokeBody(output);
final boolean nullDrawable = drawable == null;
final boolean drawableParent = drawable instanceof Drawable;
if (nullDrawable || !drawableParent) {
throw new JellyTagException(
"This tag must specify a Drawable attribute (ie. Image or Control)"
);
}
if (var == null) {
throw new JellyTagException("This tag requires a context variable name");
}
// store the GC in the context
context.setVariable(var, new GC(drawable));
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]