Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.framework / org.gvsig.andami / src / main / java / org / gvsig / andami / plugins / Extension.java @ 42784

History | View | Annotate | Download (3.25 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 java.util.Map;
27

    
28
import org.gvsig.andami.PluginServices;
29
import org.gvsig.andami.PluginsLocator;
30
import org.gvsig.andami.plugins.status.IExtensionStatus;
31
import org.slf4j.Logger;
32
import org.slf4j.LoggerFactory;
33

    
34
/**
35
 * Extensions are the way in which plugins extend Andami. Extensions
36
 * can add controls to user interface (GUI) and execute some code
37
 * when controls are activated. Every class implementing
38
 * {@link IExtension} is an extension, but directly implementing
39
 * that interface is discouraged. The preferred way to create
40
 * an extension is extending this absctract class.
41
 *
42
 * @see IExtension
43
 *
44
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
45
 */
46
public abstract class Extension implements IExtension, IExtensionQueryByAction, IExtensionExecuteWithArgs  {
47

    
48
        private static Logger logger = LoggerFactory.getLogger(Extension.class);
49

    
50
        private PluginServices plugin = null;
51

    
52
        /*
53
         *  (non-Javadoc)
54
         * @see com.iver.andami.plugins.IExtension#terminate()
55
         */
56
        public void terminate(){
57

    
58
        }
59
        /*
60
         *  (non-Javadoc)
61
         * @see com.iver.andami.plugins.IExtension#postInitialize()
62
         */
63
        public void postInitialize(){
64

    
65
        }
66

    
67
    /*
68
         *  (non-Javadoc)
69
         * @see com.iver.andami.plugins.IExtension#getStatus()
70
         */
71
    public IExtensionStatus getStatus() {
72
            return null;
73
    }
74

    
75
        /*
76
         *  (non-Javadoc)
77
         * @see com.iver.andami.plugins.IExtension#getStatus(IExtension extension)
78
         */
79
        public IExtensionStatus getStatus(IExtension extension) {
80
                return extension.getStatus();
81
        }
82

    
83
        public String getText(String msg) {
84
            return PluginsLocator.getManager().getText(this, msg);
85
        }
86

    
87
        public void setPlugin(PluginServices plugin) {
88
                if (this.plugin != null){
89
                        throw new IllegalStateException();
90
                }
91
                this.plugin = plugin;
92
        }
93

    
94
        public PluginServices getPlugin() {
95
                if (this.plugin == null){
96
                        return PluginsLocator.getManager().getPlugin(this.getClass());
97
                }
98
                return this.plugin;
99
        }
100

    
101
        public boolean isEnabled(String action) {
102
                return isEnabled();
103
        }
104

    
105
        public boolean isVisible(String action) {
106
                return isVisible();
107
        }
108

    
109
        public boolean canQueryByAction() {
110
                return false;
111
        }
112

    
113
        public void execute(String command, Object[] args) {
114
                if( args!= null && args.length>0 ) {
115
                        logger.info("calling execute with args in a extension that not support ("+this.getClass().getSimpleName()+").");
116
                }
117
                execute(command);
118
        }
119

    
120
}
121