EventRegistration PushButton_Click_getqq_ExitBtn = ClientEventManager.register( this.getqq_ExitBtn(), "Click" );
while (true) {
UIutils.processGUIActions();
EventHandle qq_currentEvent = EventManager.waitForEvent();
if (qq_currentEvent == null)
break;
// -------------
// task.Shutdown
// -------------
if (qq_currentEvent.isEvent(TaskHandle_Shutdown_langThreadcurrentThread)) {
try {
CursorMgr.startEvent();
// ================ Begin Forte Event Handler Translation ================
break;
// ================ End Forte Event Handler Translation ================
}
finally {
CursorMgr.endEvent();
}
}
// ----------------------
// TradeSO.OrderProcessed
// ----------------------
else if (qq_currentEvent.isEvent(TradeMgr_OrderProcessed_getInstance)) {
try {
CursorMgr.startEvent();
// ================ Begin Forte Event Handler Translation ================
Order theProcessedOrder = qq_currentEvent.getParam("pOrder");
if (this.getOrderList() != null) {
for (Order row : this.getOrderList()) {
if (row.getOrderID() == theProcessedOrder.getOrderID()) {
// TODO [1037,Major]: If you are deleting a row inside a loop, use the Iterator in place of the array
this.getOrderList().remove(row);
}
}
}
// ================ End Forte Event Handler Translation ================
}
finally {
CursorMgr.endEvent();
}
}
// ---------------------
// TradeSO.NewOrderAdded
// ---------------------
else if (qq_currentEvent.isEvent(TradeMgr_NewOrderAdded_getInstance)) {
try {
CursorMgr.startEvent();
// ================ Begin Forte Event Handler Translation ================
Order theNewOrder = qq_currentEvent.getParam("pNewOrder");
this.getOrderList().add(theNewOrder);
// ================ End Forte Event Handler Translation ================
}
finally {
CursorMgr.endEvent();
}
}
// ----------------------------
// <ViewHoldingsBtn>.ObjectDrop
// ----------------------------
else if (qq_currentEvent.isEvent(PushButton_ObjectDrop_getqq_ViewHoldingsBtn)) {
try {
CursorMgr.startEvent();
// ================ Begin Forte Event Handler Translation ================
JComponent theDroppedWidget = qq_currentEvent.getParam("sourceField");
int rownum = 0;
rownum = TableRow.get(this.getqq_OrderList());
CustomerWindow customerWin = new CustomerWindow();
customerWin.setUsage(Constants.WU_VIEW);
customerWin.display(this.getOrderList().get(rownum-1).getCustomerName());
// ================ End Forte Event Handler Translation ================
}
finally {
CursorMgr.endEvent();
}
}
// -----------------------
// <ViewHoldingsBtn>.Click
// -----------------------
else if (qq_currentEvent.isEvent(PushButton_Click_getqq_ViewHoldingsBtn)) {
try {
CursorMgr.startEvent();
// ================ Begin Forte Event Handler Translation ================
//self.Window.MessageDialog(MessageText='View Holdings not yet implemented',
// MessageType=MT_INFO);
CustomerWindow customerWin = new CustomerWindow();
customerWin.display(this.getTraderName());
// ================ End Forte Event Handler Translation ================
}
finally {
CursorMgr.endEvent();
}
}
// --------------------
// <MakeTradeBtn>.Click
// --------------------
else if (qq_currentEvent.isEvent(PushButton_Click_getqq_MakeTradeBtn)) {
try {
CursorMgr.startEvent();
// ================ Begin Forte Event Handler Translation ================
//self.Window.MessageDialog(MessageText='Make Trade not yet implemented',
// MessageType=MT_INFO);
try {
Order buyOrder = null, sellOrder = null;
int tradeQuantity = 0;
float tradePrice = 0;
// ------------------------------------
// Parameters for call to ValidateMatch
// ------------------------------------
ParameterHolder_Order qq_pBuyOrder = new ParameterHolder_Order();
ParameterHolder_Order qq_pSellOrder = new ParameterHolder_Order();
this.validateMatch(qq_pBuyOrder, qq_pSellOrder);
buyOrder = qq_pBuyOrder.get();
sellOrder = qq_pSellOrder.get();
//self.OrderList.DeleteRow(object=buyOrder);
//self.OrderList.DeleteRow(object=sellOrder);
new TradeMgr.AsyncRunner(true).makeTrade(TradeSO_proxy.getInstance(), buyOrder, sellOrder, new ParameterHolder_integer(), new ParameterHolder_float());
//self.Window.MessageDialog(messagetext='Trade completed successfully',
// messagetype = MT_INFO);
}
catch (InvalidTradeException badOrder) {
WindowManager.messageDialog(this, GenericException.getMessageText(badOrder), GenericException.severity(badOrder), 50);
}
// ================ End Forte Event Handler Translation ================
}
finally {
CursorMgr.endEvent();
}
}
// ------------------------
// TradeSO.MakeTrade_return
// ------------------------
else if (qq_currentEvent.isEvent(TradeMgr_MakeTrade_return_getInstance)) {
try {
CursorMgr.startEvent();
// ================ Begin Forte Event Handler Translation ================
int outputQuantity = (Integer)qq_currentEvent.getParam("pMTQuantity");
float outputPrice = (Float)qq_currentEvent.getParam("pMTPrice");
String returnSecName = qq_currentEvent.getParam("return");
TextData tempMsg = new TextData();
TextData objSecName = new TextData(returnSecName);
DecimalData objPrice = new DecimalData(outputPrice);
IntegerData objQuantity = new IntegerData(outputQuantity);
tempMsg.replaceParameters("Trade for %1 at price $%2 for %3 shares completed successfully", objSecName, objPrice, objQuantity);
WindowManager.messageDialog(this, tempMsg, Constants.MT_INFO, 50);
// when TradeSO.MakeTrade_exception do
// self.Window.MessageDialog(
// messagetext = 'Error in trading. The trade was not performed',
// messageType = MT_ERROR);
// badTrade returned as type OBJECT, need to cast to GenericException or
// ErroDesc to access message attribute
// ================ End Forte Event Handler Translation ================
}
finally {
CursorMgr.endEvent();
}
}
// ---------------------------
// TradeSO.MakeTrade_exception
// ---------------------------
else if (qq_currentEvent.isEvent(TradeMgr_MakeTrade_exception_getInstance)) {
try {
CursorMgr.startEvent();
// ================ Begin Forte Event Handler Translation ================
RuntimeException badTrade = qq_currentEvent.getParam("exception");
// TODO [1094,Minor]: Exception message has been wrapped in a TextData, ensure this doesn't cause any issues.
WindowManager.messageDialog(this, GenericException.getMessageText(((GenericException)badTrade)).getValue(), Constants.MT_ERROR, 50);
// ================ End Forte Event Handler Translation ================
}
finally {
CursorMgr.endEvent();
}
}
// ---------------
// <ExitBtn>.Click
// ---------------
else if (qq_currentEvent.isEvent(PushButton_Click_getqq_ExitBtn)) {
try {
CursorMgr.startEvent();
// ================ Begin Forte Event Handler Translation ================
break;