List of usage examples for com.google.gwt.user.client.ui FlexTable FlexTable
public FlexTable()
From source file:com.google.gwt.sample.showcase.client.content.i18n.CwDictionaryExample.java
License:Apache License
/** * Initialize this example.// ww w.ja v a 2 s.co m */ @ShowcaseSource @Override public Widget onInitialize() { // Create a vertical panel to layout the contents VerticalPanel layout = new VerticalPanel(); // Show the HTML variable that defines the dictionary HTML source = new HTML("<pre>var userInfo = {\n" + " name: \"Amelie Crutcher\",\n" + " timeZone: \"EST\",\n" + " userID: \"123\",\n" + " lastLogOn: \"2/2/2006\"\n" + "};</pre>\n"); source.getElement().setDir("ltr"); source.getElement().getStyle().setProperty("textAlign", "left"); layout.add(new HTML(constants.cwDictionaryExampleLinkText())); layout.add(source); // Create the Dictionary of data FlexTable userInfoGrid = new FlexTable(); CellFormatter formatter = userInfoGrid.getCellFormatter(); Dictionary userInfo = Dictionary.getDictionary("userInfo"); Set<String> keySet = userInfo.keySet(); int columnCount = 0; for (String key : keySet) { // Get the value from the set String value = userInfo.get(key); // Add a column with the data userInfoGrid.setHTML(0, columnCount, key); formatter.addStyleName(0, columnCount, "cw-DictionaryExample-header"); userInfoGrid.setHTML(1, columnCount, value); formatter.addStyleName(1, columnCount, "cw-DictionaryExample-data"); // Go to the next column columnCount++; } layout.add(new HTML("<br><br>")); layout.add(userInfoGrid); // Return the layout Widget return layout; }
From source file:com.google.gwt.sample.showcase.client.content.i18n.CwMessagesExample.java
License:Apache License
/** * Initialize this example.// w w w . ja va 2s . c o m */ @ShowcaseSource @Override public Widget onInitialize() { // Create the internationalized error messages errorMessages = GWT.create(ErrorMessages.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(ErrorMessages.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.cwMessagesExampleLinkText())); linkPanel.add(link); layout.setWidget(0, 0, linkPanel); formatter.setColSpan(0, 0, 2); // Show the template for reference String template = errorMessages.permissionDenied("{0}", "{1}", "{2}"); layout.setHTML(1, 0, constants.cwMessagesExampleTemplateLabel()); layout.setHTML(1, 1, template); // Add argument 0 arg0Box = new TextBox(); arg0Box.setText("amelie"); layout.setHTML(2, 0, constants.cwMessagesExampleArg0Label()); layout.setWidget(2, 1, arg0Box); // Add argument 1 arg1Box = new TextBox(); arg1Box.setText("guest"); layout.setHTML(3, 0, constants.cwMessagesExampleArg1Label()); layout.setWidget(3, 1, arg1Box); // Add argument 2 arg2Box = new TextBox(); arg2Box.setText("/secure/blueprints.xml"); layout.setHTML(4, 0, constants.cwMessagesExampleArg2Label()); layout.setWidget(4, 1, arg2Box); // Add the formatted message formattedMessage = new HTML(); layout.setHTML(5, 0, constants.cwMessagesExampleFormattedLabel()); layout.setWidget(5, 1, formattedMessage); formatter.setVerticalAlignment(5, 0, HasVerticalAlignment.ALIGN_TOP); // Add handlers to all of the argument boxes KeyUpHandler keyUpHandler = new KeyUpHandler() { public void onKeyUp(KeyUpEvent event) { updateMessage(); } }; arg0Box.addKeyUpHandler(keyUpHandler); arg1Box.addKeyUpHandler(keyUpHandler); arg2Box.addKeyUpHandler(keyUpHandler); // Return the layout Widget updateMessage(); return layout; }
From source file:com.google.gwt.sample.showcase.client.content.i18n.CwPluralFormsExample.java
License:Apache License
/** * Initialize this example.//from w ww. j a va 2 s .c o m */ @ShowcaseSource @Override public Widget onInitialize() { // Create the internationalized error messages pluralMessages = GWT.create(PluralMessages.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(PluralMessages.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.cwPluralFormsExampleLinkText())); linkPanel.add(link); layout.setWidget(0, 0, linkPanel); formatter.setColSpan(0, 0, 2); // Add argument 0 arg0Box = new TextBox(); arg0Box.setText("13"); layout.setHTML(2, 0, constants.cwPluralFormsExampleArg0Label()); layout.setWidget(2, 1, arg0Box); // Add the formatted message formattedMessage = new Label(); layout.setHTML(5, 0, constants.cwPluralFormsExampleFormattedLabel()); layout.setWidget(5, 1, formattedMessage); formatter.setVerticalAlignment(5, 0, HasVerticalAlignment.ALIGN_TOP); // Add handlers to all of the argument boxes KeyUpHandler keyUpHandler = new KeyUpHandler() { public void onKeyUp(KeyUpEvent event) { updateMessage(); } }; arg0Box.addKeyUpHandler(keyUpHandler); // Return the layout Widget updateMessage(); return layout; }
From source file:com.google.gwt.sample.showcase.client.content.panels.CwAbsolutePanel.java
License:Apache License
/** * Create an options panel that allows users to select a widget and reposition * it./* w ww . j a v a 2s.co m*/ * * @return the new options panel */ @ShowcaseSource private Widget createOptionsBar() { // Create a panel to move components around FlexTable optionsBar = new FlexTable(); topPosBox = new TextBox(); topPosBox.setWidth("3em"); topPosBox.setText("100"); leftPosBox = new TextBox(); leftPosBox.setWidth("3em"); leftPosBox.setText("60"); listBox = new ListBox(); optionsBar.setHTML(0, 0, constants.cwAbsolutePanelItemsToMove()); optionsBar.setWidget(0, 1, listBox); optionsBar.setHTML(1, 0, constants.cwAbsolutePanelTop()); optionsBar.setWidget(1, 1, topPosBox); optionsBar.setHTML(2, 0, constants.cwAbsolutePanelLeft()); optionsBar.setWidget(2, 1, leftPosBox); // Add the widgets to the list box for (String name : widgetMap.keySet()) { listBox.addItem(name); } // Set the current item position when the user selects an item listBox.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { updateSelectedItem(); } }); // Move the item as the user changes the value in the left and top boxes KeyUpHandler repositionHandler = new KeyUpHandler() { public void onKeyUp(KeyUpEvent event) { repositionItem(); } }; topPosBox.addKeyUpHandler(repositionHandler); leftPosBox.addKeyUpHandler(repositionHandler); // Return the options bar return optionsBar; }
From source file:com.google.gwt.sample.showcase.client.content.panels.CwDecoratorPanel.java
License:Apache License
/** * Initialize this example./*www . j a v a2 s . co m*/ */ @ShowcaseSource @Override public Widget onInitialize() { // Create a table to layout the form options FlexTable layout = new FlexTable(); layout.setCellSpacing(6); FlexCellFormatter cellFormatter = layout.getFlexCellFormatter(); // Add a title to the form layout.setHTML(0, 0, constants.cwDecoratorPanelFormTitle()); cellFormatter.setColSpan(0, 0, 2); cellFormatter.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER); // Add some standard form options layout.setHTML(1, 0, constants.cwDecoratorPanelFormName()); layout.setWidget(1, 1, new TextBox()); layout.setHTML(2, 0, constants.cwDecoratorPanelFormDescription()); layout.setWidget(2, 1, new TextBox()); // Wrap the content in a DecoratorPanel DecoratorPanel decPanel = new DecoratorPanel(); decPanel.setWidget(layout); return decPanel; }
From source file:com.google.gwt.sample.showcase.client.content.panels.CwDisclosurePanel.java
License:Apache License
/** * Create a form that contains undisclosed advanced options. *//*from w w w .jav a2 s .c o m*/ @ShowcaseSource private Widget createAdvancedForm() { // Create a table to layout the form options FlexTable layout = new FlexTable(); layout.setCellSpacing(6); layout.setWidth("300px"); FlexCellFormatter cellFormatter = layout.getFlexCellFormatter(); // Add a title to the form layout.setHTML(0, 0, constants.cwDisclosurePanelFormTitle()); cellFormatter.setColSpan(0, 0, 2); cellFormatter.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER); // Add some standard form options layout.setHTML(1, 0, constants.cwDisclosurePanelFormName()); layout.setWidget(1, 1, new TextBox()); layout.setHTML(2, 0, constants.cwDisclosurePanelFormDescription()); layout.setWidget(2, 1, new TextBox()); // Create some advanced options HorizontalPanel genderPanel = new HorizontalPanel(); String[] genderOptions = constants.cwDisclosurePanelFormGenderOptions(); for (int i = 0; i < genderOptions.length; i++) { genderPanel.add(new RadioButton("gender", genderOptions[i])); } Grid advancedOptions = new Grid(2, 2); advancedOptions.setCellSpacing(6); advancedOptions.setHTML(0, 0, constants.cwDisclosurePanelFormLocation()); advancedOptions.setWidget(0, 1, new TextBox()); advancedOptions.setHTML(1, 0, constants.cwDisclosurePanelFormGender()); advancedOptions.setWidget(1, 1, genderPanel); // Add advanced options to form in a disclosure panel DisclosurePanel advancedDisclosure = new DisclosurePanel(constants.cwDisclosurePanelFormAdvancedCriteria()); advancedDisclosure.setAnimationEnabled(true); advancedDisclosure.ensureDebugId("cwDisclosurePanel"); advancedDisclosure.setContent(advancedOptions); layout.setWidget(3, 0, advancedDisclosure); cellFormatter.setColSpan(3, 0, 2); // Wrap the contents in a DecoratorPanel DecoratorPanel decPanel = new DecoratorPanel(); decPanel.setWidget(layout); return decPanel; }
From source file:com.google.gwt.sample.showcase.client.content.tables.CwFlexTable.java
License:Apache License
/** * Initialize this example./*from w ww. j a va2 s . co m*/ */ @ShowcaseSource @Override public Widget onInitialize() { // Create a Flex Table final FlexTable flexTable = new FlexTable(); FlexCellFormatter cellFormatter = flexTable.getFlexCellFormatter(); flexTable.addStyleName("cw-FlexTable"); flexTable.setWidth("32em"); flexTable.setCellSpacing(5); flexTable.setCellPadding(3); // Add some text cellFormatter.setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_LEFT); flexTable.setHTML(0, 0, constants.cwFlexTableDetails()); cellFormatter.setColSpan(0, 0, 2); // Add a button that will add more rows to the table Button addRowButton = new Button(constants.cwFlexTableAddRow(), new ClickHandler() { public void onClick(ClickEvent event) { addRow(flexTable); } }); addRowButton.addStyleName("sc-FixedWidthButton"); Button removeRowButton = new Button(constants.cwFlexTableRemoveRow(), new ClickHandler() { public void onClick(ClickEvent event) { removeRow(flexTable); } }); removeRowButton.addStyleName("sc-FixedWidthButton"); VerticalPanel buttonPanel = new VerticalPanel(); buttonPanel.setStyleName("cw-FlexTable-buttonPanel"); buttonPanel.add(addRowButton); buttonPanel.add(removeRowButton); flexTable.setWidget(0, 1, buttonPanel); cellFormatter.setVerticalAlignment(0, 1, HasVerticalAlignment.ALIGN_TOP); // Add two rows to start addRow(flexTable); addRow(flexTable); // Return the panel flexTable.ensureDebugId("cwFlexTable"); return flexTable; }
From source file:com.google.gwt.sample.simplerpc.client.SimpleRPC.java
License:Apache License
/** * Create an asynchronous callback for the <code>getMultipleStrings</code> * RPC call. The same callback can be used for many RPC calls or customized * for a single one./*from ww w. j a va 2s . c om*/ */ private AsyncCallback<Map<Integer, String>> createGetMultipleStringsCallback(final Panel root) { return new AsyncCallback<Map<Integer, String>>() { public void onFailure(Throwable caught) { Window.alert("error: " + caught); } public void onSuccess(Map<Integer, String> result) { FlexTable t = new FlexTable(); t.setBorderWidth(2); t.setHTML(0, 0, "<b>Map Key</b>"); t.setHTML(0, 1, "<b>Map Value</b>"); int index = 1; for (Entry<Integer, String> element : result.entrySet()) { Integer key = element.getKey(); String value = element.getValue(); t.setText(index, 0, key.toString()); t.setText(index, 1, value); ++index; } root.add(new HTML("<h3>Result(on success)</h3>")); root.add(t); } }; }
From source file:com.google.gwt.sample.simplexml.client.SimpleXML.java
License:Apache License
private FlexTable createOrderTable(FlowPanel xmlParsed, String label) { HTML orderTableLabel = new HTML("<h2>" + label + "</h2>"); xmlParsed.add(orderTableLabel);//from ww w. j a v a 2s . c om FlexTable orderTable = new FlexTable(); orderTable.setStyleName(USER_TABLE_STYLE); orderTable.setBorderWidth(3); orderTable.getRowFormatter().setStyleName(0, USER_TABLE_LABEL_STYLE); orderTable.setText(0, 0, "Order ID"); orderTable.setText(0, 1, "Item"); orderTable.setText(0, 2, "Ordered On"); orderTable.setText(0, 3, "Street"); orderTable.setText(0, 4, "City"); orderTable.setText(0, 5, "State"); orderTable.setText(0, 6, "Zip"); xmlParsed.add(orderTable); return orderTable; }
From source file:com.google.gwt.sample.simplexml.client.SimpleXML.java
License:Apache License
private void fillInOrderTableRow(Element customerElement, Element order, HTMLTable table, int rowPos, int columnPos) { // Order ID/*from www . j ava 2 s. c o m*/ String orderId = order.getAttribute("id"); table.setText(rowPos, columnPos++, orderId); // Item Element item = (Element) order.getElementsByTagName("item").item(0); String itemUPC = item.getAttribute("upc"); String itemName = item.getFirstChild().getNodeValue(); Label itemLabel = new Label(itemUPC); itemLabel.setTitle(itemName); table.setWidget(rowPos, columnPos++, itemLabel); // Ordered On String orderedOnValue = getElementTextValue(customerElement, "orderedOn"); table.setText(rowPos, columnPos++, orderedOnValue); // Address Element address = (Element) order.getElementsByTagName("address").item(0); XMLParser.removeWhitespace(address); NodeList lst = address.getChildNodes(); for (int j = 0; j < lst.getLength(); j++) { Element next = (Element) lst.item(j); String addressPartText = next.getFirstChild().getNodeValue(); table.setText(rowPos, columnPos++, addressPartText); } // Shipped By (optional attribute) NodeList shippedByList = order.getElementsByTagName("shippingInfo"); if (shippedByList.getLength() == 1) { Element shippedBy = (Element) shippedByList.item(0); // Depending upon the shipper, different attributes might be // available, so XML carries the display info FlexTable shippedByTable = new FlexTable(); shippedByTable.getRowFormatter().setStyleName(0, USER_TABLE_LABEL_STYLE); shippedByTable.setBorderWidth(1); NodeList shippedByParts = shippedBy.getChildNodes(); for (int j = 0; j < shippedByParts.getLength(); j++) { Node next = shippedByParts.item(j); Element elem = (Element) next; shippedByTable.setText(0, j, elem.getAttribute("title")); shippedByTable.setText(1, j, elem.getFirstChild().getNodeValue()); } table.setWidget(rowPos, columnPos++, shippedByTable); } }