Package cookxml.cookswing.creator

Source Code of cookxml.cookswing.creator.UIManagerCreator

/*
* (c) Copyright 2004 by Heng Yuan
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* ITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cookxml.cookswing.creator;

import javax.swing.*;

import org.w3c.dom.Element;

import cookxml.cookswing.helper.UIManagerHelper;
import cookxml.core.DecodeEngine;
import cookxml.core.interfaces.Creator;

/**
* This creator serves only one purpose, to obtain the value from UIManager using the
* value in the tag constructor attribute.
*
* @cxattr  ctor
*       Get a value from UIManager by calling {@link javax.swing.UIManager#get(Object)}.
*
* @see javax.swing.UIManager
* @author Heng Yuan
* @version $Id: UIManagerCreator.java 233 2007-06-06 08:08:49Z coconut $
* @since CookSwing 1.0
*/
public class UIManagerCreator implements Creator
{
  /** the attribute that indicates one needs to look up in the UIManager's property. */
  public static String UI_ATTR = "ui";

  public Object create (String parentNS, String parentTag, Element elm, Object parentObj, DecodeEngine decodeEngine)
  {
    String value = elm.getAttribute ("ctor");
    if (value.length () == 0)
      return new UIManagerHelper ();
    return UIManager.get (value);
  }

  public Object editFinished (String parentNS, String parentTag, Element elm, Object parentObj, Object obj, DecodeEngine decodeEngine)
  {
    return obj;
  }
}
TOP

Related Classes of cookxml.cookswing.creator.UIManagerCreator

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.