Package cookxml.cookswing.creator

Source Code of cookxml.cookswing.creator.MenuSplitCreator

/*
* (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.core.DecodeEngine;
import cookxml.core.exception.CreatorException;
import cookxml.core.interfaces.Creator;

/**
* Directly add a menu split to the parent menu.  Alternatively, using JSeparator
* has the same result, but it is probably a obscure method.
*
* @cxdoc
* This tag serves as a menu split inside a menu or popup menu.
*
* @cxexample
* <codeblock type="xml">
*   <menu>
*     <menuitem text="File"/>
*     <menuitem text="Open"/>
*     <menusplit/>
*     <menuitem text="Exit"/>
*   </menu>
* </codeblock>
*
* @author Heng Yuan
* @version $Id: MenuSplitCreator.java 251 2007-06-08 00:19:35Z coconut $
* @since CookSwing 1.0
*/
public class MenuSplitCreator implements Creator
{
  public Object create (String parentNS, String parentTag, Element elm, Object parentObj, DecodeEngine decodeEngine)
  {
    if (parentObj == null)
      return null;
    if (parentObj instanceof JMenu)
      ((JMenu)parentObj).addSeparator ();
    else if (parentObj instanceof JPopupMenu)
      ((JPopupMenu)parentObj).addSeparator ();
    else
      throw new CreatorException (decodeEngine, null, this, parentNS, parentTag, elm, parentObj);
    return null;
  }

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

Related Classes of cookxml.cookswing.creator.MenuSplitCreator

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.