MuGenericComboBox.java :  » J2EE » WiSerFramework » de » ug2t » channel » markup » generic » Java Open Source

Java Open Source » J2EE » WiSerFramework 
WiSerFramework » de » ug2t » channel » markup » generic » MuGenericComboBox.java
// @@
// @@
/*
 * Wi.Ser Framework
 *
 * Version: 1.8.1, 20-September-2007  
 * Copyright (C) 2005 Dirk von der Weiden <dvdw@imail.de>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library located in LGPL.txt in the 
 * license directory; if not, write to the 
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA  02111-1307, USA.
 * 
 * If this agreement does not cover your requirements, please contact us
 * via email to get detailed information about the commercial license 
 * or our service offerings!
 *
 */
// @@

package de.ug2t.channel.markup.generic;

import java.util.*;

import de.ug2t.channel.markup.html.renderer.*;
import de.ug2t.connector.*;
import de.ug2t.kernel.*;
import de.ug2t.unifiedGui.interfaces.*;

public final class MuGenericComboBox extends MuGenericComponent implements IUnComboBox, IKePoolable
{
  private HashMap pem_values = new LinkedHashMap();
  private IKeView pem_view   = new HtmlComboBoxRenderer();

  public MuGenericComboBox(String xName, String xValue, String xString, ACoDataGetter xTplGetter, Object xTplName, MuGenericApplication xAppl) throws Exception
  {
    super(xName, xTplGetter, xTplName, xAppl);

    this.pcmf_setView(pem_view);

    if (xString != null && xString.equals("") == false)
    {
      this.pcmf_addValue(xValue, xString);
      this.pcmf_setValue(xValue);
    }

    this.pcmf_setBgColor("white");

    return;
  };

  // @@

  public void pcmf_addValueObj(String xValue, KeRegisteredObject xObj)
  {
    if (xObj instanceof KeTreeNode)
      this.pcmf_addNode(xValue, (KeTreeNode) xObj);

    this.pcmf_addValue(xValue, xObj);
    this.pcmf_setPropChanged(true);
  }

  public void pcmf_addValue(String xValue, String xString)
  {
    pem_values.put(xValue, xString);
    this.pcmf_setPropChanged(true);
  };

  private void pcmf_addValue(String xValue, Object xString)
  {
    pem_values.put(xValue, xString);
    this.pcmf_setPropChanged(true);
  };

  public void pcmf_removeValue(String xValue)
  {
    pem_values.remove(xValue);
    this.pcmf_removeNode(xValue);
    this.pcmf_setPropChanged(true);
  };

  public HashMap pcmf_getValues()
  {
    return (pem_values);
  };

  public void pcmf_clearComboBox()
  {
    this.pem_values.clear();

    Iterator l_it = new ArrayList(this.pcmf_getAllSubs()).iterator();
    Object l_obj = null;
    while (l_it.hasNext())
    {
      l_obj = l_it.next();
      if (l_obj instanceof IUnContextMenu || l_obj instanceof IUnEventChannel)
        continue;

      this.pcmf_removeNode((KeTreeNode) l_obj);
    }

    this.pcmf_setPropChanged(true);
  }

  public void pcmf_clearAndReleaseComboBox()
  {
    this.pem_values.clear();

    Iterator l_it = new ArrayList(this.pcmf_getAllSubs()).iterator();
    Object l_obj = null;
    while (l_it.hasNext())
    {
      l_obj = l_it.next();
      if (l_obj instanceof IUnContextMenu || l_obj instanceof IUnEventChannel)
        continue;

      this.pcmf_removeNode((KeTreeNode) l_obj);
      ((KeTreeNode) l_obj).pcmf_releaseSubs();
    }

    this.pcmf_setPropChanged(true);
  }

  public Object pcmf_getSelectedObject()
  {
    int l_idx = this.pcmf_getSelectedRow();
    if (l_idx == -1)
      return (null);

    Object l_ret = this.pem_values.keySet().toArray()[l_idx];
    return (l_ret);
  }

  public Object pcmf_setSelectedRow(int xRow)
  {
    if (xRow >= this.pem_values.size())
      return (null);

    Object l_ret = this.pem_values.keySet().toArray()[xRow];
    this.pcmf_setValue(l_ret);

    return (l_ret);
  }

  public int pcmf_getSelectedRow()
  {
    return (new ArrayList(this.pem_values.keySet()).indexOf(this.pcmf_getValue()));
  }

  private boolean pem_readOnly = false;

  public void pcmf_setReadOnly(boolean xReadOnly)
  {
    if (this.pem_readOnly == xReadOnly)
      return;

    this.pem_readOnly = xReadOnly;
    this.pcmf_setPropChanged(true);
  }

  public boolean pcmf_isReadOnly()
  {
    return (this.pem_readOnly);
  }

  // @@

  public void pcmf_clearListWidget()
  {
    this.pcmf_clearComboBox();
  }

  public void pcmf_clearAndReleaseListWidget()
  {
    this.pcmf_clearAndReleaseComboBox();
  }

  public void pcmf_beginTr()
  {
    return;
  }

  public void pcmf_commitTr()
  {
    return;
  }

  public boolean pcmf_isSelectable()
  {
    return (true);
  }
};
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.