List of usage examples for org.apache.wicket.markup.html.list ListView ListView
public ListView(final String id, final List<T> list)
From source file:edu.tsinghua.software.pages.cluster.ClusterView.java
License:Apache License
/** * Construtor/*w w w . j a v a 2 s . c o m*/ * @throws TException * @throws InterruptedException * @throws IOException */ public ClusterView() throws TException, IOException, InterruptedException { super(); inti(); //add keyspace button add(new AjaxLink("deleteKsLinkButton") { @Override public void onClick(AjaxRequestTarget target) { setResponsePage(DeleteKeyspacePage.class, pageParameters); } }); //delete keyspace button add(new AjaxLink("addKsLinkButton") { @Override public void onClick(AjaxRequestTarget target) { setResponsePage(AddKeyspace.class, pageParameters); } }); // cluster detials final ClusterPropertyModel clusterProperty = new ClusterPropertyModel(); this.setClusterProperties(clusterProperty); add(new Label("name", clusterProperty.getName())); add(new Label("snitch", clusterProperty.getSnitch())); add(new Label("partitioner", clusterProperty.getPatitioner())); add(new Label("schema", clusterProperty.getSchema())); add(new Label("api", clusterProperty.getApi())); add(new Label("keyspaceNum", clusterProperty.getKeyspace())); // keyspace viewList ListView keyspaceView = new ListView("keyspaceList", keyspaceNameList) { /** * */ private static final long serialVersionUID = 1L; protected void populateItem(ListItem item) { PageParameters keyspaceParameters = new PageParameters(); keyspaceParameters.add("clusterParam", clusterName); keyspaceParameters.add("keyspaceParam", item.getModelObject().toString()); item.add(new BookmarkablePageLink<Void>("keyspaceLink", KeyspacePage.class, keyspaceParameters) .add(new Label("keyspaceName", item.getModel()))); } }; add(keyspaceView); }
From source file:edu.tsinghua.software.pages.keyspace.KeyspacePage.java
License:Apache License
/** * KeyspacePage Contruct/*from w ww.ja v a 2s . c o m*/ * @param pageParameters * @throws InvalidRequestException * @throws TException * @throws NotFoundException * */ public KeyspacePage(final PageParameters pageParameters) throws NotFoundException, TException, InvalidRequestException { super(); init(pageParameters); // add neviation, cluster>>name add(new BookmarkablePageLink<Void>("clusterNevigation", ClusterView.class) .add(new Label("clusterName", clusterName))); add(new Label("keyspaceName", keyspaceName)); ConfirmLink deleteKeyspaceButton = new ConfirmLink("deleteKslinkButton", "? " + this.keyspaceName + "?") { @Override public void onClick() { try { client.dropKeyspace(keyspaceName); setResponsePage(new KeyspacePage(pageParameters)); } catch (Exception e) { e.printStackTrace(); } setResponsePage(ClusterView.class, pageParameters); } }; //for mutiple languge String deleteKsStr; if (getSession().getLocale() == Locale.US) { deleteKsStr = "Delete"; } else { deleteKsStr = ""; } deleteKeyspaceButton .add(new AttributeModifier("value", new Model(deleteKsStr + " '" + this.keyspaceName + "'"))); add(deleteKeyspaceButton); add(new AjaxLink("editKslinkButton") { @Override public void onClick(AjaxRequestTarget target) { setResponsePage(EditKeyspace.class, pageParameters); } }); add(new AjaxLink("addCflinkButton") { @Override public void onClick(AjaxRequestTarget target) { setResponsePage(AddColumnFamily.class, pageParameters); } }); // delete ColumnFamily button add(new AjaxLink("deleteCflinkButton") { @Override public void onClick(AjaxRequestTarget target) { setResponsePage(DeleteColumnFamilyPage.class, pageParameters); } }); //columnFamily List ListView cfView = new ListView("cfList", new CfListModel(this.keyspaceName, this.client)) { private static final long serialVersionUID = 1L; protected void populateItem(ListItem item) { PageParameters params = new PageParameters(); params.add("columnFamilyParam", item.getModelObject().toString()); params.add("keyspaceParam", keyspaceName); params.add("clusterParam", clusterName); item.add(new BookmarkablePageLink<Void>("cfLink", ColumnFamilyPage.class, params) .add(new Label("cfName", item.getModel()))); } }; add(cfView); add(new KeyspaceInfoPanel("kespaceInfo", ksDef)); Map<String, String> keyspaceStatics = clusterManager.getKeyspaceStatics(keyspaceName); add(new KeyspaceStaticsPanel("kespaceStatic", keyspaceStatics)); }
From source file:edu.uci.ics.hyracks.control.cc.adminconsole.pages.IndexPage.java
License:Apache License
public IndexPage() throws Exception { ClusterControllerService ccs = getAdminConsoleApplication().getClusterControllerService(); GetNodeSummariesJSONWork gnse = new GetNodeSummariesJSONWork(ccs); ccs.getWorkQueue().scheduleAndSync(gnse); JSONArray nodeSummaries = gnse.getSummaries(); add(new Label("node-count", String.valueOf(nodeSummaries.length()))); ListView<JSONObject> nodeList = new ListView<JSONObject>("node-list", JSONUtils.toList(nodeSummaries)) { private static final long serialVersionUID = 1L; @Override/*from w ww. ja va 2 s . co m*/ protected void populateItem(ListItem<JSONObject> item) { JSONObject o = item.getModelObject(); try { item.add(new Label("node-id", o.getString("node-id"))); item.add(new Label("heap-used", o.getString("heap-used"))); item.add(new Label("system-load-average", o.getString("system-load-average"))); PageParameters params = new PageParameters(); params.add("node-id", o.getString("node-id")); item.add(new BookmarkablePageLink<Object>("node-details", NodeDetailsPage.class, params)); } catch (JSONException e) { throw new RuntimeException(e); } } }; add(nodeList); GetJobSummariesJSONWork gjse = new GetJobSummariesJSONWork(ccs); ccs.getWorkQueue().scheduleAndSync(gjse); JSONArray jobSummaries = gjse.getSummaries(); ListView<JSONObject> jobList = new ListView<JSONObject>("jobs-list", JSONUtils.toList(jobSummaries)) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<JSONObject> item) { JSONObject o = item.getModelObject(); try { item.add(new Label("job-id", o.getString("job-id"))); item.add(new Label("status", o.getString("status"))); item.add(new Label("create-time", o.getString("create-time"))); item.add(new Label("start-time", o.getString("start-time"))); item.add(new Label("end-time", o.getString("end-time"))); PageParameters params = new PageParameters(); params.add("job-id", o.getString("job-id")); item.add(new BookmarkablePageLink<Object>("job-details", JobDetailsPage.class, params)); } catch (JSONException e) { throw new RuntimeException(e); } } }; add(jobList); }
From source file:eu.clarin.cmdi.virtualcollectionregistry.gui.menu.AjaxPopupMenu.java
License:Open Source License
public AjaxPopupMenu(String id, IModel<String> title) { super(id);/*from w w w .j a v a2 s . co m*/ setRenderBodyOnly(true); add(new Label("title", title)); add(new ListView<MenuItem>("items", items) { @Override protected void populateItem(ListItem<MenuItem> item) { final MenuItem menuitem = item.getModelObject(); final AbstractLink link = menuitem.newLink("link"); link.add(new Label("label", menuitem.getLabel())); String cssClass = menuitem.getCssClass(); if (cssClass != null) { link.add(new AttributeModifier("class", cssClass)); } item.add(link); item.setVisible(menuitem.isVisible()); item.setEnabled(menuitem.isEnabled()); } }); }
From source file:eu.esdihumboldt.hale.server.projects.war.components.ProjectList.java
License:Open Source License
/** * Constructor/*from w w w . j a v a 2 s .com*/ * * @param id the panel id * @param showCaption if the caption shall be shown */ public ProjectList(String id, boolean showCaption) { super(id); // projects list final IModel<? extends List<String>> projectsModel = new LoadableDetachableModel<List<String>>() { private static final long serialVersionUID = 7277175702043541004L; @Override protected List<String> load() { return new ArrayList<String>(projects.getResources()); } }; final ListView<String> projectList = new ListView<String>("projects", projectsModel) { private static final long serialVersionUID = -6740090246572869212L; /** * @see ListView#populateItem(ListItem) */ @Override protected void populateItem(ListItem<String> item) { final boolean odd = item.getIndex() % 2 != 0; if (odd) { item.add(AttributeModifier.replace("class", "odd")); } final String id = item.getModelObject(); // identifier item.add(new Label("identifier", id)); // status Status status = projects.getStatus(id); String statusImagePath; String statusTitle; switch (status) { case ACTIVE: statusImagePath = "images/ok.png"; statusTitle = "Active"; break; case INACTIVE: statusImagePath = "images/sleeping.gif"; statusTitle = "Inactive"; break; case BROKEN: statusImagePath = "images/error.gif"; statusTitle = "Project cannot be loaded"; break; case NOT_AVAILABLE: default: statusImagePath = "images/unknown.gif"; statusTitle = "Project file missing or not set"; } WebComponent statusImage = new WebComponent("status"); statusImage.add(AttributeModifier.replace("src", statusImagePath)); statusImage.add(AttributeModifier.replace("title", statusTitle)); item.add(statusImage); // action String actionImagePath; String actionTitle; boolean showAction; Link<?> actionLink; switch (status) { case ACTIVE: actionTitle = "Stop"; actionImagePath = "images/stop.gif"; showAction = true; actionLink = new Link<Void>("action") { private static final long serialVersionUID = 393941411843332519L; @Override public void onClick() { projects.deactivate(id); } }; break; case BROKEN: case NOT_AVAILABLE: actionTitle = "Rescan"; actionImagePath = "images/refresh.gif"; showAction = true; actionLink = new Link<Void>("action") { private static final long serialVersionUID = -4403828305588875839L; @Override public void onClick() { projects.triggerScan(); } }; break; case INACTIVE: default: actionTitle = "Start"; actionImagePath = "images/start.gif"; showAction = status.equals(Status.INACTIVE); actionLink = new Link<Void>("action") { private static final long serialVersionUID = 393941411843332519L; @Override public void onClick() { projects.activate(id); } }; break; } WebComponent actionImage = new WebComponent("image"); actionImage.add(AttributeModifier.replace("src", actionImagePath)); actionImage.add(AttributeModifier.replace("title", actionTitle)); actionLink.add(actionImage); actionLink.setVisible(showAction); item.add(actionLink); // name String projectName = ""; ProjectInfo info = projects.getInfo(id); if (info != null) { projectName = info.getName(); } item.add(new Label("name", projectName)); // download log File logFile = projects.getLoadReports(id); DownloadLink log = new DownloadLink("log", logFile, id + ".log"); log.setVisible(logFile != null && logFile.exists()); WebComponent logImage = new WebComponent("image"); if (status == Status.BROKEN) { logImage.add(AttributeModifier.replace("src", "images/error_log.gif")); } log.add(logImage); item.add(log); } }; add(projectList); boolean noProjects = projectsModel.getObject().isEmpty(); // caption WebMarkupContainer caption = new WebMarkupContainer("caption"); caption.setVisible(showCaption && !noProjects); add(caption); add(new WebMarkupContainer("noprojects").setVisible(noProjects)); }
From source file:eu.esdihumboldt.hale.server.templates.war.components.ResourcesPanel.java
License:Open Source License
/** * Constructor.//from www . jav a 2s .c o m * * @param id the component ID * @param templateId the template identifier */ public ResourcesPanel(String id, final String templateId) { super(id); @SuppressWarnings("serial") IModel<? extends List<? extends IOAction>> actionResources = new LoadableDetachableModel<List<? extends IOAction>>() { @Override protected List<? extends IOAction> load() { TemplateProject ref = templates.getReference(templateId); List<IOAction> result = new ArrayList<>(); if (ref != null) { for (String id : ref.getResources().keySet()) { IOAction action = IOActionExtension.getInstance().get(id); if (action != null) { result.add(action); } } } return result; } }; @SuppressWarnings("serial") ListView<IOAction> actions = new ListView<IOAction>("resources", actionResources) { @Override protected void populateItem(ListItem<IOAction> item) { IOAction action = item.getModelObject(); final String actionId = action.getId(); // resource category String category = action.getResourceCategoryName(); if (category == null || category.isEmpty()) { category = action.getName(); } if (category == null || category.isEmpty()) { category = action.getId(); } item.add(new Label("category", category)); @SuppressWarnings("serial") IModel<? extends List<? extends Resource>> resourcesModel = new LoadableDetachableModel<List<? extends Resource>>() { @Override protected List<? extends Resource> load() { TemplateProject ref = templates.getReference(templateId); List<Resource> result = new ArrayList<>(); if (ref != null) { result.addAll(ref.getResources().get(actionId)); } return result; } }; // resources @SuppressWarnings("serial") ListView<Resource> resources = new ListView<Resource>("resource", resourcesModel) { @Override protected void populateItem(ListItem<Resource> item) { Resource res = item.getModelObject(); String href = null; String name = "Unknown resource"; if (res.getSource() != null) { if ("file".equals(res.getSource().getScheme())) { Path resPath = Paths.get(res.getSource()).normalize(); Path basePath = new File(templates.getHuntingGrounds(), templateId).toPath(); if (resPath.startsWith(basePath)) { String templateRelativePath = basePath.relativize(resPath).toString(); name = resPath.getFileName().toString(); href = TemplateLocations.getTemplateFileUrl(templates, templateId, templateRelativePath); } else { // invalid file to reference name = resPath.toString(); } } else if ("resource".equals(res.getSource().getScheme())) { name = res.getSource().toASCIIString(); } else { href = res.getSource().toASCIIString(); name = href; } } WebMarkupContainer link; if (href != null) { link = new ExternalLink("link", href); } else { link = new WebMarkupContainer("link"); } item.add(link); link.add(new Label("name", name)); } }; item.add(resources); } }; add(actions); // mapping TemplateProject ref = templates.getReference(templateId); WebMarkupContainer mapping = new WebMarkupContainer("mapping"); mapping.setVisible(ref.getDefinedRelations() > 0); String text = ref.getDefinedRelations() + ((ref.getDefinedRelations() == 1) ? (" pre-defined relation") : (" pre-defined relations")); mapping.add(new Label("text", text)); add(mapping); }
From source file:eu.esdihumboldt.hale.server.webapp.components.JobPanel.java
License:Open Source License
/** * Create a job panel./*from w w w. j ava 2 s . c o m*/ * * @param id the component ID * @param jobFamily the job family, may be <code>null</code> if all jobs * should be shown * @param hideNoJobs if the message stating that there are no jobs running * should be hidden * * @see IJobManager#find(Object) */ public JobPanel(String id, final Serializable jobFamily, final boolean hideNoJobs) { super(id); setOutputMarkupId(true); // update panel add(timer = new StoppableAjaxSelfUpdatingTimer(Duration.milliseconds(1500))); // TODO add option to stop? // job list final IModel<? extends List<Job>> jobModel = new LoadableDetachableModel<List<Job>>() { private static final long serialVersionUID = 7277175702043541004L; @Override protected List<Job> load() { return Arrays.asList(Job.getJobManager().find(jobFamily)); } }; final ListView<Job> jobList = new ListView<Job>("jobs", jobModel) { private static final long serialVersionUID = -6740090246572869212L; /** * @see ListView#populateItem(ListItem) */ @Override protected void populateItem(final ListItem<Job> item) { // final boolean odd = item.getIndex() % 2 == 1; // if (odd) { // item.add(AttributeModifier.replace("class", "odd")); // } // name item.add(new Label("name", item.getModelObject().getName())); final IModel<eu.esdihumboldt.hale.server.progress.Progress> progressModel = new LoadableDetachableModel<eu.esdihumboldt.hale.server.progress.Progress>() { private static final long serialVersionUID = 2666038645533292585L; @Override protected eu.esdihumboldt.hale.server.progress.Progress load() { ProgressService ps = OsgiUtils.getService(ProgressService.class); if (ps == null) { return null; } return ps.getJobProgress(item.getModelObject()); } }; // progress Progress progress = new JobProgress("progress", progressModel); item.add(progress); // task name String task = progressModel.getObject().getSubTask(); if (task == null || task.isEmpty()) { task = progressModel.getObject().getTaskName(); } item.add(new Label("task", task)); } }; add(jobList); add(new WebMarkupContainer("nojobs") { private static final long serialVersionUID = -7752350858497246457L; @Override public boolean isVisible() { return !hideNoJobs && jobModel.getObject().isEmpty(); } }); }
From source file:eu.esdihumboldt.hale.server.webapp.components.SimpleBreadcrumbPanel.java
License:Open Source License
/** * Constructs a new breadcrumb panel. If a link to a root website should be * part of the breadcrumbs, then <code>rootLinkName</code> and * <code>rootLinkTarget</code> must both be set. * //from w w w . ja va 2s . c o m * @param id the component's id * @param currentPage the class of the current page * @param rootLinkName the title of the link to the root website (can be * null) * @param rootLinkTarget the href target of the link to the root website * (can be null) */ public SimpleBreadcrumbPanel(String id, Class<? extends Page> currentPage, final String rootLinkName, final String rootLinkTarget) { super(id); String title = ""; PageDescription anno = currentPage.getAnnotation(PageDescription.class); if (anno != null) { if (anno.title() == null) { throw new RuntimeException(currentPage + " has no annotated title"); } title = anno.title(); } add(new Label("breadcrumb-current", title)); // add bread crumbs Vector<Class<? extends Page>> links = new Vector<Class<? extends Page>>(); while (anno != null && anno.parent() != null) { Class<? extends WebPage> par = anno.parent(); if (!par.isAnnotationPresent(PageDescription.class)) { break; } links.insertElementAt(anno.parent(), 0); anno = anno.parent().getAnnotation(PageDescription.class); } // add a dummy element for the root web page (but don't do this if the // current page *is* the root page) if (rootLinkName != null && rootLinkTarget != null) { boolean root = false; if (currentPage.isAnnotationPresent(PageDescription.class)) { root = currentPage.getAnnotation(PageDescription.class).root(); } if (!root) { links.insertElementAt(null, 0); } } // fill list view with bread crumbs add(new ListView<Class<? extends Page>>("breadcrumb-panel", links) { private static final long serialVersionUID = 1221964671030364825L; @Override public void populateItem(final ListItem<Class<? extends Page>> item) { Class<? extends Page> p = item.getModelObject(); WebMarkupContainer link; if (p != null) { link = new BookmarkablePageLink<Void>("breadcrumb-link", p); PageDescription anno = p.getAnnotation(PageDescription.class); link.add(new Label("breadcrumb-link-text", anno.title())); } else { link = new ExternalLink("breadcrumb-link", rootLinkTarget); link.add(new Label("breadcrumb-link-text", rootLinkName)); } item.add(link); } }); }
From source file:eu.esdihumboldt.hale.server.webapp.war.pages.WelcomePage.java
License:Open Source License
@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/*from ww w. j av a 2 s.c o m*/ 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); }
From source file:eu.esdihumboldt.hale.server.webtransform.war.components.TransformationList.java
License:Open Source License
/** * Constructor/*from w w w . ja va 2 s .com*/ * * @param id the panel id * @param showCaption if the caption shall be shown */ public TransformationList(String id, boolean showCaption) { super(id); // transformations list final IModel<? extends List<TransformationEnvironment>> transformationsModel = new LoadableDetachableModel<List<TransformationEnvironment>>() { private static final long serialVersionUID = 7277175702043541004L; @Override protected List<TransformationEnvironment> load() { return new ArrayList<TransformationEnvironment>(transformations.getEnvironments()); } }; final ListView<TransformationEnvironment> transformationList = new ListView<TransformationEnvironment>( "transformations", transformationsModel) { private static final long serialVersionUID = -6740090246572869212L; /** * @see ListView#populateItem(ListItem) */ @Override protected void populateItem(ListItem<TransformationEnvironment> item) { final TransformationEnvironment env = item.getModelObject(); // identifier item.add(new Label("identifier", env.getId())); // name String projectName = ""; ProjectInfo info = env.getProjectInfo(); if (info != null) { projectName = info.getName(); } item.add(new Label("name", projectName)); // upload and transform link item.add(new BookmarkablePageLink<Void>("upload", UploadPage.class, new PageParameters().add(UploadPage.PARAMETER_PROJECT, env.getId()))); } }; add(transformationList); boolean noTransformations = transformationsModel.getObject().isEmpty(); // caption WebMarkupContainer caption = new WebMarkupContainer("caption"); caption.setVisible(showCaption && !noTransformations); add(caption); add(new WebMarkupContainer("notransformations").setVisible(noTransformations)); }