List of usage examples for com.google.gwt.user.client.ui FlexTable FlexTable
public FlexTable()
From source file:com.google.gwt.gen2.demo.picker.client.PickerDemoPanel.java
License:Apache License
public PickerDemoPanel() { FlexTable table = new FlexTable(); // A TimePicker using AM/PM 12h format final TimePicker timePicker = new TimePicker(false); table.setHTML(3, 0, "Time picker:"); table.setWidget(3, 1, timePicker);//from w w w . j a v a 2s .c o m final CheckBox enableTimePicker = new CheckBox("Enable/disable"); enableTimePicker.setValue(timePicker.isEnabled()); enableTimePicker.addClickHandler(new ClickHandler() { public void onClick(ClickEvent source) { timePicker.setEnabled(enableTimePicker.getValue()); } }); table.setWidget(3, 2, enableTimePicker); // Creating a date time picker with AM/PM 12h TimePicker final DateTimePicker dateTimePicker = new DateTimePicker(false); dateTimePicker.setWidth("200px"); // Create a label to display the selected date final Label dateLabel = new Label(); Button getDate = new Button("Show date"); getDate.addClickHandler(new ClickHandler() { public void onClick(ClickEvent source) { // Display the selected date/time using DateTimeFormat dateLabel.setText(DateTimeFormat.getMediumDateTimeFormat().format(dateTimePicker.getDate())); } }); dateLabel.setStyleName("sandbox-Date"); table.setHTML(4, 0, "Date time picker:"); table.setWidget(4, 1, dateTimePicker); table.setWidget(5, 0, getDate); table.setWidget(5, 1, dateLabel); final CheckBox enableDateTimePicker = new CheckBox("Enable/disable"); enableDateTimePicker.setValue(dateTimePicker.isEnabled()); enableDateTimePicker.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { dateTimePicker.setEnabled(enableDateTimePicker.getValue()); } }); table.setWidget(4, 2, enableDateTimePicker); final TimePicker customTimePicker = new TimePicker(new Date(), null, DateTimeFormat.getFormat("HH"), DateTimeFormat.getFormat("mm"), null); table.setHTML(8, 0, "Another time picker (24h):"); table.setWidget(8, 1, customTimePicker); final CheckBox enable = new CheckBox("Enable/disable"); enable.setValue(customTimePicker.isEnabled()); enable.addClickHandler(new ClickHandler() { public void onClick(ClickEvent sender) { customTimePicker.setEnabled(enable.getValue()); } }); table.setWidget(8, 2, enable); initWidget(table); }
From source file:com.google.gwt.maps.sample.hellomaps.client.MapEventDemo.java
License:Apache License
public MapEventDemo() { VerticalPanel vp = new VerticalPanel(); // Center the new map on Midtown Atlanta map = new MapWidget(ATLANTA, 13); map.setSize("500px", "300px"); map.addControl(new SmallMapControl()); map.addControl(new MapTypeControl()); MarkerOptions opt = MarkerOptions.newInstance(); opt.setDraggable(true);/*ww w.java2 s .c o m*/ marker = new Marker(ATLANTA, opt); Panel hp1 = createActionButtons(); HorizontalPanel hp2 = createListenerListBox(); // Make a spacer HorizontalPanel hp3 = new HorizontalPanel(); hp3.add(new Label(" ")); hp3.setSize("1em", "1em"); handlerTable = new FlexTable(); clearListenerTable(); vp.add(map); vp.add(hp1); vp.add(hp2); vp.add(hp3); vp.add(handlerTable); initWidget(vp); }
From source file:com.google.gwt.sample.contacts.client.view.EditContactView.java
public EditContactView() { DecoratorPanel contentDetailsDecorator = new DecoratorPanel(); contentDetailsDecorator.setWidth("18em"); initWidget(contentDetailsDecorator); VerticalPanel contentDetailsPanel = new VerticalPanel(); contentDetailsPanel.setWidth("100%"); // Create the contacts list ////from www. j av a 2s . co m detailsTable = new FlexTable(); detailsTable.setCellSpacing(0); detailsTable.setWidth("100%"); detailsTable.addStyleName("contacts-ListContainer"); detailsTable.getColumnFormatter().addStyleName(1, "add-contact-input"); firstName = new TextBox(); lastName = new TextBox(); emailAddress = new TextBox(); initDetailsTable(); contentDetailsPanel.add(detailsTable); HorizontalPanel menuPanel = new HorizontalPanel(); saveButton = new Button("Save"); cancelButton = new Button("Cancel"); menuPanel.add(saveButton); menuPanel.add(cancelButton); contentDetailsPanel.add(menuPanel); contentDetailsDecorator.add(contentDetailsPanel); }
From source file:com.google.gwt.sample.dynatablemvp.client.view.DynaTableMvpView.java
@UiConstructor public DynaTableMvpView(/*EventBus eventBus*/) { // this.eventBus = eventBus; initWidget(GWT.<Binder>create(Binder.class).createAndBindUi(this)); addButton = new Button("Add"); deleteButton = new Button("Delete"); // contentTable=new FlexTable(); contactsTable = new FlexTable(); /*//from ww w. j ava 2 s. c o m * FavoritesManager manager = new FavoritesManager(); * PersonEditorWorkflow.register(manager); * * calendar = new SummaryWidget(15); favorites = new * FavoritesWidget(manager); filter = new DayFilterWidget(); */ }
From source file:com.google.gwt.sample.healthyeatingapp.client.FoodLog.FoodLog.java
public FlowPanel onModuleLoad() { rpcUserNameCall();/*from w w w . ja v a 2 s .c o m*/ rpcCall(); // Create a Flex Table final FlexTable flexTable = new FlexTable(); FlexCellFormatter cellFormatter = flexTable.getFlexCellFormatter(); flexTable.addStyleName("flexTable"); flexTable.setCellSpacing(2); flexTable.setCellPadding(2); lbFG = new ListBox(); lbFN = new ListBox(); submit = new Button("Submit"); cancel = new Button("Pick a New Date"); fp = new FlowPanel(); // Add some text cellFormatter.setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_CENTER); flexTable.setHTML(0, 0, "This table allows you to log your food entries:"); cellFormatter.setColSpan(0, 0, 2); lbFG.setVisibleItemCount(1); lbFN.setVisible(false); lbFG.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { fp.remove(SuccessLabel); int selectedIndex = lbFG.getSelectedIndex(); int numRows = 0; if (selectedIndex > 0) { numRows = flexTable.getRowCount(); flexTable.setWidget(numRows - 1, 0, lbFG); lbFN.clear(); caloriesText.setText("", Direction.DEFAULT); String test = lbFG.getValue(lbFG.getSelectedIndex()); String[] str = getFoodNames(ret, test); lbFN.addItem(""); for (String s : str) { lbFN.addItem(s); } lbFN.setSelectedIndex(0); lbFN.setVisible(true); flexTable.setWidget(numRows - 1, 1, lbFN); } } }); lbFN.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { int selectedIndex = lbFN.getSelectedIndex(); int numRows = 0; if (selectedIndex > 0) numRows = flexTable.getRowCount(); flexTable.setWidget(numRows - 1, 1, lbFN); String test = lbFN.getValue(lbFN.getSelectedIndex()); String str = "" + getCalories(ret, test); caloriesText.setText(str, Direction.DEFAULT); flexTable.setWidget(numRows - 1, 2, caloriesText); } }); // Add a button that will add more rows to the table final Button addRowButton = new Button("Add a Row"); Button btn2 = new Button("Update"); addRowButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { fp.remove(SuccessLabel); addRow(flexTable); } }); addRowButton.addStyleName("fixedWidthButton"); VerticalPanel buttonPanel = new VerticalPanel(); buttonPanel.setStyleName("flexTable-buttonPanel"); buttonPanel.add(addRowButton); flexTable.setWidget(0, 1, buttonPanel); cellFormatter.setVerticalAlignment(0, 1, HasVerticalAlignment.ALIGN_TOP); // Add two rows to start // addRow(flexTable); final DatePicker datePicker = new DatePicker(); // Set the value in the text box when the user selects a date datePicker.addValueChangeHandler(new ValueChangeHandler<Date>() { public void onValueChange(ValueChangeEvent<Date> event) { Date date = event.getValue(); DateFormat dfm = new SimpleDateFormat("yyyy-MM-dd"); dateString = dfm.format(date); dateLabel.setText(dateString, Direction.DEFAULT); selectedDate = dateLabel.getText(); queryRpcCall(userNameTyped, selectedDate); } }); final Button Btn2 = new Button(); ret = new ArrayList<FoodLogItems>(); Btn2.setSize("100px", "30px"); Btn2.setText("View/Update"); Btn2.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { Btn2.setVisible(false); datePicker.setVisible(false); selectedDate = dateLabel.getText(); String[] dbRows; String[] dbElements; // Window.alert(prevFoodData); if (!(prevFoodData.equals(""))) { dbRows = prevFoodData.split(";"); for (String s : dbRows) { dbElements = s.split(":"); FoodLogData e = new FoodLogData(userNameTyped, dbElements[2], Integer.parseInt(dbElements[1]), dbElements[0], selectedDate); foodEntries.add(e); } } String[] temp; if (foodLogItems != null) { array = foodLogItems.split(";"); // String s=""; for (String s : array) { temp = s.split(":"); FoodLogItems e = new FoodLogItems(temp[0], Integer.parseInt(temp[1]), temp[2]); ret.add(e); } lbFG.addItem(""); String[] input = new String[ret.size()]; int i = 0; for (FoodLogItems e : ret) { input[i] = e.FoodGroup(); i++; } Set<String> tmp = new LinkedHashSet<String>(); for (String each : input) { tmp.add(each); } String[] output = new String[tmp.size()]; int j = 0; for (String each : tmp) { output[j++] = each; } for (String s : output) { lbFG.addItem(s); } lbFG.setSelectedIndex(0); } int numRows = flexTable.getRowCount(); // Window.alert(""+numRows); flexTable.removeAllRows(); flexTable.insertRow(0); int i = 0; for (FoodLogData j : foodEntries) { flexTable.insertRow(i + 1); numRows = flexTable.getRowCount(); flexTable.setText(numRows - 1, 0, j.getFoodGroup()); flexTable.setText(numRows - 1, 1, j.getFoodName()); flexTable.setText(numRows - 1, 2, j.getCalories() + ""); flexTable.getFlexCellFormatter().setRowSpan(0, 1, numRows + 1); i++; } numRows = flexTable.getRowCount(); lbFG.setSelectedIndex(0); flexTable.setWidget(numRows, 0, lbFG); flexTable.getFlexCellFormatter().setRowSpan(0, 1, numRows + 1); fp.add(flexTable); fp.add(addRowButton); fp.add(submit); fp.add(cancel); } }); InlineLabel dateMessageLabel = new InlineLabel(); dateMessageLabel.setText("Pick a date: "); submit.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { System.out.println("Submitting these items"); for (FoodLogData e : foodEntries) { System.out.println("Food name is " + e.getFoodName()); insertRpcCall(e.getUserName(), e.getFoodName(), e.getDate(), e.getCalories()); } fp.add(SuccessLabel); foodEntries.clear(); } }); cancel.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // TODO Auto-generated method stub fp.remove(SuccessLabel); Window.Location.reload(); } }); fp.add(dateMessageLabel); fp.add(dateLabel); fp.add(datePicker); fp.add(Btn2); return fp; }
From source file:com.google.gwt.sample.healthyeatingapp.client.SocialMedia.SocialMedia.java
public FlowPanel SocialMediaWebPageLoad() { fp = new FlowPanel(); ft = new FlexTable(); flexTableInitialize(ft);/*from www . jav a2 s .c om*/ Btn = new Button(); Btn.setSize("100px", "30px"); Btn.setText("Update"); Btn.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { PointsList.clear(); ft.removeAllRows(); ft.setText(0, 0, "Updating"); ft.getFlexCellFormatter().setColSpan(0, 0, 3); ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER); if (FBFriends.Friends.size() == 0) { System.out.println("Querying Facebook again"); Window.alert("Please authenticate with Facebook to use this feature"); FacebookGraph.getStaticObject().RequestAuthorizationAndQueryGraph("me/friends", new Callback<JSONObject, Throwable>() { @Override public void onFailure(Throwable reason) { // TODO Auto-generated method stub System.out.println(reason.getMessage()); } @Override public void onSuccess(JSONObject result) { // TODO Auto-generated method stub JSONArray datas = (JSONArray) result.get("data"); for (int i = 0; i < datas.size(); i++) { JSONObject friend = (JSONObject) datas.get(i); FBFriends.FriendsNames.add(friend.get("name").toString()); } FBFriends.FriendsNameSort(FBFriends.FriendsNames); VerifyFriendAsUser(); } }); } VerifyFriendAsUser(); } }); fp.add(ft); fp.add(Btn); if (FBFriends.Friends.size() != 0) { VerifyFriendAsUser(); } //flexTablePaint();*/ return fp; }
From source file:com.google.gwt.sample.i18n.client.I18N.java
License:Apache License
private void initDictionaryExample() { FlexTable t = new FlexTable(); t.setStyleName("i18n-dictionary"); bindElement("dictionaryExample", t); Dictionary userInfo = Dictionary.getDictionary("userInfo"); Iterator<String> s = userInfo.keySet().iterator(); for (int i = 0; s.hasNext(); i++) { String key = s.next();// ww w . j av a2 s . co m t.setText(0, i, key); t.setText(1, i, userInfo.get(key)); } t.getRowFormatter().setStyleName(0, "i18n-dictionary-header-row"); }
From source file:com.google.gwt.sample.showcase.client.content.i18n.CwBidiFormatting.java
License:Apache License
/** * Initialize this example.//w ww .jav a2 s .c o m */ @ShowcaseSource @Override public Widget onInitialize() { // Create the internationalized blog messages blogMessages = GWT.create(BlogMessages.class); // Use a FlexTable to layout the content FlexTable layout = new FlexTable(); FlexCellFormatter formatter = layout.getFlexCellFormatter(); layout.setCellSpacing(5); // Add a link to the source code of the Interface final String rawFile = getSimpleName(BlogMessages.class); Anchor link = new Anchor(rawFile); link.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { fireRawSourceRequest(rawFile + ".java"); } }); HorizontalPanel linkPanel = new HorizontalPanel(); linkPanel.setSpacing(3); linkPanel.add(new HTML(constants.cwBidiFormattingLinkText())); linkPanel.add(link); layout.setWidget(0, 0, linkPanel); formatter.setColSpan(0, 0, 2); // Show the template for reference String template = blogMessages.userComment("{0}", "{1}", "{2}"); layout.setHTML(1, 0, constants.cwBidiFormattingTemplateLabel()); layout.setHTML(1, 1, template); // Add argument 0 arg0Box = new TextBox(); // Using an initial value whose direction is opposite the locale's direction // demonstrates the need for and effect of bidi formatting. arg0Box.setText(LocaleInfo.getCurrentLocale().isRTL() ? "Tom Bombadil" : " "); layout.setHTML(2, 0, constants.cwBidiFormattingArg0Label()); layout.setWidget(2, 1, arg0Box); // Add argument 1 arg1Box = new TextBox(); arg1Box.setText("16"); layout.setHTML(3, 0, constants.cwBidiFormattingArg1Label()); layout.setWidget(3, 1, arg1Box); // Add argument 2 arg2Box = new TextBox(); // Using an initial value whose direction is opposite the locale's direction // demonstrates the need for and effect of bidi formatting. arg2Box.setText( LocaleInfo.getCurrentLocale().isRTL() ? "How deep is your love?" : " ?"); layout.setHTML(4, 0, constants.cwBidiFormattingArg2Label()); layout.setWidget(4, 1, arg2Box); // Add the unformatted message message = new HTML(); layout.setHTML(5, 0, constants.cwBidiFormattingNonbidiFormattedLabel()); layout.setWidget(5, 1, message); formatter.setVerticalAlignment(5, 0, HasVerticalAlignment.ALIGN_TOP); // Add the bidi formatted message bidiFormattedMessage = new HTML(); layout.setHTML(6, 0, constants.cwBidiFormattingBidiFormattedLabel()); layout.setWidget(6, 1, bidiFormattedMessage); formatter.setVerticalAlignment(6, 0, HasVerticalAlignment.ALIGN_TOP); // Add handlers to all of the argument boxes KeyUpHandler keyUpHandler = new KeyUpHandler() { public void onKeyUp(KeyUpEvent event) { updateMessages(); } }; arg0Box.addKeyUpHandler(keyUpHandler); arg1Box.addKeyUpHandler(keyUpHandler); arg2Box.addKeyUpHandler(keyUpHandler); // Return the layout Widget updateMessages(); return layout; }
From source file:com.google.gwt.sample.showcase.client.content.i18n.CwConstantsExample.java
License:Apache License
/** * Initialize this example.//from w w w . j a va2 s. co m */ @ShowcaseSource @Override public Widget onInitialize() { // Create the internationalized constants ExampleConstants exampleConstants = GWT.create(ExampleConstants.class); // Use a FlexTable to layout the content FlexTable layout = new FlexTable(); FlexCellFormatter formatter = layout.getFlexCellFormatter(); layout.setCellSpacing(5); // Add a link to the source code of the Interface final String rawFile = getSimpleName(ExampleConstants.class); Anchor link = new Anchor(rawFile); link.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { fireRawSourceRequest(rawFile + ".java"); } }); HorizontalPanel linkPanel = new HorizontalPanel(); linkPanel.setSpacing(3); linkPanel.add(new HTML(constants.cwConstantsExampleLinkText())); linkPanel.add(link); layout.setWidget(0, 0, linkPanel); formatter.setColSpan(0, 0, 2); // Show the first name TextBox firstNameBox = new TextBox(); firstNameBox.setText("Amelie"); firstNameBox.setWidth("17em"); layout.setHTML(1, 0, exampleConstants.firstName()); layout.setWidget(1, 1, firstNameBox); // Show the last name TextBox lastNameBox = new TextBox(); lastNameBox.setText("Crutcher"); lastNameBox.setWidth("17em"); layout.setHTML(2, 0, exampleConstants.lastName()); layout.setWidget(2, 1, lastNameBox); // Create a list box of favorite colors ListBox colorBox = new ListBox(); Map<String, String> colorMap = exampleConstants.colorMap(); for (Map.Entry<String, String> entry : colorMap.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); colorBox.addItem(value, key); } layout.setHTML(3, 0, exampleConstants.favoriteColor()); layout.setWidget(3, 1, colorBox); // Return the layout Widget return layout; }
From source file:com.google.gwt.sample.showcase.client.content.i18n.CwConstantsWithLookupExample.java
License:Apache License
/** * Initialize this example.//from w ww. j a va2 s . c om */ @ShowcaseSource @Override public Widget onInitialize() { // Create the internationalized constants colorConstants = GWT.create(ColorConstants.class); // Use a FlexTable to layout the content FlexTable layout = new FlexTable(); FlexCellFormatter formatter = layout.getFlexCellFormatter(); layout.setCellSpacing(5); // Add a link to the source code of the Interface final String rawFile = getSimpleName(ColorConstants.class); Anchor link = new Anchor(rawFile); link.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { fireRawSourceRequest(rawFile + ".java"); } }); HorizontalPanel linkPanel = new HorizontalPanel(); linkPanel.setSpacing(3); linkPanel.add(new HTML(constants.cwConstantsWithLookupExampleLinkText())); linkPanel.add(link); layout.setWidget(0, 0, linkPanel); formatter.setColSpan(0, 0, 2); // Add a field so the user can type a color colorBox = new TextBox(); colorBox.setText("red"); colorBox.setWidth("17em"); layout.setHTML(1, 0, constants.cwConstantsWithLookupExampleMethodName()); layout.setWidget(1, 1, colorBox); // Show the last name colorResultsBox = new TextBox(); colorResultsBox.setEnabled(false); colorResultsBox.setWidth("17em"); layout.setHTML(2, 0, constants.cwConstantsWithLookupExampleResults()); layout.setWidget(2, 1, colorResultsBox); // Add a handler to update the color as the user types a lookup value colorBox.addKeyUpHandler(new KeyUpHandler() { public void onKeyUp(KeyUpEvent event) { updateColor(); } }); // Return the layout Widget updateColor(); return layout; }