NoopWindowManager.java
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 org.codehaus.griffon.runtime.core.view;
017 
018 import griffon.core.GriffonApplication;
019 import griffon.core.view.WindowManager;
020 
021 import javax.annotation.Nonnull;
022 import javax.annotation.Nullable;
023 import javax.inject.Inject;
024 import java.util.Collection;
025 import java.util.Collections;
026 
027 import static java.util.Objects.requireNonNull;
028 
029 /**
030  @author Andres Almiray
031  @since 2.0.0
032  */
033 public final class NoopWindowManager implements WindowManager<Object> {
034     private final GriffonApplication application;
035 
036     @Inject
037     public NoopWindowManager(@Nonnull GriffonApplication application) {
038         this.application = requireNonNull(application, "Argument 'application' must not be null");
039     }
040 
041     @Nullable
042     @Override
043     public Object findWindow(@Nonnull String name) {
044         return null;
045     }
046 
047     @Nullable
048     @Override
049     public Object getAt(int index) {
050         return null;
051     }
052 
053     @Nullable
054     @Override
055     public Object getStartingWindow() {
056         return null;
057     }
058 
059     @Nonnull
060     @Override
061     public Collection<Object> getWindows() {
062         return Collections.emptyList();
063     }
064 
065     @Override
066     public void attach(@Nonnull String name, @Nonnull Object window) {
067     }
068 
069     @Override
070     public void detach(@Nonnull String name) {
071     }
072 
073     @Override
074     public void show(@Nonnull Object window) {
075     }
076 
077     @Override
078     public void show(@Nonnull String name) {
079     }
080 
081     @Override
082     public void hide(@Nonnull Object window) {
083     }
084 
085     @Override
086     public void hide(@Nonnull String name) {
087     }
088 
089     @Override
090     public boolean canShutdown(@Nonnull GriffonApplication app) {
091         return true;
092     }
093 
094     @Override
095     public void onShutdown(@Nonnull GriffonApplication app) {
096     }
097 
098     @Override
099     public int countVisibleWindows() {
100         return 0;
101     }
102 
103     @Override
104     public boolean isAutoShutdown() {
105         return application.getConfiguration().getAsBoolean("application.autoShutdown"true);
106     }
107 }