JBoss Rich Faces SVN: r16866 - in root/ui-sandbox/trunk/components/componentcontrol/src/main/java/org/richfaces: component and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-05-03 05:58:02 -0400 (Mon, 03 May 2010)
New Revision: 16866
Modified:
root/ui-sandbox/trunk/components/componentcontrol/src/main/java/org/richfaces/BehaviorStateHelper.java
root/ui-sandbox/trunk/components/componentcontrol/src/main/java/org/richfaces/component/UIHashParameter.java
root/ui-sandbox/trunk/components/componentcontrol/src/main/java/org/richfaces/component/behavior/ClientBehavior.java
root/ui-sandbox/trunk/components/componentcontrol/src/main/java/org/richfaces/component/behavior/ComponentControlBehavior.java
root/ui-sandbox/trunk/components/componentcontrol/src/main/java/org/richfaces/renderkit/ComponentControlBehaviorRenderer.java
root/ui-sandbox/trunk/components/componentcontrol/src/main/java/org/richfaces/tag/BehaviorRule.java
root/ui-sandbox/trunk/components/componentcontrol/src/main/java/org/richfaces/tag/BehaviorTagHandlerDelegate.java
root/ui-sandbox/trunk/components/componentcontrol/src/main/java/org/richfaces/tag/CustomBehaviorHandler.java
root/ui-sandbox/trunk/components/componentcontrol/src/main/java/org/richfaces/taglib/ComponentControlHandler.java
Log:
apply checkstyle
Modified: root/ui-sandbox/trunk/components/componentcontrol/src/main/java/org/richfaces/BehaviorStateHelper.java
===================================================================
--- root/ui-sandbox/trunk/components/componentcontrol/src/main/java/org/richfaces/BehaviorStateHelper.java 2010-05-02 23:44:02 UTC (rev 16865)
+++ root/ui-sandbox/trunk/components/componentcontrol/src/main/java/org/richfaces/BehaviorStateHelper.java 2010-05-03 09:58:02 UTC (rev 16866)
@@ -5,20 +5,19 @@
import org.richfaces.component.behavior.ClientBehavior;
-
/**
* @author Anton Belevich
- *
+ *
*/
public class BehaviorStateHelper extends PartialStateHolderHelper {
-
+
private ClientBehavior behavior;
-
+
public BehaviorStateHelper(ClientBehavior behavior) {
super(behavior);
this.behavior = behavior;
}
-
+
@Override
protected Object getValueExpressionValue(String name) {
Object retVal = null;
Modified: root/ui-sandbox/trunk/components/componentcontrol/src/main/java/org/richfaces/component/UIHashParameter.java
===================================================================
--- root/ui-sandbox/trunk/components/componentcontrol/src/main/java/org/richfaces/component/UIHashParameter.java 2010-05-02 23:44:02 UTC (rev 16865)
+++ root/ui-sandbox/trunk/components/componentcontrol/src/main/java/org/richfaces/component/UIHashParameter.java 2010-05-03 09:58:02 UTC (rev 16866)
@@ -9,60 +9,59 @@
import javax.faces.component.UIComponentBase;
import javax.faces.component.UIParameter;
-
/**
* @author Anton Belevich
*
*/
public class UIHashParameter extends UIComponentBase {
-
+
public static final String COMPONENT_TYPE = "org.richfaces.HashParameter";
-
+
public static final String COMPONENT_FAMILY = "org.richfaces.HashParameter";
enum PropertyKeys {
name
}
-
-
+
public UIHashParameter() {
super();
setRendererType(null);
}
-
+
public String getName() {
- return (String)getStateHelper().eval(PropertyKeys.name);
+ return (String) getStateHelper().eval(PropertyKeys.name);
}
-
+
public void setName(String name) {
getStateHelper().put(PropertyKeys.name, name);
}
-
+
public Map<String, Object> getValue() {
List<UIComponent> children = getChildren();
- Map <String, Object> parameters = new HashMap<String, Object>();
+ Map<String, Object> parameters = new HashMap<String, Object>();
- for(UIComponent child: children) {
- if(child instanceof UIParameter) {
- UIParameter parameter = (UIParameter)child;
- parameters.put(parameter.getName(),(String)parameter.getValue());
+ for (UIComponent child : children) {
+ if (child instanceof UIParameter) {
+ UIParameter parameter = (UIParameter) child;
+ parameters.put(parameter.getName(), (String) parameter.getValue());
}
-
- if(child instanceof UIHashParameter) {
- UIHashParameter hashParameter = (UIHashParameter)child;
+
+ if (child instanceof UIHashParameter) {
+ UIHashParameter hashParameter = (UIHashParameter) child;
String name = hashParameter.getName();
- Map<String, Object> value = hashParameter.getValue();
- if(name == null) {
- throw new FacesException("attribute 'name' for the nested " + UIHashParameter.class.getName() + " component (id = '" +hashParameter.getClientId()+"') should not be 'null'");
- }else {
+ Map<String, Object> value = hashParameter.getValue();
+ if (name == null) {
+ throw new FacesException("attribute 'name' for the nested " + UIHashParameter.class.getName()
+ + " component (id = '" + hashParameter.getClientId() + "') should not be 'null'");
+ } else {
parameters.put(name, value);
}
}
}
-
+
return parameters;
}
-
+
@Override
public String getFamily() {
return (COMPONENT_FAMILY);
Modified: root/ui-sandbox/trunk/components/componentcontrol/src/main/java/org/richfaces/component/behavior/ClientBehavior.java
===================================================================
--- root/ui-sandbox/trunk/components/componentcontrol/src/main/java/org/richfaces/component/behavior/ClientBehavior.java 2010-05-02 23:44:02 UTC (rev 16865)
+++ root/ui-sandbox/trunk/components/componentcontrol/src/main/java/org/richfaces/component/behavior/ClientBehavior.java 2010-05-03 09:58:02 UTC (rev 16866)
@@ -14,27 +14,25 @@
import javax.faces.context.FacesContext;
import org.richfaces.BehaviorStateHelper;
-
/**
* @author Anton Belevich
- *
- * base class for the client behaviors
+ *
+ * base class for the client behaviors
*/
public abstract class ClientBehavior extends ClientBehaviorBase {
-
+
private StateHelper behaviorStateHelper = null;
-
+
private Map<String, ValueExpression> bindings;
-
-
+
public StateHelper getStateHelper() {
- if(behaviorStateHelper == null) {
+ if (behaviorStateHelper == null) {
behaviorStateHelper = new BehaviorStateHelper(this);
}
return behaviorStateHelper;
}
-
+
public ValueExpression getValueExpression(String name) {
if (name == null) {
throw new NullPointerException();
@@ -42,7 +40,7 @@
return ((bindings == null) ? null : bindings.get(name));
}
-
+
public void setValueExpression(String name, ValueExpression valueExpression) {
if (name == null) {
throw new NullPointerException();
@@ -54,11 +52,11 @@
setLiteralValue(name, valueExpression);
} else {
if (bindings == null) {
- bindings = new HashMap<String, ValueExpression>(6,1.0f);
+ bindings = new HashMap<String, ValueExpression>(6, 1.0f);
}
bindings.put(name, valueExpression);
}
-
+
} else {
if (bindings != null) {
bindings.remove(name);
@@ -69,62 +67,62 @@
}
clearInitialState();
}
-
+
protected FacesContext getFacesContext() {
return FacesContext.getCurrentInstance();
}
public void setLiteralValue(String name, ValueExpression expression) {
- assert(expression.isLiteralText());
+ assert (expression.isLiteralText());
ELContext context = getFacesContext().getELContext();
-
+
try {
setLiteralAttribute(name, expression.getValue(context));
} catch (ELException elem) {
throw new FacesException(elem);
}
}
-
+
public abstract void setLiteralAttribute(String name, Object value);
-
+
@Override
public Object saveState(FacesContext context) {
- Object [] state = null;
-
+ Object[] state = null;
+
Object parentState = super.saveState(context);
- if(initialStateMarked()) {
- if(parentState != null) {
- state = new Object[] {parentState};
+ if (initialStateMarked()) {
+ if (parentState != null) {
+ state = new Object[] { parentState };
}
} else {
state = new Object[3];
state[0] = parentState;
-
+
Object attrs = null;
- if(behaviorStateHelper != null) {
+ if (behaviorStateHelper != null) {
attrs = behaviorStateHelper.saveState(context);
}
state[1] = attrs;
state[2] = saveBindings(context, bindings);
-
+
}
- return state;
+ return state;
}
-
+
@Override
public void restoreState(FacesContext context, Object state) {
- if(state != null) {
- Object [] stateObject = (Object[])state;
+ if (state != null) {
+ Object[] stateObject = (Object[]) state;
super.restoreState(context, stateObject[0]);
- if(stateObject.length > 1) {
- if(behaviorStateHelper != null) {
+ if (stateObject.length > 1) {
+ if (behaviorStateHelper != null) {
behaviorStateHelper.restoreState(context, stateObject[1]);
}
- }
+ }
restoreBindings(context, stateObject[2]);
}
}
-
+
// Utility for saving bindings state
private static Object saveBindings(FacesContext context, Map<String, ValueExpression> bindings) {
@@ -132,7 +130,7 @@
return (null);
}
- Object values[] = new Object[2];
+ Object[] values = new Object[2];
values[0] = bindings.keySet().toArray(new String[bindings.size()]);
Object[] bindingValues = bindings.values().toArray();
@@ -144,30 +142,30 @@
return (values);
}
-
+
// Utility for restoring bindings from state
private static Map<String, ValueExpression> restoreBindings(FacesContext context, Object state) {
if (state == null) {
return (null);
}
-
- Object values[] = (Object[]) state;
- String names[] = (String[]) values[0];
- Object states[] = (Object[]) values[1];
+
+ Object[] values = (Object[]) state;
+ String[] names = (String[]) values[0];
+ Object[] states = (Object[]) values[1];
Map<String, ValueExpression> bindings = new HashMap<String, ValueExpression>(names.length);
for (int i = 0; i < names.length; i++) {
bindings.put(names[i], (ValueExpression) UIComponentBase.restoreAttachedState(context, states[i]));
}
return (bindings);
}
-
+
protected boolean compare(Serializable key, String name) {
boolean retValue = false;
- if(key != null) {
+ if (key != null) {
String keyName = key.toString();
retValue = keyName.equals(name);
- }
+ }
return retValue;
}
Modified: root/ui-sandbox/trunk/components/componentcontrol/src/main/java/org/richfaces/component/behavior/ComponentControlBehavior.java
===================================================================
--- root/ui-sandbox/trunk/components/componentcontrol/src/main/java/org/richfaces/component/behavior/ComponentControlBehavior.java 2010-05-02 23:44:02 UTC (rev 16865)
+++ root/ui-sandbox/trunk/components/componentcontrol/src/main/java/org/richfaces/component/behavior/ComponentControlBehavior.java 2010-05-03 09:58:02 UTC (rev 16866)
@@ -8,72 +8,71 @@
/**
* @author Anton Belevich
- *
+ *
*/
-@FacesBehavior(value="org.richfaces.behavior.ComponentControlBehavior")
+@FacesBehavior(value = "org.richfaces.behavior.ComponentControlBehavior")
public class ComponentControlBehavior extends ClientBehavior {
-
+
public static final String BEHAVIOR_ID = "org.richfaces.behavior.ComponentControlBehavior";
-
+
private List<UIComponent> children;
-
+
enum PropertyKeys {
event, target, selector, parameters, operation
}
-
-
+
public List<UIComponent> getChildren() {
- if(children == null) {
+ if (children == null) {
children = new ArrayList<UIComponent>();
}
return children;
}
-
+
public String getEvent() {
- return (String)getStateHelper().eval(PropertyKeys.event);
+ return (String) getStateHelper().eval(PropertyKeys.event);
}
-
+
public void setEvent(String eventName) {
getStateHelper().eval(PropertyKeys.event, eventName);
}
-
+
public String getTarget() {
- return (String)getStateHelper().eval(PropertyKeys.target);
+ return (String) getStateHelper().eval(PropertyKeys.target);
}
-
+
public void setTarget(String target) {
getStateHelper().put(PropertyKeys.target, target);
}
-
+
public String getSelector() {
- return (String)getStateHelper().eval(PropertyKeys.selector);
+ return (String) getStateHelper().eval(PropertyKeys.selector);
}
-
+
public void setSelector(String selector) {
getStateHelper().put(PropertyKeys.selector, selector);
}
-
+
public String getOperation() {
- return (String)getStateHelper().eval(PropertyKeys.operation);
+ return (String) getStateHelper().eval(PropertyKeys.operation);
}
-
+
public void setOperation(String operation) {
getStateHelper().put(PropertyKeys.operation, operation);
}
-
+
@Override
public String getRendererType() {
return BEHAVIOR_ID;
}
-
+
@Override
public void setLiteralAttribute(String name, Object value) {
- if(compare(PropertyKeys.operation, name)) {
- setOperation((String)value);
- } else if(compare(PropertyKeys.target, name)) {
- setTarget((String)value);
- } else if(compare(PropertyKeys.selector, name)) {
- setSelector((String)name);
+ if (compare(PropertyKeys.operation, name)) {
+ setOperation((String) value);
+ } else if (compare(PropertyKeys.target, name)) {
+ setTarget((String) value);
+ } else if (compare(PropertyKeys.selector, name)) {
+ setSelector((String) name);
}
}
}
Modified: root/ui-sandbox/trunk/components/componentcontrol/src/main/java/org/richfaces/renderkit/ComponentControlBehaviorRenderer.java
===================================================================
--- root/ui-sandbox/trunk/components/componentcontrol/src/main/java/org/richfaces/renderkit/ComponentControlBehaviorRenderer.java 2010-05-02 23:44:02 UTC (rev 16865)
+++ root/ui-sandbox/trunk/components/componentcontrol/src/main/java/org/richfaces/renderkit/ComponentControlBehaviorRenderer.java 2010-05-03 09:58:02 UTC (rev 16866)
@@ -22,93 +22,89 @@
import org.richfaces.component.UIHashParameter;
import org.richfaces.component.behavior.ComponentControlBehavior;
-
/**
* @author Anton Belevich
- *
+ *
*/
-@FacesBehaviorRenderer(rendererType="org.richfaces.behavior.ComponentControlBehavior", renderKitId=RenderKitFactory.HTML_BASIC_RENDER_KIT)
-@ResourceDependencies( {@ResourceDependency(library = "javax.faces", name = "jsf.js"),
- @ResourceDependency(name = "jquery.js"),
- @ResourceDependency(name = "richfaces.js"),
- @ResourceDependency(name= "richfaces-event.js"),
- @ResourceDependency(name = "richfaces-queue.js"),
+@FacesBehaviorRenderer(rendererType = "org.richfaces.behavior.ComponentControlBehavior", renderKitId = RenderKitFactory.HTML_BASIC_RENDER_KIT)
+@ResourceDependencies( { @ResourceDependency(library = "javax.faces", name = "jsf.js"),
+ @ResourceDependency(name = "jquery.js"), @ResourceDependency(name = "richfaces.js"),
+ @ResourceDependency(name = "richfaces-event.js"), @ResourceDependency(name = "richfaces-queue.js"),
@ResourceDependency(name = "richfaces-base-component.js"),
- @ResourceDependency(name = "script/component-control.js")
-})
+ @ResourceDependency(name = "script/component-control.js") })
public class ComponentControlBehaviorRenderer extends ClientBehaviorRenderer {
-
+
private static final String FUNC_NAME = "RichFaces.ui.ComponentControl.execute";
-
+
private static final String REF_EVENT = "event";
private static final String REF_COMPONENT = "component";
-
+
private static final String PARAM_CALLBACK = "callback";
private static final String PARAM_TARGET = "target";
-
+
private static final String PARAM_SELECTOR = "selector";
-
+
@Override
public String getScript(ClientBehaviorContext behaviorContext, ClientBehavior behavior) {
- ComponentControlBehavior controlBehavior = (ComponentControlBehavior)behavior;
-
+ ComponentControlBehavior controlBehavior = (ComponentControlBehavior) behavior;
+
JSFunctionDefinition callback = new JSFunctionDefinition();
callback.addParameter(new JSReference(REF_EVENT));
callback.addParameter(new JSReference(REF_COMPONENT));
String apiFunctionName = controlBehavior.getOperation();
-
- //create callback function
+
+ // create callback function
StringBuffer script = new StringBuffer();
script.append(REF_COMPONENT).append("['").append(apiFunctionName).append("'].").append("apply").append("(");
-
- //get client api function parameters
+
+ // get client api function parameters
List<Object> apiFunctionParams = createSignature(controlBehavior);
script.append(REF_COMPONENT).append(",").append(ScriptUtils.toScript(apiFunctionParams.toArray())).append(");");
callback.addToBody(script);
-
+
String target = controlBehavior.getTarget();
- String selector = controlBehavior.getSelector();
-
+ String selector = controlBehavior.getSelector();
+
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put(PARAM_CALLBACK, callback);
parameters.put(PARAM_TARGET, target);
parameters.put(PARAM_SELECTOR, selector);
-
- //execution function
+
+ // execution function
JSFunction eventFunction = new JSFunction(FUNC_NAME);
eventFunction.addParameter(new JSReference(REF_EVENT));
eventFunction.addParameter(parameters);
-
+
StringBuffer execution = new StringBuffer();
execution.append(eventFunction.toScript());
execution.append("; return false;");
return execution.toString();
}
-
+
protected List<Object> createSignature(ComponentControlBehavior behavior) {
List<Object> elements = new ArrayList<Object>();
List<UIComponent> children = behavior.getChildren();
- for(UIComponent child: children) {
- if(child instanceof UIParameter) {
- UIParameter parameter = (UIParameter)child;
+ for (UIComponent child : children) {
+ if (child instanceof UIParameter) {
+ UIParameter parameter = (UIParameter) child;
Object value = parameter.getValue();
- if(value != null) {
+ if (value != null) {
elements.add(value);
- }
+ }
}
-
- if(child instanceof UIHashParameter) {
- UIHashParameter parameter = (UIHashParameter)child;
+
+ if (child instanceof UIHashParameter) {
+ UIHashParameter parameter = (UIHashParameter) child;
String name = parameter.getName();
Map<String, Object> value = parameter.getValue();
-
- if(value != null) {
- if(name != null) {
+
+ if (value != null) {
+ if (name != null) {
Map<String, Object> map = new HashMap<String, Object>();
map.put(name, value);
elements.add(map);
@@ -121,4 +117,3 @@
return elements;
}
}
-
Modified: root/ui-sandbox/trunk/components/componentcontrol/src/main/java/org/richfaces/tag/BehaviorRule.java
===================================================================
--- root/ui-sandbox/trunk/components/componentcontrol/src/main/java/org/richfaces/tag/BehaviorRule.java 2010-05-02 23:44:02 UTC (rev 16865)
+++ root/ui-sandbox/trunk/components/componentcontrol/src/main/java/org/richfaces/tag/BehaviorRule.java 2010-05-03 09:58:02 UTC (rev 16866)
@@ -12,17 +12,17 @@
/**
* @author Anton Belevich
- *
+ *
*/
public class BehaviorRule extends MetaRule {
-
+
private static Logger log = RichfacesLogger.CONNECTION.getLogger();
-
- final static class LiteralAttributeMetadata extends Metadata {
+ static final class LiteralAttributeMetadata extends Metadata {
+
private final String name;
private final String value;
-
+
public LiteralAttributeMetadata(String name, String value) {
this.value = value;
this.name = name;
@@ -32,17 +32,16 @@
((ClientBehavior) instance).setLiteralAttribute(this.name, this.value);
}
}
-
- final static class ValueExpressionMetadata extends Metadata {
+ static final class ValueExpressionMetadata extends Metadata {
+
private final String name;
private final TagAttribute attr;
private final Class type;
- public ValueExpressionMetadata(String name, Class type,
- TagAttribute attr) {
+ public ValueExpressionMetadata(String name, Class type, TagAttribute attr) {
this.name = name;
this.attr = attr;
this.type = type;
@@ -53,26 +52,28 @@
}
}
-
+
@Override
public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget meta) {
- if(meta.isTargetInstanceOf(ClientBehavior.class)) {
- if(!attribute.isLiteral()) {
+ if (meta.isTargetInstanceOf(ClientBehavior.class)) {
+ if (!attribute.isLiteral()) {
Class type = meta.getPropertyType(name);
if (type == null) {
type = Object.class;
}
return new ValueExpressionMetadata(name, type, attribute);
- } else if(meta.getWriteMethod(name) == null) {
-
- if(log.isDebugEnabled()) {
- log.debug(attribute + " Property '" + name + "' is not on type: " + meta.getTargetClass().getName());
+ } else if (meta.getWriteMethod(name) == null) {
+
+ if (log.isDebugEnabled()) {
+ log
+ .debug(attribute + " Property '" + name + "' is not on type: "
+ + meta.getTargetClass().getName());
}
return new LiteralAttributeMetadata(name, attribute.getValue());
}
}
-
+
return null;
}
}
Modified: root/ui-sandbox/trunk/components/componentcontrol/src/main/java/org/richfaces/tag/BehaviorTagHandlerDelegate.java
===================================================================
--- root/ui-sandbox/trunk/components/componentcontrol/src/main/java/org/richfaces/tag/BehaviorTagHandlerDelegate.java 2010-05-02 23:44:02 UTC (rev 16865)
+++ root/ui-sandbox/trunk/components/componentcontrol/src/main/java/org/richfaces/tag/BehaviorTagHandlerDelegate.java 2010-05-03 09:58:02 UTC (rev 16866)
@@ -11,45 +11,45 @@
/**
* @author Anton Belevich
- *
+ *
*/
-public class BehaviorTagHandlerDelegate extends TagHandlerDelegate implements AttachedObjectHandler {
-
+public class BehaviorTagHandlerDelegate extends TagHandlerDelegate implements AttachedObjectHandler {
+
TagHandlerDelegate wrappedHandlerDelegate;
-
+
CustomBehaviorHandler owner;
-
+
public BehaviorTagHandlerDelegate(CustomBehaviorHandler owner, TagHandlerDelegate wrappedHandlerDelegate) {
this.owner = owner;
this.wrappedHandlerDelegate = wrappedHandlerDelegate;
}
-
+
@Override
public void apply(FaceletContext ctx, UIComponent comp) throws IOException {
- if(owner.isWrapping()) {
- //TODO: anton create behavior and place it in BehaviorStack
+ if (owner.isWrapping()) {
+ // TODO: anton create behavior and place it in BehaviorStack
owner.applyNextHandler(ctx, comp);
} else {
wrappedHandlerDelegate.apply(ctx, comp);
- }
+ }
}
-
+
@Override
public MetaRuleset createMetaRuleset(Class type) {
- MetaRuleset metaRuleset = wrappedHandlerDelegate.createMetaRuleset(type);
+ MetaRuleset metaRuleset = wrappedHandlerDelegate.createMetaRuleset(type);
metaRuleset.addRule(new BehaviorRule());
return metaRuleset;
}
public void applyAttachedObject(FacesContext context, UIComponent parent) {
- if(wrappedHandlerDelegate instanceof AttachedObjectHandler) {
- ((AttachedObjectHandler)wrappedHandlerDelegate).applyAttachedObject(context, parent);
+ if (wrappedHandlerDelegate instanceof AttachedObjectHandler) {
+ ((AttachedObjectHandler) wrappedHandlerDelegate).applyAttachedObject(context, parent);
}
}
public String getFor() {
- if(wrappedHandlerDelegate instanceof AttachedObjectHandler) {
- return ((AttachedObjectHandler)wrappedHandlerDelegate).getFor();
+ if (wrappedHandlerDelegate instanceof AttachedObjectHandler) {
+ return ((AttachedObjectHandler) wrappedHandlerDelegate).getFor();
}
return null;
}
Modified: root/ui-sandbox/trunk/components/componentcontrol/src/main/java/org/richfaces/tag/CustomBehaviorHandler.java
===================================================================
--- root/ui-sandbox/trunk/components/componentcontrol/src/main/java/org/richfaces/tag/CustomBehaviorHandler.java 2010-05-02 23:44:02 UTC (rev 16865)
+++ root/ui-sandbox/trunk/components/componentcontrol/src/main/java/org/richfaces/tag/CustomBehaviorHandler.java 2010-05-03 09:58:02 UTC (rev 16866)
@@ -4,25 +4,24 @@
import javax.faces.view.facelets.BehaviorHandler;
import javax.faces.view.facelets.TagHandlerDelegate;
-
/**
* @author Anton Belevich
- *
+ *
*/
public abstract class CustomBehaviorHandler extends BehaviorHandler {
TagHandlerDelegate helper;
-
+
public CustomBehaviorHandler(BehaviorConfig config) {
super(config);
}
-
+
public abstract boolean isWrapping();
-
+
@Override
protected TagHandlerDelegate getTagHandlerDelegate() {
- if(helper == null) {
- helper = new BehaviorTagHandlerDelegate(this, delegateFactory.createBehaviorHandlerDelegate(this));
+ if (helper == null) {
+ helper = new BehaviorTagHandlerDelegate(this, delegateFactory.createBehaviorHandlerDelegate(this));
}
return helper;
}
Modified: root/ui-sandbox/trunk/components/componentcontrol/src/main/java/org/richfaces/taglib/ComponentControlHandler.java
===================================================================
--- root/ui-sandbox/trunk/components/componentcontrol/src/main/java/org/richfaces/taglib/ComponentControlHandler.java 2010-05-02 23:44:02 UTC (rev 16865)
+++ root/ui-sandbox/trunk/components/componentcontrol/src/main/java/org/richfaces/taglib/ComponentControlHandler.java 2010-05-03 09:58:02 UTC (rev 16866)
@@ -22,72 +22,72 @@
/**
* @author Anton Belevich
- *
+ *
*/
public class ComponentControlHandler extends CustomBehaviorHandler {
-
+
public ComponentControlHandler(BehaviorConfig config) {
super(config);
}
-
+
@Override
public void apply(FaceletContext ctx, UIComponent parent) throws IOException {
super.apply(ctx, parent);
processNestedTags(ctx, parent);
}
-
-
+
private void processNestedTags(FaceletContext ctx, UIComponent parent) throws IOException {
- if(nextHandler instanceof CompositeFaceletHandler) {
- FaceletHandler [] children = ((CompositeFaceletHandler)nextHandler).getHandlers();
- for (FaceletHandler handler: children) {
+ if (nextHandler instanceof CompositeFaceletHandler) {
+ FaceletHandler[] children = ((CompositeFaceletHandler) nextHandler).getHandlers();
+ for (FaceletHandler handler : children) {
processNextHandler(ctx, handler, parent);
}
} else {
processNextHandler(ctx, nextHandler, parent);
}
}
-
+
private void processNextHandler(FaceletContext ctx, FaceletHandler handler, UIComponent parent) throws IOException {
- if(handler instanceof ComponentHandler) {
+ if (handler instanceof ComponentHandler) {
ComponentHandler componentHandler = (ComponentHandler) handler;
-
- ComponentConfig componentConfig = componentHandler.getComponentConfig();
- String componentType = componentConfig.getComponentType();
-
- if(isUIParameter(componentType)) {
+
+ ComponentConfig componentConfig = componentHandler.getComponentConfig();
+ String componentType = componentConfig.getComponentType();
+
+ if (isUIParameter(componentType)) {
FacesContext facesContext = ctx.getFacesContext();
-
- UIComponent component = (UIComponent)facesContext.getApplication().createComponent(facesContext, componentType, null);
+
+ UIComponent component = (UIComponent) facesContext.getApplication().createComponent(facesContext,
+ componentType, null);
componentHandler.setAttributes(ctx, component);
-
- if(parent instanceof ClientBehaviorHolder) {
- ClientBehaviorHolder clientBehaviorHolder = ((ClientBehaviorHolder)parent);
- Map<String, List<ClientBehavior>> clientBehaviors = clientBehaviorHolder.getClientBehaviors();
-
- String eventName = getEventName();
-
- if(eventName == null) {
- eventName = clientBehaviorHolder.getDefaultEventName();
- }
-
- if(eventName != null) {
- List<ClientBehavior> eventClientBehaviors = clientBehaviors.get(eventName);
- for(ClientBehavior clientBehavior: eventClientBehaviors) {
- if(clientBehavior instanceof ComponentControlBehavior) {
- ((ComponentControlBehavior)clientBehavior).getChildren().add(component);
- }
- }
- }
+
+ if (parent instanceof ClientBehaviorHolder) {
+ ClientBehaviorHolder clientBehaviorHolder = ((ClientBehaviorHolder) parent);
+ Map<String, List<ClientBehavior>> clientBehaviors = clientBehaviorHolder.getClientBehaviors();
+
+ String eventName = getEventName();
+
+ if (eventName == null) {
+ eventName = clientBehaviorHolder.getDefaultEventName();
+ }
+
+ if (eventName != null) {
+ List<ClientBehavior> eventClientBehaviors = clientBehaviors.get(eventName);
+ for (ClientBehavior clientBehavior : eventClientBehaviors) {
+ if (clientBehavior instanceof ComponentControlBehavior) {
+ ((ComponentControlBehavior) clientBehavior).getChildren().add(component);
+ }
+ }
+ }
}
-
+
componentHandler.applyNextHandler(ctx, component);
}
- }
+ }
}
-
+
private boolean isUIParameter(String type) {
- return (UIParameter.COMPONENT_TYPE.equals(type) || UIHashParameter.COMPONENT_TYPE.equals(type));
+ return (UIParameter.COMPONENT_TYPE.equals(type) || UIHashParameter.COMPONENT_TYPE.equals(type));
}
@Override
@@ -95,4 +95,3 @@
return false;
}
}
-
14 years, 7 months
JBoss Rich Faces SVN: r16865 - branches/community/3.3.X/ui/calendar/src/main/java/org/richfaces/renderkit/html/iconimages.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-05-02 19:44:02 -0400 (Sun, 02 May 2010)
New Revision: 16865
Modified:
branches/community/3.3.X/ui/calendar/src/main/java/org/richfaces/renderkit/html/iconimages/CalendarIcon.java
branches/community/3.3.X/ui/calendar/src/main/java/org/richfaces/renderkit/html/iconimages/DisabledCalendarIcon.java
Log:
https://jira.jboss.org/jira/browse/RF-8610
https://jira.jboss.org/jira/browse/RFPL-566
Modified: branches/community/3.3.X/ui/calendar/src/main/java/org/richfaces/renderkit/html/iconimages/CalendarIcon.java
===================================================================
--- branches/community/3.3.X/ui/calendar/src/main/java/org/richfaces/renderkit/html/iconimages/CalendarIcon.java 2010-04-30 19:35:18 UTC (rev 16864)
+++ branches/community/3.3.X/ui/calendar/src/main/java/org/richfaces/renderkit/html/iconimages/CalendarIcon.java 2010-05-02 23:44:02 UTC (rev 16865)
@@ -51,9 +51,9 @@
public class CalendarIcon extends Java2Dresource {
private static Dimension dimension = new Dimension(20, 20);
-
+
/**
- *
+ *
*/
public CalendarIcon() {
setRenderer(new GifRenderer());
@@ -68,7 +68,7 @@
// TODO Auto-generated method stub
return dimension;
}
-
+
/* (non-Javadoc)
* @see org.ajax4jsf.resource.Java2Dresource#getDimensions(org.ajax4jsf.resource.ResourceContext)
*/
@@ -76,52 +76,52 @@
// TODO Auto-generated method stub
return dimension;
}
-
+
protected Object getDataToStore(FacesContext context, Object data) {
Skin skin = SkinFactory.getInstance().getSkin(context);
Skin defaultSkin = SkinFactory.getInstance().getDefaultSkin(context);
-
+
String skinParameter = "headerBackgroundColor";
String headerTextColor = (String) skin.getParameter(context, skinParameter);
if (null == headerTextColor || "".equals(headerTextColor))
headerTextColor = (String) defaultSkin.getParameter(context, skinParameter);
-
+
if (headerTextColor == null) {
return null;
}
-
-
+
+
skinParameter = "selectControlColor";
String headerBackgroundColor = (String) skin.getParameter(context, skinParameter);
if (null == headerBackgroundColor || "".equals(headerBackgroundColor))
headerBackgroundColor = (String) defaultSkin.getParameter(context, skinParameter);
-
+
if(headerBackgroundColor == null){
return null;
}
-
+
byte[] ret = new byte[6];
Zipper2 zipper2 = new Zipper2(ret).addColor(HtmlColor.decode(headerTextColor).getRGB());
zipper2.addColor(HtmlColor.decode(headerBackgroundColor).getRGB());
return ret;
}
-
+
protected Object deserializeData(byte[] objectArray) {
if (objectArray == null) {
return null;
}
-
+
Object[] colors = new Object[2];
Zipper2 z = new Zipper2(objectArray);
colors[0] = z.nextColor();
colors[1] = z.nextColor();
-
+
return colors;
}
-
+
public void paint(ResourceContext context, Graphics2D graphics) {
-
+
Object[] stored = (Object[]) restoreData(context);
if (stored != null) {
Dimension dim = getDimensions(context);
@@ -129,36 +129,40 @@
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
graphics.drawImage(image, 0, 0, dim.width, dim.height, null);
-
+
}
-
+
}
+ protected BufferedImage createImage(int width, int height) {
+ return new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
+ }
+
protected BufferedImage paintImage(Object [] colors) {
- BufferedImage image = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
-
+ BufferedImage image = createImage(16, 16);
+
Graphics2D g2d = image.createGraphics();
-
+
Color borderColor = (Color) colors[0];//new Color(((Integer) stored[0]).intValue());
Color activeColor = (Color) colors[1];//new Color(((Integer) stored[1]).intValue());
-
+
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
-
+
g2d.setStroke(new BasicStroke(1));
-
+
int w = 16;
int h = 16;
-
-
+
+
//Draw Border
g2d.setColor(borderColor);
Rectangle2D border = new Rectangle2D.Double(1, 1, w - 3, h - 3);
RoundRectangle2D round = new RoundRectangle2D.Double(1, 1, w- 3, h - 3, 2, 2);
g2d.draw(round);
-
+
Color lightBlue = new Color(216, 226, 240);
Paint gradient1 = new GradientPaint(w-4, h-4, lightBlue, 2, 2, Color.white);
g2d.setPaint(gradient1);
@@ -176,36 +180,36 @@
g2d.drawLine(7, 6, 7, 11);
g2d.drawLine(9, 6, 9, 11);
g2d.drawLine(11, 6, 11, 11);
-
-
-
-
-
+
+
+
+
+
//Draw orange rectangle
border = new Rectangle2D.Double(3, 3, 10, 3);
g2d.setColor(Color.white);
g2d.fill(border);
-
+
Color c = new Color(activeColor.getRed(), activeColor.getGreen(), activeColor.getBlue(), 100);
Color c2 = new Color(activeColor.getRed(), activeColor.getGreen(), activeColor.getBlue(), 200);
-
+
gradient1 = new GradientPaint(12, 4, activeColor, 4, 7, c2);
g2d.setPaint(gradient1);
g2d.fill(border);
//g2d.setColor(activeColor);
-
+
c = new Color(activeColor.getRed(), activeColor.getGreen(), activeColor.getBlue(), 150);
c2 = new Color(activeColor.getRed(), activeColor.getGreen(), activeColor.getBlue(), 200);
border = new Rectangle2D.Double(4, 4, 8, 1);
-
+
g2d.setColor(Color.white);
g2d.fill(border);
-
+
gradient1 = new GradientPaint(4, 4, c, 10, 4, c2);
//g2d.setPaint(gradient1);
g2d.setColor(c);
g2d.fill(border);
-
+
g2d.dispose();
return image;
Modified: branches/community/3.3.X/ui/calendar/src/main/java/org/richfaces/renderkit/html/iconimages/DisabledCalendarIcon.java
===================================================================
--- branches/community/3.3.X/ui/calendar/src/main/java/org/richfaces/renderkit/html/iconimages/DisabledCalendarIcon.java 2010-04-30 19:35:18 UTC (rev 16864)
+++ branches/community/3.3.X/ui/calendar/src/main/java/org/richfaces/renderkit/html/iconimages/DisabledCalendarIcon.java 2010-05-02 23:44:02 UTC (rev 16865)
@@ -21,25 +21,29 @@
package org.richfaces.renderkit.html.iconimages;
+import java.awt.Transparency;
import java.awt.color.ColorSpace;
import java.awt.image.BufferedImage;
-import java.awt.image.ColorConvertOp;
+import java.awt.image.ComponentColorModel;
+import java.awt.image.DataBuffer;
+import java.awt.image.WritableRaster;
/**
* @author Maksim Kaszynski
*
*/
public class DisabledCalendarIcon extends CalendarIcon {
-
- /* (non-Javadoc)
- * @see org.richfaces.renderkit.html.iconimages.CalendarIcon#paintImage(java.lang.Object[])
- */
- protected BufferedImage paintImage(Object[] colors) {
-
- BufferedImage image = super.paintImage(colors);
-
- image = new ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_GRAY), null).filter(image, null);
-
- return image;
+
+ @Override
+ protected BufferedImage createImage(int width, int height) {
+ ColorSpace gsColorSpace = ColorSpace.getInstance(ColorSpace.CS_GRAY);
+
+ ComponentColorModel ccm = new ComponentColorModel(gsColorSpace, true, false,
+ Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE);
+
+ WritableRaster raster = ccm.createCompatibleWritableRaster(width, height);
+
+ return new BufferedImage(ccm, raster, ccm.isAlphaPremultiplied(), null);
}
+
}
14 years, 7 months