/** * Gets the currently coupled {@link Behavior}s as a unmodifiable list. Returns an empty list * rather than null if there are no behaviors coupled to this component. * * @return The currently coupled behaviors as a unmodifiable list */ public final List<? extends Behavior> getBehaviors() { return getBehaviors(null); }
/** * Gets the currently coupled {@link Behavior}s as a unmodifiable list. Returns an empty list * rather than null if there are no behaviors coupled to this component. * * @return The currently coupled behaviors as a unmodifiable list */ public final List<? extends Behavior> getBehaviors() { return getBehaviors(null); }
/** * Gets the currently coupled {@link IBehavior}s as a unmodifiable list. Returns an empty list * rather than null if there are no behaviors coupled to this component. * * @return The currently coupled behaviors as a unmodifiable list */ public final List/* <IBehavior> */getBehaviors() { return getBehaviors(null); }
private TimerPushBehavior _findPushBehaviour(final Component component) { for (final Behavior behavior : component.getBehaviors()) if (behavior instanceof TimerPushBehavior) return (TimerPushBehavior)behavior; return null; }
private CometdPushBehavior _findPushBehaviour(final Component component) { for (final IBehavior behavior : component.getBehaviors()) if (behavior instanceof CometdPushBehavior) return (CometdPushBehavior)behavior; return null; }
/** * Gets the currently coupled {@link IBehavior}s as a unmodifiable list. Returns an empty list * rather than null if there are no behaviors coupled to this component. * * @return The currently coupled behaviors as a unmodifiable list */ public final List<IBehavior> getBehaviors() { return getBehaviors(IBehavior.class); }
private GridLayoutConstraint getGridConstraint(final Component component) { for (final Behavior behavior : component.getBehaviors()) if (behavior instanceof GridLayoutConstraint) return (GridLayoutConstraint)behavior; return null; }
private GridLayoutConstraint getGridConstraint(final Component component) { for (final IBehavior behavior : component.getBehaviors()) if (behavior instanceof GridLayoutConstraint) return (GridLayoutConstraint)behavior; return null; }
private TimerPushBehavior _findPushBehaviour(final Component component) { for (final IBehavior behavior : component.getBehaviors()) if (behavior instanceof TimerPushBehavior) return (TimerPushBehavior)behavior; return null; }
/** * @param component * @param behaviorClass * @return Behavior or null */ public static Behavior findBehavior(Component component, Class<? extends Behavior> behaviorClass) { for (Behavior behavior : component.getBehaviors(behaviorClass)) { return behavior; } return null; }
/** * @param component * @param behaviorClass * @return Behavior or null */ public static Behavior findBehavior(Component component, Class<? extends Behavior> behaviorClass) { for (Behavior behavior : component.getBehaviors(behaviorClass)) { return behavior; } return null; }
@Override public void component(Component object, IVisit<Void> visit) { observers.addAll(object.getBehaviors(io.onedev.server.web.behavior.WebSocketObserver.class)); }
@Override protected boolean matchesSafely(T item) { return Matchers.hasItem(behavior).matches(item.getBehaviors()); }
public void uninstallPush(final Component component) { for (final IBehavior behavior : component.getBehaviors()) { if (behavior instanceof TimerChannelBehavior) { component.remove(behavior); } } }
@Override public void bind(Component component) { this.component = component; for (Map.Entry<String, ExtEventAjaxBehavior> entry : eventHandlers.entrySet()) { ExtEventAjaxBehavior behavior = entry.getValue(); if (!component.getBehaviors().contains(behavior)) { component.add(behavior); } } }
@SuppressWarnings("unchecked") public Object component(Component component) { List<IBehavior> behaviors = component.getBehaviors(); for (int a = 0; a < behaviors.size(); a++) { IBehavior behavior = behaviors.get(a); if (behavior instanceof DropBehavior) { DropBehavior dropPoint = (DropBehavior) behavior; visit(dropPoint); return IVisitor.CONTINUE_TRAVERSAL_BUT_DONT_GO_DEEPER; } } return IVisitor.CONTINUE_TRAVERSAL; }
@SuppressWarnings("unchecked") public void component(Component component, IVisit<Void> visit) { for (Behavior behavior : component.getBehaviors()) { if (behavior instanceof DropBehavior) { DropBehavior dropPoint = (DropBehavior) behavior; visitDropBehavior(dropPoint); visit.dontGoDeeper(); } } }
public void component(Component component, IVisit<Void> visit) { for (Object behavior : component.getBehaviors()) { if (behavior instanceof IWireframe) { IWireframe wireframe = (IWireframe) behavior; wireframe.resize(target); visit.dontGoDeeper(); return; } } } });
/** * {@link Behavior#beforeRender(Component)} Notify all behaviors that are assigned to this * component that the component is about to be rendered. */ private void notifyBehaviorsComponentBeforeRender() { for (Behavior behavior : getBehaviors()) { if (isBehaviorAccepted(behavior)) { behavior.beforeRender(this); } } }
@Test public void removeRemovesBehavior() { final Behavior behavior = new CssClassNameAppender("classname"); final Component component = new WebMarkupContainer("container"); component.add(behavior); assertThat(Behaviors.remove(component, behavior), is(equalTo(true))); assertThat(component.getBehaviors().size(), is(equalTo(0))); }