Revision 260

View differences:

tags/org.gvsig.app.document.layout2.app-2.0.33/org.gvsig.app.document.layout2.app.mainplugin/buildNumber.properties
1
#Wed Oct 01 12:17:22 EDT 2014
2
buildNumber=52
0 3

  
tags/org.gvsig.app.document.layout2.app-2.0.33/org.gvsig.app.document.layout2.app.mainplugin/src/main/assembly/gvsig-plugin-package.xml
1
<assembly>
2
  <id>gvsig-plugin-package</id>
3
  <formats>
4
    <format>zip</format>
5
  </formats>
6
  <baseDirectory>${project.artifactId}</baseDirectory>
7
  <includeBaseDirectory>true</includeBaseDirectory>
8
  <files>
9
    <file>
10
      <source>target/${project.artifactId}-${project.version}.jar</source>
11
      <outputDirectory>lib</outputDirectory>
12
    </file>
13
    <file>
14
      <source>target/package.info</source>
15
    </file>
16
  </files>
17

  
18
  <fileSets>
19
    <fileSet>
20
      <directory>src/main/resources-plugin</directory>
21
      <outputDirectory>.</outputDirectory>
22
    </fileSet>
23
  </fileSets>
24

  
25
  <dependencySets>
26
  
27
  <!--
28
    <dependencySet>
29
      <useProjectArtifact>false</useProjectArtifact>
30
      <useTransitiveDependencies>false</useTransitiveDependencies>
31
      <outputDirectory>lib</outputDirectory>
32
      <includes>
33
      </includes>
34
    </dependencySet>
35
    
36
    -->
37
    
38
  </dependencySets>
39

  
40
</assembly>
0 41

  
tags/org.gvsig.app.document.layout2.app-2.0.33/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/LayoutInsertToolsExtension.java
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.app.extension;
23

  
24
import org.slf4j.Logger;
25
import org.slf4j.LoggerFactory;
26

  
27
import org.gvsig.andami.IconThemeHelper;
28
import org.gvsig.andami.PluginServices;
29
import org.gvsig.andami.plugins.Extension;
30
import org.gvsig.andami.ui.mdiManager.IWindow;
31
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
32

  
33
/**
34
 * Extensi?n para editar los v?rtices de las geometr?as a?adidas en un
35
 * FFrameGraphics.
36
 * 
37
 * @author Vicente Caballero Navarro
38
 */
39
public class LayoutInsertToolsExtension extends Extension {
40

  
41
    private static final Logger logger = LoggerFactory
42
        .getLogger(LayoutInsertToolsExtension.class);
43

  
44
    private LayoutPanel layout = null;
45

  
46
    public void initialize() {
47
        // TODO Auto-generated method stub
48
        registerIcons();
49
    }
50

  
51
    private void registerIcons() {
52
        
53
        IconThemeHelper.registerIcon("action", "layout-insert-text", this);
54
        IconThemeHelper.registerIcon("action", "layout-insert-point", this);
55
        IconThemeHelper.registerIcon("action", "layout-insert-rectangle", this);
56
        IconThemeHelper.registerIcon("action", "layout-insert-circle", this);
57

  
58
        IconThemeHelper.registerIcon("action", "layout-insert-line", this);
59
        IconThemeHelper.registerIcon("action", "layout-insert-polyline", this);
60
        IconThemeHelper.registerIcon("action", "layout-insert-polygon", this);
61
        IconThemeHelper.registerIcon("action", "layout-insert-image", this);
62

  
63
        IconThemeHelper.registerIcon("action", "layout-insert-view", this);
64
        IconThemeHelper.registerIcon("action", "layout-insert-locator", this);
65
        IconThemeHelper.registerIcon("action", "layout-insert-legend", this);
66
        IconThemeHelper.registerIcon("action", "layout-insert-scalebar", this);
67

  
68
        IconThemeHelper.registerIcon("action", "layout-insert-north", this);
69
        IconThemeHelper.registerIcon("action", "layout-insert-box", this);
70

  
71
        // ============================================================
72
        
73
        IconThemeHelper.registerIcon("action", "edit-delete", this);
74
        IconThemeHelper.registerIcon("action", "selection-by-rectangle", this);
75
    }
76

  
77
    public void execute(String s) {
78
        layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
79

  
80
        logger.debug("Comand : " + s);
81
        boolean insertGroupPosibility = false;
82
        
83
        if (s.equals("selection-select-by-rectangle-layout")) {
84
            layout.getLayoutControl().setTool("layoutselect");
85
        } else
86
            if (s.equals("layout-insert-view")) {
87
                layout.getLayoutControl().setTool("layoutaddview");
88
                insertGroupPosibility = true;
89
            } else
90
                if (s.equals("layout-insert-locator")) {
91
                    layout.getLayoutControl().setTool("layoutaddoverview");
92
                    insertGroupPosibility = true;
93
                } else
94
                    if (s.equals("layout-insert-image")) {
95
                        layout.getLayoutControl().setTool("layoutaddpicture");
96
                        insertGroupPosibility = true;
97
                    } else
98
                        if (s.equals("layout-insert-scalebar")) {
99
                            layout.getLayoutControl().setTool("layoutaddscale");
100
                            insertGroupPosibility = true;
101
                        } else
102
                            if (s.equals("layout-insert-legend")) {
103
                                layout.getLayoutControl().setTool(
104
                                    "layoutaddlegend");
105
                                insertGroupPosibility = true;
106
                            } else
107
                                if (s.equals("layout-insert-text")) {
108
                                    layout.getLayoutControl().setTool(
109
                                        "layoutaddtext");
110
                                    insertGroupPosibility = true;
111
                                } else
112
                                    if (s.equals("layout-insert-north")) {
113
                                        layout.getLayoutControl().setTool(
114
                                            "layoutaddnorth");
115
                                        insertGroupPosibility = true;
116
                                    } else
117
                                        if (s.equals("layout-insert-box")) {
118
                                            layout.getLayoutControl().setTool(
119
                                                "layoutaddbox");
120
                                            insertGroupPosibility = true;
121
                                        } else
122
                                            if (s.equals("layout-insert-point")) {
123
                                                layout.getLayoutControl()
124
                                                    .setTool("layoutaddpoint");
125
                                            } else
126
                                                if (s.equals("layout-insert-line")) {
127
                                                    layout.getLayoutControl()
128
                                                        .setTool(
129
                                                            "layoutaddline");
130
                                                } else
131
                                                    if (s.equals("layout-insert-polyline")) {
132
                                                        layout
133
                                                            .getLayoutControl()
134
                                                            .setTool(
135
                                                                "layoutaddpolyline");
136
                                                    } else
137
                                                        if (s.equals("layout-insert-circle")) {
138
                                                            layout
139
                                                                .getLayoutControl()
140
                                                                .setTool(
141
                                                                    "layoutaddcircle");
142
                                                        } else
143
                                                            if (s
144
                                                                .equals("layout-insert-rectangle")) {
145
                                                                layout
146
                                                                    .getLayoutControl()
147
                                                                    .setTool(
148
                                                                        "layoutaddrectangle");
149
                                                            } else
150
                                                                if (s
151
                                                                    .equals("layout-insert-polygon")) {
152
                                                                    layout
153
                                                                        .getLayoutControl()
154
                                                                        .setTool(
155
                                                                            "layoutaddpolygon");
156
                                                                } else
157
                                                                    if (s
158
                                                                        .equals("edit-delete-layout")) {
159
                                                                        layout
160
                                                                            .getLayoutContext()
161
                                                                            .delFFrameSelected();
162
                                                                        layout
163
                                                                            .getLayoutControl()
164
                                                                            .refresh();
165
                                                                    }
166
        layout.getDocument().setModified(true);
167
    }
168

  
169
    public boolean isEnabled() {
170
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
171

  
172
        if (f == null) {
173
            return false;
174
        }
175

  
176
        if (f instanceof LayoutPanel) {
177
            return ((LayoutPanel) f).getLayoutContext().isEditable();
178
        }
179

  
180
        return false;
181
    }
182

  
183
    public boolean isVisible() {
184
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
185

  
186
        if (f == null) {
187
            return false;
188
        }
189

  
190
        if (f instanceof LayoutPanel) {
191
            return true;
192
        } else {
193
            return false;
194
        }
195
    }
196
}
tags/org.gvsig.app.document.layout2.app-2.0.33/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/LayoutRedoExtension.java
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.app.extension;
23

  
24
import org.gvsig.andami.IconThemeHelper;
25
import org.gvsig.andami.PluginServices;
26
import org.gvsig.andami.messages.NotificationManager;
27
import org.gvsig.andami.plugins.Extension;
28
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
29
import org.gvsig.tools.undo.RedoException;
30

  
31
public class LayoutRedoExtension extends Extension {
32

  
33
    public void initialize() {
34
        registerIcons();
35
    }
36

  
37
    private void registerIcons() {
38

  
39
        IconThemeHelper.registerIcon("action", "edit-redo", this);
40
    }
41

  
42
    public void execute(String actionCommand) {
43
        LayoutPanel layout =
44
            (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
45
        if (actionCommand.equals("edit-redo-layout")) {
46
            try {
47
                layout.getLayoutContext().getFrameCommandsRecord().redo();
48
            } catch (RedoException e) {
49
                NotificationManager.showMessageError("Redo layout", e);
50
            }
51
            layout.getLayoutContext().updateFFrames();
52
            layout.getLayoutControl().refresh();
53
            layout.getDocument().setModified(true);
54
        }
55
    }
56

  
57
    public boolean isEnabled() {
58
        if (PluginServices.getMDIManager().getActiveWindow() instanceof LayoutPanel) {
59
            LayoutPanel layout =
60
                (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
61
            if (layout.getLayoutContext().getFrameCommandsRecord().canRedo()
62
                && layout.getLayoutContext().isEditable())
63
                return true;
64
        }
65
        return false;
66
    }
67

  
68
    public boolean isVisible() {
69
        if (PluginServices.getMDIManager().getActiveWindow() instanceof LayoutPanel) {
70
            return true;
71
        }
72
        return false;
73
    }
74
}
tags/org.gvsig.app.document.layout2.app-2.0.33/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/LayoutInsertOverViewExtension.java
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.app.extension;
23

  
24
import org.gvsig.andami.PluginServices;
25
import org.gvsig.andami.plugins.Extension;
26
import org.gvsig.andami.ui.mdiManager.IWindow;
27
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
28

  
29
/**
30
 * Extensi?n para insertar un localizador sobre el Layout.
31
 * 
32
 * @author Vicente Caballero Navarro
33
 */
34
public class LayoutInsertOverViewExtension extends Extension {
35

  
36
    private LayoutPanel layout = null;
37

  
38
    public void initialize() {
39
        // TODO Auto-generated method stub
40
    }
41

  
42
    public void execute(String s) {
43
        layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
44

  
45
        if (s.equals("layout-insert-locator")) {
46
            layout.getLayoutControl().setTool("layoutaddoverview");
47
        }
48
    }
49

  
50
    public boolean isEnabled() {
51
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
52

  
53
        if (f == null) {
54
            return false;
55
        }
56

  
57
        if (f instanceof LayoutPanel) {
58
            return ((LayoutPanel) f).getLayoutContext().isEditable();
59
        }
60

  
61
        return false;
62
    }
63

  
64
    public boolean isVisible() {
65
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
66

  
67
        if (f == null) {
68
            return false;
69
        }
70

  
71
        if (f instanceof LayoutPanel) {
72
            return true;
73
        } else {
74
            return false;
75
        }
76
    }
77
}
tags/org.gvsig.app.document.layout2.app-2.0.33/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/FFrameViewExtension.java
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.app.extension;
23

  
24
import javax.swing.JOptionPane;
25

  
26
import org.gvsig.andami.PluginServices;
27
import org.gvsig.andami.PluginsLocator;
28
import org.gvsig.andami.PluginsManager;
29
import org.gvsig.andami.actioninfo.ActionInfoManager;
30
import org.gvsig.andami.messages.NotificationManager;
31
import org.gvsig.andami.plugins.Extension;
32
import org.gvsig.andami.ui.mdiManager.IWindow;
33
import org.gvsig.app.ApplicationLocator;
34
import org.gvsig.app.ApplicationManager;
35
import org.gvsig.app.project.documents.layout.LayoutDocument;
36
import org.gvsig.app.project.documents.layout.fframes.FFrameOverView;
37
import org.gvsig.app.project.documents.layout.fframes.IFFrameUseFMap;
38
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
39
import org.gvsig.fmap.dal.exception.ReadException;
40
import org.gvsig.tools.ToolsLocator;
41
import org.gvsig.tools.dataTypes.DataTypes;
42
import org.slf4j.Logger;
43
import org.slf4j.LoggerFactory;
44

  
45
/**
46
 * Extensi?n preparada para controlar las opciones que se pueden realizar sobre
47
 * una vista a?adida en el Layout.
48
 * 
49
 * @author Vicente Caballero Navarro
50
 */
51
public class FFrameViewExtension extends Extension {
52

  
53
    private LayoutPanel layout = null;
54
    private static Logger logger = LoggerFactory.getLogger(FFrameViewExtension.class);
55
    //.info("Can't change scale of view.", ex);
56

  
57
    /**
58
     * @see org.gvsig.andami.plugins.IExtension#initialize()
59
     */
60
    public void initialize() {
61
    	
62
    }
63

  
64
    /**
65
     * @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String, Object[])
66
     */
67
    public void execute(String command, Object[] args) {
68
    	if (command.endsWith("view-change-scale")) {
69
    		ApplicationManager manager = ApplicationLocator.getManager();
70
    		IWindow window = manager.getActiveWindow();
71
    		if (!(window instanceof LayoutPanel)) {
72
    			return;
73
    		}
74
    		layout = (LayoutPanel) window;
75
    		try {
76
    			if (args.length>0) {
77
    				Long scale = (Long) ToolsLocator.getDataTypesManager().coerce(DataTypes.LONG, args[0]);
78
    				if (layout!=null &&
79
    						layout.getLayoutControl()!=null &&
80
    						layout.getLayoutControl().getLayoutFunctions()!=null) {
81
    					layout.getLayoutControl().getLayoutFunctions().setScale(scale);
82
    				}
83
    			}
84
    		} catch (Throwable ex) {
85
    			logger.info("Can't change scale of view.", ex);
86
    			ApplicationLocator.getManager().message("Can't change scale of view.", JOptionPane.ERROR_MESSAGE);
87
    		}
88
    	}
89
    	else {
90
    		execute(command);	
91
    	}
92
    }
93
    
94
    /**
95
     * @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
96
     */
97
    public void execute(String s) {
98
        layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
99

  
100
        if (s.compareTo("layout-view-navigation-zoom-in-topoint") == 0) {
101
        	layout.getLayoutControl().setTool("layoutviewzoomin");
102
        } else if (s.compareTo("layout-view-navigation-zoom-out-topoint") == 0) {
103
        	layout.getLayoutControl().setTool("layoutviewzoomout");
104
        } else if (s.compareTo("layout-view-navigation-zoom-all") == 0) {
105
        	try {
106
        		layout.getLayoutControl().viewFull();
107
        	} catch (ReadException e) {
108
        		NotificationManager.addError("Error de Driver", e);
109
        	}
110
        } else if (s.compareTo("layout-view-navigation-pan") == 0) {
111
        	layout.getLayoutControl().setTool("layoutviewpan");
112
        } else if (s.compareTo("layout-view-add-layer") == 0) {
113
        	PluginsManager manager = PluginsLocator.getManager();
114
        	AddLayer plugin = (AddLayer) manager.getExtension(AddLayer.class);
115
        	IFFrameUseFMap[] fframes = this.layout.getLayoutContext().getSelectedFFrames(IFFrameUseFMap.class);
116
        	if (fframes.length>0) {
117
        		plugin.addLayers(fframes[0].getMapContext());
118
        		fframes[0].refresh();
119
        	}
120
        }
121
        layout.getDocument().setModified(true);
122
    }
123
    
124

  
125
    /**
126
     * @see org.gvsig.andami.plugins.IExtension#isEnabled()
127
     */
128
    public boolean isEnabled() {
129
    	IWindow window = PluginServices.getMDIManager().getActiveWindow();
130
    	if (window instanceof LayoutPanel) {
131
    		LayoutPanel l =
132
    				(LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
133
    		if (!l.getLayoutContext().isEditable()) {
134
    			return false;
135
    		}
136
    		IFFrameUseFMap[] fframes = l.getLayoutContext().getSelectedFFrames(IFFrameUseFMap.class);
137
    		if (fframes.length==1 && !(fframes[0] instanceof FFrameOverView)) {
138
    			return true;
139
    		}
140
    	}
141
    	return false;
142
    }
143

  
144
    /**
145
     * @see org.gvsig.andami.plugins.IExtension#isVisible()
146
     */
147
    public boolean isVisible() {
148
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
149

  
150
        if (f == null) {
151
            return false;
152
        }
153

  
154
        if (f instanceof LayoutPanel) {
155
            // Layout layout = (Layout) f;
156

  
157
            return true; // layout.m_Display.getMapControl().getMapContext().getLayers().layerCount()
158
                         // > 0;
159
        } else {
160
            return false;
161
        }
162
    }
163
}
tags/org.gvsig.app.document.layout2.app-2.0.33/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/LayoutEditableControls.java
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.app.extension;
23

  
24
import java.awt.event.KeyEvent;
25

  
26
import javax.swing.KeyStroke;
27

  
28
import org.gvsig.andami.PluginServices;
29
import org.gvsig.andami.plugins.Extension;
30
import org.gvsig.andami.ui.mdiManager.IWindow;
31
import org.gvsig.app.project.documents.layout.LayoutKeyEvent;
32
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
33

  
34
/**
35
 * Extensi?n para controlar las operaciones basicas de edici?n sobre el Layout.
36
 * 
37
 * @author Vicente Caballero Navarro
38
 */
39
public class LayoutEditableControls extends Extension {
40

  
41
    private static LayoutKeyEvent lke = new LayoutKeyEvent();
42
    private static KeyStroke copyLayout = KeyStroke.getKeyStroke(KeyEvent.VK_C,
43
        KeyEvent.CTRL_MASK);
44
    private static KeyStroke cutLayout = KeyStroke.getKeyStroke(KeyEvent.VK_X,
45
        KeyEvent.CTRL_MASK);
46
    private static KeyStroke pasteLayout = KeyStroke.getKeyStroke(
47
        KeyEvent.VK_V, KeyEvent.CTRL_MASK);
48
    private static KeyStroke leftLayout = KeyStroke.getKeyStroke(
49
        KeyEvent.VK_LEFT, 0);
50
    private static KeyStroke rightLayout = KeyStroke.getKeyStroke(
51
        KeyEvent.VK_RIGHT, 0);
52
    private static KeyStroke upLayout = KeyStroke.getKeyStroke(KeyEvent.VK_UP,
53
        0);
54
    private static KeyStroke downLayout = KeyStroke.getKeyStroke(
55
        KeyEvent.VK_DOWN, 0);
56
    private static KeyStroke undoLayout = KeyStroke.getKeyStroke(KeyEvent.VK_Z,
57
        KeyEvent.CTRL_MASK);
58
    private static KeyStroke redoLayout = KeyStroke.getKeyStroke(KeyEvent.VK_Y,
59
        KeyEvent.CTRL_MASK);
60
    private static KeyStroke del1Layout = KeyStroke.getKeyStroke(
61
        KeyEvent.VK_DELETE, 0);
62
    private static KeyStroke del2Layout = KeyStroke.getKeyStroke(
63
        KeyEvent.VK_BACK_SPACE, 0);
64

  
65
    /**
66
     * @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
67
     */
68
    public void execute(String s) {
69
        LayoutPanel layout =
70
            (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
71
        if (s.equals("layout-properties")) {
72
            if (layout.showFProperties()) {
73
                layout.getDocument().setModified(true);
74
            }
75
        }
76
    }
77

  
78
    /**
79
     * @see com.iver.mdiApp.plugins.IExtension#isVisible()
80
     */
81
    public boolean isVisible() {
82
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
83

  
84
        if (f == null) {
85
            return false;
86
        }
87

  
88
        if (f instanceof LayoutPanel) {
89
            return true;
90
        }
91
        return false;
92
    }
93

  
94
    /**
95
     * @see org.gvsig.andami.plugins.IExtension#initialize()
96
     */
97
    public void initialize() {
98
        registerKeys();
99
    }
100

  
101
    private static void registerKeys() {
102
        PluginServices.registerKeyStroke(copyLayout, lke);
103
        PluginServices.registerKeyStroke(cutLayout, lke);
104
        PluginServices.registerKeyStroke(pasteLayout, lke);
105
        PluginServices.registerKeyStroke(leftLayout, lke);
106
        PluginServices.registerKeyStroke(rightLayout, lke);
107
        PluginServices.registerKeyStroke(upLayout, lke);
108
        PluginServices.registerKeyStroke(downLayout, lke);
109
        PluginServices.registerKeyStroke(undoLayout, lke);
110
        PluginServices.registerKeyStroke(redoLayout, lke);
111
        PluginServices.registerKeyStroke(del1Layout, lke);
112
        PluginServices.registerKeyStroke(del2Layout, lke);
113
    }
114

  
115
    /**
116
     * @see org.gvsig.andami.plugins.IExtension#isEnabled()
117
     */
118
    public boolean isEnabled() {
119
        return true;
120
    }
121
}
tags/org.gvsig.app.document.layout2.app-2.0.33/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/Print.java
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.app.extension;
23

  
24
import java.awt.Graphics;
25
import java.awt.Graphics2D;
26
import java.awt.geom.AffineTransform;
27
import java.awt.geom.Rectangle2D;
28
import java.awt.print.PageFormat;
29
import java.awt.print.Printable;
30
import java.awt.print.PrinterException;
31
import java.awt.print.PrinterJob;
32

  
33
import javax.print.Doc;
34
import javax.print.DocFlavor;
35
import javax.print.DocPrintJob;
36
import javax.print.PrintException;
37
import javax.print.PrintService;
38
import javax.print.PrintServiceLookup;
39
import javax.print.ServiceUI;
40
import javax.print.SimpleDoc;
41
import javax.print.attribute.PrintRequestAttributeSet;
42
import javax.print.event.PrintJobAdapter;
43
import javax.print.event.PrintJobEvent;
44
import javax.print.event.PrintJobListener;
45
import javax.swing.JOptionPane;
46

  
47
import org.slf4j.Logger;
48
import org.slf4j.LoggerFactory;
49

  
50
import org.gvsig.andami.IconThemeHelper;
51
import org.gvsig.andami.PluginServices;
52
import org.gvsig.andami.plugins.Extension;
53
import org.gvsig.andami.ui.mdiManager.IWindow;
54
import org.gvsig.app.ApplicationLocator;
55
import org.gvsig.app.project.documents.layout.Attributes;
56
import org.gvsig.app.project.documents.layout.FLayoutUtilities;
57
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
58
import org.gvsig.i18n.Messages;
59

  
60
/**
61
 * Extensi?n desde la que se imprime.
62
 * 
63
 * @author Vicente Caballero Navarro
64
 */
65
public class Print extends Extension implements Printable {
66

  
67
    private static Logger logger = LoggerFactory.getLogger(Print.class);
68
    
69
    public static PrinterJob printerJob = PrinterJob.getPrinterJob();
70

  
71
    // private Paper paper;
72
    Rectangle2D.Double aux = null;   
73
    private PrintService[] m_cachePrintServices = null;
74
    private PrintService m_cachePrintService = null;
75
    
76
    private static LayoutPanel theLayoutPanel = null;
77

  
78
    public void execute(String s) {
79
        if (s.compareTo("application-print-layout") == 0) {
80
            doPrint((LayoutPanel) PluginServices.getMDIManager().getActiveWindow());
81
        }
82
    }
83

  
84
    public void doPrint(final LayoutPanel layoutPanel) {
85
        
86
        theLayoutPanel = layoutPanel;
87
        
88
        try {
89
            PluginServices.backgroundExecution(new Runnable() {
90

  
91
                public void run() {
92
                    if (layoutPanel.getLayoutContext().getAttributes().getType() == Attributes.CUSTOM) {
93
                        layoutPanel.showPrintDialog(printerJob);
94
                    } else {
95
                        layoutPanel.showPrintDialog(null);
96
                    }
97
                }
98
            });
99

  
100
        } catch (Exception e) {
101
            
102
            logger.info("Error while showing print dialog.", e);
103
            ApplicationLocator.getManager().messageDialog(
104
                Messages.getText("_Error_while_showing_print_dialog"),
105
                Messages.getText("Imprimir"),
106
                JOptionPane.ERROR_MESSAGE);
107
        }
108
    }
109
    
110
    public void setLayout(LayoutPanel layoutp){
111
        theLayoutPanel = layoutp;
112
    }
113
    
114
    
115
    public boolean isVisible() {
116
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
117

  
118
        if (f == null) {
119
            return false;
120
        }
121

  
122
        return (f instanceof LayoutPanel);
123
    }
124

  
125
    public boolean isEnabled() {
126
        LayoutPanel f =
127
            (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
128

  
129
        if (f == null) {
130
            return false;
131
        }
132

  
133
        return true;
134
    }
135

  
136
   
137
    public void initialize() {
138
        registerIcons();
139
    }
140

  
141
    private void registerIcons() {
142
        IconThemeHelper.registerIcon("action", "application-print", this);
143
    }
144

  
145
    /**
146
     * Abre un di?logo para imprimir.
147
     * 
148
     * @param layout
149
     *            Layout a imprimir.
150
     */
151
    public void openDialogToPrint(LayoutPanel layoutPanel) {
152
      
153
        theLayoutPanel = layoutPanel;
154
        
155
        try {
156
            if (layoutPanel.getLayoutContext().getAttributes().getType() == Attributes.CUSTOM) {
157
                layoutPanel.showPrintDialog(printerJob);
158
            } else {
159
                layoutPanel.showPrintDialog(null);
160
            }
161
        } catch (Exception e) {
162
            System.out.println("Excepci?n al abrir el di?logo de impresi?n: "
163
                + e);
164
            e.printStackTrace();
165
        }
166
    }
167

  
168
    /**
169
     * Imprime el Layout que se pasa como par?metro.
170
     * 
171
     * @param layout
172
     *            Layout a imprimir.
173
     */
174
    public void printLayout(LayoutPanel layoutPanel) {
175

  
176
        theLayoutPanel = layoutPanel;
177
        
178
        try {
179
            printerJob.setPrintable((Printable) PluginServices
180
                .getExtension(org.gvsig.app.extension.Print.class));
181

  
182
            // Actualizar attributes
183
            PrintRequestAttributeSet att =
184
                layoutPanel.getLayoutContext().getAttributes()
185
                    .toPrintRequestAttributeSet();
186
            DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
187

  
188
            if (m_cachePrintServices == null) {
189
                m_cachePrintServices =
190
                    PrintServiceLookup.lookupPrintServices(flavor, null);
191
            }
192

  
193
            PrintService defaultService = null;
194

  
195
            if (m_cachePrintService == null) {
196
                defaultService = PrintServiceLookup.lookupDefaultPrintService();
197
            }
198

  
199
            if (m_cachePrintService == null) {
200
                m_cachePrintService =
201
                    ServiceUI.printDialog(null, 200, 200, m_cachePrintServices,
202
                        defaultService, flavor, att);
203
            }
204

  
205
            if (m_cachePrintService != null) {
206
                DocPrintJob jobNuevo = m_cachePrintService.createPrintJob();
207
                PrintJobListener pjlistener = new PrintJobAdapter() {
208

  
209
                    public void printDataTransferCompleted(PrintJobEvent e) {
210
                        System.out.println("Fin de impresi?n");
211
                    }
212
                };
213

  
214
                jobNuevo.addPrintJobListener(pjlistener);
215

  
216
                Doc doc =
217
                    new SimpleDoc(
218
                        PluginServices
219
                            .getExtension(org.gvsig.app.extension.Print.class),
220
                        flavor, null);
221
                jobNuevo.print(doc, att);
222
            }
223
        } catch (PrintException pe) {
224
            pe.printStackTrace();
225
        }
226
    }
227
    
228
    /**
229
     * Se dibuja sobre el graphics el Layout.
230
     *
231
     * @param g2 graphics sobre el que se dibuja.
232
     */
233
    public void drawShapes(Graphics2D g2) {
234
        theLayoutPanel.drawLayoutPrint(g2);
235
    }
236
    
237
    
238
    public int print(Graphics g, PageFormat format, int pi)
239
        throws PrinterException {
240
        
241
        if (pi >= 1) {
242
            return Printable.NO_SUCH_PAGE;
243
        }
244

  
245
        Graphics2D g2d = (Graphics2D) g;
246

  
247

  
248
        AffineTransform at = g2d.getTransform();
249
        g2d.translate(0, 0);
250
        theLayoutPanel.obtainRect(true);
251

  
252
        g2d.scale((double) 72 / (double) (Attributes.DPI),
253
            (double) 72 / (double) (Attributes.DPI));
254

  
255
        if (theLayoutPanel.getLayoutContext().getAttributes().isMargin()) {
256
            g2d.setClip((int) (theLayoutPanel.getLayoutControl().getRect().getMinX() +
257
                FLayoutUtilities.fromSheetDistance(theLayoutPanel.getLayoutContext().getAttributes().getAreaInsets()[2],
258
                    theLayoutPanel.getLayoutControl().getAT())),
259
                (int) (theLayoutPanel.getLayoutControl().getRect().getMinY() +
260
                FLayoutUtilities.fromSheetDistance(theLayoutPanel.getLayoutContext().getAttributes().getAreaInsets()[0],
261
                    theLayoutPanel.getLayoutControl().getAT())),
262
                (int) (theLayoutPanel.getLayoutControl().getRect().getWidth() -
263
                FLayoutUtilities.fromSheetDistance(theLayoutPanel.getLayoutContext().getAttributes().getAreaInsets()[2] +
264
                    theLayoutPanel.getLayoutContext().getAttributes().getAreaInsets()[3], theLayoutPanel.getLayoutControl().getAT())),
265
                (int) (theLayoutPanel.getLayoutControl().getRect().getHeight() -
266
                FLayoutUtilities.fromSheetDistance(theLayoutPanel.getLayoutContext().getAttributes().getAreaInsets()[0] +
267
                    theLayoutPanel.getLayoutContext().getAttributes().getAreaInsets()[1], theLayoutPanel.getLayoutControl().getAT())));
268
        }
269

  
270
        drawShapes(g2d);
271
        g2d.setTransform(at);
272

  
273
        return Printable.PAGE_EXISTS;
274
    }
275
}
tags/org.gvsig.app.document.layout2.app-2.0.33/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/LayoutCommandStackExtension.java
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.app.extension;
23

  
24
import org.gvsig.andami.IconThemeHelper;
25
import org.gvsig.andami.PluginServices;
26
import org.gvsig.andami.plugins.Extension;
27
import org.gvsig.app.gui.command.CommandStackDialog;
28
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
29

  
30
public class LayoutCommandStackExtension extends Extension {
31

  
32
    private LayoutPanel layout = null;
33

  
34
    public void initialize() {
35
        registerIcons();
36
    }
37

  
38
    private void registerIcons() {
39
        IconThemeHelper.registerIcon("action", "edit-undo-redo-actions", this);
40
    }
41

  
42
    public void execute(String s) {
43
        layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
44
        if (s.equals("edit-undo-redo-actions-layout")) {
45
            CommandStackDialog csd = new CommandStackDialog();
46
            csd.setModel(layout.getLayoutContext().getFrameCommandsRecord());
47
            layout.getLayoutContext().getFrameCommandsRecord()
48
                .addObserver(layout);
49
            PluginServices.getMDIManager().addWindow(csd);
50
            layout.getDocument().setModified(true);
51
        }
52
    }
53

  
54
    public boolean isEnabled() {
55
        layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
56
        if (layout.getLayoutContext().isEditable())
57
            return true;
58
        return false;
59
    }
60

  
61
    public boolean isVisible() {
62
        if (PluginServices.getMDIManager().getActiveWindow() instanceof LayoutPanel) {
63
            return true;
64
        }
65
        return false;
66
    }
67

  
68
}
tags/org.gvsig.app.document.layout2.app-2.0.33/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/LayoutGraphicControls.java
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.app.extension;
23

  
24
import org.slf4j.Logger;
25
import org.slf4j.LoggerFactory;
26
import org.gvsig.andami.IconThemeHelper;
27
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
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFrameDialogNotification;
32
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
33
import org.gvsig.tools.observer.Observable;
34
import org.gvsig.tools.observer.Observer;
35

  
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
        if (s.compareTo("layout-graphic-group") == 0) {
57
            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
            if (s.compareTo("layout-graphic-ungroup") == 0) {
64
                lg.ungrouping();
65
                layout.getDocument().setModified(true);
66
            } else
67
                if (s.compareTo("layout-graphic-properties") == 0) {
68
                	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
                } else
78
                    if (s.compareTo("layout-graphic-align") == 0) {
79
                        lg.aligning();
80
                        layout.getDocument().setModified(true);
81
                    } else
82
                        if (s.compareTo("layout-graphic-send-back") == 0) {
83
                            lg.behind();
84
                            layout.getDocument().setModified(true);
85
                        } else
86
                            if (s.compareTo("layout-graphic-bring-to-front") == 0) {
87
                                lg.before();
88
                                layout.getDocument().setModified(true);
89
                            } else
90
                                if (s.compareTo("layout-graphic-add-border") == 0) {
91
                                    if (lg.border()) {
92
                                        layout.getDocument().setModified(true);
93
                                    }
94
                                } else
95
                                    if (s.compareTo("layout-graphic-position") == 0) {
96
                                        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
            return true;
113
        }
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
        
126
        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
    }
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
    
144
	protected LayoutPanel getLayout() {
145
		return layout;
146
	}
147
}
tags/org.gvsig.app.document.layout2.app-2.0.33/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/LayoutUndoExtension.java
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.app.extension;
23

  
24
import org.gvsig.andami.IconThemeHelper;
25
import org.gvsig.andami.PluginServices;
26
import org.gvsig.andami.messages.NotificationManager;
27
import org.gvsig.andami.plugins.Extension;
28
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
29
import org.gvsig.tools.undo.UndoException;
30

  
31
public class LayoutUndoExtension extends Extension {
32

  
33
    public void initialize() {
34
        registerIcons();
35
    }
36

  
37
    private void registerIcons() {
38
        
39
        IconThemeHelper.registerIcon("action", "edit-undo", this);
40
    }
41

  
42
    public void execute(String actionCommand) {
43
        LayoutPanel layout =
44
            (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
45
        if (actionCommand.equals("edit-undo-layout")) {
46
            try {
47
                layout.getLayoutContext().getFrameCommandsRecord().undo();
48
            } catch (UndoException e) {
49
                NotificationManager.showMessageError("Undo layout", e);
50
            }
51
            layout.getLayoutContext().updateFFrames();
52
            layout.getLayoutControl().refresh();
53
            layout.getDocument().setModified(true);
54
        }
55
    }
56

  
57
    public boolean isEnabled() {
58
        if (PluginServices.getMDIManager().getActiveWindow() instanceof LayoutPanel) {
59
            LayoutPanel layout =
60
                (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
61
            if (layout.getLayoutContext().getFrameCommandsRecord().canUndo()
62
                && layout.getLayoutContext().isEditable())
63
                return true;
64
        }
65
        return false;
66
    }
67

  
68
    public boolean isVisible() {
69
        if (PluginServices.getMDIManager().getActiveWindow() instanceof LayoutPanel) {
70
            return true;
71
        }
72
        return false;
73
    }
74

  
75
}
tags/org.gvsig.app.document.layout2.app-2.0.33/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/TagExtension.java
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.app.extension;
23

  
24
import java.awt.Component;
25

  
26
import javax.swing.JOptionPane;
27

  
28
import org.gvsig.andami.IconThemeHelper;
29
import org.gvsig.andami.PluginServices;
30
import org.gvsig.andami.plugins.Extension;
31
import org.gvsig.andami.ui.mdiManager.IWindow;
32
import org.gvsig.app.project.documents.layout.fframes.IFFrame;
33
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
34

  
35
public class TagExtension extends Extension {
36

  
37
    private LayoutPanel layout = null;
38

  
39
    /**
40
     * @see org.gvsig.andami.plugins.IExtension#initialize()
41
     */
42
    public void initialize() {
43
        registerIcons();
44
    }
45

  
46
    private void registerIcons() {
47

  
48
        IconThemeHelper.registerIcon("action", "layout-graphic-show-tags", this);
49
        IconThemeHelper.registerIcon("action", "layout-insert-tag", this);
50

  
51
    }
52

  
53
    /**
54
     * @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
55
     */
56
    public void execute(String s) {
57

  
58
        /*
59
         * FLayoutZooms zooms = new FLayoutZooms(layout);
60
         * logger.debug("Comand : " + s);
61
         * if (s.compareTo("SET_TAG") == 0) {
62
         * layout.setTool(Layout.SET_TAG);
63
         * }
64
         */
65

  
66
        // FJP: Cambio: abrimos la ventana de tag para
67
        // asignar el tag a los elementos seleccionados
68
        if (s.equals("layout-insert-tag")) {
69
            IFFrame[] selectedFrames =
70
                layout.getLayoutContext().getSelectedFFrames();
71
            if (selectedFrames.length > 0) {
72
                String defaultStr = "";
73
                if (selectedFrames.length == 1)
74
                    defaultStr = selectedFrames[0].getTag();
75
                String theTag =
76
                    JOptionPane.showInputDialog(
77
                        (Component) PluginServices.getMainFrame(),
78
                        "Introduzca el tag:", defaultStr);
79
                if (theTag != null) {
80
                    for (int i = 0; i < selectedFrames.length; i++)
81
                        selectedFrames[i].setTag(theTag);
82
                }
83
                layout.getDocument().setModified(true);
84
            }
85
        } else
86
            if (s.equals("layout-graphic-show-tags")) {
87
                // IFFrame[] frames = layout.getFFrames();
88
                // for (int i=0; i< frames.length; i++)
89
                // {
90
                // IFFrame f = frames[i];
91
                // if (f instanceof FFrameText)
92
                // {
93
                // FFrameText txt = (FFrameText) f;
94
                // if (f.getTag() != null)
95
                // {
96
                // txt.clearText();
97
                // txt.addText(f.getTag());
98
                // }
99
                // }
100
                // }
101
                layout.setShowIconTag(true);
102
                layout.getLayoutControl().refresh();
103
            }
104
    }
105

  
106
    /**
107
     * @see org.gvsig.andami.plugins.IExtension#isEnabled()
108
     */
109
    public boolean isEnabled() {
110
        IFFrame[] selectedFrames =
111
            layout.getLayoutContext().getSelectedFFrames();
112
        if (selectedFrames == null)
113
            return false;
114
        return (selectedFrames.length > 0);
115
    }
116

  
117
    /**
118
     * @see org.gvsig.andami.plugins.IExtension#isVisible()
119
     */
120
    public boolean isVisible() {
121
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
122

  
123
        if (f != null && f instanceof LayoutPanel) {
124
            layout = (LayoutPanel) f;
125
            return true;
126
        }
127
        return false;
128
    }
129

  
130
}
tags/org.gvsig.app.document.layout2.app-2.0.33/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/PrintProperties.java
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.app.extension;
23

  
24
/**
25
 */
26
import java.awt.geom.Rectangle2D;
27

  
28
import org.gvsig.andami.IconThemeHelper;
29
import org.gvsig.andami.PluginServices;
30
import org.gvsig.andami.plugins.Extension;
31
import org.gvsig.andami.ui.mdiManager.IWindow;
32
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
33

  
34
/**
35
 * DOCUMENT ME!
36
 * 
37
 * @author vcn
38
 */
39
public class PrintProperties extends Extension /*
40
                                                * implements
41
                                                * IPreferenceExtension
42
                                                */{
43

  
44
    private LayoutPanel l;
45
    // private static final IPreference printPropertiesPage = new
46
    // PrintPropertiesPage();
47
    // private Paper paper;
48
    Rectangle2D.Double aux = null;
49

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff