Example usage for org.apache.wicket.markup.html.form ImageButton ImageButton

List of usage examples for org.apache.wicket.markup.html.form ImageButton ImageButton

Introduction

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

Prototype

public ImageButton(final String id, final String string) 

Source Link

Usage

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 ww  w  .  j  av a 2 s  .  co m*/
    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.swordlord.gozer.components.wicket.action.GWActionBox.java

License:Open Source License

/**
 * @param id/*  w w w  . ja  v a2 s.c om*/
 * @param model
 * @param actionBox
 * @param form
 */
public GWActionBox(String id, IModel<?> model, GActionBox actionBox, final Form<?> form) {
    super(id, model);

    _actionBox = actionBox;

    final GWContext context = getGWContext();
    final GozerController gc = context.getFrameExtension().getGozerController();

    final boolean isModal = context.isModal();

    List<GActionBase> actions = null;

    if (!isModal) {
        actions = filterKnownActions(actionBox, actionBox.getChildren());
    } else {
        actions = getModalActions(actionBox, actionBox.getObjectTree());
    }

    WebMarkupContainer toolbar = new WebMarkupContainer("action_toolbar");
    add(toolbar);

    // validate if this is within an hbox or not
    if (hasVBoxAsParent(actionBox)) {
        toolbar.add(new AttributeModifier("class", new Model<String>("actionbox_halve")));
    }

    ListView<GActionBase> listView = new ListView<GActionBase>("eachAction", actions) {
        @Override
        protected void populateItem(ListItem<GActionBase> item) {
            GActionBase ob = item.getModelObject();

            if (context.isModal()) {
                DataBinding dataBinding = new DataBinding(ob);

                ImageButton panel = new ImageButton(ACTION_WICKET_ID, "");
                panel.setEnabled(false);
                panel.setVisible(false);
                item.add(panel);

                if (ob.getClass().equals(GCancelAction.class)) {
                    item.add(new GWModalCancelButton(ACTION_PANEL_WICKET_ID, gc, context, dataBinding));
                } else if (ob.getClass().equals(GOKAction.class)) {
                    item.add(new GWModalOKButton(ACTION_PANEL_WICKET_ID, gc, context, dataBinding));
                }
            } else {
                Panel panel = new EmptyPanel(ACTION_PANEL_WICKET_ID);
                panel.setEnabled(false);
                panel.setVisible(false);
                item.add(panel);

                if (ob.getClass().equals(GNewAction.class)) {
                    item.add(new GWNewButton(ACTION_WICKET_ID, gc, ob, form));
                } else if (ob.getClass().equals(GCancelAction.class)) {
                    item.add(new GWCancelButton(ACTION_WICKET_ID, gc, ob, form));
                } else if (ob.getClass().equals(GDeleteAction.class)) {
                    item.add(new GWDeleteButton(ACTION_WICKET_ID, gc, ob, form));
                } else if (ob.getClass().equals(GDetailAction.class)) {
                    item.add(new GWDetailButton(ACTION_WICKET_ID, gc, ob));
                } else if (ob.getClass().equals(GPersistAction.class)) {
                    item.add(new GWPersistButton(ACTION_WICKET_ID, gc, ob, form));
                } else if (ob.getClass().equals(GGoBackAction.class)) {
                    item.add(new GWGoBackButton(ACTION_WICKET_ID, gc, ob));
                } else if (ob.getClass().equals(GEditAction.class)) {
                    item.add(new GWEditButton(ACTION_WICKET_ID, gc, ob, form));
                } else if (ob.getClass().equals(GFopAction.class)) {
                    item.add(new GWFopButton(ACTION_WICKET_ID, gc, ob));
                } else if (ob.getClass().equals(GReportAction.class)) {
                    item.add(new GWReportButton(ACTION_WICKET_ID, gc, (GReportAction) ob));
                } else if (ob.getClass().equals(GCsvAction.class)) {
                    item.add(new GWCsvButton(ACTION_WICKET_ID, gc, ob));
                } else if (ob.getClass().equals(GAddAction.class)) {
                    item.add(new GWAddButton(ACTION_WICKET_ID, gc, ob, form));
                } else if (ob.getClass().equals(GAddReferenceAction.class)) {
                    item.add(new GWAddReferenceButton(ACTION_WICKET_ID, gc, ob, form));
                } else if (ob.getClass().equals(GRemoveAction.class)) {
                    item.add(new GWRemoveButton(ACTION_WICKET_ID, gc, ob, form));
                } else if (ob.getClass().equals(GOtherAction.class)) {
                    item.add(new GWOtherButton(ACTION_WICKET_ID, gc, ob, form));
                } else {
                    LOG.error("Something went completely wrong. There is no check for the current class: "
                            + ob.getClass());
                    item.add(new WebMarkupContainer(ACTION_WICKET_ID).setVisible(false));
                }
            }
        }
    };

    listView.setReuseItems(true);

    toolbar.add(listView);

    if (actions.size() == 0) {
        toolbar.setVisible(false);
        this.setVisible(false);
    }
}

From source file:com.swordlord.gozer.components.wicket.ActionBaseListView.java

License:Open Source License

@Override
protected void populateItem(ListItem<GActionBase> item) {
    GActionBase ob = item.getModelObject();

    if (_context.isModal()) {
        DataBinding dataBinding = new DataBinding(_ob);

        ImageButton panel = new ImageButton(ACTION_WICKET_ID, "");
        panel.setEnabled(false);//from  www . j  a  va 2s.  c  om
        panel.setVisible(false);
        item.add(panel);

        if (ob.getClass().equals(GCancelAction.class)) {
            item.add(new GWModalCancelButton(ACTION_PANEL_WICKET_ID, _gc, _context, dataBinding));
        } else if (ob.getClass().equals(GOKAction.class)) {
            item.add(new GWModalOKButton(ACTION_PANEL_WICKET_ID, _gc, _context, dataBinding));
        }
    } else {
        Panel panel = new EmptyPanel(ACTION_PANEL_WICKET_ID);
        panel.setEnabled(false);
        panel.setVisible(false);
        item.add(panel);

        if (ob.getClass().equals(GNewAction.class)) {
            item.add(new GWNewButton(ACTION_WICKET_ID, _gc, ob, _form));
        } else if (ob.getClass().equals(GCancelAction.class)) {
            item.add(new GWCancelButton(ACTION_WICKET_ID, _gc, ob, _form));
        } else if (ob.getClass().equals(GDeleteAction.class)) {
            item.add(new GWDeleteButton(ACTION_WICKET_ID, _gc, ob, _form));
        } else if (ob.getClass().equals(GDetailAction.class)) {
            item.add(new GWDetailButton(ACTION_WICKET_ID, _gc, ob));
        } else if (ob.getClass().equals(GPersistAction.class)) {
            item.add(new GWPersistButton(ACTION_WICKET_ID, _gc, ob, _form));
        } else if (ob.getClass().equals(GGoBackAction.class)) {
            item.add(new GWGoBackButton(ACTION_WICKET_ID, _gc, ob));
        } else if (ob.getClass().equals(GEditAction.class)) {
            item.add(new GWEditButton(ACTION_WICKET_ID, _gc, ob, _form));
        } else if (ob.getClass().equals(GFopAction.class)) {
            item.add(new GWFopButton(ACTION_WICKET_ID, _gc, ob));
        } else if (ob.getClass().equals(GReportAction.class)) {
            item.add(new GWReportButton(ACTION_WICKET_ID, _gc, (GReportAction) ob));
        } else if (ob.getClass().equals(GCsvAction.class)) {
            item.add(new GWCsvButton(ACTION_WICKET_ID, _gc, ob));
        } else if (ob.getClass().equals(GAddAction.class)) {
            item.add(new GWAddButton(ACTION_WICKET_ID, _gc, ob, _form));
        } else if (ob.getClass().equals(GAddReferenceAction.class)) {
            item.add(new GWAddReferenceButton(ACTION_WICKET_ID, _gc, ob, _form));
        } else if (ob.getClass().equals(GRemoveAction.class)) {
            item.add(new GWRemoveButton(ACTION_WICKET_ID, _gc, ob, _form));
        } else if (ob.getClass().equals(GToggleAction.class)) {
            item.add(new GWToggleButton(ACTION_WICKET_ID, _gc, ob, _form));
        } else if (ob.getClass().equals(GOtherAction.class)) {
            item.add(new GWOtherButton(ACTION_WICKET_ID, _gc, ob, _form));
        }

        else {
            LOG.error("ActionListView can not render the current class: " + ob.getClass());
            item.add(new WebMarkupContainer(ACTION_WICKET_ID).setVisible(false));
        }
    }
}

From source file:com.userweave.pages.test.NextButton.java

License:Open Source License

public NextButton(String id) {
    super(id);//from w ww  . j  a  v  a2  s .  c om
    imagebutton = new ImageButton("nextButton", new PackageResourceReference(NextButton.class, getImage()));

    add(imagebutton);

    Label l = new Label("value", new ResourceModel("next"));
    add(l);
}

From source file:jp.xet.uncommons.wicket.social.SocialLoginFormPanel.java

License:Apache License

/**
 * TODO for daisuke/*from  w  w  w. ja  v  a 2 s  .  c  o m*/
 * 
 * @return
 * @since 1.0
 */
protected Component createForm() {
    return new Form<Void>(FORM_ID) {

        @Override
        protected boolean getStatelessHint() {
            return true;
        }

        @Override
        protected void onSubmit() {
            SocialLoginFormPanel.this.onSubmit();
        }
    }.add(new ImageButton(IMAGE_ID, getButtonImageResource()));
}