svn-document-layout / trunk / org.gvsig.app.document.layout2.app / org.gvsig.app.document.layout2.app.mainplugin / src / main / java / org / gvsig / app / extension / LayoutGraphicControls.java @ 1757
History | View | Annotate | Download (5.61 KB)
1 | 5 | jldominguez | /* 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.app.extension; |
||
23 | |||
24 | import org.slf4j.Logger; |
||
25 | import org.slf4j.LoggerFactory; |
||
26 | 24 | jldominguez | import org.gvsig.andami.IconThemeHelper; |
27 | 5 | jldominguez | import org.gvsig.andami.PluginServices; |
28 | import org.gvsig.andami.plugins.Extension; |
||
29 | import org.gvsig.andami.ui.mdiManager.IWindow; |
||
30 | import org.gvsig.app.project.documents.layout.FLayoutGraphics; |
||
31 | 250 | cmartinez | import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFrameDialogNotification; |
32 | 5 | jldominguez | import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
33 | 250 | cmartinez | import org.gvsig.tools.observer.Observable; |
34 | import org.gvsig.tools.observer.Observer; |
||
35 | 5 | jldominguez | |
36 | /**
|
||
37 | * Extensi?n que actua sobre el Layout para controlas las diferentes
|
||
38 | * operaciones sobre los gr?ficos.
|
||
39 | *
|
||
40 | * @author Vicente Caballero Navarro
|
||
41 | */
|
||
42 | public class LayoutGraphicControls extends Extension { |
||
43 | |||
44 | private static final Logger logger = LoggerFactory |
||
45 | .getLogger(LayoutGraphicControls.class); |
||
46 | private LayoutPanel layout = null; |
||
47 | |||
48 | /**
|
||
49 | * @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
|
||
50 | */
|
||
51 | public void execute(String s) { |
||
52 | layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow(); |
||
53 | FLayoutGraphics lg = new FLayoutGraphics(layout);
|
||
54 | logger.debug("Comand : " + s);
|
||
55 | |||
56 | 24 | jldominguez | if (s.compareTo("layout-graphic-group") == 0) { |
57 | 5 | jldominguez | layout.getLayoutContext().getFrameCommandsRecord() |
58 | .startComplex(PluginServices.getText(this, "group")); |
||
59 | lg.grouping(); |
||
60 | layout.getLayoutContext().getFrameCommandsRecord().endComplex(); |
||
61 | layout.getDocument().setModified(true);
|
||
62 | } else
|
||
63 | 24 | jldominguez | if (s.compareTo("layout-graphic-ungroup") == 0) { |
64 | 5 | jldominguez | lg.ungrouping(); |
65 | layout.getDocument().setModified(true);
|
||
66 | } else
|
||
67 | 24 | jldominguez | if (s.compareTo("layout-graphic-properties") == 0) { |
68 | 250 | cmartinez | lg.openFrameDialog(new Observer() { |
69 | public void update(Observable observable, |
||
70 | Object notification) {
|
||
71 | if (notification instanceof FFrameDialogNotification && |
||
72 | ((FFrameDialogNotification)notification).getType()==FFrameDialogNotification.FRAME_CREATED) { |
||
73 | getLayout().getDocument().setModified(true);
|
||
74 | } |
||
75 | } |
||
76 | }); |
||
77 | 5 | jldominguez | } else
|
78 | 24 | jldominguez | if (s.compareTo("layout-graphic-align") == 0) { |
79 | 5 | jldominguez | lg.aligning(); |
80 | layout.getDocument().setModified(true);
|
||
81 | } else
|
||
82 | 24 | jldominguez | if (s.compareTo("layout-graphic-send-back") == 0) { |
83 | 5 | jldominguez | lg.behind(); |
84 | layout.getDocument().setModified(true);
|
||
85 | } else
|
||
86 | 24 | jldominguez | if (s.compareTo("layout-graphic-bring-to-front") == 0) { |
87 | 5 | jldominguez | lg.before(); |
88 | layout.getDocument().setModified(true);
|
||
89 | } else
|
||
90 | 24 | jldominguez | if (s.compareTo("layout-graphic-add-border") == 0) { |
91 | 5 | jldominguez | if (lg.border()) {
|
92 | layout.getDocument().setModified(true);
|
||
93 | } |
||
94 | } else
|
||
95 | 24 | jldominguez | if (s.compareTo("layout-graphic-position") == 0) { |
96 | 5 | jldominguez | lg.position(); |
97 | layout.getDocument().setModified(true);
|
||
98 | } |
||
99 | } |
||
100 | |||
101 | /**
|
||
102 | * @see com.iver.mdiApp.plugins.IExtension#isVisible()
|
||
103 | */
|
||
104 | public boolean isVisible() { |
||
105 | IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
||
106 | |||
107 | if (f == null) { |
||
108 | return false; |
||
109 | } |
||
110 | |||
111 | if (f instanceof LayoutPanel) { |
||
112 | 200 | cmartinez | return true; |
113 | 5 | jldominguez | } |
114 | return false; |
||
115 | } |
||
116 | |||
117 | /**
|
||
118 | * @see org.gvsig.andami.plugins.IExtension#initialize()
|
||
119 | */
|
||
120 | public void initialize() { |
||
121 | registerIcons(); |
||
122 | } |
||
123 | |||
124 | private void registerIcons() { |
||
125 | 21 | jldominguez | |
126 | 24 | jldominguez | IconThemeHelper.registerIcon("action", "layout-graphic-group", this); |
127 | IconThemeHelper.registerIcon("action", "layout-graphic-ungroup", this); |
||
128 | IconThemeHelper.registerIcon("action", "layout-graphic-bring-to-front", this); |
||
129 | IconThemeHelper.registerIcon("action", "layout-graphic-send-back", this); |
||
130 | IconThemeHelper.registerIcon("action", "layout-graphic-position", this); |
||
131 | IconThemeHelper.registerIcon("action", "layout-graphic-add-border", this); |
||
132 | 5 | jldominguez | } |
133 | |||
134 | /**
|
||
135 | * @see org.gvsig.andami.plugins.IExtension#isEnabled()
|
||
136 | */
|
||
137 | public boolean isEnabled() { |
||
138 | layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow(); |
||
139 | if (!layout.getLayoutContext().isEditable())
|
||
140 | return false; |
||
141 | return true; |
||
142 | } |
||
143 | 250 | cmartinez | |
144 | protected LayoutPanel getLayout() {
|
||
145 | return layout;
|
||
146 | } |
||
147 | 5 | jldominguez | } |