Package cookxml.cookswing.creator

Source Code of cookxml.cookswing.creator.SpringCreator

/*
* (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.SpringConstraintHelper;
import cookxml.cookswing.helper.SpringHelper;
import cookxml.core.DecodeEngine;
import cookxml.core.interfaces.Creator;

/**
* This creator is used to add the spring generated by the SpringHelper to the parent instead
* of the helper itself.
*
* @see cookxml.cookswing.helper.SpringHelper
* @see javax.swing.Spring
* @author Heng Yuan
* @version $Id: SpringCreator.java 233 2007-06-06 08:08:49Z coconut $
* @since CookSwing 1.0
*/
public class SpringCreator implements Creator
{
  public Object create (String parentNS, String parentTag, Element elm, Object parentObj, DecodeEngine decodeEngine)
  {
    return new SpringHelper ();
  }

  public Object editFinished (String parentNS, String parentTag, Element elm, Object parentObj, Object obj, DecodeEngine decodeEngine)
  {
    if (parentObj == null || obj == null ||
      !(obj instanceof SpringHelper))
      return obj;
    Object anc;

    anc = decodeEngine.getParent (parentObj);
    while (anc != null)
    {
      if (anc == null)
        return obj;
      if (anc instanceof SpringLayout)
        break;
      if (anc instanceof SpringConstraintHelper ||
        anc instanceof Spring)
      {
        anc = decodeEngine.getParent (anc);
        continue;
      }
      return obj;
    }
    obj = ((SpringHelper)obj).getSpring ((SpringLayout)anc);
    decodeEngine.addChild (parentNS, parentTag, elm, parentObj, obj);
    return obj;
  }
}
TOP

Related Classes of cookxml.cookswing.creator.SpringCreator

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.