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.square.composants.graphiques.lib.client.composants.BlocSyntheseDepliant.java

License:Open Source License

/**
 * Constructeur./*from ww  w. j a va2 s  . c o  m*/
 * @param listeChamps .
 * @param header .
 * @param contenu .
 * @param nbChampParLigne .
 */
public BlocSyntheseDepliant(List<ChampSynthese> listeChamps, Widget header, Widget contenu,
        final int nbChampParLigne) {
    this.listeChamps = listeChamps;
    this.nbChampParLigne = nbChampParLigne;
    disclosurePanel = new CustomDisclosurePanel();
    disclosurePanel.setAnimationEnabled(true);
    disclosurePanel.addOpenHandler(this);
    disclosurePanel.addCloseHandler(this);
    disclosurePanel.addStyleName(SquareLibResources.INSTANCE.css().blocSyntheseDepliant());
    disclosurePanel.setWidth(ComposantsGraphiquesConstants.POURCENT_100);

    final SimplePanel conteneurContenu = new SimplePanel();
    conteneurContenu.add(contenu);

    icone = new Image(SquareLibResources.INSTANCE.expand());
    icone.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            disclosurePanel.setOpen(!disclosurePanel.isOpen());
        }
    });

    nbLigne = (int) Math.ceil((double) listeChamps.size() / nbChampParLigne);
    resumePanel = new Grid(nbLigne, nbChampParLigne);
    resumePanel.setWidth(ComposantsGraphiquesConstants.POURCENT_100);
    int index = 0;
    for (int row = 0; row < resumePanel.getRowCount(); row++) {
        for (int column = 0; column < resumePanel.getColumnCount() && (index < listeChamps.size()); column++) {
            final ChampSynthese champ = listeChamps.get(index++);
            resumePanel.setWidget(row, column, champ);
            addOpenEventHandler(champ);
            addCloseEventHandler(champ);
        }
    }

    final HorizontalPanel conteneurEntete = new HorizontalPanel();
    conteneurEntete.setSpacing(5);
    conteneurEntete.setWidth(ComposantsGraphiquesConstants.POURCENT_100);
    conteneurEntete.add(resumePanel);
    if (header != null) {
        conteneurEntete.add(header);
        conteneurEntete.setCellHorizontalAlignment(header, HasAlignment.ALIGN_RIGHT);
    }
    conteneurEntete.add(icone);
    conteneurEntete.setCellHorizontalAlignment(icone, HasAlignment.ALIGN_RIGHT);
    conteneurEntete.setCellVerticalAlignment(resumePanel, HasAlignment.ALIGN_MIDDLE);
    conteneurEntete.setCellVerticalAlignment(icone, HasAlignment.ALIGN_MIDDLE);

    conteneurEnteteFocus = new FocusPanel();
    conteneurEnteteFocus.setWidth(ComposantsGraphiquesConstants.POURCENT_100);
    conteneurEnteteFocus.add(conteneurEntete);

    disclosurePanel.setHeader(conteneurEnteteFocus);
    disclosurePanel.setContent(conteneurContenu);

    initWidget(disclosurePanel);
}

From source file:com.square.composants.graphiques.lib.client.composants.ChampSynthese.java

License:Open Source License

/** Construction du composant. */
private void construireWidget() {
    final HorizontalPanel bloc = new HorizontalPanel();
    bloc.setSpacing(3);
    bloc.setStyleName("enteteChamp");

    if (this.champ != null && champ instanceof CheckBox) {
        bloc.add(this.champ);
        if (!"".equals(this.label.getText())) {
            bloc.add(this.label);
            if (this.labelOuverture != null) {
                bloc.add(this.labelOuverture);
                labelOuverture.setVisible(false);
            }/*from   w ww .  j a  va 2 s.c  om*/
        }
        bloc.setCellVerticalAlignment(this.champ, HasAlignment.ALIGN_MIDDLE);
    } else {
        if (!"".equals(this.label.getText())) {
            bloc.add(this.label);
            if (this.labelOuverture != null) {
                bloc.add(this.labelOuverture);
                labelOuverture.setVisible(false);
            }
        }
    }

    bloc.add(this.champLectureSeule);

    if (this.champ != null && !(champ instanceof CheckBox)) {
        bloc.add(this.champ);
        bloc.setCellVerticalAlignment(this.champ, HasAlignment.ALIGN_MIDDLE);
    }

    if (this.icone != null) {
        bloc.add(icone);
        icone.setVisible(false);
        bloc.setCellVerticalAlignment(icone, HasAlignment.ALIGN_MIDDLE);
    }

    if (this.aide != null) {
        bloc.add(aide);
        aide.setVisible(false);
        bloc.setCellVerticalAlignment(aide, HasAlignment.ALIGN_MIDDLE);
    }

    bloc.setCellVerticalAlignment(this.label, HasAlignment.ALIGN_MIDDLE);
    if (this.labelOuverture != null) {
        bloc.setCellVerticalAlignment(this.labelOuverture, HasAlignment.ALIGN_MIDDLE);
    }
    bloc.setCellVerticalAlignment(this.champLectureSeule, HasAlignment.ALIGN_MIDDLE);
    bloc.setVisible(!afficherChampDepliement);
    this.initWidget(bloc);
}

From source file:com.sun.labs.aura.dbbrowser.client.viz.Util.java

License:Open Source License

public static HorizontalPanel getHisto(String name, int value, int maxValue, int maxWidth, String text) {

    int leftWidth = Math.round(((float) value / (float) maxValue) * (float) maxWidth);
    if (leftWidth < 1) {
        leftWidth = 1;//from   w w w . j a v  a  2  s.  co  m
    } else if (leftWidth > maxWidth) {
        leftWidth = maxWidth;
    }
    int rightWidth = maxWidth - leftWidth;
    boolean alert = false;
    if (value / (float) maxValue > 0.75) {
        alert = true;
    }

    HorizontalPanel all = new HorizontalPanel();
    all.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);
    all.add(new StyleLabel(name + ":", "viz-histoName"));

    HorizontalPanel table = new HorizontalPanel();
    table.setWidth(maxWidth + "px");
    table.setBorderWidth(0);
    table.setSpacing(0);

    Widget left = new Label("");
    if (alert) {
        left.setStyleName("viz-histoLeftAlert");
    } else {
        left.setStyleName("viz-histoLeft");
    }
    left.setWidth(leftWidth + "");
    left.setHeight("10px");
    left.getElement().getStyle().setPropertyPx("fontSize", 6);

    Widget right = new Label("");
    if (alert) {
        right.setStyleName("viz-histoRightAlert");
    } else {
        right.setStyleName("viz-histoRight");
    }
    right.setWidth(rightWidth + "");
    right.setHeight("10px");
    right.getElement().getStyle().setPropertyPx("fontSize", 6);

    table.add(left);
    table.add(right);
    all.add(table);
    all.add(new StyleLabel(text, "viz-histoText"));
    return all;
}

From source file:com.sun.labs.aura.music.wsitm.client.Main.java

License:Open Source License

Widget getMainPanel() {
    DockPanel mainPanel = new DockPanel();
    mainPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
    mainPanel.setWidth("95%");

    ArrayList<MenuItem> menuItems = new ArrayList<MenuItem>();

    contentPanel = new FlowPanel();

    Swidget serverInfo = new ServerInfoSwidget(cdm);
    registerTokenHeaders(serverInfo);//from   w w  w  .  j a  v a 2s  . c o m
    cdm.registerSwidget(serverInfo);

    Swidget userPref = new ProfileSwidget(cdm);
    registerTokenHeaders(userPref);
    cdm.registerSwidget(userPref);

    Swidget dashboard = new DashboardSwidget(cdm);
    registerTokenHeaders(dashboard);
    cdm.registerSwidget(dashboard);
    menuItems.add(dashboard.getMenuItem());

    Swidget steeringRec = new SteeringSwidget(cdm);
    registerTokenHeaders(steeringRec);
    cdm.registerSwidget(steeringRec);
    menuItems.add(steeringRec.getMenuItem());

    Swidget artistSearch = new SimpleSearchSwidget(cdm);
    registerTokenHeaders(artistSearch);
    menuItems.add(artistSearch.getMenuItem());

    PageHeaderWidget uP = new PageHeaderWidget(cdm);
    cdm.registerSwidget(uP);
    cdm.setWidgets(uP);

    Swidget homePage = new HomeSwidget(cdm);
    registerTokenHeaders(homePage);

    mainPanel.add(uP, DockPanel.NORTH);
    mainPanel.add(contentPanel, DockPanel.CENTER);

    uP.setMenuItems(menuItems);

    VerticalPanel footer = new VerticalPanel();
    footer.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);

    String disclaimers = "<a href=\"http://www.sun.com/privacy/\">Privacy</a> | "
            + "<a href=\"http://www.sun.com/termsofuse.html\">Terms of Use</a> | "
            + "<a href=\"http://www.sun.com/suntrademarks/\"> Trademarks</a> | "
            + "<a href=\"http://www.tastekeeper.com\"> More Info</a> | "
            + "<a href=\"mailto:explaura@sun.com\">Contact Us</a>";

    footer.add(new HTML(
            "<br/><hr/><center><div class=\"bottomUrl\">Powered by <a href=\"http://www.sun.com\">Sun Microsystems</a>, "
                    + "<a href=\"http://www.last.fm\">Last.fm</a>, <a href=\"http://www.spotify.com\">Spotify</a>, "
                    + "<a href=\"http://www.wikipedia.org\">Wikipedia</a>, <a href=\"http://www.flickr.com\">Flickr</a>, "
                    + "<a href=\"http://www.youtube.com\">Youtube</a>, <a href=\"http://www.yahoo.com\">Yahoo</a>, "
                    + "<a href=\"http://musicbrainz.org\">Musicbrainz</a>, <a href=\"http://upcoming.yahoo.com\">Upcoming</a>, "
                    + "<a href=\"http://the.echonest.com\">The Echo Nest</a> and <a href=\"http://www.amazon.com\">Amazon</a><br/>"
                    + disclaimers + "<br/>" + "</div></center>"));

    // if performance monitoring is enabled, add a button to the footer
    // that will show us the stats
    if (PerformanceTimer.isEnabled()) {

        HorizontalPanel hP = new HorizontalPanel();
        hP.setSpacing(5);

        // Add the server info link
        SpannedLabel perfmon = new SpannedLabel("PerfMon");
        perfmon.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent ce) {
                PerformanceTimer.showPopup();
            }
        });
        hP.add(perfmon);

        // Add the server info link
        SpannedLabel sI = new SpannedLabel("ServerInfo");
        sI.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent ce) {
                History.newItem("serverinfo:");
            }
        });
        hP.add(sI);

        footer.add(hP);

    }
    //
    // Hack to allow opening the spotify link while preventing losing the GWT state
    footer.add(new HTML("<iframe name=\"spotifyFrame\" height=\"0px\" frameborder=\"0\" />"));
    footer.setStyleName("footer");

    mainPanel.add(footer, DockPanel.SOUTH);
    mainPanel.setStyleName("main");
    return mainPanel;
}

From source file:com.sun.labs.aura.music.wsitm.client.ui.HelpPopup.java

License:Open Source License

private Widget buildSectionSteering() {

    HorizontalPanel hP = new HorizontalPanel();
    hP.setSpacing(8);
    hP.add(new Image("help-steer.png"));

    VerticalPanel vP = new VerticalPanel();
    vP.setWidth("300px");
    vP.setStyleName("helpTxt");
    vP.add(new HTML(
            "<span class=\"tag1\">(1)</span> Search for an artist or tag. Click on its name to add it to your tag cloud."));
    vP.add(new HTML(
            "<span class=\"tag1\">(2)</span> Click and drag a tag to grow it or shrink it. Right-click on a tag to display its context menu, where you can make it sticky, negative or delete it. "));
    vP.add(new HTML(
            "<span class=\"tag1\">(3)</span> Get recommendations that match your tag cloud. You can obtain an explanation of why an artist is recommended by clicking on its \"why?\" link or listen to it by clicking on its Play button."));
    hP.add(vP);/*w w w  . ja va  2 s  . com*/

    VerticalPanel mainVp = new VerticalPanel();
    mainVp.setWidth("775px");
    mainVp.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER);
    Label title = new Label("Steerable recommendations basics");
    title.addStyleName("tagPop2");
    mainVp.add(title);
    mainVp.add(hP);
    return mainVp;

}

From source file:com.sun.labs.aura.music.wsitm.client.ui.swidget.ServerInfoSwidget.java

License:Open Source License

private void invokeGetServerInfo() {

    AsyncCallback<ServerInfoItem> callback = new AsyncCallback<ServerInfoItem>() {

        public void onSuccess(ServerInfoItem info) {

            HorizontalPanel hP = new HorizontalPanel();
            hP.setSpacing(8);

            // Items info
            if (info.getItemCnt() != null) {
                hP.add(WebLib.createSection("Items", HashMapToGrid(info.getItemCnt())));
            }/*from  w  w  w.j ava2s  . co  m*/

            // Attentions info
            if (info.getAttentionCnt() != null) {
                hP.add(WebLib.createSection("Attentions", HashMapToGrid(info.getAttentionCnt())));
            }

            // Cache info
            if (info.getCacheStatus() != null) {
                hP.add(WebLib.createSection("Cache info", HashMapToGrid(info.getCacheStatus())));
            }

            g.setWidget(1, 0, hP);

        }

        public void onFailure(Throwable caught) {
            g.setWidget(1, 0, new Label("Update failed."));
        }
    };

    try {
        musicServer.getServerInfo(callback);
    } catch (Exception ex) {
        Popup.showErrorPopup(ex, Popup.ERROR_MSG_PREFIX.ERROR_OCC_WHILE, "retrieve server info.",
                Popup.ERROR_LVL.NORMAL, null);
    }
}

From source file:com.sun.labs.aura.music.wsitm.client.ui.swidget.SimpleSearchSwidget.java

License:Open Source License

private Widget getTagHeaderWidget(final TagDetails tagDetails) {

    HTML html = new HTML();
    html.setHTML(getBestTagImageAsHTML(tagDetails) + tagDetails.getDescription());
    html.setStyleName("bio");

    HorizontalPanel hP = new HorizontalPanel();
    hP.setSpacing(3);
    hP.add(WebLib.getListenWidget(tagDetails));
    SteeringWheelWidget sww = new SteeringWheelWidget(SteeringWheelWidget.wheelSize.BIG, new ClickHandler() {
        @Override//from   w ww .j a v a 2  s  . com
        public void onClick(ClickEvent event) {
            cdm.getSteerableTagCloudExternalController().clear(false);
            cdm.getSteerableTagCloudExternalController().addTag(tagDetails);
            History.newItem("steering:", true);
        }
    });
    sww.setTitle("Steerable recommendations starting with the " + tagDetails.getName() + " tag");
    hP.add(sww);

    return createMainSection(tagDetails.getName(), html, hP, tagDetails.getSimilarTags(), null, false);
}

From source file:com.sun.labs.aura.music.wsitm.client.ui.swidget.Swidget.java

License:Open Source License

protected void showHelpOffer() {
    if (useTopLoader) {
        HorizontalPanel hP = new HorizontalPanel();
        hP.setSpacing(3);
        hP.add(playImgBundle.topArrow().createImage());
        Label helpLbl = new Label("Need help?");
        helpLbl.addStyleName("tag1");
        helpLbl.setWidth("100px");
        hP.add(helpLbl);/*from  ww  w  .j a va  2 s  .  co  m*/
        hP.getElement().getStyle().setPropertyPx("marginLeft", 30);
        topMsgGrid.setWidget(0, 0, hP);

        // Clear message in 10 seconds
        Timer t = new Timer() {
            @Override
            public void run() {
                topMsgGrid.clearCell(0, 0);
            }
        };
        t.schedule(1000 * 10);
    }
}

From source file:com.sun.labs.aura.music.wsitm.client.ui.TagDisplayLib.java

License:Open Source License

/**
 * Return a panel containing the tags cloud passed in parameter. If panel
 * will be used in pop-up, pass the DialogBox that will contain it in d to add
 * so the pop-up can be closed when a tag is clicked on
 * @param tags//from  www .  jav  a2  s .c  o m
 * @param d
 * @return
 */
public static Panel getTagsInPanel(ItemInfo[] tags, PopupPanel d, ORDER order, ClientDataManager cdm,
        TagColorType colorTheme) {
    Panel p = new FlowPanel();
    if (d != null) {
        p.setWidth("600px");
    }
    HorizontalPanel innerP = new HorizontalPanel();
    innerP.setSpacing(4);

    if (tags != null && tags.length > 0) {

        double max = 0;
        double min = 1;
        double tempScore;
        for (ItemInfo tag : tags) {
            tempScore = Math.abs(tag.getScore());
            if (tempScore > max) {
                max = tempScore;
            } else if (tempScore < min) {
                min = tempScore;
            }
        }
        double range = max - min;

        if (order == ORDER.SHUFFLE) {
            Arrays.sort(tags, ItemInfo.getRandomSorter());
        } else if (order == ORDER.DESC) {
            Arrays.sort(tags, ItemInfo.getScoreSorter());
        } else if (order == ORDER.ALPHABETICAL) {
            Arrays.sort(tags, ItemInfo.getNameSorter());
        }

        for (int i = 0; i < tags.length; i++) {
            boolean isTag = tags[i].getId().startsWith("artist-tag:");
            int colorId = i % 2;

            int fontSize;
            if (tags.length == 1 || range == 0) {
                fontSize = scoreToFontSize(1);
            } else {
                fontSize = scoreToFontSize((Math.abs(tags[i].getScore()) - min) / range);
            }

            Label sL;
            if (isTag) {
                sL = new ContextMenuTagLabel(tags[i], cdm);
            } else {
                sL = new SpannedLabel(tags[i].getItemName());
            }

            sL.getElement().getStyle().setPropertyPx("fontSize", fontSize);
            setColorToElem(sL, colorId, tags[i].getScore(), null, colorTheme);
            sL.addStyleName("pointer");
            sL.addClickHandler(new DDEClickHandler<ItemInfo, Boolean>(tags[i], isTag) {
                @Override
                public void onClick(ClickEvent event) {
                    String tagLink = data.getId();
                    if (!sndData) {
                        History.newItem("artist:" + data.getId());
                    } else {
                        if (!tagLink.startsWith("artist-tag:")) {
                            tagLink = ClientDataManager.nameToKey(tagLink);
                        }
                        History.newItem("tag:" + tagLink);
                    }
                }
            });
            if (d != null) {
                sL.addClickHandler(new DEClickHandler<PopupPanel>(d) {

                    @Override
                    public void onClick(ClickEvent event) {
                        data.hide();
                    }
                });
            }
            p.add(sL);
            p.add(new SpannedLabel("    "));
        }
        return p;
    } else {
        return null;
    }
}

From source file:com.sun.labs.aura.music.wsitm.client.ui.widget.PageHeaderWidget.java

License:Open Source License

/**
 * Called after a successful login by the invoke methods that just received
 * the new ListenerDetails containing the login information. Updates page header UI
 * @param l/*from   w  w w  .  jav a2s. c  o m*/
 */
private void updatePanelAfterLogin(ListenerDetails l) {

    if (l != null && l.isLoggedIn()) {

        cdm.setListenerDetails(l);

        String name;
        if (l.getNickName() != null) {
            name = l.getNickName();
        } else if (l.getRealName() != null) {
            name = l.getRealName();
        } else {
            name = l.getOpenId();
        }

        HorizontalPanel hP = new HorizontalPanel();
        hP.setSpacing(4);
        Label loggedLbl = new Label(name);
        loggedLbl.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent ce) {
                History.newItem("userpref:");
            }
        });
        loggedLbl.addStyleName("headerMenuMedItem headerMenuMedItemC");
        hP.add(loggedLbl);

        VerticalPanel vP = new VerticalPanel();

        Label lnk = new Label("Logout");
        lnk.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent ce) {
                cdm.resetUser();
                invokeTerminateSession();
            }
        });
        lnk.setStyleName("headerMenuTinyItem headerMenuTinyItemC");
        vP.add(lnk);

        hP.add(vP);

        HorizontalPanel buttonsPanel = new HorizontalPanel();
        buttonsPanel.setVerticalAlignment(VerticalPanel.ALIGN_MIDDLE);
        Image steerable = new SteeringWheelWidget(SteeringWheelWidget.wheelSize.SMALL, new ClickHandler() {
            @Override
            public void onClick(ClickEvent ce) {
                cdm.setSteerableReset(true);
                History.newItem("steering:userCloud");
            }
        });
        steerable.setTitle("Steerable recommendations starting with your personal tag cloud");
        buttonsPanel.add(steerable);

        // Plays a random recommendation
        instantRecPlayWidget = new InstantRecPlayWidget();
        if (instantRecPlayWidget != null) {
            buttonsPanel.add(instantRecPlayWidget);
        }

        hP.add(buttonsPanel);
        mainPanel.setWidget(0, 0, hP);
    } else {
        populateLoginBox();
    }
}