001    /*
002     * Copyright 2002-2008 the original author or authors.
003     * 
004     * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005     * use this file except in compliance with the License. You may obtain a copy of
006     * 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, WITHOUT
012     * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013     * License for the specific language governing permissions and limitations under
014     * the License.
015     */
016    package org.springframework.richclient.application;
017    
018    import java.util.List;
019    
020    import org.springframework.richclient.factory.ControlFactory;
021    
022    /**
023     * An <code>ApplicationPage</code> is a container for <code>PageComponent</code> s.
024     */
025    public interface ApplicationPage extends ControlFactory {
026        String getId();
027    
028        ApplicationWindow getWindow();
029    
030        void addPageComponentListener(PageComponentListener listener);
031    
032        void removePageComponentListener(PageComponentListener listener);
033    
034        PageComponent getActiveComponent();
035    
036        void setActiveComponent(PageComponent pageComponent);
037    
038        /**
039         * Shows the {@link View} with the given id.
040         * <p>
041         * If the {@link View} is already opened, the view will be reused.
042         * <p>
043         * NOTE: this is NOT the same as calling <code>this.showView(id, null)</code>.
044         * 
045         * @param id
046         *            the view id, cannot be empty
047         * 
048         * @return the {@link View} that is shown
049         */
050        View showView(String id);
051    
052        /**
053         * Shows the {@link View} with the given id, and passes the input to the {@link View}, by calling
054         * {@link View#setInput(Object)}.
055         * <p>
056         * If the {@link View} is already opened, the view will be reused.
057         * 
058         * @param id
059         *            the view id, cannot be empty
060         * @param input
061         *            the input, can be <code>null</code>
062         * 
063         * @return the {@link View} that is shown
064         */
065        View showView(String id, Object input);
066    
067        /**
068         * Returns the {@link View} with the given id. Returns <code>null</code> if no {@link View} with the given id is
069         * shown.
070         * <p>
071         * This method is "generified" to avoid extra casts when calling this method:
072         * 
073         * <pre>
074         * ApplicationPage page = ...; // get a reference to the ApplicationPage
075         * InitialView initialView = page.getView(&quot;initialView&quot;);
076         * </pre>
077         * 
078         * @param id
079         *            the id, cannot be <code>null</code>
080         * @return the {@link View}, or <code>null</code>
081         */
082        <T extends View> T getView(String id);
083    
084        void openEditor(Object editorInput);
085    
086        boolean closeAllEditors();
087    
088        boolean close();
089    
090        boolean close(PageComponent pageComponent);
091    
092        /**
093         * Returns the list of {@link PageComponent}s on this {@link ApplicationPage}.
094         * 
095         * @return the page components
096         */
097        public List<PageComponent> getPageComponents();
098    
099    }