Checkstyle corrections. Change MatchWindow Layout

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@989825 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Pinaki Poddar 2010-08-26 17:05:37 +00:00
parent 911140bf83
commit 4d6fd5d806
5 changed files with 54 additions and 37 deletions

View File

@ -20,7 +20,7 @@
<!-- Build script to compile, package a OpenJPA/Slice based application -->
<!-- with Google Web Toolkit client to be deployed in a servlet container. -->
<!-- ====================================================================== -->
<project name="JavaOneGWT">
<project name="OpenTrader">
<!-- local environment paths for required libraries -->
<property file="build.properties" />

View File

@ -34,6 +34,9 @@ import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.DockPanel;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.RadioButton;
@ -50,37 +53,43 @@ public class MatchWindow extends PopupPanel {
public MatchWindow(final OpenTrader session, final Tradable tradable, final List<Match> matches) {
super(false, true);
this.session = session;
setAnimationEnabled(true);
DockPanel panel = new DockPanel();
panel.setHorizontalAlignment(DockPanel.ALIGN_CENTER);
final HTML header = new HTML();
final boolean ask = (tradable instanceof Ask);
String txt = (matches.isEmpty() ? "No" : ""+matches.size()) + " matching "+ (ask ? "Bid" : "Ask") + " for "
+ toString(tradable) + "<br>";
header.setHTML(txt);
header.addStyleName("table-caption");
Button close = new Button(matches.isEmpty() ? "OK" : "Cancel");
close.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
hide();
}
});
FlexTable body = new FlexTable();
final RadioButton[] buttons = new RadioButton[matches.size()];
FlowPanel panel = new FlowPanel();
String txt = (matches.isEmpty() ? "No" : matches.size()) + " matching " + (ask ? "Bid" : "Ask")
+ " for " + toString(tradable) + "<br>";
HTML html = new HTML();
html.setHTML(txt);
html.addStyleName("table-caption");
panel.add(html);
if (!matches.isEmpty()) {
FlexTable table = new FlexTable();
for (int i = 0; i < matches.size(); i++) {
Match match = matches.get(i);
Tradable t2 = ask ? match.getBid() : match.getAsk();
Trader cpty = ask ? match.getBid().getBuyer() : match.getAsk().getSeller();
buttons[i] = new RadioButton("matches");
buttons[i].setValue(i == 0);
table.setWidget(i, 0, buttons[i]);
table.setWidget(i, 1, FormatUtil.formatPrice(t2.getPrice()));
table.setWidget(i, 2, FormatUtil.formatVolume(t2.getVolume()));
table.setText(i, 3, " by " + cpty.getName());
body.setWidget(i, 0, buttons[i]);
body.setWidget(i, 1, FormatUtil.formatPrice(t2.getPrice()));
body.setWidget(i, 2, FormatUtil.formatVolume(t2.getVolume()));
body.setText(i, 3, " by " + cpty.getName());
}
panel.add(table);
panel.add(new HTML("<p>"));
Button act = new Button(ask ? "Sell" : "Buy");
panel.add(act);
act.setFocus(true);
body.setWidget(matches.size()+1, 1, act);
act.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
for (int i = 0; i < buttons.length; i++) {
@ -93,17 +102,22 @@ public class MatchWindow extends PopupPanel {
}
}
});
body.setWidget(matches.size()+1, 2, close);
} else {
panel.add(new HTML("<p>"));
body.setWidget(0,0, new HTML("<p>Open a new browser page and login with a different Trader name<br>"
+ "to create a matching " + (ask ? "Bid" : "Ask") + "<p>"));
close.setFocus(true);
body.setWidget(1, 0, close);
body.getFlexCellFormatter().setAlignment(1,0,
HasHorizontalAlignment.ALIGN_CENTER,
HasVerticalAlignment.ALIGN_MIDDLE);
}
Button cancel = new Button("Cancel");
panel.add(cancel);
cancel.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
hide(true);
}
});
add(panel);
panel.add(header, DockPanel.NORTH);
panel.add(body, DockPanel.CENTER);
setWidget(panel);
}
String toString(Tradable t) {

View File

@ -26,6 +26,7 @@ import org.apache.openjpa.trader.domain.Trade;
import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.GwtEvent.Type;
/**
* Specialization of GWTEvent (that represent mouse/keybord events and DOM events)
@ -52,7 +53,8 @@ public abstract class ServiceEvent<T, H extends EventHandler> extends GwtEvent<H
}
public static class TradableAdded extends ServiceEvent<Tradable, ServiceEventHandler.AddTradableHandler> {
public static Type<ServiceEventHandler.AddTradableHandler> TYPE = new Type<ServiceEventHandler.AddTradableHandler>();
public static Type<ServiceEventHandler.AddTradableHandler> TYPE =
new Type<ServiceEventHandler.AddTradableHandler>();
public TradableAdded(Tradable tradable) {
super(tradable);
@ -65,13 +67,14 @@ public abstract class ServiceEvent<T, H extends EventHandler> extends GwtEvent<H
}
@Override
public com.google.gwt.event.shared.GwtEvent.Type<ServiceEventHandler.AddTradableHandler> getAssociatedType() {
public Type<ServiceEventHandler.AddTradableHandler> getAssociatedType() {
return TYPE;
}
}
public static class TradableRemoved extends ServiceEvent<Tradable, ServiceEventHandler.RemoveTradableHandler> {
public static Type<ServiceEventHandler.RemoveTradableHandler> TYPE = new Type<ServiceEventHandler.RemoveTradableHandler>();
public static Type<ServiceEventHandler.RemoveTradableHandler> TYPE =
new Type<ServiceEventHandler.RemoveTradableHandler>();
public TradableRemoved(Tradable tradable) {
super(tradable);
@ -83,7 +86,7 @@ public abstract class ServiceEvent<T, H extends EventHandler> extends GwtEvent<H
}
@Override
public com.google.gwt.event.shared.GwtEvent.Type<ServiceEventHandler.RemoveTradableHandler> getAssociatedType() {
public Type<ServiceEventHandler.RemoveTradableHandler> getAssociatedType() {
return TYPE;
}
}
@ -102,13 +105,14 @@ public abstract class ServiceEvent<T, H extends EventHandler> extends GwtEvent<H
}
@Override
public com.google.gwt.event.shared.GwtEvent.Type<UpdateStockHandler> getAssociatedType() {
public Type<UpdateStockHandler> getAssociatedType() {
return TYPE;
}
}
public static class TradeCommitted extends ServiceEvent<Trade, ServiceEventHandler.AddTradeHandler> {
public static Type<ServiceEventHandler.AddTradeHandler> TYPE = new Type<ServiceEventHandler.AddTradeHandler>();
public static Type<ServiceEventHandler.AddTradeHandler> TYPE =
new Type<ServiceEventHandler.AddTradeHandler>();
public TradeCommitted(Trade trade) {
super(trade);
@ -121,7 +125,7 @@ public abstract class ServiceEvent<T, H extends EventHandler> extends GwtEvent<H
}
@Override
public com.google.gwt.event.shared.GwtEvent.Type<ServiceEventHandler.AddTradeHandler> getAssociatedType() {
public Type<ServiceEventHandler.AddTradeHandler> getAssociatedType() {
return TYPE;
}
}

View File

@ -117,5 +117,4 @@ public class ErrorDialog extends PopupPanel {
label.addStyleName(STYLE_MESSAGE);
return label;
}
}
}

View File

@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@ -16,7 +17,6 @@
specific language governing permissions and limitations
under the License.
-->
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">