Previous Next

DPM Sample - Classes

Dpm.java

Dpm is the controller for a DPM component. This class initializes the component, binding together the model, selection, view, and GUIHandler, and creating the command processor for the component. The controller also controls the animation of the component's ticker tape, which is owned by the view.

Create and initialize a DPM component, displaying data for a single customer
public class Dpm extends ComponentController {
public Dpm() {
   try {
      setResourceBundle(ResourceBundle.getBundle("dpm.DpmResources"));
   } catch( MissingResourceException e) {
      new ExceptionDialog(null, "Can't find resource file", e);
   }
   setModel(new DpmModel());
   setGUIHandler(new DpmGUIHandler(this));
   setCommandProcessor(new CommandProcessor());
   setModelSelection(new DpmSelection(this, (DpmModel)getModel()));
   setView(new DpmView());

   DpmModel dpmModel = (DpmModel)getModel();

   CustomerImpl customer = dpmModel.getCustomer();
   customer.setAppFrame(getComponentFrame()); 
}
main routine for the application
public static void main(String args[]) {
   setApplicationMain(true);
   new Dpm();
}
Stop the animated ticker tape when the applet stops
public void stop() {
   TickerTape tickerTape = ((DpmView)getView()).getTickerTape();
   tickerTape.stopAnimation();
   super.stop();
}
Start the animated ticker tape when the applet starts
public void start() {
   super.start();
   TickerTape tickerTape = ((DpmView)getView()).getTickerTape();
   tickerTape.startAnimation();
}
Delegate undo and redo calls to the component's GUIHandler
public void undo() {
   ((DpmGUIHandler)getGUIHandler()).undo();
}

public void redo() {
   ((DpmGUIHandler)getGUIHandler()).redo();
}
Functions for portfolio transactions are delegated to the component's GUIHandler
public void buy() {
   ((DpmGUIHandler)getGUIHandler()).doTransaction(DpmGUIHandler.kBuy);
}

public void sell() {
   ((DpmGUIHandler)getGUIHandler()).doTransaction(DpmGUIHandler.kSell);
}

public void setPrice() {
   ((DpmGUIHandler)getGUIHandler()).doTransaction(DpmGUIHandler.kSetPrice);
}

public void deposit() {
   ((DpmGUIHandler)getGUIHandler()).doTransaction(DpmGUIHandler.kDeposit);
}

public void withdraw() {
   ((DpmGUIHandler)getGUIHandler()).doTransaction(DpmGUIHandler.kWithdraw);
}

public void riskView() {
   ((DpmGUIHandler)getGUIHandler()).doTransaction(DpmGUIHandler.kRiskView);
}

public void securityView() {
   ((DpmGUIHandler)getGUIHandler()).doTransaction(DpmGUIHandler.kSecurityView);
}
Functions for accessing the current customer are delegated to the model
public Customer getCustomer() {
   return ((DpmModel)getModel()).getCustomer();
}


public void setCustomer(CustomerImpl customer) {
   ((DpmModel)getModel()).setCustomer(customer);
}
}

Previous Next

Copyright © Taligent, Inc. 1996 - 1997.
Copyright
© IBM Corporation 1996 - 1997.
All Rights Reserved.