Java Code Examples for org.apache.wicket.Component#setVisible()

The following examples show how to use org.apache.wicket.Component#setVisible() . 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: LambdaBehavior.java    From webanno with Apache License 2.0 5 votes vote down vote up
public static Behavior visibleWhen(SerializableBooleanSupplier aPredicate)
{
    return new Behavior()
    {
        private static final long serialVersionUID = -7550330528381560032L;

        @Override
        public void onConfigure(Component aComponent)
        {
            aComponent.setVisible(aPredicate.getAsBoolean());
        }
    };
}
 
Example 2
Source File: ServerWidePage.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
@SuppressWarnings("serial")
private void makeSelectorLink(final String id, final String view) {
	IndicatingAjaxLink link = new IndicatingAjaxLink(id) {
		@Override
		public void onClick(AjaxRequestTarget target) {
			// select view
			report.setSelectedView(view);
			// make title, description & notes visible
			reportTitle.add(new AttributeModifier("style", new Model("display: block")));
			reportDescription.add(new AttributeModifier("style", new Model("display: block")));
			reportNotes.add(new AttributeModifier("style", new Model("display: block")));
			reportChart.renderImage(target, true);
			// toggle selectors link state
			for(Component lbl : labels.values()) {
				lbl.setVisible(false);
			}
			for(Component lnk : links) {
				lnk.setVisible(true);
			}
			this.setVisible(false);
			labels.get(this).setVisible(true);
			// mark component for rendering
			target.add(selectors);
			target.add(reportTitle);
			target.add(reportDescription);
			target.add(reportNotes);
			target.appendJavaScript("setMainFrameHeightNoScroll( window.name, 650 )");
		}
	};
	link.setVisible(true);
	links.add(link);
	selectors.add(link);
	makeSelectorLabel(link, id + "Lbl");
}
 
Example 3
Source File: SettingsCategoryPanel.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * Helper to handle the value and style updates of the running total label
 *
 * @param runningTotal label component to update
 * @param runningTotalMessage error message component
 * @return
 */
private void updateRunningTotal(final Component runningTotal, final Component runningTotalMessage) {

	final List<CategoryDefinition> categories = this.model.getObject().getGradebookInformation().getCategories();

	BigDecimal total = BigDecimal.ZERO;
	for (final CategoryDefinition categoryDefinition : categories) {

		Double catWeight = categoryDefinition.getWeight();
		if (catWeight == null) {
			catWeight = 0D;
		}

		BigDecimal weight = BigDecimal.valueOf(catWeight);
		if (weight == null) {
			weight = BigDecimal.ZERO;
		}

		if (!categoryDefinition.getExtraCredit()) {
			total = total.add(weight);
		}
	}

	// if comparison passes, we have '1' as the value
	if (total.compareTo(BigDecimal.ONE) == 0) {
		runningTotal.add(new AttributeModifier("class", "text-success"));
		runningTotalMessage.setVisible(false);
	} else {
		runningTotal.add(new AttributeModifier("class", "text-danger"));
		runningTotalMessage.setVisible(true);
	}

	runningTotal.setDefaultModel(Model.of(FormatHelper.formatDoubleAsPercentage(total.doubleValue() * 100)));
}
 
Example 4
Source File: AbstractFieldPanel.java    From syncope with Apache License 2.0 5 votes vote down vote up
public AbstractFieldPanel<T> hideLabel() {
    final Component label = get(LABEL);

    if (label != null) {
        label.setVisible(false);
    }

    return this;
}
 
Example 5
Source File: ServerWidePage.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
@SuppressWarnings("serial")
private void makeSelectorLink(final String id, final String view) {
	IndicatingAjaxLink link = new IndicatingAjaxLink(id) {
		@Override
		public void onClick(AjaxRequestTarget target) {
			// select view
			report.setSelectedView(view);
			// make title, description & notes visible
			reportTitle.add(new AttributeModifier("style", new Model("display: block")));
			reportDescription.add(new AttributeModifier("style", new Model("display: block")));
			reportNotes.add(new AttributeModifier("style", new Model("display: block")));
			reportChart.renderImage(target, true);
			// toggle selectors link state
			for(Component lbl : labels.values()) {
				lbl.setVisible(false);
			}
			for(Component lnk : links) {
				lnk.setVisible(true);
			}
			this.setVisible(false);
			labels.get(this).setVisible(true);
			// mark component for rendering
			target.add(selectors);
			target.add(reportTitle);
			target.add(reportDescription);
			target.add(reportNotes);
			target.appendJavaScript("setMainFrameHeightNoScroll( window.name, 650 )");
		}
	};
	link.setVisible(true);
	links.add(link);
	selectors.add(link);
	makeSelectorLabel(link, id + "Lbl");
}
 
Example 6
Source File: SettingsCategoryPanel.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * Helper to handle the value and style updates of the running total label
 *
 * @param runningTotal label component to update
 * @param runningTotalMessage error message component
 * @return
 */
private void updateRunningTotal(final Component runningTotal, final Component runningTotalMessage) {

	final List<CategoryDefinition> categories = this.model.getObject().getGradebookInformation().getCategories();

	BigDecimal total = BigDecimal.ZERO;
	for (final CategoryDefinition categoryDefinition : categories) {

		Double catWeight = categoryDefinition.getWeight();
		if (catWeight == null) {
			catWeight = 0D;
		}

		BigDecimal weight = BigDecimal.valueOf(catWeight);
		if (weight == null) {
			weight = BigDecimal.ZERO;
		}

		if (!categoryDefinition.getExtraCredit()) {
			total = total.add(weight);
		}
	}

	// if comparison passes, we have '1' as the value
	if (total.compareTo(BigDecimal.ONE) == 0) {
		runningTotal.add(new AttributeModifier("class", "text-success"));
		runningTotalMessage.setVisible(false);
	} else {
		runningTotal.add(new AttributeModifier("class", "text-danger"));
		runningTotalMessage.setVisible(true);
	}

	runningTotal.setDefaultModel(Model.of(FormatHelper.formatDoubleAsPercentage(total.doubleValue() * 100)));
}
 
Example 7
Source File: SearchEntityPanel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
private void makeSearchComponentVisible(Component component, boolean isRowLabel) {
	component.setVisible(true);
	if (isRowLabel) {
		component.add(AttributeModifier.replace("class", "row-label row-bottom"));
	} else {
		component.add(AttributeModifier.replace("class", "row-bottom"));
	}
}
 
Example 8
Source File: ViewGradeSummaryAction.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
@Override
public ActionResponse handleEvent(final JsonNode params, final AjaxRequestTarget target) {
	final String studentUuid = params.get("studentId").asText();

	final GradebookUiSettings settings = ((GradebookPage) target.getPage()).getUiSettings();

	final GbUser student = businessService.getUser(studentUuid);

	final Map<String, Object> model = new HashMap<>();
	model.put("studentUuid", studentUuid);
	model.put("groupedByCategoryByDefault", settings.isCategoriesEnabled());

	final GradebookPage gradebookPage = (GradebookPage) target.getPage();
	final GbModalWindow window = gradebookPage.getStudentGradeSummaryWindow();

	final Component content = new StudentGradeSummaryPanel(window.getContentId(), Model.ofMap(model), window);

	if (window.isShown() && window.isVisible()) {
		window.replace(content);
		content.setVisible(true);
		target.add(content);
	} else {
		window.setContent(content);
		window.show(target);
	}

	window.setStudentToReturnFocusTo(studentUuid);
	content.setOutputMarkupId(true);

	final String modalTitle = (new StringResourceModel("heading.studentsummary",
			null, new Object[] { student.getDisplayName(), student.getDisplayId() })).getString();

	window.setTitle(modalTitle);
	window.show(target);

	target.appendJavaScript(String.format(
			"new GradebookGradeSummary($(\"#%s\"), false, \"%s\");",
			content.getMarkupId(), modalTitle));

	return new EmptyOkResponse();
}
 
Example 9
Source File: SyncVisibilityBehaviour.java    From wicket-orientdb with Apache License 2.0 4 votes vote down vote up
@Override
public void onConfigure(Component component) {
	super.onConfigure(component);
	sourceComponent.configure();
	component.setVisible(sourceComponent.determineVisibility());
}
 
Example 10
Source File: ViewGradeSummaryAction.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
@Override
public ActionResponse handleEvent(final JsonNode params, final AjaxRequestTarget target) {
	final String studentUuid = params.get("studentId").asText();

	final GradebookUiSettings settings = ((GradebookPage) target.getPage()).getUiSettings();

	final GbUser student = businessService.getUser(studentUuid);

	final Map<String, Object> model = new HashMap<>();
	model.put("studentUuid", studentUuid);
	model.put("groupedByCategoryByDefault", settings.isCategoriesEnabled());

	final GradebookPage gradebookPage = (GradebookPage) target.getPage();
	final GbModalWindow window = gradebookPage.getStudentGradeSummaryWindow();

	final Component content = new StudentGradeSummaryPanel(window.getContentId(), Model.ofMap(model), window);

	if (window.isShown() && window.isVisible()) {
		window.replace(content);
		content.setVisible(true);
		target.add(content);
	} else {
		window.setContent(content);
		window.show(target);
	}

	window.setStudentToReturnFocusTo(studentUuid);
	content.setOutputMarkupId(true);

	final String modalTitle = (new StringResourceModel("heading.studentsummary",
			null, new Object[] { student.getDisplayName(), student.getDisplayId() })).getString();

	window.setTitle(modalTitle);
	window.show(target);

	target.appendJavaScript(String.format(
			"new GradebookGradeSummary($(\"#%s\"), false, \"%s\");",
			content.getMarkupId(), modalTitle));

	return new EmptyOkResponse();
}