List of usage examples for com.google.gwt.user.client.ui HorizontalPanel setCellWidth
public void setCellWidth(IsWidget w, String width)
From source file:com.google.appinventor.client.TopPanel.java
License:Open Source License
private void addLogo(HorizontalPanel panel) { // Logo should be a link to App Inv homepage. Currently, after the user // has logged in, the top level *is* ODE; so for now don't make it a link. // Add timestamp to logo url to get around browsers that agressively cache // the image! This same trick is used in StorageUtil.getFilePath(). Image logo = new Image(LOGO_IMAGE_URL + "?t=" + System.currentTimeMillis()); logo.setSize("40px", "40px"); logo.setStyleName("ode-Logo"); String logoUrl = ode.getSystemConfig().getLogoUrl(); if (!Strings.isNullOrEmpty(logoUrl)) { logo.addClickHandler(new WindowOpenClickHandler(logoUrl)); }//from w w w . j a v a 2s . c o m panel.add(logo); panel.setCellWidth(logo, "50px"); Label title = new Label("MIT App Inventor 2"); Label version = new Label("Beta"); title.setStyleName("ode-LogoText"); version.setStyleName("ode-LogoVersion"); VerticalPanel titleContainer = new VerticalPanel(); titleContainer.add(title); titleContainer.add(version); titleContainer.setCellHorizontalAlignment(version, HorizontalPanel.ALIGN_RIGHT); panel.add(titleContainer); panel.setCellWidth(titleContainer, "180px"); panel.setCellHorizontalAlignment(logo, HorizontalPanel.ALIGN_LEFT); panel.setCellVerticalAlignment(logo, HorizontalPanel.ALIGN_MIDDLE); }
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 *//* w ww . j a v a2 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 *//*www. j a v a2 s . c o m*/ 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.gerrit.client.account.SshPanel.java
License:Apache License
SshPanel() { final FlowPanel body = new FlowPanel(); showAddKeyBlock = new Button(Util.C.buttonShowAddSshKey()); showAddKeyBlock.addClickHandler(new ClickHandler() { @Override/*w w w . j a v a2s. c om*/ public void onClick(final ClickEvent event) { showAddKeyBlock(true); } }); keys = new SshKeyTable(); body.add(keys); { final FlowPanel fp = new FlowPanel(); deleteKey = new Button(Util.C.buttonDeleteSshKey()); deleteKey.setEnabled(false); deleteKey.addClickHandler(new ClickHandler() { @Override public void onClick(final ClickEvent event) { keys.deleteChecked(); } }); fp.add(deleteKey); fp.add(showAddKeyBlock); body.add(fp); } addKeyBlock = new VerticalPanel(); addKeyBlock.setVisible(false); addKeyBlock.setStyleName(Gerrit.RESOURCES.css().addSshKeyPanel()); addKeyBlock.add(new SmallHeading(Util.C.addSshKeyPanelHeader())); final ComplexDisclosurePanel addSshKeyHelp = new ComplexDisclosurePanel(Util.C.addSshKeyHelpTitle(), false); addSshKeyHelp.setContent(new HTML(Util.C.addSshKeyHelp())); addKeyBlock.add(addSshKeyHelp); addTxt = new NpTextArea(); addTxt.setVisibleLines(12); addTxt.setCharacterWidth(80); addTxt.setSpellCheck(false); addKeyBlock.add(addTxt); final HorizontalPanel buttons = new HorizontalPanel(); addKeyBlock.add(buttons); clearNew = new Button(Util.C.buttonClearSshKeyInput()); clearNew.addClickHandler(new ClickHandler() { @Override public void onClick(final ClickEvent event) { addTxt.setText(""); addTxt.setFocus(true); } }); buttons.add(clearNew); addNew = new Button(Util.C.buttonAddSshKey()); addNew.addClickHandler(new ClickHandler() { @Override public void onClick(final ClickEvent event) { doAddNew(); } }); buttons.add(addNew); closeAddKeyBlock = new Button(Util.C.buttonCloseAddSshKey()); closeAddKeyBlock.addClickHandler(new ClickHandler() { @Override public void onClick(final ClickEvent event) { showAddKeyBlock(false); } }); buttons.add(closeAddKeyBlock); buttons.setCellWidth(closeAddKeyBlock, "100%"); buttons.setCellHorizontalAlignment(closeAddKeyBlock, HasHorizontalAlignment.ALIGN_RIGHT); body.add(addKeyBlock); serverKeys = new FlowPanel(); body.add(serverKeys); initWidget(body); }
From source file:com.google.gwt.sample.hellomaps.client.HelloMaps.java
License:Apache License
private void createMap() { // Set the map up in a Dialog box, just for fun. final DialogBox dialog = new DialogBox(false, false); final Map theMap = new Map(); final Button findButton = new Button("Address:"); final TextBox tb = new TextBox(); tb.addKeyboardListener(new KeyboardListenerAdapter() { @Override/* ww w . jav a 2 s.c om*/ public void onKeyPress(Widget sender, char keyCode, int modifiers) { if (keyCode == KEY_ENTER) { theMap.setLocation(((TextBox) sender).getText()); } else if (keyCode == KEY_ESCAPE) { dialog.removeFromParent(); } } }); findButton.addClickListener(new ClickListener() { public void onClick(Widget sender) { theMap.setLocation(tb.getText()); } }); tb.setWidth("100%"); final HorizontalPanel hp = new HorizontalPanel(); hp.add(findButton); hp.setCellWidth(findButton, "15%"); hp.add(tb); hp.setCellWidth(tb, "85%"); final VerticalPanel vp = new VerticalPanel(); vp.add(hp); vp.add(theMap); dialog.setText("Drag me!"); dialog.setWidget(vp); dialog.center(); }
From source file:com.google.gwt.sample.userwatcher.client.FileUploaderWidget_v2.java
/** * constructor/*w ww . j a va 2s . co m*/ * * @param cp */ public FileUploaderWidget_v2(ClientPersistence cp) { this.cp = cp; HorizontalPanel hp = new HorizontalPanel(); hp.add(pUpload); pUpload.setWidth("100%"); hp.setCellWidth(pUpload, "100%"); hp.setCellHorizontalAlignment(pUpload, HasHorizontalAlignment.ALIGN_CENTER); hp.setCellVerticalAlignment(pUpload, HasVerticalAlignment.ALIGN_MIDDLE); hp.add(bCancel); hp.setCellHorizontalAlignment(bCancel, HasHorizontalAlignment.ALIGN_RIGHT); hp.setCellVerticalAlignment(bCancel, HasVerticalAlignment.ALIGN_MIDDLE); pWidget.add(hp); hp.setWidth("100%"); pWidget.setCellWidth(hp, "100%"); pWidget.add(pFullSize); pWidget.add(pThumb); initWidget(pWidget); pWidget.setWidth("100%"); //pWidget.addStyleName("test2"); //hp.addStyleName("test3"); //pFullSize.addStyleName("test3"); setup(); }
From source file:com.google.gwt.widgetideas.demo.collapsiblepanel.client.CollapsiblePanelDemo.java
License:Apache License
private Panel createSchoolNavBar() { ToggleButton toggler = new ToggleButton("Directory (click to pin)", "Directory (click to collapse)"); toggler.setStyleName("CollapsibleToggle"); controlButton = toggler;/*from w w w.jav a 2s . c om*/ MyStackPanel wrapper = new MyStackPanel(); FlowPanel navBar = new FlowPanel(); navBar.setSize("200px", "100%"); HorizontalPanel panel = new HorizontalPanel(); panel.setWidth("100%"); panel.setCellHorizontalAlignment(controlButton, HasHorizontalAlignment.ALIGN_LEFT); panel.add(controlButton); panel.setCellWidth(controlButton, "1px"); panel.setCellHorizontalAlignment(controlButton, HorizontalPanel.ALIGN_CENTER); navBar.add(panel); panel.setStyleName("nav-Tree-title"); wrapper = new MyStackPanel(); wrapper.setHeight("250px"); final FastTree contents = new FastTree(); wrapper.add(contents, "<b>People</b>", true); wrapper.add(new Label("None"), "<b>Academics</b>", true); navBar.add(wrapper); FastTreeItem students = contents.addItem("Students"); students.addItem("Jill"); students.addItem("Jack"); students.addItem("Molly"); students.addItem("Ms. Muffat"); FastTreeItem teachers = contents.addItem("Teachers"); teachers.addItem("Mrs Black"); teachers.addItem("Mr White"); FastTreeItem admin = contents.addItem("Administrators"); admin.addItem("The Soup Nazi"); admin.addItem("The Grand High Supreme Master Pubba"); return navBar; }
From source file:com.google.lotrepls.client.CommandPrompt.java
License:Apache License
/** * This creates an immutable copy of the prompt and input area suitable for * adding to the page./*w w w .j ava 2s .c om*/ */ public Widget createImmutablePanel() { HorizontalPanel panelCopy = new HorizontalPanel(); Label promptCopy = new Label(prompt.getText()); promptCopy.setStyleName(prompt.getStyleName()); promptCopy.getElement().getStyle().setProperty("width", prompt.getElement().getStyle().getProperty("width")); panelCopy.add(promptCopy); final InterpreterType t = type; final String scriptText = inputArea.getText(); TextArea inputAreaCopy = new TextArea() { { this.addDomHandler(new DoubleClickHandler() { public void onDoubleClick(DoubleClickEvent event) { final DialogBox box = new DialogBox(); VerticalPanel boxPanel = new VerticalPanel(); boxPanel.add(new Label("Use the following URL to share this script with friends:")); String url = buildUrl(t, scriptText); boxPanel.add(new Anchor(trimUrl(url), url)); Button close = new Button("Close"); close.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { box.hide(); } }); close.setStyleName("closeButton"); boxPanel.add(close); box.add(boxPanel); box.getElement().getStyle().setProperty("border", "1px solid"); box.getElement().getStyle().setProperty("borderColor", "green"); box.getElement().getStyle().setProperty("backgroundColor", "black"); box.center(); } }, DoubleClickEvent.getType()); } }; inputAreaCopy.setStyleName(inputArea.getStyleName()); resizeInputArea(true); inputAreaCopy.setText(scriptText); inputAreaCopy.setVisibleLines(inputArea.getVisibleLines()); inputAreaCopy.setReadOnly(true); SimplePanel inputAreaDivCopy = new SimplePanel(); inputAreaDivCopy.add(inputAreaCopy); inputAreaDivCopy.getElement().setAttribute("style", inputAreaDiv.getElement().getAttribute("style")); panelCopy.add(inputAreaDivCopy); panelCopy.setCellWidth(inputAreaDivCopy, "100%"); return panelCopy; }
From source file:com.google.sampling.experiential.client.ExperimentRow.java
License:Open Source License
public ExperimentRow(Images resources, ExperimentDAO experiment, ExperimentListener listener, boolean joined, boolean findView) { this.images = resources; this.myConstants = GWT.create(MyConstants.class); this.experiment = experiment; this.joined = joined; this.findView = findView; this.listeners = new ArrayList<ExperimentListener>(); if (listener != null) { listeners.add(listener);/*from w ww .j a v a 2s . c o m*/ } HorizontalPanel horizontalPanel = new HorizontalPanel(); horizontalPanel.setStyleName("paco-experimentRow"); horizontalPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); horizontalPanel.setSpacing(1); horizontalPanel.setHeight("42px"); initWidget(horizontalPanel); Image experimentIcon = new Image(resources.question()); experimentIcon.setAltText(myConstants.experimentIcon()); horizontalPanel.add(experimentIcon); horizontalPanel.setCellHeight(experimentIcon, "42"); horizontalPanel.setCellWidth(experimentIcon, "42"); horizontalPanel.setCellHorizontalAlignment(experimentIcon, HasHorizontalAlignment.ALIGN_CENTER); horizontalPanel.setCellVerticalAlignment(experimentIcon, HasVerticalAlignment.ALIGN_BOTTOM); experimentIcon.setSize("42px", "42px"); VerticalPanel verticalPanel = new VerticalPanel(); verticalPanel.setHeight("39px"); horizontalPanel.add(verticalPanel); HorizontalPanel horizontalPanel_2 = new HorizontalPanel(); horizontalPanel_2.setHeight("19px"); verticalPanel.add(horizontalPanel_2); Label experimentTitleLabel = new Label(experiment.getTitle()); if (experiment.getDeleted() != null && experiment.getDeleted()) { experimentTitleLabel.setStyleName("gwt-Link-underline-strikethrough"); } else { experimentTitleLabel.setStyleName("gwt-Link-underline"); } horizontalPanel_2.add(experimentTitleLabel); horizontalPanel_2.setCellWidth(experimentTitleLabel, "22px"); horizontalPanel_2.setCellHeight(experimentTitleLabel, "18px"); experimentTitleLabel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); horizontalPanel.setCellVerticalAlignment(experimentTitleLabel, HasVerticalAlignment.ALIGN_MIDDLE); experimentTitleLabel.setWidth("180px"); ClickHandler titleHandler = new ClickHandler() { public void onClick(ClickEvent event) { showExperimentDetails(); } }; if (!isExperimentPurged()) { experimentTitleLabel.addClickHandler(titleHandler); experimentIcon.addClickHandler(titleHandler); } HorizontalPanel horizontalPanel_1 = new HorizontalPanel(); horizontalPanel_1.setSpacing(1); verticalPanel.add(horizontalPanel_1); createButtonPanel(experiment, joined, horizontalPanel, horizontalPanel_1, findView); }
From source file:com.gwttest.client.Demo.java
License:Open Source License
public void onModuleLoad() { final ChartWidget chart = new ChartWidget(); HorizontalPanel hp = new HorizontalPanel(); hp.setSpacing(10);/*w w w . j a va 2s. com*/ VerticalPanel vp = new VerticalPanel(); vp.setSpacing(20); // add home page HTML homeText = new HTML("<h2>Welcome to OFCGWT</h2>" + "<i>....the OpenFlashChart GWT Library</i></br></br>" + "This demonstration site will showcase the many different types of charts that can be inserted into a GWT application."); vp.add(homeText); vp.setCellHeight(homeText, "100"); createPopupDialog(); Button popup = new Button("Show 2nd Chart in Dialog"); popup.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { popupDb.center(); popupDb.show(); } }); vp.add(popup); Button image = new Button("Show Image of Chart"); image.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { ImageServiceAsync imgService = (ImageServiceAsync) GWT.create(ImageService.class); ServiceDefTarget target = (ServiceDefTarget) imgService; target.setServiceEntryPoint(GWT.getHostPageBaseURL() + "ImageService"); imgService.getImageToken(chart.getImageData(), new AsyncCallback<String>() { public void onFailure(Throwable caught) { } public void onSuccess(String result) { createImageDialog(GWT.getHostPageBaseURL() + "image?var=img_" + result); } }); } }); vp.add(image); vp.add(new HTML("Update Speed <i>(0-off, 4-max)</i>")); final SliderBar slider = new SliderBar(0.0, 4.0); slider.setStepSize(1.0); slider.setCurrentValue(1.0); slider.setNumTicks(4); slider.setNumLabels(4); slider.setWidth("100%"); vp.add(slider); hp.add(vp); hp.setCellWidth(vp, "300"); // add chart VerticalPanel vp2 = new VerticalPanel(); DecoratorPanel dp = new DecoratorPanel(); SimplePanel chartPanel = new SimplePanel(); chartPanel.setStylePrimaryName("chartPanel"); chart.setSize("500", "400"); chart.setChartData(getPieChartData()); chartPanel.add(chart); dp.add(chartPanel); vp2.add(dp); vp2.add(new HTML("Chart's JSON data:")); ta = new TextArea(); ta.setWidth("400"); ta.setHeight("100"); ta.setText(chart.getJsonData()); vp2.add(ta); hp.add(vp2); VerticalPanel chartlist = new VerticalPanel(); chartlist.setSpacing(5); Command cmd = new Command() { public void execute() { chart.setChartData(getPieChartData()); ta.setText(chart.getJsonData()); } }; RadioButton rb = createRadioButton("PieChart - No Labels", cmd); updateCmd = cmd; rb.setValue(true); chartlist.add(rb); chartlist.add(createRadioButton("PieChart - Animate", new Command() { public void execute() { chart.setChartData(getAniPieChartData()); ta.setText(chart.getJsonData()); } })); chartlist.add(createRadioButton("BarChart - Transparent", new Command() { public void execute() { chart.setChartData(getBarChartTransparentData()); ta.setText(chart.getJsonData()); } })); chartlist.add(createRadioButton("BarChart - Glass", new Command() { public void execute() { chart.setChartData(getBarChartGlassData()); ta.setText(chart.getJsonData()); } })); chartlist.add(createRadioButton("3DBarChart + Line", new Command() { public void execute() { chart.setChartData(get3DBarLineChartData()); ta.setText(chart.getJsonData()); } })); chartlist.add(createRadioButton("CylinderChart", new Command() { public void execute() { chart.setChartData(getCylinderChartData()); ta.setText(chart.getJsonData()); } })); chartlist.add(createRadioButton("CylinderChart - RoundGlass", new Command() { public void execute() { chart.setChartData(getCylinderChartGlassData()); ta.setText(chart.getJsonData()); } })); chartlist.add(createRadioButton("LineChart - 3 Dot Types", new Command() { public void execute() { chart.setChartData(getLineChartData()); ta.setText(chart.getJsonData()); } })); chartlist.add(createRadioButton("ScatterChart - Star Dot", new Command() { public void execute() { chart.setChartData(getScatterPointChartData()); ta.setText(chart.getJsonData()); } })); chartlist.add(createRadioButton("ScatterChart - Line", new Command() { public void execute() { chart.setChartData(getScatterLineChartData()); ta.setText(chart.getJsonData()); } })); chartlist.add(createRadioButton("RadarChart", new Command() { public void execute() { chart.setChartData(getRadarChartData()); ta.setText(chart.getJsonData()); } })); chartlist.add(createRadioButton("Horizontal-BarChart", new Command() { public void execute() { chart.setChartData(getHorizBarChartData()); ta.setText(chart.getJsonData()); } })); chartlist.add(createRadioButton("AreaChart - Hollow", new Command() { public void execute() { chart.setChartData(getAreaHollowChartData()); ta.setText(chart.getJsonData()); } })); chartlist.add(createRadioButton("AreaChart - Line", new Command() { public void execute() { chart.setChartData(getAreaLineChartData()); ta.setText(chart.getJsonData()); } })); chartlist.add(createRadioButton("SketchChart", new Command() { public void execute() { chart.setChartData(getSketchChartData()); ta.setText(chart.getJsonData()); } })); chartlist.add(createRadioButton("StackChart", new Command() { public void execute() { chart.setChartData(getStackChartData()); ta.setText(chart.getJsonData()); } })); chartlist.add(createRadioButton("HorizontalStackChart", new Command() { public void execute() { chart.setChartData(getHorizontalStackChartData()); ta.setText(chart.getJsonData()); } })); hp.add(chartlist); hp.setCellWidth(chartlist, "300"); RootPanel.get().add(hp); final Timer updater = new Timer() { public void run() { updateCmd.execute(); } }; updater.scheduleRepeating(3000); slider.addChangeListener(new ChangeListener() { public void onChange(Widget sender) { switch ((int) (slider.getCurrentValue())) { case 0: updater.cancel(); break; case 1: updater.scheduleRepeating(3000); break; case 2: updater.scheduleRepeating(1000); break; case 3: updater.scheduleRepeating(200); break; case 4: updater.scheduleRepeating(50); break; } } }); }