Package net.helipilot50.stocktrade.client

Source Code of net.helipilot50.stocktrade.client.LoginWindow

package net.helipilot50.stocktrade.client;

import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.widget.HorizontalPanel;
import com.extjs.gxt.ui.client.widget.Info;
import com.extjs.gxt.ui.client.widget.MessageBox;
import com.extjs.gxt.ui.client.widget.Window;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.layout.FormData;
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;

public class LoginWindow extends Window {


  public LoginWindow() {

    setHeading("Login");
    setResizable(false);
    setClosable(false);
    setPagePosition(10, 10);
    setHeading("Login Window");
    setLayout(new FormLayout());

    final TextField<String> txtflUserID = new TextField<String>();
    add(txtflUserID);
    txtflUserID.setFieldLabel("Customer Name");

    HorizontalPanel horizontalPanel = new HorizontalPanel();
    horizontalPanel.setHorizontalAlign(HorizontalAlignment.CENTER);
    add(horizontalPanel, new FormData("100%"));

    Button btnAsCustomer = new Button("Customer");
    horizontalPanel.add(btnAsCustomer);

    Button btnAsTrader = new Button("Trader");
    horizontalPanel.add(btnAsTrader);

    Button btnSettings = new Button("...");
    btnSettings.addListener(Events.Select, new Listener<ButtonEvent>() {
      public void handleEvent(ButtonEvent e) {
        showPropertiesDialog();
      }
    });
    horizontalPanel.add(btnSettings);

    btnAsCustomer.addListener(Events.Select, new Listener<ButtonEvent>() {
      public void handleEvent(ButtonEvent e) {
        CustomerWindow customerWindow = new CustomerWindow((String)txtflUserID.getValue());
        customerWindow.show();
      }
    });

    btnAsTrader.addListener(Events.Select, new Listener<ButtonEvent>() {
      public void handleEvent(ButtonEvent e) {
        TraderWindow traderWindow = new TraderWindow();
        traderWindow.show();
      }
    });

  }

  private void showPropertiesDialog(){
    final PropertiesDialog propertiesDialog = new PropertiesDialog();
    TradeServiceAsync tradeSO = Registry.get("TradeService");
    tradeSO.getDBHost(new AsyncCallback<String>() {
     
      @Override
      public void onSuccess(String result) {
        String parts[] = result.split(":");
        propertiesDialog.setHostName(parts[0]);
        propertiesDialog.setPort(Integer.parseInt(parts[1]));
       
      }
     
      @Override
      public void onFailure(Throwable caught) {
        MessageBox.alert("Error getting DB properties", caught.getMessage(), null);
       
      }
    });
    propertiesDialog.show();
    String hostPortString = propertiesDialog.getHostString();
//    tradeSO.setDBHost(hostPortString, new AsyncCallback<Void>() {
//
//      @Override
//      public void onSuccess(Void result) {
//        Info.display("Success", "Properties saved");
//
//      }
//
//      @Override
//      public void onFailure(Throwable caught) {
//        MessageBox.alert("Could not save properties", caught.getMessage(), null);
//
//      }
//    });

  }
}
TOP

Related Classes of net.helipilot50.stocktrade.client.LoginWindow

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.