svn-document-layout / trunk / org.gvsig.app.document.layout2.app / org.gvsig.app.document.layout2.app.mainplugin / src / main / java / org / gvsig / layout / mapbox / panel / menu / InsertColumnMapBoxMenuEntry.java @ 1714
History | View | Annotate | Download (3.54 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 (CIT)
|
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., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.layout.mapbox.panel.menu; |
23 |
|
24 |
import java.util.List; |
25 |
import org.gvsig.andami.PluginServices; |
26 |
import org.gvsig.app.project.documents.layout.LayoutContext; |
27 |
import org.gvsig.app.project.documents.layout.contextmenu.gui.*; |
28 |
import org.gvsig.app.project.documents.layout.fframes.IFFrame; |
29 |
import org.gvsig.layout.mapbox.fframe.FFrameMapBox; |
30 |
import org.gvsig.layout.mapbox.model.Cell; |
31 |
import org.gvsig.tools.lang.CloneableUtils; |
32 |
|
33 |
/**
|
34 |
* Copia el FFrame seleccionado.
|
35 |
*
|
36 |
* @author gvSIG team
|
37 |
*/
|
38 |
public class InsertColumnMapBoxMenuEntry extends AbstractLayoutContextMenuAction { |
39 |
|
40 |
@Override
|
41 |
public String getGroup() { |
42 |
return "mapbox"; |
43 |
} |
44 |
|
45 |
@Override
|
46 |
public int getGroupOrder() { |
47 |
return 5; |
48 |
} |
49 |
|
50 |
@Override
|
51 |
public int getOrder() { |
52 |
return 4; |
53 |
} |
54 |
|
55 |
@Override
|
56 |
public String getText() { |
57 |
return PluginServices.getText(this, "_Insert_column"); |
58 |
} |
59 |
|
60 |
@Override
|
61 |
public boolean isEnabled(LayoutContext layoutContext, |
62 |
IFFrame[] selectedFrames) {
|
63 |
if (selectedFrames.length != 1) { |
64 |
return false; |
65 |
} |
66 |
for (IFFrame selectedFrame : selectedFrames) {
|
67 |
if (selectedFrame instanceof FFrameMapBox) { |
68 |
FFrameMapBox frame = (FFrameMapBox) selectedFrame; |
69 |
List<Cell> selectedCells = frame.getSelectedCells();
|
70 |
return selectedCells.size() == 1; |
71 |
} |
72 |
} |
73 |
return false; |
74 |
} |
75 |
|
76 |
@Override
|
77 |
public boolean isVisible(LayoutContext layoutContext, |
78 |
IFFrame[] selectedFrames) {
|
79 |
for (IFFrame selectedFrame : selectedFrames) {
|
80 |
if (selectedFrame instanceof FFrameMapBox) { |
81 |
return true; |
82 |
} |
83 |
} |
84 |
return false; |
85 |
} |
86 |
|
87 |
@Override
|
88 |
public void execute(LayoutContext layoutContext, IFFrame[] selectedFrames) { |
89 |
if (selectedFrames.length != 1) { |
90 |
return;
|
91 |
} |
92 |
IFFrame selectedFrame = selectedFrames[0];
|
93 |
|
94 |
if (selectedFrame instanceof FFrameMapBox) { |
95 |
FFrameMapBox frame = (FFrameMapBox) selectedFrame; |
96 |
if (frame.getSelectedCells().size() != 1) { |
97 |
return;
|
98 |
} |
99 |
FFrameMapBox newFrame = (FFrameMapBox) CloneableUtils.cloneQuietly(frame); |
100 |
List<Cell> selectedCells = newFrame.getSelectedCells();
|
101 |
|
102 |
if (selectedCells.size() == 1) { |
103 |
newFrame.getModel().insertColumn(selectedCells.get(0));
|
104 |
newFrame.getSelection().clear(); |
105 |
layoutContext.fullRefresh(); |
106 |
layoutContext.getFrameCommandsRecord().update(frame, newFrame); |
107 |
layoutContext.updateFFrames(); |
108 |
} |
109 |
} |
110 |
} |
111 |
} |