Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.framework / org.gvsig.andami / src / main / java / org / gvsig / andami / plugins / ExtensionDecorator.java @ 40596

History | View | Annotate | Download (2.82 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.andami.plugins;
25

    
26
import org.gvsig.andami.plugins.status.IExtensionStatus;
27
import org.gvsig.andami.ui.mdiFrame.MDIFrame;
28
import org.slf4j.Logger;
29
import org.slf4j.LoggerFactory;
30

    
31

    
32
/**
33
 * This class extends the functionality of Extension class to let the programmer
34
 * set an extension visible or not on-the-fly.
35
 *
36
 * @autor Jaume Dominguez Faus - jaume.dominguez@iver.es
37
 */
38
public class ExtensionDecorator implements HiddableExtension{
39
    private static Logger logger = LoggerFactory.getLogger(ExtensionDecorator.class);
40
        public static final int INACTIVE = 0;
41
        public static final int ALWAYS_VISIBLE = 1;
42
        public static final int ALWAYS_INVISIBLE = 2;
43
        int  alwaysVisible;
44
        IExtension extension;
45

    
46
        public ExtensionDecorator(IExtension e, int visibilityControl){
47
                setExtension(e);
48
                setVisibility(visibilityControl);
49
        }
50

    
51
        public void setExtension(IExtension e) {
52
                this.extension = e;
53
        }
54

    
55
        public void setVisibility(int state){
56
                this.alwaysVisible = state;
57
        }
58

    
59
        public int getVisibility(){
60
                return alwaysVisible;
61
        }
62

    
63
        public IExtension getExtension(){
64
                return extension;
65
        }
66

    
67
        public void initialize() {
68
                extension.initialize();
69
        }
70

    
71
        public void terminate(){
72
                //TODO
73
        }
74

    
75
        public void execute(String actionCommand) {
76
        logger.info("{}.execute('{}')", extension.getClass().getSimpleName(), actionCommand);
77
                extension.execute(actionCommand);
78
        }
79

    
80
        public boolean isEnabled() {
81
                return extension.isEnabled();
82
        }
83

    
84
        public boolean isVisible() {
85
                if (alwaysVisible == INACTIVE)
86
                        return extension.isVisible();
87
                else if (alwaysVisible == ALWAYS_VISIBLE) return true;
88
                else return false;
89
        }
90

    
91
        public void postInitialize() {
92
                // TODO
93
        }
94

    
95
        /* (non-Javadoc)
96
         * @see com.iver.andami.plugins.IExtension#getStatus()
97
         */
98
        public IExtensionStatus getStatus() {
99
                return extension.getStatus();
100
        }
101
        public IExtensionStatus getStatus(IExtension extension) {
102
                return this.extension.getStatus(extension);
103
        }
104
}