Example usage for com.google.gwt.user.client.ui FlexTable FlexTable

List of usage examples for com.google.gwt.user.client.ui FlexTable FlexTable

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui FlexTable FlexTable.

Prototype

public FlexTable() 

Source Link

Usage

From source file:com.konakart.client.OrderBody.java

License:Open Source License

/**
 * //from   w w w  . j av a2s .c o  m
 * @return Returns the widget for edit links
 */
FlexTable getEdit(HTML link, String text) {
    FlexTable t1 = new FlexTable();
    formatCell(t1, 0, 0, "body-content-tab", "left", null, "1%");
    formatCell(t1, 0, 1, "orderEdit", "left", null, "99%");
    HTML label = new HTML("<b>" + text + "</b>");
    label.setWordWrap(false);
    t1.setWidget(0, 0, label);
    t1.setWidget(0, 1, link);
    return t1;
}

From source file:com.mallentechinc.smartwire.client.SmartWireWeb.java

License:Open Source License

public void onModuleLoad() {

    RootPanel rootPanel = RootPanel.get();

    dockLayoutPanel = new DockLayoutPanel(Unit.EM);
    rootPanel.add(dockLayoutPanel, 10, 10);
    dockLayoutPanel.setSize("1100px", "900px");

    HorizontalPanel headerPanel = new HorizontalPanel();
    dockLayoutPanel.addNorth(headerPanel, 6);

    headerPanel.setWidth("1200px");
    headerPanel.setBorderWidth(0);//w  w w.j  av  a2 s  .c om

    Image logo = new Image("images/smartwire_logo.jpg");
    headerPanel.setCellWidth(logo, "400px");
    headerPanel.add(logo);

    headerPanel.add(new HTML("jxu"));

    Image logoff = new Image("images/doorlogoff.jpg");
    logoff.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            boolean confirm = Window.confirm("You are about to logoff");
            if (confirm) {
                //redirect("j_spring_security_logout");
                logoff();
            }

        }
    });
    headerPanel.add(logoff);

    HTML htmlCopyRight = new HTML("Copy Right 2012 mallentechinc.com", true);
    dockLayoutPanel.addSouth(htmlCopyRight, 7.7);

    tabPanel = new TabLayoutPanel(2.5, Unit.EM);
    tabPanel.setAnimationDuration(1000);
    tabPanel.getElement().getStyle().setMarginBottom(10.0, Unit.PX);
    dockLayoutPanel.add(tabPanel);

    tabPanel.addSelectionHandler(new SelectionHandler() {
        public void onSelection(SelectionEvent event) {
            // Let the user know what they just did.
            // Window.alert("You clicked tab " + event.getSelectedItem().toString());
            if (event.getSelectedItem().toString().equals("0")) {
                getAllUsers();
                deckPanel.showWidget(1);
            } else if (event.getSelectedItem().toString().equals("3")) {
                getAllCircuitsByUser("jxu");
                subsysContentDeckPanel.showWidget(1);
            }

        }
    });

    //user admin
    DockLayoutPanel userdockLayoutPanel = new DockLayoutPanel(Unit.EM);

    VerticalPanel userAdminMenuPanel = new VerticalPanel();
    userAdminMenuPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);

    userdockLayoutPanel.addWest(userAdminMenuPanel, 11);

    Button getAllUsersButton = new Button("Get All Users");
    getAllUsersButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            getAllUsers();
            deckPanel.showWidget(1);
        }
    });
    userAdminMenuPanel.setSpacing(2);
    userAdminMenuPanel.add(getAllUsersButton);

    Button addNewUserButton = new Button("Add New User");
    addNewUserButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            deckPanel.showWidget(2);

        }
    });
    userAdminMenuPanel.setSpacing(2);
    userAdminMenuPanel.add(addNewUserButton);
    userAdminMenuPanel.setSize("130px", "150px");

    //search user
    Button searchUserButton = new Button("Search User");
    searchUserButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            Window.alert("Working on it, stay tune...");

        }
    });
    userAdminMenuPanel.setSpacing(2);
    userAdminMenuPanel.add(searchUserButton);

    //user content area
    deckPanel = new DeckPanel();
    deckPanel.setAnimationEnabled(true);
    userdockLayoutPanel.add(deckPanel);

    //add default page for this
    HTML htmlNewHtml = new HTML("This is admin page", true);
    deckPanel.add(htmlNewHtml);

    //add flex table
    flexTable = new FlexTable();
    flexTable.setCellSpacing(2);
    flexTable.setCellPadding(2);
    deckPanel.add(flexTable);
    flexTable.setSize("700px", "");

    //add user input page
    userformPanel = new FormPanel();
    deckPanel.add(userformPanel);

    final VerticalPanel addUserFormContentPanel = new VerticalPanel();
    addUserFormContentPanel.setSpacing(3);

    addUserFormContentPanel.add(new Label("User Name"));
    userName = new TextBox();
    userName.setName("userName");
    addUserFormContentPanel.add(userName);

    addUserFormContentPanel.add(new Label("Password"));
    passWord = new PasswordTextBox();
    userName.setName("password");
    addUserFormContentPanel.add(passWord);

    addUserFormContentPanel.add(new Label("First Name"));
    firstName = new TextBox();
    firstName.setName("firstName");
    addUserFormContentPanel.add(firstName);

    addUserFormContentPanel.add(new Label("Last Name"));
    lastName = new TextBox();
    lastName.setName("lastName");
    addUserFormContentPanel.add(lastName);

    addUserFormContentPanel.add(new Label("Email"));
    email = new TextBox();
    email.setName("email");
    addUserFormContentPanel.add(email);

    addUserFormContentPanel.add(new Label("User Role"));

    userRole = new ListBox();
    userRole.addStyleName("demo-ListBox");
    userRole.addItem("ADMIN");
    userRole.addItem("USER");
    userRole.setName("userRole");
    addUserFormContentPanel.add(userRole);

    addUserFormContentPanel.add(new Label("Position"));

    position = new ListBox();
    position.addStyleName("demo-ListBox");
    position.addItem("EMPLOYEE");
    position.addItem("MANAGER");
    position.setName("position");
    addUserFormContentPanel.add(position);

    Button insertUserButton = new Button("Add New User");
    insertUserButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {

            //get user input
            String requestData = getAddUserInput();
            //add user
            saveUpdateUser(requestData);

        }
    });
    addUserFormContentPanel.add(insertUserButton);

    userformPanel.add(addUserFormContentPanel);

    tabPanel.add(userdockLayoutPanel, "User Admin");

    //end of user admin

    //arch
    DockLayoutPanel archdockLayoutPanel = new DockLayoutPanel(Unit.EM);
    tabPanel.add(archdockLayoutPanel, "Planning & Architecture");

    VerticalPanel archMenuPanel = new VerticalPanel();
    archMenuPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    archMenuPanel.setSize("160px", "140px");

    Button getAllOption = new Button("All Option Code");
    getAllOption.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            Window.alert("Working on it, stay tune...");
        }
    });
    archMenuPanel.setSpacing(2);
    archMenuPanel.add(getAllOption);

    Button addNewOptionButton = new Button("New Option Code");
    addNewOptionButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            Window.alert("Working on it, stay tune...");

        }
    });
    archMenuPanel.setSpacing(2);
    archMenuPanel.add(addNewOptionButton);

    //search user
    Button searchOptionCodeButton = new Button("Search Option Code");
    searchOptionCodeButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            Window.alert("Working on it, stay tune...");

        }
    });
    archMenuPanel.setSpacing(2);
    archMenuPanel.add(searchOptionCodeButton);

    //search user
    Button functionCodeButton = new Button("Fuction Code");
    functionCodeButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            Window.alert("Working on it, stay tune...");

        }
    });
    archMenuPanel.setSpacing(2);
    archMenuPanel.add(functionCodeButton);

    archdockLayoutPanel.addWest(archMenuPanel, 11);

    //end of arch

    //ee components

    DockLayoutPanel eeCompdockLayoutPanel = new DockLayoutPanel(Unit.EM);

    VerticalPanel eeCompMenuPanel = new VerticalPanel();
    eeCompMenuPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    eeCompMenuPanel.setSize("160px", "120px");

    Button device = new Button("Device");
    device.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            Window.alert("Working on it, stay tune...");
        }
    });
    eeCompMenuPanel.setSpacing(2);
    eeCompMenuPanel.add(device);

    eeCompdockLayoutPanel.addWest(eeCompMenuPanel, 11);
    tabPanel.add(eeCompdockLayoutPanel, "EE Components");

    //end of ee components      

    //sub system
    DockLayoutPanel subSystemdockLayoutPanel = new DockLayoutPanel(Unit.EM);

    VerticalPanel subsysMenuPanel = new VerticalPanel();
    subsysMenuPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    subsysMenuPanel.setSize("160px", "120px");

    Button myCircuits = new Button("My Sub Systems");
    myCircuits.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            getAllCircuitsByUser("jxu");
            subsysContentDeckPanel.showWidget(1);
        }
    });
    subsysMenuPanel.setSpacing(2);
    subsysMenuPanel.add(myCircuits);

    //all sub system
    Button allSubSystems = new Button("Sub Systems");
    allSubSystems.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            Window.alert("Working on it, stay tune...");
        }
    });
    subsysMenuPanel.setSpacing(2);
    subsysMenuPanel.add(allSubSystems);

    //sub system family
    Button allSubSystemFamily = new Button("Sub System Family");
    allSubSystemFamily.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            Window.alert("Working on it, stay tune...");
        }
    });
    subsysMenuPanel.setSpacing(2);
    subsysMenuPanel.add(allSubSystemFamily);

    subSystemdockLayoutPanel.addWest(subsysMenuPanel, 11);

    //sub system content
    subsysContentDeckPanel = new DeckPanel();
    subsysContentDeckPanel.setAnimationEnabled(true);

    //html
    HTML subsystemHtml = new HTML("This is place you can manager your Sub System", true);
    subsysContentDeckPanel.add(subsystemHtml);

    //add circuit page
    circuitsFlexTable = new FlexTable();
    circuitsFlexTable.setSize("500px", "100px");
    circuitsFlexTable.setCellPadding(2);
    circuitsFlexTable.setCellSpacing(2);
    subsysContentDeckPanel.add(this.circuitsFlexTable);

    subSystemdockLayoutPanel.add(subsysContentDeckPanel);

    //end of sub system content

    tabPanel.add(subSystemdockLayoutPanel, "Sub System Design");
    //end of system       

    //config vechile
    DockLayoutPanel vehicledockLayoutPanel = new DockLayoutPanel(Unit.EM);

    VerticalPanel vehicleMenuPanel = new VerticalPanel();
    vehicleMenuPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    vehicleMenuPanel.setSize("160px", "120px");

    Button addVehcile = new Button("Add Vehicle");
    addVehcile.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            Window.alert("Working on it, stay tune...");
        }
    });
    vehicleMenuPanel.setSpacing(2);
    vehicleMenuPanel.add(addVehcile);

    //all sub system
    Button addTrim = new Button("Add Trim");
    addTrim.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            Window.alert("Working on it, stay tune...");
        }
    });
    vehicleMenuPanel.setSpacing(2);
    vehicleMenuPanel.add(addTrim);

    vehicledockLayoutPanel.addWest(vehicleMenuPanel, 11);

    tabPanel.add(vehicledockLayoutPanel, "Vehicle Configurations");
    //end of //config vechile

    DockLayoutPanel qadockLayoutPanel = new DockLayoutPanel(Unit.EM);

    tabPanel.add(qadockLayoutPanel, "Quality Assurance");

    DockLayoutPanel midockLayoutPanel = new DockLayoutPanel(Unit.EM);

    tabPanel.add(midockLayoutPanel, "Manufacture Interface");

    tabPanel.selectTab(0);
    getAllUsers();
    deckPanel.showWidget(1);

}

From source file:com.mashery.examples.api.client.ActiveExample.java

License:Open Source License

public ActiveExample(final PopupMapWidget mapWidget) {
    FlowPanel panel = new FlowPanel();

    panel.add(new HTML("<h1>Search</h1>"));

    FormPanel form = new FormPanel();
    panel.add(form);//from www  . ja va2s .  c  o  m

    FlexTable entryGrid = new FlexTable();
    form.add(entryGrid);
    FlexTable.FlexCellFormatter formatter = (FlexCellFormatter) entryGrid.getCellFormatter();
    entryGrid.setWidget(0, 0, new Label("Keywords:"));
    formatter.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_RIGHT);

    final TextBox keywordsText = new TextBox();
    entryGrid.setWidget(0, 1, keywordsText);
    keywordsText.setWidth("200px");

    entryGrid.setWidget(1, 0, new Label("Location:"));
    formatter.setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_RIGHT);

    final TextBox locationText = new TextBox();
    entryGrid.setWidget(1, 1, locationText);
    locationText.setWidth("200px");

    Anchor fromMapLink = new Anchor("<- from Map");
    final Geocoder geocoder = new Geocoder();
    fromMapLink.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            mapWidget.show();
            HasLatLng center = mapWidget.getMap().getCenter();
            GeocoderRequest request = new GeocoderRequest();
            request.setLatLng(center);
            geocoder.geocode(request, new GeocoderCallback() {
                @Override
                public void callback(List<HasGeocoderResult> responses, String status) {
                    if (responses != null) {
                        String postalCode = null;
                        String country = null;
                        RESULTS: for (HasGeocoderResult result : responses) {
                            if (result.getTypes().contains("postal_code")) {
                                for (HasAddressComponent addr : result.getAddressComponents()) {
                                    if (postalCode == null && addr.getTypes().contains("postal_code"))
                                        postalCode = addr.getLongName();

                                    if (country == null && addr.getTypes().contains("country"))
                                        country = addr.getLongName();

                                    if (postalCode != null && country != null)
                                        break RESULTS;
                                }
                            }
                        }

                        if (postalCode != null) {
                            if (country == null)
                                locationText.setText(postalCode);
                            else
                                locationText.setText(postalCode + ", " + country);
                        }
                    }
                }
            });
        }
    });

    entryGrid.setWidget(1, 2, fromMapLink);

    SubmitButton submitButton = new SubmitButton("Search");
    entryGrid.setWidget(2, 0, submitButton);
    formatter.setColSpan(2, 0, 3);
    formatter.setHorizontalAlignment(2, 0, HasHorizontalAlignment.ALIGN_RIGHT);

    final SearchResultsTable table = new SearchResultsTable(10);
    panel.add(table);
    table.setWidth("500px");

    form.addSubmitHandler(new FormPanel.SubmitHandler() {
        @Override
        public void onSubmit(SubmitEvent event) {
            String keywords = keywordsText.getValue().trim();
            String location = locationText.getValue().trim();
            table.loadData(keywords.length() == 0 ? null : keywords, location.length() == 0 ? null : location);
            event.cancel();
        }
    });

    infoPanel = new PopupPanel(true);
    infoPanel.setAutoHideOnHistoryEventsEnabled(true);
    infoGrid = new FlexTable();
    infoPanel.setWidget(infoGrid);
    FlowPanel linkPanel = new FlowPanel();
    infoGrid.setWidget(3, 0, linkPanel);

    Anchor mapLink = new Anchor("Map", "#");
    linkPanel.add(mapLink);
    mapLink.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            event.preventDefault();
            if (selectedResult == null)
                return;

            Meta meta = selectedResult.getMeta();
            if (meta == null) {
                Window.alert("No location available.");
                return;
            }

            MarkerOptions opt = new MarkerOptions();
            if (meta.getAssetName() != null)
                opt.setTitle(meta.getAssetName().trim());

            opt.setPosition(new LatLng(meta.getLatitude(), meta.getLongitude()));
            opt.setClickable(true);
            opt.setVisible(true);
            mapWidget.show(new Marker(opt));
        }
    });

    mapWidget.addAutoHidePartner(mapLink.getElement());

    linkPanel.add(new InlineHTML("&nbsp;|&nbsp;"));
    linkPanel.add(visitLink = new Anchor("Visit", "#"));

    ((FlexTable.FlexCellFormatter) infoGrid.getCellFormatter()).setColSpan(1, 0, 2);
    ((FlexTable.FlexCellFormatter) infoGrid.getCellFormatter()).setColSpan(2, 0, 2);
    ((FlexTable.FlexCellFormatter) infoGrid.getCellFormatter()).setColSpan(3, 0, 2);

    initWidget(new ScrollPanel(panel));
}

From source file:com.mashery.examples.api.client.Examples.java

License:Open Source License

@Override
public void onModuleLoad() {
    DockLayoutPanel mainPanel = new DockLayoutPanel(Unit.PX);
    RootLayoutPanel.get().add(mainPanel);

    DockLayoutPanel headerPanel = new DockLayoutPanel(Unit.PX);
    mainPanel.addNorth(headerPanel, 80d);

    FlexTable rightPanel = new FlexTable();
    headerPanel.addEast(rightPanel, 250d);
    rightPanel.setCellPadding(4);//www  .j a  v a  2  s .c om
    rightPanel.setSize("100%", "100%");
    rightPanel.getCellFormatter().setHeight(0, 0, "100%");
    rightPanel.getCellFormatter().setWidth(1, 0, "100%");
    rightPanel.getCellFormatter().setAlignment(0, 0, HasHorizontalAlignment.ALIGN_RIGHT,
            HasVerticalAlignment.ALIGN_TOP);
    ((FlexTable.FlexCellFormatter) rightPanel.getCellFormatter()).setColSpan(0, 0, 2);

    final FlowPanel userPanel = new FlowPanel();
    rightPanel.setWidget(0, 0, userPanel);

    LoginServiceAsync loginSvc = GWT.create(LoginService.class);
    loginSvc.getUserEmail(new AsyncCallback<String>() {

        @Override
        public void onSuccess(final String email) {
            final Anchor loginLink = new Anchor();
            loginLink.setHref(email == null ? "/examples/login" : "/examples/login?logout=true");
            loginLink.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    String callbackURL = Window.Location.createUrlBuilder().buildString();
                    StringBuilder buf = new StringBuilder("/examples/login?callbackURL=");
                    buf.append(URL.encodeQueryString(callbackURL));
                    if (email != null)
                        buf.append("&logout=true");

                    loginLink.setHref(buf.toString());
                }
            });

            if (email == null) {
                loginLink.setHTML("Sign&nbsp;in");
            } else {
                loginLink.setHTML("Sign&nbsp;out");
                userPanel.add(new InlineLabel(email));
                userPanel.add(new InlineHTML("&nbsp;|&nbsp;"));
            }

            userPanel.add(loginLink);
        }

        @Override
        public void onFailure(Throwable caught) {
            userPanel.add(new Label(caught.getLocalizedMessage()));
        }
    });

    mapWidget = new PopupMapWidget();
    rightPanel.setWidget(1, 1, mapWidget);

    Grid logoPanel = new Grid(1, 2);
    logoPanel.setCellSpacing(8);
    logoPanel.getRowFormatter().setVerticalAlign(0, HasVerticalAlignment.ALIGN_TOP);
    headerPanel.add(logoPanel);

    Image masheryLogoImg = new Image("resources/img/mashery.gif");
    Anchor masheryLink = new Anchor();
    masheryLink.setTitle("Mashery, Inc.");
    masheryLink.setHref("http://developer.mashery.com");
    masheryLink.getElement().appendChild(masheryLogoImg.getElement());
    logoPanel.setWidget(0, 0, masheryLink);

    InlineLabel logoLabel = new InlineLabel("Mashery Examples");
    logoLabel.getElement().getStyle().setFontWeight(FontWeight.BOLD);
    logoLabel.getElement().getStyle().setFontSize(28d, Unit.PT);
    logoLabel.getElement().getStyle().setColor("#c1080a");
    logoPanel.setWidget(0, 1, logoLabel);

    SplitLayoutPanel centerPanel = new SplitLayoutPanel();
    mainPanel.add(centerPanel);

    final StackLayoutPanel examplesPanel = new StackLayoutPanel(Unit.PX);
    centerPanel.addWest(examplesPanel, 200d);

    contentPanel = new DeckPanel();
    centerPanel.add(contentPanel);
    contentPanel.getElement().getStyle().setPaddingLeft(8d, Unit.PX);
    contentPanel.setAnimationEnabled(true);

    addExample(new Example("quova", "Quova") {
        @Override
        public Widget createContent() {
            return new QuovaExample(mapWidget);
        }
    }, examplesPanel);

    addExample(new Example("etsy", "Etsy") {
        @Override
        public Widget createContent() {
            return new EtsyExample(mapWidget);
        }
    }, examplesPanel);

    addExample(new Example("weatherbug", "WeatherBug") {
        @Override
        public Widget createContent() {
            return new WeatherBugExample(mapWidget);
        }
    }, examplesPanel);

    addExample(new Example("hotwire", "Hotwire") {
        @Override
        public Widget createContent() {
            return new HotwireExample(mapWidget);
        }
    }, examplesPanel);

    addExample(new Example("active", "Active") {
        @Override
        public Widget createContent() {
            return new ActiveExample(mapWidget);
        }
    }, examplesPanel);

    String historyToken = History.getToken();
    Integer index = exampleIndex.get(historyToken);
    if (index == null)
        index = 0;

    examplesPanel.showWidget(index);
    showExample(index);

    examplesPanel.addSelectionHandler(new SelectionHandler<Integer>() {
        @Override
        public void onSelection(SelectionEvent<Integer> event) {
            int index = event.getSelectedItem();
            Example example = examples.get(index);
            if (example != null)
                History.newItem(example.getId());
        }
    });

    History.addValueChangeHandler(new ValueChangeHandler<String>() {
        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            String historyToken = event.getValue();
            Integer index = exampleIndex.get(historyToken);
            if (index != null) {
                examplesPanel.showWidget(index);
                showExample(index);
            }
        }
    });
}

From source file:com.mashery.examples.api.client.HotwireExample.java

License:Open Source License

public HotwireExample(final PopupMapWidget mapWidget) {
    FlowPanel panel = new FlowPanel();

    panel.add(new HTML("<h1>Hotel Deals</h1>"));

    FormPanel form = new FormPanel();
    panel.add(form);// ww w.ja v a2 s .c  o  m

    FlexTable entryGrid = new FlexTable();
    form.add(entryGrid);
    FlexTable.FlexCellFormatter formatter = (FlexCellFormatter) entryGrid.getCellFormatter();
    entryGrid.setWidget(0, 0, new Label("Destination:"));
    formatter.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_RIGHT);

    FlowPanel destPanel = new FlowPanel();
    entryGrid.setWidget(0, 1, destPanel);
    formatter.setColSpan(0, 1, 5);

    final TextBox destText = new TextBox();
    destPanel.add(destText);
    destText.setWidth("220px");

    Anchor fromMapLink = new Anchor("<- from Map");
    fromMapLink.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            HasLatLng center = mapWidget.getMap().getCenter();
            destText.setText(center.getLatitude() + "," + center.getLongitude());
        }
    });

    destPanel.add(new InlineHTML("&nbsp;"));
    destPanel.add(fromMapLink);

    entryGrid.setWidget(1, 0, new Label("From:"));
    formatter.setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_RIGHT);

    final TextBox startDateText = new TextBox();
    entryGrid.setWidget(1, 1, startDateText);
    startDateText.setWidth("100px");

    final PopupPanel startDatePanel = new PopupPanel(true);
    startDatePanel.setAutoHideOnHistoryEventsEnabled(true);

    final ToggleButton startDateButton = new ToggleButton(new Image("resources/img/date-picker.gif"));
    entryGrid.setWidget(1, 2, startDateButton);
    startDateButton.setPixelSize(16, 16);
    startDatePanel.addAutoHidePartner(startDateButton.getElement());
    startDateButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            startDatePanel.showRelativeTo(startDateButton);
        }
    });

    startDatePanel.addCloseHandler(new CloseHandler<PopupPanel>() {
        @Override
        public void onClose(CloseEvent<PopupPanel> event) {
            startDateButton.setDown(false);
        }
    });

    final DateTimeFormat dateFormat = DateTimeFormat.getFormat("MM/dd/yyyy");

    final DatePicker startDatePicker = new DatePicker();
    startDatePanel.setWidget(startDatePicker);
    startDatePicker.addValueChangeHandler(new ValueChangeHandler<Date>() {
        @Override
        public void onValueChange(ValueChangeEvent<Date> event) {
            startDateText.setText(dateFormat.format(event.getValue()));
            startDatePanel.hide();
        }
    });

    startDateText.addValueChangeHandler(new ValueChangeHandler<String>() {
        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            try {
                Date date = dateFormat.parse(event.getValue());
                startDatePicker.setValue(date);
            } catch (IllegalArgumentException e) {
                // ignore
            }
        }
    });

    Date date = new Date();
    startDatePicker.setValue(date, true);

    entryGrid.setWidget(1, 3, new Label("To:"));
    formatter.setHorizontalAlignment(1, 2, HasHorizontalAlignment.ALIGN_RIGHT);

    final TextBox endDateText = new TextBox();
    entryGrid.setWidget(1, 4, endDateText);
    endDateText.setWidth("100px");

    final PopupPanel endDatePanel = new PopupPanel(true);
    endDatePanel.setAutoHideOnHistoryEventsEnabled(true);

    final ToggleButton endDateButton = new ToggleButton(new Image("resources/img/date-picker.gif"));
    entryGrid.setWidget(1, 5, endDateButton);
    endDateButton.setPixelSize(16, 16);
    endDatePanel.addAutoHidePartner(endDateButton.getElement());
    endDateButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            endDatePanel.showRelativeTo(endDateButton);
        }
    });

    endDatePanel.addCloseHandler(new CloseHandler<PopupPanel>() {
        @Override
        public void onClose(CloseEvent<PopupPanel> event) {
            endDateButton.setDown(false);
        }
    });

    final DatePicker endDatePicker = new DatePicker();
    endDatePanel.setWidget(endDatePicker);
    endDatePicker.addValueChangeHandler(new ValueChangeHandler<Date>() {
        @Override
        public void onValueChange(ValueChangeEvent<Date> event) {
            endDateText.setText(dateFormat.format(event.getValue()));
            endDatePanel.hide();
        }
    });

    endDateText.addValueChangeHandler(new ValueChangeHandler<String>() {
        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            try {
                Date date = dateFormat.parse(event.getValue());
                endDatePicker.setValue(date);
            } catch (IllegalArgumentException e) {
                // ignore
            }
        }
    });

    date = CalendarUtil.copyDate(date);
    CalendarUtil.addDaysToDate(date, 1);
    endDatePicker.setValue(date, true);

    SubmitButton submitButton = new SubmitButton("Search");
    entryGrid.setWidget(2, 0, submitButton);
    formatter.setColSpan(2, 0, 6);
    formatter.setHorizontalAlignment(2, 0, HasHorizontalAlignment.ALIGN_RIGHT);

    final HotelDealsTable table = new HotelDealsTable(10);
    panel.add(table);
    table.setWidth("500px");

    form.addSubmitHandler(new FormPanel.SubmitHandler() {
        @Override
        public void onSubmit(SubmitEvent event) {
            String dest = destText.getValue().trim();
            String start = startDateText.getValue().trim();
            String end = endDateText.getValue().trim();
            table.loadData(dest.length() == 0 ? null : dest, start.length() == 0 ? null : start,
                    end.length() == 0 ? null : end);
            event.cancel();
        }
    });

    infoPanel = new PopupPanel(true);
    infoPanel.setAutoHideOnHistoryEventsEnabled(true);
    infoGrid = new FlexTable();
    infoPanel.setWidget(infoGrid);
    FlowPanel linkPanel = new FlowPanel();
    infoGrid.setWidget(3, 0, linkPanel);

    Anchor mapLink = new Anchor("Map", "#");
    linkPanel.add(mapLink);
    mapLink.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            event.preventDefault();
            if (selectedResult == null)
                return;

            MarkerOptions opt = new MarkerOptions();
            opt.setTitle(selectedResult.getHeadline());
            LatLng latLng = new LatLng(selectedResult.getNeighborhoodLatitude(),
                    selectedResult.getNeighborhoodLongitude());
            opt.setPosition(latLng);
            opt.setClickable(true);
            opt.setVisible(true);
            mapWidget.show(new Marker(opt));

        }
    });

    mapWidget.addAutoHidePartner(mapLink.getElement());

    linkPanel.add(new InlineHTML("&nbsp;|&nbsp;"));
    linkPanel.add(visitLink = new Anchor("Visit", "#"));

    initWidget(new ScrollPanel(panel));
}

From source file:com.mashery.examples.api.client.PagedTable.java

License:Open Source License

public PagedTable(int pageSize) {
    assert pageSize > 0;
    this.pageSize = pageSize;

    Grid rootPanel = new Grid(2, 1);

    table = new FlexTable();
    rootPanel.setWidget(0, 0, table);//w  w w  .j a  va2  s .  co m
    table.addStyleName("gwt-PagedTable");
    table.setWidth("100%");
    //      table.setBorderWidth(1);
    table.getRowFormatter().addStyleName(0, "gwt-PagedTableHeader");

    Grid controlPanel = new Grid(1, 5);
    rootPanel.setWidget(1, 0, controlPanel);
    controlPanel.setSize("100%", "2em");

    firstButton = new PushButton("|<", new ControlButtonHandler() {
        @Override
        protected void setPageIndex() {
            pageIndex = 0;
        }
    });

    firstButton.setWidth("4em");
    firstButton.getElement().getStyle().setProperty("textAlign", "center");

    prevButton = new PushButton("<<", new ControlButtonHandler() {
        @Override
        protected void setPageIndex() {
            --pageIndex;
        }
    });

    prevButton.setWidth("4em");
    prevButton.getElement().getStyle().setProperty("textAlign", "center");

    nextButton = new PushButton(">>", new ControlButtonHandler() {
        @Override
        protected void setPageIndex() {
            ++pageIndex;
        }
    });

    nextButton.setWidth("4em");
    nextButton.getElement().getStyle().setProperty("textAlign", "center");

    lastButton = new PushButton(">|", new ControlButtonHandler() {
        @Override
        protected void setPageIndex() {
            pageIndex = pageCount - 1;
        }
    });

    lastButton.setWidth("4em");
    lastButton.getElement().getStyle().setProperty("textAlign", "center");

    Grid centerPanel = new Grid(1, 2);

    pageLabel = new InlineLabel();
    centerPanel.setWidget(0, 0, pageLabel);

    Anchor refreshLink = new Anchor("Refresh", "#");
    refreshLink.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            event.preventDefault();
            showLoading(true);
            reloadData(args);
        }
    });

    refreshPanel = new FlowPanel();
    centerPanel.setWidget(0, 1, refreshPanel);

    refreshPanel.add(new InlineHTML("&nbsp;|&nbsp;"));
    refreshPanel.add(refreshLink);

    controlPanel.setWidget(0, 0, firstButton);
    controlPanel.setWidget(0, 1, prevButton);
    controlPanel.setWidget(0, 2, centerPanel);
    controlPanel.setWidget(0, 3, nextButton);
    controlPanel.setWidget(0, 4, lastButton);

    controlPanel.getRowFormatter().setVerticalAlign(0, HasVerticalAlignment.ALIGN_MIDDLE);
    controlPanel.getCellFormatter().setHorizontalAlignment(0, 2, HasHorizontalAlignment.ALIGN_CENTER);
    controlPanel.getCellFormatter().setWidth(0, 2, "100%");

    updateNavigationControls();

    loadingPopup = new PopupPanel();
    loadingPopup.getElement().getStyle().setBorderStyle(BorderStyle.NONE);
    loadingPopup.getElement().getStyle().setBorderWidth(0d, Unit.PX);
    loadingPopup.getElement().getStyle().setOpacity(0.75d);
    Grid loadingLabel = new Grid(1, 1);
    loadingPopup.setWidget(loadingLabel);
    loadingLabel.setWidget(0, 0, new Image("resources/img/ajax-loader.gif"));
    loadingLabel.getCellFormatter().setAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER,
            HasVerticalAlignment.ALIGN_MIDDLE);

    initWidget(rootPanel);
}

From source file:com.mashery.examples.api.client.QuovaExample.java

License:Open Source License

public QuovaExample(final PopupMapWidget mapWidget) {
    FlowPanel panel = new FlowPanel();

    panel.add(new HTML("<h1>IP Info</h1>"));

    FormPanel entryForm = new FormPanel();
    panel.add(entryForm);/*from  www  .  j  a  v a2 s  .  c  o  m*/

    Grid entryPanel = new Grid(1, 3);
    entryForm.setWidget(entryPanel);

    entryPanel.setWidget(0, 0, new Label("IP Address:"));
    entryPanel.getCellFormatter().setAlignment(0, 0, HasHorizontalAlignment.ALIGN_RIGHT,
            HasVerticalAlignment.ALIGN_MIDDLE);

    addressText = new TextBox();
    entryPanel.setWidget(0, 1, addressText);
    addressText.setWidth("150px");
    entryPanel.getCellFormatter().setVerticalAlignment(0, 1, HasVerticalAlignment.ALIGN_MIDDLE);

    submitButton = new SubmitButton("Look Up");
    entryPanel.setWidget(0, 2, submitButton);
    entryPanel.getCellFormatter().setAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT,
            HasVerticalAlignment.ALIGN_MIDDLE);

    final IPInfoServiceAsync ipInfoSvc = GWT.create(IPInfoService.class);
    entryForm.addSubmitHandler(new FormPanel.SubmitHandler() {
        @Override
        public void onSubmit(SubmitEvent event) {
            addressText.setReadOnly(true);
            submitButton.setEnabled(false);

            String value = addressText.getText().trim();
            lookupIPInfo(ipInfoSvc, value.length() == 0 ? null : value);
            event.cancel();
        }
    });

    panel.add(new HTML("<em>Note: Leave blank to use your auto-detected IP address.</em>"));
    panel.add(new HTML());

    generalTable = new FlexTable();
    panel.add(generalTable);

    FlexTable.FlexCellFormatter formatter = (FlexCellFormatter) generalTable.getCellFormatter();
    int row = -1;
    formatter.setWidth(0, 0, "160px");
    generalTable.setText(++row, 0, "IP Address:");
    generalTable.setText(row, 1, "");
    formatter.setHorizontalAlignment(row, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    generalTable.setText(++row, 0, "IP Type:");
    generalTable.setText(row, 1, "");
    formatter.setHorizontalAlignment(row, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    generalTable.setText(++row, 0, "Anonymizer Status:");
    generalTable.setText(row, 1, "");
    formatter.setHorizontalAlignment(row, 0, HasHorizontalAlignment.ALIGN_RIGHT);

    for (int i = 0, n = generalTable.getRowCount(); i < n; ++i)
        formatter.getElement(i, 0).getStyle().setFontWeight(FontWeight.BOLD);

    DisclosurePanel networkPanel = new DisclosurePanel("Network");
    panel.add(networkPanel);
    networkPanel.setAnimationEnabled(true);

    networkTable = new FlexTable();
    networkPanel.setContent(networkTable);

    formatter = (FlexCellFormatter) networkTable.getCellFormatter();
    row = -1;
    formatter.setWidth(0, 0, "144px");
    networkTable.setText(++row, 0, "Organization:");
    networkTable.setText(row, 1, "");
    formatter.setHorizontalAlignment(row, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    networkTable.setText(++row, 0, "Carrier:");
    networkTable.setText(row, 1, "");
    formatter.setHorizontalAlignment(row, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    networkTable.setText(++row, 0, "ASN:");
    networkTable.setText(row, 1, "");
    formatter.setHorizontalAlignment(row, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    networkTable.setText(++row, 0, "Connection Type:");
    networkTable.setText(row, 1, "");
    formatter.setHorizontalAlignment(row, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    networkTable.setText(++row, 0, "Line Speed:");
    networkTable.setText(row, 1, "");
    formatter.setHorizontalAlignment(row, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    networkTable.setText(++row, 0, "IP Routing Type:");
    networkTable.setText(row, 1, "");
    formatter.setHorizontalAlignment(row, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    networkTable.setText(++row, 0, "Domain:");
    networkTable.setText(row, 1, "");
    formatter.setHorizontalAlignment(row, 0, HasHorizontalAlignment.ALIGN_RIGHT);

    for (int i = 0, n = networkTable.getRowCount(); i < n; ++i)
        formatter.getElement(i, 0).getStyle().setFontWeight(FontWeight.BOLD);

    locationPanel = new DisclosurePanel("Location");
    panel.add(locationPanel);
    locationPanel.setAnimationEnabled(true);

    locationTable = new FlexTable();
    locationPanel.setContent(locationTable);

    formatter = (FlexCellFormatter) locationTable.getCellFormatter();
    row = -1;
    formatter.setWidth(0, 0, "144px");
    locationTable.setText(++row, 0, "Continent:");
    locationTable.setText(row, 1, "");
    formatter.setHorizontalAlignment(row, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    locationTable.setText(++row, 0, "Country:");
    locationTable.setText(row, 1, "");
    formatter.setHorizontalAlignment(row, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    locationTable.setText(++row, 0, "Region:");
    locationTable.setText(row, 1, "");
    formatter.setHorizontalAlignment(row, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    locationTable.setText(++row, 0, "State:");
    locationTable.setText(row, 1, "");
    formatter.setHorizontalAlignment(row, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    locationTable.setText(++row, 0, "DMA:");
    locationTable.setText(row, 1, "");
    formatter.setHorizontalAlignment(row, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    locationTable.setText(++row, 0, "MSA:");
    locationTable.setText(row, 1, "");
    formatter.setHorizontalAlignment(row, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    locationTable.setText(++row, 0, "City:");
    locationTable.setText(row, 1, "");
    formatter.setHorizontalAlignment(row, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    locationTable.setText(++row, 0, "Postal Code:");
    locationTable.setText(row, 1, "");
    formatter.setHorizontalAlignment(row, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    locationTable.setText(++row, 0, "Time Zone:");
    locationTable.setText(row, 1, "");
    formatter.setHorizontalAlignment(row, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    locationTable.setText(++row, 0, "Area Code:");
    locationTable.setText(row, 1, "");
    formatter.setHorizontalAlignment(row, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    locationTable.setText(++row, 0, "Latitude:");
    locationTable.setText(row, 1, "");
    formatter.setHorizontalAlignment(row, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    locationTable.setText(++row, 0, "Longitude:");
    locationTable.setText(row, 1, "");
    formatter.setHorizontalAlignment(row, 0, HasHorizontalAlignment.ALIGN_RIGHT);

    for (int i = 0, n = locationTable.getRowCount(); i < n; ++i)
        formatter.getElement(i, 0).getStyle().setFontWeight(FontWeight.BOLD);

    mapButton = new Button("Locate on Map", new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            MarkerOptions opt = new MarkerOptions();
            opt.setTitle(result.getIpAddress());
            opt.setPosition(new LatLng(result.getLatitude(), result.getLongitude()));
            opt.setClickable(true);
            opt.setVisible(true);
            mapWidget.show(new Marker(opt));
        }
    });

    mapButton.setEnabled(false);
    locationTable.setWidget(++row, 0, mapButton);
    formatter.setColSpan(row, 0, 2);
    //      formatter.setHorizontalAlignment(row, 0, HasHorizontalAlignment.ALIGN_RIGHT);

    initWidget(new ScrollPanel(panel));
}

From source file:com.mashery.examples.api.client.WeatherBugExample.java

License:Open Source License

public WeatherBugExample(final PopupMapWidget mapWidget) {
    this.mapWidget = mapWidget;

    FlowPanel panel = new FlowPanel();

    panel.add(new HTML("<h1>Weather Forecast</h1>"));

    Grid controlPanel = new Grid(1, 3);
    panel.add(controlPanel);/*  w w  w  . j  av a  2 s.c o  m*/

    Button refreshButton = new Button("Get Weather Forecast", new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            fetchWeather();
        }
    });

    controlPanel.setWidget(0, 0, refreshButton);
    mapWidget.addAutoHidePartner(refreshButton.getElement());

    controlPanel.setHTML(0, 1, "&nbsp;&nbsp;&nbsp;Map Overlay:");

    final ListBox overlayBox = new ListBox();
    controlPanel.setWidget(0, 2, overlayBox);
    overlayBox.addItem("(none)", "");
    for (LayerType layerType : LayerType.values())
        overlayBox.addItem(layerType.getDescription(), layerType.toString());

    final WeatherBugOverlayView overlay = new WeatherBugOverlayView();

    overlayBox.addChangeHandler(new ChangeHandler() {

        private boolean initialized;

        private boolean visible = true;

        @Override
        public void onChange(ChangeEvent event) {
            int index = overlayBox.getSelectedIndex();
            LayerType layerType = index == 0 ? null : LayerType.valueOf(overlayBox.getValue(index));
            if (layerType == null) {
                if (initialized && visible) {
                    overlay.hide();
                    visible = false;
                }
            } else {
                overlay.setLayerType(layerType);
                if (initialized) {
                    if (!visible) {
                        overlay.show();
                        visible = true;
                    }
                } else {
                    overlay.setMap(mapWidget.getMap());
                    initialized = true;
                }

                mapWidget.show();
            }
        }
    });

    mapWidget.addAutoHidePartner(overlayBox.getElement());

    panel.add(new HTML());

    table = new FlexTable();
    panel.add(table);
    table.setCellSpacing(20);
    ((FlexTable.FlexCellFormatter) table.getCellFormatter()).setColSpan(0, 0, 5);

    initWidget(new ScrollPanel(panel));
}

From source file:com.mcherm.zithiacharsheet.client.FancyListSelectionDialog.java

License:Apache License

/**
 * Private subroutine of the constructor that puts contents into
 * the dialog./*from  w  w  w .ja  v  a  2 s  .  co  m*/
 */
private void setupDialogContents() {
    final VerticalPanel dialogVPanel = new VerticalPanel();
    dialogVPanel.add(new HTML("<b>" + title + "</b>"));
    final FlexTable table = new FlexTable();
    table.addStyleName(tableStyle);

    int row = 0;
    for (final T item : items) {
        ClickHandler rowClickHandler = new ClickHandler() {
            public void onClick(ClickEvent event) {
                itemSelectCallback.newItemSelected(item);
                dialogCompleted();
            }
        };
        final List<Widget> widgets = itemDisplayCallback.getDisplay(item);
        int col = 0;
        for (final Widget widget : widgets) {
            if (widget instanceof HasClickHandlers) {
                final HasClickHandlers hch = (HasClickHandlers) widget;
                hch.addClickHandler(rowClickHandler);
            }
            table.setWidget(row, col, widget);
            col++;
        }
        row++;
    }

    dialogVPanel.add(table);
    final Button closeButton = new Button("Cancel");
    closeButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            dialogCompleted();
        }
    });
    dialogVPanel.add(closeButton);
    this.setWidget(dialogVPanel);
}

From source file:com.mcherm.zithiacharsheet.client.SkillCatalogDisplay.java

License:Apache License

/**
 * Subroutine of constructor to set up a smaller table with the skills
 * from an individual category.//from w  w  w  . j  a  va  2  s.  c o m
 */
private FlexTable makeCategorySkillsSubtable(final SkillCatalog.SkillCategory skillCategory) {
    // FIXME: Make this a subroutine
    FlexTable subTable = new FlexTable();
    final FlexCellFormatter subFormatter = subTable.getFlexCellFormatter();
    int skillRow = 0;
    for (final ZithiaSkill skill : skillCategory.getSkills()) {
        final int SKILL_ROW = skillRow;
        ClickHandler rowClickHandler = new ClickHandler() {
            public void onClick(ClickEvent event) {
                onSkillClicked(event, skill, SKILL_ROW);
            }
        };
        String statsText;
        if (skill.hasRoll()) {
            statsText = skill.getStat().getName() + "/" + skill.getBaseCost() + "/" + skill.getFirstLevelCost();
        } else {
            statsText = Integer.toString(skill.getBaseCost());
        }
        subFormatter.addStyleName(SKILL_ROW, 0, "statsCol");
        Label statsLabel = new Label(statsText);
        statsLabel.addClickHandler(rowClickHandler);
        subTable.setWidget(SKILL_ROW, 0, statsLabel);
        subFormatter.addStyleName(SKILL_ROW, 1, "nameCol");
        Label nameLabel = new Label(skill.getName());
        nameLabel.addClickHandler(rowClickHandler);
        subTable.setWidget(SKILL_ROW, 1, nameLabel);
        skillRow++;
    }
    return subTable;
}