Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.file / org.gvsig.fmap.dal.file.lib / src / main / java / org / gvsig / fmap / dal / serverexplorer / filesystem / FilesystemServerExplorerParameters.java @ 46338

History | View | Annotate | Download (3.37 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.fmap.dal.serverexplorer.filesystem;
25

    
26
import org.apache.commons.lang3.StringUtils;
27
import org.gvsig.fmap.dal.DataServerExplorerParameters;
28
import org.gvsig.fmap.dal.DataTypes;
29
import org.gvsig.fmap.dal.spi.AbstractDataParameters;
30
import org.gvsig.tools.ToolsLocator;
31
import org.gvsig.tools.dynobject.DelegatedDynObject;
32
import org.gvsig.tools.dynobject.DynClass;
33
import org.gvsig.tools.dynobject.DynField;
34
import org.gvsig.tools.dynobject.DynObjectManager;
35

    
36
public class FilesystemServerExplorerParameters extends AbstractDataParameters
37
                implements DataServerExplorerParameters {
38

    
39
    public static final String DYNCLASS_NAME = "FilesystemServerExplorerParameters";
40

    
41
    private static final String FIELD_ROOT = "root";
42

    
43
        private DelegatedDynObject delegatedDynObject;
44

    
45
        public FilesystemServerExplorerParameters() {
46
                this.delegatedDynObject = (DelegatedDynObject) ToolsLocator
47
                                .getDynObjectManager()
48
                                .createDynObject(this.registerDynClass());
49
        }
50

    
51
        private DynClass registerDynClass() {
52
                   DynObjectManager dynman = ToolsLocator.getDynObjectManager();
53
            DynClass dynClass = dynman.get(DYNCLASS_NAME);
54
            DynField field;
55
            if (dynClass == null) {
56
                    dynClass = dynman.add(DYNCLASS_NAME);
57

    
58
                    field = dynClass.addDynField(FIELD_ROOT);
59
                    field.setType(DataTypes.STRING);
60
                    field.setDescription("Root directory path of the explorer");
61
                    field.setTheTypeOfAvailableValues(DynField.ANY);
62

    
63

    
64
                    field = dynClass.addDynField("initialpath");
65
                        field.setType(DataTypes.STRING);
66
                        field.setDescription("Initial path of the explorer");
67
                        field.setTheTypeOfAvailableValues(DynField.ANY);
68

    
69
            }
70
            return dynClass;
71
        }
72

    
73
        public void setRoot(String path) {
74
                this.setDynValue(FIELD_ROOT, path);
75
        }
76

    
77
        public String getRoot() {
78
                return (String) this.getDynValue(FIELD_ROOT);
79
        }
80

    
81
        public void setInitialpath(String path) {
82
                this.setDynValue("initialpath", path);
83
        }
84

    
85
        public String getInitialpath() {
86
                return (String) this.getDynValue("initialpath");
87
        }
88

    
89
        public String getExplorerName() {
90
                return FilesystemServerExplorer.NAME;
91
        }
92

    
93
        protected DelegatedDynObject getDelegatedDynObject() {
94
                return delegatedDynObject;
95
        }
96

    
97
    @Override
98
    public boolean isTheSameServerExplorer(DataServerExplorerParameters params) {
99
        if(!(params instanceof FilesystemServerExplorerParameters)){
100
            return false;
101
        }
102
        return StringUtils.equals(this.getRoot(), ((FilesystemServerExplorerParameters)params).getRoot());
103
    }
104
}