List of usage examples for org.apache.wicket MarkupContainer get
@Override public final Component get(String path)
From source file:com.chitek.ignition.drivers.generictcp.meta.config.ui.HeaderConfigUI.java
License:Apache License
/** * Create the DataType drop down. When the data type is changed, the offsets will be recalculated and updated. *//*www .j a v a 2s . c o m*/ private DropDownChoice<HeaderDataType> getDataTypeDropdown() { DropDownChoice<HeaderDataType> dropDown = new DropDownChoice<HeaderDataType>("dataType", HeaderDataType.getOptions(), new EnumChoiceRenderer<HeaderDataType>(this)) { @Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); if (hasErrorMessage()) { String style = "background-color:#ffff00;"; String oldStyle = tag.getAttribute("style"); tag.put("style", style + oldStyle); } } }; dropDown.setRequired(true); // When the data type is changed, the offsets are recalculated and displayed dropDown.add(new OnChangeAjaxBehavior() { @SuppressWarnings("unchecked") @Override protected void onUpdate(AjaxRequestTarget target) { // Recalculate and display the offsets updateOffsets(target); // Disable value field when DataType does not use a value. DropDownChoice<HeaderDataType> choice = (DropDownChoice<HeaderDataType>) getComponent(); MarkupContainer parent = choice.getParent(); HeaderDataType dataType = choice.getConvertedInput(); target.add( parent.get("rawValue").setEnabled(dataType.isHasValue()).setVisible(dataType.isHasValue())); target.add(parent.get("size").setEnabled(dataType.isArrayAllowed())); } }); dropDown.add(new UniqueListItemValidator<HeaderDataType>(dropDown) { @Override public String getValue(IValidatable<HeaderDataType> validatable) { return String.valueOf(validatable.getValue().name()); } }.setMessageKey("dataType.SpecialTypesValidator").setFilterList(HeaderDataType.getSpecialItemNames())); return dropDown; }
From source file:com.chitek.ignition.drivers.generictcp.meta.config.ui.MessageConfigUI.java
License:Apache License
/** * Create the DataType dropdown. When the datatype is changed, the offsets will be recalculated and updated. *///from w w w . java 2s .co m private DropDownChoice<BinaryDataType> getDataTypeDropdown() { DropDownChoice<BinaryDataType> dropDown = new DropDownChoice<BinaryDataType>("dataType", BinaryDataType.getOptions(), new EnumChoiceRenderer<BinaryDataType>(this)) { @Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); if (hasErrorMessage()) { String style = "background-color:#ffff00;"; String oldStyle = tag.getAttribute("style"); tag.put("style", style + oldStyle); } } }; dropDown.setRequired(true); // When the datatype is changed, the offsets are recalculated and displayed dropDown.add(new OnChangeAjaxBehavior() { @SuppressWarnings("unchecked") @Override protected void onUpdate(AjaxRequestTarget target) { // Recalculate and display the offsets updateOffsets(target); // Disable input fields when DataType is a special type. // Current state is determined by the enabled state of TextField("id") DropDownChoice<BinaryDataType> choice = (DropDownChoice<BinaryDataType>) getComponent(); MarkupContainer parent = choice.getParent(); Component idTextField = parent.get("id"); BinaryDataType dataType = choice.getConvertedInput(); if (dataType.isSpecial() && idTextField.isEnabled()) { // DataType changed to special type // Store current values ((TextField<Integer>) idTextField).getRawInput(); idTextField.replaceWith(getSpecialIdTextField().setEnabled(false)); target.add(parent.get("id")); target.add(parent.get("alias").setVisible(false)); } else if (!idTextField.isEnabled()) { idTextField.replaceWith(getIdTextField()); target.add(parent.get("id").setEnabled(true)); target.add(parent.get("alias").setVisible(true)); } target.add(parent.get("size").setEnabled(dataType.isArrayAllowed())); target.add(parent.get("tagLengthType").setEnabled(dataType.supportsVariableLength())); if (!dataType.supportsVariableLength()) { EditorListItem<TagConfig> listItem = getComponent().findParent(EditorListItem.class); if (listItem != null) { listItem.getModelObject().setTagLengthType(TagLengthType.FIXED_LENGTH); } } } }); dropDown.add(new UniqueListItemValidator<BinaryDataType>(dropDown) { @Override public String getValue(IValidatable<BinaryDataType> validatable) { return String.valueOf(validatable.getValue().name()); } }.setMessageKey("dataType.SpecialTypesValidator") .setFilterList(new String[] { BinaryDataType.MessageAge.name() })); return dropDown; }
From source file:com.francetelecom.clara.cloud.presentation.utils.PaasWicketTester.java
License:Apache License
public String lookupPath(final MarkupContainer markupContainer, final String path) { // try to look it up directly if (markupContainer.get(path) != null) return path; // if that fails, traverse the component hierarchy looking for it final List<Component> candidates = new ArrayList<Component>(); markupContainer.visitChildren(new IVisitor<Component, List<Component>>() { Set<Component> visited = new HashSet<Component>(); @Override// w ww .j a v a 2 s .c om public void component(Component c, IVisit<List<Component>> visit) { if (!visited.contains(c)) { visited.add(c); if (c.getId().equals(path)) { candidates.add(c); } else { if (c.getPath().endsWith(path)) { candidates.add(c); } } } } }); // if its unambiguous, then return the full path if (candidates.isEmpty()) { fail("path: '" + path + "' not found for " + Classes.simpleName(markupContainer.getClass())); return null; } else if (candidates.size() == 1) { String pathToContainer = markupContainer.getPath(); String pathToComponent = candidates.get(0).getPath(); return pathToComponent.replaceFirst(pathToContainer + ":", ""); } else { String message = "path: '" + path + "' is ambiguous for " + Classes.simpleName(markupContainer.getClass()) + ". Possible candidates are: "; for (Component c : candidates) { message += "[" + c.getPath() + "]"; } fail(message); return null; } }
From source file:com.googlecode.londonwicket.ComponentExpression.java
License:Apache License
private static List<Component> getChild(Component parent, String expression, Collection<Condition> conditions) { if (parent instanceof MarkupContainer) { MarkupContainer parentContainer = (MarkupContainer) parent; if (expression.equals(ANY_COMPONENT_MATCHER)) { List<Component> allChildren = getAllChildren(parentContainer); List<Component> allChildrenMatchingCondition = new ArrayList<Component>(); for (Component child : allChildren) { if (child != null && evaluateConditions(conditions, child)) { allChildrenMatchingCondition.add(child); }//w w w . java2 s . c o m } return allChildrenMatchingCondition; } else { Component comp = parentContainer.get(expression); if (comp == null || !evaluateConditions(conditions, comp)) { return Collections.emptyList(); } else { return Arrays.asList(comp); } } } else { return Collections.emptyList(); } }
From source file:com.servoy.j2db.server.headlessclient.dataui.WebAccordionPanel.java
License:Open Source License
private void addCurrentFormComponent() { if (currentForm.isReady()) { int index = getTabIndex(); if (index >= 0) { MarkupContainer parent = (MarkupContainer) ((MarkupContainer) accordion.get(0)).get(index); if (parent != null) { if (parent.get(currentForm.getWebForm().getId()) != null) { // replace it parent.replace(currentForm.getWebForm()); } else { // else add it parent.add(currentForm.getWebForm()); }/*from w w w . j a va2 s .c om*/ } } } }
From source file:de.alpharogroup.wicket.component.search.ComponentExpression.java
License:Apache License
/** * Search for all child {@link org.apache.wicket.Component}s with the given expression and the * given parent with the given collection of {@link Condition}s as filter. * /* ww w. ja va 2 s . c om*/ * @param parent * the parent that will be the start point to search. * @param expression * the expression for search. * @param conditions * a collection of {@link Condition}s to filter. * @return all found child {@link org.apache.wicket.Component}s in a {@link java.util.List}. */ private static List<Component> getChild(Component parent, String expression, Collection<Condition> conditions) { if (parent instanceof MarkupContainer) { MarkupContainer parentContainer = (MarkupContainer) parent; if (expression.equals(ANY_COMPONENT_MATCHER)) { List<Component> allChildren = getAllChildren(parentContainer); List<Component> allChildrenMatchingCondition = new ArrayList<Component>(); for (Component child : allChildren) { if (child != null && evaluateConditions(conditions, child)) { allChildrenMatchingCondition.add(child); } } return allChildrenMatchingCondition; } else { Component comp = parentContainer.get(expression); if (comp == null || !evaluateConditions(conditions, comp)) { return Collections.emptyList(); } else { return Arrays.asList(comp); } } } else { return Collections.emptyList(); } }
From source file:de.javakaffee.kryoserializers.wicket.WicketTest.java
License:Apache License
@Test(enabled = true) public void testFeedbackPanel() throws Exception { final FeedbackPanel markupContainer = new FeedbackPanel("foo"); //markupContainer.info( "foo" ); final Component child = markupContainer.get(0); child.isVisible();//from ww w .ja v a 2 s . co m final byte[] serialized = serialize(_kryo, markupContainer); final MarkupContainer deserialized = deserialize(_kryo, serialized, markupContainer.getClass()); final Component deserializedChild = deserialized.get(0); deserializedChild.isVisible(); KryoTest.assertDeepEquals(deserialized, markupContainer); }
From source file:gr.interamerican.wicket.bo2.utils.SelfDrawnUtils.java
License:Open Source License
/** * Returns the component of a SelfDrawnPanel under the specific repeater wicketId. * //from w w w . ja v a2 s .c o m * @param selfDrawnPanel * Self drawn panel. * * @param wicketId * The wicketId of the repeater that has this component. * * @return selfDrawnComponent * Component in the repeater that has the specified wicket id. */ public static Component getComponentFromSelfDrawnPanel(MarkupContainer selfDrawnPanel, String wicketId) { if (selfDrawnPanel == null) { return null; } return selfDrawnPanel.get(wicketId); }
From source file:gr.interamerican.wicket.factories.LinkFactory.java
License:Open Source License
/** * Creates an AjaxLink that togles on/of the visibility of a component. * //www .j a v a2 s. c om * The Component must have <code>outputMarkUpPlaceholderId = true</code>. * * @param componentName * Name of the panel who's visibility is toggled on/off. * @param <T> * Type of link model object. * * @param container - O container that contains the component and the link. * * @return Returns the link. */ public static <T> AjaxLink<T> createTogleVisibleLink(final String componentName, final MarkupContainer container) { AjaxLink<T> refreshLink = new AjaxLink<T>(componentName + "Link") { //$NON-NLS-1$ /** * serialize. */ private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { Component component = container.get(componentName); boolean newVisibility = !component.isVisible(); component.setVisible(newVisibility); target.add(component); } }; return refreshLink; }
From source file:gr.interamerican.wicket.utils.WicketUtils.java
License:Open Source License
/** * Method that enables Required Validators. * @param container - the component that contains the required fields * @param mandatoryFields - the required fields * /* w w w . j a v a 2 s. c om*/ */ public static void enableRequiredValidators(MarkupContainer container, String[] mandatoryFields) { for (String mandatoryField : mandatoryFields) { ((FormComponent<?>) container.get(mandatoryField)).setRequired(true); } }