Example usage for org.apache.wicket.extensions.ajax.markup.html AjaxEditableLabel AjaxEditableLabel

List of usage examples for org.apache.wicket.extensions.ajax.markup.html AjaxEditableLabel AjaxEditableLabel

Introduction

In this page you can find the example usage for org.apache.wicket.extensions.ajax.markup.html AjaxEditableLabel AjaxEditableLabel.

Prototype

public AjaxEditableLabel(final String id) 

Source Link

Document

Constructor

Usage

From source file:cz.zcu.kiv.eegdatabase.wui.ui.experiments.metadata.template.TemplatePropertyPanel.java

License:Apache License

private void setupComponents(final IModel<Property> model) {

    add(new AjaxEditableLabel<String>("name") {

        private static final long serialVersionUID = 1L;

        @Override//from w w  w  . j a v  a  2 s.  c o m
        protected String defaultNullLabel() {
            return ResourceUtils.getString("text.template.empty.propertyName");
        }

    });
    add(new PropertyMultiValuePanel("value", model));
    add(new AjaxEditableMultiLineLabel<String>("definition", new PropertyModel(model, "definition") {

        private static final long serialVersionUID = 1L;

        // TODO remove this if java odml lib will be upgraded, bug fix with definition setter.

        @Override
        public void setObject(Object object) {
            super.setObject(object == null ? "" : object);
        }

    }) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onConfigure() {
            super.onConfigure();
            setVisible(TemplatePropertyPanel.this.viewModel.isDefinitionVisible());
        }

        @Override
        protected String defaultNullLabel() {
            return ResourceUtils.getString("text.template.empty.property.definition");
        }
    });

    add(new AjaxLink<Void>("remove-property") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            Property property = (Property) TemplatePropertyPanel.this.getDefaultModelObject();
            property.getParent().removeProperty(property.getName());

            target.add(container);
        }

    });

    add(new AjaxCheckBox("required", new PropertyModel<Boolean>(model.getObject(), "guiHelper.required")) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            target.add(this);
        }
    }.setOutputMarkupId(true));
}

From source file:cz.zcu.kiv.eegdatabase.wui.ui.experiments.metadata.template.TemplateSectionPanel.java

License:Apache License

private void setupHeadAndControlComponents(final IModel<Section> model, final List<Section> choices) {
    // head + control
    final boolean notRootSection = model.getObject().getParent() != null;

    head.add(new AjaxEditableLabel<String>("name") {

        private static final long serialVersionUID = 1L;

        @Override//  w  w  w.  j  a va2  s .com
        protected String defaultNullLabel() {

            if (notRootSection) {
                return ResourceUtils.getString("text.template.empty.sectionName");
            } else {
                return ResourceUtils.getString("text.template.empty.templateName");
            }
        }
    });

    String key;
    if (notRootSection) {
        key = "label.template.section";
    } else {
        key = "label.template.templateName";
    }

    head.add(new Label("sectionNameLabel", ResourceUtils.getString(key)));

    head.add(new AjaxEditableMultiLineLabel<String>("definition") {

        private static final long serialVersionUID = 1L;

        @Override
        protected String defaultNullLabel() {
            return ResourceUtils.getString("text.template.empty.section.definition");
        }

        @Override
        protected void onConfigure() {
            super.onConfigure();
            setVisible(viewModel.isDefinitionVisible());
        }
    }.setVisibilityAllowed(notRootSection));

    final DropDownChoice<Section> sectionList = new DropDownChoice<Section>("addSubsectionList",
            new Model<Section>(), choices, new ChoiceRenderer<Section>("name"));
    sectionList.setOutputMarkupId(true);
    head.add(sectionList);
    sectionList.add(new AjaxFormComponentUpdatingBehavior("onChange") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            Section section = sectionList.getModelObject();
            try {
                section = section.copy();
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }

            TemplateSectionPanel.this.model.getObject().add(section);
            sectionList.setModelObject(null);
            target.add(mainContainer);
        }

    });

    head.add(new AjaxLink<Void>("removeSection") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {

            Section section = TemplateSectionPanel.this.model.getObject();

            section.getParent().removeSection(section);
            target.add(mainContainer);
        }

    }.setVisibilityAllowed(notRootSection));

    head.add(new AjaxLink<Void>("showhideSectionContent") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {

            content.setVisible(!content.isVisible());
            target.add(content);
        }

    });

    head.add(new AjaxLink<Void>("addProperty") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {

            try {
                Property property = new Property(
                        ResourceUtils.getString("text.template.empty.propertyName") + propertySuffix++,
                        ResourceUtils.getString("text.template.empty.propertyValue"));
                TemplateSectionPanel.this.model.getObject().add(property);
            } catch (Exception e) {
                e.printStackTrace();
            }
            target.add(mainContainer);
        }

    }.setVisibilityAllowed(notRootSection));
}

From source file:pl.klimczakowie.cpublication2.web.view.base.BaseCriteriaTablePage.java

License:Apache License

/**
 * Constructor that is invoked when page is invoked without a session.
 * //w  w  w  .  j a v a2  s.com
 * @param parameters
 *            Page parameters
 */
@SuppressWarnings("rawtypes")
public BaseCriteriaTablePage(final PageParameters parameters) {
    super(parameters);
    reRender = new ReRenderComponentProvider();

    // TABLE
    GenericSortableDataProvider<T, M> dataProvider = new GenericSortableDataProvider<T, M>(
            getPersistenceReference(), this);
    table = new AjaxFallbackDefaultDataTable<T, String>("table", getColumns(), dataProvider, getRowsPerPage());

    criteriaWMC = new WebMarkupContainer("criteriaWMC");
    criteriaWMC.setOutputMarkupId(true);
    criteriaWMC.add(new DataView<CriterionDTO>("criterionList", new CriteriaDataProvider()) {
        private static final long serialVersionUID = 2544212454413843168L;

        @SuppressWarnings("unchecked")
        @Override
        protected void populateItem(final Item<CriterionDTO> item) {
            final StaticImage pencil = new StaticImage("pencil", "pencil.png");

            item.add(new Label("displayName"));
            item.add(new Label("type"));
            item.add(new AjaxEditableLabel<Object>("stringValue") {
                private static final long serialVersionUID = -8211904925503430617L;

                @Override
                protected void onSubmit(final AjaxRequestTarget target) {
                    super.onSubmit(target);
                    getCriteria().set(item.getModelObject());
                    reRender.reRenderComponents(target);
                }

                protected Component newLabel(final MarkupContainer parent, final String componentId,
                        final IModel<Object> model) {
                    pencil.add(new LabelAjaxBehavior(getLabelAjaxEvent()));
                    return super.newLabel(parent, componentId, model);
                }
            });

            item.add(pencil);
            item.add(new CriteriaRemoveLink("remove", item.getModelObject()));
        }
    });

    reRender.addReRenderComponent(table, getRefreshDuration());
    reRender.addReRenderComponent(criteriaWMC);

    add(criteriaWMC);
    add(table);
    add(new ModalWindowActionPanel<Criterion<M>>("addCriterion", "Add new search criterion",
            new CriteriumToModalProvider(reRender)));
}