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

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

Introduction

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

Prototype

protected Button(com.google.gwt.dom.client.Element element) 

Source Link

Document

This constructor may be used by subclasses to explicitly use an existing element.

Usage

From source file:com.google.gwt.gdata.sample.hellogdata.client.GoogleBaseUpdateItemDemo.java

License:Apache License

/**
 * Starts this demo./* w  ww  .ja va  2  s  . c om*/
 */
private void startDemo() {
    service = GoogleBaseService.newInstance("HelloGData_GoogleBase_UpdateItemDemo_v2.0");
    if (User.getStatus(scope) == AuthSubStatus.LOGGED_IN) {
        Button startButton = new Button("Update an item");
        startButton.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                getItems("http://www.google.com/base/feeds/items/");
            }
        });
        mainPanel.setWidget(0, 0, startButton);
    } else {
        showStatus("You are not logged on to Google Base.", true);
    }
}

From source file:com.google.gwt.gdata.sample.hellogdata.client.MapsCreateMapDemo.java

License:Apache License

/**
 * Starts this demo./* w  w  w. ja  v  a 2s  . co m*/
 */
private void startDemo() {
    service = MapsService.newInstance("HelloGData_Maps_CreateMapDemo_v2.0");
    if (User.getStatus(scope) == AuthSubStatus.LOGGED_IN) {
        Button startButton = new Button("Create a map");
        startButton.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                createMap("http://maps.google.com/maps/feeds/maps/default/full");
            }
        });
        mainPanel.setWidget(0, 0, startButton);
    } else {
        showStatus("You are not logged on to Google Maps.", true);
    }
}

From source file:com.google.gwt.gdata.sample.hellogdata.client.MapsCreateMapFeatureDemo.java

License:Apache License

/**
 * Starts this demo./*  w  w w.j a v a 2  s . c  o  m*/
 */
private void startDemo() {
    service = MapsService.newInstance("HelloGData_Maps_CreateMapFeatureDemo_v2.0");
    if (User.getStatus(scope) == AuthSubStatus.LOGGED_IN) {
        Button startButton = new Button("Create a map feature");
        startButton.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                getMaps("http://maps.google.com/maps/feeds/maps/default/full");
            }
        });
        mainPanel.setWidget(0, 0, startButton);
    } else {
        showStatus("You are not logged on to Google Maps.", true);
    }
}

From source file:com.google.gwt.gdata.sample.hellogdata.client.MapsDeleteMapDemo.java

License:Apache License

/**
 * Starts this demo./*from  w w  w.j a v a2  s.  co  m*/
 */
private void startDemo() {
    service = MapsService.newInstance("HelloGData_Maps_DeleteMapDemo_v2.0");
    if (User.getStatus(scope) == AuthSubStatus.LOGGED_IN) {
        Button startButton = new Button("Delete a map");
        startButton.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                getMaps("http://maps.google.com/maps/feeds/maps/default/full");
            }
        });
        mainPanel.setWidget(0, 0, startButton);
    } else {
        showStatus("You are not logged on to Google Maps.", true);
    }
}

From source file:com.google.gwt.gdata.sample.hellogdata.client.MapsDeleteMapFeatureDemo.java

License:Apache License

/**
 * Starts this demo.//from w w  w .  j  a  v a 2  s.  c o m
 */
private void startDemo() {
    service = MapsService.newInstance("HelloGData_Maps_DeleteMapFeatureDemo_v2.0");
    if (User.getStatus(scope) == AuthSubStatus.LOGGED_IN) {
        Button startButton = new Button("Delete a map feature");
        startButton.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                getMaps("http://maps.google.com/maps/feeds/maps/default/full");
            }
        });
        mainPanel.setWidget(0, 0, startButton);
    } else {
        showStatus("You are not logged on to Google Maps.", true);
    }
}

From source file:com.google.gwt.gdata.sample.hellogdata.client.MapsUpdateMapDemo.java

License:Apache License

/**
 * Starts this demo.//from  w  w w  .ja  v a  2 s  .co m
 */
private void startDemo() {
    service = MapsService.newInstance("HelloGData_Maps_UpdateMapDemo_v2.0");
    if (User.getStatus(scope) == AuthSubStatus.LOGGED_IN) {
        Button startButton = new Button("Update a map");
        startButton.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                getMaps("http://maps.google.com/maps/feeds/maps/default/full");
            }
        });
        mainPanel.setWidget(0, 0, startButton);
    } else {
        showStatus("You are not logged on to Google Maps.", true);
    }
}

From source file:com.google.gwt.gdata.sample.hellogdata.client.MapsUpdateMapFeatureDemo.java

License:Apache License

/**
 * Starts this demo.//from ww w  .ja va 2 s  . co  m
 */
private void startDemo() {
    service = MapsService.newInstance("HelloGData_Maps_UpdateMapFeatureDemo_v2.0");
    if (User.getStatus(scope) == AuthSubStatus.LOGGED_IN) {
        Button startButton = new Button("Update a map feature");
        startButton.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                getMaps("http://maps.google.com/maps/feeds/maps/default/full");
            }
        });
        mainPanel.setWidget(0, 0, startButton);
    } else {
        showStatus("You are not logged on to Google Maps.", true);
    }
}

From source file:com.google.gwt.gears.sample.uploaddemo.client.UploadDemo.java

License:Apache License

/**
 * This is the entry point method./*from  w  w  w. j  a v  a 2 s . c o m*/
 */
public void onModuleLoad() {
    root = RootPanel.get();

    final Button browse = new Button("Browse");

    final Button upload = new Button("Upload");
    upload.setEnabled(false);

    final TextBox selected = new TextBox();
    selected.setEnabled(false);

    final SimplePanel progressInner = new SimplePanel();
    progressInner.addStyleName("progressInner");

    final SimplePanel progressGauge = new SimplePanel();
    progressGauge.addStyleName("progressGauge");
    progressGauge.add(progressInner);

    final HTML result = new HTML();

    browse.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            Desktop desktop = factory.createDesktop();
            desktop.openFiles(new OpenFilesHandler() {

                public void onOpenFiles(OpenFilesEvent event) {
                    File[] files = event.getFiles();
                    selected.setText(files[0].getName());
                    selectedFile = files[0].getBlob();
                    upload.setEnabled(true);
                }
            }, true);
        }
    });

    upload.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            HttpRequest request = factory.createHttpRequest();
            request.open("POST", GWT.getModuleBaseURL() + "upload");
            request.setRequestHeader("X-Filename", selected.getText());

            request.setCallback(new RequestCallback() {
                public void onResponseReceived(HttpRequest request) {
                    String msg = request.getStatus() + " " + request.getResponseText();
                    if (request.getStatus() != 200) {
                        result.setHTML("<p style=\"color:red\">" + msg + "</p>");
                    } else {
                        result.setHTML("<p style=\"color:green\">" + msg + "</p>");
                    }
                }
            });

            request.getUpload().setProgressHandler(new ProgressHandler() {
                public void onProgress(ProgressEvent event) {
                    double pcnt = ((double) event.getLoaded() / event.getTotal());
                    progressInner.setWidth((int) Math.floor(pcnt * 100) + "%");
                }
            });
            request.send(selectedFile);
        }
    });

    HorizontalPanel inputPanel = new HorizontalPanel();
    inputPanel.add(selected);
    inputPanel.add(browse);
    inputPanel.add(upload);

    root.add(inputPanel);
    root.add(new HTML("Progress:"));
    root.add(progressGauge);
    root.add(result);
}

From source file:com.google.gwt.gears.sample.workerpool.client.AnimationToy.java

License:Apache License

/**
 * Create an options panel that allows users to select a widget and reposition
 * it./*ww w. j  a  v a 2s  .com*/
 * 
 * @return the new options panel
 */
private Widget createOptionsBar() {
    // Create a panel to move components around
    HorizontalPanel optionsBar = new HorizontalPanel();
    optionsBar.setSpacing(5);
    optionsBar.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);

    // Add a title
    optionsBar.add(new HTML("<b>Animate Logos</b>"));

    // Add start button
    startButton = new Button("Start");
    startButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            animation.run(2000);
        }
    });
    optionsBar.add(startButton);

    // Add cancel button
    cancelButton = new Button("Cancel");
    cancelButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            animation.cancel();
        }
    });
    optionsBar.add(cancelButton);

    // Return the options bar
    return optionsBar;
}

From source file:com.google.gwt.gears.sample.workerpooldemo.client.AnimationToy.java

License:Apache License

/**
 * Create an options panel that allows users to select a widget and reposition
 * it.//from   ww  w  .j a  v a 2 s . c  o  m
 *
 * @return the new options panel
 */
private Widget createOptionsBar() {
    // Create a panel to move components around
    HorizontalPanel optionsBar = new HorizontalPanel();
    optionsBar.setSpacing(5);
    optionsBar.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);

    // Add a title
    optionsBar.add(new HTML("<b>Animate Logos</b>"));

    // Add start button
    startButton = new Button("Start");
    startButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            animation.run(2000);
        }
    });
    optionsBar.add(startButton);

    // Add cancel button
    cancelButton = new Button("Cancel");
    cancelButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            animation.cancel();
        }
    });
    optionsBar.add(cancelButton);

    // Return the options bar
    return optionsBar;
}