List of usage examples for com.google.gwt.user.client.ui HorizontalPanel HorizontalPanel
public HorizontalPanel()
From source file:com.google.gwt.gears.sample.database.client.DatabaseDemo.java
License:Apache License
public void onModuleLoad() { VerticalPanel outerPanel = new VerticalPanel(); outerPanel.setSpacing(10);//www . jav a 2 s .com outerPanel.getElement().getStyle().setPropertyPx("margin", 15); HorizontalPanel textAndButtonsPanel = new HorizontalPanel(); textAndButtonsPanel.add(new Label("Enter a Phrase: ")); textAndButtonsPanel.add(input); textAndButtonsPanel.add(addButton); textAndButtonsPanel.add(clearButton); outerPanel.add(textAndButtonsPanel); outerPanel.add(new Label("Last 3 Entries:")); outerPanel.add(dataTable); for (int i = 0; i <= NUM_SAVED_ROWS; ++i) { dataTable.insertRow(i); for (int j = 0; j < NUM_DATA_TABLE_COLUMNS; j++) { dataTable.addCell(i); } } dataTable.setWidget(0, 0, new HTML("<b>Id</b>")); dataTable.setWidget(0, 1, new HTML("<b>Phrase</b>")); dataTable.setWidget(0, 2, new HTML("<b>Timestamp</b>")); // Create the database if it doesn't exist. try { db = Factory.getInstance().createDatabase(); db.open("database-demo"); db.execute( "CREATE TABLE IF NOT EXISTS Phrases (Id INTEGER PRIMARY KEY AUTOINCREMENT, Phrase VARCHAR(255), Timestamp INTEGER)"); } catch (DatabaseException e) { RootPanel.get("demo").add(new HTML( "Error opening or creating database: <font color=\"red\">" + e.toString() + "</font>")); // Fatal error. Do not build the interface. return; } input.addKeyboardListener(new KeyboardListenerAdapter() { @Override public void onKeyDown(Widget sender, char keyCode, int modifiers) { if (keyCode == KeyboardListener.KEY_ENTER) { insertPhrase(); } } }); addButton.addClickListener(new ClickListener() { public void onClick(Widget sender) { insertPhrase(); } }); clearButton.addClickListener(new ClickListener() { public void onClick(Widget sender) { clearPhrases(); displayRecentPhrases(); } }); RootPanel.get("demo").add(outerPanel); displayRecentPhrases(); }
From source file:com.google.gwt.gears.sample.databasedemo.client.DatabaseDemo.java
License:Apache License
public void onModuleLoad() { VerticalPanel outerPanel = new VerticalPanel(); outerPanel.setSpacing(10);/*from ww w . j av a2 s. c o m*/ outerPanel.getElement().getStyle().setPropertyPx("margin", 15); HorizontalPanel textAndButtonsPanel = new HorizontalPanel(); textAndButtonsPanel.add(new Label("Enter a Phrase: ")); textAndButtonsPanel.add(input); textAndButtonsPanel.add(addButton); textAndButtonsPanel.add(clearButton); outerPanel.add(textAndButtonsPanel); outerPanel.add(new Label("Last 3 Entries:")); outerPanel.add(dataTable); for (int i = 0; i <= NUM_SAVED_ROWS; ++i) { dataTable.insertRow(i); for (int j = 0; j < NUM_DATA_TABLE_COLUMNS; j++) { dataTable.addCell(i); } } dataTable.setWidget(0, 0, new HTML("<b>Id</b>")); dataTable.setWidget(0, 1, new HTML("<b>Phrase</b>")); dataTable.setWidget(0, 2, new HTML("<b>Timestamp</b>")); // Create the database if it doesn't exist. try { db = Factory.getInstance().createDatabase(); db.open("database-demo"); db.execute( "CREATE TABLE IF NOT EXISTS Phrases (Id INTEGER PRIMARY KEY AUTOINCREMENT, Phrase VARCHAR(255), Timestamp INTEGER)"); } catch (DatabaseException e) { RootPanel.get("demo").add(new HTML( "Error opening or creating database: <font color=\"red\">" + e.toString() + "</font>")); // Fatal error. Do not build the interface. return; } input.addKeyDownHandler(new KeyDownHandler() { public void onKeyDown(KeyDownEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { insertPhrase(); } } }); addButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { insertPhrase(); } }); clearButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { clearPhrases(); displayRecentPhrases(); } }); RootPanel.get("demo").add(outerPanel); displayRecentPhrases(); }
From source file:com.google.gwt.gears.sample.gwtnote.client.ui.RichTextWidget.java
License:Apache License
/** * Creates a new widget. This class needs access to certain fields and methods * on the application enclosing it.// ww w .j av a2s. c o m * * @param parent the host application */ public RichTextWidget(final GWTNote parent) { super(); VerticalPanel top = new VerticalPanel(); top.setWidth("100%"); HorizontalPanel header = new HorizontalPanel(); top.add(header); header.setWidth("100%"); header.add(new Label("GWT GearsNote")); header.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); status = new Label("Ready"); header.add(status); this.bodyWidget = new RichTextArea(); bodyWidget.addKeyboardListener(new KeyboardListenerAdapter() { @Override public void onKeyPress(Widget sender, char keyCode, int modifiers) { String newText = bodyWidget.getText(); if (((newText == null) && (curText != null)) || ((newText != null) && !newText.equals(curText))) { curText = newText; } } }); HorizontalPanel controls = new HorizontalPanel(); RichTextToolbar tb = new RichTextToolbar(this.bodyWidget); name = new TextBox(); name.setText("default"); name.setEnabled(false); nameEdit = new PushButton("Edit"); nameEdit.addClickListener(new ClickListener() { public void onClick(Widget sender) { String curName = name.getText(); boolean doNotify = !oldName.equals(curName); if (!nameEditable) { // if becoming editable, store off current value oldName = curName; } if (nameEditable && (curName == null || "".equals(curName))) { // if becoming un-editable, check to make sure it's valid Window.alert("The note name cannot be blank. Please try again."); nameEdit.setText(oldName); return; } // if all else is good, just flip the state nameEditable = !nameEditable; name.setEnabled(nameEditable); nameEdit.getUpFace().setText((nameEditable ? "Confirm" : "Edit")); if (doNotify) { notifyNameListeners(); } } }); nameEdit.addStyleName("edit-button"); options = new ListBox(); controls.add(tb); options.addItem("default"); options.setSelectedIndex(0); options.addChangeListener(new ChangeListener() { public void onChange(Widget sender) { String newName = options.getItemText(options.getSelectedIndex()); name.setText(newName); notifyNameListeners(); } }); HorizontalPanel tmp = new HorizontalPanel(); tmp.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); tmp.add(new Label("Note name:")); tmp.add(name); tmp.add(nameEdit); tmp.add(options); controls.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); controls.setWidth("100%"); controls.add(tmp); top.add(controls); top.add(bodyWidget); this.bodyWidget.setWidth("100%"); top.setCellHeight(bodyWidget, ((int) (Window.getClientHeight() * .75)) + "px"); this.bodyWidget.setHeight("100%"); initWidget(top); }
From source file:com.google.gwt.gears.sample.managedresourcestore.client.ManagedResourceStoreDemo.java
License:Apache License
public void onModuleLoad() { HorizontalPanel hpanel = new HorizontalPanel(); hpanel.setSpacing(10);/* w w w. j a va 2 s.c o m*/ RootPanel.get("demo").add(hpanel); hpanel.add(createManagedResourceStoreButton); // See if we're already running from a ManagedResourceStore try { LocalServer server = Factory.getInstance().createLocalServer(); // This check to see if the host page can be served locally if (server.canServeLocally(Window.Location.getPath())) { createManagedResourceStoreButton.setText("Refresh Manifest"); // Give the user an opportunity to delete the MRS hpanel.add(removeManagedResourceStoreButton); } } catch (GearsException e) { // Gears probably isn't available (e.g. hosted mode) } createManagedResourceStoreButton.addClickListener(new ClickListener() { public void onClick(Widget sender) { statusLabel.setText("Starting update"); createManagedResourceStore(); } }); removeManagedResourceStoreButton.addClickListener(new ClickListener() { public void onClick(Widget sender) { try { LocalServer server = Factory.getInstance().createLocalServer(); ManagedResourceStore store = Offline.getManagedResourceStore(); server.removeManagedStore(store.getName()); statusLabel.setText("Removed ManagedResourceStore. Press Refresh to see Online version."); createManagedResourceStoreButton.setEnabled(false); removeManagedResourceStoreButton.setEnabled(false); } catch (GearsException e) { statusLabel.setText(e.getMessage()); } } }); hpanel.add(statusLabel); }
From source file:com.google.gwt.gears.sample.managedresourcestoredemo.client.ManagedResourceStoreDemo.java
License:Apache License
public void onModuleLoad() { HorizontalPanel hpanel = new HorizontalPanel(); hpanel.setSpacing(10);//from w w w. j a v a 2 s. c om RootPanel.get("demo").add(hpanel); hpanel.add(createManagedResourceStoreButton); // See if we're already running from a ManagedResourceStore try { LocalServer server = Factory.getInstance().createLocalServer(); // This check to see if the host page can be served locally if (server.canServeLocally(Window.Location.getPath())) { createManagedResourceStoreButton.setText("Refresh Manifest"); // Give the user an opportunity to delete the MRS hpanel.add(removeManagedResourceStoreButton); } } catch (GearsException e) { // Gears probably isn't available (e.g. hosted mode) } createManagedResourceStoreButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { statusLabel.setText("Starting update"); createManagedResourceStore(); } }); removeManagedResourceStoreButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { try { LocalServer server = Factory.getInstance().createLocalServer(); ManagedResourceStore store = Offline.getManagedResourceStore(); server.removeManagedStore(store.getName()); statusLabel.setText("Removed ManagedResourceStore. Press Refresh to see Online version."); createManagedResourceStoreButton.setEnabled(false); removeManagedResourceStoreButton.setEnabled(false); } catch (GearsException e) { statusLabel.setText(e.getMessage()); } } }); hpanel.add(statusLabel); }
From source file:com.google.gwt.gears.sample.uploaddemo.client.UploadDemo.java
License:Apache License
/** * This is the entry point method./*from ww w . j a v a2 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./*w w 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.workerpool.client.WorkerPoolDemo.java
License:Apache License
public void onModuleLoad() { vp.setSpacing(10);// w w w. j a va2 s . com vp.add(buildControlPanel()); vp.add(statusLabel); HorizontalPanel digitPanel = new HorizontalPanel(); digitPanel.add(new HTML("<h1>3.</h1>")); digitPanel.add(htmlGoesHere); htmlResults.setHTML("<h1><i>???</i></h1>"); htmlGoesHere.add(htmlResults); vp.add(digitPanel); RootPanel.get().add(vp); }
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.//w w w . ja va 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; }
From source file:com.google.gwt.gen2.demo.datepicker.client.DatePickerDemo.java
License:Apache License
/** * This is the entry point method./* w w w .jav a 2 s . c o m*/ */ public void onModuleLoad() { Log.info("Log messages enabled"); HorizontalPanel master = new HorizontalPanel(); SimpleLogHandler handler = new SimpleLogHandler(false); Log.addLogHandler(handler); DatePicker.injectDefaultCss(); TabPanel panel = new TabPanel(); master.add(panel); master.add(handler.getWidget()); panel.add(new LazyPanel<Widget>() { @Override public Widget createWidget() { return simplePicker(); } }, "simple"); panel.add(new LazyPanel<Widget>() { @Override public Widget createWidget() { return eventPicker(); } }, "events"); panel.add(new LazyPanel<Widget>() { @Override public Widget createWidget() { return stylingPicker(); } }, "styles"); panel.add(new LazyPanel<Widget>() { @Override public Widget createWidget() { return dateRange(); } }, "date range"); panel.selectTab(0); RootPanel.get().add(master); }