Search in sources :

Example 1 with Activator

use of eu.esdihumboldt.hale.server.webapp.war.internal.Activator 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)

Aggregations

Activator (eu.esdihumboldt.hale.server.webapp.war.internal.Activator)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ExternalLink (org.apache.wicket.markup.html.link.ExternalLink)1 ListItem (org.apache.wicket.markup.html.list.ListItem)1 ListView (org.apache.wicket.markup.html.list.ListView)1 LoadableDetachableModel (org.apache.wicket.model.LoadableDetachableModel)1 Bundle (org.osgi.framework.Bundle)1 DefaultContextPathStrategy (org.springframework.osgi.web.deployer.support.DefaultContextPathStrategy)1