UnFilePickListener.java :  » J2EE » WiSerFramework » de » ug2t » unifiedGui » listener » Java Open Source

Java Open Source » J2EE » WiSerFramework 
WiSerFramework » de » ug2t » unifiedGui » listener » UnFilePickListener.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.unifiedGui.listener;

import de.ug2t.kernel.*;
import de.ug2t.unifiedGui.*;
import de.ug2t.unifiedGui.interfaces.*;

public class UnFilePickListener implements IUnGuiEventListener
{
  protected UnComponent  pdm_target   = null;
  private IUnFileChooser pem_fc       = null;
  protected String       pdm_prefix   = "file:///";
  private String         pem_pickMode = "READ_FILE";

  class UnFilePickHelper implements IUnGuiEventListener
  {
    public void pcmf_execListener(UnComponent xParam) throws Exception
    {
      String l_val = UnFilePickListener.this.pdm_prefix + xParam.pcmf_getValue();
      UnFilePickListener.this.pdm_target.pcmf_setValue(l_val.replace('\\', '/'));

      return;
    }
  }

  /**
   * 
   */
  public UnFilePickListener(UnComponent xCopy, IUnFileChooser xFc, String xPrefix)
  {
    this.pdm_target = xCopy;
    this.pem_fc = xFc;
    this.pdm_prefix = xPrefix;
    xFc.pcmf_getUnComponent().pcmf_addListener(new UnFilePickHelper());
  }

  public UnFilePickListener(UnComponent xCopy, IUnFileChooser xFc, String xPrefix, String xMode)
  {
    this.pdm_target = xCopy;
    this.pem_fc = xFc;
    this.pdm_prefix = xPrefix;
    this.pem_pickMode = xMode;
    xFc.pcmf_getUnComponent().pcmf_addListener(new UnFilePickHelper());
  }

  /**
   * 
   */
  public UnFilePickListener(UnComponent xCopy, IUnFileChooser xFc)
  {
    this.pdm_target = xCopy;
    this.pem_fc = xFc;
    xFc.pcmf_getUnComponent().pcmf_addListener(new UnFilePickHelper());
  }

  /**
   * <p>
   * Does...
   * </p>
   * <p>
   * 
   * @return a Type with
   *         </p>
   *         <p>
   * @param
   *         </p>
   */
  public void pcmf_execListener(UnComponent xParam) throws Exception
  {
    if (this.pem_pickMode.equals("DIR_FILE"))
      this.pem_fc.pcmf_selectFile();
    else if (this.pem_pickMode.equals("READ_FILE"))
      this.pem_fc.pcmf_selectReadFile();
    else if (this.pem_pickMode.equals("WRITE_FILE"))
      this.pem_fc.pcmf_selectWriteFile();
    else
    {
      KeLog.pcmf_log("ug2t", "no valid mode: " + this.pem_pickMode, this, KeLog.MESSAGE);
      this.pem_fc.pcmf_selectFile();
    }
  }
}
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.