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

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

Introduction

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

Prototype

public final Component setOutputMarkupId(final boolean output) 

Source Link

Document

Sets whether or not component will output id attribute into the markup.

Usage

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

License:Open Source License

/**
 * Construct the panel/*from  w w w .ja v  a 2 s. c o m*/
 * 
 * @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:ch.qos.mistletoe.wicket.TreeExpansionLink.java

License:Open Source License

public TreeExpansionLink(String id) {
    super(id);/*from   w w  w.  j  a v a2  s  .c  om*/
    ResourceReference ref = getControlSymbolResourceReference(expanded);
    Image image = new Image(Constants.TREE_CONTROL_SYMBOL_ID, ref);
    image.setOutputMarkupId(true);

    this.add(image);
}

From source file:com.socialsite.image.ImagePanel.java

License:Open Source License

/**
 * //  w  w w. j  a v a2s.  co  m
 * @param component
 *            component id
 * @param id
 *            id used to fetch the image
 * @param imageType
 *            type of the image (userimage , courseimage etc)
 * @param thumb
 *            will show thumb image if true
 * @param lastModified
 *            lastmodified date of the image
 */
public ImagePanel(final String component, final long id, final ImageType imageType, final Date lastModified,
        final boolean thumb, final boolean changeLink) {
    super(component);

    this.changeLink = changeLink;

    // allow the modal window to update the panel
    setOutputMarkupId(true);
    final ResourceReference imageResource = new ResourceReference(imageType.name());
    final Image userImage;
    final ValueMap valueMap = new ValueMap();
    valueMap.add("id", id + "");

    // the version is used to change the url dynamically if the image is
    // changed. This will allow the browser to cache images
    // reference http://code.google.com/speed/page-speed/docs/caching.html
    // #Use fingerprinting to dynamically enable caching.
    valueMap.add("version", lastModified.getTime() + "");
    if (thumb) {
        valueMap.add("thumb", "true");
    }
    add(userImage = new Image("userimage", imageResource, valueMap));
    userImage.setOutputMarkupId(true);

    final ModalWindow modal;
    add(modal = new ModalWindow("modal"));

    modal.setContent(new UploadPanel(modal.getContentId()) {

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

        @Override
        public String onFileUploaded(final FileUpload upload) {

            if (upload == null || upload.getSize() == 0) {
                // No image was provided
                error("Please upload an image.");
            } else if (!checkContentType(upload.getContentType())) {
                error("Only images of types png, jpg, and gif are allowed.");
            } else {
                saveImage(upload.getBytes());
            }

            return null;
        }

        @Override
        public void onUploadFinished(final AjaxRequestTarget target, final String filename,
                final String newFileUrl) {

            final ResourceReference imageResource = new ResourceReference(imageType.name());

            final ValueMap valueMap = new ValueMap();
            valueMap.add("id", id + "");
            // change the image lively
            valueMap.add("version", new Date().getTime() + "");
            if (thumb) {
                valueMap.add("thumb", "true");
            }

            userImage.setImageResourceReference(imageResource, valueMap);
            // update the image after the user changes it
            target.addComponent(userImage);
        }
    });
    modal.setTitle(" Select the image ");
    modal.setCookieName("modal");

    modal.setCloseButtonCallback(new ModalWindow.CloseButtonCallback() {
        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        public boolean onCloseButtonClicked(final AjaxRequestTarget target) {
            return true;
        }
    });

    modal.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        public void onClose(final AjaxRequestTarget target) {
        }
    });

    add(new AjaxLink<Void>("changeimage") {
        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            if (changeLink) {
                // TODO allow admins to change the university image and
                // allow
                // staffs to change the course image
                // it. don't show it for thumb images
                return hasRole(SocialSiteRoles.OWNER) || hasRole(SocialSiteRoles.STAFF);
            }
            return false;

        }

        @Override
        public void onClick(final AjaxRequestTarget target) {
            modal.show(target);
        }
    });
}

From source file:com.userweave.pages.components.slidableajaxtabpanel.addmethodpanel.AbstractAddPanel.java

License:Open Source License

private void replacePreviewImage(AjaxRequestTarget target) {
    Image replacement = new Image("previewImage",
            new PackageResourceReference(AbstractAddPanel.class, getImageResource(selectedItem)));

    replacement.setOutputMarkupId(true);

    imagePreview.replaceWith(replacement);

    imagePreview = replacement;/*from   ww  w .  j av  a 2s  . co m*/

    target.addComponent(imagePreview);
}

From source file:de.alpharogroup.wicket.components.factory.ComponentFactory.java

License:Apache License

/**
 * Factory method for create a new {@link Image}.
 *
 * @param id//from w w w.j  a v a2 s.  c om
 *            the id
 * @param imageResource
 *            the IResource object
 * @return the new {@link Image}.
 */
public static Image newImage(final String id, final IResource imageResource) {
    final Image image = new Image(id, imageResource);
    image.setOutputMarkupId(true);
    return image;
}

From source file:de.tudarmstadt.ukp.csniper.webapp.support.wicket.AnalysisPanel.java

License:Apache License

public AnalysisPanel(String aId, ParseTreeResource aParseTree) {
    super(aId);/* w  ww.j  a v  a2  s.c om*/

    final Image treeImage = new NonCachingImage("treeImg", aParseTree);
    treeImage.setOutputMarkupId(true);
    add(treeImage);
}

From source file:net.kornr.swit.site.Menu.java

License:Apache License

public Menu(String id) {
    super(id);//from w w  w.  j a  v a  2 s  .c o m

    this.add(new ListView<Pair>("items", s_menus) {
        @Override
        protected void populateItem(ListItem<Pair> item) {
            Pair<String, Class> p = item.getModelObject();

            BookmarkablePageLink link = new BookmarkablePageLink("link", p.getSecond());
            item.add(link);

            Image img;
            if (p.getSecond().equals(m_selectedClass)) {
                link.add(img = ButtonResource.getImage("img", s_button_selected, p.getFirst()));
                link.setEnabled(false);
            } else
                link.add(img = ButtonResource.getImage("img", s_button, p.getFirst()));
            img.setOutputMarkupId(true);
            m_ids.put(p.getFirst(), img.getMarkupId());
        }

    });
}

From source file:net.rrm.ehour.ui.admin.config.panel.SkinConfigPanel.java

License:Open Source License

private Image createPreviewImage() {
    final ImageLogo excelLogo = getConfigService().getExcelLogo();

    int width = excelLogo.getWidth();
    double divideBy = width / 350d;
    double height = (double) excelLogo.getHeight() / divideBy;

    Image img = new Image("excelImage", "img");
    img.setOutputMarkupId(true);
    img.add(AttributeModifier.replace("width", "350"));
    img.add(AttributeModifier.replace("height", Integer.toString((int) height)));

    img.setImageResource(new DynamicImageResource() {
        @Override//w w w  . jav  a 2  s. c  o m
        protected byte[] getImageData(Attributes attributes) {
            return excelLogo.getImageData();
        }
    });
    return img;
}

From source file:org.apache.syncope.client.console.pages.Workflow.java

License:Apache License

public Workflow(final PageParameters parameters) {
    super(parameters);

    WebMarkupContainer noActivitiEnabledForUsers = new WebMarkupContainer("noActivitiEnabledForUsers");
    noActivitiEnabledForUsers.setOutputMarkupPlaceholderTag(true);
    body.add(noActivitiEnabledForUsers);

    WebMarkupContainer workflowDef = new WebMarkupContainer("workflowDefContainer");
    workflowDef.setOutputMarkupPlaceholderTag(true);

    Image workflowDefDiagram = new Image("workflowDefDiagram", new Model<IResource>()) {

        private static final long serialVersionUID = -8457850449086490660L;

        @Override//from w w w . j av  a2 s .c o  m
        protected IResource getImageResource() {
            return new DynamicImageResource() {

                private static final long serialVersionUID = 923201517955737928L;

                @Override
                protected byte[] getImageData(final IResource.Attributes attributes) {
                    return isActivitiEnabledForUsers() ? wfRestClient.getDiagram() : new byte[0];
                }
            };
        }
    };
    workflowDefDiagram.setOutputMarkupId(true);
    workflowDef.add(workflowDefDiagram);

    WorkflowTogglePanel togglePanel = new WorkflowTogglePanel("togglePanel", getPageReference(),
            workflowDefDiagram);
    togglePanel.setOutputMarkupId(true);
    workflowDef.add(togglePanel);

    if (isActivitiEnabledForUsers()) {
        noActivitiEnabledForUsers.setVisible(false);
    } else {
        workflowDef.setVisible(false);
    }

    MetaDataRoleAuthorizationStrategy.authorize(workflowDef, ENABLE, StandardEntitlement.WORKFLOW_DEF_READ);
    body.add(workflowDef);
}

From source file:org.apache.syncope.client.console.wicket.markup.html.form.ImageModalPanel.java

License:Apache License

public ImageModalPanel(final BaseModal<T> modal, final byte[] content, final PageReference pageRef) {
    super(modal, pageRef);

    Image image = new Image("image", new Model<IResource>()) {

        private static final long serialVersionUID = -8457850449086490660L;

        @Override//from  www.  ja v a 2 s .c  o m
        protected IResource getImageResource() {
            return new DynamicImageResource() {

                private static final long serialVersionUID = 923201517955737928L;

                @Override
                protected byte[] getImageData(final IResource.Attributes attributes) {
                    return content;
                }
            };
        }
    };
    image.setOutputMarkupId(true);
    add(image);
}