WindowStateAdapter.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 griffon.pivot.support.adapters;
017 
018 import griffon.core.CallableWithArgs;
019 import org.apache.pivot.util.Vote;
020 
021 /**
022  @author Andres Almiray
023  @since 2.0.0
024  */
025 public class WindowStateAdapter implements GriffonPivotAdapter, org.apache.pivot.wtk.WindowStateListener {
026     private CallableWithArgs<Vote> previewWindowOpen;
027     private CallableWithArgs<Void> windowOpenVetoed;
028     private CallableWithArgs<Vote> previewWindowClose;
029     private CallableWithArgs<Void> windowCloseVetoed;
030     private CallableWithArgs<Void> windowOpened;
031     private CallableWithArgs<Void> windowClosed;
032 
033     public CallableWithArgs<Vote> getPreviewWindowOpen() {
034         return this.previewWindowOpen;
035     }
036 
037     public CallableWithArgs<Void> getWindowOpenVetoed() {
038         return this.windowOpenVetoed;
039     }
040 
041     public CallableWithArgs<Vote> getPreviewWindowClose() {
042         return this.previewWindowClose;
043     }
044 
045     public CallableWithArgs<Void> getWindowCloseVetoed() {
046         return this.windowCloseVetoed;
047     }
048 
049     public CallableWithArgs<Void> getWindowOpened() {
050         return this.windowOpened;
051     }
052 
053     public CallableWithArgs<Void> getWindowClosed() {
054         return this.windowClosed;
055     }
056 
057 
058     public void setPreviewWindowOpen(CallableWithArgs<Vote> previewWindowOpen) {
059         this.previewWindowOpen = previewWindowOpen;
060     }
061 
062     public void setWindowOpenVetoed(CallableWithArgs<Void> windowOpenVetoed) {
063         this.windowOpenVetoed = windowOpenVetoed;
064     }
065 
066     public void setPreviewWindowClose(CallableWithArgs<Vote> previewWindowClose) {
067         this.previewWindowClose = previewWindowClose;
068     }
069 
070     public void setWindowCloseVetoed(CallableWithArgs<Void> windowCloseVetoed) {
071         this.windowCloseVetoed = windowCloseVetoed;
072     }
073 
074     public void setWindowOpened(CallableWithArgs<Void> windowOpened) {
075         this.windowOpened = windowOpened;
076     }
077 
078     public void setWindowClosed(CallableWithArgs<Void> windowClosed) {
079         this.windowClosed = windowClosed;
080     }
081 
082 
083     public org.apache.pivot.util.Vote previewWindowOpen(org.apache.pivot.wtk.Window arg0) {
084         if (previewWindowOpen != null) {
085             return previewWindowOpen.call(arg0);
086         }
087         return Vote.APPROVE;
088     }
089 
090     public void windowOpenVetoed(org.apache.pivot.wtk.Window arg0, org.apache.pivot.util.Vote arg1) {
091         if (windowOpenVetoed != null) {
092             windowOpenVetoed.call(arg0, arg1);
093         }
094     }
095 
096     public org.apache.pivot.util.Vote previewWindowClose(org.apache.pivot.wtk.Window arg0) {
097         if (previewWindowClose != null) {
098             return previewWindowClose.call(arg0);
099         }
100         return Vote.APPROVE;
101     }
102 
103     public void windowCloseVetoed(org.apache.pivot.wtk.Window arg0, org.apache.pivot.util.Vote arg1) {
104         if (windowCloseVetoed != null) {
105             windowCloseVetoed.call(arg0, arg1);
106         }
107     }
108 
109     public void windowOpened(org.apache.pivot.wtk.Window arg0) {
110         if (windowOpened != null) {
111             windowOpened.call(arg0);
112         }
113     }
114 
115     public void windowClosed(org.apache.pivot.wtk.Window arg0, org.apache.pivot.wtk.Display arg1, org.apache.pivot.wtk.Window arg2) {
116         if (windowClosed != null) {
117             windowClosed.call(arg0, arg1, arg2);
118         }
119     }
120 
121 }