WindowStateAdapter.java
001 /*
002  * SPDX-License-Identifier: Apache-2.0
003  *
004  * Copyright 2008-2017 the original author or authors.
005  *
006  * Licensed under the Apache License, Version 2.0 (the "License");
007  * you may not use this file except in compliance with the License.
008  * You may obtain a copy of the License at
009  *
010  *     http://www.apache.org/licenses/LICENSE-2.0
011  *
012  * Unless required by applicable law or agreed to in writing, software
013  * distributed under the License is distributed on an "AS IS" BASIS,
014  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015  * See the License for the specific language governing permissions and
016  * limitations under the License.
017  */
018 package griffon.pivot.support.adapters;
019 
020 import griffon.core.CallableWithArgs;
021 import org.apache.pivot.util.Vote;
022 
023 /**
024  @author Andres Almiray
025  @since 2.0.0
026  */
027 public class WindowStateAdapter implements GriffonPivotAdapter, org.apache.pivot.wtk.WindowStateListener {
028     private CallableWithArgs<Vote> previewWindowOpen;
029     private CallableWithArgs<Void> windowOpenVetoed;
030     private CallableWithArgs<Vote> previewWindowClose;
031     private CallableWithArgs<Void> windowCloseVetoed;
032     private CallableWithArgs<Void> windowOpened;
033     private CallableWithArgs<Void> windowClosed;
034 
035     public CallableWithArgs<Vote> getPreviewWindowOpen() {
036         return this.previewWindowOpen;
037     }
038 
039     public CallableWithArgs<Void> getWindowOpenVetoed() {
040         return this.windowOpenVetoed;
041     }
042 
043     public CallableWithArgs<Vote> getPreviewWindowClose() {
044         return this.previewWindowClose;
045     }
046 
047     public CallableWithArgs<Void> getWindowCloseVetoed() {
048         return this.windowCloseVetoed;
049     }
050 
051     public CallableWithArgs<Void> getWindowOpened() {
052         return this.windowOpened;
053     }
054 
055     public CallableWithArgs<Void> getWindowClosed() {
056         return this.windowClosed;
057     }
058 
059 
060     public void setPreviewWindowOpen(CallableWithArgs<Vote> previewWindowOpen) {
061         this.previewWindowOpen = previewWindowOpen;
062     }
063 
064     public void setWindowOpenVetoed(CallableWithArgs<Void> windowOpenVetoed) {
065         this.windowOpenVetoed = windowOpenVetoed;
066     }
067 
068     public void setPreviewWindowClose(CallableWithArgs<Vote> previewWindowClose) {
069         this.previewWindowClose = previewWindowClose;
070     }
071 
072     public void setWindowCloseVetoed(CallableWithArgs<Void> windowCloseVetoed) {
073         this.windowCloseVetoed = windowCloseVetoed;
074     }
075 
076     public void setWindowOpened(CallableWithArgs<Void> windowOpened) {
077         this.windowOpened = windowOpened;
078     }
079 
080     public void setWindowClosed(CallableWithArgs<Void> windowClosed) {
081         this.windowClosed = windowClosed;
082     }
083 
084 
085     public org.apache.pivot.util.Vote previewWindowOpen(org.apache.pivot.wtk.Window arg0) {
086         if (previewWindowOpen != null) {
087             return previewWindowOpen.call(arg0);
088         }
089         return Vote.APPROVE;
090     }
091 
092     public void windowOpenVetoed(org.apache.pivot.wtk.Window arg0, org.apache.pivot.util.Vote arg1) {
093         if (windowOpenVetoed != null) {
094             windowOpenVetoed.call(arg0, arg1);
095         }
096     }
097 
098     public org.apache.pivot.util.Vote previewWindowClose(org.apache.pivot.wtk.Window arg0) {
099         if (previewWindowClose != null) {
100             return previewWindowClose.call(arg0);
101         }
102         return Vote.APPROVE;
103     }
104 
105     public void windowCloseVetoed(org.apache.pivot.wtk.Window arg0, org.apache.pivot.util.Vote arg1) {
106         if (windowCloseVetoed != null) {
107             windowCloseVetoed.call(arg0, arg1);
108         }
109     }
110 
111     public void windowOpened(org.apache.pivot.wtk.Window arg0) {
112         if (windowOpened != null) {
113             windowOpened.call(arg0);
114         }
115     }
116 
117     public void windowClosed(org.apache.pivot.wtk.Window arg0, org.apache.pivot.wtk.Display arg1, org.apache.pivot.wtk.Window arg2) {
118         if (windowClosed != null) {
119             windowClosed.call(arg0, arg1, arg2);
120         }
121     }
122 
123 }