Search in sources :

Example 1 with LoadableDetachableModel

use of org.apache.wicket.model.LoadableDetachableModel in project hale by halestudio.

the class WelcomePage method addControls.

@Override
protected void addControls(boolean loggedIn) {
    super.addControls(loggedIn);
    // create a model which loads the list of war bundles dynamically
    IModel<List<BundleInfo>> listViewModel = new LoadableDetachableModel<List<BundleInfo>>() {

        private static final long serialVersionUID = 8919477639656535497L;

        @Override
        protected List<BundleInfo> load() {
            // get context paths of other war bundles
            List<BundleInfo> wars = new ArrayList<BundleInfo>();
            Activator aa = Activator.getInstance();
            DefaultContextPathStrategy s = new DefaultContextPathStrategy();
            for (Bundle b : aa.getWarBundles()) {
                if (isHidden(b)) {
                    continue;
                }
                BundleInfo bi = new BundleInfo();
                bi.name = getHumanReadableName(b);
                bi.path = s.getContextPath(b);
                wars.add(bi);
            }
            // sort list
            Collections.sort(wars, new Comparator<BundleInfo>() {

                @Override
                public int compare(BundleInfo o1, BundleInfo o2) {
                    return o1.name.compareTo(o2.name);
                }
            });
            return wars;
        }
    };
    // fill list view
    ListView<BundleInfo> lv = new ListView<BundleInfo>("applications", listViewModel) {

        private static final long serialVersionUID = -3861139762631118268L;

        @Override
        protected void populateItem(ListItem<BundleInfo> item) {
            BundleInfo bi = item.getModelObject();
            item.add(new ExternalLink("path", bi.path, bi.name));
        }
    };
    add(lv);
}
Also used : Bundle(org.osgi.framework.Bundle) ArrayList(java.util.ArrayList) DefaultContextPathStrategy(org.springframework.osgi.web.deployer.support.DefaultContextPathStrategy) ExternalLink(org.apache.wicket.markup.html.link.ExternalLink) ListView(org.apache.wicket.markup.html.list.ListView) Activator(eu.esdihumboldt.hale.server.webapp.war.internal.Activator) LoadableDetachableModel(org.apache.wicket.model.LoadableDetachableModel) ArrayList(java.util.ArrayList) List(java.util.List) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 2 with LoadableDetachableModel

use of org.apache.wicket.model.LoadableDetachableModel in project the-app by devops-dojo.

the class FeedbackPanel method wrapperContainer.

private Component wrapperContainer() {
    WebMarkupContainer wrapperContainer = new WebMarkupContainer("wrapperContainer");
    wrapperContainer.add(feedbackPanel());
    wrapperContainer.add(new AttributeAppender("class", new LoadableDetachableModel<String>() {

        @Override
        protected String load() {
            if (feedbackPanel.anyMessage(FeedbackMessage.ERROR)) {
                return "alert-danger";
            }
            if (feedbackPanel.anyMessage(FeedbackMessage.SUCCESS)) {
                return "alert-success";
            }
            if (feedbackPanel.anyMessage(FeedbackMessage.INFO)) {
                return "alert-info";
            }
            return "";
        }
    }, " "));
    return wrapperContainer;
}
Also used : LoadableDetachableModel(org.apache.wicket.model.LoadableDetachableModel) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 3 with LoadableDetachableModel

use of org.apache.wicket.model.LoadableDetachableModel in project webanno by webanno.

the class CurationPage method getAllowedProjects.

private IModel<List<DecoratedObject<Project>>> getAllowedProjects() {
    return new LoadableDetachableModel<List<DecoratedObject<Project>>>() {

        private static final long serialVersionUID = -2518743298741342852L;

        @Override
        protected List<DecoratedObject<Project>> load() {
            User user = userRepository.get(SecurityContextHolder.getContext().getAuthentication().getName());
            List<DecoratedObject<Project>> allowedProject = new ArrayList<>();
            List<Project> projectsWithFinishedAnnos = projectService.listProjectsWithFinishedAnnos();
            for (Project project : projectService.listProjects()) {
                if (SecurityUtil.isCurator(project, projectService, user)) {
                    DecoratedObject<Project> dp = DecoratedObject.of(project);
                    if (projectsWithFinishedAnnos.contains(project)) {
                        dp.setColor("green");
                    } else {
                        dp.setColor("red");
                    }
                    allowedProject.add(dp);
                }
            }
            return allowedProject;
        }
    };
}
Also used : Project(de.tudarmstadt.ukp.clarin.webanno.model.Project) DecoratedObject(de.tudarmstadt.ukp.clarin.webanno.support.wicket.DecoratedObject) User(de.tudarmstadt.ukp.clarin.webanno.security.model.User) LoadableDetachableModel(org.apache.wicket.model.LoadableDetachableModel) ArrayList(java.util.ArrayList)

Example 4 with LoadableDetachableModel

use of org.apache.wicket.model.LoadableDetachableModel in project webanno by webanno.

the class CorrectionPage method getAllowedProjects.

private IModel<List<DecoratedObject<Project>>> getAllowedProjects() {
    return new LoadableDetachableModel<List<DecoratedObject<Project>>>() {

        private static final long serialVersionUID = -2518743298741342852L;

        @Override
        protected List<DecoratedObject<Project>> load() {
            User user = userRepository.get(SecurityContextHolder.getContext().getAuthentication().getName());
            List<DecoratedObject<Project>> allowedProject = new ArrayList<>();
            for (Project project : projectService.listProjects()) {
                if (SecurityUtil.isAnnotator(project, projectService, user) && WebAnnoConst.PROJECT_TYPE_CORRECTION.equals(project.getMode())) {
                    allowedProject.add(DecoratedObject.of(project));
                }
            }
            return allowedProject;
        }
    };
}
Also used : Project(de.tudarmstadt.ukp.clarin.webanno.model.Project) DecoratedObject(de.tudarmstadt.ukp.clarin.webanno.support.wicket.DecoratedObject) User(de.tudarmstadt.ukp.clarin.webanno.security.model.User) LoadableDetachableModel(org.apache.wicket.model.LoadableDetachableModel) ArrayList(java.util.ArrayList)

Example 5 with LoadableDetachableModel

use of org.apache.wicket.model.LoadableDetachableModel in project wicket by apache.

the class EnhancedPageView method newTree.

private AbstractTree<TreeNode> newTree() {
    TreeProvider provider = new TreeProvider();
    IModel<Set<TreeNode>> expandStateModel = new LoadableDetachableModel<Set<TreeNode>>() {

        private static final long serialVersionUID = 1L;

        @Override
        protected Set<TreeNode> load() {
            return expandState;
        }
    };
    AbstractTree<TreeNode> tree = new DefaultTableTree<TreeNode, Void>("tree", visibleColumns, provider, Integer.MAX_VALUE, expandStateModel) {

        private static final long serialVersionUID = 1L;

        @Override
        protected Item<TreeNode> newRowItem(String id, int index, IModel<TreeNode> model) {
            return new OddEvenItem<>(id, index, model);
        }
    };
    tree.setOutputMarkupId(true);
    return tree;
}
Also used : IModel(org.apache.wicket.model.IModel) HashSet(java.util.HashSet) Set(java.util.Set) OddEvenItem(org.apache.wicket.markup.repeater.OddEvenItem) SortableTreeProvider(org.apache.wicket.extensions.markup.html.repeater.util.SortableTreeProvider) LoadableDetachableModel(org.apache.wicket.model.LoadableDetachableModel) DefaultTableTree(org.apache.wicket.extensions.markup.html.repeater.tree.DefaultTableTree)

Aggregations

LoadableDetachableModel (org.apache.wicket.model.LoadableDetachableModel)8 ArrayList (java.util.ArrayList)5 Project (de.tudarmstadt.ukp.clarin.webanno.model.Project)2 User (de.tudarmstadt.ukp.clarin.webanno.security.model.User)2 DecoratedObject (de.tudarmstadt.ukp.clarin.webanno.support.wicket.DecoratedObject)2 List (java.util.List)2 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)2 ListItem (org.apache.wicket.markup.html.list.ListItem)2 ListView (org.apache.wicket.markup.html.list.ListView)2 JSONArray (com.github.openjson.JSONArray)1 JSONObject (com.github.openjson.JSONObject)1 Options (com.googlecode.wicket.jquery.core.Options)1 Calendar (com.googlecode.wicket.jquery.ui.calendar.Calendar)1 CalendarView (com.googlecode.wicket.jquery.ui.calendar.CalendarView)1 GoogleCalendar (com.googlecode.wicket.jquery.ui.calendar.EventSource.GoogleCalendar)1 Button (com.googlecode.wicket.jquery.ui.form.button.Button)1 TransformationWorkspace (eu.esdihumboldt.hale.common.headless.transform.TransformationWorkspace)1 JobPanel (eu.esdihumboldt.hale.server.webapp.components.JobPanel)1 Activator (eu.esdihumboldt.hale.server.webapp.war.internal.Activator)1