| 
001 /*002  * Copyright 2008-2015 the original author or authors.
 003  *
 004  * Licensed under the Apache License, Version 2.0 (the "License");
 005  * you may not use this file except in compliance with the License.
 006  * You may obtain a copy of the License at
 007  *
 008  *     http://www.apache.org/licenses/LICENSE-2.0
 009  *
 010  * Unless required by applicable law or agreed to in writing, software
 011  * distributed under the License is distributed on an "AS IS" BASIS,
 012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 013  * See the License for the specific language governing permissions and
 014  * limitations under the License.
 015  */
 016 package griffon.core.controller;
 017
 018 import griffon.core.artifact.GriffonController;
 019
 020 import javax.annotation.Nonnull;
 021 import javax.annotation.Nullable;
 022 import java.util.Map;
 023
 024 /**
 025  * @author Andres Almiray
 026  * @since 2.0.0
 027  */
 028 public interface ActionManager {
 029     String ACTION = "Action";
 030
 031     @Nonnull
 032     Map<String, Action> actionsFor(@Nonnull GriffonController controller);
 033
 034     @Nullable
 035     Action actionFor(@Nonnull GriffonController controller, @Nonnull String actionName);
 036
 037     void createActions(@Nonnull GriffonController controller);
 038
 039     @Nonnull
 040     String normalizeName(@Nonnull String actionName);
 041
 042     /**
 043      * Updates all actions currently configured.
 044      *
 045      * @since 2.1.0
 046      */
 047     void updateActions();
 048
 049     /**
 050      * Updates all actions belonging to the supplied controller.
 051      *
 052      * @param controller the controller that owns the actions to be updated.
 053      * @since 2.1.0
 054      */
 055     void updateActions(@Nonnull GriffonController controller);
 056
 057     /**
 058      * Update the action's properties using registered {@code ActionHandler}s.
 059      *
 060      * @param action the action to be updated
 061      * @since 2.1.0
 062      */
 063     void updateAction(@Nonnull Action action);
 064
 065     /**
 066      * Update the action's properties using registered {@code ActionHandler}s.
 067      *
 068      * @param controller the controller that owns the action
 069      * @param actionName the action's name
 070      * @since 2.1.0
 071      */
 072     void updateAction(@Nonnull GriffonController controller, @Nonnull String actionName);
 073
 074     /**
 075      * Execute the action using registered {@code ActionHandler}s.
 076      *
 077      * @param controller the controller that owns the action
 078      * @param actionName the action's name
 079      * @param args       additional arguments to be sent to the action
 080      */
 081     void invokeAction(@Nonnull GriffonController controller, @Nonnull String actionName, Object... args);
 082
 083     /**
 084      * Execute the action using registered {@code ActionHandler}s.
 085      *
 086      * @param action the action to be invoked
 087      * @param args   additional arguments to be sent to the action
 088      * @since 2.1.0
 089      */
 090     void invokeAction(@Nonnull Action action, @Nonnull Object... args);
 091
 092     /**
 093      * Register an {@code ActionHandler} with this instance.
 094      *
 095      * @param actionHandler the handler to be added to this ActionManager
 096      * @since 2.1.0
 097      */
 098     void addActionHandler(@Nonnull ActionHandler actionHandler);
 099
 100     /**
 101      * Register an {@code ActionInterceptor} with this instance.
 102      *
 103      * @param actionInterceptor the interceptor to be added to this ActionManager
 104      * @deprecated use {@code addActionHandler} instead.
 105      */
 106     @Deprecated
 107     void addActionInterceptor(@Nonnull ActionInterceptor actionInterceptor);
 108 }
 |