public void showHTMLCode(String codeSource) { final DialogBox codePopup = new DialogBox(true, true); codePopup.setGlassEnabled(true); codePopup.setText(constants.showCodeTitle()); String[] lignesCode = codeSource.split("\n"); VerticalPanel tab = new VerticalPanel(); for (String ligneCode : lignesCode) { String maLigne = new String(ligneCode); String[] ligne = ligneCode.split("\t"); for (String texte : ligne) { if (texte.equals("")) { maLigne = " " + maLigne; } } maLigne = maLigne.replace("<", "<"); maLigne = maLigne.replace("div", "<span style='color: blue;'>div</span>"); maLigne = maLigne.replace("id=", "<span style='color: red;'>id</span>="); maLigne = maLigne.replace("class", "<span style='color: red;'>class</span>"); int commentBegin = maLigne.indexOf("<!--"); if (commentBegin != -1) { int commentEnd = maLigne.indexOf("-->"); String comment = maLigne.substring(commentBegin, commentEnd + 3); maLigne = maLigne.replace(comment, "<span style='color: #008000;'>" + comment + "</span>"); } HTML htmlLine = new HTML(maLigne); htmlLine.setStyleName("builder-source"); tab.add(htmlLine); } Button closeButton = new Button( constants.close(), new ClickHandler() { public void onClick(ClickEvent event) { codePopup.hide(); } }); tab.add(closeButton); tab.setCellHorizontalAlignment(closeButton, HasHorizontalAlignment.ALIGN_CENTER); codePopup.add(tab); codePopup.center(); codePopup.show(); }
public void showCodePreviewPanel() { CaptionPanel showCode = new CaptionPanel(constants.showCodeTitle()); showCode.setWidth("185px"); VerticalPanel vp = new VerticalPanel(); vp.setWidth("100%"); vp.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); showCodeButton = new Button(constants.showCode()); vp.add(showCodeButton); showCode.setContentWidget(vp); builderContent.add(showCode); }