List of usage examples for org.apache.wicket.util.visit IVisitor IVisitor
IVisitor
From source file:au.com.scds.isis.viewer.wicket.ui.components.entity.properties.MyEntityPropertiesForm.java
License:Apache License
private void addButtons(MarkupContainer markupContainer) { // edit button editButton = new AjaxButtonWithOnError(ID_EDIT_BUTTON, new ResourceModel("editLabel")) { private static final long serialVersionUID = 1L; @Override/*from w ww . j av a2 s .c om*/ public void validate() { // same logic as in cancelButton; should this be factored out? try { getEntityModel().load(ConcurrencyChecking.CHECK); } catch (ConcurrencyException ex) { getMessageBroker().addMessage("Object changed by " + ex.getOid().getVersion().getUser() + ", automatically reloading"); getEntityModel().load(ConcurrencyChecking.NO_CHECK); } super.validate(); } @Override public void onSubmit(final AjaxRequestTarget target, final Form<?> form) { getEntityModel().resetPropertyModels(); toEditMode(target); } @Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.getAjaxCallListeners().add(new org.apache.wicket.ajax.attributes.AjaxCallListener() { private static final long serialVersionUID = 1L; @Override public CharSequence getSuccessHandler(Component component) { // scroll to the top of the entity panel return "$('html, body').animate({" + " scrollTop: $('.entityIconAndTitlePanel').offset().top" + " }, 1000);"; } }); } }; editButton.add(new Label("editLabel", editButton.getModel())); markupContainer.add(editButton); // ok button okButton = new AjaxButtonForValidate(ID_OK_BUTTON, new ResourceModel("okLabel")); markupContainer.add(okButton); // cancel button cancelButton = new AjaxButtonForCancel(ID_CANCEL_BUTTON, new ResourceModel("cancelLabel")) { private static final long serialVersionUID = 1L; @Override public void validate() { // same logic as in editButton; should this be factored out? try { getEntityModel().load(ConcurrencyChecking.CHECK); } catch (ConcurrencyException ex) { getMessageBroker().addMessage("Object changed by " + ex.getOid().getVersion().getUser() + ", automatically reloading"); getEntityModel().load(ConcurrencyChecking.NO_CHECK); } super.validate(); } @Override protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { Session.get().getFeedbackMessages().clear(); getForm().clearInput(); getForm().visitFormComponentsPostOrder(new IVisitor<FormComponent<?>, Void>() { @Override public void component(FormComponent<?> formComponent, IVisit<Void> visit) { if (formComponent instanceof CancelHintRequired) { final CancelHintRequired cancelHintRequired = (CancelHintRequired) formComponent; cancelHintRequired.onCancel(); } } }); try { getEntityModel().resetPropertyModels(); } catch (RuntimeException ex) { throw ex; } toViewMode(target); } }; markupContainer.add(cancelButton); okButton.setOutputMarkupPlaceholderTag(true); editButton.setOutputMarkupPlaceholderTag(true); cancelButton.setOutputMarkupPlaceholderTag(true); // flush any JGrowl messages (typically concurrency exceptions) if they // are added. okButton.add(new JGrowlBehaviour()); editButton.add(new JGrowlBehaviour()); cancelButton.add(new JGrowlBehaviour()); }
From source file:com.axway.ats.testexplorer.TestExplorerApplication.java
License:Apache License
@Override protected void init() { Locale.setDefault(Locale.US); getApplicationSettings().setPageExpiredErrorPage(PageExpiredErrorPage.class); getApplicationSettings().setInternalErrorPage(InternalErrorPage.class); // show internal error page rather than default developer page //TODO: use this line in PRODUCTION mode, by default in development mode is used ExceptionSettings.SHOW_EXCEPTION_PAGE // getExceptionSettings().setUnexpectedExceptionDisplay( ExceptionSettings.SHOW_INTERNAL_ERROR_PAGE ); mountPage("/runs", RunsPage.class); mountPage("/suites", SuitesPage.class); mountPage("/scenarios", ScenariosPage.class); mountPage("/testcases", TestcasesPage.class); mountPage("/testcase", TestcasePage.class); mountPage("/charts", ChartsBasePage.class); mountPage("/compare", ComparePage.class); mountPage("/compareStatistics", CompareTestcaseSystemStatisticsPage.class); mountPage("/runMessages", RunMessagePage.class); mountPage("/suiteMessages", SuiteMessagePage.class); mountPage("/machines", MachinesPage.class); mountPage("/runCopy", RunCopyPage.class); mountPage("/testcasesCopy", TestcasesCopyPage.class); mountPage("/reportSelect", SelectTestcaseReportPage.class); mountPage("/pageExpired", PageExpiredErrorPage.class); mountPage("/error", InternalErrorPage.class); mountPage("/dashboardhome", RunsByTypeDashboardHomePage.class); mountPage("/dashboardrun", RunsByTypeDashboardRunPage.class); mountPage("/dashboardsuite", RunsByTypeDashboardSuitePage.class); mountPage("/groups", TestcasesByGroupsPage.class); try {/*from w ww . j a va 2 s .com*/ configProperties = new Properties(); configProperties.load(this.getClass().getClassLoader().getResourceAsStream("ats.config.properties")); } catch (IOException e) { LOG.error("Can't load config.properties file", e); } getAjaxRequestTargetListeners().add(new AjaxRequestTarget.IListener() { @Override public void onBeforeRespond(Map<String, Component> map, final AjaxRequestTarget target) { // if( !Session.get().getFeedbackMessages().isEmpty() ) { target.getPage().visitChildren(IFeedback.class, new IVisitor<Component, Void>() { public void component(final Component component, final IVisit<Void> visit) { if (component.getOutputMarkupId()) { target.appendJavaScript( "$('#" + component.getMarkupId() + "').effect('bounce', { times:5 }, 200);"); target.add(component); //visit.stop(); } visit.dontGoDeeper(); } }); } @Override public void onAfterRespond(Map<String, Component> map, IJavaScriptResponse response) { // Do nothing. } @Override public void updateAjaxAttributes(AbstractDefaultAjaxBehavior behavior, AjaxRequestAttributes attributes) { // TODO Auto-generated method stub } }); // load any available Test Explorer plugins TestExplorerPluginsRepo.getInstance(); }
From source file:com.chitek.ignition.drivers.generictcp.meta.config.ui.MessageConfigUI.java
License:Apache License
/** * Common handler for errors during an Ajax submit *//*from ww w .jav a2 s.co m*/ private void handleError(final AjaxRequestTarget target) { // Update feedback panel and components with errors target.addChildren(getPage(), FeedbackPanel.class); target.getPage().visitChildren(FormComponent.class, new IVisitor<Component, Void>() { @Override public void component(Component component, IVisit<Void> arg1) { if (component.hasErrorMessage()) { target.add(component); } } }); }
From source file:com.chitek.wicket.listeditor.ListEditor.java
License:Apache License
/** * Returns a List with all child components that match the given id and class. * //from www . jav a 2s . c o m * @param id * ID of child components to return * @param clazz * Ther class of the components to return * @return */ public <K extends Component> List<K> getComponentsById(final String id, Class<K> clazz) { final List<K> list = new ArrayList<K>(this.size()); visitChildren(clazz, new IVisitor<K, Boolean>() { @Override public void component(K component, IVisit<Boolean> visit) { if (component.getId().equals(id)) { list.add(component); visit.dontGoDeeper(); } } }); return list; }
From source file:com.evolveum.midpoint.gui.api.util.WebComponentUtil.java
License:Apache License
public static void refreshFeedbacks(MarkupContainer component, final AjaxRequestTarget target) { component.visitChildren(IFeedback.class, new IVisitor<Component, Void>() { @Override//from w w w. j a va2 s . c om public void component(final Component component, final IVisit<Void> visit) { target.add(component); } }); }
From source file:com.evolveum.midpoint.web.component.assignment.AssignmentEditorPanel.java
License:Apache License
private void addAjaxOnUpdateBehavior(WebMarkupContainer container) { container.visitChildren(new IVisitor<Component, Object>() { @Override/*from www . java2 s . co m*/ public void component(Component component, IVisit<Object> objectIVisit) { if (component instanceof InputPanel) { addAjaxOnBlurUpdateBehaviorToComponent(((InputPanel) component).getBaseFormComponent()); } else if (component instanceof FormComponent) { addAjaxOnBlurUpdateBehaviorToComponent(component); } } }); }
From source file:com.francetelecom.clara.cloud.presentation.applications.ApplicationCreatePanel.java
License:Apache License
@Override protected void onInitialize() { parentPage = (ApplicationsPage) getPage(); initComponents();/*from w w w . j a v a2 s . co m*/ appForm.visitChildren(FormComponent.class, new IVisitor<Component, Void>() { @Override public void component(Component object, IVisit<Void> visit) { object.add(new FieldFeedbackDecorator()); visit.dontGoDeeper(); } }); super.onInitialize(); }
From source file:com.francetelecom.clara.cloud.presentation.applications.ApplicationInformationPanel.java
License:Apache License
@Override protected void onInitialize() { appForm.visitChildren(FormComponent.class, new IVisitor<Component, Void>() { @Override/*w w w.jav a2s. com*/ public void component(Component object, IVisit<Void> visit) { object.add(new FieldFeedbackDecorator()); visit.dontGoDeeper(); } }); super.onInitialize(); }
From source file:com.francetelecom.clara.cloud.presentation.designer.EditServiceIT.java
License:Apache License
@Test public void testEditShowsValues() { for (final LogicalService service : logicalDeployment.listLogicalServices()) { DeleteEditObjects.editServiceAtRow(myTester, GetObjectsUtils.getPositionForItem(myTester, service)); myTester.assertVisible(NavigationUtils.designerParamFormPath); Form form = GetObjectsUtils.getParamsForm(myTester); form.visitFormComponents(new IVisitor<FormComponent, Void>() { @Override// w w w . j a v a 2 s .c o m public void component(FormComponent formComponent, IVisit<Void> visit) { if (!(formComponent instanceof Button)) { String name = ((FormComponent) formComponent).getInputName(); // We don't test complex fields, such as maven reference // parameters // Full Validation field don't need to be tested if (!name.contains(".") && !name.equals("fullvalidationContent:fullvalidation")) { try { Field field = GetObjectsUtils.getAnyField(service.getClass(), name); field.setAccessible(true); if (field.get(service) != null) { Assert.assertEquals(field.get(service).toString(), ((FormComponent) formComponent).getDefaultModelObject().toString()); } } catch (NoSuchFieldException e) { Assert.fail("field " + name + " could not be found"); } catch (IllegalAccessException e) { Assert.fail("illegal access on " + name + " field"); } } } visit.dontGoDeeper(); } }); NavigationUtils.submitParamsForm(myTester); } }
From source file:com.francetelecom.clara.cloud.presentation.designer.EditServiceIT.java
License:Apache License
@Test public void testEditReadOnly() { try {//ww w. j a va 2 s . c om ApplicationRelease release = manageApplicationRelease.findApplicationReleaseByUID( myTester.getLastRenderedPage().getPageParameters().get("releaseUid").toString()); release.validate(); release.lock(); manageApplicationRelease.updateApplicationRelease(release); } catch (ObjectNotFoundException e) { Assert.fail("could not find application release with id " + myTester.getLastRenderedPage().getPageParameters().get("releaseUid").toString()); } // go on designer step one page to access internal services NavigationUtils.goOnDesignerPage(myTester, releaseUid); myTester.assertRenderedPage(DesignerPage.class); for (final LogicalService service : logicalDeployment.listLogicalServices()) { // When: I try to edit the service int index = GetObjectsUtils.getPositionForItem(myTester, service); Assert.assertFalse("service not found in architecture matrix", -1 == index); myTester.assertVisible(NavigationUtils.getPathForCell(index, 0) + ":cell-view"); DeleteEditObjects.viewServiceAtRow(myTester, index); myTester.assertVisible(NavigationUtils.modalPath); // Then: all displayed fields are read-only Form form = GetObjectsUtils.getModalParamsForm(myTester); form.visitFormComponents(new IVisitor<FormComponent, Void>() { @Override public void component(FormComponent formComponent, IVisit<Void> visit) { if (!(formComponent instanceof Button)) { TagTester tagTester = myTester.getTagByWicketId(((FormComponent) formComponent).getId()); if (tagTester != null) { Assert.assertNotNull(tagTester.getAttribute("disabled")); } } else { if ("addUpdateButton".equals(((Button) formComponent).getId())) { Assert.assertFalse("add/update button should not be visible", ((Button) formComponent).isVisible()); } else if ("cancelCloseButton".equals(((Button) formComponent).getId())) { Label buttonLabel = (Label) ((FormComponent) formComponent).get("cancelLabel"); Assert.assertTrue("cancel/close button should display \"close\"", "close".equals(buttonLabel.getDefaultModelObjectAsString())); } } visit.dontGoDeeper(); } }); } for (final ProcessingNode node : logicalDeployment.listProcessingNodes()) { // When: I try to edit the node int index = GetObjectsUtils.getPositionForItem(myTester, node); Assert.assertFalse("node not found in architecture matrix", -1 == index); myTester.assertVisible(NavigationUtils.getPathForCell(0, index) + ":cell-view"); DeleteEditObjects.viewNodeAtCol(myTester, index); myTester.assertVisible(NavigationUtils.modalPath); // Then: all displayed fields are read-only Form form = GetObjectsUtils.getModalParamsForm(myTester); form.visitFormComponents(new IVisitor<FormComponent, Void>() { @Override public void component(FormComponent object, IVisit<Void> visit) { if (!(object instanceof Button)) { // Assert.assertFalse(((FormComponent)formComponent).getInputName() // + " should be disabled", // ((FormComponent)formComponent).isEnabled()); } visit.dontGoDeeper(); } }); } }