public void setTextAreaWidth(int width) { textArea.setWidth(width + "px"); }
public void onModuleLoad() { TabLayoutPanel tabLayoutPanel = new TabLayoutPanel(2.5, Unit.EM); final SplitLayoutPanel splitLayoutPanel = new SplitLayoutPanel(); final HorizontalPanel hPanel = new HorizontalPanel(); hPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); hPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); hPanel.setSpacing(10); hPanel.add(new HTML("HQMF Viewer.")); Button processHQMFButton = new Button("Process HQMF."); processHQMFButton.addStyleName("sendButton"); hPanel.add(processHQMFButton); hPanel.add(new HTML("\t(For some reason, works only in IE right now.)")); final VerticalPanel summaryVerticalPanel = new VerticalPanel(); summaryVerticalPanel.setSpacing(3); processHQMFButton.setStyleName("summaryVPanel"); summaryVerticalPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); summaryVerticalPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); splitLayoutPanel.addNorth(hPanel, 50); splitLayoutPanel.addWest(summaryVerticalPanel, 0); final RichTextArea textArea = new RichTextArea(); textArea.setTitle("Paste your HQMF XML here."); textArea.setText("Paste your HQMF XML here."); textArea.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { if (textArea.getText().length() < 30 && textArea.getText().equals("Paste your HQMF XML here.")) { textArea.setText(""); } } }); textArea.addStyleName("boxsizingBorder"); textArea.setWidth("100%"); textArea.setHeight("100%"); processHQMFButton.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { processHQMF(textArea, splitLayoutPanel, summaryVerticalPanel); splitLayoutPanel.remove(hPanel); splitLayoutPanel.setWidgetSize(summaryVerticalPanel, 200); splitLayoutPanel.setWidgetToggleDisplayAllowed(summaryVerticalPanel, true); } }); splitLayoutPanel.add(textArea); MySplitLayoutPanel mySplitPanel = new MySplitLayoutPanel(); final VerticalPanel testVerticalPanel = new VerticalPanel(); testVerticalPanel.setSpacing(3); testVerticalPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); testVerticalPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); // final RichTextArea testtextArea = getSmartTextArea(); // final AceEditor testtextArea = getAceEditor(); AceEditor aceTxtArea = new AceEditor(); aceTxtArea.setWidth("100%"); aceTxtArea.setHeight("100%"); mySplitPanel.addEast(testVerticalPanel, 0); mySplitPanel.add(aceTxtArea); // mySplitPanel.add(testtextArea); aceTxtArea.startEditor(); setAceEditorProperties(aceTxtArea); mySplitPanel.setWidgetToggleDisplayAllowed(testVerticalPanel, true); tabLayoutPanel.add(mySplitPanel, "test CQL Editor."); tabLayoutPanel.add(splitLayoutPanel, "HQMF Viewer"); RootLayoutPanel.get().add(tabLayoutPanel); }
protected void initItem(int width, int height) { String legacyHtml = ""; if (toolBar != null) { toolBar.removeFromParent(); } if (textArea != null) { legacyHtml = textArea.getHTML(); textArea.removeFromParent(); } if (mainLayout != null) { removeItem(mainLayout); mainLayout.destroy(); } textArea = new RichTextArea(); toolBar = new RichTextToolbar(textArea, DisplayType.DETAILED); saveButton = new IButton(BLCMain.getMessageManager().getString("ok")); IButton cancelButton = new IButton(BLCMain.getMessageManager().getString("cancel")); cancelButton.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { hide(); } }); final HtmlEditingPresenter pp = HtmlEditingPresenter.getInstance(); final HLayout buttonsLayout = new HLayout(10); buttonsLayout.setAlign(Alignment.CENTER); buttonsLayout.addMember(saveButton); buttonsLayout.addMember(cancelButton); buttonsLayout.setLayoutTopMargin(2); buttonsLayout.setLayoutBottomMargin(2); buttonsLayout.setWidth100(); buttonsLayout.setHeight(25); mainLayout = new VLayout(); mainLayout.setWidth100(); mainLayout.setHeight100(); toolBar.setHeight("60px"); final VLayout toolbarLayout = new VLayout(); toolbarLayout.setWidth100(); toolbarLayout.setHeight(60); toolbarLayout.addMember(toolBar); int textHeight = height - 130; textArea.setHeight(textHeight + "px"); textArea.setWidth(width + "px"); final VLayout textAreaLayout = new VLayout(); textAreaLayout.setWidth100(); textAreaLayout.setHeight(textHeight); textAreaLayout.addMember(textArea); mainLayout.addMember(toolbarLayout); mainLayout.addMember(textAreaLayout); mainLayout.addMember(buttonsLayout); addItem(mainLayout); toolBar.addAssetHandler( new Command() { @Override public void execute() { pp.displayAssetSearchDialog(toolBar); } }); textArea.setHTML(legacyHtml); saveButton.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { if (richTextItem != null) { richTextItem.setValue(toolBar.getHTML()); richTextItem.getForm().fireEvent(new ItemChangedEvent(richTextItem.getJsObj())); } hide(); } }); }
public RichTextArea getSmartTextArea() { final RichTextArea testtextArea = new RichTextArea(); testtextArea.setTitle("test test test."); testtextArea.setText("test test test."); testtextArea.addStyleName("boxsizingBorder"); testtextArea.setWidth("100%"); testtextArea.setHeight("100%"); // testtextArea.addKeyPressHandler(new KeyPressHandler() { // @Override // public void onKeyPress(KeyPressEvent event) { // System.out.println( "KeyPressEvent:" + // event.getCharCode() + ":" + // event.isAnyModifierKeyDown() + ":" + // event.isControlKeyDown()); // } // // // }); testtextArea.addKeyUpHandler( new KeyUpHandler() { @Override public void onKeyUp(KeyUpEvent event) { // if(event.getNativeKeyCode() == 32 && event.isControlKeyDown()){ if (event.getNativeKeyCode() == 32) { System.out.println( "Show popup with context sensitive alternatives. Give focus to popup."); event.preventDefault(); event.stopPropagation(); // int xCoOrdinate = event.getNativeEvent().getScreenX(); // int yCoOrdinate = event.getNativeEvent().getScreenY(); RichTextArea richTextArea = (RichTextArea) event.getSource(); String htmlText = richTextArea.getHTML(); boolean isEndParagraphTagRemoved = false; System.out.println("before htmlText:" + htmlText); if (htmlText.endsWith("</p>")) { htmlText = htmlText.substring(0, htmlText.length() - 4); isEndParagraphTagRemoved = true; } System.out.println("after htmlText:" + htmlText); for (int i = htmlText.length() - 2; i >= 0; i--) { char c = htmlText.charAt(i); if (c == ' ') { String newText = htmlText.substring(i).trim(); if (newText.length() > 0) { htmlText = htmlText.substring(0, i); String setHTMLString = htmlText + " <span style='color:blue'>" + newText + " </span>" + (isEndParagraphTagRemoved ? "</p>" : ""); System.out.println(setHTMLString); richTextArea.setHTML(setHTMLString); } else { String setHTMLString = htmlText + (isEndParagraphTagRemoved ? "</p>" : ""); System.out.println(setHTMLString); richTextArea.setHTML(setHTMLString); } break; } } System.out.println("New html:" + richTextArea.getHTML()); // System.out.println("x:"+xCoOrdinate); // System.out.println("y:"+yCoOrdinate); // // ListBox listBox = new ListBox(); // listBox.addItem("define", "define"); // listBox.addItem("function", "function"); // listBox.addItem("library", "library"); // listBox.addItem("using", "using"); // listBox.addItem("include", "include"); // listBox.addItem("public", "public"); // listBox.addItem("private", "private"); // listBox.addItem("valueset", "valueset"); // listBox.addItem("List", "List"); // listBox.addItem("Tuple", "Tuple"); // listBox.addItem("Interval", "Interval"); // // listBox.setVisibleItemCount(listBox.getItemCount()+1); // PopupPanel popupPanel = new PopupPanel(true); // popupPanel.add(listBox); // popupPanel.setPopupPosition(xCoOrdinate, yCoOrdinate); // popupPanel.show(); } } }); return testtextArea; }