Statistics
| Revision:

root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / view / toc / actions / FLyrVectEditPropertiesTocMenuEntry.java @ 7738

History | View | Annotate | Download (4.67 KB)

1
package com.iver.cit.gvsig.project.documents.view.toc.actions;
2

    
3
import javax.swing.JDialog;
4

    
5
import com.iver.andami.PluginServices;
6
import com.iver.cit.gvsig.fmap.layers.FLayer;
7
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
8
import com.iver.cit.gvsig.fmap.layers.layerOperations.ClassifiableVectorial;
9
import com.iver.cit.gvsig.project.documents.view.legend.gui.FThemeManagerWindow;
10
import com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction;
11
import com.iver.cit.gvsig.project.documents.view.toc.ITocItem;
12
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
13
 *
14
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
15
 *
16
 * This program is free software; you can redistribute it and/or
17
 * modify it under the terms of the GNU General Public License
18
 * as published by the Free Software Foundation; either version 2
19
 * of the License, or (at your option) any later version.
20
 *
21
 * This program is distributed in the hope that it will be useful,
22
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
 * GNU General Public License for more details.
25
 *
26
 * You should have received a copy of the GNU General Public License
27
 * along with this program; if not, write to the Free Software
28
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
29
 *
30
 * For more information, contact:
31
 *
32
 *  Generalitat Valenciana
33
 *   Conselleria d'Infraestructures i Transport
34
 *   Av. Blasco Ib??ez, 50
35
 *   46010 VALENCIA
36
 *   SPAIN
37
 *
38
 *      +34 963862235
39
 *   gvsig@gva.es
40
 *      www.gvsig.gva.es
41
 *
42
 *    or
43
 *
44
 *   IVER T.I. S.A
45
 *   Salamanca 50
46
 *   46005 Valencia
47
 *   Spain
48
 *
49
 *   +34 963163400
50
 *   dac@iver.es
51
 */
52
/* CVS MESSAGES:
53
 *
54
 * $Id: FLyrVectEditPropertiesTocMenuEntry.java 7738 2006-10-02 13:52:34Z jaume $
55
 * $Log$
56
 * Revision 1.2  2006-10-02 13:52:34  jaume
57
 * organize impots
58
 *
59
 * Revision 1.1  2006/09/15 10:41:30  caballero
60
 * extensibilidad de documentos
61
 *
62
 * Revision 1.1  2006/09/12 15:58:14  jorpiell
63
 * "Sacadas" las opcines del men? de FPopupMenu
64
 *
65
 *
66
 */
67
/**
68
 * Muestra el men? de propiedades del tema.
69
 *
70
 * @author jmorell
71
 */
72

    
73

    
74
public class FLyrVectEditPropertiesTocMenuEntry extends AbstractTocContextMenuAction {
75
        public String getGroup() {
76
                return "group2"; //FIXME
77
        }
78

    
79
        public int getGroupOrder() {
80
                return 20;
81
        }
82

    
83
        public int getOrder() {
84
                return 0;
85
        }
86

    
87
        public String getText() {
88
                return PluginServices.getText(this, "propiedades");
89
        }
90

    
91
        public boolean isEnabled(ITocItem item, FLayer[] selectedItems) {
92
                return selectedItems.length == 1;
93
        }
94

    
95
        public boolean isVisible(ITocItem item, FLayer[] selectedItems) {
96
                if (isTocItemBranch(item)) {
97
                        FLayer lyr = getNodeLayer(item);
98
            if ((lyr instanceof ClassifiableVectorial)) {
99
                    if (!((lyr instanceof FLyrVect) &&
100
                                    !((FLyrVect)lyr).isPropertiesMenuVisible())){
101
                            return true;
102
                    }
103

    
104
            }
105
                }
106
                return false;
107

    
108
        }
109

    
110

    
111
        public void execute(ITocItem item, FLayer[] selectedItems) {
112
                FLayer[] actives = selectedItems;
113
                FThemeManagerWindow fThemeManagerWindow;
114
            if (actives.length==1) {
115
                    if (!actives[0].isAvailable()) return;
116
                    System.out.println("openPliegoThemeProperties(): Una sola capa. Abrimos el panel para la capa " + actives[0]);
117
                    fThemeManagerWindow = new FThemeManagerWindow();
118
                    try {
119
                            fThemeManagerWindow.setMapContext(getMapContext());
120
                    } catch (com.iver.cit.gvsig.fmap.DriverException e1) {
121
                            e1.printStackTrace();
122
                    }
123
            //PluginServices.getMDIManager().addView(fThemeManagerWindow);
124
                    if (PluginServices.getMainFrame() == null) {
125
                            JDialog dlg = new JDialog();
126
                            fThemeManagerWindow.setPreferredSize(fThemeManagerWindow.getSize());
127
                            dlg.getContentPane().add(fThemeManagerWindow);
128
                            dlg.setModal(false);
129
                            dlg.pack();
130
                            dlg.show();
131
                    } else {
132
                            PluginServices.getMDIManager().addWindow(fThemeManagerWindow);
133
                    }
134
            } else {
135
                for (int i = 0; i < actives.length; i++){
136
                        if (actives[0].isAvailable()) {
137
                                System.out.println("openPliegoThemeProperties(): Muchas capas. Abrimos el panel para la capa " + actives[i]);
138
                                fThemeManagerWindow = new FThemeManagerWindow(actives[i], getMapContext());
139
                                //PluginServices.getMDIManager().addView(fThemeManagerWindow);
140
                                if (PluginServices.getMainFrame() == null) {
141
                                        JDialog dlg = new JDialog();
142
                                        fThemeManagerWindow.setPreferredSize(fThemeManagerWindow.getSize());
143
                                        dlg.getContentPane().add(fThemeManagerWindow);
144
                                        dlg.setModal(false);
145
                                        dlg.pack();
146
                                        dlg.show();
147
                                } else {
148
                                        PluginServices.getMDIManager().addWindow(fThemeManagerWindow);
149
                                }
150
                        }
151
                }
152
            }
153
        }
154

    
155
}