001 package com.sptci.rwt.webui;
002
003 import nextapp.echo2.app.Component;
004 import nextapp.echo2.app.Grid;
005 import nextapp.echo2.app.TextField;
006
007 import echopointng.PopUp;
008
009 import com.sptci.echo2.Utilities;
010 import com.sptci.echo2.View;
011
012 /**
013 * A component that is used to display the components necessary to
014 * prompt the user for entering information to save a JDBC connection.
015 *
016 * <p>© Copyright 2007 <a href='http://sptci.com/' target='_new'>Sans Pareil Technologies, Inc.</a></p>
017 * @author Rakesh Vidyadharan 2007-10-14
018 * @version $Id: SaveConnectionComponent.java 4123 2008-05-25 21:49:01Z rakesh $
019 */
020 public class SaveConnectionComponent extends Grid implements View
021 {
022 /** The component used to enter the name for the connection. */
023 private TextField name;
024
025 /** The controller to use to interact with the rest of the application. */
026 private final MainController controller;
027
028 /**
029 * Create a new instance with the specified controller.
030 *
031 * @param controller The controller to use to interact with the
032 * application.
033 */
034 public SaveConnectionComponent( final MainController controller )
035 {
036 this.controller = controller;
037 }
038
039 /**
040 * Life-cycle method used to initialise the component.
041 *
042 * @see #createName
043 */
044 @Override
045 public void init()
046 {
047 removeAll();
048 createName();
049 }
050
051 /**
052 * Initialise the {@link #name} component and its associated {@link
053 * nextapp.echo2.app.Label}.
054 */
055 protected void createName()
056 {
057 add( Utilities.createLabel(
058 getClass().getName(), "name", "Title.Label" ) );
059 add( Utilities.createTextField(
060 getClass().getName(), "name",
061 new SaveConnectionListener( controller ), this ) );
062 }
063
064 /**
065 * Return the value entered in {@link #name} field.
066 *
067 * @return The value entered or an empty string if no value was entered.
068 */
069 public String getName()
070 {
071 return name.getText();
072 }
073 }