List of usage examples for com.google.gwt.user.client.ui HorizontalPanel HorizontalPanel
public HorizontalPanel()
From source file:com.google.appinventor.client.widgets.boxes.ColumnLayout.java
License:Open Source License
@Override public void apply(WorkAreaPanel workArea) { // Clear base panel workArea.clear();/* w w w . jav a2s . c o m*/ // Horizontal panel to hold columns HorizontalPanel horizontalPanel = new HorizontalPanel(); horizontalPanel.setSize("100%", "100%"); workArea.add(horizontalPanel); // Initialize columns for (Column column : columns) { horizontalPanel.add(column.columnPanel); workArea.getWidgetDragController().registerDropController(column); // Add invisible dummy widget to prevent column from collapsing when it contains no boxes column.columnPanel.add(new Label()); // Add boxes from layout List<BoxDescriptor> boxes = column.boxes; for (int index = 0; index < boxes.size(); index++) { BoxDescriptor bd = boxes.get(index); Box box = workArea.createBox(bd); if (box != null) { column.insert(box, index); box.restoreLayoutSettings(bd); } } } workArea.getWidgetDragController().addDragHandler(changeDetector); }
From source file:com.google.appinventor.client.widgets.LabeledTextBox.java
License:Open Source License
/** * Creates a new TextBox with the given leading caption. * * @param caption caption for leading label *//*ww w . j ava 2 s . c o m*/ public LabeledTextBox(String caption) { HorizontalPanel panel = new HorizontalPanel(); Label label = new Label(caption); panel.add(label); textbox = new TextBox(); textbox.setWidth("100%"); panel.add(textbox); panel.setCellWidth(label, "40%"); initWidget(panel); setWidth("100%"); }
From source file:com.google.appinventor.client.widgets.LabeledTextBox.java
License:Open Source License
/** * Use this TextBox if you want to have text validation while a user is typing * * @param caption caption for leading label * @param validator The validator to use for a specific textBox *//*from ww w . j a v a 2 s . com*/ public LabeledTextBox(String caption, Validator validator) { this.validator = validator; HorizontalPanel panel = new HorizontalPanel(); Label label = new Label(caption); panel.add(label); textbox = new TextBox(); defaultTextBoxColor = textbox.getElement().getStyle().getBorderColor(); textbox.setWidth("100%"); panel.add(textbox); panel.setCellWidth(label, "40%"); HorizontalPanel errorPanel = new HorizontalPanel(); errorLabel = new Label(""); errorPanel.add(errorLabel); VerticalPanel vp = new VerticalPanel(); vp.add(panel); vp.add(errorPanel); vp.setHeight("85px"); initWidget(vp); setWidth("100%"); }
From source file:com.google.appinventor.client.widgets.properties.AdditionalChoicePropertyEditor.java
License:Open Source License
/** * Initializes the additional choice panel. * * <p>This method must be called from any implementor's constructor. * * @param panel panel containing additional choices *///from w ww . java 2 s . c om protected void initAdditionalChoicePanel(Panel panel) { Button cancelButton = new Button(MESSAGES.cancelButton()); cancelButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { closeAdditionalChoiceDialog(false); } }); Button okButton = new Button(MESSAGES.okButton()); okButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { closeAdditionalChoiceDialog(true); } }); HorizontalPanel buttonPanel = new HorizontalPanel(); buttonPanel.add(cancelButton); buttonPanel.add(okButton); buttonPanel.setWidth("100%"); buttonPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT); VerticalPanel contentPanel = new VerticalPanel(); contentPanel.add(panel); contentPanel.add(buttonPanel); popup = new PopupPanel(false, true); popup.setAutoHideEnabled(true); popup.setWidget(contentPanel); popup.setStylePrimaryName("ode-MultipleChoicePropertyEditor"); }
From source file:com.google.appinventor.client.widgets.Toolbar.java
License:Open Source License
/** * Initializes and assembles all commands into buttons in the toolbar. *//*from w ww .j a v a 2s. co m*/ public Toolbar() { buttonMap = new HashMap<String, TextButton>(); dropDownButtonMap = new HashMap<String, DropDownButton>(); leftButtons = new HorizontalPanel(); leftButtons.setSpacing(4); rightButtons = new HorizontalPanel(); rightButtons.setSpacing(4); rightButtons.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT); HorizontalPanel toolbar = new HorizontalPanel(); toolbar.add(leftButtons); // this nesting keeps buttons left aligned toolbar.add(rightButtons); toolbar.setCellHorizontalAlignment(rightButtons, HorizontalPanel.ALIGN_RIGHT); toolbar.setWidth("100%"); toolbar.setStylePrimaryName("ya-Toolbar"); initWidget(toolbar); }
From source file:com.google.appinventor.client.wizards.InputTemplateUrlWizard.java
License:Open Source License
/** * Creates a new YoungAndroid project wizard. *///www .j a va 2 s . c o m public InputTemplateUrlWizard(final NewUrlDialogCallback callback) { super(MESSAGES.inputNewUrlCaption(), true, true); // Initialize the UI. setStylePrimaryName("ode-DialogBox"); HorizontalPanel panel = new HorizontalPanel(); urlTextBox = new LabeledTextBox(MESSAGES.newUrlLabel()); urlTextBox.getTextBox().setWidth("250px"); urlTextBox.getTextBox().addKeyUpHandler(new KeyUpHandler() { @Override public void onKeyUp(KeyUpEvent event) { int keyCode = event.getNativeKeyCode(); if (keyCode == KeyCodes.KEY_ENTER) { handleOkClick(); } else if (keyCode == KeyCodes.KEY_ESCAPE) { handleCancelClick(); } } }); VerticalPanel page = new VerticalPanel(); panel.add(urlTextBox); page.add(panel); addPage(page); // Create finish command (create a new Young Android project). initFinishCommand(new Command() { @Override public void execute() { String hostUrl = urlTextBox.getText(); if (TemplateUploadWizard.hasUrl(hostUrl)) { Window.alert("The Url " + hostUrl + " already exists."); } else { callback.updateTemplateOptions(hostUrl); } } }); }
From source file:com.google.appinventor.client.wizards.TemplateUploadWizard.java
License:Open Source License
/** * The UI consists of a vertical panel that holds a drop-down list box, * a Horizontal panel that holds the templates list (cell list) plus * the selected template. This is inserted in the Wizard dialog. * * @param templates should never be null * @return the main panel for Wizard dialog. *//*w w w . ja v a 2 s . co m*/ VerticalPanel createUI(final ArrayList<TemplateInfo> templates) { VerticalPanel panel = new VerticalPanel(); panel.setStylePrimaryName("gwt-SimplePanel"); panel.setVerticalAlignment(VerticalPanel.ALIGN_MIDDLE); panel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER); templatePanel = new HorizontalPanel(); templatePanel.add(makeTemplateSelector(templates)); if (templates.size() > 0) templatePanel.add(new TemplateWidget(templates.get(0), templateHostUrl)); templatesMenu = makeTemplatesMenu(); HorizontalPanel hPanel = new HorizontalPanel(); hPanel.add(templatesMenu); removeButton = new Button("Remove this repository", new ClickHandler() { @Override public void onClick(ClickEvent arg0) { removeCurrentlySelectedRepository(); } }); removeButton.setVisible(false); hPanel.add(removeButton); panel.add(hPanel); panel.add(templatePanel); return panel; }
From source file:com.google.appinventor.client.wizards.TemplateUploadWizard.java
License:Open Source License
/** * Loads templates into the templatePanel, which consists of a * clickable list widget of templates and a widget that displays * a summary of the list's current selection. * * @param templates// w w w. j a va 2 s .c o m */ void populateTemplateDialog(ArrayList<TemplateInfo> templates) { String hostUrl = ""; // Validity check for user-entered Url. if (this.newUrlTestIsPending) { newUrlTestIsPending = false; hostUrl = pendingUrl; pendingUrl = ""; if (templates != null) { dynamicTemplateUrls.add(hostUrl); templatesMenu.addItem(hostUrl); templatesMenu.setSelectedIndex(templatesMenu.getItemCount() - 1); // Last item lastSelectedIndex = templatesMenu.getSelectedIndex(); usingExternalTemplate = true; templateHostUrl = templatesMenu.getValue(lastSelectedIndex); } else { return; } } if (templates == null) return; // Display the templates for the the selected Url. for (int k = 0; k < templatePanel.getWidgetCount(); k++) { templatePanel.getWidget(k).removeFromParent(); } VerticalPanel parent = (VerticalPanel) templatePanel.getParent(); templatePanel.removeFromParent(); templatePanel = new HorizontalPanel(); // Add the new templates templatePanel.add(makeTemplateSelector(templates)); if (templates.size() > 0) templatePanel.add(new TemplateWidget(templates.get(0), templateHostUrl)); parent.add(templatePanel); }
From source file:com.google.appinventor.client.wizards.Wizard.java
License:Open Source License
/** * Creates a new wizard.//w ww.ja v a 2 s .co m * <p> * Implementations are expected to build the wizard dialog in their * constructor. In particular, it is expected that * {@link #addPage(Panel)} and {@link #initFinishCommand(Command)} * will be called before the constructor terminates. * * @param title title displayed in wizard dialog box * @param modal indicates modality of the wizard * @param adaptiveSizing instead of using the minimal size for the * wizard also considers the size of the browser area */ protected Wizard(String title, boolean modal, boolean adaptiveSizing) { // Initialize UI // TODO(lizlooney) - investigate using built-in modality support. The // reasons for not using it initially are no longer valid. super(false, false); this.modal = modal; this.adaptiveSizing = adaptiveSizing; setStylePrimaryName("ode-DialogBox"); setText(title); ClickListener buttonListener = new ClickListener() { @Override public void onClick(Widget sender) { if (sender == cancelButton) { handleCancelClick(); } else if (sender == nextButton) { showNextPage(); } else if (sender == backButton) { showPreviousPage(); } else if (sender == okButton) { handleOkClick(); } } }; cancelButton = new Button(MESSAGES.cancelButton()); cancelButton.addClickListener(buttonListener); backButton = new Button(MESSAGES.backButton()); backButton.addClickListener(buttonListener); nextButton = new Button(MESSAGES.nextButton()); nextButton.addClickListener(buttonListener); okButton = new Button(MESSAGES.okButton()); okButton.addClickListener(buttonListener); buttonPanel = new HorizontalPanel(); buttonPanel.add(cancelButton); buttonPanel.add(backButton); buttonPanel.add(nextButton); buttonPanel.add(okButton); buttonPanel.setSize("100%", "24px"); pageDeck = new DeckPanel(); pageDeck.setSize("100%", "100%"); pagePanel = new AbsolutePanel(); pagePanel.add(pageDeck); pagePanel.setWidth("100%"); VerticalPanel contentPanel = new VerticalPanel(); contentPanel.add(pagePanel); contentPanel.add(buttonPanel); contentPanel.setSize("100%", "100%"); add(contentPanel); }
From source file:com.google.code.gwt.storage.sample.hellostorage.client.HelloStorage.java
License:Apache License
/** * This is the entry point method.//from www.j a v a2 s . c o m */ public void onModuleLoad() { VerticalPanel main = new VerticalPanel(); RootPanel.get().add(main); RootPanel.get().setWidgetPosition(main, 10, 10); eventArea = new TextArea(); eventArea.setStyleName("widePanel"); eventArea.setHeight("60px"); eventArea.setText("[StorageEvent info]"); main.add(eventArea); HorizontalPanel eventPanel = new HorizontalPanel(); eventPanel.setStyleName("widePanel"); main.add(eventPanel); handlersLabel = new Label("#Handlers: 0"); eventPanel.add(new Button("Add a Handler", new ClickHandler() { public void onClick(ClickEvent event) { StorageEventHandler handler = new MyHandler(handlers.size() + 1); handlers.add(handler); Storage.addStorageEventHandler(handler); handlersLabel.setText("#Handlers: " + handlers.size()); } })); eventPanel.add(new Button("Delete a Handler", new ClickHandler() { public void onClick(ClickEvent event) { if (handlers.size() > 0) { StorageEventHandler handler = handlers.remove(handlers.size() - 1); Storage.removeStorageEventHandler(handler); handlersLabel.setText("#Handlers: " + handlers.size()); } } })); eventPanel.add(handlersLabel); eventPanel.setCellHorizontalAlignment(handlersLabel, HasHorizontalAlignment.ALIGN_RIGHT); if (!Storage.isLocalStorageSupported() && !Storage.isSessionStorageSupported()) { Window.alert("Web Storage NOT supported in this browser!"); return; } Storage local = Storage.getLocalStorage(); Storage session = Storage.getSessionStorage(); TabPanel tabs = new TabPanel(); main.add(tabs); tabs.add(createStorageTab(local, Storage.isLocalStorageSupported()), "localStorage"); tabs.add(createStorageTab(session, Storage.isSessionStorageSupported()), "sessionStorage"); tabs.selectTab(0); }