Example usage for org.apache.wicket AttributeModifier append

List of usage examples for org.apache.wicket AttributeModifier append

Introduction

In this page you can find the example usage for org.apache.wicket AttributeModifier append.

Prototype

public static AttributeAppender append(String attributeName, Serializable value) 

Source Link

Document

Creates a attribute modifier that appends the current value with the given value using a default space character (' ') separator.

Usage

From source file:biz.turnonline.ecosystem.origin.frontend.page.DecoratedPage.java

License:Apache License

protected Navbar newNavbar(String componentId) {
    Navbar navbar = new Navbar(componentId) {
        @Override//from  w  ww.j  av  a 2  s  .  c o  m
        protected Image newBrandImage(String markupId) {
            Image image = super.newBrandImage(markupId);

            image.setImageResource(new ContextRelativeResource("logo.png"));

            return image;
        }
    };

    navbar.addComponents(NavbarComponents.transform(Navbar.ComponentPosition.RIGHT, newNavbarComponents()));
    navbar.get("brandName").get("brandImage").add(AttributeModifier.append("style", "max-height:32px;"));
    navbar.setInverted(true);

    return navbar;
}

From source file:com.apachecon.memories.ApproveGallery.java

License:Apache License

@Override
protected void enrich(WebMarkupContainer secondContainer, UserFile file, int page) {
    secondContainer.add(new ImageLink("imageLink", file));

    final EmptyPanel decorator = new EmptyPanel("decorator");
    decorator.setOutputMarkupId(true);//from  w  w w . ja  va  2s .c  o  m

    if (!file.isNew()) {
        // decorate files only if they come from approved/declined directory
        decorator.add(AttributeModifier.append("class", file.isApproved() ? "approved" : "declined"));
    }
    secondContainer.add(decorator);

    secondContainer.add(new ApproveLink("approve", file) {
        private static final long serialVersionUID = 1L;

        protected void update(AjaxRequestTarget target) {
            decorator.add(AttributeModifier.replace("class", "approved"));
            target.add(decorator);
        }
    });
    secondContainer.add(new DeclineLink("decline", file) {
        private static final long serialVersionUID = 1L;

        protected void update(AjaxRequestTarget target) {
            decorator.add(AttributeModifier.replace("class", "declined"));
            target.add(decorator);
        }
    });
}

From source file:com.apachecon.memories.BrowseGallery.java

License:Apache License

@Override
protected void enrich(WebMarkupContainer secondContainer, UserFile file, int page) {
    ImageLink link = new ImageLink("imageLink", file);
    link.add(AttributeModifier.append("rel", "page-" + page));
    secondContainer.add(link);/* w  ww  .j a  va  2s .co  m*/
}

From source file:com.apachecon.memories.ScrapbookPage.java

License:Apache License

@SuppressWarnings({ "rawtypes", "unchecked" })
public ScrapbookPage() {
    add(new ExternalLink("apacheCon", "http://na11.apachecon.com/"));

    add(new BookmarkablePageLink("logo", Index.class));

    List<Class<? extends Page>> links = new ArrayList<Class<? extends Page>>();
    links.add(Index.class);
    links.add(Upload.class);
    Roles roles = AuthenticatedWebSession.get().getRoles();
    if (roles != null && roles.hasRole("admin")) {
        links.add(Browse.class);
        links.add(Approve.class);
        links.add(Logout.class);
    } else {/* www.j ava 2 s .co m*/
        links.add(Browse.class);
        links.add(SignIn.class);
    }

    add(new ListView<Class>("menu", links) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<Class> item) {
            BookmarkablePageLink link = new BookmarkablePageLink("link", item.getModelObject());

            String simpleName = item.getModelObject().getSimpleName();

            if (getPage().getClass().equals(item.getModelObject())) {
                item.add(AttributeModifier.append("class", "active"));
            }

            link.add(new Label("label", simpleName));
            item.add(link);
        }
    });
}

From source file:com.apachecon.memories.Thumbs.java

License:Apache License

public Thumbs(String id, int maxElems, int rowElements, IModel<List<UserFile>> model) {
    super(id, model);

    RepeatingView repeater = new RepeatingView("items");
    int itemCount = 0;
    for (UserFile file : model.getObject()) {
        MarkupContainer container = new WebMarkupContainer(repeater.newChildId());
        Link link = new BookmarkablePageLink("link", Upload.class);
        link.add(file.createSmallThumb("thumb"));
        container.add(link);/*  w w  w.  ja va2  s.  c om*/

        repeater.add(container);

        if (++itemCount % rowElements == 0) {
            container.add(AttributeModifier.append("class", "last"));
        }

        if (itemCount == maxElems) {
            break;
        }
    }

    add(repeater);
}

From source file:com.axway.ats.testexplorer.pages.model.ColumnsDialog.java

License:Apache License

@SuppressWarnings({ "rawtypes" })
public ColumnsDialog(String id, final DataGrid grid, List<TableColumn> columnDefinitions) {

    super(id);//www. ja  v a 2 s. c  o  m
    setOutputMarkupId(true);

    this.dbColumnDefinitions = columnDefinitions;

    DataView<TableColumn> table = new DataView<TableColumn>("headers",
            new ListDataProvider<TableColumn>(dbColumnDefinitions), 100) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final Item<TableColumn> item) {

            final TableColumn column = item.getModelObject();

            item.add(new CheckBox("visible", new PropertyModel<Boolean>(column, "visible")));
            item.add(new Label("columnName", new PropertyModel<String>(column, "columnName")));

            item.add(new AjaxEventBehavior("click") {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onEvent(AjaxRequestTarget target) {

                    TableColumn tableColumn = (TableColumn) this.getComponent().getDefaultModelObject();
                    tableColumn.setVisible(!tableColumn.isVisible());

                    if (tableColumn.isVisible()) {
                        item.add(AttributeModifier.replace("class", "selected"));
                    } else {
                        item.add(AttributeModifier.replace("class", "notSelected"));
                    }
                    grid.getColumnState().setColumnVisibility(tableColumn.getColumnId(),
                            tableColumn.isVisible());
                    target.add(grid);
                    target.add(this.getComponent());

                    open(target);
                }
            });
            item.setOutputMarkupId(true);

            if (column.isVisible()) {
                item.add(AttributeModifier.replace("class", "selected"));
            } else {
                item.add(AttributeModifier.replace("class", "notSelected"));
            }
        }
    };
    add(table);

    final Form<Void> columnDefinitionsForm = new Form<Void>("columnDefinitionsForm");
    add(columnDefinitionsForm);

    AjaxSubmitLink saveButton = new AjaxSubmitLink("saveButton", columnDefinitionsForm) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {

            super.updateAjaxAttributes(attributes);
            AjaxCallListener ajaxCallListener = new AjaxCallListener();
            ajaxCallListener.onPrecondition("getTableColumnDefinitions(); ");
            attributes.getAjaxCallListeners().add(ajaxCallListener);
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {

            String columnDefinitionsString = form.getRequest().getPostParameters()
                    .getParameterValue("columnDefinitions").toString();

            List<TableColumn> jsColDefinitions = asList(columnDefinitionsString);
            orderTableColumns(dbColumnDefinitions, jsColDefinitions);

            try {
                saveColumnDefinitionsToDb(jsColDefinitions);

                modifyDBColumnDefinitionList(jsColDefinitions);

            } catch (DatabaseAccessException dae) {
                throw new RuntimeException("Unable to save table Column definitions in db: "
                        + ((TestExplorerSession) Session.get()).getDbName(), dae);
            } catch (SQLException sqle) {
                throw new RuntimeException("Unable to save table Column definitions in db: "
                        + ((TestExplorerSession) Session.get()).getDbName(), sqle);
            }

            close(target);
        }
    };
    add(AttributeModifier.append("class", "runsTableColDialogDivWrapper"));
    columnDefinitionsForm.add(saveButton);

    add(new Behavior() {

        private static final long serialVersionUID = 1L;

        @Override
        public void renderHead(Component component, IHeaderResponse response) {

            if (autoAddToHeader()) {

                String script = "jQuery.fn.center=function(){" + "this.css(\"position\",\"absolute\");"
                        + "this.css(\"top\",(jQuery(window).height()-this.height())/2+jQuery(window).scrollTop()+\"px\");"
                        + "this.css(\"left\",(jQuery(window).width()-this.width())/2+jQuery(window).scrollLeft()+\"px\");"
                        + "return this};";

                String css = "#settingsoverlay,.settingsoverlay,#settingsoverlay_high,"
                        + ".settingsoverlay_high{filter:Alpha(Opacity=40);"
                        + "-moz-opacity:.4;opacity:.4;background-color:#444;display:none;position:absolute;"
                        + "left:0;top:0;width:100%;height:100%;text-align:center;z-index:5000;}"
                        + "#settingsoverlay_high,.settingsoverlay_high{z-index:6000;}"
                        + "#settingsoverlaycontent,#settingsoverlaycontent_high{display:none;z-index:5500;"
                        + "text-align:center;}.settingsoverlaycontent,"
                        + ".settingsoverlaycontent_high{display:none;z-index:5500;text-align:left;}"
                        + "#settingsoverlaycontent_high,.settingsoverlaycontent_high{z-index:6500;}"
                        + "#settingsoverlaycontent .modalborder,"
                        + "#settingsoverlaycontent_high .modalborder{padding:15px;width:300px;"
                        + "border:1px solid #444;background-color:white;"
                        + "-webkit-box-shadow:0 0 10px rgba(0,0,0,0.8);-moz-box-shadow:0 0 10px rgba(0,0,0,0.8);"
                        + "box-shadow:0 0 10px rgba(0,0,0,0.8);"
                        + "filter:progid:DXImageTransform.Microsoft.dropshadow(OffX=5,OffY=5,Color='gray');"
                        + "-ms-filter:\"progid:DXImageTransform.Microsoft.dropshadow(OffX=5,OffY=5,Color='gray')\";}";

                response.render(JavaScriptHeaderItem.forScript(script, null));
                response.render(CssHeaderItem.forCSS(css, null));
                if (isSupportIE6()) {
                    response.render(JavaScriptHeaderItem
                            .forReference(new PackageResourceReference(getClass(), "jquery.bgiframe.js")));
                }
            }

            response.render(OnDomReadyHeaderItem.forScript(getJS()));
        }

        private String getJS() {

            StringBuilder sb = new StringBuilder();
            sb.append("if (jQuery('#").append(getDivId())
                    .append("').length == 0) { jQuery(document.body).append('")
                    .append(getDiv().replace("'", "\\'")).append("'); }");
            return sb.toString();
        }

        private String getDivId() {

            return getMarkupId() + "_ovl";
        }

        private String getDiv() {

            if (isClickBkgToClose()) {
                return ("<div id=\"" + getDivId() + "\" class=\"settingsoverlayCD\" onclick=\""
                        + getCloseString() + "\"></div>");
            } else {
                return ("<div id=\"" + getDivId() + "\" class=\"settingsoverlayCD\"></div>");
            }
        }
    });

}

From source file:com.axway.ats.testexplorer.pages.reports.compare.CompareRunsPage.java

License:Apache License

private ListView<List<TestcasesTableCell>> getTestcasesTable(
        List<List<TestcasesTableCell>> testcasesTableModel) {

    ListView<List<TestcasesTableCell>> statisticDetailsTable = new ListView<List<TestcasesTableCell>>(
            "runsDetailsRows", testcasesTableModel) {

        private static final long serialVersionUID = 1L;

        @Override/*  w ww.ja  v  a 2s.c  o m*/
        protected void populateItem(ListItem<List<TestcasesTableCell>> item) {

            // table TR
            List<TestcasesTableCell> tdObjects = item.getModelObject();
            final int columnsCount = tdObjects.size();

            if (item.getIndex() == 0) {
                item.add(AttributeModifier.append("class", "runName"));
            } else if (item.getIndex() == 1) {
                item.add(AttributeModifier.append("class", "runDuration"));
            } else if (item.getIndex() == 2) {
                item.add(AttributeModifier.append("class", "testStateFilter"));
            } else if (item.getIndex() == 3 || item.getIndex() == 4) {
                // this is the Apply Filter Button row, we will use colspan, so we need only one column
                tdObjects = item.getModelObject().subList(0, 1);
            } else if (item.getIndex() % 2 != 0) {
                item.add(AttributeModifier.append("class", "oddRow"));
            } else {
                item.add(AttributeModifier.append("class", "evenRow"));
            }

            item.add(new ListView<TestcasesTableCell>("runsDetailsColumns", tdObjects) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void populateItem(ListItem<TestcasesTableCell> item) {

                    // table TD
                    if (item.getIndex() == 0) {
                        item.add(AttributeModifier.append("class", "compareTest_firstCell"));
                    }
                    TestcasesTableCell cell = item.getModelObject();
                    if (cell.isFilter) {

                        item.add(new CheckBox("showOnlyTestsPresentInAllRuns").setVisible(false));
                        item.add(new Label("label", "").setVisible(false));
                        item.add(getTestStateChoices(cell.labelText));

                    } else if (cell.isShowOnlyTestsPresentInAllRunsCheckbox) {

                        item.add(AttributeModifier.replace("class", "compareTest_checkboxCell"));
                        item.add(AttributeModifier.replace("colspan", columnsCount));

                        item.add(new CheckBox("showOnlyTestsPresentInAllRuns",
                                showOnlyTestsPresentInAllRunsModel).setOutputMarkupId(true)
                                        .setMarkupId("showOnlyTestsPresentInAllRuns"));
                        item.add(new Label("label",
                                "<label for=\"showOnlyTestsPresentInAllRuns\">Show only tests present in all runs</label>")
                                        .setEscapeModelStrings(false));
                        item.add(getTestStateChoices(null).setVisible(false));
                    } else if (cell.isFilterButton) {

                        item.add(AttributeModifier.replace("class", "compareTest_applyFilterButtonCell"));
                        item.add(AttributeModifier.replace("colspan", columnsCount));

                        item.add(new CheckBox("showOnlyTestsPresentInAllRuns").setVisible(false));
                        Label label = new Label("label",
                                "<a href=\"#\" class=\"button applyFilterButton\" onclick=\"document.getElementById('applyFilterButton').click();\"><span>Apply Filter</span></a>");
                        label.setEscapeModelStrings(false);
                        item.add(label);
                        item.add(getTestStateChoices(null).setVisible(false));
                    } else {

                        if (cell.cssClass != null) {
                            item.add(AttributeModifier.append("class", cell.cssClass));
                        }
                        item.add(new CheckBox("showOnlyTestsPresentInAllRuns").setVisible(false));
                        Label label = null;
                        if (cell.url != null) {
                            label = new Label("label", "<a href=\"" + cell.url + "\" target=\"_blank\">"
                                    + cell.labelText + "</a>");
                        } else {
                            label = new Label("label", cell.labelText);
                        }
                        label.setEscapeModelStrings(false);
                        item.add(label);
                        item.add(getTestStateChoices(null).setVisible(false));
                    }
                }
            });
        }
    };

    statisticDetailsTable.setOutputMarkupId(true);
    return statisticDetailsTable;
}

From source file:com.axway.ats.testexplorer.pages.testcase.statistics.StatisticsPanel.java

License:Apache License

/**
 * @return ListView containing all diagrams
 *//*from  w w  w  .jav  a  2  s. com*/
private ListView<DbStatisticDescription> addChartGroupListView() {

    ListView<DbStatisticDescription> listViewChartGroup = new ListView<DbStatisticDescription>("chartGroupRows",
            listViewContent) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<DbStatisticDescription> item) {

            DbStatisticDescription statElement = listViewContent.get(item.getIndex());

            if (statElement.name.equals("HEADER")) { // add the header row for the diagram table
                item.add(AttributeModifier.replace("class", "chartGroupHeader"));
                Label removeIcon = new Label("removeIcon");
                removeIcon.add(AttributeModifier.append("style", ";display:none;"));
                item.add(removeIcon);
                item.add(addDiagramHeaderName("statName", "Name"));

                IModel<String> aliasModel = new Model<String>();
                aliasModel.setObject("Alias");
                TextField<String> alias = new TextField<String>("alias", aliasModel);
                alias.setOutputMarkupId(true);
                alias.add(AttributeModifier.append("style",
                        ";background-color:transparent;border:0px;pointer-events:none;text-align: center;font-family:\"Times New Roman\",Times,serif;"));
                alias.add(AttributeModifier.replace("class", "chartGroupHeader"));
                item.add(alias);
                item.add(addDiagramHeaderName("startDate", "Start Time"));
                item.add(addDiagramHeaderName("run", "Run"));
                item.add(addDiagramHeaderName("suite", "Suite"));
                item.add(addDiagramHeaderName("scenario", "Scenario"));
                item.add(addDiagramHeaderName("testcase", "Testcase"));

            } else if (statElement.unit == null) { // add diagram name row

                final AjaxButton deleteAllButton = new AjaxButton("removeIcon") {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public void onSubmit(AjaxRequestTarget target, Form<?> form) {

                        String diagramName = listViewContent.get(item.getIndex()).name;
                        getTESession().getDiagramContainer().remove(diagramName);
                        updateDiagramTableContent();

                        target.add(statsForm);
                    }
                };
                deleteAllButton
                        .add(AttributeModifier.replace("class", "fixGroupTableColumn removeAllItemsIcon"));
                item.add(deleteAllButton);
                item.add(AttributeModifier.replace("class", "chartGroup"));

                item.add(new Label("statName", "").setEscapeModelStrings(false));
                Label alias = new Label("alias", "");
                // disable and change CSS of the input tag
                alias.add(AttributeModifier.append("style",
                        ";background-color:transparent;border:0px;pointer-events:none"));
                item.add(alias);
                item.add(new Label("startDate", statElement.name).setEscapeModelStrings(false));
                item.add(new Label("run", "").setEscapeModelStrings(false));
                item.add(new Label("suite", "").setEscapeModelStrings(false));
                item.add(new Label("scenario", "").setEscapeModelStrings(false));
                item.add(new Label("testcase", "").setEscapeModelStrings(false));

            } else { // add diagram content
                List<String> statNavigationTokens = getStatisticNavigation(statElement);
                final AjaxButton deleteButton = new AjaxButton("removeIcon") {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public void onSubmit(AjaxRequestTarget target, Form<?> form) {

                        deleteSingleRowFromDiagramList(item);
                        updateDiagramTableContent();

                        target.add(statsForm);
                    }
                };
                item.add(deleteButton);
                item.add(new Label("statName", statElement.name).setEscapeModelStrings(false));
                IModel<String> aliasModel = null;
                DbStatisticDescription currentElement = listViewContent.get(item.getIndex());
                String currentElementKey = null;
                if (currentElement.getStatisticId() != 0 && currentElement.machineId != 0) {
                    currentElementKey = getDiagramName(item.getIndex()) + "_" + currentElement.testcaseStarttime
                            + "_" + currentElement.getStatisticId() + "_" + currentElement.machineId;
                } else {
                    currentElementKey = getDiagramName(item.getIndex()) + "_" + currentElement.testcaseStarttime
                            + "_" + currentElement.getName() + "_" + currentElement.getParentName();
                }
                // using diagramName+testcaseStartTime+statisticTypeId+machineId or testcaseStartTime+name+queueName for key
                IModel<String> alias = getTESession().getStatisticsAliasModels().get(currentElementKey);
                if (alias != null && alias.getObject() != null) {
                    aliasModel = alias;
                } else {
                    aliasModel = new Model<String>();
                }
                getTESession().getStatisticsAliasModels().put(currentElementKey, aliasModel);
                item.add(new TextField<String>("alias", aliasModel).setOutputMarkupId(true));
                item.add(new Label("startDate", statNavigationTokens.get(4)).setEscapeModelStrings(false));
                item.add(new Label("run", statNavigationTokens.get(0)).setEscapeModelStrings(false));
                item.add(new Label("suite", statNavigationTokens.get(1)).setEscapeModelStrings(false));
                item.add(new Label("scenario", statNavigationTokens.get(2)).setEscapeModelStrings(false));
                item.add(new Label("testcase", statNavigationTokens.get(3)).setEscapeModelStrings(false));
            }
        };
    };
    listViewChartGroup.setOutputMarkupId(true);

    return listViewChartGroup;
}

From source file:com.axway.ats.testexplorer.pages.testcase.statistics.StatisticsPanel.java

License:Apache License

private Label addDiagramHeaderName(String wicketId, String value) {

    Label label = new Label(wicketId, value);
    label.setEscapeModelStrings(false);//w w  w  .j  av a 2s .  c o  m
    label.add(AttributeModifier.append("style", "text-align: center;"));

    return label;
}

From source file:com.cubeia.network.shared.web.wicket.navigation.MenuPanel.java

License:Open Source License

private void createMenuItems(List<PageNode> pages, Class<? extends Page> currentPageClass, RepeatingView rv) {
    for (PageNode n : pages) {
        if (!n.isLinkable()) {
            continue;
        }//from  w  ww  . j  a va2 s  .com
        AbstractItem item = new AbstractItem(rv.newChildId());
        item.add(createMenuItem(n));
        boolean linkableChildren = n.hasLinkableChildren();
        if (n.isRelatedTo(currentPageClass)) {

            if (linkableChildren) {
                item.add(AttributeModifier.append("class", "open"));
            }
            if (n.getPageClass() != null) {
                item.add(AttributeModifier.append("class", "active"));
            }
        }
        if (linkableChildren) {
            item.add(AttributeModifier.append("class", "submenu"));
            item.add(new MenuPanel("children", n.getChildren(), currentPageClass));
        } else {
            item.add(new WebMarkupContainer("children"));
        }
        rv.add(item);
    }
}