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

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

Introduction

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

Prototype

public AjaxLazyLoadPanel(final String id) 

Source Link

Document

Constructor

Usage

From source file:com.doculibre.constellio.wicket.pages.SearchResultsPage.java

License:Open Source License

private void initComponents() {
    final SimpleSearch simpleSearch = getSimpleSearch();
    String collectionName = simpleSearch.getCollectionName();
    ConstellioUser currentUser = ConstellioSession.get().getUser();
    RecordCollectionServices recordCollectionServices = ConstellioSpringUtils.getRecordCollectionServices();
    RecordCollection collection = recordCollectionServices.get(collectionName);
    boolean userHasPermission = false;
    if (collection != null) {
        userHasPermission = (!collection.hasSearchPermission())
                || (currentUser != null && currentUser.hasSearchPermission(collection));
    }/*www  .  j a v a 2  s.  co  m*/
    if (StringUtils.isEmpty(collectionName) || !userHasPermission) {
        setResponsePage(ConstellioApplication.get().getHomePage());
    } else {

        final IModel suggestedSearchKeyListModel = new LoadableDetachableModel() {
            @Override
            protected Object load() {
                ListOrderedMap suggestedSearch = new ListOrderedMap();
                if (simpleSearch.isQueryValid() && simpleSearch.getQuery() != null) {
                    SpellChecker spellChecker = new SpellChecker(ConstellioApplication.get().getDictionaries());
                    try {
                        if (!simpleSearch.getQuery().equals("*:*")) {
                            suggestedSearch = spellChecker.suggest(simpleSearch.getQuery(),
                                    simpleSearch.getCollectionName());
                        }
                    } catch (RuntimeException e) {
                        e.printStackTrace();
                        // chec du spellchecker, pas besoin de faire planter la page
                    }
                }
                return suggestedSearch;
            }
        };

        BaseSearchResultsPageHeaderPanel headerPanel = (BaseSearchResultsPageHeaderPanel) getHeaderComponent();
        headerPanel.setAdvancedForm(simpleSearch.getAdvancedSearchRule() != null);
        SearchFormPanel searchFormPanel = headerPanel.getSearchFormPanel();

        final ThesaurusSuggestionPanel thesaurusSuggestionPanel = new ThesaurusSuggestionPanel(
                "thesaurusSuggestion", simpleSearch, getLocale());
        add(thesaurusSuggestionPanel);

        SpellCheckerPanel spellCheckerPanel = new SpellCheckerPanel("spellChecker",
                searchFormPanel.getSearchTxtField(), searchFormPanel.getSearchButton(),
                suggestedSearchKeyListModel) {
            @SuppressWarnings("unchecked")
            public boolean isVisible() {
                boolean visible = false;
                if (dataProvider != null && !thesaurusSuggestionPanel.isVisible()) {
                    RecordCollectionServices collectionServices = ConstellioSpringUtils
                            .getRecordCollectionServices();
                    RecordCollection collection = collectionServices.get(simpleSearch.getCollectionName());
                    if (collection != null && collection.isSpellCheckerActive()
                            && simpleSearch.getAdvancedSearchRule() == null) {
                        ListOrderedMap spell = (ListOrderedMap) suggestedSearchKeyListModel.getObject();
                        if (spell.size() > 0/* && dataProvider.size() == 0 */) {
                            for (String key : (List<String>) spell.keyList()) {
                                if (spell.get(key) != null) {
                                    return visible = true;
                                }
                            }
                        }
                    }
                }
                return visible;
            }
        };
        add(spellCheckerPanel);

        dataProvider = new SearchResultsDataProvider(simpleSearch, 10);

        WebMarkupContainer searchResultsSection = new WebMarkupContainer("searchResultsSection") {
            @Override
            public boolean isVisible() {
                return StringUtils.isNotBlank(simpleSearch.getLuceneQuery());
            }
        };
        add(searchResultsSection);

        IModel detailsLabelModel = new LoadableDetachableModel() {
            @Override
            protected Object load() {
                String detailsLabel;
                QueryResponse queryResponse = dataProvider.getQueryResponse();
                long start;
                long nbRes;
                double elapsedTimeSeconds;
                if (queryResponse != null) {
                    start = queryResponse.getResults().getStart();
                    nbRes = dataProvider.size();
                    elapsedTimeSeconds = (double) queryResponse.getElapsedTime() / 1000;
                } else {
                    start = 0;
                    nbRes = 0;
                    elapsedTimeSeconds = 0;
                }
                long end = start + 10;
                if (nbRes < end) {
                    end = nbRes;
                }

                String pattern = "#.####";
                DecimalFormat elapsedTimeFormatter = new DecimalFormat(pattern);
                String elapsedTimeStr = elapsedTimeFormatter.format(elapsedTimeSeconds);

                String forTxt = new StringResourceModel("for", SearchResultsPage.this, null).getString();
                String noResultTxt = new StringResourceModel("noResult", SearchResultsPage.this, null)
                        .getString();
                String resultsTxt = new StringResourceModel("results", SearchResultsPage.this, null)
                        .getString();
                String ofTxt = new StringResourceModel("of", SearchResultsPage.this, null).getString();
                String secondsTxt = new StringResourceModel("seconds", SearchResultsPage.this, null)
                        .getString();

                String queryTxt = " ";
                if (simpleSearch.isQueryValid() && simpleSearch.getQuery() != null
                        && simpleSearch.getAdvancedSearchRule() == null) {
                    queryTxt = " " + forTxt + " " + simpleSearch.getQuery() + " ";
                }

                if (nbRes > 0) {
                    Locale locale = getLocale();
                    detailsLabel = resultsTxt + " " + NumberFormatUtils.format(start + 1, locale) + " - "
                            + NumberFormatUtils.format(end, locale) + " " + ofTxt + " "
                            + NumberFormatUtils.format(nbRes, locale) + queryTxt + "(" + elapsedTimeStr + " "
                            + secondsTxt + ")";
                } else {
                    detailsLabel = noResultTxt + " " + queryTxt + "(" + elapsedTimeStr + " " + secondsTxt + ")";
                }

                String collectionName = dataProvider.getSimpleSearch().getCollectionName();
                if (collectionName != null) {
                    RecordCollectionServices collectionServices = ConstellioSpringUtils
                            .getRecordCollectionServices();
                    RecordCollection collection = collectionServices.get(collectionName);
                    Locale displayLocale = collection.getDisplayLocale(getLocale());
                    String collectionTitle = collection.getTitle(displayLocale);
                    detailsLabel = collectionTitle + " > " + detailsLabel;
                }
                return detailsLabel;
            }
        };
        Label detailsLabel = new Label("detailsRes", detailsLabelModel);
        add(detailsLabel);

        final IModel sortOptionsModel = new LoadableDetachableModel() {

            @Override
            protected Object load() {
                List<SortChoice> choices = new ArrayList<SortChoice>();
                choices.add(new SortChoice(null, null, null));
                String collectionName = dataProvider.getSimpleSearch().getCollectionName();
                if (collectionName != null) {
                    IndexFieldServices indexFieldServices = ConstellioSpringUtils.getIndexFieldServices();
                    RecordCollectionServices collectionServices = ConstellioSpringUtils
                            .getRecordCollectionServices();
                    RecordCollection collection = collectionServices.get(collectionName);
                    for (IndexField indexField : indexFieldServices.getSortableIndexFields(collection)) {
                        String label = indexField.getLabel(IndexField.LABEL_TITLE,
                                ConstellioSession.get().getLocale());
                        if (label == null || label.isEmpty()) {
                            label = indexField.getName();
                        }
                        choices.add(new SortChoice(indexField.getName(), label, "asc"));
                        choices.add(new SortChoice(indexField.getName(), label, "desc"));
                    }
                }
                return choices;
            }
        };

        IChoiceRenderer triChoiceRenderer = new ChoiceRenderer() {
            @Override
            public Object getDisplayValue(Object object) {
                SortChoice choice = (SortChoice) object;
                String displayValue;
                if (choice.title == null) {
                    displayValue = new StringResourceModel("sort.relevance", SearchResultsPage.this, null)
                            .getString();
                } else {
                    String order = new StringResourceModel("sortOrder." + choice.order, SearchResultsPage.this,
                            null).getString();
                    displayValue = choice.title + " " + order;
                }
                return displayValue;
            }
        };
        IModel value = new Model(new SortChoice(simpleSearch.getSortField(), simpleSearch.getSortField(),
                simpleSearch.getSortOrder()));
        DropDownChoice sortField = new DropDownChoice("sortField", value, sortOptionsModel, triChoiceRenderer) {
            @Override
            protected boolean wantOnSelectionChangedNotifications() {
                return true;
            }

            @Override
            protected void onSelectionChanged(Object newSelection) {
                SortChoice choice = (SortChoice) newSelection;
                if (choice.name == null) {
                    simpleSearch.setSortField(null);
                    simpleSearch.setSortOrder(null);
                } else {
                    simpleSearch.setSortField(choice.name);
                    simpleSearch.setSortOrder(choice.order);
                }
                simpleSearch.setPage(0);

                PageFactoryPlugin pageFactoryPlugin = PluginFactory.getPlugin(PageFactoryPlugin.class);
                RequestCycle.get().setResponsePage(pageFactoryPlugin.getSearchResultsPage(),
                        SearchResultsPage.getParameters(simpleSearch));
            }

            @Override
            public boolean isVisible() {
                return ((List<?>) sortOptionsModel.getObject()).size() > 1;
            }
        };
        searchResultsSection.add(sortField);
        sortField.setNullValid(false);

        add(new AjaxLazyLoadPanel("facetsPanel") {
            @Override
            public Component getLazyLoadComponent(String markupId) {
                return new FacetsPanel(markupId, dataProvider);
            }
        });

        final IModel featuredLinkModel = new LoadableDetachableModel() {
            @Override
            protected Object load() {
                FeaturedLink suggestion;
                RecordCollectionServices collectionServices = ConstellioSpringUtils
                        .getRecordCollectionServices();
                FeaturedLinkServices featuredLinkServices = ConstellioSpringUtils.getFeaturedLinkServices();
                Long featuredLinkId = simpleSearch.getFeaturedLinkId();
                if (featuredLinkId != null) {
                    suggestion = featuredLinkServices.get(featuredLinkId);
                } else {
                    String collectionName = simpleSearch.getCollectionName();
                    if (simpleSearch.getAdvancedSearchRule() == null) {
                        String text = simpleSearch.getQuery();
                        RecordCollection collection = collectionServices.get(collectionName);
                        suggestion = featuredLinkServices.suggest(text, collection);
                        if (suggestion == null) {
                            SynonymServices synonymServices = ConstellioSpringUtils.getSynonymServices();
                            List<String> synonyms = synonymServices.getSynonyms(text, collectionName);
                            if (!synonyms.isEmpty()) {
                                for (String synonym : synonyms) {
                                    if (!synonym.equals(text)) {
                                        suggestion = featuredLinkServices.suggest(synonym, collection);
                                    }
                                    if (suggestion != null) {
                                        break;
                                    }
                                }
                            }
                        }
                    } else {
                        suggestion = new FeaturedLink();
                    }
                }
                return suggestion;
            }
        };
        IModel featuredLinkTitleModel = new LoadableDetachableModel() {
            @Override
            protected Object load() {
                FeaturedLink featuredLink = (FeaturedLink) featuredLinkModel.getObject();
                return featuredLink.getTitle(getLocale());
            }
        };
        final IModel featuredLinkDescriptionModel = new LoadableDetachableModel() {
            @Override
            protected Object load() {
                FeaturedLink featuredLink = (FeaturedLink) featuredLinkModel.getObject();
                StringBuffer descriptionSB = new StringBuffer();
                String description = featuredLink.getDescription(getLocale());
                if (description != null) {
                    descriptionSB.append(description);
                    String lookFor = "${";
                    int indexOfLookFor = -1;
                    while ((indexOfLookFor = descriptionSB.indexOf(lookFor)) != -1) {
                        int indexOfEnclosingQuote = descriptionSB.indexOf("}", indexOfLookFor);
                        String featuredLinkIdStr = descriptionSB.substring(indexOfLookFor + lookFor.length(),
                                indexOfEnclosingQuote);

                        int indexOfTagBodyStart = descriptionSB.indexOf(">", indexOfEnclosingQuote) + 1;
                        int indexOfTagBodyEnd = descriptionSB.indexOf("</a>", indexOfTagBodyStart);
                        String capsuleQuery = descriptionSB.substring(indexOfTagBodyStart, indexOfTagBodyEnd);
                        if (capsuleQuery.indexOf("<br/>") != -1) {
                            capsuleQuery = StringUtils.remove(capsuleQuery, "<br/>");
                        }
                        if (capsuleQuery.indexOf("<br />") != -1) {
                            capsuleQuery = StringUtils.remove(capsuleQuery, "<br />");
                        }

                        try {
                            String linkedCapsuleURL = getFeaturedLinkURL(new Long(featuredLinkIdStr));
                            descriptionSB.replace(indexOfLookFor, indexOfEnclosingQuote + 1, linkedCapsuleURL);
                        } catch (NumberFormatException e) {
                            // Ignore
                        }
                    }
                }
                return descriptionSB.toString();
            }

            private String getFeaturedLinkURL(Long featuredLinkId) {
                SimpleSearch clone = simpleSearch.clone();
                clone.setFeaturedLinkId(featuredLinkId);
                PageFactoryPlugin pageFactoryPlugin = PluginFactory.getPlugin(PageFactoryPlugin.class);
                String url = RequestCycle.get()
                        .urlFor(pageFactoryPlugin.getSearchResultsPage(), getParameters(clone)).toString();
                return url;
            }
        };

        WebMarkupContainer featuredLink = new WebMarkupContainer("featuredLink", featuredLinkModel) {
            @Override
            public boolean isVisible() {
                boolean visible = super.isVisible();
                if (visible) {
                    if (featuredLinkModel.getObject() != null) {
                        String description = (String) featuredLinkDescriptionModel.getObject();
                        visible = StringUtils.isNotEmpty(description);
                    } else {
                        visible = false;
                    }
                }
                DataView dataView = (DataView) searchResultsPanel.getDataView();
                return visible && dataView.getCurrentPage() == 0;
            }
        };
        searchResultsSection.add(featuredLink);
        featuredLink.add(new Label("title", featuredLinkTitleModel));
        featuredLink.add(new WebMarkupContainer("description", featuredLinkDescriptionModel) {
            @Override
            protected void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
                String descriptionHTML = (String) getModel().getObject();
                replaceComponentTagBody(markupStream, openTag, descriptionHTML);
            }
        });

        searchResultsSection
                .add(searchResultsPanel = new SearchResultsPanel("resultatsRecherchePanel", dataProvider));
    }
}

From source file:com.doculibre.constellio.wicket.panels.admin.stats.CollectionStatsPanel.java

License:Open Source License

public CollectionStatsPanel(String id, final String collectionName) {
    super(id);//from ww w.  j a  va2s .  co m

    endDate = new Date();
    startDate = DateUtils.addMonths(endDate, -1);

    Form form = new Form("form") {
        @Override
        protected void onSubmit() {
            statsPanel.replaceWith(statsPanel = new CollectionStatsReportPanel(statsPanel.getId(),
                    collectionName, statsType, startDate, endDate, rows, includeFederatedCollections));
        }
    };
    add(form);

    IModel queryExcludeRegexpsModel = new Model() {
        @Override
        public Object getObject() {
            String result;
            AdminCollectionPanel adminCollectionPanel = (AdminCollectionPanel) findParent(
                    AdminCollectionPanel.class);
            RecordCollection collection = adminCollectionPanel.getCollection();
            CollectionStatsFilter statsFilter = collection.getStatsFilter();
            if (statsFilter != null) {
                StringBuffer sb = new StringBuffer();
                Set<String> existingRegexps = statsFilter.getQueryExcludeRegexps();
                for (String existingRegexp : existingRegexps) {
                    sb.append(existingRegexp);
                    sb.append("\n");
                }
                result = sb.toString();
            } else {
                result = null;
            }
            return result;
        }

        @Override
        public void setObject(Object object) {
            String queryExcludeRegexpsStr = (String) object;
            String[] newRegexpsArray = StringUtils.split(queryExcludeRegexpsStr, "\n");
            List<String> newRegexps = new ArrayList<String>();
            for (String newRegexp : newRegexpsArray) {
                newRegexps.add(newRegexp.trim());
            }

            AdminCollectionPanel adminCollectionPanel = (AdminCollectionPanel) findParent(
                    AdminCollectionPanel.class);
            RecordCollection collection = adminCollectionPanel.getCollection();
            CollectionStatsFilter statsFilter = collection.getStatsFilter();
            if (statsFilter == null) {
                statsFilter = new CollectionStatsFilter();
                statsFilter.setRecordCollection(collection);
                collection.setStatsFilter(statsFilter);
            }

            Set<String> existingRegexps = statsFilter.getQueryExcludeRegexps();
            if (!CollectionUtils.isEqualCollection(existingRegexps, newRegexps)) {
                RecordCollectionServices collectionServices = ConstellioSpringUtils
                        .getRecordCollectionServices();
                EntityManager entityManager = ConstellioPersistenceContext.getCurrentEntityManager();
                if (!entityManager.getTransaction().isActive()) {
                    entityManager.getTransaction().begin();
                }
                existingRegexps.clear();
                existingRegexps.addAll(newRegexps);
                collectionServices.makePersistent(collection, false);

                entityManager.getTransaction().commit();
            }
        }
    };

    form.add(new TextArea("queryExcludeRegexps", queryExcludeRegexpsModel));
    form.add(new DateTextField("startDate", new PropertyModel(this, "startDate"), "yyyy-MM-dd")
            .add(new DatePicker()));
    form.add(new DateTextField("endDate", new PropertyModel(this, "endDate"), "yyyy-MM-dd")
            .add(new DatePicker()));
    form.add(new TextField("rows", new PropertyModel(this, "rows"), Integer.class));
    form.add(new CheckBox("includeFederatedCollections",
            new PropertyModel(this, "includeFederatedCollections")) {
        @Override
        public boolean isVisible() {
            boolean visible = super.isVisible();
            if (visible) {
                AdminCollectionPanel adminCollectionPanel = (AdminCollectionPanel) findParent(
                        AdminCollectionPanel.class);
                RecordCollection collection = adminCollectionPanel.getCollection();
                visible = collection.isFederationOwner();
            }
            return visible ? visible : false;
        }
    });

    form.add(new DropDownChoice("statsType", new PropertyModel(this, "statsType"), StatsConstants.ALL_STATS,
            new StringResourceChoiceRenderer("statsType", this)));

    form.add(new Label("title", new PropertyModel(this, "statsType")));
    statsPanel = new AjaxLazyLoadPanel("statsPanel") {
        @Override
        public Component getLazyLoadComponent(String markupId) {
            return new CollectionStatsReportPanel(markupId, collectionName, statsType, startDate, endDate, rows,
                    includeFederatedCollections);
        }
    };
    form.add(statsPanel);
}

From source file:com.koodaripalvelut.common.wicket.webtest.openid.InfoPage.java

License:Open Source License

public InfoPage() {
    add(new AjaxLazyLoadPanel(SIGNIN_PANEL_ID) {

        private static final long serialVersionUID = 1L;

        @Override//ww w . j  av a 2  s  .  c o m
        public Component getLazyLoadComponent(final String markupId) {
            return new OpenIDPanel(markupId);
        }

        @Override
        public Component getLoadingComponent(final String markupId) {
            final Label label = (Label) super.getLoadingComponent(markupId);
            final StringBuilder sb = new StringBuilder(label.getDefaultModelObjectAsString());
            sb.append("<div>");
            sb.append(InfoPage.this.getString("loadingMesssage"));
            sb.append("</div>");
            label.setDefaultModel(Model.of(sb.toString()));
            return label;
        }
    });
}

From source file:com.mycompany.DropDownPage.java

License:Apache License

public DropDownPage() {

    List<ChoiceElement> years = Arrays.asList(new ChoiceElement("2010", "2010N"),
            new ChoiceElement("2011", "2011N"), new ChoiceElement("2012", "2012N"),
            new ChoiceElement("2013", "2013N"), new ChoiceElement("2014", "2014N"),
            new ChoiceElement("2015", "2015N"));
    final DropDownChoice<ChoiceElement> choice = new DropDownChoice<ChoiceElement>("choice",
            new Model<ChoiceElement>(), years, new IChoiceRenderer<ChoiceElement>() {
                public Object getDisplayValue(ChoiceElement object) {
                    return object.getName();
                }//from  ww  w . ja  va2  s .  c o  m

                public String getIdValue(ChoiceElement object, int index) {
                    return object.getId();
                }
            });
    final WebMarkupContainer dataPanel = new WebMarkupContainer("dataPanel");
    dataPanel.setOutputMarkupId(true);
    dataPanel.add(new EmptyPanel("dataList"));
    choice.add(new OnChangeAjaxBehavior() {
        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            dataPanel.remove("dataList");
            dataPanel.add(new AjaxLazyLoadPanel("dataList") {

                @Override
                public Component getLazyLoadComponent(String markupId) {
                    return new PagingNavigatorPanel(markupId, choice.getModelObject().getName(),
                            choice.getValue());
                }
            });
            target.add(dataPanel);
        }
    });
    add(dataPanel);
    add(choice);
}

From source file:com.mycompany.PagingNavigatorPanel.java

License:Apache License

public PagingNavigatorPanel(String id, String name, final String value) {
    super(id);//from   w ww.ja  va2 s.c o  m
    Label output = new Label("output", name);
    output.setOutputMarkupId(true);
    add(output);

    HashMap<String, List<ListElement>> dataMap = createDataMap();

    final DataView<ListElement> view = new DataView<ListElement>("holidayData",
            new ListDataProvider<ListElement>(dataMap.get(value)), 5) {
        @Override
        protected void populateItem(Item<ListElement> item) {
            ListElement element = item.getModelObject();
            item.add(new Label("no", new PropertyModel<String>(element, "no")));
            item.add(new Label("monthDay", new PropertyModel<String>(element, "monthDay")));
            item.add(new Label("week", new PropertyModel<String>(element, "week")));
            item.add(new Label("name", new PropertyModel<String>(element, "name")));
        }
    };
    view.setOutputMarkupId(true);

    final WebMarkupContainer dataContainer = new WebMarkupContainer("dataContainer");
    dataContainer.setOutputMarkupId(true);
    dataContainer.add(new AjaxLazyLoadPanel("dataView") {
        @Override
        public Component getLazyLoadComponent(String markupId) {
            return new DataListPanel(markupId, value, view);
        }
    });

    add(dataContainer);
    add(new AjaxPagingNavigator("paging", view));
}

From source file:com.romeikat.datamessie.core.base.ui.page.AbstractAuthenticatedPage.java

License:Open Source License

private void initialize() {
    // Active project
    final IModel<ProjectDto> activeProjectModel = new LoadableDetachableModel<ProjectDto>() {

        private static final long serialVersionUID = 1L;

        @Override/*from  www.j ava2  s .  c o m*/
        protected ProjectDto load() {
            // Determine requested project id
            final StringValue projectParameter = getRequest().getRequestParameters()
                    .getParameterValue("project");
            // Load respective project
            ProjectDto activeProject;
            if (projectParameter.isNull()) {
                activeProject = getDefaultProject();
            } else {
                final Long userId = DataMessieSession.get().getUserId();
                activeProject = projectDao.getAsDto(sessionFactory.getCurrentSession(),
                        projectParameter.toLong(), userId);
                if (activeProject == null) {
                    activeProject = getDefaultProject();
                }
            }
            // Ensure project parameter
            if (activeProject != null) {
                getPageParameters().set("project", activeProject.getId());
                DataMessieSession.get().getDocumentsFilterSettings().setProjectId(activeProject.getId());
            }
            // Done
            return activeProject;
        }
    };

    aciveProjectDropDownChoice = new ProjectSelector("activeProjectSelector", activeProjectModel) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onSelectionChanged(final ProjectDto newSelection) {
            if (newSelection == null) {
                return;
            }

            final PageParameters projectPageParameters = new PageParameters();
            final Long selectedProjectId = newSelection.getId();
            projectPageParameters.set("project", selectedProjectId);
            final Class<? extends Page> responsePage = AbstractAuthenticatedPage.this.getNavigationLinkClass();
            final PageParameters pageParameters = getDefaultPageParameters(projectPageParameters);
            AbstractAuthenticatedPage.this.setResponsePage(responsePage, pageParameters);
        }

        @Override
        protected boolean wantOnSelectionChangedNotifications() {
            return true;
        }
    };
    add(aciveProjectDropDownChoice);

    // Navigation links
    final List<NavigationLink<? extends Page>> navigationLinks = getDataMessieApplication()
            .getNavigationLinks();
    final ListView<NavigationLink<? extends Page>> navigationLinksListView = new ListView<NavigationLink<? extends Page>>(
            "navigationLinks", navigationLinks) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<NavigationLink<? extends Page>> item) {
            // Link
            final NavigationLink<? extends Page> navigationLink = item.getModelObject();
            final PageParameters projectPageParameters = createProjectPageParameters();
            final BookmarkablePageLink<? extends Page> bookmarkablePageLink = createBookmarkablePageLink(
                    "navigationLink", navigationLink, projectPageParameters);
            final Label bookmarkablePageLinkLabel = new Label("navigationLinkLabel", navigationLink.getLabel());
            // Active link
            if (AbstractAuthenticatedPage.this.getNavigationLinkClass() == navigationLink.getPageClass()) {
                markLinkSelected(bookmarkablePageLink);
            }
            // Done
            bookmarkablePageLink.add(bookmarkablePageLinkLabel);
            item.add(bookmarkablePageLink);
        }
    };
    add(navigationLinksListView);

    // Sign out link
    signOutLink = new Link<SignInPage>("signOutLink") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick() {
            AuthenticatedWebSession.get().invalidate();
            setResponsePage(getApplication().getHomePage());
        }
    };
    add(signOutLink);

    // Side panels
    final List<SidePanel> sidePanels = getDataMessieApplication().getSidePanels();
    final ListView<SidePanel> sidePanelsListView = new ListView<SidePanel>("sidePanels", sidePanels) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<SidePanel> item) {
            // Link
            final SidePanel sidePanel = item.getModelObject();
            final Panel panel = sidePanel.getPanel();
            item.add(panel);
        }
    };
    add(sidePanelsListView);

    // Task executions container
    final WebMarkupContainer taskExecutionsContainer = new WebMarkupContainer("taskExecutionsContainer");
    taskExecutionsContainer.setOutputMarkupId(true);
    taskExecutionsContainer.add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(selfUpdatingInterval)));
    add(taskExecutionsContainer);
    // Task executions
    taskExecutionsPanel = new AjaxLazyLoadPanel("taskExecutionsPanel") {
        private static final long serialVersionUID = 1L;

        @Override
        public Component getLazyLoadComponent(final String id) {
            final TaskExecutionsPanel taskExecutionsPanel = new TaskExecutionsPanel(id);
            return taskExecutionsPanel;
        }

    };
    taskExecutionsContainer.add(taskExecutionsPanel);
}

From source file:com.romeikat.datamessie.core.base.ui.panel.AbstractTableContainerPanel.java

License:Open Source License

@Override
protected void onConfigure() {
    super.onConfigure();

    tablePanel = new AjaxLazyLoadPanel("tablePanel") {
        private static final long serialVersionUID = 1L;

        @Override// w w w. j  a v  a2 s. c  o m
        public Component getLazyLoadComponent(final String id) {
            final AbstractTablePanel<?, ?, ?> tablePanel = createTablePanel(id);
            tablePanel.setOutputMarkupId(true);
            return tablePanel;
        }
    };
    tablePanel.setOutputMarkupId(true);
    addOrReplace(tablePanel);

}

From source file:com.romeikat.datamessie.core.base.ui.panel.StatisticsPanel.java

License:Open Source License

public StatisticsPanel(final String id) {
    super(id);/*from  w  w w  .ja v a 2  s . co m*/

    setOutputMarkupId(true);
    add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(SELF_UPDATING_INTERVAL)) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void updateAjaxAttributes(final AjaxRequestAttributes attributes) {
            super.updateAjaxAttributes(attributes);
            attributes.setRequestTimeout(AJAX_TIMEOUT);
        }
    });

    // Today's history
    final AjaxLazyLoadPanel todaysStatisticsPanel = new AjaxLazyLoadPanel("todaysStatistics") {
        private static final long serialVersionUID = 1L;

        @Override
        public Component getLazyLoadComponent(final String id) {
            final StatisticsPeriodPanel statisticsPeriodPanel = new StatisticsPeriodPanel(id, 1);
            return statisticsPeriodPanel;
        }

        @Override
        protected void updateAjaxAttributes(final AjaxRequestAttributes attributes) {
            super.updateAjaxAttributes(attributes);
            attributes.setRequestTimeout(AJAX_TIMEOUT);
        }
    };
    add(todaysStatisticsPanel);
}

From source file:com.romeikat.datamessie.core.view.ui.page.CrawlingsPage.java

License:Open Source License

private void initialize() {
    // Sources overview
    crawlingsOverviewPanel = new AjaxLazyLoadPanel("crawlingsOverviewPanel") {
        private static final long serialVersionUID = 1L;

        @Override/*from   w  w w . j  av a  2  s . co  m*/
        public Component getLazyLoadComponent(final String id) {
            return new CrawlingsOverviewPanel(id, DataMessieSession.get().getDocumentsFilterSettingsModel());
        }

        @Override
        public void onConfigure() {
            super.onConfigure();
            setVisible(getActiveProject() != null);
        }
    };
    crawlingsOverviewPanel.setOutputMarkupId(true);
    add(crawlingsOverviewPanel);
}

From source file:com.romeikat.datamessie.core.view.ui.page.DocumentsPage.java

License:Open Source License

private void initialize() {
    // Documents overview
    documentsOverviewPanel = new AjaxLazyLoadPanel("documentsOverviewPanel") {
        private static final long serialVersionUID = 1L;

        @Override//w  w w  . j  ava  2 s. co m
        public Component getLazyLoadComponent(final String id) {
            return new DocumentsOverviewPanel(id, DataMessieSession.get().getDocumentsFilterSettingsModel());
        }

        @Override
        public void onConfigure() {
            super.onConfigure();
            setVisible(getActiveProject() != null);
        }
    };
    documentsOverviewPanel.setOutputMarkupId(true);
    add(documentsOverviewPanel);
}