openGit(null, url);
}
public static void openGit(String source, final String url) {
final XFlexTable tbl = new XFlexTable();
final XButton btnCopy = new XButton("Copy", XButtonType.Shadow);
btnCopy.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
markText(tbl.getWidget(0, 0).getElement());
}
});
final XButton btnGit = new XButton("View in GitHub", XButtonType.Shadow);
btnGit.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
// Window.open(Globals.GIT_HOST + url + ".java", "_tab", "");
// Utils.loadUrl(Globals.GIT_HOST + url + ".java");
// This click handler seems to work best
openURL(Globals.GIT_HOST + url + ".java");
}
});
tbl.getElement().setId("codeText");
String codeUrl = url.substring(url.lastIndexOf("/") + 1);
HTTP.doGet(Globals.SOURCE_PATH.replace("$", codeUrl), new ResponseReader() {
public void onSuccess(Response resp) {
tbl.setWidget(0, 0, new HTML("<pre>" + toHighlighted(resp.getText()) + "</pre>"));
tbl.setWidget(1, 0, btnCopy);
tbl.setWidget(1, 1, btnGit);
}
});
final XPopup popup = new XPopup();
XDragScrollView view = new XDragScrollView();
view.addStyleName("codeDemo");
tbl.setWidget(0, 0, new XSpinner());
tbl.setCellSpacing(10);
FlexCellFormatter fcf = tbl.getFlexCellFormatter();
fcf.setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_TOP);
fcf.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT);
fcf.setVerticalAlignment(1, 0, HasVerticalAlignment.ALIGN_TOP);
fcf.setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_RIGHT);
fcf.setVerticalAlignment(1, 1, HasVerticalAlignment.ALIGN_TOP);