svn-gvsig-desktop / trunk / applications / appgvSIG / src / org / gvsig / fmap / swing / toc / action / TOCActionFactoryAdapter.java @ 37876
History | View | Annotate | Download (2.74 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government.
|
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 2
|
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., 59 Temple Place - Suite 330,
|
19 |
* Boston, MA 02111-1307, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.fmap.swing.toc.action; |
23 |
|
24 |
import com.iver.cit.gvsig.project.documents.IContextMenuAction; |
25 |
|
26 |
import org.gvsig.fmap.swing.toc.TOC; |
27 |
import org.gvsig.tools.ToolsLocator; |
28 |
import org.gvsig.tools.dynobject.DynObject; |
29 |
import org.gvsig.tools.service.Service; |
30 |
import org.gvsig.tools.service.ServiceException; |
31 |
import org.gvsig.tools.service.spi.ServiceManager; |
32 |
|
33 |
/**
|
34 |
* Utility class to wrap the old style menu actions in a {@link TOCActionFactory}
|
35 |
*
|
36 |
* @author Juan Lucas Dominguez jldominguez prodevelop es
|
37 |
* @version $Id: TOCActionFactoryAdapter.java 37876 2012-02-07 15:12:49Z fpenarrubia $
|
38 |
*
|
39 |
*/
|
40 |
public class TOCActionFactoryAdapter implements TOCActionFactory { |
41 |
|
42 |
private IContextMenuAction icma = null; |
43 |
private String name = null; |
44 |
|
45 |
public static final String DYN_CLASS_NAME = |
46 |
TOCActionFactoryAdapter.class.getName() + "_DynClass";
|
47 |
|
48 |
/**
|
49 |
* Constructor needs the old style menu action
|
50 |
*
|
51 |
* @param _icma
|
52 |
*/
|
53 |
public TOCActionFactoryAdapter(IContextMenuAction _icma) {
|
54 |
icma = _icma; |
55 |
} |
56 |
|
57 |
public Service create(DynObject pars, ServiceManager paramServiceManager)
|
58 |
throws ServiceException {
|
59 |
|
60 |
TOC toc = null;
|
61 |
try {
|
62 |
toc = (TOC) pars.getDynValue(TOCActionFactory.TOC_PARAMETER_KEY); |
63 |
} catch (Exception ex) { |
64 |
throw new ServiceException(ex.getMessage(), "", -1); |
65 |
} |
66 |
return new TOCActionAdapter(icma, toc); |
67 |
} |
68 |
|
69 |
public DynObject createParameters() {
|
70 |
return ToolsLocator.getDynObjectManager().createDynObject(
|
71 |
DYN_CLASS_NAME); |
72 |
} |
73 |
|
74 |
public String getName() { |
75 |
if (name == null) { |
76 |
name = icma.getClass().getName() + "_TOCActionFactoryAdapter";
|
77 |
} |
78 |
return name;
|
79 |
} |
80 |
|
81 |
/**
|
82 |
* Useful to register OldTocMenuEntry wrappers.
|
83 |
* @param name
|
84 |
*/
|
85 |
public void setName(String name) { |
86 |
this.name = name + "_TOCActionFactoryAdapter"; |
87 |
} |
88 |
|
89 |
public void initialize() { |
90 |
} |
91 |
|
92 |
} |