Java Code Examples for org.apache.wicket.markup.html.basic.Label

The following are top voted examples for showing how to use org.apache.wicket.markup.html.basic.Label. 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: gitplex-mit   File: AssistPanel.java   View source code 7 votes vote down vote up
private Component newSuggestionItem(String itemId, InputCompletion suggestion) {
	WebMarkupContainer item = new WebMarkupContainer(itemId);
	WebMarkupContainer link = new WebMarkupContainer("link");
	Range matchRange = suggestion.getMatchRange();
	String label = suggestion.getLabel();
	if (matchRange != null) {
		String prefix = StringEscapeUtils.escapeHtml4(label.substring(0, matchRange.getFrom()));
		String suffix = StringEscapeUtils.escapeHtml4(label.substring(matchRange.getTo()));
		String matched = StringEscapeUtils.escapeHtml4(label.substring(matchRange.getFrom(), matchRange.getTo()));
		link.add(new Label("label", prefix + "<b>" + matched + "</b>" + suffix).setEscapeModelStrings(false));
	} else {
		link.add(new Label("label", label));
	}
	item.add(link);
	if (suggestion.getDescription() != null)
		item.add(new Label("description", suggestion.getDescription()));
	else
		item.add(new Label("description").setVisible(false));
	item.add(AttributeAppender.append("data-content", suggestion.complete(inputStatus).getContent()));
	item.add(AttributeAppender.append("data-caret", suggestion.getCaret()));
	item.setOutputMarkupId(true);
	return item;
}
 
Example 2
Project: karate   File: VarsRefreshingView.java   View source code 6 votes vote down vote up
@Override
protected void populateItem(Item<Var> item) {
    String name = item.getModel().getObject().getName();
    item.add(new AjaxLink("show") {
        @Override
        public void onClick(AjaxRequestTarget target) {
            selectedName = name;
            Component headerPanel = getPage().get(BasePage.STICKY_HEADER_ID);
            VarModel varModel = new VarModel(model.getSessionId(), name);
            VarPanel varPanel = new VarPanel(BasePage.STICKY_HEADER_ID, varModel, VarsRefreshingView.this);                
            headerPanel = headerPanel.replaceWith(varPanel);
            target.add(headerPanel);
            Component varsPanel = getPage().get(BasePage.LEFT_NAV_ID);
            target.add(varsPanel);
        }
    }.add(new Label("name", name)));
    String type = item.getModel().getObject().getValue().getTypeAsShortString();
    item.add(new Label("type", type));
    if (name.equals(selectedName)) {
        item.add(new AttributeModifier("class", "success"));
    }
}
 
Example 3
Project: karate   File: FeaturePage.java   View source code 6 votes vote down vote up
public FeaturePage(String sessionId) {
    replace(new Label(HEADER_ID, ""));
    replace(new FeaturePanel(CONTENT_ID, sessionId));
    replace(new VarsPanel(LEFT_NAV_ID, sessionId));
    add(new WebSocketBehavior() {
        @Override
        protected void onConnect(ConnectedMessage message) {
            KarateSession session = service.getSession(sessionId);
            webSocketSessionId = message.getSessionId();
            webSocketClientKey = message.getKey();
            WebSocketLogAppender appender = session.getAppender();
            appender.setTarget(FeaturePage.this);
            logger.debug("websocket client connected, session: {}", message.getSessionId());
        }
    });
}
 
Example 4
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 5
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 6
Project: gitplex-mit   File: ContributorPanel.java   View source code 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	add(new UserLink("author", author));
	if (committer.getEmailAddress().equals(author.getEmailAddress())
			&& committer.getName().equals(author.getName())) {
		add(new WebMarkupContainer("committer").setVisible(false));
	} else {
		add(new UserLink("committer", committer));
	}
	if (withDate)
		add(new Label("date", DateUtils.formatAge(committer.getWhen())));
	else
		add(new WebMarkupContainer("date").setVisible(false));
}
 
Example 7
Project: gitplex-mit   File: BlobDiffTitle.java   View source code 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	add(new Label("renamedTitle", change.getOldBlobIdent().path)
			.setVisible(change.getType() == ChangeType.RENAME));
	add(new Label("title", change.getPath()));

	String modeChange;
	if (change.getOldBlobIdent().mode != null && change.getNewBlobIdent().mode != null
			&& !change.getOldBlobIdent().mode.equals(change.getNewBlobIdent().mode)) {
		modeChange = Integer.toString(change.getOldBlobIdent().mode, 8) 
				+ " <i class='fa fa-long-arrow-right'></i> " 
				+ Integer.toString(change.getNewBlobIdent().mode, 8);
	} else {
		modeChange = null;
	}

	add(new Label("modeChange", modeChange).setEscapeModelStrings(false));
}
 
Example 8
Project: gitplex-mit   File: ReferencedPanel.java   View source code 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	PullRequestReference reference = getModelObject();
	
	User userForDisplay = User.getForDisplay(reference.getUser(), reference.getUserName());
	add(new AvatarLink("avatar", userForDisplay));
	add(new UserLink("name", userForDisplay));
	add(new Label("age", DateUtils.formatAge(reference.getDate())));
	
	ViewStateAwarePageLink<Void> link = new ViewStateAwarePageLink<Void>("link", 
			RequestOverviewPage.class, RequestOverviewPage.paramsOf(reference.getReferencedBy()));
	link.add(new Label("number", "#" + reference.getReferencedBy().getNumber()));
	link.add(new Label("title", reference.getReferencedBy().getTitle()));
	add(link);
	
	add(new RequestStatusPanel("status", new AbstractReadOnlyModel<PullRequest>() {

		@Override
		public PullRequest getObject() {
			return ReferencedPanel.this.getModelObject().getReferencedBy();
		}
		
	}));
}
 
Example 9
Project: gitplex-mit   File: CommentedPanel.java   View source code 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();

	add(new UserLink("user", User.getForDisplay(getComment().getUser(), getComment().getUserName())));
	add(new Label("age", DateUtils.formatAge(getComment().getDate())));
	
	add(new SinceChangesLink("changes", new AbstractReadOnlyModel<PullRequest>() {

		@Override
		public PullRequest getObject() {
			return getComment().getRequest();
		}

	}, getComment().getDate()));
	
	add(newViewer());

	setOutputMarkupId(true);
}
 
Example 10
Project: gitplex-mit   File: ServerLogPage.java   View source code 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();

	add(new ResourceLink<Void>("download", new ServerLogResourceReference()));
	
	List<String> lines = ServerLogResource.readServerLog();		
	String content;
	if (lines.size() > MAX_DISPLAY_LINES) {
		add(new Label("warning", "Too many log entries, displaying recent " + MAX_DISPLAY_LINES));
		content = Joiner.on("\n").join(lines.subList(lines.size()-MAX_DISPLAY_LINES, lines.size()));
	} else {
		add(new WebMarkupContainer("warning").setVisible(false));
		content = Joiner.on("\n").join(lines);
	}
	
	add(new Label("logContent", content));
}
 
Example 11
Project: gitplex-mit   File: ServerInitPage.java   View source code 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();

	add(new Label("title", initStage.getMessage()));
	
	if (!initStage.getManualConfigs().isEmpty()) {
		List<ManualConfigStep> configSteps = new ArrayList<ManualConfigStep>();
		for (ManualConfig each: initStage.getManualConfigs())
			configSteps.add(new ManualConfigStep(each));
		add(new Wizard("wizard", configSteps) {

			@Override
			protected void finished() {
				WebSession.get().logout();
				User root = GitPlex.getInstance(UserManager.class).getRoot();
				SecurityUtils.getSubject().runAs(root.getPrincipals());
				throw new RestartResponseException(DashboardPage.class);
			}
			
		});
	} else {
		add(new WebMarkupContainer("wizard").setVisible(false));
	}
}
 
Example 12
Project: openNaEF   File: LocationViewPage.java   View source code 6 votes vote down vote up
private void createHeader() {
    ExternalLink topLink = UrlUtil.getTopLink("top");
    add(topLink);
    Link<Void> reloadLink = new BookmarkablePageLink<Void>("refresh",
            LocationViewPage.class, LocationUtil.getParameters(current));
    add(reloadLink);

    Label categoryLabel = new Label("category", Model.of(LocationRenderer.getLocationType(current)));
    add(categoryLabel);

    String buildingCode = LocationRenderer.getBuildingCode(current);
    if (buildingCode != null) {
        buildingCode = "Building Code: " + buildingCode;
    }
    Label addressLabel = new Label("buildingCode", Model.of(buildingCode));
    add(addressLabel);

    String popName = LocationRenderer.getPopName(current);
    if (popName != null) {
        popName = "POP Name: " + popName;
    }
    Label popNameLabel = new Label("popName", Model.of(popName));
    add(popNameLabel);
}
 
Example 13
Project: openNaEF   File: LocationViewPage.java   View source code 6 votes vote down vote up
private void createAddLocationLink() {
    Link<Void> link = new Link<Void>("addLocation") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick() {
            LocationAddPage page = new LocationAddPage(LocationViewPage.this, current);
            setResponsePage(page);
        }
    };
    if (LocationUtil.isTrash(current)) {
        link.setEnabled(false);
        link.setVisible(false);
    }

    LocationType type = LocationType.getByCaption(LocationRenderer.getLocationType(current));
    if (LocationType.RACK.equals(type)) {
        link.add(new Label("label", ""));
    } else {
        link.add(new Label("label", "Add child location"));
    }
    add(link);
}
 
Example 14
Project: openNaEF   File: NodePageUtil.java   View source code 6 votes vote down vote up
public static Link<Void> createNodeLink(final String id, final PortDto port) {
    final PageParameters param;
    final String nodeName;
    if (port != null) {
        param = NodeUtil.getParameters(port.getNode());
        nodeName = port.getNode().getName();
    } else {
        param = null;
        nodeName = null;
    }
    BookmarkablePageLink<Void> link = new BookmarkablePageLink<Void>(id, SimpleNodeDetailPage.class, param);
    link.setEnabled(port != null);
    Label label = new Label("nodeName", nodeName);
    link.add(label);
    return link;
}
 
Example 15
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 16
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 17
Project: GeoCrawler   File: CrawlsPage.java   View source code 6 votes vote down vote up
private void populateCrawlRow(Item<Crawl> item) {
  item.add(new AjaxLink<Crawl>("edit", item.getModel()) {
    @Override
    public void onClick(AjaxRequestTarget target) {
      editCrawl(target, getModel());
    }
  }.add(new Label("crawlName")));
  item.add(new Label("seedList.name"));

  item.add(new Label("progress"));
  item.add(createStatusLabel());
  item.add(new Link<Crawl>("start", item.getModel()) {
    @Override
    public void onClick() {
      crawlService.startCrawl(getModelObject().getId(), getCurrentInstance());
    }
  });

  item.add(new Link<Crawl>("delete", item.getModel()) {
    @Override
    public void onClick() {
      crawlService.deleteCrawl(getModelObject().getId());
    }
  });
}
 
Example 18
Project: GeoCrawler   File: SettingsPage.java   View source code 6 votes vote down vote up
public SettingsPage() {
  settingsTable = new WebMarkupContainer("settingsTable");
  settingsTable.setOutputMarkupId(true);
  RefreshingView<NutchConfig> nutchConfig = new RefreshingView<NutchConfig>(
      "settings") {

    @Override
    protected Iterator<IModel<NutchConfig>> getItemModels() {
      return new CpmIteratorAdapter<NutchConfig>(
          convertNutchConfig(nutchService.getNutchConfig(getCurrentInstance()
              .getId())));
    }

    @Override
    protected void populateItem(Item<NutchConfig> item) {
      item.add(new Label("name"));
      item.add(new TextField<String>("value"));
    }
  };
  settingsTable.add(nutchConfig);
  add(settingsTable);
}
 
Example 19
Project: vlo-curation   File: FieldsTablePanel.java   View source code 6 votes vote down vote up
private Component createValueLabel(String id, final IModel<String> facetNameModel, final IModel<String> valueModel) {
    final String fieldName = facetNameModel.getObject();

    if (FacetConstants.FIELD_LANGUAGE_CODE.equals(facetNameModel.getObject())) {
        return new LanguageInfoLink(id, valueModel, facetNameModel);
    } else if (SMART_LINK_FIELDS.contains(fieldName)) {
        // create label that generates links
        return new SmartLinkFieldValueLabel(id, new HandleLinkModel(valueModel), facetNameModel);
    } else {
        // add a label for the facet value
        final Label fieldLabel = new FieldValueLabel(id, valueModel, facetNameModel);

        // some selected fields may have HTML that needs to be preserved...
        fieldLabel.setEscapeModelStrings(!UNESCAPED_VALUE_FIELDS.contains(fieldName));
        return fieldLabel;
    }
}
 
Example 20
Project: vlo-curation   File: VloBasePage.java   View source code 6 votes vote down vote up
@Override
protected void onInitialize() {
    super.onInitialize();
    // page title label is added here because it uses an overridable method
    add(new Label("title", getTitleModel()));

    // same for page description (this populates the <meta name="description" /> element)
    add(new WebComponent("pageDescription") {
        {
            add(new AttributeAppender("content", getPageDescriptionModel()));
        }
    });

    add(new WebComponent("canonicalUrl") {

        @Override
        protected void onRender() {
            final IModel<String> canonicalUrlModel = getCanonicalUrlModel();
            if (canonicalUrlModel != null) {
                getResponse().write("<link rel=\"canonical\" href=\"" + canonicalUrlModel.getObject() + "\"/>");
            }
        }

    });
}
 
Example 21
Project: Unicorn   File: EventViewPanel.java   View source code 6 votes vote down vote up
public void setEvent(final EapEvent event) {
	this.event = event;

	// add eventtype
	this.label = new Label("eventType", event.getEventType().getTypeName());
	this.label.setOutputMarkupId(true);
	this.addOrReplace(this.label);

	// timestamp
	this.timestamp = new Label("timestamp", this.dateFormatter.format(event.getTimestamp()));
	this.timestamp.setOutputMarkupId(true);
	this.addOrReplace(this.timestamp);

	// hierarchical display of attributes
	this.tree = new LabelTree<EventTreeElement>("treeTable", new TreeProvider(this.generateNodesOfEventTypeTree()), new TreeExpansionModel());
	TreeExpansion.get().expandAll();
	this.tree.setOutputMarkupId(true);
	this.addOrReplace(this.tree);
}
 
Example 22
Project: vlo-curation   File: RecordNavigationPanel.java   View source code 6 votes vote down vote up
public RecordNavigationPanel(String id, final IModel<SearchContext> model, IModel<String> tabModel) {
    super(id, model);

    // Add a label 'record X of Y'
    add(new Label("recordIndex", StringResourceModelMigration.of("record.navigation.index", this, model,
            new Object[]{
                // These values get inserted into the string
                // First: index shifted with +1 (because count starts at 0)
                new ShiftedIndexModel(new PropertyModel<Long>(model, "index"), +1),
                // Second: total result count, unmodified
                new PropertyModel<>(model, "resultCount")
            }
    )));

    // Add a link to go to the previous record
    add(createPreviousLink(model, tabModel));
    // Add a link to go to the next record
    add(createNextLink(model, tabModel));
}
 
Example 23
Project: engerek   File: PageSelfRegistration.java   View source code 6 votes vote down vote up
private void createPasswordPanel(WebMarkupContainer staticRegistrationForm) {
	// ProtectedStringType initialPassword = null;
	PasswordPanel password = new PasswordPanel(ID_PASSWORD,
			new PropertyModel<ProtectedStringType>(userModel, "credentials.password.value"), false, true);
	password.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
	password.getBaseFormComponent().setRequired(true);
	staticRegistrationForm.add(password);

	Label help = new Label(ID_TOOLTIP);
	final StringResourceModel tooltipText = createStringResource("PageSelfRegistration.password.policy");
	help.add(AttributeModifier.replace("title", tooltipText));
	help.add(new InfoTooltipBehavior());
	help.add(new VisibleEnableBehaviour() {
		private static final long serialVersionUID = 1L;

		@Override
		public boolean isVisible() {

			return StringUtils.isNotEmpty(tooltipText.getObject());
		}
	});
	staticRegistrationForm.add(help);
}
 
Example 24
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 25
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 26
Project: engerek   File: ModelOperationStatusPanel.java   View source code 6 votes vote down vote up
protected void initLayout() {

        add(new Label(ID_STATE, new StringResourceModel("ModelOperationStatusPanel.state.${}", new PropertyModel<ModelState>(getModel(), ModelOperationStatusDto.F_STATE))));
//        add(new Label(ID_FOCUS_TYPE, new PropertyModel<String>(getModel(), ModelOperationStatusDto.F_FOCUS_TYPE)));
//        add(new Label(ID_FOCUS_NAME, new PropertyModel<String>(getModel(), ModelOperationStatusDto.F_FOCUS_NAME)));


        ScenePanel deltaPanel = new ScenePanel(ID_PRIMARY_DELTA, new PropertyModel<SceneDto>(getModel(), ModelOperationStatusDto.F_PRIMARY_DELTA));
        deltaPanel.add(new VisibleEnableBehaviour() {
            @Override
            public boolean isVisible() {
                return getModelObject() != null && getModelObject().getPrimaryDelta() != null;
            }
        });
        add(deltaPanel);

    }
 
Example 27
Project: vlo-curation   File: BookmarkLinkPanel.java   View source code 6 votes vote down vote up
public BookmarkLinkPanel(String id, IModel<String> linkModel, IModel<String> pageTitleModel) {
    super(id);
    this.linkModel = linkModel;
    this.pageTitleModel = pageTitleModel;

    add(new ExternalLink("link", linkModel)
            .add(new Label("linkText", pageTitleModel)));
    add(new TextField("linkInput", linkModel));

    add(new WebMarkupContainer("bookmarkInstructions") {
        @Override
        protected void onConfigure() {
            setVisible(bookmarkMode);
        }

    });
    add(new WebMarkupContainer("copyInstructions") {
        @Override
        protected void onConfigure() {
            setVisible(copyMode);
        }

    });
}
 
Example 28
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 29
Project: Unicorn   File: ExternalKnowledgePanel.java   View source code 6 votes vote down vote up
private void buildHeader() {

		final Label attributeToFillLabel = new Label("attributeToFillLabel", "Attribute: " + this.attributeToFill.getAttributeExpression() + " (" + this.attributeToFill.getType() + ")");
		this.layoutForm.addOrReplace(attributeToFillLabel);

		final AjaxButton addCriteriaAttributesAndValuesButton = new AjaxButton("addCriteriaAttributesAndValuesButton", this.layoutForm) {
			private static final long serialVersionUID = 6456362459418575615L;

			@Override
			public void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
				ExternalKnowledgePanel.this.coalesceExpressions.add(new ExternalKnowledgeExpression());
				ExternalKnowledgePanel.this.criteriaAttributesAndValuesListView.setList(ExternalKnowledgePanel.this.coalesceExpressions);
				target.add(ExternalKnowledgePanel.this.container);
			}
		};
		this.layoutForm.addOrReplace(addCriteriaAttributesAndValuesButton);
	}
 
Example 30
Project: engerek   File: CapabilityValuePanel.java   View source code 6 votes vote down vote up
protected void initLayout(PageResourceWizard parentPage) {

		parentPage.addEditingEnabledBehavior(this);

        Label label = new Label(ID_LABEL, createStringResource(getCapabilityLabelKey()));
        add(label);

        CheckBox enabled = new CheckBox(ID_ENABLED, new PropertyModel<Boolean>(getModel(), "capability.enabled"));
		enabled.add(new EmptyOnChangeAjaxFormUpdatingBehavior() {
			@Override
			protected void onUpdate(AjaxRequestTarget target) {
				target.add(capabilityTable);
			}
		});
        add(enabled);
    }
 
Example 31
Project: engerek   File: PageAccounts.java   View source code 6 votes vote down vote up
private void initTotals(Form form) {
    WebMarkupContainer totals = new WebMarkupContainer(ID_TOTALS);
    totals.setOutputMarkupId(true);

    totalModel = createTotalModel();
    deletedModel = createTotalsModel(SynchronizationSituationType.DELETED);
    unmatchedModel = createTotalsModel(SynchronizationSituationType.UNMATCHED);
    disputedModel = createTotalsModel(SynchronizationSituationType.DISPUTED);
    linkedModel = createTotalsModel(SynchronizationSituationType.LINKED);
    unlinkedModel = createTotalsModel(SynchronizationSituationType.UNLINKED);
    nothingModel = createTotalsModel(null);

    totals.add(new Label(ID_TOTAL, totalModel));
    totals.add(new Label(ID_DELETED, deletedModel));
    totals.add(new Label(ID_UNMATCHED, unmatchedModel));
    totals.add(new Label(ID_DISPUTED, disputedModel));
    totals.add(new Label(ID_LINKED, linkedModel));
    totals.add(new Label(ID_UNLINKED, unlinkedModel));
    totals.add(new Label(ID_NOTHING, nothingModel));

    form.add(totals);
}
 
Example 32
Project: engerek   File: WizardHelpDialog.java   View source code 6 votes vote down vote up
public void initLayout(WebMarkupContainer content){
    Label helpLabel = new Label(ID_HELP, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return getString(determineHelpKey());
        }
    });
    helpLabel.setEscapeModelStrings(false);
    content.add(helpLabel);

    AjaxLink ok = new AjaxLink(ID_BUTTON_OK) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            closePerformed(target);
        }
    };
    content.add(ok);
}
 
Example 33
Project: engerek   File: SampleFormFocusTabPanel.java   View source code 6 votes vote down vote up
private void initLayout(final LoadableModel<ObjectWrapper<F>> focusModel, LoadableModel<List<AssignmentEditorDto>> assignmentsModel, PageBase pageBase) {
    add(new Label(ID_HEADER, "Object details"));
    WebMarkupContainer body = new WebMarkupContainer("body");
    add(body);

    addPrismPropertyPanel(body, ID_PROP_NAME, FocusType.F_NAME);
    addPrismPropertyPanel(body, ID_PROP_FULL_NAME, UserType.F_FULL_NAME);

    // TODO: create proxy for these operations
    Task task = pageBase.createSimpleTask(OPERATION_SEARCH_ROLES);
    List<PrismObject<RoleType>> availableRoles;
    try {
        availableRoles = pageBase.getModelService().searchObjects(RoleType.class, null, null, task, task.getResult());
    } catch (SchemaException | ObjectNotFoundException | SecurityViolationException | CommunicationException | 
    		ConfigurationException | ExpressionEvaluationException e) {
        task.getResult().recordFatalError(e);
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load roles", e);
        availableRoles = new ArrayList<>();
        // TODO: better errror reporting
    }

    add(new SimpleRoleSelector<F,RoleType>(ID_ROLES, assignmentsModel, availableRoles));
}
 
Example 34
Project: engerek   File: TextDetailsPanel.java   View source code 6 votes vote down vote up
public TextDetailsPanel(String id, IModel<T> model, Class clazz){
    super(id);

    final TextField<T> text = new TextField<>(ID_INPUT, model);
    text.setType(clazz);
    add(text);

    Label details = new Label(ID_DETAILS);
    details.add(AttributeModifier.replace("title", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return createAssociationTooltip();
        }
    }));
    details.add(new InfoTooltipBehavior(){

        @Override
        public String getDataPlacement(){
            return "bottom";
        }
    });
    add(details);
}
 
Example 35
Project: engerek   File: SystemInfoPanel.java   View source code 6 votes vote down vote up
@Override
protected void initLayout() {
    final WebMarkupContainer table = new WebMarkupContainer(ID_TABLE);
    table.setOutputMarkupId(true);
    add(table);
    table.add(new AjaxSelfUpdatingTimerBehavior(Duration.milliseconds(10000)));

    Label cpuUsage = new Label(ID_CPU_USAGE, new PropertyModel<>(getModel(), SystemInfoDto.F_CPU_USAGE));
    table.add(cpuUsage);

    Label heapMemory = new Label(ID_HEAP_MEMORY, createMemoryModel(true));
    table.add(heapMemory);

    Label nonHeapMemory = new Label(ID_NON_HEAP_MEMORY, createMemoryModel(false));
    table.add(nonHeapMemory);

    Label threads = new Label(ID_THREADS, createThreadModel());
    table.add(threads);

    DateLabelComponent startTime = new DateLabelComponent(ID_START_TIME, createStartTimeModel(), DateLabelComponent.MEDIUM_MEDIUM_STYLE);
    table.add(startTime);

    Label uptime = new Label(ID_UPTIME, createUptimeModel());
    table.add(uptime);
}
 
Example 36
Project: rotabuilder   File: CustomFooterPanel.java   View source code 5 votes vote down vote up
private void addAboutLink() {
    final BookmarkablePageLink<Void> aboutLink = new BookmarkablePageLink<>(ID_ABOUT_LINK, AboutPage.class);
    add(aboutLink);

    final Label aboutLabel = new Label(ID_ABOUT_MESSAGE, new ResourceModel("aboutLabel"));
    aboutLink.add(aboutLabel);
    addDevModeWarning(aboutLink);
}
 
Example 37
Project: karate   File: VarPanel.java   View source code 5 votes vote down vote up
public VarPanel(String id, VarModel model, VarsRefreshingView varsView) {
	super(id);
       IModel<String> txtModel = new IModel<String>() {
           @Override
           public String getObject() {
               return model.getObject().getValue().getAsString();
           }            
           @Override
           public void setObject(String object) {
              
           }
           @Override
           public void detach() {}
       };
       add(new TextArea("value", txtModel));
       String title = model.getObject().getName() + " - " + model.getObject().getValue().getType();
       add(new Label("title", title));
       add(new AjaxLink("close") {
           @Override
           public void onClick(AjaxRequestTarget target) {
               varsView.setSelectedName(null);
               Component headerPanel = VarPanel.this;
               headerPanel = headerPanel.replaceWith(new Label(BasePage.STICKY_HEADER_ID, ""));
               target.add(headerPanel);
               Component varsPanel = varsView.getParent();
               target.add(varsPanel);                        
           }
       });
}
 
Example 38
Project: ansible-docker-talk   File: PersonListView.java   View source code 5 votes vote down vote up
@Override
protected void populateItem(ListItem<Person> item) {
  Person person = item.getModelObject();
  item.add(new Label("firstname", person.getFirstName()));
  item.add(new Label("lastname", person.getLastName()));
  item.add(new Label("jobtitle", person.getJobTitle()));
}
 
Example 39
Project: gitplex-mit   File: ConcreteListPropertyViewer.java   View source code 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	add(new ListView<PropertyContext<Serializable>>("headers", elementPropertyContexts) {

		@Override
		protected void populateItem(ListItem<PropertyContext<Serializable>> item) {
			item.add(new Label("header", EditableUtils.getName(item.getModelObject().getPropertyGetter())));
		}
		
	});
	add(new ListView<Serializable>("rows", elements) {

		@Override
		protected void populateItem(final ListItem<Serializable> rowItem) {
			rowItem.add(new ListView<PropertyContext<Serializable>>("columns", elementPropertyContexts) {

				@Override
				protected void populateItem(ListItem<PropertyContext<Serializable>> columnItem) {
					PropertyContext<Serializable> propertyContext = columnItem.getModelObject(); 
					Serializable elementPropertyValue = (Serializable) propertyContext.getPropertyValue(rowItem.getModelObject());
					columnItem.add(propertyContext.renderForView("cell", Model.of(elementPropertyValue)));
				}
				
			});
		}
		
	});
	WebMarkupContainer noElements = new WebMarkupContainer("noElements");
	noElements.setVisible(elements.isEmpty());
	noElements.add(AttributeModifier.append("colspan", elementPropertyContexts.size()));
	add(noElements);
}
 
Example 40
Project: gitplex-mit   File: PageTabLink.java   View source code 5 votes vote down vote up
public PageTabLink(String id, PageTab tab) {
	super(id);
	
	Link<?> pageLink = newLink("link", tab.getMainPageClass());
	add(pageLink);
	pageLink.add(new Label("label", tab.getTitleModel()));
}