/** * Use this constructor only when you are subclassing TextAreaFieldWidget and need the special * case provided by the willEncapsulate parameter. * * @param fieldDef the FieldDef that is the Model for this TextAreaFieldWidget * @param willEncapsulate this parameter should be true only if you are subclassing text box and * plan to wrap it in another widget. If true, you must call initWidget() in the subclass and * TextAreaFieldWidget will not call it. This parameter is rarely used */ protected TextAreaInputField(FieldDef fieldDef, boolean willEncapsulate) { _fieldDef = fieldDef; _textArea = new TextArea(); _textArea.setSize("250px", "135px"); addHandlers(); if (!willEncapsulate) initWidget(_textArea); _textArea.setTitle(_fieldDef.getShortDesc()); if (_fieldDef.getDefaultValueAsString() != null) { _textArea.setText(_fieldDef.getDefaultValueAsString()); } }
public void createCritRefTextArea( final FlowPanel flowPanel, final ScrollPanel scrollPanel, String critRefStringBuilder) { final TextArea critReftextArea = new TextArea(); critReftextArea.setStyleName("textarea_noborder"); critReftextArea.addStyleName("criteriaRef_background"); critReftextArea.setText(critRefStringBuilder); flowPanel.add(critReftextArea); critReftextArea.setReadOnly(true); critReftextArea.setWidth("100%"); critReftextArea.setHeight("100%"); critReftextArea.setVisibleLines(critRefStringBuilder.split("\\r?\\n").length + 1); critReftextArea.setTitle("Double click to go see the entry."); critReftextArea.addDoubleClickHandler( new DoubleClickHandler() { @Override public void onDoubleClick(DoubleClickEvent event) { handleTextAreaClick(flowPanel, event, critReftextArea, scrollPanel); } }); }
private void init() { setModal(true); setAnimationEnabled(true); ensureDebugId("cwDialogBox"); setText("New Recipe"); // Create a table to layout the content VerticalPanel dialogContents = new VerticalPanel(); setWidget(dialogContents); HorizontalPanel namePanel = new HorizontalPanel(); namePanel.setSpacing(6); namePanel.add(new Label("Name:")); nameTextBox = new TextBox(); nameTextBox.setWidth("600px"); namePanel.add(nameTextBox); HorizontalPanel categoriesPanel = new HorizontalPanel(); categoriesPanel.setSpacing(6); categoriesPanel.add(new Label("Category")); category.addItem("Fish"); category.addItem("Meat"); category.addItem("Poultry"); categoriesPanel.add(category); categoriesPanel.add(new Label("Cuisine")); cuisine.addItem("American"); cuisine.addItem("Mexican"); cuisine.addItem("Italian"); categoriesPanel.add(cuisine); categoriesPanel.add(new Label("Occasion")); occasion.addItem("Easter"); occasion.addItem("Summer"); occasion.addItem("Thanksgiving"); categoriesPanel.add(occasion); categoriesPanel.add(new Label("Serves")); serves.addItem("1"); serves.addItem("4"); serves.addItem("12"); serves.setItemSelected(1, true); categoriesPanel.add(serves); ingredients = new TextArea(); ingredients.setTitle("Ingredients"); ingredients.setHeight("200px"); ingredients.setWidth("600px"); Label ingredientsLabel = new Label("Ingredients"); directions = new TextArea(); directions.setTitle("Directions"); directions.setHeight("200px"); directions.setWidth("600px"); Label directionsLabel = new Label("Directions"); FlexTable grid = new FlexTable(); grid.setWidget(0, 0, ingredientsLabel); grid.getCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_TOP); grid.getCellFormatter().setVerticalAlignment(1, 0, HasVerticalAlignment.ALIGN_TOP); grid.setWidget(0, 1, ingredients); dialogContents.add(namePanel); grid.setWidget(1, 0, directionsLabel); grid.setWidget(1, 1, directions); dialogContents.setCellHeight(namePanel, "50px"); dialogContents.add(categoriesPanel); dialogContents.setCellHeight(namePanel, "50px"); dialogContents.add(grid); // Add a close button at the bottom of the dialog Button closeButton = new Button( "Close", new ClickHandler() { public void onClick(ClickEvent event) { hide(); } }); Button createButton = new Button( "Create Recipe", new ClickHandler() { public void onClick(ClickEvent event) { GWT.log("Creating Recipe: " + nameTextBox.getText(), null); addRecipe( new RecipeTO( nameTextBox.getText(), category.getValue(category.getSelectedIndex()), cuisine.getValue(cuisine.getSelectedIndex()), occasion.getValue(occasion.getSelectedIndex()), serves.getValue(serves.getSelectedIndex()), ingredients.getText(), directions.getText())); hide(); } }); Button saveButton = new Button( "Save Recipe", new ClickHandler() { public void onClick(ClickEvent event) { GWT.log("Updating Recipe: " + nameTextBox.getText(), null); updateRecipe( new RecipeTO( nameTextBox.getText(), category.getValue(category.getSelectedIndex()), cuisine.getValue(cuisine.getSelectedIndex()), occasion.getValue(occasion.getSelectedIndex()), serves.getValue(serves.getSelectedIndex()), ingredients.getText(), directions.getText())); hide(); mainView.loadRecipes(); RootPanel.get("stockList").remove(0); RootPanel.get("stockList").add(mainView); History.newItem("hoho"); } }); HorizontalPanel buttonPanel = new HorizontalPanel(); buttonPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); // Display update or create button if recipe exists and is being edited if (recipeExists) { buttonPanel.add(saveButton); } else { buttonPanel.add(createButton); } buttonPanel.add(closeButton); dialogContents.add(buttonPanel); // Return the dialog box }