Example usage for org.apache.wicket.markup.html.image Image Image

List of usage examples for org.apache.wicket.markup.html.image Image Image

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html.image Image Image.

Prototype

protected Image(final String id) 

Source Link

Document

This constructor can be used if you override #getImageResourceReference() or #getImageResource()

Usage

From source file:au.org.theark.core.web.component.panel.collapsiblepanel.CollapsiblePanel.java

License:Open Source License

/**
 * Construct the panel/*from  w  ww.j a  va  2 s .com*/
 * 
 * @param id
 *           Panel ID
 * @param titleModel
 *           Model used to get the panel title
 * @param defaultOpen
 *           Is the default state open
 */
public CollapsiblePanel(String id, IModel<String> titleModel, boolean defaultOpen) {
    super(id);
    this.visible = defaultOpen;
    innerPanel = getInnerPanel("innerPanel");
    innerPanel.setVisible(visible);
    innerPanel.setOutputMarkupId(true);
    innerPanel.setOutputMarkupPlaceholderTag(true);
    add(innerPanel);

    final Image showHideImage = new Image("showHideIcon") {
        private static final long serialVersionUID = 8638737301579767296L;

        @Override
        public ResourceReference getImageResourceReference() {
            return visible ? open : closed;
        }
    };
    showHideImage.setOutputMarkupId(true);
    IndicatingAjaxLink<String> showHideLink = new IndicatingAjaxLink<String>("showHideLink") {
        private static final long serialVersionUID = -1929927616508773911L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            visible = !visible;
            innerPanel.setVisible(visible);
            target.add(innerPanel);
            target.add(showHideImage);
        }
    };
    showHideLink.add(showHideImage);
    add(new Label("titlePanel", titleModel));
    add(showHideLink);
}

From source file:com.google.code.jqwicket.ui.cloudzoom.CloudZoomImagePanel.java

License:Apache License

protected Image newCloudZoomImage(final String id, final CharSequence url, final CharSequence alt,
        final CharSequence title) {
    return new Image(id) {
        private static final long serialVersionUID = 1L;

        @Override//w ww. java2  s  . c o  m
        protected void onComponentTag(ComponentTag tag) {
            tag.put("src", url);
            if (alt != null)
                tag.put("alt", alt);
            if (title != null)
                tag.put("title", title);
        }
    };
}

From source file:com.senacor.wbs.web.core.layout.Header.java

License:Apache License

public Header(final String id, final IModel titleModel, final IModel subTitleModel) {
    super(id);/*from   w  ww. j  a v  a  2  s.  com*/
    setRenderBodyOnly(true);
    add(new Label("title", titleModel));
    add(new Label("subtitle", subTitleModel));
    Link deLink = new Link("langde") {
        @Override
        public void onClick() {
            getSession().setLocale(Locale.GERMANY);
        }
    };
    deLink.add(new AttributeModifier("title", true, new Model(Locale.GERMANY.getDisplayName(Locale.GERMANY))));
    add(deLink);
    Link usLink = new Link("langus") {
        @Override
        public void onClick() {
            getSession().setLocale(Locale.US);
        }
    };
    usLink.add(new AttributeModifier("title", true, new Model(Locale.US.getDisplayName(Locale.US))));
    add(usLink);
    Link frLink = new Link("langfr") {
        @Override
        public void onClick() {
            getSession().setLocale(Locale.FRANCE);
        }
    };
    frLink.add(new AttributeModifier("title", true, new Model(Locale.FRANCE.getDisplayName(Locale.FRANCE))));
    frLink.setEnabled(false);
    Image inactiveFrImage = new Image("imgFrance");
    frLink.add(inactiveFrImage);
    add(frLink);
    try {
        add(new AuthenticationStatePanel("loginPanel"));
    } catch (IllegalStateException e) {
        add(new Label("loginPanel"));
    }
    add(new ExternalLink("contactLink", new Model("http://www.senacor.de"),
            new ResourceModel("contact.link.label")));
    add(new ExternalLink("imprintLink", new Model("http://www.senacor.de"),
            new ResourceModel("imprint.link.label")));
}

From source file:com.servoy.extensions.beans.dbtreeview.table.DBTreeTableTreeNode.java

License:Open Source License

/**
 * Creates the icon component for the node
 * // w w w .j  a va2s .c o m
 * @param componentId
 * @param tree
 * @param model
 * @return icon image component
 */
protected Component newImageComponent(String componentId, final AbstractTree tree, final IModel model) {
    Object treeNode = model.getObject();
    Component imgComp = null;

    if (treeNode != null && treeNode instanceof FoundSetTreeModel.UserNode) {
        Icon nodeIcon = ((FoundSetTreeModel.UserNode) treeNode).getIcon();

        if (nodeIcon != null) {
            final ResourceReference imageResource = WicketTreeNodeStyleAdapter.imageResource(nodeIcon);
            if (imageResource != null) {
                imgComp = new Image(componentId) {
                    private static final long serialVersionUID = 1L;

                    @Override
                    protected ResourceReference getImageResourceReference() {
                        return imageResource;
                    }
                };

                imgComp.add(new SimpleAttributeModifier("width", "" + nodeIcon.getIconWidth()));
                imgComp.add(new SimpleAttributeModifier("height", "" + nodeIcon.getIconHeight()));
            }
        }

    }

    if (imgComp == null)
        imgComp = getDefaultIcon(componentId, tree, model);

    return imgComp;
}

From source file:com.servoy.extensions.beans.dbtreeview.table.DBTreeTableTreeNode.java

License:Open Source License

/**
 * Creates default icon for the node//  w  w w.java2s.  c  o  m
 * 
 * @param componentId
 * @param tree
 * @param model
 * @return icon image component
 */
private Component getDefaultIcon(String componentId, final AbstractTree tree, final IModel model) {
    return new Image(componentId) {
        private static final long serialVersionUID = 1L;

        @Override
        protected ResourceReference getImageResourceReference() {
            return DBTreeTableTreeNode.this.getImageResourceReference(tree, (TreeNode) model.getObject());
        }
    };
}

From source file:com.servoy.extensions.beans.dbtreeview.WicketDBTreeViewNode.java

License:Open Source License

/**
 * Creates the icon component for the node
 * /*from w ww .j ava2s.c  o m*/
 * @param componentId
 * @param tree
 * @param model
 * @return icon image component
 */
@Override
protected Component newImageComponent(String componentId, final BaseTree tree, final IModel model) {
    final Object treeNode = model.getObject();
    Component imgComp = null;

    if (treeNode != null && treeNode instanceof FoundSetTreeModel.UserNode) {
        Icon nodeIcon = ((FoundSetTreeModel.UserNode) treeNode).getIcon();

        if (nodeIcon != null) {
            final Object mediaUrl = ((FoundSetTreeModel.UserNode) treeNode).getUserObject();
            final ResourceReference imageResource = WicketTreeNodeStyleAdapter.imageResource(nodeIcon);
            if (imageResource != null) {
                imgComp = new Image(componentId) {
                    private static final long serialVersionUID = 1L;

                    @Override
                    protected ResourceReference getImageResourceReference() {
                        String key = ((FoundSetTreeModel.UserNode) treeNode).getUserObject().toString();
                        if (mediaUrlToResource.containsKey(key)) {
                            return mediaUrlToResource.get(key);
                        } else {
                            ResourceReference resRefference = WicketTreeNodeStyleAdapter
                                    .imageResource(((FoundSetTreeModel.UserNode) treeNode).getIcon());
                            resRefference.bind(getApplication());
                            resRefference.getResource().setCacheable(true);
                            mediaUrlToResource.putIfAbsent(
                                    ((FoundSetTreeModel.UserNode) treeNode).getUserObject().toString(),
                                    resRefference);

                            return resRefference;
                        }
                    }
                };
                imgComp.add(new SimpleAttributeModifier("width", "" + nodeIcon.getIconWidth()));
                imgComp.add(new SimpleAttributeModifier("height", "" + nodeIcon.getIconHeight()));
            }
        }

    }

    if (imgComp == null)
        imgComp = super.newImageComponent(componentId, tree, model);

    return imgComp;
}

From source file:eu.uqasar.web.components.qmtree.util.QMTreeFolder.java

License:Apache License

@Override
protected Component newLabelComponent(String id, final IModel<QMTreeNode> model) {
    WebMarkupContainer labelContainer = new WebMarkupContainer(id);
    settings = qmService.get(new QModelSettings());

    Label idLabel;/*from   w w w .  ja  v  a2  s  .  c  o m*/
    Label entityLabel;

    int qoIndex = 0;
    int qiIndex = 0;
    int qmetIndex = 0;

    if (model.getObject() instanceof QModel) {
        entityLabel = new Label("entityLabel", "");
        idLabel = new Label("idLabel", " ");
    } else if (model.getObject() instanceof QMQualityObjective) {
        entityLabel = new Label("entityLabel", settings.getHigh() + " - ");
        qoIndex = (model.getObject()).getParent().getChildren().indexOf(model.getObject()) + 1;
        idLabel = new Label("idLabel", qoIndex + " ");
    } else if (model.getObject() instanceof QMQualityIndicator) {
        entityLabel = new Label("entityLabel", settings.getMedium() + " - ");
        qoIndex = (model.getObject()).getParent().getSiblings().indexOf(model.getObject().getParent()) + 1;
        qiIndex = (model.getObject()).getParent().getChildren().indexOf(model.getObject()) + 1;
        idLabel = new Label("idLabel", qoIndex + " " + qiIndex + " ");
    } else {
        entityLabel = new Label("entityLabel", settings.getLow() + " - ");
        qoIndex = (model.getObject()).getParent().getParent().getSiblings()
                .indexOf(model.getObject().getParent().getParent()) + 1;
        qiIndex = (model.getObject()).getParent().getSiblings().indexOf(model.getObject().getParent()) + 1;
        qmetIndex = (model.getObject()).getParent().getChildren().indexOf(model.getObject()) + 1;
        idLabel = new Label("idLabel", qoIndex + " " + qiIndex + " " + qmetIndex + " ");
    }

    Label label = new Label("labelText", newLabelModel(model));
    Label icon = (Label) new Label("icon")
            .add(new AttributeAppender("class", model.getObject().getIconType().cssClassName()));

    //alarm when the node is incomplete in quality model
    Image incomplete = new Image("incomplete") {
        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        protected void onComponentTag(ComponentTag tag) {
            super.onComponentTag(tag);
            if (!model.getObject().isCompleted()) {
                tag.getAttributes().put("src", "/uqasar/assets/img/exclamation.jpg");
                tag.getAttributes().put("alt", "incomplete");
                tag.getAttributes().put("title", "incomplete");
                tag.getAttributes().put("style", "max-width:3%");
            } else {
                tag.getAttributes().put("src", "/uqasar/assets/img/noexclamation.jpg");
                tag.getAttributes().put("display", "none");
                tag.getAttributes().put("style", "max-width:0%");
            }

        }
    };

    labelContainer.add(incomplete);
    labelContainer.add(label);
    labelContainer.add(icon);
    labelContainer.add(idLabel);
    labelContainer.add(entityLabel);

    return labelContainer;
}

From source file:eu.uqasar.web.pages.qmtree.qmodels.panels.QModelViewPanel.java

License:Apache License

public QModelViewPanel(String id, IModel<QModel> model) {
    super(id, model);

    final QModel qmodel = model.getObject();
    logger.info("QModelViewPanel::QModelViewPanel" + qmodel.getName());

    add(new Label("name", new PropertyModel<>(qmodel, "name")));
    add(new Label("icon").add(new CssClassNameAppender(qmodel.getIconType().cssClassName())));
    // TODO only show if authorized to edit
    BookmarkablePageLink<QModelEditPage> editLink = new BookmarkablePageLink<>("link.edit",
            QModelEditPage.class, QMBaseTreePage.forQModel(qmodel));
    add(editLink);/*w  ww  . j  a  va2 s.c  om*/

    add(new Label("nodeKey", new PropertyModel<>(model, "nodeKey")));
    add(new Label("edition", new PropertyModel<>(qmodel, "edition")));

    add(new Label("company", new PropertyModel<>(qmodel, "company")));

    SimpleDateFormat df = (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.MEDIUM,
            Session.get().getLocale());
    PatternDateConverter pdc = new PatternDateConverter(df.toPattern(), true);
    add(new DateLabel("updateDate", new PropertyModel<Date>(model, "updateDate"), pdc));

    add(new Label("description", new PropertyModel<String>(model, "description")).setEscapeModelStrings(false));

    //isActive
    Image img = new Image("isActive") {
        @Override
        protected void onComponentTag(ComponentTag tag) {
            super.onComponentTag(tag);
            if (qmodel.getIsActive().equals(QModelStatus.Active)) {
                tag.getAttributes().put("src", "/uqasar/assets/img/imgv.gif");
                tag.getAttributes().put("alt", "active");
            } else {
                tag.getAttributes().put("src", "/uqasar/assets/img/imgx.gif");
                tag.getAttributes().put("alt", "inactive");
            }
            tag.getAttributes().put("style", "max-width:10%");
        }
    };

    add(img);

}

From source file:hsa.awp.usergui.FlatListPanel.java

License:Open Source License

/**
 * Constructor for the FlatList panel, which defines all needed components.
 *
 * @param id ID which declares the location in the markup.
 *//* w w  w  . j  a va 2s. com*/
public FlatListPanel(String id, final Campaign campaign) {

    super(id);

    this.campaign = campaign;

    singleUser = controller.getUserById(SecurityContextHolder.getContext().getAuthentication().getName());

    // find events where user is allowed
    events = controller.getEventsWhereRegistrationIsAllowed(campaign, singleUser);

    // find categories with events where user is allowed
    categories = getCategoriesOfEvents(events);

    // find events of category where user is allowed

    final LoadableDetachedModel<List<Category>> categoriesModel = new LoadableDetachedModel<List<Category>>() {
        /**
         * unique serialization id.
         */
        private static final long serialVersionUID = 1594571791900639307L;

        @Override
        protected List<Category> load() {
            List<Category> categoryList = new ArrayList<Category>(categories);
            Collections.sort(categoryList, EventSorter.alphabeticalCategoryName());
            return categoryList;
        }
    };

    final WebMarkupContainer flatListContainer = new WebMarkupContainer("flatlist.container");
    flatListContainer.setOutputMarkupId(true);

    flatListContainer.add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(30f)));

    add(flatListContainer);

    add(new Label("flatlist.capacityDE", new Model<Integer>((int) (capacityPercent * 100))));
    add(new Label("flatlist.capacityEN", new Model<Integer>((int) (capacityPercent * 100))));

    flatListContainer.add(new ListView<Category>("categorylist", categoriesModel) {
        /**
         * Generated serialization id.
         */
        private static final long serialVersionUID = 490760462608363776L;

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

            List<Event> eventsOfCategory = getEventsOfCategory(item.getModelObject(), events);

            item.add(new Label("categoryname", item.getModelObject().getName()));
            item.add(new ListView<Event>("eventlist", eventsOfCategory) {
                /**
                 * Generated serialization id.
                 */
                private static final long serialVersionUID = 497760462608363776L;

                @SuppressWarnings("serial")
                @Override
                protected void populateItem(final ListItem<Event> item) {

                    final Event event = item.getModelObject();

                    int maxParticipants = event.getMaxParticipants();

                    long participantCount = controller.countConfirmedRegistrationsByEventId(event.getId());

                    if (participantCount > maxParticipants) {
                        participantCount = maxParticipants;
                    }

                    item.add(new Label("eventNumber", formatEventId(event)));
                    item.add(new Label("subjectname", event.getSubject().getName()));
                    item.add(new Label("eventdescription", formatDetailInformation(event)));
                    item.add(new Label("eventplaces", "(" + participantCount + "/" + maxParticipants + ")"));

                    Link<Object> link = new Link<Object>("submited") {
                        public void onClick() {

                            Procedure procedure = campaign.findCurrentProcedure();

                            FifoProcedure fifo;

                            if (procedure instanceof FifoProcedure) {
                                fifo = (FifoProcedure) procedure;
                            } else {
                                throw new IllegalStateException("Flatlist works only with Fifoprocedure.");
                            }

                            String initiator = SecurityContextHolder.getContext().getAuthentication().getName();
                            controller.registerWithFifoProcedure(fifo, event, initiator, initiator, true);
                        }
                    };

                    Image icon = new Image("icon");
                    icon.add(new AttributeModifier("src", true, new Model<String>()));

                    if (controller.hasParticipantConfirmedRegistrationInEvent(singleUser, event)) {
                        link.setVisible(false);
                        item.add(new AttributeAppender("class", new Model<String>("disabled"), " "));
                    }

                    if ((maxParticipants - participantCount) <= 0) {
                        link.setEnabled(false);
                        item.add(new AttributeAppender("class", new Model<String>("disabled"), " "));
                        icon.add(new AttributeModifier("src", true, new Model<String>("images/red.png")));
                    } else if ((Float.valueOf(maxParticipants - participantCount)
                            / maxParticipants) <= capacityPercent) {
                        icon.add(new AttributeModifier("src", true, new Model<String>("images/yellow.png")));
                    } else {
                        icon.add(new AttributeModifier("src", true, new Model<String>("images/green.png")));
                    }

                    link.add(icon);
                    link.add(new JavascriptEventConfirmation("onclick", "Sind Sie sicher?"));
                    item.add(link);

                    final ModalWindow detailWindow = new ModalWindow("detailWindow");
                    detailWindow.setTitle(new Model<String>("Veranstaltungsdetails"));
                    detailWindow.setInitialWidth(450);

                    item.add(detailWindow);

                    item.add(new AjaxFallbackLink<Object>("infoLink") {
                        /**
                         * unique serialization id.
                         */
                        private static final long serialVersionUID = 543607735730300949L;

                        @Override
                        public void onClick(AjaxRequestTarget target) {
                            detailWindow.setContent(new EventDetailPanel(detailWindow.getContentId(), event));
                            detailWindow.show(target);
                        }
                    });
                }
            });
        }
    });

    LoadableDetachedModel<String> dateModel = new LoadableDetachedModel<String>() {
        /**
         * unique serialization id.
         */
        private static final long serialVersionUID = -3714278116173742179L;

        @Override
        protected String load() {

            DateFormat singleFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
            return singleFormat.format(Calendar.getInstance().getTime());
        }
    };
    flatListContainer.add(new Label("flatlist.date", dateModel));

    flatListContainer.add(new AjaxFallbackLink<Object>("flatlist.refresh") {
        /**
         * unique serialization id.
         */
        private static final long serialVersionUID = 8370439147861506762L;

        @Override
        public void onClick(AjaxRequestTarget target) {

            categoriesModel.detach();
            target.addComponent(flatListContainer);
        }
    });

    flatListContainer.add(new Label("flatlist.userInfo", new LoadableDetachedModel<String>() {
        @Override
        protected String load() { //Kampangenname: Phase: Phasenname vom xx.xx.xx. hh:mm bis xx.xx.xx hh:mm
            StringBuilder sb = new StringBuilder();
            sb.append(campaign.getName());
            sb.append(": Phase: ");
            Procedure currentProcedure = campaign.findCurrentProcedure();
            sb.append(currentProcedure.getName());
            sb.append(" vom ");
            DateFormat df = new SimpleDateFormat("dd.MM.yyyy HH:mm");
            sb.append(df.format(currentProcedure.getStartDate().getTime()));
            sb.append(" bis ");
            sb.append(df.format(currentProcedure.getEndDate().getTime()));
            return sb.toString();
        }
    }));
}

From source file:info.jtrac.wicket.IndividualHeadPanel.java

License:Apache License

/**
 * Constructor./*from   www .j  a  v  a  2  s.com*/
 */
public IndividualHeadPanel() {
    super("individual");

    final Map<String, String> configMap = getJtrac().loadAllConfig();
    Image img = new Image("icon");
    img.add(new AttributeModifier("src", true, new AbstractReadOnlyModel() {
        private static final long serialVersionUID = 1L;

        @Override
        public final Object getObject() {
            // based on some condition return the image source
            String url = configMap.get("jtrac.header.picture");
            if (StringUtils.isBlank(url)) {
                String urlbase = StringUtils.defaultString(configMap.get("jtrac.url.base"),
                        RequestCycle.get().getRequest().getRelativePathPrefixToContextRoot());
                return urlbase + "/resources/jtrac-logo.gif";
            } else
                return url;
        }
    }));
    add(img);
    String message = configMap.get("jtrac.header.text");
    if ((message == null) || ("".equals(message)))
        add(new Label("message", "JTrac - Open Source Issue Tracking System"));
    else if ((message != null) && ("no".equals(message)))
        add(new Label("message", ""));
    else
        add(new Label("message", message));
}