Java Code Examples for org.apache.wicket.markup.html.list.ListItem

The following are top voted examples for showing how to use org.apache.wicket.markup.html.list.ListItem. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: geoserver-documentor   File: DocumentationIndexPage.java   View source code 6 votes vote down vote up
public DocumentationIndexPage() {
	Harvester harvester = new Harvester();
	
	@SuppressWarnings({ "unchecked", "rawtypes" })
	ListView listview = new ListView("listview", harvester.getWorkspaces()) {
	    /**
		 * 
		 */
		private static final long serialVersionUID = 2974513833506276491L;

		protected void populateItem(ListItem item) {
	    	WorkspaceDoc wi = (WorkspaceDoc) item.getModelObject();
			BookmarkablePageLink link = new BookmarkablePageLink("link", WorkspacePage.class);
			link.setParameter("workspaceName", wi.getName());
			link.add(new Label("workspaceName", wi.getName()));
	        item.add(link);
	    }
	};
	add(listview);

	ExtensionInfo info = new ExtensionInfo();
	add(new Label("documentorVersion", info.getVersion()));
	add(new Label("documentorGitVersion", info.getGitVersion()));
	add(new Label("readme", info.getReadme()));
}
 
Example 2
Project: gitplex-mit   File: ReflectionBeanViewer.java   View source code 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	add(new ListView<PropertyContext<Serializable>>("properties", propertyContexts) {

		@Override
		protected void populateItem(ListItem<PropertyContext<Serializable>> item) {
			PropertyContext<Serializable> propertyContext = item.getModelObject();
			Method propertyGetter = propertyContext.getPropertyGetter();
			Label nameLabel = new Label("name", EditableUtils.getName(propertyGetter));
			item.add(nameLabel);
			OmitName omitName = propertyGetter.getAnnotation(OmitName.class);

			if (omitName != null && omitName.value() != OmitName.Place.EDITOR) {
				nameLabel.setVisible(false);
				item.add(AttributeAppender.append("class", "name-omitted"));
			}

			Serializable bean = (Serializable) ReflectionBeanViewer.this.getDefaultModelObject();
			Serializable propertyValue = (Serializable) propertyContext.getPropertyValue(bean);
			item.add(propertyContext.renderForView("value", Model.of(propertyValue)));
		}

	});
}
 
Example 3
Project: gitplex-mit   File: RevisionDiffPanel.java   View source code 6 votes vote down vote up
@Nullable
private SourceAware getSourceAware(String path) {
	return diffsView.visitChildren(new IVisitor<Component, SourceAware>() {

		@SuppressWarnings("unchecked")
		@Override
		public void component(Component object, IVisit<SourceAware> visit) {
			if (object instanceof ListItem) {
				ListItem<BlobChange> item = (ListItem<BlobChange>) object;
				if (item.getModelObject().getPaths().contains(path)) {
					visit.stop((SourceAware) item.get(DIFF_ID));
				} else {
					visit.dontGoDeeper();
				}
			} 
		}

	});
}
 
Example 4
Project: openNaEF   File: LocationViewPage.java   View source code 6 votes vote down vote up
private void populateNode() throws ExternalServiceException, IOException, RemoteException {
    ListView<NodeDto> list = new ListView<NodeDto>("nodeList", this.model) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<NodeDto> item) {
            NodeDto node = item.getModelObject();
            BookmarkablePageLink<Void> link = NodePageUtil.createNodeLink("nodeLink", node);
            item.add(link);
        }
    };
    add(list);
    WebMarkupContainer container = new WebMarkupContainer("nodeBlock");
    add(container);
    container.setVisible(this.model.isVisible());
}
 
Example 5
Project: MasterStats   File: BasePage.java   View source code 6 votes vote down vote up
/**
 * generates the navbar and mark the active page
 *
 * @param activePage page to be marked active (null for no active page)
 */
private void loadNavbar(final PageType activePage) {
    // add an entry for each page type
    add(new ListView<PageType>("navbar_left_elements", Arrays.asList(PageType.values())) {
        @Override
        protected void populateItem(final ListItem<PageType> item) {
            final PageType type = item.getModelObject();
            // create a link for the page type
            BookmarkablePageLink<String> link = new BookmarkablePageLink<>("navbar_left_element_link", type.getPageClass());
            link.add(new Label("navbar_left_element_text", type.getLinkText()));
            // if the type is same as active page, mark it as active
            if (type.equals(activePage)) link.add(new AttributeAppender("class", "active", " "));
            item.add(link);
        }
    });

    // create the summoner search region drop down menu
    // get all valid entries
    List<String> endpoints = Arrays.asList(RiotEndpoint.PLAYABLE_ENDPOINTS)
            .stream().map(RiotEndpoint::name).collect(Collectors.toList());
    // add the options to the drop down menu
    DropDownChoice<String> dropDownChoice = new DropDownChoice<>("navbar_form_regions_select",
            new PropertyModel<>(this, "selectedRegion"), endpoints, new StringChoiceRenderer());
    dropDownChoice.add(new AttributeModifier("name", "region"));
    add(dropDownChoice);
}
 
Example 6
Project: engerek   File: MultiValueChoosePanel.java   View source code 6 votes vote down vote up
protected void initButtons(ListItem<T> item, WebMarkupContainer parent) {
        WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP); {
	        buttonGroup.setOutputMarkupId(true);
	
	        AjaxLink remove = new AjaxLink(ID_REMOVE) {
	
	            @Override
	            public void onClick(AjaxRequestTarget target) {
	                removeValuePerformed(target, item.getModelObject());
	            }
	        };
	        
	        remove.add(new VisibleEnableBehaviour() {
	
	            @Override
	            public boolean isVisible() {
	                return isRemoveButtonVisible();
	            }
	        });
	        buttonGroup.add(remove);
        }

        parent.add(buttonGroup);
}
 
Example 7
Project: engerek   File: MultiValueTextPanel.java   View source code 6 votes vote down vote up
protected void removeValuePerformed(AjaxRequestTarget target, ListItem<T> item){
    List<T> objects = getModelObject();
    Iterator<T> iterator = objects.iterator();
    while (iterator.hasNext()) {
        T object = iterator.next();
        if (object == null){
            continue;
        }
        if (object.equals(item.getModelObject())) {
            iterator.remove();
            break;
        }
    }

    target.add(this);
}
 
Example 8
Project: engerek   File: ObjectPolicyConfigurationEditor.java   View source code 6 votes vote down vote up
private void removePerformed(AjaxRequestTarget target, ListItem<ObjectPolicyConfigurationTypeDto> item){
    List<ObjectPolicyConfigurationTypeDto> list = getModelObject();
    Iterator<ObjectPolicyConfigurationTypeDto> iterator = list.iterator();

    while (iterator.hasNext()){
        ObjectPolicyConfigurationTypeDto object = iterator.next();

        if(object.equals(item.getModelObject())){
            iterator.remove();
            break;
        }
    }

    if(list.size() == 0){
        list.add(new ObjectPolicyConfigurationTypeDto());
    }

    target.add(this);
}
 
Example 9
Project: engerek   File: AssignmentTablePanel.java   View source code 6 votes vote down vote up
protected AttributeModifier getClassModifier(ListItem<AssignmentEditorDto> item){
	return AttributeModifier.append("class", new AbstractReadOnlyModel<String>() {
		private static final long serialVersionUID = 1L;

		@Override
		public String getObject() {
			AssignmentEditorDto dto = item.getModel().getObject();
			ObjectReferenceType targetRef = dto.getTargetRef();
			if (targetRef != null && targetRef.getType() != null) {
				return WebComponentUtil.getBoxThinCssClasses(targetRef.getType());
			} else {
				return GuiStyleConstants.CLASS_OBJECT_RESOURCE_BOX_THIN_CSS_CLASSES;
			}
		}
	});
}
 
Example 10
Project: engerek   File: SimpleRoleSelector.java   View source code 6 votes vote down vote up
private void initLayout() {
    setOutputMarkupId(true);
    ListView<PrismObject<R>> list = new ListView<PrismObject<R>>(ID_LIST, availableRoles) {
        @Override
        protected void populateItem(ListItem<PrismObject<R>> item) {
            item.add(createRoleLink(ID_ITEM, item.getModel()));
        }
    };
    list.setOutputMarkupId(true);
    add(list);

    AjaxLink<String> buttonReset = new AjaxLink<String>(ID_BUTTON_RESET) {
        @Override
        public void onClick(AjaxRequestTarget target) {
            reset();
            target.add(SimpleRoleSelector.this);
        }
    };
    buttonReset.setBody(createStringResource("SimpleRoleSelector.reset"));
    add(buttonReset);
}
 
Example 11
Project: engerek   File: DelegationEditorPanel.java   View source code 6 votes vote down vote up
private void addPrivilegesPanel(WebMarkupContainer body){
    privilegesNames = getPrivilegesNamesList();
    ListView<String> privilegesListComponent = new ListView<String>(ID_PRIVILEGES_LIST, privilegesNames){
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<String> item) {
            Label privilageNameLabel = new Label(ID_PRIVILEGE, item.getModel());
            item.add(privilageNameLabel);
        }
    };
    privilegesListComponent.setOutputMarkupId(true);
    privilegesListComponent.add(new VisibleEnableBehaviour(){
        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible(){
            if (!UserDtoStatus.ADD.equals(getModelObject().getStatus())){
                return true;
            }
           return false;
        }
    });
    body.addOrReplace(privilegesListComponent);
}
 
Example 12
Project: engerek   File: ApprovalProcessesPreviewPanel.java   View source code 6 votes vote down vote up
private void initLayout() {
	ListView<ApprovalProcessExecutionInformationDto> list = new ListView<ApprovalProcessExecutionInformationDto>(ID_PROCESSES, getModel()) {
		@Override
		protected void populateItem(ListItem<ApprovalProcessExecutionInformationDto> item) {
			item.add(new Label(ID_NAME, LoadableModel.create(() -> {
				String targetName = item.getModelObject().getTargetName();
				if (targetName != null) {
					return ApprovalProcessesPreviewPanel.this.getString("ApprovalProcessesPreviewPanel.processRelatedTo", targetName);
				} else {
					return getString("ApprovalProcessesPreviewPanel.process");
				}
			}, false)));
			item.add(new ApprovalProcessExecutionInformationPanel(ID_PREVIEW, item.getModel()));
		}
	};
	add(list);
}
 
Example 13
Project: engerek   File: PrismObjectPanel.java   View source code 6 votes vote down vote up
private void addOrReplaceContainers(IModel<ObjectWrapper<O>> model, final Form form, boolean isToBeReplaced){
    ListView<ContainerWrapper> containers = new ListView<ContainerWrapper>(ID_CONTAINERS,
            createContainerModel(model)) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<ContainerWrapper> item) {
            PrismContainerPanel containerPanel = createContainerPanel(item, form);
            createMetadataPanel(model, item, containerPanel);
        }
    };
    containers.setReuseItems(true);

    if (isToBeReplaced) {
        replace(containers);
    } else {
        add(containers);
    }
}
 
Example 14
Project: engerek   File: PrismContainerPanel.java   View source code 6 votes vote down vote up
private void addOrReplaceProperties(IModel<ContainerWrapper> model, final Form form, boolean isToBeReplaced){
     ListView<ItemWrapper> properties = new ListView<ItemWrapper>("properties",
             new PropertyModel(model, "properties")) {
private static final long serialVersionUID = 1L;

@Override
         protected void populateItem(final ListItem<ItemWrapper> item) {
             item.add(new PrismPropertyPanel("property", item.getModel(), form, pageBase));
             item.add(new VisibleEnableBehaviour() {
             	private static final long serialVersionUID = 1L;
             	
             	@Override
             	public boolean isVisible() {
             		return item.getModel().getObject().isVisible();
             	}
             });
             item.add(AttributeModifier.append("class", createStyleClassModel(item.getModel())));
         }
     };
     properties.setReuseItems(true);
     if (isToBeReplaced) {
         replace(properties);
     } else {
         add(properties);
     }
 }
 
Example 15
Project: engerek   File: ResourceDependencyEditor.java   View source code 6 votes vote down vote up
private IModel<String> createCollapseItemId(final ListItem<ResourceObjectTypeDependencyType> item, final boolean appendSelector){
    return new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            StringBuilder sb = new StringBuilder();

            if(appendSelector){
                sb.append("#");
            }

            sb.append("collapse").append(item.getId());

            return sb.toString();
        }
    };
}
 
Example 16
Project: engerek   File: ResourceProtectedEditor.java   View source code 6 votes vote down vote up
private IModel<String> createCollapseItemId(final ListItem<ResourceObjectPatternType> item,final boolean includeSelector){
    return new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            StringBuilder sb = new StringBuilder();

            if(includeSelector){
                sb.append("#");
            }

            sb.append("collapse").append(item.getId());

            return sb.toString();
        }
    };
}
 
Example 17
Project: engerek   File: LimitationsEditorDialog.java   View source code 6 votes vote down vote up
private IModel<String> createCollapseItemId(final ListItem<PropertyLimitationsTypeDto> item, final boolean appendSelector){
    return new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            StringBuilder sb = new StringBuilder();

            if (appendSelector) {
                sb.append("#");
            }

            sb.append("collapse").append(item.getId());

            return sb.toString();
        }
    };
}
 
Example 18
Project: engerek   File: InformationPanel.java   View source code 6 votes vote down vote up
private void initLayout() {
	Label titleLabel = new Label(ID_TITLE, new PropertyModel<>(getModel(), InformationType.F_TITLE.getLocalPart()));
	titleLabel.add(new VisibleBehaviour(() -> getModelObject().getTitle() != null));
	add(titleLabel);

	ListView<InformationPartType> list = new ListView<InformationPartType>(ID_PARTS,
			new PropertyModel<>(getModel(), InformationType.F_PART.getLocalPart())) {
		@Override
		protected void populateItem(ListItem<InformationPartType> item) {
			InformationPartType part = item.getModelObject();
			Label label = new Label(ID_PART, part.getText());
			if (Boolean.TRUE.equals(part.isHasMarkup())) {
				label.setEscapeModelStrings(false);
			}
			item.add(label);
		}
	};
	add(list);
}
 
Example 19
Project: engerek   File: PageInternals.java   View source code 6 votes vote down vote up
private void initCounters() {
   	
   	ListView<InternalCounters> countersTable = new ListView<InternalCounters>(ID_COUNTERS_TABLE, Arrays.asList(InternalCounters.values())) {
		private static final long serialVersionUID = 1L;

		@Override
		protected void populateItem(ListItem<InternalCounters> item) {
			InternalCounters counter = item.getModelObject();
			Label label = new Label(ID_COUNTER_LABEL, createStringResource("InternalCounters."+counter.getKey()));
			item.add(label);
	    	
	    	Label valueLabel = new Label(ID_COUNTER_VALUE, new AbstractReadOnlyModel<String>() {
				private static final long serialVersionUID = 1L;

				@Override
				public String getObject() {
					long val = InternalMonitor.getCount(counter);
					return Long.toString(val);
				}
			});
	    	item.add(valueLabel);
		}
   		
   	};
   	add(countersTable);
}
 
Example 20
Project: engerek   File: ObjectPolicyPanel.java   View source code 6 votes vote down vote up
private void removePerformed(AjaxRequestTarget target, ListItem item) {
		List<PropertyConstraintTypeDto> list = model.getObject().getPropertyConstraintsList();
		Iterator<PropertyConstraintTypeDto> iterator = list.iterator();

		while (iterator.hasNext()) {
			PropertyConstraintTypeDto object = iterator.next();

			if (object.equals(item.getModelObject())) {
				iterator.remove();
				break;
			}
		}

		if (list.size() == 0) {
			list.add(new PropertyConstraintTypeDto(null));
		}

//		target.add(getContent());
	}
 
Example 21
Project: vlo-curation   File: FacetValuesPanel.java   View source code 6 votes vote down vote up
/**
 * Adds an individual facet value selection link to a dataview item
 *
 * @param item item to add link to
 */
private void addFacetValue(String id, final ListItem<Count> item) {
    item.setDefaultModel(new CompoundPropertyModel<>(item.getModel()));

    // link to select an individual facet value
    final Link selectLink = new IndicatingAjaxFallbackLink(id) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            // reset filter
            ((NameAndCountFieldValuesFilter) filterModel.getObject()).setName(null);

            // call callback
            onValuesSelected(
                    // for now only single values can be selected
                    Collections.singleton(item.getModelObject().getName()),
                    target);
        }
    };
    item.add(selectLink);

    // 'name' field from Count (name of value)
    selectLink.add(new FieldValueLabel("name", fieldNameModel));
    // 'count' field from Count (document count for value)
    selectLink.add(new Label("count"));
}
 
Example 22
Project: vlo-curation   File: BootstrapDropdown.java   View source code 6 votes vote down vote up
protected Component createMenu(String id) {
    final WebMarkupContainer menu = new WebMarkupContainer(id);
    menu.add(new ListView<DropdownMenuItem>("menuItem", getModel()) {
        @Override
        protected void populateItem(ListItem<DropdownMenuItem> item) {
            final DropdownMenuItem itemObject = item.getModelObject();
            //link that forms the menu item's action
            item.add(itemObject.getLink("link")
                    //link label defined by the menu item object
                    .add(new Label("label", itemObject.getLabel()))
                    //icon with icon class defined by the menu item object
                    .add(new WebMarkupContainer("icon")
                            .add(new AttributeModifier("class", itemObject.getIconClass())))
            );
        }
    });
    return menu;
}
 
Example 23
Project: singular-server   File: ExtensionButtonsPanel.java   View source code 6 votes vote down vote up
private void addButtons() {
    add(new ListView<RequirementButtonExtension>("buttons", extensions) {
        @Override
        protected void populateItem(ListItem<RequirementButtonExtension> item) {
            final RequirementButtonExtension itemModel = item.getModelObject();
            SingularSaveButton button = new SingularSaveButton("button", formModel, itemModel.shouldValidateForm()) {
                @Override
                protected void onValidationSuccess(AjaxRequestTarget target, Form<?> form, IModel<? extends SInstance> instanceModel) {
                    itemModel.onAction(new RequirementButtonExtension
                            .ActionContext(target, form, petInstanceModel.getObject(), instanceModel.getObject()));
                }
            };
            RequirementButtonExtension.ButtonView buttonView = itemModel.getButtonView();
            WebMarkupContainer                    icon       = new WebMarkupContainer("icon");
            if (buttonView.getIcon() != null) {
                icon.add($b.classAppender(buttonView.getIcon().getCssClass()));
            }
            else {
                icon.setVisible(false);
            }
            button.add(icon);
            button.add(new Label("label", buttonView.getLabel()).setRenderBodyOnly(true));
            item.add(button);
        }
    }.setRenderBodyOnly(true));
}
 
Example 24
Project: Intercloud   File: CategoryResponsePanel.java   View source code 6 votes vote down vote up
public CategoryResponsePanel(String id, IModel<? extends CategoryModel> categoryModel) {
    super(id);

    CategoryModel category = categoryModel.getObject();
    this.add(new Label("type", getType()));
    this.add(new Label("term", category.getTerm()));
    this.add(new Label("schema", category.getSchema()));
    this.add(new WebMarkupContainer("titleRow") {
        @Override
        public boolean isVisible() {
            return null != category.getTitle();
        }
    }.add(new Label("title", category.getTitle())));

    this.add(new ListView<AttributeModel>("attributeContainer", new ListModel<>(new ArrayList<>(category.getAttributes()))) {
        @Override
        protected void populateItem(ListItem<AttributeModel> listItem) {
            AttributeModel attribute = listItem.getModelObject();
            listItem.add(new Label("name", attribute.getName()));
            listItem.add(new Label("value", attribute.getValue().toString()));
            listItem.add(new Label("description", attribute.getDescription()));
        }
    });
}
 
Example 25
Project: oldSyncopeIdM   File: FieldPanel.java   View source code 6 votes vote down vote up
/**
 * Userd by MultiValueSelectorPanel to attach items.
 * @param item item to attach.
 * @return updated FieldPanel object.
 */
public FieldPanel setNewModel(
        final ListItem<T> item, final Class reference) {

    setNewModel(new Model() {

        private static final long serialVersionUID = 6799404673615637845L;

        @Override
        public Serializable getObject() {
            return item.getModelObject();
        }

        @Override
        public void setObject(final Serializable object) {
            if (object != null && !object.toString().isEmpty()) {
                item.setModelObject((T) object);
            }
        }
    });
    return this;
}
 
Example 26
Project: openmeetings   File: RoomForm.java   View source code 6 votes vote down vote up
@Override
protected void populateItem(final ListItem<StreamClient> item) {
	StreamClient client = item.getModelObject();
	item.add(new Label("clientId", "" + client.getId()))
		.add(new Label("clientLogin", "" + client.getLogin()))
		.add(new ConfirmableAjaxBorder("clientDelete", getString("80"), getString("833")) {
			private static final long serialVersionUID = 1L;

			@Override
			protected void onSubmit(AjaxRequestTarget target) {
				StreamClient c = item.getModelObject();
				getBean(UserManager.class).kickById(c.getUid());
				updateClients(target);
			}
		});
}
 
Example 27
Project: openmeetings   File: RoomClientPanel.java   View source code 6 votes vote down vote up
public RoomClientPanel(String id, ListItem<Client> item, final RoomPanel room) {
	super(id, item.getModel());
	setRenderBodyOnly(true);
	Client c = item.getModelObject();
	final String uid = c.getUid();
	item.setMarkupId(String.format("user%s", c.getUid()));
	item.add(AttributeModifier.append("style", String.format("background-image: url(profile/%s);", c.getUserId())));
	item.add(AttributeModifier.append("data-userid", c.getUserId()));
	add(new RefreshIcon("refresh", uid, room));
	final String name = getName(c);
	add(new Label("name", name));
	add(new UserSpeaksIcon("user-speaks", uid, room));
	item.add(AttributeModifier.replace(ATTR_TITLE, name));
	WebMarkupContainer actions = new WebMarkupContainer("actions");
	actions.add(new KickIcon("kick", uid, room));
	actions.add(new WebMarkupContainer("privateChat").setVisible(!room.getRoom().isHidden(RoomElement.Chat) && !getUserId().equals(c.getUserId())));
	actions.setVisible(room.getClient().hasRight(Right.moderator));
	if (c.getUid().equals(room.getClient().getUid())) {
		actions.add(new SelfIconsPanel("icons", uid, room, false));
		item.add(AttributeModifier.append(ATTR_CLASS, "current"));
	} else {
		actions.add(new ClientIconsPanel("icons", uid, room));
	}
	add(actions);
}
 
Example 28
Project: openmeetings   File: WbPanel.java   View source code 6 votes vote down vote up
public WbPanel(String id, RoomPanel rp) {
	super(id, rp);
	this.roomId = rp.getRoom().getId();
	if (rp.getRoom().isHidden(RoomElement.Whiteboard)) {
		setVisible(false);
	} else {
		add(new ListView<String>("clipart", Arrays.asList(OmFileHelper.getPublicClipartsDir().list())) {
			private static final long serialVersionUID = 1L;

			@Override
			protected void populateItem(ListItem<String> item) {
				String cls = String.format("clipart-%s", item.getIndex());
				item.add(append(ATTR_CLASS, cls), append("data-mode", cls)
						, append("data-image", item.getModelObject()).setSeparator(""));
			}
		}, fileName);
	}
}
 
Example 29
Project: openmeetings   File: MenuPanel.java   View source code 6 votes vote down vote up
public MenuPanel(String id, List<IMenuItem> menus) {
	super(id);
	setOutputMarkupPlaceholderTag(true);
	setMarkupId(id);
	add(new Menu("menu", menus, new Options().set("icons", "{ submenu: 'ui-icon-triangle-1-s' }")
				.set("position", "{ my: 'left top', at: 'left bottom'}"))
	{
		private static final long serialVersionUID = 1L;

		@Override
		protected void addMenuItem(ListItem<IMenuItem> item, IMenuItem menuItem) {
			super.addMenuItem(item, menuItem);
			OmMenuItem m = (OmMenuItem)menuItem;
			item.add(AttributeModifier.append(ATTR_CLASS, m.isTop() ? "top" : "sub"));
			if (!Strings.isEmpty(m.getDesc())) {
				item.add(AttributeModifier.append(ATTR_TITLE, m.getDesc()));
			}
			if (!Strings.isEmpty(m.getIcon())) {
				item.add(AttributeModifier.append(ATTR_CLASS, m.getIcon()));
			}
		}
	});
}
 
Example 30
Project: ontopia   File: FieldInstancesPanel.java   View source code 6 votes vote down vote up
public FieldInstancesPanel(String id, 
    List<FieldInstanceModel> fieldInstanceModels, final FieldsViewModel fieldsViewModel,
    final boolean readonly, final boolean traversable) {
  super(id);
  this.readonly = readonly;
  
  listView = new ListView<FieldInstanceModel>("fields", fieldInstanceModels) {
    @Override
    public void populateItem(final ListItem<FieldInstanceModel> item) {
      FieldInstanceModel fieldInstanceModel = item.getModelObject();
      item.setRenderBodyOnly(true);
      Component component;
      try {
        component = createFieldInstanceComponent("field", fieldInstanceModel, fieldsViewModel, traversable);
      } catch (Exception e) {
        log.error("Error occurred while creating field instance component", e);
        component = new FieldInstanceErrorPanel("field", fieldInstanceModel, e);
      }
      component.setRenderBodyOnly(true);
      item.add(component);
    }
  };
  listView.setReuseItems(true);
  add(listView);    
}
 
Example 31
Project: webanno   File: ProjectCasDoctorPanel.java   View source code 6 votes vote down vote up
private ListView<LogMessageSet> createMessageSetsView()
{
    return new ListView<LogMessageSet>("messageSets",
            PropertyModel.of(this, "formModel.messageSets"))
    {
        private static final long serialVersionUID = 8957632000765128508L;

        @Override
        protected void populateItem(ListItem<LogMessageSet> aItem)
        {
            IModel<LogMessageSet> set = aItem.getModel();
            aItem.add(new Label("name", PropertyModel.of(set, "name")));
            aItem.add(createMessagesView(set));
        }
    };
}
 
Example 32
Project: webanno   File: ProjectCasDoctorPanel.java   View source code 6 votes vote down vote up
private ListView<LogMessage> createMessagesView(IModel<LogMessageSet> aModel)
{
    return new ListView<LogMessage>("messages", PropertyModel.of(aModel, "messages"))
    {
        private static final long serialVersionUID = 8957632000765128508L;

        @Override
        protected void populateItem(ListItem<LogMessage> aItem)
        {
            IModel<LogMessage> msg = aItem.getModel();
            aItem.add(new Label("level", PropertyModel.of(msg, "level")));
            aItem.add(new Label("source", PropertyModel.of(msg, "source.simpleName")));
            aItem.add(new Label("message", PropertyModel.of(msg, "message")));
        }
    };
}
 
Example 33
Project: relax-dms   File: User.java   View source code 6 votes vote down vote up
private void createDocumentList(String id, List<DocumentListData> docList) {
    ListView listview = new ListView(id, docList) {
        @Override
        protected void populateItem(ListItem item) {
            DocumentListData doc = (DocumentListData) item.getModelObject();
            
            PageParameters pp = new PageParameters();
            pp.add("id", doc.getId());
            
            BookmarkablePageLink<Void> docLink = new BookmarkablePageLink("docLink", DocumentTabs.class, pp);
            item.add(docLink.add(new Label("id", doc.getId())));
            item.add(new Label("title", doc.getTitle()));
        }
    };
    add(listview);
}
 
Example 34
Project: relax-dms   File: DocumentCreate.java   View source code 6 votes vote down vote up
private void createTemplateList(Map<String, String> templateMap) {  
    List<String> titleList = templateMap.keySet().stream().collect(Collectors.toList());
    ListView listview = new ListView("listView", titleList) {
        @Override
        protected void populateItem(ListItem item) {
            final String title = (String) item.getModelObject();
            final String id = templateMap.get(title);
            
            AjaxLink<Void> templateLink = new AjaxLink("templateLink") {
                @Override
                public void onClick(AjaxRequestTarget target) {
                    PageParameters params = new PageParameters();
                    params.add("templateId", id);
                    setResponsePage(DocumentCreate.class, params);
                }
            };
            item.add(templateLink.add(new Label("label", title)));
        }
    };
    add(listview);
}
 
Example 35
Project: elpaaso-core   File: DesignerSteppedProcessPanel.java   View source code 6 votes vote down vote up
private void initComponents() {

        WebMarkupContainer container = new WebMarkupContainer("container");
        add(container);

        list = new ListView<String>("repeater", stepItemsModel) {
            private static final long serialVersionUID = -49889646848608542L;

            @Override
            protected void populateItem(ListItem<String> listItem) {
                Label stepNumber = new Label("stepNumber", new Model<String>(String.valueOf(listItem.getIndex()+1)));
                stepNumber.setRenderBodyOnly(true);
                listItem.add(stepNumber);
                listItem.add(new Label("stepName", listItem.getDefaultModelObjectAsString()));

                updateProcessStep(listItem, currentStep);

            }
        };
        container.add(list);

    }
 
Example 36
Project: elpaaso-core   File: DesignerSteppedProcessPanel.java   View source code 6 votes vote down vote up
public void updateProcessStep(ListItem<String> listItem, int step) {

        /* CSS Management */
        if(listItem.getIndex() < currentStep) {
            listItem.add(new AttributeAppender("class", new Model<>("step_visited"), ""));
        } else if(listItem.getIndex() == currentStep) {
            listItem.add(new AttributeAppender("class", new Model<>("step_current"), ""));
        } else if(listItem.getIndex() > currentStep) {
            listItem.add(new AttributeAppender("class", new Model<>("step_future"), ""));
        }

        if(listItem.getIndex() == 0) {
            listItem.add(new AttributeAppender("class", new Model<>(" first"), ""));
        }

        if(listItem.getIndex() == stepsNumber - 1) {
            listItem.add(new AttributeAppender("class", new Model<>(" last"), ""));
        }

    }
 
Example 37
Project: artifactory   File: RepositoryConfigPage.java   View source code 6 votes vote down vote up
@Override
protected void populateItem(final ListItem<T> item) {
    super.populateItem(item);
    item.add(new AjaxEventBehavior("ondblclick") {
        @SuppressWarnings({"unchecked"})
        @Override
        protected void onEvent(AjaxRequestTarget target) {
            ModalHandler modalHandler = ModalHandler.getInstanceFor(RepoListPanel.this);
            T itemObject = (T) item.getDefaultModelObject();
            modalHandler.setModalPanel(newUpdateItemPanel(itemObject));
            modalHandler.show(target);
        }

        @Override
        protected IAjaxCallDecorator getAjaxCallDecorator() {
            return new CancelDefaultDecorator();
        }
    });
}
 
Example 38
Project: artifactory   File: VirtualRepoListPanel.java   View source code 6 votes vote down vote up
/**
 * Adds a list of virtual repositories, using a RepoAwareActionableItem for information
 *
 * @param item The selected item from the tree
 */
private void addRepoList(final RepoAwareActionableItem item) {
    RepositoryService repositoryService = ContextHelper.get().getRepositoryService();
    List<VirtualRepoDescriptor> reposToDisplay = repositoryService.getVirtualReposContainingRepo(item.getRepo());

    add(new ListView<VirtualRepoDescriptor>("items", reposToDisplay) {
        @Override
        protected void populateItem(ListItem<VirtualRepoDescriptor> virtualRepo) {
            VirtualRepoDescriptor virtualRepoDescriptor = virtualRepo.getModelObject();
            final String hrefPrefix = RequestUtils.getWicketServletContextUrl();
            String path = getRepoPath(item);
            String href = hrefPrefix + "/" + virtualRepoDescriptor.getKey() + "/" + path;
            if (!href.endsWith("/")) {
                href += "/";
            }
            AbstractLink link = new ExternalLink("link", href, virtualRepoDescriptor.getKey());
            link.add(new CssClass("repository-virtual"));
            virtualRepo.add(link);
        }
    });
}
 
Example 39
Project: artifactory   File: SortedRepoDragDropSelection.java   View source code 6 votes vote down vote up
@Override
protected String getSortValue(ListItem item) {
    Object modelObject = item.getDefaultModelObject();

    /**
     * Implement a special sorting order if the list items are repo descriptors
     */
    if (modelObject instanceof LocalCacheRepoDescriptor) {
        return "3";
    } else if (modelObject instanceof LocalRepoDescriptor) {
        return "1";
    } else if (modelObject instanceof HttpRepoDescriptor) {
        return "2";
    } else if (modelObject instanceof VirtualRepoDescriptor) {
        return "4";
    }
    return super.getSortValue(item);
}
 
Example 40
Project: sakai   File: SortGradeItemsByGradeItemPanel.java   View source code 6 votes vote down vote up
@Override
public void onInitialize() {
	super.onInitialize();

	final List<Assignment> assignments = this.businessService.getGradebookAssignments(SortType.SORT_BY_SORTING);

	add(new ListView<Assignment>("gradeItemList", assignments) {
		@Override
		protected void populateItem(final ListItem<Assignment> assignmentItem) {
			final Assignment assignment = assignmentItem.getModelObject();
			assignmentItem.add(new Label("name", assignment.getName()));
			assignmentItem.add(new HiddenField<Long>("id",
					Model.of(assignment.getId())).add(
							new AttributeModifier("name",
									String.format("id", assignment.getId()))));
			assignmentItem.add(new HiddenField<Integer>("order",
					Model.of(assignment.getSortOrder())).add(
							new AttributeModifier("name",
									String.format("item_%s[order]", assignment.getId()))));
			assignmentItem.add(new HiddenField<Integer>("current_order",
					Model.of(assignment.getSortOrder())).add(
							new AttributeModifier("name",
									String.format("item_%s[current_order]", assignment.getId()))));
		}
	});
}