org.apache.wicket.util.visit.IVisit Java Examples

The following examples show how to use org.apache.wicket.util.visit.IVisit. 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: SaveODocumentsCommand.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
@Override
public void onClick(Optional<AjaxRequestTarget> targetOptional) {
	table.visitChildren(OrienteerDataTable.MetaContextItem.class, new IVisitor<OrienteerDataTable.MetaContextItem<ODocument, ?>, Void>() {

		@Override
		public void component(MetaContextItem<ODocument, ?> rowItem, IVisit<Void> visit) {
			ODocument doc = rowItem.getModelObject();
			if(doc.isDirty()) {
				if(doc.getIdentity().isNew()) SaveODocumentCommand.realizeMandatory(doc);
				doc.save();
			}
			visit.dontGoDeeper();
		}
	});
	if(forceCommit) {
		ODatabaseDocument db = getDatabase();
		boolean active = db.getTransaction().isActive();
		db.commit();
		if(active) db.begin();
	}
	super.onClick(targetOptional);
}
 
Example #2
Source File: SaveOArtifactCommand.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
@Override
public void onClick(final Optional<AjaxRequestTarget> targetOptional) {
    final IModel<Boolean> failed = Model.of(Boolean.FALSE);
    table.visitChildren(MetaContextItem.class, new IVisitor<MetaContextItem<OArtifact, ?>,Void >() {
        @Override
        public void component(MetaContextItem<OArtifact, ?> rowItem, IVisit<Void> visit) {
            OArtifact module = rowItem.getModelObject();
            if (isUserArtifactValid(targetOptional, module)) {
                OArtifact moduleForUpdate = new OArtifact(module.getPreviousArtifactRefence());
                moduleForUpdate.setLoad(module.isLoad())
                        .setTrusted(module.isTrusted());
                OrienteerClassLoaderUtil.updateOArtifactInMetadata(moduleForUpdate, module);
            } else failed.setObject(Boolean.TRUE);
            visit.dontGoDeeper();
        }
    });

    if (!failed.getObject()) {
        showFeedback(targetOptional, false);
        super.onClick(targetOptional);
    }
}
 
Example #3
Source File: AbstractMetaPanel.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public static <K extends AbstractMetaPanel<?, ?, ?>> K getMetaComponent(IMetaContext<?> context, final Object critery)
{
	if(context==null || critery==null) return null;
	else return (K)context.getContextComponent()
					.visitChildren(AbstractMetaPanel.class, new IVisitor<AbstractMetaPanel<?, ?, ?>, AbstractMetaPanel<?, ?, ?>>() {

						@Override
						public void component(
								AbstractMetaPanel<?, ?, ?> object,
								IVisit<AbstractMetaPanel<?, ?, ?>> visit) {
							if(Objects.isEqual(object.getPropertyObject(), critery)) visit.stop(object);
							else visit.dontGoDeeper();
						}
	});
}
 
Example #4
Source File: SaveOLocalizationsCommand.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
@Override
public void onClick(Optional<AjaxRequestTarget> targetOptional) {
    table.visitChildren(OrienteerDataTable.MetaContextItem.class, new IVisitor<OrienteerDataTable.MetaContextItem<ODocument, ?>, Void>() {

        @Override
        public void component(OrienteerDataTable.MetaContextItem<ODocument, ?> rowItem, IVisit<Void> visit) {
            ODocument modelObject = rowItem.getModelObject();
            if (modelObject == null) {
                return;
            }

            String localizationLang = modelObject.field(OrienteerLocalizationModule.OPROPERTY_LANG);
            String localizationValue = modelObject.field(OrienteerLocalizationModule.OPROPERTY_VALUE);
            if (!Strings.isNullOrEmpty(localizationLang) && !Strings.isNullOrEmpty(localizationValue)) {
                modelObject.field(OrienteerLocalizationModule.OPROPERTY_ACTIVE, true);
            }

            modelObject.save();
            visit.dontGoDeeper();
        }
    });
    super.onClick(targetOptional);
}
 
Example #5
Source File: BeanEditor.java    From onedev with MIT License 6 votes vote down vote up
@Override
public void error(PathNode propertyNode, Path pathInProperty, String errorMessage) {
	PathNode.Named named = (Named) propertyNode;
	PropertyEditor<?> propertyEditor = visitChildren(PropertyEditor.class, 
			new IVisitor<PropertyEditor<Serializable>, PropertyEditor<Serializable>>() {

		@Override
		public void component(PropertyEditor<Serializable> object, IVisit<PropertyEditor<Serializable>> visit) {
			if (object.getDescriptor().getPropertyName().equals(named.getName()) && object.isVisibleInHierarchy())
				visit.stop(object);
			else
				visit.dontGoDeeper();
		}
		
	});
	if (propertyEditor != null)
		propertyEditor.error(pathInProperty, errorMessage);
}
 
Example #6
Source File: AbstractUITCase.java    From syncope with Apache License 2.0 6 votes vote down vote up
protected static <V extends Serializable> Component findComponentByPropNotNull(
        final String property, final String path) {

    Component component = TESTER.getComponentFromLastRenderedPage(path);
    return (component instanceof MarkupContainer ? MarkupContainer.class.cast(component) : component.getPage()).
            visitChildren(ListItem.class, (ListItem<?> object, IVisit<Component> visit) -> {
                try {
                    Method getter = PropertyResolver.getPropertyGetter(property, object.getModelObject());
                    if (getter != null && getter.invoke(object.getModelObject()) != null) {
                        visit.stop(object);
                    }
                } catch (Exception e) {
                    LOG.debug("Error finding component by property {} not null on path {}", property, path, e);
                }
            });
}
 
Example #7
Source File: AbstractUITCase.java    From syncope with Apache License 2.0 6 votes vote down vote up
protected static <V extends Serializable> Component findComponentByProp(
        final String property, final String path, final V key) {

    Component component = TESTER.getComponentFromLastRenderedPage(path);
    return (component instanceof MarkupContainer ? MarkupContainer.class.cast(component) : component.getPage()).
            visitChildren(ListItem.class, (ListItem<?> object, IVisit<Component> visit) -> {
                try {
                    Method getter = PropertyResolver.getPropertyGetter(property, object.getModelObject());
                    if (getter != null && getter.invoke(object.getModelObject()).equals(key)) {
                        visit.stop(object);
                    }
                } catch (Exception e) {
                    LOG.debug("Error finding component by property ({},{}) on path {}", property, key, path, e);
                }
            });
}
 
Example #8
Source File: LogsITCase.java    From syncope with Apache License 2.0 6 votes vote down vote up
private static Component searchLog(final String property, final String searchPath, final String key) {
    Component component = TESTER.getComponentFromLastRenderedPage(searchPath);

    Component result = component.getPage().
            visitChildren(ListItem.class, (final ListItem<LoggerTO> object, final IVisit<Component> visit) -> {
                try {
                    if (object.getModelObject() instanceof LoggerTO && PropertyResolver.getPropertyGetter(
                            property, object.getModelObject()).invoke(object.getModelObject()).equals(key)) {
                        visit.stop(object);
                    }
                } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
                    LOG.error("Error invoke method", ex);
                }
            });
    return result;
}
 
Example #9
Source File: BootstrapFeedbackPopover.java    From pm-wicket-utils with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();

	filter = new IFeedbackMessageFilter() {
		private static final long serialVersionUID = -7726392072697648969L;

		public boolean accept(final FeedbackMessage msg) {
			Boolean b = visitChildren(FormComponent.class, new IVisitor<FormComponent<?>, Boolean>() {
				@Override
				public void component(FormComponent<?> arg0, IVisit<Boolean> arg1) {
					if (arg0.equals(msg.getReporter()))
						arg1.stop(true);
				}
			});

			if (b == null)
				return false;

			return b;
		}
	};

}
 
Example #10
Source File: BootstrapFeedbackPanel.java    From pm-wicket-utils with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean accept(final FeedbackMessage message) {
	if(BootstrapFeedbackPanel.this.getParent()!=null){
		BootstrapFeedbackPopover innerAccepted = BootstrapFeedbackPanel.this.getParent()
				.visitChildren(BootstrapFeedbackPopover.class, new IVisitor<BootstrapFeedbackPopover, BootstrapFeedbackPopover>() {

			@Override
			public void component(BootstrapFeedbackPopover object, IVisit<BootstrapFeedbackPopover> visit) {
				if(object.getFilter().accept(message)){
					visit.stop(object);
				}
			}
		});
		
		return innerAccepted==null;
	}
	return true;
}
 
Example #11
Source File: BootstrapControlGroupFeedback.java    From pm-wicket-utils with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected void onConfigure() {
	super.onConfigure();
	
	filter = new IFeedbackMessageFilter() {
		private static final long serialVersionUID = -7726392072697648969L;

		public boolean accept(final FeedbackMessage msg) {
			Boolean b = visitChildren(FormComponent.class, new IVisitor<FormComponent<?>, Boolean>() {
				@Override
				public void component(FormComponent<?> arg0, IVisit<Boolean> arg1) {
					if (arg0.equals(msg.getReporter()))
						arg1.stop(true);
				}
			});

			if (b == null)
				return false;

			return b;
		}
	};
}
 
Example #12
Source File: BootstrapDateTimePicker.java    From pm-wicket-utils with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Gets the DateTextField inside this datepicker wrapper.
 *
 * @return the date field
 */
public DateTextField getDateTextField()
{
	DateTextField component = visitChildren(DateTextField.class, new IVisitor<DateTextField, DateTextField>() {
		@Override
		public void component(DateTextField arg0, IVisit<DateTextField> arg1) {
			arg1.stop(arg0);
		}
	});

	if (component == null) {
		
		throw new WicketRuntimeException("BootstrapDateTimepicker didn't have any DateTextField child!");
	}
	
	return component;
}
 
Example #13
Source File: WicketPageTestBase.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Searches ContentMenuEntryPanels.
 * @param container
 * @param accessKey
 * @return Found component with the given label or null if no such component found.
 * @see FormComponent#getModelObject()
 * @see LabeledWebMarkupContainer#getLabel()
 * @see ContentMenuEntryPanel#getLabel()
 */
public Component findComponentByAccessKey(final MarkupContainer container, final char accessKey)
{
  final Component[] component = new Component[1];
  container.visitChildren(new IVisitor<Component, Void>() {
    @Override
    public void component(final Component object, final IVisit<Void> visit)
    {
      if (object instanceof AbstractLink) {
        final AbstractLink link = (AbstractLink) object;
        final AttributeModifier attrMod = WicketUtils.getAttributeModifier(link, "accesskey");
        if (attrMod == null || attrMod.toString().contains("object=[n]") == false) {
          return;
        }
        component[0] = object;
        visit.stop();
      }
    }
  });
  return component[0];
}
 
Example #14
Source File: AdvancedFormVisitor.java    From nextreports-server with Apache License 2.0 6 votes vote down vote up
public void component(FormComponent<?> object, IVisit<Void> visit) {
		Palette<?> palette = object.findParent(Palette.class);
		Component comp;
		if (palette != null) {
			comp = palette;
		} else {
			comp = object;
		}
		if (!visited.contains(comp))	{
			visited.add(comp);
			
			/*
			if (isValidComponent(c)) {
				AdvancedFormComponentLabel label = new AdvancedFormComponentLabel(getLabelId(c), c);
				c.getParent().add(label);
				c.setLabel(new Model<String>(c.getId()));
			}
			*/
			
//			c.setComponentBorder(new RequiredBorder());
			comp.add(new ValidationMessageBehavior());
			comp.add(new ErrorHighlightBehavior());
		}
	}
 
Example #15
Source File: AjaxCheckTablePanel.java    From nextreports-server with Apache License 2.0 6 votes vote down vote up
private void onHeaderCheckChanged(final boolean selectAll, final AjaxRequestTarget target) {
 	// refresh rows affected by changing
 	dataTable.visitChildren(HighlitableDataItem.class, new IVisitor<HighlitableDataItem, Void>() {

@Override
public void component(HighlitableDataItem object, IVisit<Void> visit) {
 			if (object.isHighlite() != selectAll) {
 				object.toggleHighlite();
 				target.add(object);
 			}
}

 	});

 	// refresh bulk menu
 	updateSelectedObjects();
     new BulkMenuUpdateEvent(this, target).fire();
 }
 
Example #16
Source File: RevisionDiffPanel.java    From onedev with MIT License 6 votes vote down vote up
@Nullable
private SourceAware getSourceAware(String path) {
	return diffsView.visitChildren(new IVisitor<Component, SourceAware>() {

		@SuppressWarnings("unchecked")
		@Override
		public void component(Component object, IVisit<SourceAware> visit) {
			if (object instanceof ListItem) {
				ListItem<BlobChange> item = (ListItem<BlobChange>) object;
				if (item.getModelObject().getPaths().contains(path)) {
					visit.stop((SourceAware) item.get(DIFF_ID));
				} else {
					visit.dontGoDeeper();
				}
			} 
		}

	});
}
 
Example #17
Source File: BeanEditor.java    From onedev with MIT License 6 votes vote down vote up
@Override
protected Serializable convertInputToValue() throws ConversionException {
	final Serializable bean = (Serializable) getDescriptor().newBeanInstance();
	
	visitChildren(PropertyEditor.class, new IVisitor<PropertyEditor<Serializable>, PropertyEditor<Serializable>>() {

		@Override
		public void component(PropertyEditor<Serializable> object, IVisit<PropertyEditor<Serializable>> visit) {
			if (!object.getDescriptor().isPropertyExcluded()) 
				object.getDescriptor().setPropertyValue(bean, object.getConvertedInput());
			visit.dontGoDeeper();
		}
		
	});
	
	return bean;
}
 
Example #18
Source File: InfinitePagingDataTable.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
@Override
public void onConfigure()
{
	super.onConfigure();
	toolbars.configure();

	Boolean visible = toolbars.visitChildren(new IVisitor<Component, Boolean>()
	{
		@Override
		public void component(Component object, IVisit<Boolean> visit)
		{
			object.configure();
			if (object.isVisible())
			{
				visit.stop(Boolean.TRUE);
			}
			else
			{
				visit.dontGoDeeper();
			}
		}
	});

	if (visible == null)
	{
		visible = false;
	}

	setVisible(visible);
}
 
Example #19
Source File: StructureTable.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@Override
public void onConfigure()
{
	super.onConfigure();

	toolbars.configure();

	Boolean visible = toolbars.visitChildren(new IVisitor<Component, Boolean>()
	{
		@Override
		public void component(Component object, IVisit<Boolean> visit)
		{
			object.configure();
			if (object.isVisible())
			{
				visit.stop(Boolean.TRUE);
			}
			else
			{
				visit.dontGoDeeper();
			}
		}
	});
	if (visible == null)
	{
		visible = false;
	}
	setVisible(visible);
}
 
Example #20
Source File: DefaultFocusFormVisitor.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
public void component(Component object, IVisit<Void> visit) {
	if (!visited.contains(object) && (object instanceof FormComponent) && !(object instanceof Button)) {
		final FormComponent<?> fc = (FormComponent<?>) object;
		visited.add(fc);
		if (!found && fc.isEnabled() && fc.isVisible()
				&& (fc instanceof DropDownChoice || fc instanceof AbstractTextComponent)) {
			found = true;
			fc.add(new DefaultFocusBehavior());
		}
	}
}
 
Example #21
Source File: NextFeedbackPanel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
private List<FormComponent<?>> getFormComponents(Form<?> form) {
     final List<FormComponent<?>> components = new ArrayList<FormComponent<?>>();
     form.visitFormComponents(new IVisitor<FormComponent<?>, Void>() {

@Override
public void component(FormComponent<?> object, IVisit<Void> visit) {
             components.add(object);
}

     });
     
     return components;
 }
 
Example #22
Source File: AjaxCheckTablePanel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
private void updateSelectedObjects() {
 	selectedObjects.clear();
 	dataTable.visitChildren(HighlitableDataItem.class, new IVisitor<HighlitableDataItem, Void>() {

@Override
public void component(HighlitableDataItem object, IVisit<Void> visit) {
 			if (object.isHighlite()) {
 				selectedObjects.add(object.getModelObject());
 			}

	visit.dontGoDeeper();
}

 	});
 }
 
Example #23
Source File: AjaxCheckTablePanel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
@Override
    public Component getHeader(String componentId) {
    	IModel<Boolean> checkBoxHeaderModel = new LoadableDetachableModel<Boolean>() {

private static final long serialVersionUID = 1L;

private boolean selected;

@Override
protected Boolean load() {
	selected = false;
      	dataTable.visitChildren(HighlitableDataItem.class, new IVisitor<HighlitableDataItem, Void>() {

		@Override
		public void component(HighlitableDataItem object, IVisit<Void> visit) {
      			if (!object.isHighlite()) {
      				selected = false;
      				return;
      			}
      			
      			selected = true;
      			
  				visit.dontGoDeeper();
		}

      	});

      	return selected;
}
    		
    	};

        return new CheckBoxHeaderPanel(componentId, checkBoxHeaderModel);
    }
 
Example #24
Source File: EmbeddedCollectionEditPanel.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
protected void convertToData() {
	visitFormComponentsPostOrder(this, new IVisitor<FormComponent<?>, Void>() {

		@Override
		public void component(FormComponent<?> object,
				IVisit<Void> visit) {
			if(embeddedView != null && embeddedView.equals(object.getClass()))
			{
				object.convertInput();
				object.updateModel();
				visit.dontGoDeeper();
			}
		}
	});
}
 
Example #25
Source File: EmbeddedMapEditPanel.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
protected void convertToData() {
	visitChildren(FormComponent.class, new IVisitor<FormComponent<Object>, Void>() {

		@Override
		public void component(FormComponent<Object> object,
				IVisit<Void> visit) {
			if(!(EmbeddedMapEditPanel.this.equals(object)))
			{
				object.convertInput();
				object.updateModel();
				visit.dontGoDeeper();
			}
		}
	});
}
 
Example #26
Source File: AbstractMetaPanel.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public static <C> IMetaContext<C> getMetaContext(Component component)
{
	return (IMetaContext<C>) component.visitParents(MarkupContainer.class, new IVisitor<MarkupContainer, IMetaContext<C>>() {

		@Override
		public void component(MarkupContainer object,
				IVisit<IMetaContext<C>> visit) {
			visit.stop((IMetaContext<C>)object);
		}
	}, new ClassVisitFilter(IMetaContext.class));
}
 
Example #27
Source File: BootstrapDatePicker.java    From pm-wicket-utils with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Gets the DateTextField inside this datepicker wrapper.
 *
 * @return the date field
 */
public DateTextField getDateTextField(){
	DateTextField component = visitChildren(DateTextField.class, new IVisitor<DateTextField, DateTextField>() {
		@Override
		public void component(DateTextField arg0, IVisit<DateTextField> arg1) {
			arg1.stop(arg0);
		}
	});

	if (component == null)
		throw new WicketRuntimeException("BootstrapDatepicker didn't have any DateTextField child!");

	return component;
}
 
Example #28
Source File: BootstrapTemporalDatepicker.java    From pm-wicket-utils with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected void onConfigure() {
	super.onConfigure();

	dateField = visitChildren(TemporalTextField.class, new IVisitor<TemporalTextField<T>, TemporalTextField<T>>() {
		@Override
		public void component(TemporalTextField<T> arg0, IVisit<TemporalTextField<T>> arg1) {
			arg1.stop(arg0);
		}
	});
}
 
Example #29
Source File: InfinitePagingDataTable.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
@Override
public void onConfigure()
{
	super.onConfigure();
	toolbars.configure();

	Boolean visible = toolbars.visitChildren(new IVisitor<Component, Boolean>()
	{
		@Override
		public void component(Component object, IVisit<Boolean> visit)
		{
			object.configure();
			if (object.isVisible())
			{
				visit.stop(Boolean.TRUE);
			}
			else
			{
				visit.dontGoDeeper();
			}
		}
	});

	if (visible == null)
	{
		visible = false;
	}

	setVisible(visible);
}
 
Example #30
Source File: ValidationFormVisitor.java    From wicket-spring-boot with Apache License 2.0 5 votes vote down vote up
@Override
	public void component(Component c, IVisit<R> visit) {
		if (!visited.contains(c)) {
			if(c instanceof FormComponent){
				FormComponent fc = (FormComponent) c;
				c.add(new ValidationMsgBehavior());
//				c.add(new PropertyValidator<>());
				visited.add(fc);
			}
		}
	}