MVCGroupManager.java
001 /*
002  * Copyright 2008-2014 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.mvc;
017 
018 import griffon.core.GriffonApplication;
019 import griffon.core.artifact.GriffonController;
020 import griffon.core.artifact.GriffonModel;
021 import griffon.core.artifact.GriffonView;
022 
023 import javax.annotation.Nonnull;
024 import javax.annotation.Nullable;
025 import java.util.Map;
026 
027 /**
028  * Manages the configuration and instantiation of MVC groups.
029  *
030  @author Andres Almiray
031  @since 2.0.0
032  */
033 public interface MVCGroupManager extends MVCHandler {
034     /**
035      * Creates an MVCConfiguration instance with the given arguments.
036      *
037      @param mvcType the name of the MVC group
038      @param members members of the group
039      @param config  additional configuration required by the group
040      @return a ready-to-use MVCGroupConfiguration instance
041      */
042     @Nonnull
043     MVCGroupConfiguration newMVCGroupConfiguration(@Nonnull String mvcType, @Nonnull Map<String, String> members, @Nonnull Map<String, Object> config);
044 
045     /**
046      * Clones an existing MVCGroupConfiguration, optionally overriding additional config values.
047      *
048      @param mvcType the name of the configuration to clone
049      @param config  additional config parameters to be set on the configuration
050      @return a ready-to-use MVCGroupConfiguration instance
051      */
052     @Nonnull
053     MVCGroupConfiguration cloneMVCGroupConfiguration(@Nonnull String mvcType, @Nonnull Map<String, Object> config);
054 
055     /**
056      * Creates a new MVCGroup instance.
057      *
058      @param configuration the configuration of the group
059      @param mvcId         the id to use for the group
060      @param members       the instance members of the group
061      @return a ready-to-use MVCGroup instance
062      */
063     @Nonnull
064     MVCGroup newMVCGroup(@Nonnull MVCGroupConfiguration configuration, @Nullable String mvcId, @Nonnull Map<String, Object> members);
065 
066     /**
067      * Initializes this manager with the group configurations provided by the application and addons.
068      *
069      @param configurations available group configurations
070      */
071     void initialize(@Nonnull Map<String, MVCGroupConfiguration> configurations);
072 
073     void addConfiguration(@Nonnull MVCGroupConfiguration configuration);
074 
075     void removeConfiguration(@Nonnull MVCGroupConfiguration configuration);
076 
077     void removeConfiguration(@Nonnull String name);
078 
079     @Nonnull
080     Map<String, MVCGroupConfiguration> getConfigurations();
081 
082     @Nonnull
083     Map<String, MVCGroup> getGroups();
084 
085     @Nonnull
086     MVCGroupConfiguration findConfiguration(@Nonnull String mvcType);
087 
088     @Nullable
089     MVCGroup findGroup(@Nonnull String mvcId);
090 
091     @Nullable
092     MVCGroup getAt(@Nonnull String mvcId);
093 
094     /**
095      * Returns all currently available model instances, keyed by group name.<p>
096      *
097      @return a Map of all currently instantiated models.
098      */
099     @Nonnull
100     Map<String, ? extends GriffonModel> getModels();
101 
102     /**
103      * Returns all currently available view instances, keyed by group name.<p>
104      *
105      @return a Map of all currently instantiated views.
106      */
107     @Nonnull
108     Map<String, ? extends GriffonView> getViews();
109 
110     /**
111      * Returns all currently available controller instances, keyed by group name.<p>
112      *
113      @return a Map of all currently instantiated controllers.
114      */
115     @Nonnull
116     Map<String, ? extends GriffonController> getControllers();
117 
118     GriffonApplication getApplication();
119 }