HorizontalPanel masterPanel = new HorizontalPanel();
masterPanel.setWidth("100%");
header.add(masterPanel);
header.addStyleName(STYLE_LOG_HEADER);
final Label titleLabel = new Label("gwt-log", false);
titleLabel.setStylePrimaryName("log-title");
HorizontalPanel buttonPanel = new HorizontalPanel();
levelButtons = new Button[levels.length];
for (int i = 0; i < levels.length; i++) {
final int level = levels[i];
levelButtons[i] = new Button(LogUtil.levelToString(level));
buttonPanel.add(levelButtons[i]);
levelButtons[i].addClickListener(new ClickListener() {
public void onClick(Widget sender) {
((FocusWidget) sender).setFocus(false);
Log.setCurrentLogLevel(level);
}
});
}
Button clearButton = new Button("Clear");
clearButton.addStyleName("log-clear-button");
DOM.setStyleAttribute(clearButton.getElement(), "color", "#00c");
clearButton.addClickListener(new ClickListener() {
public void onClick(Widget sender) {
((FocusWidget) sender).setFocus(false);
Log.clear();
}
});
buttonPanel.add(clearButton);
Button aboutButton = new Button("About");
aboutButton.addStyleName("log-clear-about");
aboutButton.addClickListener(new ClickListener() {
public void onClick(Widget sender) {
((FocusWidget) sender).setFocus(false);
// TODO Add GWT.getVersion() after 1.5
Log.diagnostic("\n" //
+ "gwt-log-" + Log.getVersion() //
+ " - Runtime logging for your Google Web Toolkit projects\n" + //
"Copyright 2007-2008 Fred Sauer\n" + //
"The original software is available from:\n" + //
"\u00a0\u00a0\u00a0\u00a0http://allen-sauer.com/gwt/\n", null);
}
});
masterPanel.add(titleLabel);
masterPanel.add(buttonPanel);
masterPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
masterPanel.add(aboutButton);
masterPanel.setCellHeight(titleLabel, "100%");
masterPanel.setCellWidth(titleLabel, "50%");
masterPanel.setCellWidth(aboutButton, "50%");
titleLabel.addMouseListener(new MouseListenerAdapter() {
private boolean dragging = false;
private int dragStartX;
private int dragStartY;
public void onMouseDown(Widget sender, int x, int y) {
dragging = true;
DOM.setCapture(titleLabel.getElement());
dragStartX = x;
dragStartY = y;
}
public void onMouseMove(Widget sender, int x, int y) {
if (dragging) {
int absX = x + debugDockPanel.getAbsoluteLeft();
int absY = y + debugDockPanel.getAbsoluteTop();
RootPanel.get().setWidgetPosition(debugDockPanel, absX - dragStartX, absY - dragStartY);
}
}
public void onMouseUp(Widget sender, int x, int y) {
dragging = false;
DOM.releaseCapture(titleLabel.getElement());
}
});
return header;
}