home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2003 March / DPPCPRO0303.ISO / Components / Microsoft ASP / _SETUP.1 / ASPWizard.jar / asp / wizard / WizardSubDbQuery.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-11-20  |  8.2 KB  |  216 lines

  1. package asp.wizard;
  2.  
  3. import asp.netobjects.nfx.util.ExceptionHandler;
  4. import asp.netobjects.nfx.util.ExternalError;
  5. import asp.netobjects.nfx.util.InternalError;
  6. import asp.netobjects.nfx.wizard.Wizard;
  7. import asp.netobjects.nfx.wizard.WizardPage;
  8. import asp.netobjects.nfx.wizard.WizardView;
  9. import asp.util.EResourceUtil;
  10. import asp.util.ResourceUtil;
  11. import asp.wizard.def.DefConnection;
  12. import asp.wizard.util.UiUtil;
  13. import com.sun.java.swing.ImageIcon;
  14. import com.sun.java.swing.JFrame;
  15. import java.awt.Component;
  16. import java.awt.Dialog;
  17. import java.awt.Font;
  18. import java.awt.Frame;
  19. import java.awt.Window;
  20. import java.awt.event.ActionEvent;
  21. import java.awt.event.WindowEvent;
  22. import java.net.URL;
  23. import java.util.Hashtable;
  24. import java.util.Observable;
  25.  
  26. public class WizardSubDbQuery extends Wizard {
  27.    private static final String ID_LBL_TITLE = "window.title";
  28.    private static final String ID_BTN_BUILDSQL = "button.buildsql";
  29.    private static final String IMG_DIR = "image";
  30.    private static final String BUTTON_CANCEL = "button.cancel";
  31.    private static final String BUTTON_BACK = "button.back";
  32.    private static final String BUTTON_NEXT = "button.next";
  33.    private static final String BUTTON_FINISH = "button.finish";
  34.    private static WizardSubDbQuery _instance = null;
  35.    private DefConnection _defConnection;
  36.    private WizardModelDbQuery _owner;
  37.    private ResourceUtil _resourceUtil;
  38.    private SubDBQueryData _data = new SubDBQueryData();
  39.  
  40.    public static void main(String[] args) {
  41.       JFrame f = new JFrame();
  42.       WizardSubDbQuery wiz = new WizardSubDbQuery(f, "Test", (String)null, 540, 400, (ExceptionHandler)null);
  43.       WizardView wv = ((Wizard)wiz).getView();
  44.       ((Window)wv).addWindowListener(new 1());
  45.       ((Wizard)wiz).setVisible(true);
  46.    }
  47.  
  48.    public SubDBQueryData getData() {
  49.       return this._data;
  50.    }
  51.  
  52.    public void clearValues() {
  53.       this._data.clear();
  54.    }
  55.  
  56.    public static WizardSubDbQuery getInstance() {
  57.       if (_instance == null) {
  58.          JFrame f = new JFrame();
  59.          ((Component)f).setFont(new Font("Dialog", 0, 11));
  60.          _instance = new WizardSubDbQuery(f, (String)null, (String)null, 540, 400, new AspWizardExceptionHandler(f));
  61.       }
  62.  
  63.       return _instance;
  64.    }
  65.  
  66.    public WizardSubDbQuery(JFrame parent, String title, String codeBase, int width, int height, ExceptionHandler handler) {
  67.       super(parent, title, codeBase, width, height, handler);
  68.       this.init_internal();
  69.    }
  70.  
  71.    public WizardSubDbQuery(JFrame parent, String title, String codeBase, ExceptionHandler handler) {
  72.       super(parent, title, codeBase, handler);
  73.       this.init_internal();
  74.    }
  75.  
  76.    protected void init_internal() {
  77.       this._data.setWizard(this);
  78.       this.initResourceUtil();
  79.       this.initView();
  80.       this.initSequence();
  81.       this.initListeners();
  82.       ((Wizard)this).enableButtons();
  83.    }
  84.  
  85.    private void initResourceUtil() {
  86.       try {
  87.          this._resourceUtil = new ResourceUtil("asp.wizard.res", this.getClass());
  88.       } catch (EResourceUtil e) {
  89.          System.err.println(((Throwable)e).getMessage());
  90.       }
  91.  
  92.    }
  93.  
  94.    private void initSequence() {
  95.       try {
  96.          WizardModelAbstract model = new WizardModelSubDbQuerySelect(this, (String)null, (String)null, (ImageIcon)null, (ExceptionHandler)null);
  97.          ((Wizard)this).add(model);
  98.       } catch (InternalError e) {
  99.          System.err.println(((Throwable)e).getMessage());
  100.       }
  101.  
  102.    }
  103.  
  104.    private void initView() {
  105.       WizardView wv = ((Wizard)this).getView();
  106.       if (wv != null) {
  107.          ((Dialog)wv).setTitle(this._resourceUtil.getString("window.title"));
  108.          URL u = this.getClass().getResource("image/transicon.gif");
  109.          if (u != null) {
  110.             ImageIcon icon = new ImageIcon(u);
  111.             if (wv instanceof Frame) {
  112.                ((Frame)wv).setIconImage(icon.getImage());
  113.             }
  114.          }
  115.  
  116.          wv.getCancelButton().setText(this._resourceUtil.getString("button.cancel"));
  117.          wv.getBackButton().setText(this._resourceUtil.getString("button.back"));
  118.          wv.getNextButton().setText(this._resourceUtil.getString("button.next"));
  119.          wv.getFinishButton().setText(this._resourceUtil.getString("button.finish"));
  120.          UiUtil.centerComponentInScreen(wv);
  121.          ((Dialog)wv).setResizable(false);
  122.       }
  123.  
  124.    }
  125.  
  126.    private void initListeners() {
  127.       ((Wizard)this).getView().addWindowListener(new 2(this));
  128.    }
  129.  
  130.    private void handleFinishButtonPressed(ActionEvent e) {
  131.    }
  132.  
  133.    private void handleWindowClosing(WindowEvent e) {
  134.       ((Observable)this).setChanged();
  135.       ((Observable)this).notifyObservers(e);
  136.    }
  137.  
  138.    private void handleWindowClosed(WindowEvent e) {
  139.       ((Observable)this).setChanged();
  140.       ((Observable)this).notifyObservers(e);
  141.    }
  142.  
  143.    public String getSelect() {
  144.       return this._data.getSelect();
  145.    }
  146.  
  147.    public String getFrom() {
  148.       String from = "";
  149.  
  150.       try {
  151.          from = this._data.getFrom();
  152.       } catch (Exception var2) {
  153.       }
  154.  
  155.       return from;
  156.    }
  157.  
  158.    public String getWhere() {
  159.       return this._data.getWhere();
  160.    }
  161.  
  162.    public String getOrderBy() {
  163.       return this._data.getOrderby();
  164.    }
  165.  
  166.    public DefConnection getDefConnection() {
  167.       return this._defConnection;
  168.    }
  169.  
  170.    public void setDefConnection(DefConnection defConnection) {
  171.       this._defConnection = defConnection;
  172.    }
  173.  
  174.    public void destroy() {
  175.    }
  176.  
  177.    public void initialize() throws InternalError, ExternalError {
  178.       super.initialize();
  179.       WizardPage model = (WizardPage)((Wizard)this).getPageIndex().get("1");
  180.       if (model != null) {
  181.          model.initialize(1);
  182.          if (!model.getView().isVisible()) {
  183.             model.getView().setVisible(true);
  184.          }
  185.       }
  186.  
  187.       ((Wizard)this).enableButtons();
  188.    }
  189.  
  190.    public WizardPage getLastPage() {
  191.       WizardPage result = null;
  192.       Hashtable models = ((Wizard)this).getPageIndex();
  193.       new String();
  194.       String key = String.valueOf(models.size());
  195.       result = (WizardPage)models.get(key);
  196.       return result;
  197.    }
  198.  
  199.    public void finish() throws InternalError, ExternalError {
  200.       ((Wizard)this).getCurrPage().validate();
  201.       ((Wizard)this).getCurrPage().commit();
  202.       ((Observable)this).setChanged();
  203.       ((Observable)this).notifyObservers();
  204.    }
  205.  
  206.    // $FF: synthetic method
  207.    static void access$0(WizardSubDbQuery $0, WindowEvent $1) {
  208.       $0.handleWindowClosing($1);
  209.    }
  210.  
  211.    // $FF: synthetic method
  212.    static void access$1(WizardSubDbQuery $0, WindowEvent $1) {
  213.       $0.handleWindowClosed($1);
  214.    }
  215. }
  216.