Example usage for org.apache.wicket.ajax.markup.html AjaxLink AjaxLink

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

Introduction

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

Prototype

public AjaxLink(final String id) 

Source Link

Document

Construct.

Usage

From source file:com.doculibre.constellio.wicket.panels.admin.analyzer.filter.AddEditFilterPanel.java

License:Open Source License

public AddEditFilterPanel(String id, AnalyzerFilter filter, int index) {
    super(id, true);
    this.entityModel = new ReloadableEntityModel<AnalyzerFilter>(filter);
    // Ne pas utiliser filter.getID() pour dterminer si c'est en cration.
    // Car cela empche de modifier un filtre tout juste cr
    this.index = index;

    Form form = getForm();//from   ww  w.  j  av a  2s .com
    form.setModel(new CompoundPropertyModel(entityModel));

    final ModalWindow filterClassModal = new ModalWindow("filterClassModal");
    form.add(filterClassModal);
    filterClassModal.setCssClassName(ModalWindow.CSS_CLASS_GRAY);

    IModel filterClassesModel = new LoadableDetachableModel() {
        @Override
        protected Object load() {
            FilterClassServices filterClassServices = ConstellioSpringUtils.getFilterClassServices();
            return filterClassServices.list();
        }
    };

    IChoiceRenderer filterClassRenderer = new ChoiceRenderer("className");

    final DropDownChoice filterClassField = new DropDownChoice("filterClass", filterClassesModel,
            filterClassRenderer);
    form.add(filterClassField);
    filterClassField.setOutputMarkupId(true);

    AjaxLink addFilterClassLink = new AjaxLink("addFilterClassLink") {
        @Override
        public void onClick(AjaxRequestTarget target) {
            AddEditFilterClassPanel addEditAnalyzerClassPanel = new AddEditFilterClassPanel(
                    filterClassModal.getContentId(), new FilterClass(), filterClassField);
            filterClassModal.setContent(addEditAnalyzerClassPanel);
            filterClassModal.show(target);
        }
    };
    form.add(addFilterClassLink);

    form.add(new CheckBox("ignoreCase"));
    form.add(new CheckBox("expand"));
    form.add(new CheckBox("enablePositionIncrements"));
    form.add(new CheckBox("inject"));
    form.add(new TextField("language"));
    form.add(new TextArea("wordsText"));
    form.add(new TextArea("synonymsText"));
    form.add(new TextArea("protectedText"));
    form.add(new TextField("generateWordParts", Integer.class));
    form.add(new TextField("generateNumberParts", Integer.class));
    form.add(new TextField("catenateWords", Integer.class));
    form.add(new TextField("catenateNumbers", Integer.class));
    form.add(new TextField("catenateAll", Integer.class));
    form.add(new TextField("splitOnCaseChange", Integer.class));
    form.add(new TextField("delimiter"));
    form.add(new TextField("encoder"));
    form.add(new TextField("pattern"));
    form.add(new TextField("replacement"));
    form.add(new TextField("replace"));
}

From source file:com.doculibre.constellio.wicket.panels.admin.analyzer.filter.FilterListPanel.java

License:Open Source License

@Override
protected WebMarkupContainer createDeleteLink(String id, final IModel entityModel, final int index) {
    return new AjaxLink(id) {
        @Override/*from w  w w  .  j a  v a 2 s. c  om*/
        public void onClick(AjaxRequestTarget target) {
            AddEditAnalyzerFieldPanel addEditAnalyzerFieldPanel = (AddEditAnalyzerFieldPanel) findParent(
                    AddEditAnalyzerFieldPanel.class);
            addEditAnalyzerFieldPanel.getFilters().remove(index);
            target.addComponent(FilterListPanel.this);
        }

        @Override
        protected IAjaxCallDecorator getAjaxCallDecorator() {
            return new AjaxCallDecorator() {
                @Override
                public CharSequence decorateScript(CharSequence script) {
                    String confirmMsg = getLocalizer().getString("confirmDelete", FilterListPanel.this);
                    return "if (confirm('" + confirmMsg + "')) {" + script + "} else { return false; }";
                }
            };
        }
    };
}

From source file:com.doculibre.constellio.wicket.panels.admin.categorization.rules.CategorizationRuleListPanel.java

License:Open Source License

@Override
protected WebMarkupContainer createDeleteLink(String id, final IModel entityModel, final int index) {
    return new AjaxLink(id) {
        @Override/*from www  .  java  2  s  . c o m*/
        public void onClick(AjaxRequestTarget target) {
            AddEditCategorizationPanel addEditCategorizationPanel = (AddEditCategorizationPanel) findParent(
                    AddEditCategorizationPanel.class);
            addEditCategorizationPanel.getRules().remove(index);
            target.addComponent(CategorizationRuleListPanel.this);
        }

        @Override
        protected IAjaxCallDecorator getAjaxCallDecorator() {
            return new AjaxCallDecorator() {
                @Override
                public CharSequence decorateScript(CharSequence script) {
                    String confirmMsg = getLocalizer().getString("confirmDelete",
                            CategorizationRuleListPanel.this);
                    return "if (confirm('" + confirmMsg + "')) {" + script + "} else { return false; }";
                }
            };
        }
    };
}

From source file:com.doculibre.constellio.wicket.panels.admin.categorization.rules.values.CategorizationRuleValueListPanel.java

License:Open Source License

@Override
protected WebMarkupContainer createDeleteLink(String id, final IModel entityModel, final int index) {
    return new AjaxLink(id) {
        @Override//from  www  .  jav a  2  s.c om
        public void onClick(AjaxRequestTarget target) {
            AddEditCategorizationRulePanel addEditCategorizationRulePanel = (AddEditCategorizationRulePanel) findParent(
                    AddEditCategorizationRulePanel.class);
            addEditCategorizationRulePanel.getValues().remove(index);
            target.addComponent(CategorizationRuleValueListPanel.this);
        }

        @Override
        protected IAjaxCallDecorator getAjaxCallDecorator() {
            return new AjaxCallDecorator() {
                @Override
                public CharSequence decorateScript(CharSequence script) {
                    String confirmMsg = getLocalizer().getString("confirmDelete",
                            CategorizationRuleValueListPanel.this);
                    return "if (confirm('" + confirmMsg + "')) {" + script + "} else { return false; }";
                }
            };
        }
    };
}

From source file:com.doculibre.constellio.wicket.panels.admin.collection.CollectionListPanel.java

License:Open Source License

@Override
protected List<IColumn> getDataColumns() {
    List<IColumn> dataColumns = super.getDataColumns();

    IColumn descriptionColumn = new PropertyColumn(new StringResourceModel("description", this, null),
            "description") {
        @Override/* w w  w .jav  a  2s  .c om*/
        protected IModel createLabelModel(final IModel embeddedModel) {
            return new LoadableDetachableModel() {
                @Override
                protected Object load() {
                    RecordCollection collection = (RecordCollection) embeddedModel.getObject();
                    return collection.getDescription(getLocale());
                }
            };
        }

    };
    dataColumns.add(descriptionColumn);
    // Move up
    dataColumns.add(new HeaderlessColumn() {
        @Override
        public void populateItem(Item cellItem, String componentId, final IModel rowModel) {
            cellItem.add(new ImgLinkHolder(componentId) {
                @Override
                protected WebMarkupContainer newLink(String id) {
                    return new AjaxLink(id) {
                        @Override
                        public void onClick(AjaxRequestTarget target) {
                            RecordCollectionServices collectionServices = ConstellioSpringUtils
                                    .getRecordCollectionServices();
                            RecordCollection collection = (RecordCollection) rowModel.getObject();
                            List<RecordCollection> collections = collectionServices.list();
                            int index = collections.indexOf(collection);
                            // Cannot move higher!
                            if (index > 0) {
                                RecordCollection previousCollection = collections.get(index - 1);
                                Integer previousPosition = previousCollection.getPosition();
                                Integer currentPosition = collection.getPosition();
                                collection.setPosition(previousPosition);
                                previousCollection.setPosition(currentPosition);

                                EntityManager entityManager = ConstellioPersistenceContext
                                        .getCurrentEntityManager();
                                if (!entityManager.getTransaction().isActive()) {
                                    entityManager.getTransaction().begin();
                                }
                                collectionServices.makePersistent(collection, false);
                                collectionServices.makePersistent(previousCollection, false);
                                entityManager.getTransaction().commit();
                                entityManager.clear();

                                target.addComponent(findParent(CollectionListPanel.class));
                            }
                        }
                    };
                }

                @Override
                protected Component newImg(String id) {
                    return new NonCachingImage(id,
                            new ResourceReference(BaseConstellioPage.class, "images/up.png"));
                }
            });
        }
    });

    // Move down
    dataColumns.add(new HeaderlessColumn() {
        @Override
        public void populateItem(Item cellItem, String componentId, final IModel rowModel) {
            cellItem.add(new ImgLinkHolder(componentId) {
                @Override
                protected WebMarkupContainer newLink(String id) {
                    return new AjaxLink(id) {
                        @Override
                        public void onClick(AjaxRequestTarget target) {
                            RecordCollectionServices collectionServices = ConstellioSpringUtils
                                    .getRecordCollectionServices();
                            RecordCollection collection = (RecordCollection) rowModel.getObject();
                            List<RecordCollection> collections = collectionServices.list();
                            int index = collections.indexOf(collection);
                            // Cannot move lower!
                            if (index < collections.size() - 1) {
                                RecordCollection nextCollection = collections.get(index + 1);
                                Integer nextPosition = nextCollection.getPosition();
                                Integer currentPosition = collection.getPosition();
                                collection.setPosition(nextPosition);
                                nextCollection.setPosition(currentPosition);

                                EntityManager entityManager = ConstellioPersistenceContext
                                        .getCurrentEntityManager();
                                if (!entityManager.getTransaction().isActive()) {
                                    entityManager.getTransaction().begin();
                                }
                                collectionServices.makePersistent(collection, false);
                                collectionServices.makePersistent(nextCollection, false);
                                entityManager.getTransaction().commit();
                                entityManager.clear();

                                target.addComponent(findParent(CollectionListPanel.class));
                            }
                        }
                    };
                }

                @Override
                protected Component newImg(String id) {
                    return new NonCachingImage(id,
                            new ResourceReference(BaseConstellioPage.class, "images/down.png"));
                }
            });
        }
    });

    IColumn searchColumn = new HeaderlessColumn() {
        @Override
        public void populateItem(Item cellItem, String componentId, final IModel rowModel) {
            cellItem.add(new LinkHolder(componentId) {
                @Override
                protected WebMarkupContainer newLink(String id) {
                    RecordCollection collection = (RecordCollection) rowModel.getObject();
                    SimpleSearch simpleSearch = new SimpleSearch();
                    simpleSearch.setCollectionName(collection.getName());
                    PageFactoryPlugin pageFactoryPlugin = PluginFactory.getPlugin(PageFactoryPlugin.class);
                    return new BookmarkablePageLink(id, pageFactoryPlugin.getSearchFormPage(),
                            SearchFormPage.getParameters(simpleSearch));
                }

                @Override
                protected IModel getLabelModel() {
                    return new StringResourceModel("search", null);
                }
            });
        }
    };
    dataColumns.add(searchColumn);
    return dataColumns;
}

From source file:com.doculibre.constellio.wicket.panels.admin.connector.schedule.TimeIntervalListPanel.java

License:Open Source License

@Override
protected WebMarkupContainer createDeleteLink(String id, final IModel entityModel,
        final int timeIntervalIndex) {
    return new AjaxLink(id) {
        @Override//from  w w  w  .ja v a 2s  .com
        public void onClick(AjaxRequestTarget target) {
            AddEditConnectorPanel addEditConnectorPanel = (AddEditConnectorPanel) findParent(
                    AddEditConnectorPanel.class);
            List<SerializableScheduleTimeInterval> timeIntervals = addEditConnectorPanel.getSchedule()
                    .getTimeIntervals();
            timeIntervals.remove(timeIntervalIndex);
            target.addComponent(TimeIntervalListPanel.this);
            if (timeIntervals.isEmpty()) {
                addEditConnectorPanel.getDisabledScheduleField().setModelObject(true);
                target.addComponent(addEditConnectorPanel.getDisabledScheduleField());
            }
        }

        @Override
        protected IAjaxCallDecorator getAjaxCallDecorator() {
            return new AjaxCallDecorator() {
                @Override
                public CharSequence decorateScript(CharSequence script) {
                    String confirmMsg = getLocalizer().getString("confirmDelete", TimeIntervalListPanel.this);
                    return "if (confirm('" + confirmMsg + "')) {" + script + "} else { return false; }";
                }
            };
        }
    };
}

From source file:com.doculibre.constellio.wicket.panels.admin.connectorTypeMeta.AddEditConnectorTypeMetaMappingPanel.java

License:Open Source License

public AddEditConnectorTypeMetaMappingPanel(String id, ConnectorTypeMetaMapping metaMapping) {
    super(id, true);
    this.metaMappingModel = new ReloadableEntityModel<ConnectorTypeMetaMapping>(metaMapping);

    Form form = getForm();//from w  ww  . j  a va 2 s . c o  m
    form.setModel(new CompoundPropertyModel(metaMappingModel));

    TextField metaNameField = new RequiredTextField("metaName");
    metaNameField.add(new StringValidator.MaximumLengthValidator(255));
    form.add(metaNameField);

    TextField indexFieldNameField = new RequiredTextField("indexFieldName");
    indexFieldNameField.add(new StringValidator.MaximumLengthValidator(255));
    form.add(indexFieldNameField);

    final CheckBox indexedCheckbox = new CheckBox("indexed");
    form.add(indexedCheckbox);

    //        final CheckBox storedCheckbox = new CheckBox("stored");
    //        form.add(storedCheckbox);

    final CheckBox multiValuedCheckbox = new CheckBox("multiValued");
    form.add(multiValuedCheckbox);

    final ModalWindow fieldTypeModal = new ModalWindow("fieldTypeModal");
    form.add(fieldTypeModal);
    fieldTypeModal.setCssClassName(ModalWindow.CSS_CLASS_GRAY);

    IModel fieldTypesModel = new LoadableDetachableModel() {
        @Override
        protected Object load() {
            FieldTypeServices fieldTypeServices = ConstellioSpringUtils.getFieldTypeServices();
            return fieldTypeServices.list();
        }
    };

    IChoiceRenderer fieldTypeRenderer = new ChoiceRenderer("name");

    final DropDownChoice fieldTypeField = new DropDownChoice("fieldType", fieldTypesModel, fieldTypeRenderer);
    form.add(fieldTypeField);
    fieldTypeField.setOutputMarkupId(true);

    AjaxLink addFieldTypeLink = new AjaxLink("addFieldTypeLink") {
        @Override
        public void onClick(AjaxRequestTarget target) {
            AddEditFieldTypePanel addEditFieldTypePanel = new AddEditFieldTypePanel(
                    fieldTypeModal.getContentId(), new FieldType(), fieldTypeField);
            fieldTypeModal.setContent(addEditFieldTypePanel);
            fieldTypeModal.show(target);
        }
    };
    form.add(addFieldTypeLink);
}

From source file:com.doculibre.constellio.wicket.panels.admin.crud.CRUDPanel.java

License:Open Source License

private void initComponents() {
    if (isUseModalsAddEdit()) {
        addLink = new AjaxLink("addLink") {
            @Override/*from   w ww  .  j a  va 2  s .  co m*/
            public void onClick(AjaxRequestTarget target) {
                String addMsg = getLocalizer().getString("add", CRUDPanel.this);
                addModal.setTitle(addMsg);

                WebMarkupContainer addContent = createAddContent(addModal.getContentId());
                addModal.setContent(addContent);
                addModal.show(target);
            }

            @Override
            public boolean isVisible() {
                return super.isVisible() && isAddLink();
            }
        };
    } else {
        addLink = new Link("addLink") {
            @Override
            public void onClick() {
                WebMarkupContainer addContent = createAddContent(CRUDPanel.this.getId());
                CRUDPanel.this.replaceWith(addContent);
            }

            @Override
            public boolean isVisible() {
                return super.isVisible() && isAddLink();
            }
        };
    }
    add(addLink);

    addModal = new ModalWindow("addModal");
    addModal.setInitialHeight(MODAL_HEIGHT);
    addModal.setInitialWidth(MODAL_WIDTH);
    addModal.setCssClassName(CSS_MODAL);
    add(addModal);
}

From source file:com.doculibre.constellio.wicket.panels.admin.crud.CRUDPanel.java

License:Open Source License

protected IColumn getEditLinkColumn() {
    return new HeaderlessColumn() {
        @Override/*ww  w  .ja v a 2  s. c om*/
        public void populateItem(Item cellItem, String componentId, final IModel rowItemModel) {
            Item rowItem = (Item) cellItem.findParent(Item.class);
            final int rowIndex = getFirstRowItemAbsoluteIndex() + rowItem.getIndex();
            cellItem.add(new ModalImgLinkHolder(componentId) {
                @Override
                public WebMarkupContainer newLink(String id) {
                    if (isUseModalsAddEdit()) {
                        return new AjaxLink(id) {
                            @Override
                            public void onClick(AjaxRequestTarget target) {
                                ModalWindow editModal = getModalWindow();
                                editModal.setInitialHeight(MODAL_HEIGHT);
                                editModal.setInitialWidth(MODAL_WIDTH);
                                String editMsg = getLocalizer().getString("edit", CRUDPanel.this);
                                editModal.setTitle(editMsg);

                                WebMarkupContainer editContent = createEditContent(editModal.getContentId(),
                                        rowItemModel, rowIndex);
                                editModal.setContent(editContent);
                                editModal.show(target);
                            }

                            @Override
                            public boolean isVisible() {
                                return super.isVisible() && isEditLink(rowItemModel, rowIndex);
                            }
                        };
                    } else {
                        return new Link(id) {
                            @Override
                            public void onClick() {
                                WebMarkupContainer editContent = createEditContent(CRUDPanel.this.getId(),
                                        rowItemModel, rowIndex);
                                CRUDPanel.this.replaceWith(editContent);
                            }

                            @Override
                            public boolean isVisible() {
                                return super.isVisible() && isEditLink(rowItemModel, rowIndex);
                            }
                        };
                    }
                }

                @Override
                protected Component newImg(String id) {
                    return new NonCachingImage(id,
                            new ResourceReference(BaseConstellioPage.class, "images/ico_crayon.png"));
                }
            });
        }

        @Override
        public String getCssClass() {
            return "aligncenter width50px";
        }
    };
}

From source file:com.doculibre.constellio.wicket.panels.admin.crud.CRUDPanel.java

License:Open Source License

protected WebMarkupContainer createDeleteLink(String id, final IModel rowItemModel, final int index) {
    return new AjaxLink(id) {
        @Override/*from w ww .  ja v  a 2 s .c  o  m*/
        public void onClick(AjaxRequestTarget target) {
            onClickDeleteLink(rowItemModel, target, index);
        }

        @Override
        protected IAjaxCallDecorator getAjaxCallDecorator() {
            return new AjaxCallDecorator() {
                @Override
                public CharSequence decorateScript(CharSequence script) {
                    String confirmMsg = getLocalizer().getString("confirmDelete", CRUDPanel.this);
                    return "if (confirm('" + confirmMsg + "')) {" + script + "} else { return false; }";
                }
            };
        }

        @Override
        public boolean isVisible() {
            return super.isVisible() && isDeleteLink(rowItemModel, index);
        }
    };
}