Example usage for com.google.gwt.user.client.ui HorizontalPanel setSpacing

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

Introduction

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

Prototype

public void setSpacing(int spacing) 

Source Link

Document

Sets the amount of spacing between this panel's cells.

Usage

From source file:com.ephesoft.gxt.rv.client.widget.ThumbnailWidgetPanel.java

License:Open Source License

@Override
protected Widget createWidget() {
    if (null != document) {
        final List<String> thumbnailNamesList = BatchSchemaUtil.getThumbnails(document);
        List<Image> thumbnailImages = null;
        Image thumbnailImage = new Image();
        if (!CollectionUtil.isEmpty(thumbnailNamesList)) {
            thumbnailImages = new ArrayList<Image>();
            for (final String thumbnailName : thumbnailNamesList) {
                thumbnailImage = new Image(ReviewValidateNavigator.getAbsoluteURL(thumbnailName));
                thumbnailImages.add(thumbnailImage);
            }//from   w w  w  .j a  va2  s .  c  o m
        }
        panel = new VerticalPanel();
        panel.addStyleName("documentStack");
        documentNameLabel = new Label(getDocumentTypeDisplayText(document));
        documentNameLabel = new Label(document.getType());
        final HorizontalPanel horizontalPanel = new HorizontalPanel();
        horizontalPanel.setSpacing(5);
        documentNameLabel.addStyleName("highlightedLabel");
        horizontalPanel.add(new Label(docIdentifier));
        horizontalPanel.add(documentNameLabel);
        final ThumbnailStack thumbnailStack = new ThumbnailStack(thumbnailImages);
        panel.add(horizontalPanel);
        panel.add(thumbnailStack);
    }
    return panel;
}

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 av  a2s .c  om
 * @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);
    hpanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    hpanel.add(leftWidget);/*  w  w w  .j  a  va 2 s.  c o m*/
    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//w w  w.  j a  v  a2  s  . c o  m
 * @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.google.appinventor.client.explorer.SourceStructureExplorer.java

License:Open Source License

/**
 * Creates a new source structure explorer.
 *///  www . j a  v a 2  s  . c om
public SourceStructureExplorer() {
    // Initialize UI elements
    tree = new Tree(Ode.getImageBundle());
    tree.setAnimationEnabled(true);
    tree.addCloseHandler(new CloseHandler<TreeItem>() {
        @Override
        public void onClose(CloseEvent<TreeItem> event) {
            TreeItem treeItem = event.getTarget();
            if (treeItem != null) {
                Object userObject = treeItem.getUserObject();
                if (userObject instanceof SourceStructureExplorerItem) {
                    SourceStructureExplorerItem item = (SourceStructureExplorerItem) userObject;
                    item.onStateChange(false);
                }
            }
        }
    });
    tree.addOpenHandler(new OpenHandler<TreeItem>() {
        @Override
        public void onOpen(OpenEvent<TreeItem> event) {
            TreeItem treeItem = event.getTarget();
            if (treeItem != null) {
                Object userObject = treeItem.getUserObject();
                if (userObject instanceof SourceStructureExplorerItem) {
                    SourceStructureExplorerItem item = (SourceStructureExplorerItem) userObject;
                    item.onStateChange(true);
                }
            }
        }
    });
    tree.addSelectionHandler(new SelectionHandler<TreeItem>() {
        @Override
        public void onSelection(SelectionEvent<TreeItem> event) {
            TreeItem treeItem = event.getSelectedItem();
            if (treeItem != null) {
                Object userObject = treeItem.getUserObject();
                if (userObject instanceof SourceStructureExplorerItem) {
                    SourceStructureExplorerItem item = (SourceStructureExplorerItem) userObject;
                    enableButtons(item);
                    //showBlocks(item);
                    item.onSelected();
                } else {
                    disableButtons();
                    //hideComponent();
                }
            } else {
                disableButtons();
            }
        }
    });
    tree.addKeyDownHandler(new KeyDownHandler() {
        @Override
        public void onKeyDown(KeyDownEvent event) {
            int keyCode = event.getNativeKeyCode();
            if (keyCode == KeyCodes.KEY_DELETE || keyCode == KeyCodes.KEY_BACKSPACE) {
                event.preventDefault();
                deleteItemFromTree();
            }
        }
    });

    // Put a ScrollPanel around the tree.
    ScrollPanel scrollPanel = new ScrollPanel(tree);
    scrollPanel.setWidth("200px"); // wide enough to avoid a horizontal scrollbar most of the time
    scrollPanel.setHeight("480px"); // approximately the same height as the viewer

    HorizontalPanel buttonPanel = new HorizontalPanel();
    buttonPanel.setStyleName("ode-PanelButtons");
    buttonPanel.setSpacing(4);

    renameButton = new TextButton(MESSAGES.renameButton());
    renameButton.setEnabled(false);
    renameButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            TreeItem treeItem = tree.getSelectedItem();
            if (treeItem != null) {
                Object userObject = treeItem.getUserObject();
                if (userObject instanceof SourceStructureExplorerItem) {
                    SourceStructureExplorerItem item = (SourceStructureExplorerItem) userObject;
                    item.rename();
                }
            }
        }
    });
    buttonPanel.add(renameButton);
    buttonPanel.setCellHorizontalAlignment(renameButton, HorizontalPanel.ALIGN_RIGHT);

    deleteButton = new TextButton(MESSAGES.deleteButton());
    deleteButton.setEnabled(false);
    deleteButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            deleteItemFromTree();
        }
    });
    buttonPanel.add(deleteButton);
    buttonPanel.setCellHorizontalAlignment(deleteButton, HorizontalPanel.ALIGN_LEFT);

    VerticalPanel panel = new VerticalPanel();
    panel.add(scrollPanel);
    panel.add(new Label());
    panel.add(buttonPanel);
    panel.setCellHorizontalAlignment(buttonPanel, HorizontalPanel.ALIGN_CENTER);
    initWidget(panel);
}

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);
    RootPanel.get("demo").add(hpanel);

    hpanel.add(createManagedResourceStoreButton);

    // See if we're already running from a ManagedResourceStore
    try {/*  ww  w. ja v  a2  s  . c  o m*/
        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);
    RootPanel.get("demo").add(hpanel);

    hpanel.add(createManagedResourceStoreButton);

    // See if we're already running from a ManagedResourceStore
    try {//w  ww . java  2  s .c o m
        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.workerpool.client.AnimationToy.java

License:Apache License

/**
 * Create an options panel that allows users to select a widget and reposition
 * it./*from  w  w  w  . ja 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./*  w w  w  .j  a v  a2s.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.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.gwtai.demo.client.CounterAppletTab.java

License:Apache License

public CounterAppletTab() {
    VerticalPanel panelMain = new VerticalPanel();
    panelMain.setWidth("100%");
    panelMain.setSpacing(4);//from  ww  w . java2s .c o m

    Button buttonInc = new Button("Increment");
    Button buttonDec = new Button("Decrement");
    Button buttonGet = new Button("Get current count");

    final CounterApplet counterApplet = (CounterApplet) GWT.create(CounterApplet.class);

    buttonInc.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            counterApplet.increment();
        }
    });

    buttonDec.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            counterApplet.decrement();
        }
    });

    buttonGet.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            Object value = counterApplet.getCurrentValue();

            DialogBox dialogBox = createDialogBox(value);
            dialogBox.center();
            dialogBox.show();
        }
    });

    HorizontalPanel buttonPanel = new HorizontalPanel();
    buttonPanel.setSpacing(4);
    buttonPanel.add(buttonInc);
    buttonPanel.add(buttonDec);
    buttonPanel.add(buttonGet);

    Widget widgetApplet = AppletJSUtil.createAppletWidget(counterApplet);
    Label labelTitle = new Label(
            "To call a method on an applet object from within your GWT code - a piece of cake!");
    DisclosurePanel panelCode = new DisclosurePanel("View code");
    panelCode.setWidth("100%");
    panelCode.setAnimationEnabled(true);
    panelCode.setContent(createCodeHTML());

    panelMain.add(labelTitle);
    panelMain.add(widgetApplet);
    panelMain.add(buttonPanel);
    panelMain.add(panelCode);

    panelMain.setCellHorizontalAlignment(labelTitle, VerticalPanel.ALIGN_CENTER);
    panelMain.setCellHorizontalAlignment(widgetApplet, VerticalPanel.ALIGN_CENTER);
    panelMain.setCellHorizontalAlignment(buttonPanel, VerticalPanel.ALIGN_CENTER);

    initWidget(panelMain);
}