1 /** 2 * Copyright 2005-2014 The Kuali Foundation 3 * 4 * Licensed under the Educational Community License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.opensource.org/licenses/ecl2.php 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package org.kuali.rice.krad.uif.lifecycle; 17 18 import java.util.List; 19 20 import org.kuali.rice.krad.uif.component.Component; 21 import org.kuali.rice.krad.uif.lifecycle.ViewLifecycle.LifecycleEvent; 22 import org.kuali.rice.krad.uif.util.LifecycleElement; 23 24 /** 25 * Represents a phase in the view lifecycle. 26 * 27 * <p>A phase is contains a collection of {@link org.kuali.rice.krad.uif.lifecycle.ViewLifecycleTask} instances 28 * that are processed on each component in the view tree.</p> 29 * 30 * @author Kuali Rice Team (rice.collab@kuali.org) 31 */ 32 public interface ViewLifecyclePhase extends LifecycleElementState, Runnable { 33 34 /** 35 * Prepares a phase for use after being recycled (state cleared). 36 * 37 * @param element lifecycle element to prepare 38 * @param parentPath path of the element related to its parent (in other words the property of the parent 39 * that holds this element) 40 * @param parent parent component 41 * @param refreshPaths during a component refresh request, the list of view paths that should be processed 42 * by the phase (this includes a subset of the entire view tree) 43 */ 44 void prepare(LifecycleElement element, Component parent, String parentPath, List<String> refreshPaths); 45 46 /** 47 * Retrieves the component that is a parent to the element being processed in the 48 * view three. 49 * 50 * @return parent component 51 */ 52 Component getParent(); 53 54 /** 55 * Determines if this lifecycle phase has completed processing. 56 * 57 * <p> 58 * This method will return true when this phase's tasks have been processed, but does not 59 * necessarily indicate that successor phases have been completed. Use {@link #isComplete()} to 60 * determine if the lifecycle has been fully completed for this phase. 61 * </p> 62 * 63 * @return true if this phase has been processed, false if not 64 */ 65 boolean isProcessed(); 66 67 /** 68 * Determines if this lifecycle phase and all successor phases, have completed processing. 69 * 70 * @return true if this phase and all successor phases have been processed, false if not 71 * @see Component#notifyCompleted(ViewLifecyclePhase) 72 */ 73 boolean isComplete(); 74 75 /** 76 * Gets the task currently running. 77 * 78 * @return the task currently running, null if this phase is not active. 79 */ 80 ViewLifecycleTask<?> getCurrentTask(); 81 82 /** 83 * Gets the event to notify on completion. 84 * 85 * @return lifecycle event to notify on completion 86 * @see ViewLifecycle.LifecycleEvent 87 */ 88 LifecycleEvent getEventToNotify(); 89 90 /** 91 * Gets the expected view status prior to phase execution. 92 * 93 * @return expected view status prior to phase execution 94 */ 95 String getStartViewStatus(); 96 97 /** 98 * Gets the expected view status after phase execution. 99 * 100 * @return expected view status after phase execution 101 */ 102 String getEndViewStatus(); 103 104 /** 105 * Gets the lifecycle phase that directly precedes this phase. 106 * 107 * @return lifecycle phase that directly precedes this phase 108 */ 109 ViewLifecyclePhase getPredecessor(); 110 111 /** 112 * Sets the next phase, to queue for processing after this phase is completed. 113 * 114 * @param nextPhase next phase 115 * @throws IllegalArgumentException If nextPhase is null, or if the view status of the phases don't match. 116 * @throws IllegalStateException If the nextPhase has been set to a non-null value already. 117 */ 118 void setNextPhase(ViewLifecyclePhase nextPhase); 119 120 /** 121 * Sets the predecessor, for notification during processing. 122 * 123 * @param phase predecessor phase 124 */ 125 void setPredecessor(ViewLifecyclePhase phase); 126 127 /** 128 * Sets the refresh paths for this phase. 129 * 130 * @param refreshPaths list of refresh paths. 131 */ 132 void setRefreshPaths(List<String> refreshPaths); 133 134 /** 135 * During a component refresh, returns the list of view paths the lifecycle phase will be processed on. 136 * 137 * @return list of view paths 138 */ 139 List<String> getRefreshPaths(); 140 141 /** 142 * Determines of there are any pending successors of this phase. 143 * 144 * @return True if there are pending successors, false if no successors are pending. 145 */ 146 boolean hasPendingSuccessors(); 147 148 /** 149 * Remove a pending successor by path. 150 * 151 * @param parentPath path 152 */ 153 void removePendingSuccessor(String parentPath); 154 155 /** 156 * Invoked by the processor when this phase and all successors have completely processed. 157 */ 158 void notifyCompleted(); 159 160 /** 161 * Prepares this phase instance for recycled use. 162 */ 163 void recycle(); 164 165 }