Package org.geoforge.guillc.dialog

Source Code of org.geoforge.guillc.dialog.GfrDlgNewSettingsXloNamAbs

/*
*  Copyright (C) 2011-2014 GeoForge Project
*
*  This program 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 3 of the License, or
*  (at your option) any later version.
*
*  This program 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 program.  If not, see <http://www.gnu.org/licenses/>.
*/

package org.geoforge.guillc.dialog;

import javax.swing.JFrame;
import org.geoforge.guillc.border.GfrFactoryBorder;
import org.geoforge.guillc.event.GfrEvtPanelChange;
import org.geoforge.guillc.handler.IGfrHandlerListenerPanelDialog;
import org.geoforge.guillc.event.GfrEvtValidityChanged;
import org.geoforge.guillc.panel.GfrPnlGrpTxfFullEditableYes;
import org.geoforge.guillc.panel.GfrPnlSelEdt;
import org.geoforge.lang.util.GfrResBundleLang;
import org.geoforge.java.lang.string.GfrUtlString;

/**
*
* @author Amadeus.Sowerby
*
* email: Amadeus.Sowerby_AT_gmail.com
* ... please remove "_AT_" from the above string to get the right email address
*/
abstract public class GfrDlgNewSettingsXloNamAbs extends GfrDlgCmdCancelOkExtItmLstUnselectableAbs
{

   //--
   //-- beg private fields
   private String _strWhat_ = null;
   //--end private fields
   //--
   //--
   //--beg protected fields

   protected GfrPnlGrpTxfFullEditableYes _pnlName = null;

   protected GfrPnlSelEdt _pnlGeneral = null;
   //--end protected fields
   //--

   public String getValueName()
   {
      return this._pnlName.getValue();
   }

   //--
   //-- beg private methods
   protected boolean _doesNameEnableOk()
   {
      String strName = this._pnlName.getValue();

      if (strName == null || strName.length() < 1)
         return false;

      if (super._alreadyExists(strName))
      {
         validityChanged(new GfrEvtValidityChanged(false, "Name already exists"));
         return false;
      }

      return true;
   }

   protected boolean _doesNameHaveNoError()
   {
      String strName = this._pnlName.getValue();

      if (strName == null || strName.length() < 1)
         return true;

      return _doesNameEnableOk();
   }
   //-- end private methods
   //--

   //--
   //--beg protected methods
   @Override
   protected boolean _okEnableable()
   {
      return _doesNameEnableOk();
   }

   @Override
   protected boolean _noErrorToDisplay()
   {
      return _doesNameHaveNoError();
   }

   @Override
   protected void _updateModifiedFieldStatus(GfrEvtPanelChange e)
   {
      Object objSource = e.getSource();

      if (objSource.equals(this._pnlName))
      {
         this._pnlName.setValueIsOk(this._doesNameEnableOk());
         return;
      }


   }
   //--end protected methods
   //--

   protected GfrDlgNewSettingsXloNamAbs(
           JFrame frmOwner,
           String strWhat,
           String strSentence,
           String[] strsExistingItems)
   {
      super(
              frmOwner,
              strsExistingItems,
              strSentence);

      this._pnlGeneral = new GfrPnlSelEdt();

      this._pnlName = new GfrPnlGrpTxfFullEditableYes(
              GfrResBundleLang.s_getInstance().getValue("word.name"));

      super.addToListResizable(this._pnlName);

      this._pnlName.addPanelListener((IGfrHandlerListenerPanelDialog) this);
      this._strWhat_ = strWhat;
   }

   @Override
   public boolean init()
   {
      if (!super.init())
         return false;

      if (!this._pnlGeneral.init())
         return false;

      if (!this._pnlName.init())
         return false;

      this._pnlName.setMandatoryIcon(true);

      //Panel General
      this._pnlGeneral.setBorder(GfrFactoryBorder.createTitledBorder(
              GfrResBundleLang.s_getInstance().getValue("word.General")));

      this._pnlGeneral.addWithSpace(this._pnlName);

      super._pnlContent.addWithSpace(this._pnlGeneral);

      this._pnlName.setContent(
              GfrUtlString.s_createUniqueNameByNumber(super.getExistingsItems(), this._strWhat_));

      this._pnlName.selectText();


      return true;
   }

   @Override
   public void destroy()
   {
      super.destroy();

      if (this._pnlGeneral != null)
      {
         this._pnlGeneral.destroy();
         this._pnlGeneral = null;
      }

      if (this._pnlName != null)
      {
         this._pnlName.destroy();
         this._pnlName = null;
      }

   }

}
TOP

Related Classes of org.geoforge.guillc.dialog.GfrDlgNewSettingsXloNamAbs

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.