Example usage for org.apache.wicket.model AbstractReadOnlyModel AbstractReadOnlyModel

List of usage examples for org.apache.wicket.model AbstractReadOnlyModel AbstractReadOnlyModel

Introduction

In this page you can find the example usage for org.apache.wicket.model AbstractReadOnlyModel AbstractReadOnlyModel.

Prototype

AbstractReadOnlyModel

Source Link

Usage

From source file:com.mastfrog.acteur.wicket.borrowed.HomePage.java

License:Apache License

/**
 * Construct./*from   w w  w.j  a  va  2  s. c o m*/
 */
public HomePage() {
    super();

    add(new Label("version", new AbstractReadOnlyModel<String>() {

        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {

            /*
             * Read the specification version from the wicket-core MANIFEST.MF file.
             */
            Package p = Application.class.getPackage();

            String version = p.getSpecificationVersion();

            if (version == null || version.length() == 0) {
                return "Missing Version";
            } else {
                return version;
            }
        }
    }));
}

From source file:com.mastfrog.acteur.wicket.borrowed.SourcesPage.java

License:Apache License

/**
 * /*from w w w. j av  a 2  s.co m*/
 * Construct.
 * 
 * @param params
 */
public SourcesPage(final PageParameters params) {
    super(params);

    filename = new Label("filename", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return name != null ? name
                    : getPage().getRequest().getRequestParameters().getParameterValue(SOURCE)
                            .toOptionalString();
        }

    });
    filename.setOutputMarkupId(true);
    add(filename);
    codePanel = new CodePanel("codepanel").setOutputMarkupId(true);
    add(codePanel);
    add(new FilesBrowser("filespanel"));
}

From source file:com.norconex.commons.wicket.bootstrap.table.BootstrapNavigationToolbar.java

License:Apache License

public BootstrapNavigationToolbar(final DataTable<?, ?> table, boolean showNavigationLabel) {
    super(table);
    this.showNavigationLabel = showNavigationLabel;
    WebMarkupContainer span = new WebMarkupContainer("span");
    add(span);/*w  w w.  j  a  v  a  2s . c o m*/
    span.add(AttributeModifier.replace("colspan", new AbstractReadOnlyModel<String>() {
        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            return String.valueOf(table.getColumns().size());
        }
    }));
    span.add(newPagingNavigator("navigator", table));
    span.add(newNavigatorLabel("navigatorLabel", table));
}

From source file:com.pingone.fuji.web.WicketDemo.java

License:Apache License

public WicketDemo() {
    super();/* w w w . j  a v a2 s  .  co  m*/
    add(new Label("currentDay", new AbstractReadOnlyModel<String>() {

        private static final long serialVersionUID = -9190170483114408204L;

        @Override
        public String getObject() {
            return basicSvc.getCurrentDate();
        }
    }));

    add(new Label("emailTaken", new AbstractReadOnlyModel<String>() {

        private static final long serialVersionUID = 394410077004796591L;

        @Override
        public String getObject() {
            return Boolean.toString(basicSvc.isEmailTakenByAUser("joe@example.com"));
        }

    }));
}

From source file:com.romeikat.datamessie.core.base.ui.page.TableNavigatorLabel.java

License:Open Source License

public TableNavigatorLabel(final String id, final AbstractTable<?, ?> table) {
    super(id);//from  w  w w.j av  a2s . co m

    final IModel<String> model = new AbstractReadOnlyModel<String>() {
        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            final long itemCount = table.getItemCount();
            final String objectName = itemCount == 1 ? table.getSingularObjectName()
                    : table.getPluralObjectName();
            final String label = itemCount + " " + objectName;
            return label;
        }
    };
    setDefaultModel(model);
}

From source file:com.senacor.wbs.web.border.LayoutColumn.java

License:Apache License

public LayoutColumn(String id, final ColumnType columnType, final Position position) {
    super(id);//w w  w .ja v  a 2  s .  c  o m
    setRenderBodyOnly(true);
    WebMarkupContainer column = new WebMarkupContainer("column");
    column.add(new AttributeModifier("class", true, new Model<String>(columnType.toString())));
    add(column);
    WebMarkupContainer columnContent = new WebMarkupContainer("columnContent");
    columnContent.add(new AttributeModifier("class", true, new AbstractReadOnlyModel<String>() {
        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            String attrValue;
            switch (position) {
            case LEFT:
                attrValue = "subcl";
                break;
            case RIGHT:
                attrValue = "subcr";
                break;
            default:
                attrValue = "subc";
                break;
            }
            return attrValue;
        }
    }));
    column.add(columnContent);
    columnContent.add(getBodyContainer());
}

From source file:com.senacor.wbs.web.border.ToggleBorder.java

License:Apache License

public ToggleBorder(String id, IModel titleModel) {
    super(id, titleModel);
    add(CSSPackageResource.getHeaderContribution(this.getClass(), "ToggleBorder.css"));
    setOutputMarkupId(true);/*from  w w w . j a  va 2 s  .  co m*/
    PackageResource rollUp = PackageResource.get(ToggleBorder.this.getClass(), "up.png");
    Image rollUpImage = new Image("rollUpImage", rollUp) {
        @Override
        public boolean isVisible() {
            return isExpanded;
        }
    };
    PackageResource rollDown = PackageResource.get(ToggleBorder.this.getClass(), "down.png");
    Image rollDownImage = new Image("rollDownImage", rollDown) {
        @Override
        public boolean isVisible() {
            return !isExpanded;
        }
    };
    AbstractLink headerLink = new AjaxLink("header") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            isExpanded = !isExpanded;
            target.addComponent(ToggleBorder.this);
        }
    };
    headerLink.add(new Label("title", titleModel));
    headerLink.add(rollUpImage);
    headerLink.add(rollDownImage);
    add(headerLink);
    final WebMarkupContainer content = new WebMarkupContainer("content");
    content.add(getBodyContainer());
    content.add(new AttributeAppender("style", true, new AbstractReadOnlyModel() {
        @Override
        public String getObject() {
            return (isExpanded ? "display:block" : "display:none");
        }
    }, ";"));
    add(content);
}

From source file:com.senacor.wbs.web.project.ProjectListPanel.java

License:Apache License

public ProjectListPanel(final String id, final List<Project> projects) {
    super(id);//from  w  ww  .j  a  v  a  2 s .  com
    this.locale = getLocale();
    SortableListDataProvider<Project> projectProvider = new SortableListDataProvider<Project>(projects) {
        @Override
        protected Locale getLocale() {
            return ProjectListPanel.this.getLocale();
        }

        public IModel model(final Object object) {
            return new CompoundPropertyModel(object);
        }
    };
    projectProvider.setSort("name", true);
    dataView = new DataView("projects", projectProvider, 4) {
        @Override
        protected void populateItem(final Item item) {
            Project project = (Project) item.getModelObject();
            PageParameters pageParameters = new PageParameters();
            pageParameters.put("projectId", project.getId());
            item.add(new BookmarkablePageLink("tasks", ProjectDetailsPage.class, pageParameters)
                    .add(new Label("id")));
            item.add(new Label("kuerzel"));
            item.add(new Label("titel", project.getName()));
            item.add(new Label("budget"));
            item.add(new Label("costPerHour"));
            item.add(new Label("start"));
            item.add(new Label("ende"));
            item.add(new Label("state"));
            // Alternieren der Farbe zwischen geraden und
            // ungeraden Zeilen
            item.add(new AttributeModifier("class", true, new AbstractReadOnlyModel() {
                @Override
                public Object getObject() {
                    return (item.getIndex() % 2 == 1) ? "even" : "odd";
                }
            }));
        }
    };
    add(dataView);
    Form localeForm = new Form("localeForm");
    ImageButton deButton = new ImageButton("langde", new ResourceReference(BaseWBSPage.class, "de.png")) {
        @Override
        public void onSubmit() {
            ProjectListPanel.this.locale = Locale.GERMANY;
        }
    };
    localeForm.add(deButton);
    ImageButton usButton = new ImageButton("langus", new ResourceReference(BaseWBSPage.class, "us.png")) {
        @Override
        public void onSubmit() {
            ProjectListPanel.this.locale = Locale.US;
        }
    };
    localeForm.add(usButton);
    add(localeForm);
    final IResourceStream pdfResourceStream = new AbstractResourceStreamWriter() {
        public void write(final OutputStream output) {
            Document document = new Document();
            try {
                PdfWriter.getInstance(document, output);
                document.open();
                // document.add(new
                // Paragraph("WBS-Projektliste"));
                // document.add(new Paragraph(""));
                PdfPTable table = new PdfPTable(new float[] { 1f, 1f, 2f, 1f });
                PdfPCell cell = new PdfPCell(new Paragraph("WBS-Projektliste"));
                cell.setColspan(4);
                cell.setGrayFill(0.8f);
                table.addCell(cell);
                table.addCell("ID");
                table.addCell("Krzel");
                table.addCell("Titel");
                table.addCell("Budget in PT");
                for (Project project : projects) {
                    table.addCell("" + project.getId());
                    table.addCell(project.getKuerzel());
                    table.addCell(project.getName());
                    table.addCell("" + project.getBudget());
                }
                document.add(table);
                document.close();
            } catch (DocumentException e) {
                throw new RuntimeException(e);
            }
        }

        public String getContentType() {
            return "application/pdf";
        }
    };
    WebResource projectsResource = new WebResource() {
        {
            setCacheable(false);
        }

        @Override
        public IResourceStream getResourceStream() {
            return pdfResourceStream;
        }

        @Override
        protected void setHeaders(final WebResponse response) {
            super.setHeaders(response);
            // response.setAttachmentHeader("projekte.pdf");
        }
    };
    WebResource projectsResourceDL = new WebResource() {
        {
            setCacheable(false);
        }

        @Override
        public IResourceStream getResourceStream() {
            return pdfResourceStream;
        }

        @Override
        protected void setHeaders(final WebResponse response) {
            super.setHeaders(response);
            response.setAttachmentHeader("projekte.pdf");
        }
    };
    ResourceLink pdfDownload = new ResourceLink("pdfDownload", projectsResourceDL);
    ResourceLink pdfPopup = new ResourceLink("pdfPopup", projectsResource);
    PopupSettings popupSettings = new PopupSettings(PopupSettings.STATUS_BAR);
    popupSettings.setWidth(500);
    popupSettings.setHeight(700);
    pdfPopup.setPopupSettings(popupSettings);
    Link pdfReqTarget = new Link("pdfReqTarget") {
        @Override
        public void onClick() {
            RequestCycle.get()
                    .setRequestTarget(new ResourceStreamRequestTarget(pdfResourceStream, "projekte.pdf"));
        }
    };
    add(pdfReqTarget);
    add(pdfDownload);
    add(pdfPopup);
    add(new OrderByBorder("orderByKuerzel", "kuerzel", projectProvider));
    add(new OrderByBorder("orderByName", "name", projectProvider));
    add(new OrderByBorder("orderByBudget", "budget", projectProvider));
    add(new OrderByBorder("orderByCostPerHour", "costPerHour", projectProvider));
    add(new OrderByBorder("orderByStart", "start", projectProvider));
    add(new OrderByBorder("orderByEnde", "ende", projectProvider));
    add(new OrderByBorder("orderByState", "state", projectProvider));
    add(new PagingNavigator("projectsNavigator", dataView));
}

From source file:com.senacor.wbs.web.user.UserAdminPage.java

License:Apache License

public UserAdminPage() {
    SearchUserPanel searchUserPanel = new SearchUserPanel(middleColumn.getListPanel().newChildId()) {
        @Override/*from   www  .  j  a v  a2 s . c om*/
        protected void doSearch(final AjaxRequestTarget target, final User userCriteria) {
            // foundUser = userManager.find(userCriteria);
            // Workaround bis userManager.find(userCriteria)
            // funktioniert
            userListPanel.setCurrentPage(0);
            foundUser.clear();
            for (User user : userManager.findAll()) {
                if (startsWith(user.getVorname(), userCriteria.getVorname())
                        && startsWith(user.getName(), userCriteria.getName())
                        && startsWith(user.getUsername(), userCriteria.getUsername())) {
                    foundUser.add(user);
                }
            }
            target.addComponent(userListPanel);
        }

        @Override
        protected Iterator<User> doGetChoices(final String input) {
            if (StringUtils.isBlank(input)) {
                return new ArrayList<User>().iterator();
            } else {
                String stripped = input.replaceAll("\\(|\\)", "");
                String[] inputParts = StringUtils.split(stripped);
                String criteria = StringUtils.join(inputParts, "* ");
                criteria = criteria + "*";
                System.out.println("criteria: " + criteria);
                List<User> userList = userManager.findPerIndex(criteria);
                return userList.iterator();
            }
        }
    };
    middleColumn.getListPanel().add(searchUserPanel);
    IModel userDataModel = new AbstractReadOnlyModel() {
        @Override
        public Object getObject() {
            return foundUser;
        }
    };
    userListPanel = new UserListPanel(middleColumn.getListPanel().newChildId(),
            new UserDataSource(userDataModel));
    userListPanel.setOutputMarkupId(true);
    userListPanel.setRenderBodyOnly(false);
    middleColumn.getListPanel().add(userListPanel);
}

From source file:com.servoy.j2db.server.headlessclient.dataui.ReadOnlyAndEnableTestAttributeModifier.java

License:Open Source License

/**
 * @param eventExecutor/* w  w  w . j  ava 2  s  .  c om*/
 * @param attribute
 * @param value
 */
ReadOnlyAndEnableTestAttributeModifier(String attribute, final CharSequence value) {
    if (attribute == null) {
        throw new IllegalArgumentException("Argument [attr] cannot be null");
    }
    if (value == null) {
        throw new IllegalArgumentException("Argument [value] cannot be null");
    }
    this.attribute = attribute;
    this.model = new AbstractReadOnlyModel<CharSequence>() {

        @Override
        public CharSequence getObject() {
            return value;
        }

    };
}