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

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

Introduction

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

Prototype

public Component add(final Behavior... behaviors) 

Source Link

Document

Adds a behavior modifier to the component.

Usage

From source file:com.evolveum.midpoint.web.component.AsyncUpdatePanel.java

License:Apache License

protected Component getLoadingComponent(final String markupId) {
    Image image = new Image(markupId, PRELOADER);
    image.add(new VisibleEnableBehaviour() {

        @Override//from w  ww  .ja  v  a  2 s .c  o m
        public boolean isVisible() {
            return isLoadingVisible();
        }
    });

    return image;
}

From source file:com.evolveum.midpoint.web.component.prism.PrismObjectPanel.java

License:Apache License

private void initLayout(final IModel<ObjectWrapper> model, ResourceReference image, final Form form) {
    add(createHeader(ID_HEADER, model));

    WebMarkupContainer headerPanel = new WebMarkupContainer("headerPanel");
    headerPanel.add(new AttributeAppender("class", createHeaderClassModel(model), " "));
    //        TODO - attempt to fix row color application when certain actions performed, similar to AssignmentEditorPanel.
    //        headerPanel.add(AttributeModifier.append("class", createHeaderClassModel(model)));
    //        headerPanel.setOutputMarkupId(true);
    add(headerPanel);//from  w w  w .  j a va2s.  c  om
    headerPanel.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return isShowHeader();
        }
    });

    Image shield = new Image("shield", new PackageResourceReference(ImgResources.class, ImgResources.SHIELD));
    shield.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            ObjectWrapper wrapper = model.getObject();
            return wrapper.isProtectedAccount();
        }
    });
    headerPanel.add(shield);

    Label header = new Label("header", createDisplayName(model));
    header.add(new AttributeAppender("class", createHeaderNameClassModel(model), " "));
    header.add(createHeaderOnClickBehaviour(model));
    headerPanel.add(header);
    Label description = new Label("description", createDescription(model));
    description.add(new AttributeModifier("title", createDescription(model)));

    description.add(createHeaderOnClickBehaviour(model));
    headerPanel.add(description);

    Image headerImg = new Image("headerImg", image);
    headerImg.add(createHeaderOnClickBehaviour(model));
    headerPanel.add(headerImg);

    initButtons(headerPanel, model);

    WebMarkupContainer body = new WebMarkupContainer("body");
    body.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            ObjectWrapper wrapper = model.getObject();
            return !wrapper.isMinimalized();
        }
    });
    add(body);

    ListView<ContainerWrapper> containers = new ListView<ContainerWrapper>("containers",
            new PropertyModel<List<ContainerWrapper>>(model, "containers")) {

        @Override
        protected void populateItem(ListItem<ContainerWrapper> item) {
            item.add(new PrismContainerPanel("container", item.getModel(), form));
        }
    };
    containers.setReuseItems(true);
    body.add(containers);
}

From source file:com.evolveum.midpoint.web.component.prism.PrismOptionButtonPanel.java

License:Apache License

private void initButtons(final IModel<ObjectWrapper> model) {
    AjaxLink showEmpty = new AjaxLink("showEmptyButton") {

        @Override/*from   www  .ja va2s.co  m*/
        public void onClick(AjaxRequestTarget target) {
            showEmptyOnClick(target);
        }

    };
    add(showEmpty);

    showEmpty.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !model.getObject().isReadonly();
        }
    });

    Image showEmptyImg = new Image("showEmptyImg", new AbstractReadOnlyModel() {

        @Override
        public Object getObject() {
            ObjectWrapper wrapper = model.getObject();
            if (wrapper.isShowEmpty()) {
                return new PackageResourceReference(PrismObjectPanel.class, "ShowEmptyFalse.png");
            }
            return new PackageResourceReference(PrismObjectPanel.class, "ShowEmptyTrue.png");
        }
    });

    showEmptyImg.add(new AttributeAppender("title", new AbstractReadOnlyModel() {

        @Override
        public Object getObject() {
            ObjectWrapper wrapper = model.getObject();
            if (wrapper.isShowEmpty()) {
                return getString("prismOptionButtonPanel.hideEmpty");
            }
            return getString("prismOptionButtonPanel.showEmpty");
        }
    }, ""));

    showEmpty.add(showEmptyImg);

    AjaxLink minimize = new AjaxLink("minimizeButton") {

        @Override
        public void onClick(AjaxRequestTarget target) {
            minimizeOnClick(target);
        }
    };
    add(minimize);

    Image minimizeImg = new Image("minimizeImg", new AbstractReadOnlyModel() {

        @Override
        public Object getObject() {
            ObjectWrapper wrapper = model.getObject();
            if (wrapper.isMinimalized()) {
                return new PackageResourceReference(PrismObjectPanel.class, "Maximize.png");
            }

            return new PackageResourceReference(PrismObjectPanel.class, "Minimize.png");
        }
    });
    minimizeImg.add(new AttributeAppender("title", new AbstractReadOnlyModel() {

        @Override
        public Object getObject() {
            ObjectWrapper wrapper = model.getObject();
            if (wrapper.isMinimalized()) {
                return getString("prismOptionButtonPanel.maximize");
            }

            return getString("prismOptionButtonPanel.minimize");
        }
    }, ""));

    minimize.add(minimizeImg);
}

From source file:com.googlecode.wicketelements.components.gravatar.GravatarPanel.java

License:Apache License

public GravatarPanel(final String idParam, final String emailParam) {
    super(idParam);
    if (emailParam == null) {
        LOGGER.debug(new StringResourceModel("nullEmailParamLogMessage", this, null).getString());
        addDefaultGravatarImage();/*  w w w  . ja v a 2  s  .  co m*/
    } else {
        try {
            final byte[] hash = MessageDigest.getInstance(MD5).digest(emailParam.getBytes());
            final StringBuilder hashString = new StringBuilder();
            for (final byte elementLocal : hash) {
                final String hex = Integer.toHexString(elementLocal);
                if (hex.length() == 1) {
                    hashString.append(ZERO);
                    hashString.append(hex.charAt(hex.length() - 1));
                } else {
                    hashString.append(hex.substring(hex.length() - 2));
                }
            }
            final Image imgLocal = new Image(WICKET_ID_GRAVATAR_IMG, (IResource) null);
            imgLocal.add(AttributeModifierFactory.newAttributeAppenderForSrc(
                    "http://www.gravatar.com/avatar/" + hashString.toString() + DOT_JPG));
            imgLocal.add(AttributeModifierFactory.newAttributeAppenderForAlt(
                    new StringResourceModel("gravatarAlt", this, null) + emailParam + DOT));
            add(imgLocal);
        } catch (final NoSuchAlgorithmException ex) {
            LOGGER.info(new StringResourceModel("md5HashAlgoNotFoundLogMessage", this, null).getString(), ex);
            addDefaultGravatarImage();
        }
    }
}

From source file:com.googlecode.wicketelements.components.gravatar.GravatarPanel.java

License:Apache License

private void addDefaultGravatarImage() {
    final Image imgLocal = new Image(WICKET_ID_GRAVATAR_IMG, (IResource) null);
    imgLocal.add(AttributeModifierFactory.newAttributeAppenderForSrc(
            new StringResourceModel("defaultGravatarImageHref", this, null).getString()));
    imgLocal.add(AttributeModifierFactory.newAttributeAppenderForAlt(
            new StringResourceModel("defaultGravatarImageAlt", this, null).getString()));
    add(imgLocal);//from  w ww  .  j a  va 2s.  c o m

}

From source file:de.inren.frontend.storehouse.dynamic.TextImagePicturePanel.java

License:Apache License

@Override
protected void onInitialize() {
    super.onInitialize();
    String css = "thumbnail";
    Image picture = new Image("pic", image);
    picture.add(AttributeModifier.replace("alt", image.getText()));
    picture.add(AttributeModifier.replace("title", image.getText()));
    picture.add(AttributeModifier.replace("class", css));
    add(picture);//from ww  w  .  j  a  v a2  s.  c o  m
}

From source file:gr.abiss.calipso.wicket.IconPanel.java

License:Open Source License

public void addIcon(String id, IModel idModel, String iconsFolderName, boolean getSmall) {

    BufferedImage icon = null;/* w  w  w  .j  av a  2 s.co m*/
    long iconId = (Long) idModel.getObject();

    if (iconId != 0) {
        //get image folder path
        String iconFolderPath = CalipsoPropertiesEditor.getHomeFolder(new StringBuffer(iconsFolderName)
                .append(File.separator).append("id").append(iconId).toString());
        File iconFile;
        if (getSmall) {
            iconFile = new File(new StringBuffer(iconFolderPath).append(File.separator).append("icon_small.png")
                    .toString());
        } else {
            iconFile = new File(
                    new StringBuffer(iconFolderPath).append(File.separator).append("icon.png").toString());
        }

        //read image           
        try {
            icon = ImageIO.read(iconFile);
        } catch (IOException e) {
        }
    }

    //modify css classes for the span tag
    SimpleAttributeModifier sam;
    if (getSmall) {
        sam = new SimpleAttributeModifier("class", "iconSmall");
    } else {
        sam = new SimpleAttributeModifier("class", "icon");
    }

    //render html
    if (icon != null) {
        BufferedDynamicImageResource iconResource = new BufferedDynamicImageResource();
        iconResource.setImage(icon);
        Image image = new Image("icon", iconResource);
        image.add(sam);

        add(image);
    } else {
        WebMarkupContainer defaultImage = new WebMarkupContainer("icon");
        if (getSmall) {// if small render the small icon
            defaultImage.add(new SimpleAttributeModifier("src",
                    "../resources/default-" + iconsFolderName + "-icon-small.png"));
        } else {
            defaultImage.add(new SimpleAttributeModifier("src",
                    "../resources/default-" + iconsFolderName + "-icon.png"));
        }
        defaultImage.add(sam);
        add(defaultImage);
    }

}

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.
 *//*from   w  w w . j av a2 s .  c om*/
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.// w  ww .  j  a v a  2 s.  c o  m
 */
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));
}

From source file:name.martingeisse.wicket.panel.javascript.JavascriptImageRadioButtonPanel.java

License:Open Source License

/**
 * Constructor.//from  ww  w .  j a v a2  s . com
 * @param id the wicket id
 * @param group the radio button group this button panel belongs to
 * @param userDataExpression a Javascript expression source text to use for the userData field (passed to the group callback)
 * @param tooltip optional tooltip text
 */
public JavascriptImageRadioButtonPanel(final String id, final JavascriptImageRadioButtonPanelGroup group,
        final String userDataExpression, String tooltip) {
    super(id);
    this.group = group;
    this.userDataExpression = userDataExpression;
    group.getMembers().add(this);
    setOutputMarkupId(true);

    WebMarkupContainer link = new WebMarkupContainer("link");
    add(link);

    Image image = new Image("image",
            new PropertyModel<ResourceReference>(group, "deselectedIconResourceReference"));
    link.add(image);

    if (tooltip != null) {
        image.add(new AttributeModifier("title", Model.of(tooltip)));
    }
}