List of usage examples for com.google.gwt.user.client.ui TextArea setVisibleLines
public void setVisibleLines(int lines)
From source file:ch.heftix.mailxel.client.AttachmentPanel.java
License:Open Source License
public AttachmentPanel(final AttachmentTO attachmentTO, final MailServiceAsync mailxelService, final MailxelPanel mailxelPanel, final boolean directDownload) { String url = GWT.getModuleBaseURL() + "mailxel?id=" + Integer.toString(attachmentTO.id); int type = MimeTypeDescriptor.TYPE_ANY; final MimeTypeDescriptor mtd = MimeTypeUtil.mimeTypeByName(attachmentTO.name); type = mtd.fileType;// www. j a v a 2s.co m Frame frame = null; if (directDownload) { frame = new Frame(url); add(frame); return; } ServiceCall sc = new ServiceCall() { public String getMessage() { return "get attachment data"; }; public boolean runSynchronized() { return true; }; public void run(final StatusItem si) { mailxelService.getAttachmentData(attachmentTO.id, new AsyncCallback<String>() { public void onSuccess(String result) { si.done(); switch (mtd.fileType) { case MimeTypeDescriptor.TYPE_HTM: HTML html = new HTML(); html.setHTML(result); add(html); break; default: TextArea ta = new TextArea(); ta.setCharacterWidth(80); ta.setVisibleLines(25); ta.setReadOnly(true); ta.setText(result); add(ta); break; } } public void onFailure(Throwable caught) { si.error(caught); } }); } }; switch (type) { case MimeTypeDescriptor.TYPE_IMG: Image img = new Image(url); add(img); break; case MimeTypeDescriptor.TYPE_HTM: case MimeTypeDescriptor.TYPE_TXT: mailxelPanel.statusStart(sc); break; default: frame = new Frame(url); add(frame); break; } }
From source file:cl.uai.client.page.EditMarkDialog.java
License:Open Source License
/** * Creates a comment dialog at a specific position * /*from ww w. java 2 s .co m*/ * @param posx Top position for the dialog * @param posy Left position for the dialog * @param level An optional rubric level in case we are editing one */ public EditMarkDialog(int posx, int posy, int level, int regradeid) { super(true, false); this.regradeId = regradeid; this.levelId = level; Level lvl = MarkingInterface.submissionData.getLevelById(levelId); if (EMarkingConfiguration.getKeywords() != null && EMarkingConfiguration.getKeywords().length() > 0) { logger.fine("Keywords: " + EMarkingConfiguration.getKeywords()); } if (!EMarkingConfiguration.getKeywords().equals("") && (level > 0 || regradeid > 0)) { feedbackArray = new ArrayList<FeedbackObject>(); feedbackPanel = new FeedbackInterface(); feedbackPanel.setParent(this); } else { simplePanel = true; } superPanel = new HorizontalPanel(); superPanel.addStyleName(Resources.INSTANCE.css().feedbackdialog()); feedbackForStudent = new VerticalPanel(); feedbackForStudent.addStyleName(Resources.INSTANCE.css().feedbackforstudent()); feedbackSummary = new ScrollPanel(feedbackForStudent); feedbackSummary.addStyleName(Resources.INSTANCE.css().feedbacksummary()); mainPanel = new VerticalPanel(); mainPanel.addStyleName(Resources.INSTANCE.css().editmarkdialog()); // Adds the CSS style and other settings this.addStyleName(Resources.INSTANCE.css().commentdialog()); this.setAnimationEnabled(true); this.setGlassEnabled(true); bonusTxt = new TextBox(); bonusTxt.addStyleName(Resources.INSTANCE.css().bonuslist()); this.levelsList = new ListBox(); this.levelsList.addStyleName(Resources.INSTANCE.css().levelslist()); this.levelsList.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { int levelid = Integer.parseInt(levelsList.getValue(levelsList.getSelectedIndex())); levelId = levelid; Level lvl = MarkingInterface.submissionData.getLevelById(levelId); setBonus(lvl.getBonus()); } }); // If there's a rubric level we should edit a Mark // otherwise we are just editing its comment if (this.levelId == 0) { this.setHTML(MarkingInterface.messages.AddEditComment()); } else { this.setHTML(MarkingInterface.messages.AddEditMark() + "<br/>" + lvl.getCriterion().getDescription()); } // Position the dialog if (simplePanel) { this.setPopupPosition(posx, posy); } else { // The Dialog is more big, so we need to fix the position this.setPopupPosition((int) (Window.getClientWidth() * 0.08), (int) (Window.getClientHeight() * 0.15)); } if (this.levelId > 0) { loadLevelsList(); HorizontalPanel hpanelLevels = new HorizontalPanel(); hpanelLevels.setWidth("100%"); Label messages = new Label(MarkingInterface.messages.Level()); hpanelLevels.add(messages); hpanelLevels.add(levelsList); hpanelLevels.setCellHorizontalAlignment(levelsList, HasHorizontalAlignment.ALIGN_RIGHT); mainPanel.add(hpanelLevels); mainPanel.setCellHorizontalAlignment(hpanelLevels, HasHorizontalAlignment.ALIGN_RIGHT); } // Save button Button btnSave = new Button(MarkingInterface.messages.Save()); btnSave.addStyleName(Resources.INSTANCE.css().btnsave()); btnSave.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (levelId > 0 && !bonusIsValid()) { Window.alert(MarkingInterface.messages.InvalidBonusValue()); return; } cancelled = false; hide(); } }); // Cancel button Button btnCancel = new Button(MarkingInterface.messages.Cancel()); btnSave.addStyleName(Resources.INSTANCE.css().btncancel()); btnCancel.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { cancelled = true; hide(); } }); // The comment text box TextArea txt = new TextArea(); txt.setVisibleLines(5); txt.getElement().getStyle().setMarginBottom(5, Unit.PT); txtComment = new SuggestBox(EMarkingWeb.markingInterface.previousCommentsOracle, txt); txtComment.setAutoSelectEnabled(false); txtComment.addStyleName(Resources.INSTANCE.css().editmarksuggestbox()); HorizontalPanel hpanelComment = new HorizontalPanel(); hpanelComment.setWidth("100%"); hpanelComment.add(new Label(MarkingInterface.messages.Comment())); hpanelComment.add(txtComment); hpanelComment.setCellHorizontalAlignment(txtComment, HasHorizontalAlignment.ALIGN_RIGHT); mainPanel.add(hpanelComment); mainPanel.setCellHorizontalAlignment(hpanelComment, HasHorizontalAlignment.ALIGN_RIGHT); // If the rubric level is not null then create the bonus list and add it to the dialog if (this.levelId > 0) { setBonus(lvl.getBonus()); HorizontalPanel hpanelBonus = new HorizontalPanel(); hpanelBonus.setWidth("100%"); hpanelBonus.add(new Label(MarkingInterface.messages.SetBonus())); hpanelBonus.add(bonusTxt); hpanelBonus.setCellHorizontalAlignment(bonusTxt, HasHorizontalAlignment.ALIGN_RIGHT); if (EMarkingConfiguration.isFormativeFeedbackOnly()) { hpanelBonus.setVisible(false); } mainPanel.add(hpanelBonus); mainPanel.setCellHorizontalAlignment(hpanelBonus, HasHorizontalAlignment.ALIGN_RIGHT); } // The regrade comment text box txt = new TextArea(); txt.setVisibleLines(5); txt.getElement().getStyle().setMarginBottom(5, Unit.PT); txtRegradeComment = new SuggestBox(EMarkingWeb.markingInterface.previousCommentsOracle, txt); if (this.regradeId > 0) { mainPanel.add(new HTML("<hr>")); mainPanel.add(new Label(MarkingInterface.messages.Regrade())); // Add the textbox HorizontalPanel hpanelRegradeComment = new HorizontalPanel(); hpanelRegradeComment.setWidth("100%"); hpanelRegradeComment.add(new Label(MarkingInterface.messages.RegradeComment())); hpanelRegradeComment.add(txtRegradeComment); hpanelRegradeComment.setCellHorizontalAlignment(txtRegradeComment, HasHorizontalAlignment.ALIGN_RIGHT); mainPanel.add(hpanelRegradeComment); mainPanel.setCellHorizontalAlignment(hpanelRegradeComment, HasHorizontalAlignment.ALIGN_RIGHT); } // Add buttons HorizontalPanel hpanel = new HorizontalPanel(); hpanel.setSpacing(2); hpanel.setWidth("100%"); hpanel.add(btnSave); hpanel.add(btnCancel); hpanel.setCellWidth(btnSave, "100%"); hpanel.setCellWidth(btnCancel, "0px"); hpanel.setCellHorizontalAlignment(btnCancel, HasHorizontalAlignment.ALIGN_RIGHT); hpanel.setCellHorizontalAlignment(btnSave, HasHorizontalAlignment.ALIGN_RIGHT); mainPanel.add(hpanel); mainPanel.setCellHorizontalAlignment(hpanel, HasHorizontalAlignment.ALIGN_RIGHT); if (simplePanel) { // No feedback this.setWidget(mainPanel); } else { // Remove CSS Style mainPanel.removeStyleName(Resources.INSTANCE.css().editmarkdialog()); mainPanel.addStyleName(Resources.INSTANCE.css().editmarkdialogWithFeedback()); bonusTxt.removeStyleName(Resources.INSTANCE.css().bonuslist()); bonusTxt.addStyleName(Resources.INSTANCE.css().bonuslistWithFeedback()); this.levelsList.removeStyleName(Resources.INSTANCE.css().levelslist()); this.levelsList.addStyleName(Resources.INSTANCE.css().levelslistWithFeedback()); txtComment.removeStyleName(Resources.INSTANCE.css().editmarksuggestbox()); txtComment.addStyleName(Resources.INSTANCE.css().editmarksuggestboxWithFeedback()); // Add feedback panel mainPanel.add(new HTML("<h4>Feedback</h4>")); mainPanel.add(feedbackSummary); superPanel.add(mainPanel); superPanel.add(feedbackPanel); this.setWidget(superPanel); } }
From source file:com.bedatadriven.renjin.appengine.client.CommandPrompt.java
License:Apache License
/** * This creates an immutable copy of the prompt and input area suitable for * adding to the page./*w ww . java 2s . c om*/ */ public Widget createImmutablePanel() { HorizontalPanel panelCopy = new HorizontalPanel(); Label promptCopy = new Label(prompt.getText()); promptCopy.setStyleName(prompt.getStyleName()); promptCopy.getElement().getStyle().setProperty("width", prompt.getElement().getStyle().getProperty("width")); panelCopy.add(promptCopy); final InterpreterType t = type; final String scriptText = inputArea.getText(); TextArea inputAreaCopy = new TextArea(); inputAreaCopy.setStyleName(inputArea.getStyleName()); inputAreaCopy.setText(removeTrailingNewLines(scriptText)); inputAreaCopy.setVisibleLines(countLines(inputArea)); inputAreaCopy.setReadOnly(true); SimplePanel inputAreaDivCopy = new SimplePanel(); inputAreaDivCopy.add(inputAreaCopy); inputAreaDivCopy.getElement().setAttribute("style", inputAreaDiv.getElement().getAttribute("style")); panelCopy.add(inputAreaDivCopy); panelCopy.setCellWidth(inputAreaDivCopy, "100%"); return panelCopy; }
From source file:com.eucalyptus.webui.client.view.InputViewImpl.java
License:Open Source License
private HasValueWidget getHasValueWidget(ValueType type, final ValueChecker checker) { switch (type) { case TEXT:/*ww w .j a v a 2 s. co m*/ return new HasValueWidget() { private TextBox input = new TextBox(); @Override public Widget getWidget() { return input; } @Override public String getValue() { return this.input.getValue(); } }; case TEXTAREA: return new HasValueWidget() { private TextArea input = getTextArea(); protected final TextArea getTextArea() { TextArea w = new TextArea(); w.setVisibleLines(TEXT_AREA_LINES); return w; } @Override public Widget getWidget() { return input; } @Override public String getValue() { return this.input.getValue(); } }; case PASSWORD: return new HasValueWidget() { private PasswordTextBox input = new PasswordTextBox(); @Override public Widget getWidget() { return input; } @Override public String getValue() { return this.input.getValue(); } }; case NEWPASSWORD: return new HasValueWidget() { private PasswordTextBox input = getPasswordInput(); protected final PasswordTextBox getPasswordInput() { final PasswordTextBox box = new PasswordTextBox(); //TODO(wenye): disable strength indication for now. The security Tsar said it is confusing. /* box.addKeyPressHandler( new KeyPressHandler( ) { @Override public void onKeyPress( KeyPressEvent arg0 ) { String strength = ValueChecker.WEAK; try { strength = checker.check( box.getValue( ) ); } catch ( InvalidValueException e ) { } LOG.log( Level.INFO, "Password strength: " + strength ); box.setStyleName( getPasswordStrengthStyleName( strength ) ); } } ); */ return box; } @Override public Widget getWidget() { return input; } @Override public String getValue() { return this.input.getValue(); } }; default: return null; } }
From source file:com.gmail.cjbooms.thesis.pythonappengine.client.menus.git.GitCommitLocalChangesDialogWidget.java
License:Open Source License
/** * Create and return the Text holder for the log messsage * @return//from w w w . j av a 2 s. c o m */ private VerticalPanel createLogMessageTextBox() { VerticalPanel logPanel = new VerticalPanel(); logPanel.add(new Label("Enter Log Message:")); TextArea logMessageBox = new TextArea(); logMessageBox.setCharacterWidth(40); logMessageBox.setVisibleLines(4); logMessageBox.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { logMessage = event.getValue(); } }); logPanel.add(logMessageBox); logPanel.setSpacing(10); logPanel.setHeight("100px"); return logPanel; }
From source file:com.google.gwt.examples.TextBoxExample.java
License:Apache License
public void onModuleLoad() { // Make some text boxes. The password text box is identical to the text // box, except that the input is visually masked by the browser. PasswordTextBox ptb = new PasswordTextBox(); TextBox tb = new TextBox(); // TODO(ECC) must be tested. tb.addKeyPressHandler(new KeyPressHandler() { public void onKeyPress(KeyPressEvent event) { if (!Character.isDigit(event.getCharCode())) { ((TextBox) event.getSource()).cancelKey(); }/* w w w. j a v a2 s . c o m*/ } }); // Let's make an 80x50 text area to go along with the other two. TextArea ta = new TextArea(); ta.setCharacterWidth(80); ta.setVisibleLines(50); // Add them to the root panel. VerticalPanel panel = new VerticalPanel(); panel.add(tb); panel.add(ptb); panel.add(ta); RootPanel.get().add(panel); }
From source file:com.google.gwt.sample.showcase.client.content.text.CwBasicText.java
License:Apache License
/** * Initialize this example./*from ww w. j av a2s.c o m*/ */ @ShowcaseSource @Override public Widget onInitialize() { // Create a panel to layout the widgets VerticalPanel vpanel = new VerticalPanel(); vpanel.setSpacing(5); // Add a normal and disabled text box TextBox normalText = new TextBox(); normalText.ensureDebugId("cwBasicText-textbox"); // Set the normal text box to automatically adjust its direction according // to the input text. Use the Any-RTL heuristic, which sets an RTL direction // iff the text contains at least one RTL character. normalText.setDirectionEstimator(AnyRtlDirectionEstimator.get()); TextBox disabledText = new TextBox(); disabledText.ensureDebugId("cwBasicText-textbox-disabled"); disabledText.setText(constants.cwBasicTextReadOnly()); disabledText.setEnabled(false); vpanel.add(new HTML(constants.cwBasicTextNormalLabel())); vpanel.add(createTextExample(normalText, true)); vpanel.add(createTextExample(disabledText, false)); // Add a normal and disabled password text box PasswordTextBox normalPassword = new PasswordTextBox(); normalPassword.ensureDebugId("cwBasicText-password"); PasswordTextBox disabledPassword = new PasswordTextBox(); disabledPassword.ensureDebugId("cwBasicText-password-disabled"); disabledPassword.setText(constants.cwBasicTextReadOnly()); disabledPassword.setEnabled(false); vpanel.add(new HTML("<br><br>" + constants.cwBasicTextPasswordLabel())); vpanel.add(createTextExample(normalPassword, true)); vpanel.add(createTextExample(disabledPassword, false)); // Add a text area TextArea textArea = new TextArea(); textArea.ensureDebugId("cwBasicText-textarea"); textArea.setVisibleLines(5); vpanel.add(new HTML("<br><br>" + constants.cwBasicTextAreaLabel())); vpanel.add(createTextExample(textArea, true)); // Return the panel return vpanel; }
From source file:com.google.javascript.jscomp.gwt.client.JsCompGwtMain.java
License:Apache License
@Override public void onModuleLoad() { final TextArea tb = new TextArea(); tb.setCharacterWidth(80);/*from w w w . j a v a 2 s .com*/ tb.setVisibleLines(25); tb.setReadOnly(true); final TextArea ta = new TextArea(); ta.setCharacterWidth(80); ta.setVisibleLines(25); ta.addKeyUpHandler(new KeyUpHandler() { public void onKeyUp(KeyUpEvent event) { clearConsole(); tb.setValue(compile(ta.getValue())); } }); VerticalPanel panel = new VerticalPanel(); panel.add(ta); panel.add(tb); RootPanel.get().add(panel); }
From source file:com.google.lotrepls.client.CommandPrompt.java
License:Apache License
/** * This creates an immutable copy of the prompt and input area suitable for * adding to the page./*from w w w .ja v a 2 s . c om*/ */ public Widget createImmutablePanel() { HorizontalPanel panelCopy = new HorizontalPanel(); Label promptCopy = new Label(prompt.getText()); promptCopy.setStyleName(prompt.getStyleName()); promptCopy.getElement().getStyle().setProperty("width", prompt.getElement().getStyle().getProperty("width")); panelCopy.add(promptCopy); final InterpreterType t = type; final String scriptText = inputArea.getText(); TextArea inputAreaCopy = new TextArea() { { this.addDomHandler(new DoubleClickHandler() { public void onDoubleClick(DoubleClickEvent event) { final DialogBox box = new DialogBox(); VerticalPanel boxPanel = new VerticalPanel(); boxPanel.add(new Label("Use the following URL to share this script with friends:")); String url = buildUrl(t, scriptText); boxPanel.add(new Anchor(trimUrl(url), url)); Button close = new Button("Close"); close.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { box.hide(); } }); close.setStyleName("closeButton"); boxPanel.add(close); box.add(boxPanel); box.getElement().getStyle().setProperty("border", "1px solid"); box.getElement().getStyle().setProperty("borderColor", "green"); box.getElement().getStyle().setProperty("backgroundColor", "black"); box.center(); } }, DoubleClickEvent.getType()); } }; inputAreaCopy.setStyleName(inputArea.getStyleName()); resizeInputArea(true); inputAreaCopy.setText(scriptText); inputAreaCopy.setVisibleLines(inputArea.getVisibleLines()); inputAreaCopy.setReadOnly(true); SimplePanel inputAreaDivCopy = new SimplePanel(); inputAreaDivCopy.add(inputAreaCopy); inputAreaDivCopy.getElement().setAttribute("style", inputAreaDiv.getElement().getAttribute("style")); panelCopy.add(inputAreaDivCopy); panelCopy.setCellWidth(inputAreaDivCopy, "100%"); return panelCopy; }
From source file:com.googlesource.gerrit.plugins.cookbook.client.FoodPreferencesScreen.java
License:Apache License
FoodPreferencesScreen() { setStyleName("cookbook-panel"); Panel messagePanel = new VerticalPanel(); messagePanel.add(new Label("Food Allergies or Dietary Concerns:")); TextArea txt = new TextArea(); txt.addKeyPressHandler(new KeyPressHandler() { @Override//from w ww.ja v a 2 s .co m public void onKeyPress(final KeyPressEvent event) { event.stopPropagation(); } }); txt.setVisibleLines(12); txt.setCharacterWidth(80); txt.getElement().setPropertyBoolean("spellcheck", false); messagePanel.add(txt); add(messagePanel); Button helloButton = new Button("Save"); helloButton.addStyleName("cookbook-helloButton"); helloButton.addClickHandler(new ClickHandler() { @Override public void onClick(final ClickEvent event) { Window.alert("TODO: implement save"); } }); add(helloButton); helloButton.setEnabled(true); }