svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.geometrymeasurement.app / org.gvsig.geometrymeasurement.app.mainplugin / src / main / java / org / gvsig / geometrymeasurement / app / extension / PerimeterMeasurementExtension.java @ 44868
History | View | Annotate | Download (2.55 KB)
1 | 40557 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | 40435 | jjdelcerro | *
|
4 | 40557 | jjdelcerro | * Copyright (C) 2007-2013 gvSIG Association.
|
5 | 40435 | jjdelcerro | *
|
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 | 40557 | jjdelcerro | * as published by the Free Software Foundation; either version 3
|
9 | 40435 | jjdelcerro | * 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 | 40557 | jjdelcerro | * For any additional information, do not hesitate to contact us
|
22 | * at info AT gvsig.com, or visit our website www.gvsig.com.
|
||
23 | 40435 | jjdelcerro | */
|
24 | package org.gvsig.geometrymeasurement.app.extension; |
||
25 | |||
26 | import org.gvsig.andami.IconThemeHelper; |
||
27 | import org.gvsig.app.project.documents.table.TableDocument; |
||
28 | 44616 | omartinez | import org.gvsig.fmap.dal.DataStoreProviderFactory; |
29 | 40435 | jjdelcerro | import org.gvsig.fmap.dal.feature.FeatureStore; |
30 | 44616 | omartinez | import org.gvsig.fmap.dal.feature.FeatureStoreProviderFactory; |
31 | 40435 | jjdelcerro | import org.gvsig.fmap.geom.Geometry; |
32 | import org.gvsig.geometrymeasurement.app.extension.utils.Operations; |
||
33 | |||
34 | /**
|
||
35 | * Andami extension to show PerimeterMeasurementExtension in the application.
|
||
36 | 44616 | omartinez | *
|
37 | 40435 | jjdelcerro | * @author gvSIG Team
|
38 | * @version $Id$
|
||
39 | */
|
||
40 | public class PerimeterMeasurementExtension extends |
||
41 | 44616 | omartinez | AbstractGeometryMeasurementExtension { |
42 | 40435 | jjdelcerro | |
43 | 44616 | omartinez | @Override
|
44 | 40435 | jjdelcerro | public void initialize() { |
45 | 44616 | omartinez | super.initialize();
|
46 | 40435 | jjdelcerro | IconThemeHelper.registerIcon("action", "table-add-perimeter", this); |
47 | } |
||
48 | |||
49 | @Override
|
||
50 | protected void execute(String actionCommand, FeatureStore featureStore) |
||
51 | 44616 | omartinez | throws Exception { |
52 | 40435 | jjdelcerro | new Operations().addDoubleFieldFromOperation(featureStore, "PERIMETER", |
53 | 44616 | omartinez | "perimeter");
|
54 | 40435 | jjdelcerro | } |
55 | |||
56 | @Override
|
||
57 | protected boolean isVisibleForTable(TableDocument tableDocument) { |
||
58 | 44616 | omartinez | DataStoreProviderFactory factory = tableDocument.getFeatureStore().getProviderFactory(); |
59 | if (factory instanceof FeatureStoreProviderFactory) { |
||
60 | FeatureStoreProviderFactory ffactory = (FeatureStoreProviderFactory) factory; |
||
61 | if (ffactory.allowEditableFeatureType() == FeatureStoreProviderFactory.NO) {
|
||
62 | return false; |
||
63 | } |
||
64 | } |
||
65 | return !isStoreOfAnyType(tableDocument, new int[]{Geometry.TYPES.POINT, |
||
66 | 40435 | jjdelcerro | Geometry.TYPES.MULTIPOINT}); |
67 | } |
||
68 | |||
69 | } |