Java Code Examples for org.apache.wicket.markup.html.basic.Label#setOutputMarkupId()

The following examples show how to use org.apache.wicket.markup.html.basic.Label#setOutputMarkupId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CafeAddress.java    From tutorials with MIT License 6 votes vote down vote up
public CafeAddress(final PageParameters parameters) {
    super(parameters);
    initCafes();

    ArrayList<String> cafeNames = new ArrayList<>(cafeNamesAndAddresses.keySet());
    selectedCafe = cafeNames.get(0);
    address = new Address(cafeNamesAndAddresses.get(selectedCafe).getAddress());

    final Label addressLabel = new Label("address", new PropertyModel<String>(this.address, "address"));
    addressLabel.setOutputMarkupId(true);

    final DropDownChoice<String> cafeDropdown = new DropDownChoice<>("cafes", new PropertyModel<>(this, "selectedCafe"), cafeNames);
    cafeDropdown.add(new AjaxFormComponentUpdatingBehavior("onchange") {
        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            String name = (String) cafeDropdown.getDefaultModel().getObject();
            address.setAddress(cafeNamesAndAddresses.get(name).getAddress());
            target.add(addressLabel);
        }
    });

    add(addressLabel);
    add(cafeDropdown);

}
 
Example 2
Source File: HtmlAnnotationEditor.java    From inception with Apache License 2.0 5 votes vote down vote up
public HtmlAnnotationEditor(String aId, IModel<AnnotatorState> aModel,
        AnnotationActionHandler aActionHandler, CasProvider aCasProvider)
{
    super(aId, aModel, aActionHandler, aCasProvider);

    vis = new Label("vis", LambdaModel.of(this::renderHtml));
    vis.setOutputMarkupId(true);
    vis.setEscapeModelStrings(false);
    add(vis);

    storeAdapter = new StoreAdapter();
    add(storeAdapter);
}
 
Example 3
Source File: BaseTreePage.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
protected AjaxLink getExpandCollapseLink(){
	//Expand Collapse Link:
	final Label expandCollapse = new Label("expandCollapse", new StringResourceModel("exapndNodes", null));
	expandCollapse.setOutputMarkupId(true);
	AjaxLink expandLink  = new AjaxLink("expandAll")
	{
		boolean expand = true;
		@Override
		public void onClick(AjaxRequestTarget target)
		{
			if(expand){
				getTree().getTreeState().expandAll();
				expandCollapse.setDefaultModel(new StringResourceModel("collapseNodes", null));
				collapseEmptyFolders();
			}else{
				getTree().getTreeState().collapseAll();
				expandCollapse.setDefaultModel(new StringResourceModel("exapndNodes", null));
			}
			target.add(expandCollapse);
			getTree().updateTree(target);
			expand = !expand;

		}
		@Override
		public boolean isVisible() {
			return getTree().getDefaultModelObject() != null;
		}
	};
	expandLink.add(expandCollapse);
	return expandLink;
}
 
Example 4
Source File: BaseTreePage.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
protected AjaxLink getExpandCollapseLink(){
	//Expand Collapse Link:
	final Label expandCollapse = new Label("expandCollapse", new StringResourceModel("exapndNodes", null));
	expandCollapse.setOutputMarkupId(true);
	AjaxLink expandLink  = new AjaxLink("expandAll")
	{
		boolean expand = true;
		@Override
		public void onClick(AjaxRequestTarget target)
		{
			if(expand){
				getTree().getTreeState().expandAll();
				expandCollapse.setDefaultModel(new StringResourceModel("collapseNodes", null));
				collapseEmptyFolders();
			}else{
				getTree().getTreeState().collapseAll();
				expandCollapse.setDefaultModel(new StringResourceModel("exapndNodes", null));
			}
			target.add(expandCollapse);
			getTree().updateTree(target);
			expand = !expand;

		}
		@Override
		public boolean isVisible() {
			return getTree().getDefaultModelObject() != null;
		}
	};
	expandLink.add(expandCollapse);
	return expandLink;
}
 
Example 5
Source File: DashboardEmbedCodePanel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
public DashboardEmbedCodePanel(String id, final String dashboardId) {
	super(id);						
					
	model = new ErrorLoadableDetachableModel(dashboardId);
	final Label codeLabel = new Label("code", model);
	codeLabel.setEscapeModelStrings(false);		
	codeLabel.setOutputMarkupId(true);
	add(codeLabel);					
			
	feedbackPanel = new FeedbackPanel("feedback");
       feedbackPanel.setOutputMarkupId(true);
       add(feedbackPanel);
						
}
 
Example 6
Source File: HomePage.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
public HomePage(PageParameters parameters) {
    super(parameters);        

	// clear search context
	NextServerSession.get().setSearchContext(null);

	growlLabel = new Label("growl", "");
	growlLabel.setOutputMarkupId(true);
    growlBehavior = new JGrowlAjaxBehavior();
	growlLabel.add(growlBehavior);
	add(growlLabel);

    // add slidebar
    addSlidebar();

    // add css
    /*
    add(new Behavior() {

        @Override
        public void renderHead(Component component, IHeaderResponse response) {
            super.renderHead(component, response);

            response.render(CssReferenceHeaderItem.forUrl("css/style.css"));
            response.render(CssReferenceHeaderItem.forUrl("css/table.css"));
            response.render(CssReferenceHeaderItem.forUrl("css/layout.css"));
        }

    });
    */
}
 
Example 7
Source File: KeyBindingsPanel.java    From webanno with Apache License 2.0 4 votes vote down vote up
public KeyBindingsPanel(String aId, IModel<List<KeyBinding>> aKeyBindings,
        IModel<FeatureState> aModel, AnnotationActionHandler aHandler)
{
    super(aId, aModel);
    
    actionHandler = aHandler;
    keyBindings = aKeyBindings;
   
    add(visibleWhen(() -> keyBindings.map(List::isEmpty).getObject()));
    
    WebMarkupContainer keyBindingsContainer = new WebMarkupContainer("keyBindingsContainer");
    keyBindingsContainer.setOutputMarkupId(true);
    keyBindingsContainer.add(new ClassAttributeModifier() {
        private static final long serialVersionUID = -6661003854862017619L;

        @Override
        protected Set<String> update(Set<String> aClasses)
        {
            if (!keyBindingsVisible) {
                aClasses.add("there-but-not-visible");
            }
            return aClasses;
        }
    });
    add(keyBindingsContainer);

    Label showHideMessage = new Label("showHideMessage", () -> {
        return keyBindingsVisible ? "Hide key bindings..." : "Show key bindings...";
    });
    showHideMessage.setOutputMarkupId(true);

    LambdaAjaxLink toggleKeyBindingHints = new LambdaAjaxLink("toggleKeyBindingHints", 
        _target -> {
            keyBindingsVisible = !keyBindingsVisible;
            _target.add(keyBindingsContainer, showHideMessage);
        });
    toggleKeyBindingHints.add(showHideMessage);
    toggleKeyBindingHints
            .add(LambdaBehavior.visibleWhen(() -> !aKeyBindings.getObject().isEmpty()));
    add(toggleKeyBindingHints);
    
    keyBindingsContainer.add(new ListView<KeyBinding>("keyBindings", aKeyBindings) {
        private static final long serialVersionUID = 3942714328686353093L;

        @Override
        protected void populateItem(ListItem<KeyBinding> aItem)
        {
            AnnotationFeature feature = aModel.getObject().feature;
            String value = aItem.getModelObject().getValue();
            FeatureSupport<?> fs = featureSupportRegistry.getFeatureSupport(feature);
            
            LambdaAjaxLink link = new LambdaAjaxLink("shortcut",
                _target -> actionInvokeShortcut(_target, aItem.getModelObject()));
            
            KeyType[] keyCombo = aItem.getModelObject().asKeyTypes();
            link.add(new InputBehavior(keyCombo, EventType.click)
            {
                private static final long serialVersionUID = -413804179695231212L;

                @Override
                protected Boolean getDisable_in_input()
                {
                    return true;
                }
            });
            
            aItem.add(new Label("keyCombo", aItem.getModelObject().asHtml())
                    .setEscapeModelStrings(false));
            
            link.add(new Label("value", fs.renderFeatureValue(feature, value)));
            aItem.add(link);
        }
    });
}
 
Example 8
Source File: OnlinePresenceIndicator.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
public OnlinePresenceIndicator(String id, String userUuid) {
	super(id);
	
	//get user's firstname
	String firstname = sakaiProxy.getUserFirstName(userUuid);
	if(StringUtils.isBlank(firstname)){
		firstname = new StringResourceModel("profile.name.first.none", null).getString();
	}
	
	//get user's online status
	int status = connectionsLogic.getOnlineStatus(userUuid);
	
	//get the mapping
	Map<String,String> m = mapStatus(status);
	
	//tooltip text
	Label text = new Label("text", new StringResourceModel(m.get("text"), null, new Object[]{ firstname } ));
	text.setOutputMarkupId(true);
	add(text);
	
	//we need to id of the text span so that we can map it to the link.
	//the qtip functions automatically hide it for us.
	StringBuilder textId = new StringBuilder();
	textId.append("#");
	textId.append(text.getMarkupId());
	
	//link
	AjaxFallbackLink link = new AjaxFallbackLink("link") {
		public void onClick(AjaxRequestTarget target) {
			//nothing
		}
	};
	link.add(new AttributeModifier("rel", true, new Model(textId)));
	link.add(new AttributeModifier("href", true, new Model(textId)));
	
	//image
	ContextImage image = new ContextImage("icon",new Model(m.get("url")));
	link.add(image);
	
	add(link);

}
 
Example 9
Source File: ServerWidePage.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
private void renderBody() {
	add(new AdminMenu("menu"));
	
	// model
	report = new ServerWideModel();
	setDefaultModel(new CompoundPropertyModel(this));
	
	Form form = new Form("serverWideReportForm");
	add(form);
	
	// title, description & notes
	reportTitle = new Label("report.reportTitle");
	reportTitle.setOutputMarkupId(true);
	form.add(reportTitle);
	reportDescription = new Label("report.reportDescription");
	reportDescription.setOutputMarkupId(true);
	form.add(reportDescription);
	reportNotes = new Label("report.reportNotes");
	reportNotes.setOutputMarkupId(true);
	form.add(reportNotes);

	// chart
	reportChart = new AjaxLazyLoadImage("reportChart", getPage()) {
		@Override
		public byte[] getImageData() {
			return getChartImage(selectedWidth, selectedHeight);
		}

		@Override
		public byte[] getImageData(int width, int height) {
			return getChartImage(width, height);
		}
	};
	reportChart.setOutputMarkupId(true);
	reportChart.setAutoDetermineChartSizeByAjax(".chartContainer");
	form.add(reportChart);
	
	// selectors
	selectors = new WebMarkupContainer("selectors");
	selectors.setOutputMarkupId(true);
	form.add(selectors);
	makeSelectorLink("reportMonthlyLogin", StatsManager.MONTHLY_LOGIN_REPORT);
	makeSelectorLink("reportWeeklyLogin", StatsManager.WEEKLY_LOGIN_REPORT);
	makeSelectorLink("reportDailyLogin", StatsManager.DAILY_LOGIN_REPORT);
	makeSelectorLink("reportRegularUsers", StatsManager.REGULAR_USERS_REPORT);
	makeSelectorLink("reportHourlyUsage", StatsManager.HOURLY_USAGE_REPORT);
	makeSelectorLink("reportTopActivities", StatsManager.TOP_ACTIVITIES_REPORT);
	makeSelectorLink("reportTool", StatsManager.TOOL_REPORT);
}
 
Example 10
Source File: TopologyNodePanel.java    From syncope with Apache License 2.0 4 votes vote down vote up
public TopologyNodePanel(final String id, final TopologyNode node) {
    super(id);
    this.node = node;

    final String resourceName = node.getDisplayName().length() > 14
            ? node.getDisplayName().subSequence(0, 10) + "..."
            : node.getDisplayName();

    label = new Label("label", resourceName);
    label.setOutputMarkupId(true);
    add(label);

    final String title;

    switch (node.getKind()) {
        case SYNCOPE:
            title = "";
            add(new AttributeAppender("class", "topology_root", " "));
            break;
        case CONNECTOR_SERVER:
            title = node.getDisplayName();
            add(new AttributeAppender("class", "topology_cs", " "));
            break;
        case FS_PATH:
            title = node.getDisplayName();
            add(new AttributeAppender("class", "topology_cs", " "));
            break;
        case CONNECTOR:
            title = (StringUtils.isBlank(node.getConnectionDisplayName())
                    ? "" : node.getConnectionDisplayName() + ':') + node.getDisplayName();
            add(new AttributeAppender("class", "topology_conn", " "));
            break;
        default:
            title = node.getDisplayName().length() > 14 ? node.getDisplayName() : "";
            add(new AttributeAppender("class", "topology_res", " "));
    }

    if (StringUtils.isNotEmpty(title)) {
        add(AttributeModifier.append("data-original-title", title));
    }

    this.setMarkupId(node.getDisplayName());
}
 
Example 11
Source File: LogStatementPanel.java    From syncope with Apache License 2.0 4 votes vote down vote up
public LogStatementPanel(final String id, final LogStatement statement) {
    super(id);

    Alert.Type type;
    switch (statement.getLevel()) {
        case DEBUG:
            type = Alert.Type.Success;
            break;

        case INFO:
            type = Alert.Type.Info;
            break;

        case ERROR:
            type = Alert.Type.Danger;
            break;

        case WARN:
            type = Alert.Type.Warning;
            break;

        default:
            type = Alert.Type.Info;
    }
    labelCssClass = "alert-" + type.name().toLowerCase();

    add(new Label("logger", Model.of(statement.getLoggerName())));
    add(new Label("instant", Model.of(FORMAT.format(statement.getTimeMillis()))));
    add(new Label("message", Model.of(statement.getMessage())));

    WebMarkupContainer collapse = new WebMarkupContainer("collapse");
    collapse.setOutputMarkupId(true);
    collapse.setOutputMarkupPlaceholderTag(true);
    collapse.setVisible(StringUtils.isNotBlank(statement.getStackTrace()));
    collapse.add(new JQueryUIBehavior(
            '#' + collapse.getMarkupId(), "accordion", new Options("active", false).set("collapsible", true)));
    add(collapse);

    Label stacktrace = new Label("stacktrace", Model.of(statement.getStackTrace()));
    stacktrace.setOutputMarkupId(true);
    collapse.add(stacktrace);
}
 
Example 12
Source File: AlertWidget.java    From syncope with Apache License 2.0 4 votes vote down vote up
public AlertWidget(final String id) {
    super(id);
    this.latestAlerts = getLatestAlerts();

    setOutputMarkupId(true);

    final LoadableDetachableModel<Integer> size = new LoadableDetachableModel<Integer>() {

        private static final long serialVersionUID = 7474274077691068779L;

        @Override
        protected Integer load() {
            return getLatestAlertsSize();
        }
    };

    add(getIcon("icon"));

    linkAlertsNumber = new Label("alerts", size) {

        private static final long serialVersionUID = 4755868673082976208L;

        @Override
        protected void onComponentTag(final ComponentTag tag) {
            super.onComponentTag(tag);
            if (Integer.parseInt(getDefaultModelObject().toString()) > 0) {
                tag.put("class", "badge badge-warning navbar-badge");
            } else {
                tag.put("class", "badge badge-success navbar-badge");
            }
        }
    };
    add(linkAlertsNumber.setOutputMarkupId(true));

    headerAlertsNumber = new Label("number", size);
    headerAlertsNumber.setOutputMarkupId(true);
    add(headerAlertsNumber);

    add(getEventsLink("alertsLink"));

    latestAlertsList = new WebMarkupContainer("latestAlertsList");
    latestAlertsList.setOutputMarkupId(true);
    add(latestAlertsList);
}
 
Example 13
Source File: OnlinePresenceIndicator.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
public OnlinePresenceIndicator(String id, String userUuid) {
	super(id);
	
	//get user's firstname
	String firstname = sakaiProxy.getUserFirstName(userUuid);
	if(StringUtils.isBlank(firstname)){
		firstname = new StringResourceModel("profile.name.first.none", null).getString();
	}
	
	//get user's online status
	int status = connectionsLogic.getOnlineStatus(userUuid);
	
	//get the mapping
	Map<String,String> m = mapStatus(status);
	
	//tooltip text
	Label text = new Label("text", new StringResourceModel(m.get("text"), null, new Object[]{ firstname } ));
	text.setOutputMarkupId(true);
	add(text);
	
	//we need to id of the text span so that we can map it to the link.
	//the qtip functions automatically hide it for us.
	StringBuilder textId = new StringBuilder();
	textId.append("#");
	textId.append(text.getMarkupId());
	
	//link
	AjaxFallbackLink link = new AjaxFallbackLink("link") {
		public void onClick(AjaxRequestTarget target) {
			//nothing
		}
	};
	link.add(new AttributeModifier("rel", true, new Model(textId)));
	link.add(new AttributeModifier("href", true, new Model(textId)));
	
	//image
	ContextImage image = new ContextImage("icon",new Model(m.get("url")));
	link.add(image);
	
	add(link);

}
 
Example 14
Source File: ServerWidePage.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
private void renderBody() {
	add(new AdminMenu("menu"));
	
	// model
	report = new ServerWideModel();
	setDefaultModel(new CompoundPropertyModel(this));
	
	Form form = new Form("serverWideReportForm");
	add(form);
	
	// title, description & notes
	reportTitle = new Label("report.reportTitle");
	reportTitle.setOutputMarkupId(true);
	form.add(reportTitle);
	reportDescription = new Label("report.reportDescription");
	reportDescription.setOutputMarkupId(true);
	form.add(reportDescription);
	reportNotes = new Label("report.reportNotes");
	reportNotes.setOutputMarkupId(true);
	form.add(reportNotes);

	// chart
	reportChart = new AjaxLazyLoadImage("reportChart", getPage()) {
		@Override
		public byte[] getImageData() {
			return getChartImage(selectedWidth, selectedHeight);
		}

		@Override
		public byte[] getImageData(int width, int height) {
			return getChartImage(width, height);
		}
	};
	reportChart.setOutputMarkupId(true);
	reportChart.setAutoDetermineChartSizeByAjax(".chartContainer");
	form.add(reportChart);
	
	// selectors
	selectors = new WebMarkupContainer("selectors");
	selectors.setOutputMarkupId(true);
	form.add(selectors);
	makeSelectorLink("reportMonthlyLogin", StatsManager.MONTHLY_LOGIN_REPORT);
	makeSelectorLink("reportWeeklyLogin", StatsManager.WEEKLY_LOGIN_REPORT);
	makeSelectorLink("reportDailyLogin", StatsManager.DAILY_LOGIN_REPORT);
	makeSelectorLink("reportRegularUsers", StatsManager.REGULAR_USERS_REPORT);
	makeSelectorLink("reportHourlyUsage", StatsManager.HOURLY_USAGE_REPORT);
	makeSelectorLink("reportTopActivities", StatsManager.TOP_ACTIVITIES_REPORT);
	makeSelectorLink("reportTool", StatsManager.TOOL_REPORT);
}
 
Example 15
Source File: DefineDrillEntityPanel.java    From nextreports-server with Apache License 2.0 4 votes vote down vote up
public DefineDrillEntityPanel(String id, String type, final DrillDownEntity drillEntity, Entity entity) {
	super(id, new CompoundPropertyModel<DrillDownEntity>(drillEntity));
	
	this.type = type;
	
	final Label widgetLabel = new Label("entityLabel", getString(type));		
	add(widgetLabel);
	
	final DropDownChoice<Entity> entityChoice = new DropDownChoice<Entity>("entities", 
			new PropertyModel<Entity>(drillEntity, "entity"), new WidgetDropDownModel(), new EntityChoiceRenderer());
	entityChoice.setOutputMarkupPlaceholderTag(true);
	entityChoice.setOutputMarkupId(true);
	entityChoice.setRequired(true);
	add(entityChoice);
	
	final Label linkLabel = new Label("linkLabel", getString("ActionContributor.Drill.parameter"));
	linkLabel.setOutputMarkupId(true);
	linkLabel.setOutputMarkupPlaceholderTag(true);
	add(linkLabel);
	
	final DropDownChoice<String> paramChoice = new DropDownChoice<String>("parameters",
               new PropertyModel<String>(drillEntity, "linkParameter"), parameters, new ChoiceRenderer<String>());
       paramChoice.setRequired(true);
       paramChoice.setLabel(new Model<String>( getString("ActionContributor.Drill.parameter")));
       paramChoice.setOutputMarkupId(true);
       paramChoice.setOutputMarkupPlaceholderTag(true);
       add(paramChoice);
       
       final Label columnLabel = new Label("columnLabel",  getString("ActionContributor.Drill.column"));            
       columnLabel.setOutputMarkupId(true);
       columnLabel.setOutputMarkupPlaceholderTag(true);
	add(columnLabel);
                   
       final TextField<Integer> columnField = new TextField<Integer>("column");            
       columnField.setOutputMarkupId(true);
       columnField.setOutputMarkupPlaceholderTag(true);
       add(columnField);
       
       if (drillEntity.getIndex() == 0) {
       	if (entity instanceof Chart) {
       		columnLabel.setVisible(false);            	
       		columnField.setVisible(false);            		 
       	}
       } else {
       	if (DrillDownUtil.getLastDrillType(entity) == DrillDownEntity.CHART_TYPE) {
       		columnLabel.setVisible(false);            	
       		columnField.setVisible(false);            		   
       	} 
       }
       
       entityChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") {

           @Override
           protected void onUpdate(AjaxRequestTarget target) {
          	updateParameters(drillEntity);                     
              target.add(paramChoice);
           }

       }); 
       
}
 
Example 16
Source File: FollowedArtifactNotificationRulesDemoPanel.java    From artifact-listener with Apache License 2.0 4 votes vote down vote up
public FollowedArtifactNotificationRulesDemoPanel(String id, IModel<List<ArtifactNotificationRule>> rulesModel) {
	super(id, rulesModel);
	
	add(new Label("title", new ResourceModel("artifact.rules.demo.title")));
	
	add(new Label("demoDescription", new ResourceModel("artifact.rules.demo.text")));
	
	final IModel<String> demoTextModel = Model.of();
	final IModel<Boolean> willNotifyModel = Model.of(false);
	IModel<String> demoResultModel = new LoadableDetachableModel<String>() {
		private static final long serialVersionUID = 1L;

		@Override
		protected String load() {
			if (!StringUtils.hasText(demoTextModel.getObject())) {
				return getString("artifact.rules.demo.label.empty");
			} else if (willNotifyModel.getObject()) {
				return getString("artifact.rules.demo.label.willNotify");
			}
			return getString("artifact.rules.demo.label.willIgnore");
		}
	};
	
	final Label demoResultLabel = new Label("demoResultLabel", demoResultModel);
	demoResultLabel.setOutputMarkupId(true);
	demoResultLabel.add(new AttributeModifier("class", LABEL_INFO_CLASS));
	add(demoResultLabel);
	
	TextField<String> demoInput = new TextField<String>("demoInput", demoTextModel);
	demoInput.add(new OnChangeAjaxBehavior() {
		private static final long serialVersionUID = 1L;

		@Override
		protected void onUpdate(AjaxRequestTarget target) {
			String version = demoTextModel.getObject();
			boolean willNotify = false;
			String textClass;

			if (StringUtils.hasText(version)) {
				willNotify = artifactNotificationRuleService.checkRulesForVersion(version, getModelObject());
				textClass = (willNotify) ? LABEL_SUCCESS_CLASS : LABEL_ERROR_CLASS;
			} else {
				textClass = LABEL_INFO_CLASS;
			}
			demoResultLabel.add(new AttributeModifier("class", textClass));

			willNotifyModel.setObject(willNotify);
			target.add(demoResultLabel);
		}
	});
	add(demoInput);
}