Example usage for com.google.gwt.user.client.ui Label setText

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

Introduction

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

Prototype

public void setText(String text) 

Source Link

Document

Sets the label's content to the given text.

Usage

From source file:com.GTDF.client.GWT_Transxchange2GoogleTransit.java

License:Apache License

public void onModuleLoad() {

    String wikiUserName = readUsername();

    //Service Start
    final TextBox textBoxServiceStartGz = new TextBox();

    TabPanel tabs = new TabPanel();
    tabs.setStyleName(".gwt-TabBar");

    tabs.setWidth("100%");
    tabs.setHeight("100%");

    //-------------------------EDJ ----------------
    DockPanel dock = new DockPanel();
    dock.setSize("663px", "220px");
    dock.setStyleName("gwt-TabBar");
    VerticalPanel TransformWindow = new VerticalPanel();
    TransformWindow.setStyleName("weather-input-panel");

    //Agency URL/*from  w ww. ja v  a  2  s. com*/
    HorizontalPanel AgencyURL = new HorizontalPanel();
    Label url_lbl = new Label("Agency URL:");
    url_lbl.setWidth("90");
    final TextBox textBoxUrl = new TextBox();
    textBoxUrl.setText("http://www.agency.org");
    textBoxUrl.setVisibleLength(40);
    AgencyURL.add(url_lbl);
    AgencyURL.add(textBoxUrl);
    //-----------

    //Route Type
    HorizontalPanel RType = new HorizontalPanel();
    Label rt_lbl = new Label("Route Type:");
    rt_lbl.setWidth("90");
    final ListBox listBoxDefaultRouteType = new ListBox();
    listBoxDefaultRouteType.setVisibleItemCount(1);
    listBoxDefaultRouteType.addItem("Tram");
    listBoxDefaultRouteType.addItem("Subway");
    listBoxDefaultRouteType.addItem("Rail");
    listBoxDefaultRouteType.addItem("Bus");
    listBoxDefaultRouteType.addItem("Ferry");
    listBoxDefaultRouteType.addItem("Cable car");
    listBoxDefaultRouteType.addItem("Gondola");
    listBoxDefaultRouteType.addItem("Funicular");
    listBoxDefaultRouteType.setSelectedIndex(0);
    RType.add(rt_lbl);
    RType.add(listBoxDefaultRouteType);
    //-----------

    //Time Zone
    VerticalPanel TZ = new VerticalPanel();
    Label tz_lbl = new Label("Time Zone:");
    tz_lbl.setWidth("90");

    HorizontalPanel Continent = new HorizontalPanel();
    Label continent_lbl = new Label("Continent:");
    continent_lbl.setWidth("90");
    final ListBox listBoxTimezoneP = new ListBox();
    listBoxTimezoneP.addItem("Africa");
    listBoxTimezoneP.addItem("America");
    listBoxTimezoneP.addItem("Antarctica");
    listBoxTimezoneP.addItem("Artic");
    listBoxTimezoneP.addItem("Asia");
    listBoxTimezoneP.addItem("Atlantic");
    listBoxTimezoneP.addItem("Australia");
    listBoxTimezoneP.addItem("Europe");
    listBoxTimezoneP.addItem("Indian");
    listBoxTimezoneP.addItem("Pacific");
    listBoxTimezoneP.setVisibleItemCount(1);
    listBoxTimezoneP.setSelectedIndex(0);

    Continent.add(continent_lbl);
    Continent.add(listBoxTimezoneP);

    HorizontalPanel Region = new HorizontalPanel();
    Label region_lbl = new Label("Region:");
    region_lbl.setWidth("90");
    final ListBox listBoxTimezoneS = new ListBox();
    switchTimezone(listBoxTimezoneS, 0);
    Region.add(region_lbl);
    Region.add(listBoxTimezoneS);

    TZ.add(tz_lbl);
    TZ.add(Continent);
    TZ.add(Region);
    //-----------

    Button dialogButton = new Button("Show Dialog", new ClickListener() {
        public void onClick(Widget sender) {
            //EDJ
            DialogBox dlg = new MyDialog();
            int left = 120;
            int top = 300;
            dlg.setPopupPosition(left, top);
            dlg.show();
        }
    });

    final Label labelOutdir = new Label(); // Displays wikiuser
    final Label labelResultGz = new Label();
    final Label labelResult = new Label();
    final Label labelResultUser = new Label();

    final FormPanel uploadFormGz = new FormPanel();
    uploadFormGz.setAction(GWT.getModuleBaseURL() + "upload");
    uploadFormGz.setEncoding(FormPanel.ENCODING_MULTIPART);
    uploadFormGz.setMethod(FormPanel.METHOD_POST);
    //Upload
    final HorizontalPanel uploadPanelGz = new HorizontalPanel();
    Label upload_lbl = new Label("Upload File:");
    upload_lbl.setWidth("90");
    uploadPanelGz.add(upload_lbl);
    //uploadPanelGz.add(upload_tb);
    //uploadPanelGz.add(upload_btn);
    //--------------

    // Add hidden widget to pass user name to FileUploadServlet for verification against wiki user table
    final Hidden hwGz = new Hidden("username", wikiUserName);
    uploadPanelGz.add(hwGz);

    // Add hidden widget to pass service start to FileUploadServlet
    final Hidden ssGz = new Hidden("prefix");
    uploadPanelGz.add(ssGz);

    final FileUpload uploadGz = new FileUpload();
    uploadGz.setName("uploadFormElement");
    uploadPanelGz.add(uploadGz);

    //final VerticalPanel uploadPanelGz = new VerticalPanel();
    uploadFormGz.setWidget(uploadPanelGz);

    /*
     * Add Transxchange2GoogleTransit file upload
     */
    final FormPanel uploadForm = new FormPanel();
    uploadForm.setAction(GWT.getModuleBaseURL() + "upload");
    uploadForm.setEncoding(FormPanel.ENCODING_MULTIPART);
    uploadForm.setMethod(FormPanel.METHOD_POST);
    final VerticalPanel uploadPanel = new VerticalPanel();
    uploadForm.setWidget(uploadPanel);

    // Add hidden widget to pass user name to FileUploadServlet for verification against wiki user table
    final Hidden hw = new Hidden("username", wikiUserName);
    uploadPanel.add(hw);

    final FileUpload upload = new FileUpload();
    upload.setName("uploadFormElement");
    uploadPanel.add(upload);

    /*
    * Verify user and enable action buttons if user exists
    */
    WikiUserServiceAsync wikiUserService = (WikiUserServiceAsync) GWT.create(WikiUserService.class);

    ServiceDefTarget endpoint = (ServiceDefTarget) wikiUserService;
    String moduleRelativeURL = GWT.getModuleBaseURL() + "WikiUser";
    endpoint.setServiceEntryPoint(moduleRelativeURL);

    AsyncCallback callback = new AsyncCallback() {
        public void onSuccess(Object result) {
            Button buttonGz = new Button("Upload", new ClickListener() {
                public void onClick(Widget sender) {
                    // Extract service start and pass as prefix
                    String serviceStart = textBoxServiceStartGz.getText();
                    ssGz.setValue(serviceStart);
                    // Upload selected infile to server
                    uploadFormGz.submit();

                    //EDJ
                    DialogBox dlg = new MyDialog();
                    int left = 120;
                    int top = 300;
                    dlg.setPopupPosition(left, top);
                    dlg.show();
                }
            });
            Button button = new Button("Transform", new ClickListener() {
                public void onClick(Widget sender) {
                    // Upload selected infile to server
                    uploadForm.submit();
                }
            });

            if (result != "LOGGED") {
                button.setEnabled(false);
                buttonGz.setEnabled(false);
                labelResultUser.setText((String) result);
            }
            uploadPanel.add(button);
            uploadPanelGz.add(buttonGz);
        }

        public void onFailure(Throwable caught) {
            try {
                throw caught;
            } catch (InvocationException e) {
                labelResult.setText("InvocationException: " + e.getMessage());
            } catch (Throwable e) {
                labelResult.setText("callback failed: " + e.getMessage());
            }
        }
    };
    wikiUserService.wikiUserVerify(wikiUserName, callback);

    /*
     * Upload google_transit.zip file
     */
    uploadFormGz.addFormHandler(new FormHandler() {
        public void onSubmitComplete(FormSubmitCompleteEvent event) {

            labelResultGz.setText((String) event.getResults());

        }

        public void onSubmit(FormSubmitEvent event) {
            // Upload infile to server
            String inFilename = uploadGz.getFilename();
            if (inFilename.length() == 0) {
                Window.alert("Infile required");
                return;
            }
        }
    });

    /*
     * Upload TransXChange file and call Transxchange2GoogleTransit servlet when "transform" button is pushed
     */
    uploadForm.addFormHandler(new FormHandler() {
        public void onSubmitComplete(FormSubmitCompleteEvent event) {

            labelResult.setText((String) event.getResults());

            // Start transformation
            String parseArgs = upload.getFilename();
            parseArgs = parseArgs + " " + textBoxUrl.getText();
            parseArgs = parseArgs + " " + listBoxTimezoneP.getItemText(listBoxTimezoneP.getSelectedIndex());
            String helpString = listBoxTimezoneS.getItemText(listBoxTimezoneS.getSelectedIndex());
            parseArgs = parseArgs + "/" + helpString.substring(0, helpString.indexOf(' '));
            parseArgs = parseArgs + " " + listBoxDefaultRouteType.getSelectedIndex();
            parseArgs = parseArgs + " " + labelOutdir.getText();

            // call server through GWT asynchronous RPC
            Transxchange2GoogleTransitServiceAsync transxchange2GoogleTransitService = (Transxchange2GoogleTransitServiceAsync) GWT
                    .create(Transxchange2GoogleTransitService.class);

            ServiceDefTarget endpoint = (ServiceDefTarget) transxchange2GoogleTransitService;
            String moduleRelativeURL = GWT.getModuleBaseURL() + "GTDF";
            endpoint.setServiceEntryPoint(moduleRelativeURL);

            AsyncCallback callback = new AsyncCallback() {
                public void onSuccess(Object result) {
                    labelResult.setText((String) result);
                }

                public void onFailure(Throwable caught) {
                    try {
                        throw caught;
                    } catch (InvocationException e) {
                        labelResult.setText("InvocationException: " + e.getMessage());
                    } catch (Throwable e) {
                        labelResult.setText("callback failed: " + e.getMessage());
                    }
                }
            };
            transxchange2GoogleTransitService.transxchange2GoogleTransit_transform(parseArgs, callback);
        }

        public void onSubmit(FormSubmitEvent event) {
            // Upload infile to server
            String inFilename = upload.getFilename();
            if (inFilename.length() == 0) {
                Window.alert("Infile required");
                return;
            }
        }
    });

    /*
     * Add UI elements
     *       Better practice (for future reference): use CSS
     */
    TransformWindow.add(AgencyURL);
    TransformWindow.add(RType);
    TransformWindow.add(TZ);
    TransformWindow.add(uploadPanelGz);
    TransformWindow.add(uploadPanel);
    TransformWindow.add(dialogButton);
    tabs.add(TransformWindow, "TransXChange");
    //tabs.add(TZ, "Transformation2");
    tabs.selectTab(0);
    dock.add(tabs, DockPanel.CENTER);
    RootPanel.get("tab_area").add(dock);

    /*
    RootPanel.get("gz_servicestart").add(textBoxServiceStartGz);    
     RootPanel.get("gz_infile").add(uploadFormGz);    
    RootPanel.get("url").add(textBoxUrl);
    RootPanel.get("timezoneP").add(listBoxTimezoneP);
    RootPanel.get("timezoneS").add(listBoxTimezoneS);
    RootPanel.get("defaultroutetype").add(listBoxDefaultRouteType);
    RootPanel.get("outdir").add(labelOutdir);
    labelOutdir.setText(wikiUserName);
    RootPanel.get("user_result").add(labelResultUser);
    RootPanel.get("gz_result").add(labelResultGz);
    RootPanel.get("result").add(labelResult);
     RootPanel.get("infile").add(uploadForm);    */

    // Primary time zone (Africa, Europe, ...) selected
    listBoxTimezoneP.addChangeListener(new ChangeListener() {
        public void onChange(Widget sender) {
            switchTimezone(listBoxTimezoneS, listBoxTimezoneP.getSelectedIndex());
        }
    });

    //----------------------------------------------------------------------------------------------
    //----------------------------------------EDJ---------------------------------------------------

}

From source file:com.gwt.conn.client.Authenticate.java

/** This is essentially the main method for the editor app. */
public static void go() {
    storage.clear(); // uncomment to completely reset app

    final DialogBox startupBox = new DialogBox(); // movable box that contains widgets
    startupBox.setAnimationEnabled(true);
    startupBox.setText("Connoisseur");
    final VerticalPanel startupPanel = new VerticalPanel(); // can contain other widgets
    startupPanel.addStyleName("marginPanel"); // interacts with Connfrontend.css
    startupPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);

    // check to see if storage is supported
    if (storage != null) {

        // load dashboard if license key has been submitted before
        if (storage.getLength() > 0) {
            boolean internet = Communicate.hasInternet();
            StorageContainer.initStorage(); // prepares storage for interaction
            Dashboard.loadMenu(Communicate.deserialize(storage.getItem("menu")), "", internet);
            //Dashboard.loadDashboard();
        }/* w  w  w .  j a  va  2 s .  c  o  m*/

        // otherwise load authentication UI in order to receive license key input
        else {
            final Button submitButton = new Button("Submit"); // "Submit" appears on button
            submitButton.addStyleName("myButton"); // interacts with Connfrontend.css
            final HorizontalPanel buttonPanel = new HorizontalPanel(); // used to center button
            buttonPanel.addStyleName("marginlessPanel");

            // license widgets
            final Label licenseErrorLabel = new Label(); // dynamic text
            licenseErrorLabel.addStyleName("errorLabel"); // interacts with Connfrontend.css
            final TextBox submitLicense = new TextBox(); // user can input text using this
            submitLicense.setText("license key..."); // default text to be seen on load

            // restaurant ID widgets
            final Label restErrorLabel = new Label();
            restErrorLabel.addStyleName("errorLabel");
            final TextBox submitRestID = new TextBox();
            submitRestID.setText("restaurant ID...");

            // organize UI
            startupPanel.add(new HTML("Please enter your license key:"));
            startupPanel.add(submitLicense);
            startupPanel.add(licenseErrorLabel);
            startupPanel.add(new HTML("<br>Please enter your restaurant ID:"));
            startupPanel.add(submitRestID);
            startupPanel.add(restErrorLabel);
            startupPanel.add(new HTML("<br>"));
            buttonPanel.add(submitButton);
            final HTML commError = new HTML();
            commError.addStyleName("errorLabel");
            buttonPanel.add(commError);
            startupPanel.add(buttonPanel);

            // setup startupBox, which is what will be seen by the user
            startupBox.setWidget(startupPanel); // connects the two widgets
            startupBox.center(); // also shows the box

            // focus the cursor on submitLicense when startupBox appears
            submitLicense.setFocus(true);
            submitLicense.selectAll();

            // create a handler for the submitButton and submitLicense
            class MyHandler implements ClickHandler, KeyUpHandler {
                /** Fired when the user clicks submit. */
                public void onClick(ClickEvent event) {
                    submit();
                }

                /** Fired when the user presses Enter in submitLicense. */
                public void onKeyUp(KeyUpEvent event) {
                    if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER)
                        submit();
                }

                /** Checks the submitted license key for validity. Loads the dashboard if valid. */
                private void submit() {
                    // check submit fields
                    String license = submitLicense.getText();
                    String restID = submitRestID.getText();
                    int returnFlag = 0; // so that both tests can be done
                    licenseErrorLabel.setText("");
                    restErrorLabel.setText("");

                    // validate license
                    String result = FieldVerifier.isValidLicenseKey(license); // from FieldVerifier.java
                    if (!result.equals("")) { // error
                        licenseErrorLabel.setText(result);
                        returnFlag = 1;
                    }

                    // validate restID
                    result = FieldVerifier.isValidRestaurantID(restID);
                    if (!result.equals("")) { // error
                        restErrorLabel.setText(result);
                        returnFlag = 1;
                    }

                    // don't do anything until the errors are resolved
                    if (returnFlag == 1)
                        return;
                    storage.setItem("menu", "");

                    // attempt to authenticate
                    Communicate.authenticate(restID, license, commError, startupBox, submitButton,
                            submitLicense, submitRestID);

                } // end submit
            } // MyHandler

            // attach the handler
            final MyHandler handler = new MyHandler();
            submitButton.addClickHandler(handler);
            submitLicense.addKeyUpHandler(handler);
            submitRestID.addKeyUpHandler(handler);
        } // else load authentication UI

    } // if storage supported

    // storage is not supported, so report error
    else {
        startupPanel.add(new HTML("<font color=red>The app will not function because local<br>"
                + "storage is not supported on this platform.</font>"));
        startupBox.setWidget(startupPanel);
        startupBox.center();
    }
}

From source file:com.gwt.conn.client.Dashboard.java

/** Called when the user wants to create a new menu. */
private void newMenu(final DialogBox dashboardBox) {
    // declarations
    final DialogBox submitBox = new DialogBox();
    submitBox.setAnimationEnabled(true);

    final VerticalPanel submitVPanel = new VerticalPanel();
    submitVPanel.addStyleName("marginPanel");
    submitVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);

    final Label errorLabel = new Label();
    errorLabel.addStyleName("errorLabel");

    final Button sendButton = new Button("Submit");
    sendButton.addStyleName("myButton");

    final Button cancelButton = new Button("Cancel");
    sendButton.addStyleName("myButton");

    final TextBox submitField = new TextBox(); // user can input text using
    // this//w ww.  j a  v a2 s. c  om
    submitField.setText("menu name..."); // default text to be seen on load

    final HorizontalPanel submitHPanel = new HorizontalPanel();

    // organize UI
    submitVPanel.add(new HTML("Please enter a name for your new menu:"));
    submitHPanel.add(submitField);
    submitHPanel.add(sendButton);
    submitHPanel.add(cancelButton);
    submitVPanel.add(submitHPanel);
    submitVPanel.add(errorLabel);
    submitBox.setWidget(submitVPanel);
    submitBox.center();
    submitField.setFocus(true);
    submitField.selectAll();

    // handler for the sendButton and submitField
    class SubmitHandler implements ClickHandler, KeyUpHandler {
        /** Fired when the user clicks submit. */
        public void onClick(ClickEvent event) {
            submit();
        }

        /** Fired when the user presses Enter in submitField. */
        public void onKeyUp(KeyUpEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER)
                submit();
        }

        /**
         * Checks the submitted menu name for validity. If valid, loads a
         * new menu object and starts the visual editor.
         */
        private void submit() {
            // validate menu name
            String menuName = submitField.getText();
            String test = FieldVerifier.isValidMenuName(menuName);
            if (!test.equals("")) {
                errorLabel.setText(test);
                submitField.selectAll();
                return;
            }

            String json = "";// createDefaultJSON(); // get default JSON
                             // object
            StorageContainer.addMenu(menuName, json); // to storage
            sendButton.setEnabled(false);
            submitBox.hide();
            // visualEditor.loadVisualEditor(dashboardBox, json); // start
            // editing
        }
    }

    // handler for the cancel button
    class CancelHandler implements ClickHandler {
        /** Fired when the user clicks cancel. */
        public void onClick(ClickEvent event) {
            submitBox.hide();
            dashboardBox.center();
        }
    }

    // attach the handlers
    final SubmitHandler submitHandler = new SubmitHandler();
    final CancelHandler cancelHandler = new CancelHandler();
    sendButton.addClickHandler(submitHandler);
    submitField.addKeyUpHandler(submitHandler);
    cancelButton.addClickHandler(cancelHandler);
}

From source file:com.gwt2go.dev.client.ui.widget.LazySimplePanel.java

License:Apache License

@Override
protected Widget createWidget() {
    SimplePanel panel = new SimplePanel();
    VerticalPanel vrPanel = new VerticalPanel();

    final Label label = new Label("Drag me");
    label.getElement().setDraggable(Element.DRAGGABLE_TRUE);

    label.addDragStartHandler(new DragStartHandler() {

        @Override/*from   w w  w . j  av a2s  . c o  m*/
        public void onDragStart(DragStartEvent event) {
            // required
            event.setData("text", "Hello World");

            // optinal: show copy of the image
            event.getDataTransfer().setDragImage(label.getElement(), 10, 10);
        }
    });

    // some widgets do not implement drag handles
    // for that reason you can use addDomHandler()
    /* label.addDomHandler(new DragStartHandler() {
       @Override
       public void onDragStart(DragStartEvent event) {
    // required
    event.setData("text", "Hello World again;)");
            
    // optional
    event.getDataTransfer().setDragImage(label.getElement(), 10, 10);
       }
    }, DragStartEvent.getType()); */

    final Label target = new Label("Drag onto me");
    // required: you must add dragoverhandler to create a target
    target.addDragOverHandler(new DragOverHandler() {
        @Override
        public void onDragOver(DragOverEvent event) {
            target.getElement().getStyle().setBackgroundColor("#ffa");
        }
    });

    // add drop hanlder
    target.addDropHandler(new DropHandler() {
        @Override
        public void onDrop(DropEvent event) {
            // prevent the native text drop
            event.preventDefault();

            // get the data out of the event
            String data = event.getData("text");
            target.setText(data);
        }
    });

    panel.add(vrPanel);
    vrPanel.getElement().appendChild(this.nameSpan);
    vrPanel.add(label);
    vrPanel.add(target);
    return panel;
}

From source file:com.gwtmobile.ui.client.widgets.PanelBase.java

License:Apache License

@Override
public void add(Widget w) {
    if (isDesignTimeEmptyLabel(w)) {
        Label label = (Label) w;
        String designTimeMessage = getDesignTimeMessage();
        if (designTimeMessage == null) {
            label.setText("Empty " + Utils.getSimpleName(this.getClass()));
        } else {/*from w w w .j a va  2s . c om*/
            label.setText("Empty " + Utils.getSimpleName(this.getClass()) + ". " + designTimeMessage);
        }
    }
    super.add(w);
}

From source file:com.gwtmodel.table.view.util.polymer.PolymerUtil.java

License:Apache License

static void setTitleMess(Label ltitle, Label lmess, String title, String mess) {
    if (!CUtil.EmptyS(title))
        ltitle.setText(iMess.getMessage(title));
    lmess.setText(iMess.getMessage(mess));
}

From source file:com.gwtmodel.table.view.webpanel.common.AbstractWebPanel.java

License:Apache License

protected void setLabels(Label productName, Label ownerName, Label userName, Label hotelName, Label upInfo) {
    this.productName = productName;
    this.ownerName = ownerName;
    this.userName = userName;
    this.hotelName = hotelName;
    this.upInfo = upInfo;
    Window.setTitle(pResources.getRes(IWebPanelResources.TITLE));
    productName.setText(pResources.getRes(IWebPanelResources.PRODUCTNAME));
    ownerName.setText(pResources.getRes(IWebPanelResources.OWNERNAME));
}

From source file:com.hazelcast.monitor.client.AddClusterClickHandler.java

License:Open Source License

private void handleException(Throwable caught, Label error) {
    error.setText(caught.getLocalizedMessage());
    error.setVisible(true);
}

From source file:com.hazelcast.monitor.client.InstanceChartPanel.java

License:Open Source License

public void handle(ChangeEvent e) {
    InstanceStatistics event = (InstanceStatistics) e;
    if (super.name == null || !super.name.equals(event.getName())) {
        return;/*from  w ww  .ja  va 2 s . c om*/
    }
    VerticalPanel vPanel = (VerticalPanel) disclosurePanel.getContent();
    Label label = (Label) vPanel.getWidget(0);
    label.setText("Size: " + event.getSize() + " | Total Throughput: " + event.getTotalOPS());
    if (vPanel.getWidgetCount() < 2) {
        HorizontalPanel horizontalPanel = new HorizontalPanel();
        horizontalPanel.add(createAbsPanelWithImage());
        horizontalPanel.add(createAbsPanelWithImage());
        horizontalPanel.setBorderWidth(0);
        vPanel.add(horizontalPanel);
    }
    HorizontalPanel horizontalPanel = (HorizontalPanel) vPanel.getWidget(1);
    Image sizeChart = (Image) ((AbsolutePanel) horizontalPanel.getWidget(0)).getWidget(0);
    String encodeName = URL.encodeComponent(name);
    sizeChart.setUrl(getServletName() + "?name=" + encodeName + "&type=size&random=" + Math.random() * 10);
    Image opsChart = (Image) ((AbsolutePanel) horizontalPanel.getWidget(1)).getWidget(0);
    opsChart.setUrl(getServletName() + "?name=" + encodeName + "&type=ops&random=" + Math.random() * 10);
}

From source file:com.hazelcast.monitor.client.MapBrowserPanel.java

License:Open Source License

@Override
protected FlexTable createTable() {
    FlexTable table = new FlexTable();
    table.addStyleName("table");
    table.addStyleName("mapstats");
    FlexTable getTable = new FlexTable();
    table.setWidget(0, 0, new Label(""));
    table.getFlexCellFormatter().setColSpan(0, 0, 2);
    table.setWidget(1, 1, getTable);/*from  w w w  .  j a  v a  2s. co  m*/
    final TextBox key = new TextBox();
    getTable.setWidget(0, 0, new Label("Key: "));
    getTable.setWidget(0, 1, key);
    Button button = new Button("Get");
    button.addStyleName("map_get_button");
    getTable.setWidget(0, 2, button);
    FlexTable resultTable = new FlexTable();
    resultTable.setWidth("500px");
    table.setWidget(1, 2, resultTable);
    resultTable.setWidget(0, 0, new Label("Value: "));
    resultTable.setWidget(1, 0, new Label("Hits: "));
    resultTable.setWidget(2, 0, new Label("Cost: "));
    resultTable.setWidget(3, 0, new Label("Valid: "));
    resultTable.setWidget(4, 0, new Label("Expiration Time: "));
    resultTable.setWidget(5, 0, new Label("Last Acess Time: "));
    resultTable.setWidget(6, 0, new Label("Last Update Time: "));
    resultTable.setWidget(7, 0, new Label("Creation Time: "));
    for (int i = 0; i < resultTable.getRowCount(); i++) {
        Label label = (Label) resultTable.getWidget(i, 0);
        label.addStyleName("bold");
        if (i % 2 == 1) {
            resultTable.getRowFormatter().addStyleName(i, "mapstatsEvenRow");
        }
    }
    final TextArea value = new TextArea();
    final Label hits = new Label();
    final Label cost = new Label();
    final Label expirationTime = new Label();
    final Label lastAcessTime = new Label();
    final Label lastUpdateTime = new Label();
    final Label creationTime = new Label();
    final Label valid = new Label();
    resultTable.setWidget(0, 1, value);
    resultTable.setWidget(1, 1, hits);
    resultTable.setWidget(2, 1, cost);
    resultTable.setWidget(3, 1, valid);
    resultTable.setWidget(4, 1, expirationTime);
    resultTable.setWidget(5, 1, lastAcessTime);
    resultTable.setWidget(6, 1, lastUpdateTime);
    resultTable.setWidget(7, 1, creationTime);
    final DateTimeFormat dateFormatter = DateTimeFormat.getFormat("yyyy.MM.dd HH:mm:ss");
    button.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent clickEvent) {
            mapService.get(clusterWidgets.clusterId, name, key.getText(), new AsyncCallback<MapEntry>() {
                public void onFailure(Throwable throwable) {
                    if (throwable instanceof ClientDisconnectedException) {
                        clusterWidgets.disconnected();
                    }
                    value.setText(throwable.toString());
                }

                public void onSuccess(MapEntry mapEntry) {
                    value.setText((mapEntry == null) ? "null" : mapEntry.getValue());
                    hits.setText((mapEntry == null) ? "" : String.valueOf(mapEntry.getHits()));
                    cost.setText((mapEntry == null) ? "" : formatMemorySize(mapEntry.getCost()));
                    valid.setText((mapEntry == null) ? "" : String.valueOf(mapEntry.isValid()));
                    expirationTime.setText(
                            (mapEntry == null) ? "" : format(dateFormatter, mapEntry.getExpirationTime()));
                    lastAcessTime.setText(
                            (mapEntry == null) ? "" : format(dateFormatter, mapEntry.getLastAccessTime()));
                    lastUpdateTime.setText(
                            (mapEntry == null) ? "" : format(dateFormatter, mapEntry.getLastUpdateTime()));
                    creationTime.setText(
                            (mapEntry == null) ? "" : format(dateFormatter, mapEntry.getCreationTime()));
                }
            });
        }
    });
    return table;
}