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

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

Introduction

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

Prototype

public MarkupContainer add(final Component... children) 

Source Link

Document

Adds the child component(s) to this container.

Usage

From source file:com.axway.ats.testexplorer.pages.runsByTypeDashboard.home.RunsByTypeDashboardHomePage.java

License:Apache License

public RunsByTypeDashboardHomePage(PageParameters parameters) {

    super(parameters);

    addNavigationLink(WelcomePage.class, new PageParameters(), "Home", null);

    filter = new Filter();

    add(filter);/*from   ww w .  j  a  va2 s.  com*/

    filter.performSearchOnPageLoad();

    AjaxLink<String> modalTooltip = new AjaxLink<String>("modalTooltip") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {

        }
    };
    //        modalTooltip.
    modalTooltip.add(new WebMarkupContainer("helpButton"));

    add(modalTooltip);

    TestExplorerSession session = (TestExplorerSession) Session.get();

    try {
        jsonDatas = new DashboardHomeUtils().initJsonData(filter.getSelectedProductAndVersionNames(),
                session.getDbReadConnection().getAllBuildTypes("AND 1=1"));
    } catch (DatabaseAccessException e) {
        error("Unable to perform initial search");
        LOG.error("Unable to perform initial search", e);
    }

}

From source file:com.axway.ats.testexplorer.pages.runsByTypeDashboard.run.RunsByTypeDashboardRunPage.java

License:Apache License

public RunsByTypeDashboardRunPage(PageParameters parameters) {

    super(parameters);

    addNavigationLink(WelcomePage.class, new PageParameters(), "Home", null);

    addNavigationLink(RunsByTypeDashboardHomePage.class, new PageParameters(), "Runs by type",
            parameters.get("productName").toString() + "/" + parameters.get("versionName").toString() + "/"
                    + parameters.get("type").toString());

    AjaxLink<String> modalTooltip = new AjaxLink<String>("modalTooltip") {

        private static final long serialVersionUID = 1L;

        @Override/*  ww w.  j  av a  2 s.  c o m*/
        public void onClick(AjaxRequestTarget target) {

        }
    };
    //        modalTooltip.
    modalTooltip.add(new WebMarkupContainer("helpButton"));

    add(modalTooltip);

    if (!parameters.isEmpty()) {
        String productName = parameters.get("productName").toString();
        String versionName = parameters.get("versionName").toString();
        String buildType = parameters.get("type").toString();

        try {
            jsonDatas = new DashboardRunUtils().initData(productName, versionName, buildType);
        } catch (DatabaseAccessException e) {
            LOG.error("Unable to get run and suites data.", e);
            error("Unable to get run and suites data.");
        }

    }

}

From source file:com.axway.ats.testexplorer.pages.runsByTypeDashboard.suite.RunsByTypeDashboardSuitePage.java

License:Apache License

public RunsByTypeDashboardSuitePage(PageParameters parameters) {

    super(parameters);

    addNavigationLink(WelcomePage.class, new PageParameters(), "Home", null);
    addNavigationLink(RunsByTypeDashboardHomePage.class, new PageParameters(), "Runs by type",
            parameters.get("productName").toString() + "/" + parameters.get("versionName").toString() + "/"
                    + parameters.get("type").toString());
    addNavigationLink(RunsByTypeDashboardRunPage.class, parameters, "Suites",
            parameters.get("suiteName").toString());

    AjaxLink<String> modalTooltip = new AjaxLink<String>("modalTooltip") {

        private static final long serialVersionUID = 1L;

        @Override//w  w  w . j ava 2  s  . c o  m
        public void onClick(AjaxRequestTarget target) {

        }
    };
    //        modalTooltip.
    modalTooltip.add(new WebMarkupContainer("helpButton"));

    add(modalTooltip);

    if (!parameters.isEmpty()) {
        try {
            jsonDatas = new DashboardSuiteUtils().initData(parameters.get("suiteName").toString(),
                    parameters.get("type").toString(), parameters.get("suiteBuild").toString(),
                    parameters.get("productName").toString(), parameters.get("versionName").toString());
        } catch (DatabaseAccessException e) {
            LOG.error("Unable to get testcases data.", e);
            error("Unable to get testcases data.");
        }

    }
}

From source file:com.axway.ats.testexplorer.pages.testcasesByGroups.TestcasesByGroupsPage.java

License:Apache License

public TestcasesByGroupsPage(PageParameters parameters) {

    super(parameters);

    addNavigationLink(WelcomePage.class, new PageParameters(), "Home", null);

    filter = new TestcasesByGroupFilter("searchForm");

    add(filter);/*from   w  w  w. j a v  a2s  .  c o  m*/

    filter.performSearchOnPageLoad();

    filterData = filter.getFilterData();

    TestExplorerSession session = (TestExplorerSession) Session.get();
    TestcaseInfoPerGroupStorage perGroupStorage = null;
    try {
        perGroupStorage = session.getDbReadConnection().getTestcaseInfoPerGroupStorage(
                filter.getSelectedProductName(), filter.getSelectedVersionNames(),
                filter.getSelectedGroupNames(), filter.getSearchByAfterDate(), filter.getSearchByBeforeDate(),
                filter.getSearchByGroupContains());

    } catch (DatabaseAccessException e) {
        LOG.error("Unable to get Testcases and Groups data", e);
        error("Unable to get Testcases and Groups data");
    }

    if (perGroupStorage != null) {
        treemapData = perGroupStorage.generateTreemapData();
        testcasesIdsMap = perGroupStorage.generateTestcasesIdsMap();
    }

    AjaxLink<String> modalTooltip = new AjaxLink<String>("modalTooltip") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {

        }
    };
    //modalTooltip.
    modalTooltip.add(new WebMarkupContainer("helpButton"));

    add(modalTooltip);

}

From source file:com.doculibre.constellio.wicket.panels.admin.solrConfig.SolrConfigPanel.java

License:Open Source License

private ListView getPropertiesListView(List<PropertyRow> propertyRows) {
    return new ListView("properties", propertyRows) {

        @Override//from  w w  w  .  j  av a2s.  c o  m
        protected void populateItem(final ListItem item) {

            final PropertyRow propertyRow = (PropertyRow) item.getModelObject();
            item.setOutputMarkupId(true);
            item.add(new Label("property",
                    new StringResourceModel(propertyRow.getMessageKey(), SolrConfigPanel.this, null)));
            IModel stateModel = new LoadableDetachableModel() {

                protected Object load() {
                    SolrConfig config = solrConfigModel.getObject();
                    boolean isSet = PropertyResolver.getValue(propertyRow.getProperty(), config) != null;
                    return new StringResourceModel(isSet ? "yes" : "no", SolrConfigPanel.this, null)
                            .getObject();
                }

            };
            item.add(new Label("state", stateModel));
            AjaxLink defaultValueLink = new AjaxLink("defaultValue") {

                @Override
                public void onClick(AjaxRequestTarget target) {
                    SolrConfig config = solrConfigModel.getObject();
                    PropertyResolver.setValue(propertyRow.getProperty(), config, null, null);
                    target.addComponent(item);
                    save();
                }

                @Override
                public boolean isVisible() {
                    SolrConfig config = solrConfigModel.getObject();
                    return PropertyResolver.getValue(propertyRow.getProperty(), config) != null;
                }
            };
            item.add(defaultValueLink);
            IModel titleLabelModel = new LoadableDetachableModel() {

                @Override
                protected Object load() {
                    boolean isServerConfig = solrConfigModel.getObject().getRecordCollection() == null;
                    String resourceKey = isServerConfig ? "defaultValue" : "defaultServerValue";
                    return new StringResourceModel(resourceKey, SolrConfigPanel.this, null).getObject();
                }
            };
            defaultValueLink.add(new Label("label", titleLabelModel));

            if (propertyRow.isModalEdit()) {
                item.add(new ModalImgLinkHolder("editComponent") {
                    @Override
                    public WebMarkupContainer newLink(String id) {
                        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", SolrConfigPanel.this);
                                editModal.setTitle(editMsg);

                                WebMarkupContainer editContent = propertyRow
                                        .getEditLinkPanel(editModal.getContentId());
                                editModal.setContent(editContent);
                                editModal.show(target);
                                target.addComponent(item);
                            }
                        };
                    }

                    @Override
                    protected Component newImg(String id) {
                        return new NonCachingImage(id,
                                new ResourceReference(BaseConstellioPage.class, "images/ico_crayon.png"));
                    }
                });
            } else if (propertyRow.getType().equals(Boolean.class)) {
                final IModel valueModel = propertyRow.createModel();
                item.add(new CheckBoxHolder("editComponent") {

                    @Override
                    protected WebMarkupContainer newInput(String id) {
                        return new AjaxCheckBox(id, valueModel) {

                            @Override
                            protected void onUpdate(AjaxRequestTarget target) {
                                save();
                                target.addComponent(item);
                            }

                            @Override
                            public void detachModels() {
                                super.detachModels();
                                valueModel.detach();
                            }

                        };
                    }
                });
            } else {
                final IModel valueModel = propertyRow.createModel();
                item.add(new AjaxEditableLabel("editComponent", valueModel) {

                    @Override
                    protected void onSubmit(AjaxRequestTarget target) {
                        super.onSubmit(target);
                        save();
                        target.addComponent(item);
                    }

                    @Override
                    public void detachModels() {
                        super.detachModels();
                        valueModel.detach();
                    }

                });
            }

        }

    };
}

From source file:com.doculibre.constellio.wicket.panels.results.MailDetailsPanel.java

License:Open Source License

public MailDetailsPanel(String id, final Email email) {
    super(id, new CompoundPropertyModel(email));

    add(new Label("froms").setEscapeModelStrings(false));

    String messageContentText = email.getMessageContentHtml();
    String text = email.getMessageContentText();
    //FIXME : hack car les fichiers textes attachs sont ajout comme contenu texte
    if (text.length() > messageContentText.length()) {
        messageContentText = text;/*from w w  w .j a va 2 s  .  c  om*/
    }

    messageContentText = StringUtils.replace(messageContentText, ">>", "&gt;&gt;");
    messageContentText = StringUtils.replace(messageContentText, "\n>", "\n&gt;");
    messageContentText = StringUtils.replace(messageContentText, "\n", "\n<br />");

    //      String encodedString;
    //      try {
    //         encodedString = new String(messageContentText.getBytes(), email.getContentEncoding());
    //      } catch (UnsupportedEncodingException e) {
    //         // TODO Auto-generated catch block
    //         e.printStackTrace();
    //         encodedString = messageContentText;
    //      }
    //      add(new Label("messageContent", encodedString).setEscapeModelStrings(false));

    add(new Label("messageContent", messageContentText).setEscapeModelStrings(false));

    add(new ListView("linksList", email.getAttachments()) {
        @Override
        protected void populateItem(final ListItem item) {
            final Email.AttachmentClass element = (Email.AttachmentClass) item.getModelObject();

            final AJAXDownload download = new AJAXDownload() {
                @Override
                protected IResourceStream getResourceStream() {
                    return createResourceStream(element);
                }

                @Override
                protected String getFileName() {
                    return element.getAttachmentName();
                }

                private IResourceStream createResourceStream(final Email.AttachmentClass element) {
                    IResourceStream resourceStream = new IResourceStream() {
                        private Locale locale = null;
                        private InputStream inputStream = null;

                        @Override
                        public void close() throws IOException {
                            if (inputStream != null) {
                                IOUtils.closeQuietly(inputStream);
                            }
                        }

                        @Override
                        public String getContentType() {
                            return element.getAttachmentType();
                        }

                        @Override
                        public InputStream getInputStream() throws ResourceStreamNotFoundException {
                            if (inputStream == null) {
                                inputStream = new ByteArrayInputStream(element.getAttachmentContent());
                            }
                            return inputStream;
                        }

                        @Override
                        public Locale getLocale() {
                            return locale;
                        }

                        @Override
                        public long length() {
                            return ((Integer) element.getAttachmentContent().length).longValue();
                        }

                        @Override
                        public void setLocale(Locale locale) {
                            this.locale = locale;
                        }

                        @Override
                        public Time lastModifiedTime() {
                            // TODO Auto-generated method stub
                            return null;
                        }

                    };
                    return resourceStream;
                }
            };
            item.add(download);

            AjaxLink link;
            item.add(link = new AjaxLink("attachmentLinks") {
                @Override
                public void onClick(AjaxRequestTarget target) {
                    download.initiate(target);
                }
            });
            link.add(new Label("urlTitle", element.getAttachmentName()));

            /*Link link;
            add(link = new DownloadInputStreamLink("attachmentLinks",
                  new LoadableDetachableModel() {
             @Override
             protected Object load() {
                ByteArrayInputStream in = new ByteArrayInputStream(
                      element.getAttachmentContent());
                return in;
             }
                    
                  }, element.getAttachmentName(), element
                .getAttachmentType(),
                  ((Integer) element.getAttachmentContent().length)
                .longValue(), new Date()));
            link.add(new Label("urlTitle", element.getAttachmentName()));*/
            item.add(link);
        }
    });

    add(new Label("recipients").setEscapeModelStrings(false));

    //FIXME 1 by 1
    String flags = StringUtils.join(email.getFlags(), ", ");
    //FIXME i18n
    flags = StringUtils.replace(flags, "seen", getLocalizer().getString("seen", this));
    flags = StringUtils.replace(flags, "flagged", getLocalizer().getString("flagged", this));
    add(new Label("flags", flags).setEscapeModelStrings(false));

    //      add(new Label("folderNames").setEscapeModelStrings(false));
    add(new Label("receivedDate").setEscapeModelStrings(false));

}

From source file:com.doculibre.constellio.wicket.panels.results.MailSearchResultPanel.java

License:Open Source License

public MailSearchResultPanel(String id, final SolrDocument doc, final SearchResultsDataProvider dataProvider) {
    super(id);//from   ww w.j  ava 2  s .  c  o  m

    RecordServices recordServices = ConstellioSpringUtils.getRecordServices();
    RecordCollectionServices collectionServices = ConstellioSpringUtils.getRecordCollectionServices();
    final Long recordId = new Long(doc.getFieldValue(IndexField.RECORD_ID_FIELD).toString());
    final String collectionName = dataProvider.getSimpleSearch().getCollectionName();
    RecordCollection collection = collectionServices.get(collectionName);
    Record record = recordServices.get(recordId, collection);

    final IModel subjectModel = new LoadableDetachableModel() {
        @Override
        protected Object load() {
            RecordServices recordServices = ConstellioSpringUtils.getRecordServices();
            Record record = recordServices.get(doc);
            String subject = record.getDisplayTitle();
            if (StringUtils.isBlank(subject)) {
                subject = getLocalizer().getString("noSubject", MailSearchResultPanel.this);
            }
            if (subject.length() > 60) {
                subject = subject.substring(0, 60) + " ...";
            }
            return subject;
        }
    };

    // List<byte[]> attachmentContents = new ArrayList<byte[]>();
    // String messageContent = null;
    // for (RawContent raw : rawContents) {
    // byte[] bytes = raw.getContent();
    // if (messageContent == null) {
    // messageContent = new String(bytes);
    // } else {
    // attachmentContents.add(bytes);
    // }
    // System.out.println("partial content :" + new String(bytes));
    // }
    // System.out.println("content 1 :" + messageContent);

    // Description du document dans extrait:
    QueryResponse response = dataProvider.getQueryResponse();
    Map<String, Map<String, List<String>>> highlighting = response.getHighlighting();
    final String recordURL = record.getUrl();
    Map<String, List<String>> fieldsHighlighting = highlighting.get(recordURL);

    ConnectorInstance connectorInstance = record.getConnectorInstance();
    IndexField defaultSearchField = collection.getDefaultSearchIndexField();

    String excerpt = getExcerptFromHighlight(defaultSearchField.getName(), fieldsHighlighting);

    final ModalWindow detailsMailModal = new ModalWindow("detailsMailModal");
    detailsMailModal.setPageCreator(new PageCreator() {
        @Override
        public Page createPage() {
            return new BaseConstellioPage();
        }
    });
    add(detailsMailModal);
    detailsMailModal.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    detailsMailModal.setCookieName("detailsMailModal");

    IModel modalTitleModel = subjectModel;
    detailsMailModal.setTitle(modalTitleModel);

    final String displayURL = (String) doc.getFieldValue(collection.getUrlIndexField().getName());

    emailModel = new LoadableDetachableModel() {
        @Override
        protected Object load() {
            RecordServices recordServices = ConstellioSpringUtils.getRecordServices();
            Record record = recordServices.get(doc);

            List<String> attachmentNames = record.getMetaContents(MailConnectorConstants.META_ATTACHMENTNAME);
            List<String> attachmentTypes = record.getMetaContents(MailConnectorConstants.META_ATTACHMENTTYPE);
            List<String> recipients = record.getMetaContents(MailConnectorConstants.META_RECIPIENTS);
            List<String> flags = record.getMetaContents(MailConnectorConstants.META_FLAGS);
            List<String> froms = record.getMetaContents(MailConnectorConstants.META_SENDER);
            // FIXME Hardcoded
            List<String> contentEncoding = record.getMetaContents("Content-Encoding");

            List<String> receivedDateList = record.getMetaContents(MailConnectorConstants.META_RECEIVEDDATE);

            // FIXME voir avec Vincent : exemple qui ne marche pas jobboom car mail contient que du html
            RawContentServices rawContentServices = ConstellioSpringUtils.getRawContentServices();
            List<RawContent> rawContents = rawContentServices.getRawContents(record);
            ParsedContent parsedContents = record.getParsedContent();

            Email email;
            if (rawContents.size() != 0) {
                byte[] content = rawContents.get(0).getContent();
                String tmpFilePath = ClasspathUtils.getCollectionsRootDir() + File.separator + "tmp.eml";
                try {
                    email = MailMessageUtils.toEmail(content, tmpFilePath);
                } catch (Exception e) {
                    System.out.println("Error in reading content of mail");
                    // le contenu n'a pas bien t lu correctement
                    email = new Email();
                    email.setMessageContentText(parsedContents.getContent());
                }
            } else {
                // le contenu n'a pas bien t lu correctement
                email = new Email();
                email.setMessageContentText(parsedContents.getContent());
            }

            email.setFlags(flags);

            // email.setMessageContentHtml(messageContentHtml);
            if (!receivedDateList.isEmpty()) {
                email.setReceivedDate(receivedDateList.get(0));
            }
            email.setRecipients(recipients);
            email.setSubject((String) subjectModel.getObject());
            email.setFroms(froms);
            // email.setLanguage(language);
            if (!contentEncoding.isEmpty()) {
                email.setContentEncoding(contentEncoding.get(0));
            }
            return email;
        }
    };

    final RecordModel recordModel = new RecordModel(record);
    AjaxLink detailsMailLink = new AjaxLink("detailsMailLink") {
        @Override
        public void onClick(AjaxRequestTarget target) {
            Email email = (Email) emailModel.getObject();
            detailsMailModal.setContent(new MailDetailsPanel(detailsMailModal.getContentId(), email));
            detailsMailModal.show(target);
        }

        @Override
        protected IAjaxCallDecorator getAjaxCallDecorator() {
            return new AjaxCallDecorator() {
                @Override
                public CharSequence decorateScript(CharSequence script) {
                    Record record = recordModel.getObject();
                    SimpleSearch simpleSearch = dataProvider.getSimpleSearch();
                    WebRequest webRequest = (WebRequest) RequestCycle.get().getRequest();
                    HttpServletRequest httpRequest = webRequest.getHttpServletRequest();
                    return script + ";" + ComputeSearchResultClickServlet.getCallbackJavascript(httpRequest,
                            simpleSearch, record);
                }
            };
        }
    };
    add(detailsMailLink);

    IModel recipientsLabelModel = new LoadableDetachableModel() {
        @Override
        protected Object load() {
            RecordServices recordServices = ConstellioSpringUtils.getRecordServices();
            Record record = recordServices.get(doc);
            List<String> recipients = record.getMetaContents(MailConnectorConstants.META_RECIPIENTS);
            return getLocalizer().getString("to", MailSearchResultPanel.this) + " : " + recipients;
        }
    };

    IModel receivedDateLabelModel = new LoadableDetachableModel() {
        @Override
        protected Object load() {
            RecordServices recordServices = ConstellioSpringUtils.getRecordServices();
            Record record = recordServices.get(doc);
            List<String> receivedDateList = record.getMetaContents(MailConnectorConstants.META_RECEIVEDDATE);
            String receivedDate;
            if (!receivedDateList.isEmpty()) {
                receivedDate = receivedDateList.get(0);
            } else {
                receivedDate = "";
            }
            return getLocalizer().getString("date", MailSearchResultPanel.this) + " : " + receivedDate;
        }
    };

    Label subjectLabel = new Label("subject", subjectModel);
    detailsMailLink.add(subjectLabel.setEscapeModelStrings(false));

    Label excerptLbl = new Label("messageContent", excerpt);
    add(excerptLbl.setEscapeModelStrings(false));
    add(new Label("recipient", recipientsLabelModel) {
        @Override
        public boolean isVisible() {
            boolean visible = super.isVisible();
            if (visible) {
                RecordCollectionServices collectionServices = ConstellioSpringUtils
                        .getRecordCollectionServices();
                RecordServices recordServices = ConstellioSpringUtils.getRecordServices();
                RecordCollection collection = collectionServices.get(collectionName);
                Record record = recordServices.get(recordId, collection);
                List<String> recipients = record.getMetaContents(MailConnectorConstants.META_RECIPIENTS);
                visible = !recipients.isEmpty();
            }
            return visible;
        }
    });
    // add(new Label("from", getLocalizer().getString("from", this) + " : " + froms));
    add(new Label("date", receivedDateLabelModel));
    add(new WebMarkupContainer("hasAttachmentsImg") {
        @Override
        public boolean isVisible() {
            boolean visible = super.isVisible();
            if (visible) {
                RecordServices recordServices = ConstellioSpringUtils.getRecordServices();
                Record record = recordServices.get(doc);
                List<String> attachmentNames = record
                        .getMetaContents(MailConnectorConstants.META_ATTACHMENTNAME);
                visible = !attachmentNames.isEmpty();
            }
            return visible;
        }
    });

    final ReloadableEntityModel<RecordCollection> collectionModel = new ReloadableEntityModel<RecordCollection>(
            collection);
    add(new ListView("searchResultFields", new LoadableDetachableModel() {
        @Override
        protected Object load() {
            RecordCollection collection = collectionModel.getObject();
            return collection.getSearchResultFields();
        }

        /**
         * Detaches from the current request. Implement this method with custom behavior, such as
         * setting the model object to null.
         */
        protected void onDetach() {
            recordModel.detach();
            collectionModel.detach();
        }
    }) {
        @Override
        protected void populateItem(ListItem item) {
            SearchResultField searchResultField = (SearchResultField) item.getModelObject();
            IndexFieldServices indexFieldServices = ConstellioSpringUtils.getIndexFieldServices();
            Record record = recordModel.getObject();
            IndexField indexField = searchResultField.getIndexField();
            Locale locale = getLocale();
            String indexFieldTitle = indexField.getTitle(locale);
            if (StringUtils.isBlank(indexFieldTitle)) {
                indexFieldTitle = indexField.getName();
            }
            StringBuffer fieldValueSb = new StringBuffer();
            List<Object> fieldValues = indexFieldServices.extractFieldValues(record, indexField);
            Map<String, String> defaultLabelledValues = indexFieldServices.getDefaultLabelledValues(indexField,
                    locale);
            for (Object fieldValue : fieldValues) {
                if (fieldValueSb.length() > 0) {
                    fieldValueSb.append("\n");
                }
                String fieldValueLabel = indexField.getLabelledValue("" + fieldValue, locale);
                if (fieldValueLabel == null) {
                    fieldValueLabel = defaultLabelledValues.get("" + fieldValue);
                }
                if (fieldValueLabel == null) {
                    fieldValueLabel = "" + fieldValue;
                }
                fieldValueSb.append(fieldValueLabel);
            }

            item.add(new Label("indexField", indexFieldTitle));
            item.add(new MultiLineLabel("indexFieldValue", fieldValueSb.toString()));
            item.setVisible(fieldValueSb.length() > 0);
        }

        @SuppressWarnings("unchecked")
        @Override
        public boolean isVisible() {
            boolean visible = super.isVisible();
            if (visible) {
                List<SearchResultField> searchResultFields = (List<SearchResultField>) getModelObject();
                visible = !searchResultFields.isEmpty();
            }
            return visible;
        }
    });

    add(new ElevatePanel("elevatePanel", record, dataProvider.getSimpleSearch()));
}

From source file:com.doculibre.constellio.wicket.panels.results.PopupSearchResultPanel.java

License:Open Source License

public PopupSearchResultPanel(String id, SolrDocument doc, final SearchResultsDataProvider dataProvider) {
    super(id);/*from  w  ww. java2s.  c o m*/

    RecordCollectionServices collectionServices = ConstellioSpringUtils.getRecordCollectionServices();
    String solrServerName = dataProvider.getSimpleSearch().getCollectionName();
    RecordCollection collection = collectionServices.get(solrServerName);

    IndexField uniqueKeyField = collection.getUniqueKeyIndexField();
    IndexField defaultSearchField = collection.getDefaultSearchIndexField();
    IndexField urlField = collection.getUrlIndexField();
    IndexField titleField = collection.getTitleIndexField();

    // title
    String documentID = (String) getFieldValue(doc, uniqueKeyField.getName());

    String documentTitle = (String) getFieldValue(doc, titleField.getName());

    if (StringUtils.isBlank(documentTitle)) {
        if (urlField == null) {
            documentTitle = (String) getFieldValue(doc, uniqueKeyField.getName());
        } else {
            documentTitle = (String) getFieldValue(doc, urlField.getName());
        }
    }
    if (documentTitle.length() > 120) {
        documentTitle = documentTitle.substring(0, 120) + " ...";
    }

    // content
    RecordServices recordServices = ConstellioSpringUtils.getRecordServices();
    Record record = recordServices.get(doc);

    RawContentServices rawContentServices = ConstellioSpringUtils.getRawContentServices();
    List<RawContent> rawContents = rawContentServices.getRawContents(record);
    StringBuilder content = new StringBuilder();
    for (RawContent raw : rawContents) {
        byte[] bytes = raw.getContent();
        content.append(new String(bytes));
    }

    String documentContent = content.toString();

    // date
    String documentLastModified = getFieldValue(doc, IndexField.LAST_MODIFIED_FIELD);

    // Description du document dans extrait:
    QueryResponse response = dataProvider.getQueryResponse();
    Map<String, Map<String, List<String>>> highlighting = response.getHighlighting();
    final String recordURL = record.getUrl();
    Map<String, List<String>> fieldsHighlighting = highlighting.get(recordURL);

    String extrait = getExcerptFromHighlight(defaultSearchField.getName(), fieldsHighlighting);

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

    detailsDocumentModal.setContent(
            new PopupDetailsPanel(detailsDocumentModal.getContentId(), documentContent, documentLastModified));
    detailsDocumentModal.setCookieName("detailsDocumentModal");

    String modalTitle = documentTitle;
    detailsDocumentModal.setTitle(modalTitle);

    AjaxLink detailsDocumentLink = new AjaxLink("detailsDocumentLink") {
        @Override
        public void onClick(AjaxRequestTarget target) {
            detailsDocumentModal.show(target);
        }
    };
    add(detailsDocumentLink);

    final RecordModel recordModel = new RecordModel(record);
    AttributeAppender computeClickAttributeModifier = new AttributeAppender("onclick", true,
            new LoadableDetachableModel() {
                @Override
                protected Object load() {
                    Record record = recordModel.getObject();
                    SimpleSearch simpleSearch = dataProvider.getSimpleSearch();
                    WebRequest webRequest = (WebRequest) RequestCycle.get().getRequest();
                    HttpServletRequest httpRequest = webRequest.getHttpServletRequest();
                    return ComputeSearchResultClickServlet.getCallbackJavascript(httpRequest, simpleSearch,
                            record);
                }

                @Override
                protected void onDetach() {
                    recordModel.detach();
                    super.onDetach();
                }
            }, ";") {
        @Override
        protected String newValue(String currentValue, String appendValue) {
            return appendValue + currentValue;
        }
    };
    detailsDocumentLink.add(computeClickAttributeModifier);

    Label subjectLabel = new Label("subject", documentTitle);
    detailsDocumentLink.add(subjectLabel.setEscapeModelStrings(false));

    Label extraitLbl = new Label("documentContent", extrait);
    add(extraitLbl.setEscapeModelStrings(false));
    add(new Label("date", "Date : " + documentLastModified));

    add(new ElevatePanel("elevatePanel", record, dataProvider.getSimpleSearch()));
}

From source file:com.doculibre.constellio.wicket.panels.results.SearchResultsPanel.java

License:Open Source License

public SearchResultsPanel(String id, final SearchResultsDataProvider dataProvider) {
    super(id);//from www  .  jav  a2s .co  m
    setOutputMarkupId(true);

    List<TransfertSearchResultsPlugin> plugins = PluginFactory.getPlugins(TransfertSearchResultsPlugin.class);

    this.transfertLink = new AjaxLink("transfertLink") {

        @Override
        public void onClick(AjaxRequestTarget target) {
            transfertPanel.setVisible(true);
            transfertLink.setVisible(false);
            transfertActive = true;
            target.addComponent(SearchResultsPanel.this);
        }
    };
    transfertLink.setVisible(!plugins.isEmpty() && ConstellioSession.get().getUser() != null
            && ConstellioSpringUtils.getIntelliGIDServiceInfo() != null);
    add(transfertLink);

    this.transfertPanel = new WebMarkupContainer("transfertPanel");
    transfertPanel.setOutputMarkupId(true);
    transfertPanel.setVisible(false);
    add(transfertPanel);

    IModel allNoneModel = new Model() {

        @Override
        public Object getObject() {
            return allNone;
        }

        @Override
        public void setObject(Object object) {
            allNone = (Boolean) object;
            if (allNone) {
                Iterator it = dataProvider.iterator(0, dataProvider.size());
                while (it.hasNext()) {
                    SolrDocument document = (SolrDocument) it.next();
                    dataProvider.getSimpleSearch().getSelectedResults()
                            .add(new Long(document.getFieldValue(IndexField.RECORD_ID_FIELD).toString()));
                }
            } else {
                dataProvider.getSimpleSearch().getSelectedResults().clear();
            }
        }

    };

    allNoneCheckbox = new AjaxCheckBox("allNoneCheckbox", allNoneModel) {

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

    errorMessageLabel = new Label("errorMessageLabel", new PropertyModel(this, "errorMessage"));
    errorMessageLabel.setOutputMarkupId(true);
    transfertPanel.add(errorMessageLabel);

    transfertPanel.add(new ListView("transfertButtons", plugins) {

        @Override
        protected void populateItem(ListItem item) {
            final TransfertSearchResultsPlugin plugin = ((TransfertSearchResultsPlugin) item.getModelObject());
            AjaxLink link = new AjaxLink("launchTransfertLink") {

                @Override
                public void onClick(AjaxRequestTarget target) {
                    errorMessage = null;
                    List<Record> records = new ArrayList<Record>();
                    SimpleSearch search = dataProvider.getSimpleSearch();
                    RecordCollection collection = ConstellioSpringUtils.getRecordCollectionServices()
                            .get(search.getCollectionName());
                    for (Long recordId : search.getSelectedResults()) {
                        records.add(ConstellioSpringUtils.getRecordServices().get(recordId, collection));
                    }

                    if (!records.isEmpty()) {
                        doTransfert(plugin, target, records);
                    }

                }

                private void doTransfert(final TransfertSearchResultsPlugin plugin, AjaxRequestTarget target,
                        List<Record> records) {
                    List<Record> transferedRecords = new ArrayList<Record>();
                    List<String> ids = new ArrayList<String>();
                    for (Record record : records) {
                        try {
                            ids.add(plugin.transfert(record));
                            transferedRecords.add(record);
                        } catch (Throwable t) {
                            t.printStackTrace();
                            errorMessage = t.getMessage();
                            break;
                        }
                    }
                    if (errorMessage != null) {
                        try {
                            for (int i = 0; i < ids.size(); i++) {
                                plugin.cancel(transferedRecords.get(i), ids.get(i));
                            }
                        } catch (Throwable t) {
                            t.printStackTrace();
                        }
                    } else {
                        plugin.afterTransfert(transferedRecords, ids);
                    }
                    target.addComponent(errorMessageLabel);
                }
            };
            item.add(link);
            link.add(new Label("launchTransfertLabel", plugin.getLabelText()));
        }
    });

    this.dataView = new DataView(DATA_VIEW_ID, dataProvider, dataProvider.getResultsPerPage()) {
        @Override
        protected void populateItem(Item item) {
            SolrDocument doc = (SolrDocument) item.getModelObject();
            final Long id;
            RecordServices recordServices = ConstellioSpringUtils.getRecordServices();

            if (doc.getFieldValue(IndexField.RECORD_ID_FIELD) != null) {
                Record record = recordServices.get(doc);
                id = record.getId();
                if (record != null) {
                    ConnectorInstance connectorInstance = record.getConnectorInstance();

                    final ReloadableEntityModel<ConnectorInstance> connectorInstanceModel = new ReloadableEntityModel<ConnectorInstance>(
                            connectorInstance);
                    ConnectorType connectorType = connectorInstance.getConnectorType();
                    ResourceReference imageResourceReference = new ResourceReference(
                            "connectorType_" + connectorType.getId()) {
                        @Override
                        protected Resource newResource() {
                            ConnectorInstance connectorInstance = (ConnectorInstance) connectorInstanceModel
                                    .getObject();
                            ConnectorType connectorType = connectorInstance.getConnectorType();
                            Resource imageResource;
                            byte[] iconBytes = connectorType.getIconFileContent();
                            // Convert resource path to absolute path relative to base package
                            if (iconBytes != null) {
                                imageResource = new ByteArrayResource("image", iconBytes);
                            } else {
                                imageResource = PackageResource.get(ConnectorListPanel.class,
                                        "default_icon.gif");
                            }
                            return imageResource;
                        }
                    };

                    item.add(new NonCachingImage("icon", imageResourceReference) {
                        @Override
                        public void detachModels() {
                            connectorInstanceModel.detach();
                            super.detachModels();
                        }

                        @Override
                        public boolean isVisible() {
                            boolean visible = super.isVisible();
                            if (visible) {
                                SearchInterfaceConfigServices searchInterfaceConfigServices = ConstellioSpringUtils
                                        .getSearchInterfaceConfigServices();
                                SearchInterfaceConfig searchInterfaceConfig = searchInterfaceConfigServices
                                        .get();
                                visible = searchInterfaceConfig.isUseIconsInSearchResults();
                            }
                            return visible;
                        }
                    });
                } else {
                    item.setVisible(false);
                }
            } else {
                item.add(new WebMarkupContainer("icon").setVisible(false));
                id = null;
            }

            item.add(getSearchResultPanel("searchResultPanel", item, dataProvider));
            item.add(new SearchResultTaggingPanel("taggingPanel", doc, dataProvider));

            newRecordCheckbox(dataProvider, item, id);
        }

        private void newRecordCheckbox(final SearchResultsDataProvider dataProvider, Item item, final Long id) {
            IModel isChecked = new Model() {
                @Override
                public Object getObject() {
                    return id != null && dataProvider.getSimpleSearch().getSelectedResults().contains(id);
                }

                @Override
                public void setObject(Object object) {
                    if (id != null) {
                        Boolean state = (Boolean) object;
                        dataProvider.getSimpleSearch().getSelectedResults().remove(id);
                        if (state) {
                            dataProvider.getSimpleSearch().getSelectedResults().add(id);
                        } else {
                            allNone = false;
                        }
                    }
                }
            };

            item.add(new AjaxCheckBox("checkedResults", isChecked) {

                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                    target.addComponent(allNoneCheckbox);
                }

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

            });
        }
    };
    add(dataView);
    dataView.setOutputMarkupId(true);
    int page = dataProvider.getSimpleSearch().getPage();
    int pageCount = dataView.getPageCount();
    dataView.setCurrentPage(page == -1 ? pageCount - 1 : page);

    ConstellioPagingNavigator pagingNavigator = new ConstellioPagingNavigator("resultsPN", dataView);
    add(pagingNavigator);

    add(new WebMarkupContainer("noResultsMessage") {
        @Override
        public boolean isVisible() {
            return dataProvider.size() == 0;
        }
    });
}

From source file:com.doculibre.constellio.wicket.panels.results.tagging.SearchResultEditTaggingPanel.java

License:Open Source License

public SearchResultEditTaggingPanel(String id, final SolrDocument doc, final IDataProvider dataProvider,
        Thesaurus source) {/*from   w  w w  . j av  a 2s  .  c  om*/
    super(id);
    if (source == null) {
        freeTextTags = true;
        source = new Thesaurus(getLocalizer().getString("freeTextTags", SearchResultEditTaggingPanel.this));
    }
    RecordServices recordServices = ConstellioSpringUtils.getRecordServices();
    Record record = recordServices.get(doc);
    recordModel = new RecordModel(record);
    taggingSourceModel = new EntityModel<Thesaurus>(source);

    filterAddForm = new Form("filterAddForm");
    filterAddForm.setOutputMarkupId(true);

    IModel taggingSourceChoicesModel = new LoadableDetachableModel() {
        @Override
        protected Object load() {
            List<Object> taggingSources = new ArrayList<Object>();

            taggingSources.add(
                    new Thesaurus(getLocalizer().getString("freeTextTags", SearchResultEditTaggingPanel.this)));

            SkosServices skosServices = ConstellioSpringUtils.getSkosServices();
            Record record = recordModel.getObject();
            ConnectorInstance connectorInstance = record.getConnectorInstance();
            RecordCollection collection = connectorInstance.getRecordCollection();
            Map<String, Object> criteria = new HashMap<String, Object>();
            criteria.put("recordCollection", collection);
            taggingSources.addAll(skosServices.list(criteria));

            return taggingSources;
        }
    };
    IChoiceRenderer taggingSourceRenderer = new ChoiceRenderer("dcTitle");
    taggingSourceField = new DropDownChoice("taggingSource", taggingSourceModel, taggingSourceChoicesModel,
            taggingSourceRenderer);
    taggingSourceField.setVisible(isSourceSelectionVisible());
    taggingSourceField.add(new AjaxFormComponentUpdatingBehavior("onchange") {
        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            target.addComponent(availableTagsContainer);
            target.addComponent(appliedTagsContainer);
            target.addComponent(filterAddField);
            target.addComponent(filterAddButton);
        }
    });

    filterAddField = new TextField("filterAddField", new Model());
    filterAddField.setOutputMarkupId(true);
    filterAddField.add(new AjaxFormComponentUpdatingBehavior("onkeyup") {
        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            String input = filterAddField.getModelObjectAsString();
            availableTagsModel.setFilter(input);
            appliedTagsModel.setFilter(input);
            if (isFreeTextTagSource()) {
                target.addComponent(availableTagsContainer);
                target.addComponent(appliedTagsContainer);
            }
        }
    });

    filterAddButton = new AjaxButton("filterAddButton") {
        @Override
        protected void onSubmit(AjaxRequestTarget target, Form form) {
            String tagName = (String) filterAddField.getModelObject();
            if (StringUtils.isNotBlank(tagName)) {
                if (isFreeTextTagSource()) {
                    FreeTextTagServices freeTextTagServices = ConstellioSpringUtils.getFreeTextTagServices();
                    FreeTextTag existingTag = freeTextTagServices.get(tagName);
                    if (existingTag == null) {
                        FreeTextTag newTag = new FreeTextTag();
                        newTag.setFreeText(tagName);

                        EntityManager entityManager = ConstellioPersistenceContext.getCurrentEntityManager();
                        if (!entityManager.getTransaction().isActive()) {
                            entityManager.getTransaction().begin();
                        }
                        freeTextTagServices.makePersistent(newTag);
                        entityManager.getTransaction().commit();

                        availableTagsModel.setFilter(null);
                        appliedTagsModel.setFilter(null);
                        filterAddField.clearInput();
                        filterAddField.setModelObject(null);
                        target.addComponent(filterAddField);
                        target.addComponent(availableTagsContainer);
                        target.addComponent(appliedTagsContainer);
                    }
                } else {
                    target.addComponent(availableTagsContainer);
                }
            }
        }
    };
    filterAddButton.add(new AttributeModifier("value", true, new LoadableDetachableModel() {
        @Override
        protected Object load() {
            String key = isFreeTextTagSource() ? "add" : "filter";
            return getLocalizer().getString(key, SearchResultEditTaggingPanel.this);
        }
    }));

    availableTagsContainer = new WebMarkupContainer("availableTagsContainer");
    availableTagsContainer.setOutputMarkupId(true);
    availableTagsModel = new FilteredObjectsModel() {
        @Override
        protected List<Object> filter(String filter) {
            List<Object> matches = new ArrayList<Object>();
            Thesaurus taggingSource = taggingSourceModel.getObject();

            if (taggingSource == null || taggingSource.getId() == null) {
                if (StringUtils.isNotBlank(filter)) {
                    filter = filter + "*";
                }
                FreeTextTagServices taggingServices = ConstellioSpringUtils.getFreeTextTagServices();
                if (StringUtils.isBlank(filter)) {
                    List<FreeTextTag> first100 = taggingServices.list(100);
                    matches.addAll(first100);
                } else {
                    Set<FreeTextTag> searchResults = taggingServices.search(filter);
                    matches.addAll(searchResults);
                }
            } else {
                SkosServices skosServices = ConstellioSpringUtils.getSkosServices();
                Set<SkosConcept> searchResults = skosServices.searchAllLabels(filter, taggingSource, null);
                matches.addAll(searchResults);
            }
            return matches;
        }
    };
    availableTagsListView = new ListView("availableTags", availableTagsModel) {
        @Override
        protected void populateItem(ListItem item) {
            ConstellioEntity tagSource = (ConstellioEntity) item.getModelObject();
            final ReloadableEntityModel<ConstellioEntity> tagSourceModel = new ReloadableEntityModel<ConstellioEntity>(
                    tagSource);
            final ModalWindow detailsModal = new ModalWindow("detailsModal");
            item.add(detailsModal);

            final AjaxLink detailsLink = new AjaxLink("detailsLink") {
                @Override
                public void onClick(AjaxRequestTarget target) {
                    ConstellioEntity tagSource = (ConstellioEntity) tagSourceModel.getObject();
                    if (tagSource instanceof SkosConcept) {
                        SkosConcept skosConcept = (SkosConcept) tagSource;
                        detailsModal.setContent(
                                new SkosConceptModalPanel(detailsModal.getContentId(), skosConcept));
                        detailsModal.show(target);
                    }
                }
            };
            item.add(detailsLink);
            detailsLink.setEnabled(tagSource instanceof SkosConcept);

            detailsLink.add(new Label("name", new LoadableDetachableModel() {
                @Override
                protected Object load() {
                    String name;
                    ConstellioEntity tagSource = (ConstellioEntity) tagSourceModel.getObject();
                    if (tagSource != null) {
                        if (tagSource instanceof FreeTextTag) {
                            FreeTextTag freeTextTag = (FreeTextTag) tagSource;
                            name = freeTextTag.getFreeText();
                        } else {
                            SkosConcept skosConcept = (SkosConcept) tagSource;
                            name = skosConcept.getPrefLabel(getLocale());
                        }
                    } else {
                        name = "null";
                    }
                    return name;
                }
            }));

            item.add(new AjaxLink("addLink") {
                @Override
                public void onClick(AjaxRequestTarget target) {
                    Record record = recordModel.getObject();
                    ConstellioEntity tagSource = (ConstellioEntity) tagSourceModel.getObject();
                    if (tagSource instanceof FreeTextTag) {
                        FreeTextTag freeTextTag = (FreeTextTag) tagSource;
                        record.addFreeTextTag(freeTextTag, true);
                    } else {
                        SkosConcept skosConcept = (SkosConcept) tagSource;
                        record.addSkosConcept(skosConcept, true);
                    }
                    record.setUpdateIndex(true);

                    RecordServices recordServices = ConstellioSpringUtils.getRecordServices();

                    SolrServer solrServer = SolrCoreContext
                            .getSolrServer(record.getConnectorInstance().getRecordCollection());
                    try {
                        ConstellioPersistenceUtils.beginTransaction();
                        recordServices.makePersistent(record);
                        try {
                            solrServer.commit();
                        } catch (Throwable t) {
                            try {
                                solrServer.rollback();
                            } catch (Exception e) {
                                throw new RuntimeException(t);
                            }
                        }
                    } finally {
                        ConstellioPersistenceUtils.finishTransaction(false);
                    }

                    target.addComponent(availableTagsContainer);
                    target.addComponent(appliedTagsContainer);
                }

                @Override
                public boolean isVisible() {
                    boolean visible = super.isVisible();
                    if (visible) {
                        Record record = recordModel.getObject();
                        if (tagSourceModel.getObject() instanceof FreeTextTag) {
                            FreeTextTag freeTextTag = (FreeTextTag) tagSourceModel.getObject();
                            visible = !record.hasFreeTextTag(freeTextTag);
                        } else {
                            SkosConcept skosConcept = (SkosConcept) tagSourceModel.getObject();
                            visible = !record.hasSkosConcept(skosConcept);
                        }
                    }
                    return visible;
                }

                @Override
                public void detachModels() {
                    tagSourceModel.detach();
                    super.detachModels();
                }
            });
        }
    };

    appliedTagsContainer = new WebMarkupContainer("appliedTagsContainer");
    appliedTagsContainer.setOutputMarkupId(true);
    appliedTagsModel = new FilteredObjectsModel() {
        @Override
        protected List<RecordTag> filter(String filter) {
            List<RecordTag> matches = new ArrayList<RecordTag>();
            Record record = recordModel.getObject();
            Thesaurus source = taggingSourceModel.getObject();
            for (RecordTag recordTag : record.getIncludedRecordTags(freeTextTags ? null : source, true)) {
                //                    if (StringUtils.isEmpty(filter)
                //                        || recordTag.getName(getLocale()).toLowerCase().indexOf(filter.toLowerCase()) != -1) {
                matches.add(recordTag);
                //                    }
            }
            return matches;
        }
    };
    appliedTagsListView = new ListView("appliedTags", appliedTagsModel) {
        @Override
        protected void populateItem(ListItem item) {
            RecordTag recordTag = (RecordTag) item.getModelObject();
            final RecordTagModel recordTagModel = new RecordTagModel(recordTag);

            ConstellioEntity tagSource;
            if (recordTag.getFreeTextTag() != null) {
                tagSource = recordTag.getFreeTextTag();
            } else {
                tagSource = recordTag.getSkosConcept();
            }
            final ReloadableEntityModel<ConstellioEntity> tagSourceModel = new ReloadableEntityModel<ConstellioEntity>(
                    tagSource);
            final ModalWindow detailsModal = new ModalWindow("detailsModal");
            item.add(detailsModal);

            final AjaxLink detailsLink = new AjaxLink("detailsLink") {
                @Override
                public void onClick(AjaxRequestTarget target) {
                    ConstellioEntity tagSource = (ConstellioEntity) tagSourceModel.getObject();
                    if (tagSource instanceof SkosConcept) {
                        SkosConcept skosConcept = (SkosConcept) tagSource;
                        detailsModal.setContent(
                                new SkosConceptModalPanel(detailsModal.getContentId(), skosConcept));
                        detailsModal.show(target);
                    }
                }
            };
            item.add(detailsLink);
            detailsLink.setEnabled(tagSource instanceof SkosConcept);

            detailsLink.add(new Label("name", new LoadableDetachableModel() {
                @Override
                protected Object load() {
                    String name;
                    ConstellioEntity tagSource = (ConstellioEntity) tagSourceModel.getObject();
                    if (tagSource != null) {
                        if (tagSource instanceof FreeTextTag) {
                            FreeTextTag freeTextTag = (FreeTextTag) tagSource;
                            name = freeTextTag.getFreeText();
                        } else {
                            SkosConcept skosConcept = (SkosConcept) tagSource;
                            name = skosConcept.getPrefLabel(getLocale());
                        }
                    } else {
                        name = "null";
                    }
                    return name;
                }
            }));
            detailsLink.add(new AttributeModifier("style", true, new LoadableDetachableModel() {
                @Override
                protected Object load() {
                    RecordTag recordTag = recordTagModel.getObject();
                    return recordTag.isExcluded() ? "text-decoration: line-through;" : "text-decoration:none";
                }
            }));
            item.add(new AjaxLink("removeLink") {
                @Override
                public void onClick(AjaxRequestTarget target) {
                    Record record = recordModel.getObject();
                    RecordTag recordTag = recordTagModel.getObject();
                    boolean excluded = recordTag.isExcluded();
                    if (excluded) {
                        record.getRecordTags().remove(recordTag);
                    } else {
                        recordTag.setManual(true);
                        recordTag.setExcluded(true);
                    }
                    record.setUpdateIndex(true);

                    RecordServices recordServices = ConstellioSpringUtils.getRecordServices();

                    SolrServer solrServer = SolrCoreContext
                            .getSolrServer(record.getConnectorInstance().getRecordCollection());
                    try {
                        ConstellioPersistenceUtils.beginTransaction();
                        recordServices.makePersistent(record);
                        try {
                            solrServer.commit();
                        } catch (Throwable t) {
                            try {
                                solrServer.rollback();
                            } catch (Exception e) {
                                throw new RuntimeException(t);
                            }
                        }
                    } finally {
                        ConstellioPersistenceUtils.finishTransaction(false);
                    }

                    target.addComponent(availableTagsContainer);
                    target.addComponent(appliedTagsContainer);
                }

                @Override
                public void detachModels() {
                    recordTagModel.detach();
                    tagSourceModel.detach();
                    super.detachModels();
                }
            });
        }
    };

    closeLink = new AjaxLink("closeLink") {
        @Override
        public void onClick(AjaxRequestTarget target) {
            SearchResultTaggingPanel parent = (SearchResultTaggingPanel) findParent(
                    SearchResultTaggingPanel.class);
            target.addComponent(parent);
            ModalWindow.closeCurrent(target);
        }
    };

    add(taggingSourceField);
    add(new Label("sourceName", source.getDcTitle()).setVisible(!isSourceSelectionVisible()));
    add(filterAddForm);
    filterAddForm.add(filterAddField);
    filterAddForm.add(filterAddButton);

    add(availableTagsContainer);
    availableTagsContainer.add(availableTagsListView);

    add(appliedTagsContainer);
    appliedTagsContainer.add(appliedTagsListView);

    add(closeLink);
}