Example usage for com.google.gwt.user.client.ui CellPanel setCellHeight

List of usage examples for com.google.gwt.user.client.ui CellPanel setCellHeight

Introduction

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

Prototype

public void setCellHeight(Widget w, String height) 

Source Link

Document

Sets the height of the cell associated with the given widget, related to the panel as a whole.

Usage

From source file:de.eckhartarnold.client.TiledLayout.java

License:Apache License

private int createTiles(CellPanel parent, ImageCollectionInfo info, String config, int i) {
    while (i < config.length()) {
        switch (config.charAt(i)) {
        case ('C'): {
            parent.add(caption);/*  w  ww  . ja v  a  2s  .  com*/
            caption.addStyleDependentName("tiled");
            parent.setCellVerticalAlignment(caption, HasVerticalAlignment.ALIGN_MIDDLE);
            parent.setCellHorizontalAlignment(caption, HasHorizontalAlignment.ALIGN_CENTER);
            parent.setCellWidth(caption, "100%");
            break;
        }
        case ('O'): {
            overlay = new CaptionOverlay(caption, imagePanel, slideshow,
                    info.getInfo().get(CaptionOverlay.KEY_CAPTION_POSITION));
        }
        case ('I'): {
            parent.add(imagePanel);
            parent.setCellVerticalAlignment(imagePanel, HasVerticalAlignment.ALIGN_MIDDLE);
            parent.setCellHorizontalAlignment(imagePanel, HasHorizontalAlignment.ALIGN_CENTER);
            parent.setCellWidth(imagePanel, "100%");
            parent.setCellHeight(imagePanel, "100%");
            break;
        }
        case ('P'):
        case ('F'): {
            assert control instanceof Widget;
            parent.add((Widget) control);
            ((Widget) control).addStyleDependentName("tiled");
            parent.setCellVerticalAlignment(((Widget) control), HasVerticalAlignment.ALIGN_MIDDLE);
            if (parent instanceof HorizontalPanel && parent.getWidgetCount() == 1) {
                parent.setCellHorizontalAlignment(((Widget) control), HasHorizontalAlignment.ALIGN_RIGHT);
            } else {
                parent.setCellHorizontalAlignment(((Widget) control), HasHorizontalAlignment.ALIGN_CENTER);
            }
            break;
        }
        case ('-'): {
            HTML horizLine = new HTML("<hr class=\"tiledSeparator\" />");
            panel.add(horizLine);
            break;
        }
        case (']'): {
            return i;
        }
        case ('['): {
            CellPanel panel;
            if (parent instanceof VerticalPanel) {
                panel = new HorizontalPanel();
                panel.setStyleName("tiled");
            } else {
                panel = new VerticalPanel();
                panel.setStyleName("tiled");
            }
            i = createTiles(panel, info, config, i + 1);
            parent.add(panel);
            break;
        }
        default:
            assert false : "Illegal token '" + config.charAt(i) + "' in config string";
        }
        i++;
    }
    return i;
}

From source file:edu.caltech.ipac.firefly.commands.DynSearchCmd.java

protected DockLayoutPanel processSplitPanel(SplitPanelTag sp, Request inputReq, WidgetFactory factory,
        EventHub hub, PrimaryTableUILoader loader) {

    DynData hData = (DynData) Application.getInstance().getAppData(DynUtils.HYDRA_APP_DATA);

    SplitLayoutPanelFirefly slp = new SplitLayoutPanelFirefly();
    hub.bind(slp);//from w  w w  .j  a v a2  s.c o m
    //        SplitLayoutPanel slp = new SplitLayoutPanel();
    slp.setSize("100%", "100%");
    slp.setMinCenterSize(30, 120);
    GwtUtil.setStyle(slp, "overflowX", "auto");

    LinkedHashSet<LayoutAreaTag> laTags = sp.getLayoutAreas();
    boolean centerAdded = false;
    for (LayoutAreaTag laTag : laTags) {
        if (centerAdded) {
            DynUtils.PopupMessage("XML Error",
                    "XML configuration file is invalid!  Center layouts must be added last within a SplitPanel!");
            break;
        }

        // if groupId set, store widget and parent splitlayoutpanel
        DynData.SplitLayoutPanelData panelData = null;
        String groupId = laTag.getGroupId();
        if (groupId != null) {
            panelData = new DynData.SplitLayoutPanelData(slp);
        }

        LayoutAreaTag.LayoutDirection dir = laTag.getType();
        boolean doTag = Boolean.parseBoolean(String.valueOf(laTag.getTagIt()));

        List<SplitPanelTag> spList = laTag.getSplitPanels();
        for (SplitPanelTag spItem : spList) {
            DockLayoutPanel slp2 = processSplitPanel(spItem, inputReq, factory, hub, loader);

            switch (dir) {
            case NORTH:
                slp.addNorth(slp2, laTag.getIntialHeight());
                break;

            case SOUTH:
                slp.addSouth(slp2, laTag.getIntialHeight());
                break;

            case EAST:
                slp.addEast(slp2, laTag.getIntialWidth());
                break;

            case WEST:
                slp.addWest(slp2, laTag.getIntialWidth());
                break;

            case CENTER:
                slp.add(slp2);
                centerAdded = true;
            }
        }

        List<FormTag> fList = laTag.getForms();
        if (fList != null && fList.size() > 0) {
            for (FormTag f : fList) {
                final String title = f.getTitle();
                final String helpId = StringUtils.isEmpty(f.getHelpId()) ? null : f.getHelpId();
                final Form form = GwtUtil.createForm(f, hub, null);
                form.getFieldCount(); // adds listeners

                Toolbar.CmdButton button = new Toolbar.CmdButton(title, title, title, new Command() {
                    public void execute() {
                        PopupUtil.showDialog(Application.getInstance().getToolBar(), form, title, "Done",
                                helpId);
                    }
                });
                Application.getInstance().getToolBar().addButton(button);
                WebEventManager.getAppEvManager().addListener(Name.SEARCH_RESULT_START, new WebEventListener() {
                    public void eventNotify(WebEvent ev) {
                        Application.getInstance().getToolBar().removeButton(title);
                        WebEventManager.getAppEvManager().removeListener(this);
                    }
                });
            }
        }

        String layoutType = laTag.getLayout();
        TabPane tp = null;
        CellPanel container = null;

        if (layoutType != null
                && (layoutType.equalsIgnoreCase("tab") || layoutType.equalsIgnoreCase("fixedTab"))) {
            tp = new TabPane();
            tp.setSize("100%", "100%");

            String tpName = laTag.getLayoutName();
            if (!StringUtils.isEmpty(tpName)) {
                tp.setTabPaneName(tpName);
            }

            if (layoutType.equalsIgnoreCase("tab")) {
                new NewTableEventHandler(hub, tp);
            }

        } else if (layoutType != null) {
            container = layoutType.equalsIgnoreCase("horizontal") ? new HorizontalPanel() : new VerticalPanel();
            container.setSize("100%", "100%");
            container.setSpacing(5);
            GwtUtil.setStyles(container, "borderSpacing", "10px 5px", "tableLayout", "fixed");
        }

        if (laTag.getId() != null) {
            tp.getElement().setId(laTag.getId());
        }

        List<LayoutContentTypeTag> lctList = laTag.getLayoutContentTypes();
        for (LayoutContentTypeTag lct : lctList) {
            if (lct instanceof TableTag) {
                TableTag t = (TableTag) lct;
                String queryId = t.getQueryId();

                // check constraintsTag
                boolean constraintCheck = true;
                List<QueryTag> queryTagList = searchTypeTag.getQueries();
                QueryTag queryTag = null;

                for (QueryTag q : queryTagList) {
                    if (queryId.equalsIgnoreCase(q.getId())) {
                        queryTag = q;

                        constraintCheck = checkConstraints(q.getConstraints(), inputReq);

                        // tables only have 1 QuerySource
                        break;
                    }
                }

                if (queryTag != null && constraintCheck) {
                    String searchProcessorId = queryTag.getSearchProcessorId();
                    if (searchProcessorId != null) {
                        Map<String, String> tableParams = new HashMap<String, String>();
                        tableParams.put(TablePanelCreator.TITLE, t.getTitle());
                        tableParams.put(TablePanelCreator.SHORT_DESC, t.getShortDescription());
                        tableParams.put(TablePanelCreator.QUERY_SOURCE, t.getQueryId());

                        List<ParamTag> pList = t.getParams();
                        for (ParamTag p : pList) {
                            tableParams.put(p.getKey(), p.getValue());
                        }

                        TableServerRequest tsReq = new TableServerRequest(searchProcessorId, inputReq);

                        tsReq.setParam(DynUtils.QUERY_ID, t.getQueryId());

                        // get query params
                        List<ParamTag> paramTagList = queryTag.getParams();
                        for (ParamTag p : paramTagList) {
                            tsReq.setParam(p.getKey(), p.getValue());
                        }

                        tableParams.put("QUERY_ID", searchProcessorId);

                        String tableType = t.getType();
                        final PrimaryTableUI primary = factory.createPrimaryUI(tableType, tsReq, tableParams);

                        DownloadTag dlTag = queryTag.getDownload();
                        DynDownloadSelectionDialog ddsd = DynUtils.makeDownloadDialog(dlTag, getForm());
                        if (ddsd != null) {
                            String dlId = dlTag.getId();

                            List<ParamTag> dlParams = dlTag.getParams();
                            List<SearchFormParamTag> sfParams = dlTag.getSearchFormParams();
                            for (SearchFormParamTag sfpt : sfParams) {
                                DynUtils.evaluateSearchFormParam(getForm(), sfpt, dlParams);
                            }

                            String downloadTitle = dlTag.getTitlePrefix();
                            if (!StringUtils.isEmpty(inputReq.getShortDesc())) {
                                downloadTitle += " " + inputReq.getShortDesc();
                            }
                            downloadTitle += " Search";
                            primary.addDownloadButton(ddsd, dlId, dlTag.getFilePrefix(), downloadTitle,
                                    DynUtils.convertToParamList(dlParams));
                        }

                        // process view, if exists
                        List<ViewTag> tviews = t.getViews();
                        if (tviews != null) {
                            HashMap<String, String> formFields = new HashMap<String, String>();
                            for (Param p : inputReq.getParams()) {
                                formFields.put(p.getName(), p.getValue());
                            }

                            for (ViewTag v : tviews) {
                                String vqueryId = !StringUtils.isEmpty(v.getQueryId()) ? v.getQueryId()
                                        : queryId;
                                Map<String, String> params = new HashMap<String, String>();
                                params.putAll(formFields);
                                params.put(DynUtils.QUERY_ID, vqueryId);
                                for (ParamTag pt : v.getParams()) {
                                    params.put(pt.getKey(), pt.getValue());
                                }
                                TablePanel.View view = factory.createTablePanelView(v.getType(), params);
                                if (primary instanceof TablePrimaryDisplay) {
                                    view.bind(hub);
                                    ((TablePrimaryDisplay) primary).getTable().addView(view);
                                }
                            }
                        }

                        if (primary != null)
                            primary.bind(hub);

                        loader.addTable(primary);

                        if (t.getId() != null) {
                            primary.getDisplay().getElement().setId(t.getId());
                        }

                        if (tp != null) {
                            tp.addTab(primary.getDisplay(), t.getTitle(), t.getShortDescription(), false);

                        } else if (container != null) {
                            //                                Widget w = createShadowTitlePanel(primary.getDisplay(), primary.getShortDesc(), laTag.getHelpId(), doTag);
                            SimplePanel wrapper = new SimplePanel();
                            wrapper.add(primary.getDisplay());
                            wrapper.setStyleName("shadow");
                            wrapper.addStyleName("expand-fully");
                            //                                w.setSize(getInitSizeStr(laTag.getIntialWidth()), getInitSizeStr(laTag.getIntialHeight()));
                            container.add(wrapper);
                            if (layoutType.equalsIgnoreCase("horizontal")) {
                                container.setCellHeight(wrapper, "100%");
                                container.setCellWidth(wrapper, 100 / lctList.size() + "%");
                            } else {
                                container.setCellWidth(wrapper, "100%");
                                container.setCellHeight(wrapper, 100 / lctList.size() + "%");
                            }
                        } else {
                            Widget w = createShadowTitlePanel(primary.getDisplay(), primary.getShortDesc(),
                                    laTag.getHelpId(), doTag);
                            switch (dir) {
                            case NORTH:
                                slp.addNorth(w, laTag.getIntialHeight());
                                break;

                            case SOUTH:
                                slp.addSouth(w, laTag.getIntialHeight());
                                break;

                            case EAST:
                                slp.addEast(w, laTag.getIntialWidth());
                                break;

                            case WEST:
                                slp.addWest(w, laTag.getIntialWidth());
                                break;

                            case CENTER:
                                slp.add(w);
                                centerAdded = true;
                            }
                        }
                    }
                }

            } else if (lct instanceof PreviewTag) {
                PreviewTag pv = (PreviewTag) lct;
                List<String> queryIds = pv.getQueryIds();

                // check constraintsTag of all possible queries
                boolean constraintCheck = false;

                if (queryIds != null) {
                    List<QueryTag> queryTagList = searchTypeTag.getQueries();
                    for (String queryId : queryIds) {
                        List<String> qIdList = StringUtils.asList(queryId, ",");

                        for (QueryTag q : queryTagList) {
                            if (qIdList.contains(q.getId())) {
                                constraintCheck = constraintCheck
                                        || checkConstraints(q.getConstraints(), inputReq);
                            }
                        }
                    }
                }
                ConstraintsTag c = pv.getConstraints();
                if (c != null) {
                    constraintCheck = constraintCheck && checkConstraints(c, inputReq);
                }

                if (queryIds == null || constraintCheck) {
                    Map<String, String> previewParams = new HashMap<String, String>();
                    List<ParamTag> pList = pv.getParams();
                    for (ParamTag p : pList) {
                        String key = p.getKey();
                        String value = p.getValue();

                        previewParams.put(key, value);
                    }

                    if (queryIds != null) {
                        previewParams.put("QUERY_ID", StringUtils.toString(queryIds, ","));
                    }

                    List<String> eventWorkerIds = pv.getEventWorkerIds();
                    if (eventWorkerIds != null) {
                        previewParams.put("EVENT_WORKER_ID", StringUtils.toString(eventWorkerIds, ","));
                    }

                    String previewType = pv.getType();
                    TablePreview preview = factory.createObserverUI(previewType, previewParams);

                    String previewId = pv.getId();
                    if (previewId != null) {
                        preview.setID(previewId);
                    }

                    if (preview != null)
                        preview.bind(hub);

                    if (tp != null) {
                        tp.addTab(preview.getDisplay(), pv.getTitle(), pv.getShortDescription(), false);

                    } else if (container != null) {
                        //                            Widget pw = createPreviewPanel(preview, pv.getFrameType(), laTag.getHelpId(), doTag);
                        //                            pw.setSize(getInitSizeStr(laTag.getIntialWidth()), getInitSizeStr(laTag.getIntialHeight()));
                        ResizablePanel wrapper = new ResizablePanel();
                        wrapper.add(preview.getDisplay());
                        wrapper.setStyleName("shadow");
                        wrapper.addStyleName("expand-fully");
                        container.add(wrapper);
                        if (layoutType.equalsIgnoreCase("horizontal")) {
                            container.setCellHeight(wrapper, "100%");
                        } else {
                            container.setCellWidth(wrapper, "100%");
                        }
                    } else {
                        Widget pw = createPreviewPanel(preview, pv.getFrameType(), laTag.getHelpId(), doTag);
                        Double size = null;
                        switch (dir) {
                        case NORTH:
                            size = new Double(laTag.getIntialHeight());
                            slp.addNorth(pw, size);

                            break;

                        case SOUTH:
                            size = new Double(laTag.getIntialHeight());
                            slp.addSouth(pw, size);
                            break;

                        case EAST:
                            size = new Double(laTag.getIntialWidth());
                            slp.addEast(pw, size);
                            break;

                        case WEST:
                            size = new Double(laTag.getIntialWidth());
                            slp.addWest(pw, size);
                            break;

                        case CENTER:
                            slp.add(pw);
                            centerAdded = true;
                        }

                        // if groupId set, store widget and parent splitlayoutpanel
                        if (panelData != null) {
                            panelData.addWidget(previewId, pw);
                            panelData.addSize(previewId, size);
                        }
                    }
                }
            }
        }

        // HtmlLoaderTag call the server, then display the result message as html
        List<HtmlLoaderTag> htmlLoaders = laTag.getHtmlLoaders();
        if (htmlLoaders != null) {
            for (HtmlLoaderTag htmlLoader : htmlLoaders) {
                HTML html = new HTML();
                LabelTag l = htmlLoader.getLabel();
                if (l != null) {
                    html.setHTML(l.getHtmlString());
                }
                doHtmlLoad(inputReq, htmlLoader, html);
                container.add(html);
            }
        }

        if (tp != null) {
            Widget w = null;
            String taTitle = laTag.getTitle();
            if (taTitle != null && taTitle.length() > 0) {
                w = createShadowTitlePanel(tp, taTitle, laTag.getHelpId(), doTag);
            } else {
                w = tp;
                if (!StringUtils.isEmpty(laTag.getHelpId())) {
                    tp.setHelpId(laTag.getHelpId());
                }
            }

            switch (dir) {
            case NORTH:
                slp.addNorth(w, laTag.getIntialHeight());
                break;

            case SOUTH:
                slp.addSouth(w, laTag.getIntialHeight());
                break;

            case EAST:
                slp.addEast(w, laTag.getIntialWidth());
                break;

            case WEST:
                slp.addWest(w, laTag.getIntialWidth());
                break;

            case CENTER:
                slp.add(w);
                centerAdded = true;
            }

            hub.bind(tp);

        } else if (container != null) {
            Widget w = null;
            String taTitle = laTag.getTitle();
            if (taTitle != null && taTitle.length() > 0) {
                w = createShadowTitlePanel(container, taTitle, laTag.getHelpId(), doTag);
            } else
                w = container;

            switch (dir) {
            case NORTH:
                slp.addNorth(w, laTag.getIntialHeight());
                break;

            case SOUTH:
                slp.addSouth(w, laTag.getIntialHeight());
                break;

            case EAST:
                slp.addEast(w, laTag.getIntialWidth());
                break;

            case WEST:
                slp.addWest(w, laTag.getIntialWidth());
                break;

            case CENTER:
                slp.add(w);
                centerAdded = true;
            }

        }
        // store panel data, if necessary
        if (panelData != null) {
            hData.addSplitLayoutPanelItem(groupId, panelData);
        }

    }

    return slp;
}

From source file:org.nightcode.gwt.selectio.client.ui.ItemSelector.java

License:Apache License

private void attachPanel(CellPanel parent, Widget child, double heightPercent) {
    parent.add(child);//from   w  w w  .  ja  va2s  .c o  m
    parent.setCellHeight(child, Math.round(height * heightPercent / 100.0) + "px");
}