List of usage examples for com.google.gwt.user.client.ui HorizontalPanel HorizontalPanel
public HorizontalPanel()
From source file:com.github.gwtbootstrap.client.ui.SimplePager.java
License:Apache License
/** * Construct a {@link SimplePager} with the specified resources. * * @param location// w w w . j a v a 2 s . co m * the location of the text relative to the buttons * @param resources * the {@link Resources} to use * @param showFastForwardButton * if true, show a fast-forward button that advances by a larger * increment than a single page * @param fastForwardRows * the number of rows to jump when fast forwarding * @param showLastPageButton * if true, show a button to go the the last page * @param imageButtonConstants * Constants that contain the image button names */ public SimplePager(TextLocation location, Resources resources, boolean showFastForwardButton, final int fastForwardRows, boolean showLastPageButton, ImageButtonsConstants imageButtonConstants) { this.resources = resources; this.fastForwardRows = fastForwardRows; this.style = this.resources.simplePagerStyle(); this.style.ensureInjected(); // Create the buttons. firstPage = new Button(); firstPage.setType(ButtonType.LINK); firstPage.setIcon(IconType.FAST_BACKWARD); firstPage.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { firstPage(); } }); firstPageTooltip = new Tooltip(imageButtonConstants.firstPage()); firstPageTooltip.setWidget(firstPage); firstPageTooltip.setPlacement(tooltipPlacement); firstPageTooltip.setShowDelay(tooltipDelay); nextPage = new Button(); nextPage.setType(ButtonType.LINK); nextPage.setIcon(IconType.STEP_FORWARD); nextPage.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { nextPage(); } }); nextPageTooltip = new Tooltip(imageButtonConstants.nextPage()); nextPageTooltip.setWidget(nextPage); nextPageTooltip.setPlacement(tooltipPlacement); nextPageTooltip.setShowDelay(tooltipDelay); prevPage = new Button(); prevPage.setType(ButtonType.LINK); prevPage.setIcon(IconType.STEP_BACKWARD); prevPage.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { previousPage(); } }); prevPageTooltip = new Tooltip(imageButtonConstants.prevPage()); prevPageTooltip.setWidget(prevPage); prevPageTooltip.setPlacement(tooltipPlacement); prevPageTooltip.setShowDelay(tooltipDelay); if (showLastPageButton) { lastPage = new Button(); lastPage.setType(ButtonType.LINK); lastPage.setIcon(IconType.FAST_FORWARD); lastPage.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { lastPage(); } }); lastPageTooltip = new Tooltip(imageButtonConstants.lastPage()); lastPageTooltip.setWidget(lastPage); lastPageTooltip.setPlacement(tooltipPlacement); lastPageTooltip.setShowDelay(tooltipDelay); } else { lastPage = null; lastPageTooltip = null; } if (showFastForwardButton) { fastForward = new Button(); fastForward.setType(ButtonType.LINK); fastForward.setIcon(IconType.FORWARD); fastForward.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { setPage(getPage() + getFastForwardPages()); } }); fastForwardTooltip = new Tooltip(imageButtonConstants.fastForward()); fastForwardTooltip.setWidget(fastForward); fastForwardTooltip.setPlacement(tooltipPlacement); fastForwardTooltip.setShowDelay(tooltipDelay); } else { fastForward = null; fastForwardTooltip = null; } // Construct the widget. HorizontalPanel layout = new HorizontalPanel(); layout.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); initWidget(layout); if (location == TextLocation.LEFT) { layout.add(label); } layout.add(firstPage); layout.add(prevPage); if (location == TextLocation.CENTER) { layout.add(label); } layout.add(nextPage); if (showFastForwardButton) { layout.add(fastForward); } if (showLastPageButton) { layout.add(lastPage); } layout.add(firstPageTooltip); layout.add(prevPageTooltip); layout.add(nextPageTooltip); if (showFastForwardButton) { layout.add(fastForwardTooltip); } if (showLastPageButton) { layout.add(lastPageTooltip); } if (location == TextLocation.RIGHT) { layout.add(label); } // Add style names to the cells. firstPage.getElement().getParentElement().addClassName(style.button()); prevPage.getElement().getParentElement().addClassName(style.button()); label.getElement().getParentElement().addClassName(style.pageDetails()); nextPage.getElement().getParentElement().addClassName(style.button()); if (showFastForwardButton) { fastForward.getElement().getParentElement().addClassName(style.button()); } if (showLastPageButton) { lastPage.getElement().getParentElement().addClassName(style.button()); } // Disable the buttons by default. setDisplay(null); }
From source file:com.gmail.cjbooms.thesis.pythonappengine.client.filebrowser.TreeItemWidget.java
License:Open Source License
/** * Create a new Tree Widget that has a file icon and caption * @param fileType/*from ww w .j ava 2 s . c o m*/ * @param caption */ public TreeItemWidget(FileType fileType, String caption) { resources = GWT.create(MyResources.class); treeItemPanel = new HorizontalPanel(); treeItemPanel.setSpacing(2); Image icon = getIconForFileType(fileType); treeItemPanel.add(icon); treeItemPanel.add(new HTML(caption)); initWidget(treeItemPanel); }
From source file:com.gmail.cjbooms.thesis.pythonappengine.client.menus.AbstractMenuDialog.java
License:Open Source License
/** * Add two widgets to a horizontal panel * @param leftWidget// ww w. j a v a 2 s .co m * @param rightWidget * @return the horizontal panel containing both widgets */ protected HorizontalPanel createHorizontalHolder(Widget leftWidget, Widget rightWidget) { HorizontalPanel hpanel = new HorizontalPanel(); hpanel.setSpacing(10); hpanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); hpanel.add(leftWidget); hpanel.add(rightWidget); return hpanel; }
From source file:com.gmail.cjbooms.thesis.pythonappengine.client.menus.DeleteProjectDialogWidget.java
License:Open Source License
private HorizontalPanel createHorizontalHolder(Widget leftWidget, Widget rightWidget) { HorizontalPanel hpanel = new HorizontalPanel(); hpanel.setSpacing(10);/* w w w . j av a2s.c o m*/ hpanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); hpanel.add(leftWidget); hpanel.add(rightWidget); return hpanel; }
From source file:com.gmail.cjbooms.thesis.pythonappengine.client.menus.git.GitCommitLocalChangesDialogWidget.java
License:Open Source License
/** * Helper Method to add two widgets to a horizontal panel * TODO Refactor To Utility Class// ww w .ja va2s .com * @param leftWidget * @param rightWidget * @return */ private HorizontalPanel createHorizontalHolder(Widget leftWidget, Widget rightWidget) { HorizontalPanel hpanel = new HorizontalPanel(); hpanel.setSpacing(10); hpanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); hpanel.add(leftWidget); hpanel.add(rightWidget); return hpanel; }
From source file:com.gmail.cjbooms.thesis.pythonappengine.client.menus.Toolbar.java
License:Open Source License
/** * Constructs a Toolbar part./*from w w w . j av a 2 s.c o m*/ */ public Toolbar() { resources = GWT.create(MyResources.class); buttons = new ArrayList<Widget>(); toolBar = new HorizontalPanel(); toolBar.setHeight("30px"); toolBar.setWidth("100%"); toolBar.setStylePrimaryName("lab-Tools-Panel"); toolBar.add(buildToolBar()); initWidget(toolBar); }
From source file:com.gmail.cjbooms.thesis.pythonappengine.client.menus.Toolbar.java
License:Open Source License
/** * Builds the main toolbar.//w ww . j a va2s. c o m * * @return the main toolbar */ private HorizontalPanel buildToolBar() { HorizontalPanel toolbarPanel = new HorizontalPanel(); toolbarPanel.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE); toolbarPanel.setStyleName("lab-Toolbar"); toolbarPanel.add(buildButton(resources.blankFile(), "New Project", new CreateNewProjectDialogWidget().openDialogForNewProjectCommand())); toolbarPanel.add(buildButton(resources.openIcon(), "Open Project", createBlankCommand())); toolbarPanel.add(buildButton(resources.saveIcon(), "Save Project", createBlankCommand())); toolbarPanel.add(buildSeparator()); toolbarPanel.add(buildButton(resources.refreshIcon(), "Refresh", createBlankCommand())); toolbarPanel.add(buildSeparator()); toolbarPanel.add(buildButton(resources.copyIcon(), "Clone Project", (new GitCloneDialogWidget().openDialogForGITCloneCommand()))); toolbarPanel.add(buildSeparator()); toolbarPanel .add(buildButton(resources.uploadIcon(), "Deploy Project", (new DeployDialog().openMenuDialog()))); return toolbarPanel; }
From source file:com.google.appinventor.client.editor.blocks.BlocklyPanel.java
License:Open Source License
/** * Create a Dialog Box. We call this from Javascript (blockly) to * display a dialog box. We do this here because we can get calls * from the blocklyframe when it is not visible. Because we are in * the parent window, we can display dialogs that will be visible * even when the blocklyframe is not visible. * * @param title Title for the Dialog Box * @param mess The message to display * @param buttonName The string to display in the "OK" button. * @param size 0 or 1. 0 makes a smaller box 1 makes a larger box. * @param callback an opague JavaScriptObject that contains the * callback function provided by the Javascript code. * @return The created dialog box.// w w w . j a v a 2 s . co m */ public static DialogBox createDialog(String title, String mess, final String buttonName, final String cancelButtonName, int size, final JavaScriptObject callback) { final DialogBox dialogBox = new DialogBox(); dialogBox.setStylePrimaryName("ode-DialogBox"); dialogBox.setText(title); if (size == 0) { dialogBox.setHeight("150px"); } else { dialogBox.setHeight("400px"); } dialogBox.setWidth("400px"); dialogBox.setGlassEnabled(true); dialogBox.setAnimationEnabled(true); dialogBox.center(); VerticalPanel DialogBoxContents = new VerticalPanel(); HTML message = new HTML(mess); HorizontalPanel holder = new HorizontalPanel(); if (buttonName != null) { // If buttonName and cancelButtonName are null Button ok = new Button(buttonName); // We won't have any buttons and other ok.addClickHandler(new ClickHandler() { // code is needed to dismiss us @Override public void onClick(ClickEvent event) { doCallBack(callback, buttonName); } }); holder.add(ok); } if (cancelButtonName != null) { Button cancel = new Button(cancelButtonName); cancel.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { doCallBack(callback, cancelButtonName); } }); holder.add(cancel); } DialogBoxContents.add(message); DialogBoxContents.add(holder); dialogBox.setWidget(DialogBoxContents); terminateDrag(); // cancel a drag before showing the modal dialog dialogBox.show(); return dialogBox; }
From source file:com.google.appinventor.client.editor.simple.palette.SimplePaletteItem.java
License:Open Source License
/** * Creates a new palette item.//from w ww .j a v a 2s.c o m * * @param scd component descriptor for palette item * @param dropTargetProvider provider of targets that palette items can be dropped on */ public SimplePaletteItem(SimpleComponentDescriptor scd, DropTargetProvider dropTargetProvider) { this.dropTargetProvider = dropTargetProvider; this.scd = scd; componentPrototype = null; // Initialize palette item UI HorizontalPanel panel = new HorizontalPanel(); panel.setStylePrimaryName("ode-SimplePaletteItem"); Image image = scd.getImage(); image.setStylePrimaryName("ode-SimplePaletteItem-icon"); panel.add(image); panel.setCellHorizontalAlignment(image, HorizontalPanel.ALIGN_LEFT); panel.setCellWidth(image, "30px"); Label label = new Label(TranslationDesignerPallete.getCorrespondingString(scd.getName())); label.setHorizontalAlignment(Label.ALIGN_LEFT); label.addStyleName("ode-SimplePaletteItem-caption"); panel.add(label); HorizontalPanel optPanel = new HorizontalPanel(); ComponentHelpWidget helpImage = new ComponentHelpWidget(scd); helpImage.addStyleName("ode-SimplePalleteItem-button"); optPanel.add(helpImage); optPanel.setCellHorizontalAlignment(helpImage, HorizontalPanel.ALIGN_LEFT); if (scd.getExternal()) { ComponentRemoveWidget deleteImage = new ComponentRemoveWidget(scd); deleteImage.addStyleName("ode-SimplePalleteItem-button"); optPanel.add(deleteImage); optPanel.setCellHorizontalAlignment(deleteImage, HorizontalPanel.ALIGN_RIGHT); } panel.add(optPanel); panel.setCellHorizontalAlignment(optPanel, HorizontalPanel.ALIGN_RIGHT); panel.setWidth("100%"); add(panel); setWidth("100%"); }
From source file:com.google.appinventor.client.editor.youngandroid.BlocklyPanel.java
License:Open Source License
/** * Create a Dialog Box. We call this from Javascript (blockly) to * display a dialog box. We do this here because we can get calls * from the blocklyframe when it is not visible. Because we are in * the parent window, we can display dialogs that will be visible * even when the blocklyframe is not visible. * * @param title Title for the Dialog Box * @param mess The message to display * @param buttonName The string to display in the "OK" button. * @param size 0 or 1. 0 makes a smaller box 1 makes a larger box. * @param callback an opague JavaScriptObject that contains the * callback function provided by the Javascript code. * @return The created dialog box./*from w w w. ja va 2 s . c o m*/ */ public static DialogBox createDialog(String title, String mess, final String buttonName, final String cancelButtonName, int size, final JavaScriptObject callback) { final DialogBox dialogBox = new DialogBox(); dialogBox.setStylePrimaryName("ode-DialogBox"); dialogBox.setText(title); if (size == 0) { dialogBox.setHeight("150px"); } else { dialogBox.setHeight("400px"); } dialogBox.setWidth("400px"); dialogBox.setGlassEnabled(true); dialogBox.setAnimationEnabled(true); dialogBox.center(); VerticalPanel DialogBoxContents = new VerticalPanel(); HTML message = new HTML(mess); message.setStyleName("DialogBox-message"); HorizontalPanel holder = new HorizontalPanel(); if (buttonName != null) { // If buttonName and cancelButtonName are null Button ok = new Button(buttonName); // We won't have any buttons and other ok.addClickListener(new ClickListener() { // code is needed to dismiss us public void onClick(Widget sender) { doCallBack(callback, buttonName); } }); holder.add(ok); } if (cancelButtonName != null) { Button cancel = new Button(cancelButtonName); cancel.addClickListener(new ClickListener() { public void onClick(Widget sender) { doCallBack(callback, cancelButtonName); } }); holder.add(cancel); } DialogBoxContents.add(message); DialogBoxContents.add(holder); dialogBox.setWidget(DialogBoxContents); dialogBox.show(); return dialogBox; }