Revision 1598

View differences:

tags/org.gvsig.app.document.layout2.app-2.0.280/pom.xml
1
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
2

  
3
    <modelVersion>4.0.0</modelVersion>
4
    <artifactId>org.gvsig.app.document.layout2.app</artifactId>
5
    <packaging>pom</packaging>
6
    <version>2.0.280</version>
7

  
8
    <name>${project.artifactId}</name>
9
    <description>This plugin adds creation/management of layout (map) documents.</description>
10

  
11
    <parent>
12
        <groupId>org.gvsig</groupId>
13
        <artifactId>org.gvsig.desktop</artifactId>
14
        <version>2.0.423</version>
15
    </parent>
16

  
17
	<url>https://devel.gvsig.org/redmine/projects/gvsig-app-document-layout</url>
18

  
19
    <scm>
20
        <connection>scm:svn:https://devel.gvsig.org/svn/gvsig-app-document-layout/tags/org.gvsig.app.document.layout2.app-2.0.280</connection>
21
        <developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-app-document-layout/tags/org.gvsig.app.document.layout2.app-2.0.280</developerConnection>
22
        <url>https://devel.gvsig.org/redmine/projects/gvsig-app-document-layout/repository/show/tags/org.gvsig.app.document.layout2.app-2.0.280</url>
23
    </scm>
24
    <repositories>
25
      <repository>
26
        <id>gvsig-public-http-repository</id>
27
        <name>gvSIG maven public HTTP repository</name>
28
        <url>http://devel.gvsig.org/m2repo/j2se</url>
29
        <releases>
30
          <enabled>true</enabled>
31
          <updatePolicy>daily</updatePolicy>
32
          <checksumPolicy>warn</checksumPolicy>
33
        </releases>
34
        <snapshots>
35
          <enabled>true</enabled>
36
          <updatePolicy>daily</updatePolicy>
37
          <checksumPolicy>warn</checksumPolicy>
38
        </snapshots>
39
      </repository>
40
    </repositories>
41

  
42
	<build>
43
		<plugins>
44
			<plugin>
45
				<groupId>org.apache.maven.plugins</groupId>
46
				<artifactId>maven-release-plugin</artifactId>
47
				<configuration>
48
					<tagBase>https://devel.gvsig.org/svn/gvsig-app-document-layout/tags</tagBase>
49
				</configuration>
50
			</plugin>
51
		</plugins>
52
	</build>
53

  
54
    <dependencyManagement>
55
         <dependencies>
56
            <!--
57
            Versions of child projects
58
            -->
59
            <dependency>
60
                <groupId>org.gvsig</groupId>
61
                <artifactId>org.gvsig.app.document.layout2.app.mainplugin</artifactId>
62
                <version>2.0.280</version>
63
            </dependency>
64
            <dependency>
65
                <groupId>org.gvsig</groupId>
66
                <artifactId>org.gvsig.pdf.swing.api</artifactId>
67
                <version>${org.gvsig.pdf.version}</version>
68
            </dependency>
69
            <dependency>
70
                <groupId>org.gvsig</groupId>
71
                <artifactId>org.gvsig.report.lib.api</artifactId>
72
                <version>${org.gvsig.report.version}</version>
73
            </dependency>
74
            
75

  
76
        </dependencies>
77
    </dependencyManagement>
78
    <properties>
79
        <org.gvsig.pdf.version>1.0.132</org.gvsig.pdf.version>
80
    </properties>
81
	<modules>
82
		<module>org.gvsig.app.document.layout2.app.mainplugin</module>
83
	</modules>
84

  
85
</project>
tags/org.gvsig.app.document.layout2.app-2.0.280/org.gvsig.app.document.layout2.app.mainplugin/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2

  
3
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4
    
5
    <modelVersion>4.0.0</modelVersion>
6
    <packaging>jar</packaging>
7
    <artifactId>org.gvsig.app.document.layout2.app.mainplugin</artifactId>
8
    <name>${project.artifactId}</name>
9

  
10
    <parent>
11
        <groupId>org.gvsig</groupId>
12
        <artifactId>org.gvsig.app.document.layout2.app</artifactId>
13
        <version>2.0.280</version>
14
    </parent>
15
    
16
    <dependencies>
17

  
18
        <dependency>
19
            <groupId>org.gvsig</groupId>
20
            <artifactId>org.gvsig.app.mainplugin</artifactId>
21
            <scope>compile</scope>
22
        </dependency>
23
        <dependency>
24
            <groupId>org.gvsig</groupId>
25
            <artifactId>org.gvsig.andami</artifactId>
26
            <scope>compile</scope>
27
        </dependency>
28
        <dependency>
29
            <groupId>org.gvsig</groupId>
30
            <artifactId>org.gvsig.fmap.control</artifactId>
31
            <scope>compile</scope>
32
        </dependency>
33
        <dependency>
34
            <groupId>org.gvsig</groupId>
35
            <artifactId>org.gvsig.tools.lib</artifactId>
36
            <scope>compile</scope>
37
        </dependency>
38
        <dependency>
39
            <groupId>org.gvsig</groupId>
40
            <artifactId>org.gvsig.tools.swing.api</artifactId>
41
            <scope>compile</scope>
42
        </dependency>
43
        <dependency>
44
            <groupId>org.gvsig</groupId>
45
            <artifactId>org.gvsig.fmap.mapcontext.api</artifactId>
46
            <scope>compile</scope>
47
        </dependency>
48
        <dependency>
49
            <groupId>org.gvsig</groupId>
50
            <artifactId>org.gvsig.fmap.geometry.api</artifactId>
51
            <scope>compile</scope>
52
        </dependency>
53
        <dependency>
54
            <groupId>org.gvsig</groupId>
55
            <artifactId>org.gvsig.utils</artifactId>
56
            <scope>compile</scope>
57
        </dependency>
58
        <dependency>
59
            <groupId>org.gvsig</groupId>
60
            <artifactId>org.gvsig.ui</artifactId>
61
            <scope>compile</scope>
62
        </dependency>
63
        <dependency>
64
            <groupId>org.gvsig</groupId>
65
            <artifactId>org.gvsig.fmap.dal.api</artifactId>
66
            <scope>compile</scope>
67
        </dependency>
68
        <dependency>
69
            <groupId>org.gvsig</groupId>
70
            <artifactId>org.gvsig.compat.api</artifactId>
71
            <scope>compile</scope>
72
        </dependency>
73
        <dependency>
74
            <groupId>org.gvsig</groupId>
75
            <artifactId>org.gvsig.projection.api</artifactId>
76
            <scope>compile</scope>
77
        </dependency>
78
        <dependency>
79
            <groupId>org.gvsig</groupId>
80
            <artifactId>org.gvsig.symbology.lib.api</artifactId>
81
            <scope>compile</scope>
82
        </dependency>
83
        <dependency>
84
            <groupId>org.gvsig</groupId>
85
            <artifactId>org.gvsig.symbology.swing.api</artifactId>
86
            <scope>compile</scope>
87
        </dependency>
88
        <dependency>
89
            <groupId>org.gvsig</groupId>
90
            <artifactId>org.gvsig.metadata.lib.basic.api</artifactId>
91
            <scope>compile</scope>
92
        </dependency>
93
        <dependency>
94
            <groupId>com.lowagie</groupId>
95
            <artifactId>itext</artifactId>
96
            <scope>compile</scope>
97
        </dependency>
98
        <dependency>
99
            <groupId>org.apache.xmlgraphics</groupId>
100
            <artifactId>batik-gvt</artifactId>
101
            <scope>compile</scope>
102
        </dependency>
103
        <dependency>
104
            <groupId>org.apache.xmlgraphics</groupId>
105
            <artifactId>batik-script</artifactId>
106
            <scope>compile</scope>
107
        </dependency>
108
        
109
        <!--
110
        <dependency>
111
            <groupId>org.gvsig</groupId>
112
            <artifactId>batik-ext-gvsig-custom</artifactId>
113
        </dependency>
114
        -->
115
        
116
        <dependency>
117
            <groupId>com.sun</groupId>
118
            <artifactId>jimi</artifactId>
119
            <scope>compile</scope>
120
        </dependency>
121
        <dependency>
122
            <groupId>org.gvsig</groupId>
123
            <artifactId>org.gvsig.i18n</artifactId>
124
            <scope>compile</scope>
125
        </dependency>
126
        <dependency>
127
            <groupId>org.gvsig</groupId>
128
            <artifactId>org.gvsig.pdf.swing.api</artifactId>
129
            <scope>compile</scope>
130
        </dependency>
131
    </dependencies>
132

  
133
    <properties>
134
	<gvsig.package.info.name>Document: Layout document plugin, version 2</gvsig.package.info.name>
135
        <gvsig.package.info.dependencies>conflict: org.gvsig.app.document.layout1.app.mainplugin -ge 1, required: org.gvsig.app.mainplugin -ge 2.1.0</gvsig.package.info.dependencies>
136
        <gvsig.package.info.categories>Layout</gvsig.package.info.categories>
137
	<gvsig.package.info.poolURL>https://devel.gvsig.org/download/projects/gvsig-app-document-layout/pool</gvsig.package.info.poolURL>
138
	<gvsig.package.info.sourcesURL>http://devel.gvsig.org/svn/gvsig-app-document-layout/trunk/org.gvsig.app.document.layout2.app</gvsig.package.info.sourcesURL>
139
	<gvsig.package.info.state>final</gvsig.package.info.state>
140
        <gvsig.package.info.official>true</gvsig.package.info.official>
141
        <gvsig.package.info.codealias>org.gvsig.app.document.layout.app.mainplugin</gvsig.package.info.codealias>
142

  
143
    </properties>
144

  
145
</project>
146

  
tags/org.gvsig.app.document.layout2.app-2.0.280/org.gvsig.app.document.layout2.app.mainplugin/buildNumber.properties
1
#Mon Jun 19 00:31:23 CEST 2023
2
buildNumber=302
0 3

  
tags/org.gvsig.app.document.layout2.app-2.0.280/org.gvsig.app.document.layout2.app.mainplugin/src/test/resources/README.txt
1
Put into this folder the resources needed by your test classes.
2

  
3
This folder is added to the Tests classpath, so you can load any resources 
4
through the ClassLoader.
5

  
6
By default, in this folder you can find an example of log4j configuration,
7
prepared to log messages through the console, so logging works when you
8
run your tests classes.
tags/org.gvsig.app.document.layout2.app-2.0.280/org.gvsig.app.document.layout2.app.mainplugin/src/test/resources/log4j.xml
1
<?xml version="1.0" encoding="ISO-8859-1" ?>
2
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
3

  
4
<!-- 
5
Log4J configuration file for unit tests execution.
6
 -->
7
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
8

  
9
	<!-- Appender configuration to show logging messages through the console -->
10
	<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
11
		<layout class="org.apache.log4j.PatternLayout">
12
			<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n  %m%n" />
13
		</layout>
14
	</appender>
15

  
16
	<!-- 
17
	Activate logging messages of DEBUG level of higher only for the
18
	org.gvsig.tools packages.
19
	You can put full classes names or packages instead, to configure
20
	logging for all the classes and subpackages of the package.
21
	-->
22
	<category name="org.gvsig.tools">
23
		<priority value="DEBUG" />
24
	</category>
25
	<category name="org.gvsig.app.document.layout">
26
		<priority value="DEBUG" />
27
	</category>
28

  
29
	<!-- 
30
	By default, show only logging messages of INFO level or higher, 
31
	through the previously configured CONSOLE appender. 
32
	-->
33
	<root>
34
		<priority value="INFO" />
35
		<appender-ref ref="CONSOLE" />
36
	</root>
37
</log4j:configuration>
0 38

  
tags/org.gvsig.app.document.layout2.app-2.0.280/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.280/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.280/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/FFrameViewPanExtension.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 FFrameViewPanExtension extends Extension {
52

  
53
    private LayoutPanel layout = null;
54
    private static Logger logger = LoggerFactory.getLogger(FFrameViewPanExtension.class);
55

  
56
    /**
57
     * @see org.gvsig.andami.plugins.IExtension#initialize()
58
     */
59
    public void initialize() {
60
    	
61
    }
62
    
63
    /**
64
     * @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
65
     */
66
    public void execute(String s) {
67
        layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
68
        if (s.compareTo("layout-view-navigation-pan") == 0) {
69
        	layout.getLayoutControl().setTool("layoutviewpan");
70
        	layout.getDocument().setModified(true);
71
        }
72
    }
73
    
74

  
75
    /**
76
     * @see org.gvsig.andami.plugins.IExtension#isEnabled()
77
     */
78
    public boolean isEnabled() {
79
    	IWindow window = PluginServices.getMDIManager().getActiveWindow();
80
    	if (window instanceof LayoutPanel) {
81
    		LayoutPanel l =
82
    				(LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
83
    		if (!l.getLayoutContext().isEditable()) {
84
    			return false;
85
    		}
86
    		IFFrameUseFMap[] fframes = l.getLayoutContext().getSelectedFFrames(IFFrameUseFMap.class);
87
    		if (fframes.length==1 && !(fframes[0] instanceof FFrameOverView)) {
88
    			IFFrameUseFMap fframeview = (IFFrameUseFMap) fframes[0];
89
    			if (fframeview.getScaleType()==IFFrameUseFMap.SCALE_TYPE.NORMAL
90
    					|| fframeview.getScaleType()==IFFrameUseFMap.SCALE_TYPE.FIXED_SCALE) {
91
    				return true;
92
    			}
93
    		}
94
    	}
95
    	return false;
96
    }
97

  
98
    /**
99
     * @see org.gvsig.andami.plugins.IExtension#isVisible()
100
     */
101
    public boolean isVisible() {
102
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
103
        if (f == null) {
104
            return false;
105
        }
106
        if (f instanceof LayoutPanel) {
107
            return true;
108
        } else {
109
            return false;
110
        }
111
    }
112
}
tags/org.gvsig.app.document.layout2.app-2.0.280/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 static Logger logger = LoggerFactory.getLogger(FFrameViewExtension.class);
54

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

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

  
98
        if (s.compareTo("layout-view-navigation-zoom-in-topoint") == 0) {
99
        	layout.getLayoutControl().setTool("layoutviewzoomin");
100
        } else if (s.compareTo("layout-view-navigation-zoom-out-topoint") == 0) {
101
        	layout.getLayoutControl().setTool("layoutviewzoomout");
102
        } else if (s.compareTo("layout-view-navigation-zoom-all") == 0) {
103
        	try {
104
        		layout.getLayoutControl().viewFull();
105
        	} catch (ReadException e) {
106
        		NotificationManager.addError("Error de Driver", e);
107
        	}
108
        }
109
        else {
110
        	return;
111
        }
112
        layout.getDocument().setModified(true);
113
    }
114
    
115

  
116
    /**
117
     * @see org.gvsig.andami.plugins.IExtension#isEnabled()
118
     */
119
    public boolean isEnabled() {
120
    	IWindow window = PluginServices.getMDIManager().getActiveWindow();
121
    	if (window instanceof LayoutPanel) {
122
    		LayoutPanel l =
123
    				(LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
124
    		if (!l.getLayoutContext().isEditable()) {
125
    			return false;
126
    		}
127
    		IFFrameUseFMap[] fframes = l.getLayoutContext().getSelectedFFrames(IFFrameUseFMap.class);
128
    		if (fframes.length==1 && !(fframes[0] instanceof FFrameOverView)) {
129
    			IFFrameUseFMap fframeview = (IFFrameUseFMap) fframes[0];
130
    			if (fframeview.getScaleType()==IFFrameUseFMap.SCALE_TYPE.NORMAL) {
131
    				return true;
132
    			}
133
    		}
134
    	}
135
    	return false;
136
    }
137

  
138
    /**
139
     * @see org.gvsig.andami.plugins.IExtension#isVisible()
140
     */
141
    public boolean isVisible() {
142
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
143

  
144
        if (f == null) {
145
            return false;
146
        }
147

  
148
        if (f instanceof LayoutPanel) {
149
            return true;
150
        } else {
151
            return false;
152
        }
153
    }
154
}
tags/org.gvsig.app.document.layout2.app-2.0.280/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.280/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.280/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/FFrameViewZoomPrev.java
1
package org.gvsig.app.extension;
2

  
3
import org.gvsig.andami.IconThemeHelper;
4
import org.gvsig.andami.PluginServices;
5
import org.gvsig.andami.plugins.Extension;
6
import org.gvsig.andami.ui.mdiManager.IWindow;
7
import org.gvsig.app.project.documents.layout.fframes.FFrameOverView;
8
import org.gvsig.app.project.documents.layout.fframes.IFFrameUseFMap;
9
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
10
import org.gvsig.fmap.mapcontext.ExtentHistory;
11
import org.gvsig.fmap.mapcontext.MapContext;
12
import org.gvsig.fmap.mapcontext.ViewPort;
13

  
14

  
15

  
16
public class FFrameViewZoomPrev extends Extension {
17

  
18
    public void postInitialize() {
19
    }
20

  
21
    public void initialize() {
22
        IconThemeHelper.registerIcon("action", "layout-view-navigation-zoom-back", this);
23
    }
24

  
25
    
26
    public boolean isEnabled() {
27
    	IWindow window = PluginServices.getMDIManager().getActiveWindow();
28
    	if (window instanceof LayoutPanel) {
29
    		LayoutPanel l =
30
    				(LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
31
    		IFFrameUseFMap[] fframes = l.getLayoutContext().getSelectedFFrames(IFFrameUseFMap.class);
32
    		if (fframes.length==1 && !(fframes[0] instanceof FFrameOverView)) {
33
    			IFFrameUseFMap fframeView = (IFFrameUseFMap) fframes[0];
34
    			MapContext mc = fframeView.getMapContext();
35
    			if (mc!=null) {
36
    				ExtentHistory history = mc.getViewPort().getEnvelopes();
37
    				if (history.hasPrevious()&&fframeView.getScaleType()==IFFrameUseFMap.SCALE_TYPE.NORMAL) {
38
    					return true;
39
    				}
40
    			}
41
    		}
42
    	}
43
    	return false;
44
    }
45

  
46
    /**
47
     * @see org.gvsig.andami.plugins.IExtension#isVisible()
48
     */
49
    public boolean isVisible() {
50
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
51

  
52
        if (f == null || !(f instanceof LayoutPanel)) {
53
            return false;
54
        }
55
        return true;
56
    }
57

  
58
    public void execute(String arg0) {
59
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
60

  
61
        if (f == null || !(f instanceof LayoutPanel)) {
62
            return;
63
        }
64
		LayoutPanel l =
65
				(LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
66
   		IFFrameUseFMap[] fframes = l.getLayoutContext().getSelectedFFrames(IFFrameUseFMap.class);
67
		if (fframes.length==1 && !(fframes[0] instanceof FFrameOverView)) {
68
			IFFrameUseFMap fframeView = (IFFrameUseFMap) fframes[0];
69
			ViewPort vp = fframeView.getMapContext().getViewPort();
70
	        vp.setPreviousEnvelope();
71
	        l.getDocument().setModified(true);
72
		}
73
    }
74

  
75
}
tags/org.gvsig.app.document.layout2.app-2.0.280/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/FFrameViewAddLayerExtension.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.PluginsLocator;
26
import org.gvsig.andami.PluginsManager;
27
import org.gvsig.andami.plugins.Extension;
28
import org.gvsig.andami.ui.mdiManager.IWindow;
29
import org.gvsig.app.project.documents.layout.fframes.FFrameOverView;
30
import org.gvsig.app.project.documents.layout.fframes.IFFrameUseFMap;
31
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
32
import org.slf4j.Logger;
33
import org.slf4j.LoggerFactory;
34

  
35
/**
36
 * Extension to control the options that can be done on a view added to layout
37
 * 
38
 * @author Cesar Martinez Izquierdo
39
 */
40
public class FFrameViewAddLayerExtension extends Extension {
41

  
42
    private static Logger logger = LoggerFactory.getLogger(FFrameViewAddLayerExtension.class);
43
    //.info("Can't change scale of view.", ex);
44

  
45
    /**
46
     * @see org.gvsig.andami.plugins.IExtension#initialize()
47
     */
48
    public void initialize() {
49
    	
50
    }
51
    
52
    /**
53
     * @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
54
     */
55
    public void execute(String s) {
56
        LayoutPanel layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
57
    	if (s.compareTo("layout-view-add-layer") == 0) {
58
        	PluginsManager manager = PluginsLocator.getManager();
59
        	AddLayer plugin = (AddLayer) manager.getExtension(AddLayer.class);
60
        	IFFrameUseFMap[] fframes = layout.getLayoutContext().getSelectedFFrames(IFFrameUseFMap.class);
61
        	if (fframes.length>0) {
62
        		if (fframes[0].getMapContext()!=null) {
63
        			plugin.addLayers(fframes[0].getMapContext());
64
        			fframes[0].refresh();
65
        			layout.getDocument().setModified(true);
66
        		}
67
        	}
68
        }
69
    }
70
    
71

  
72
    /**
73
     * @see org.gvsig.andami.plugins.IExtension#isEnabled()
74
     */
75
    public boolean isEnabled() {
76
    	IWindow window = PluginServices.getMDIManager().getActiveWindow();
77
    	if (window instanceof LayoutPanel) {
78
    		LayoutPanel l =
79
    				(LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
80
    		if (!l.getLayoutContext().isEditable()) {
81
    			return false;
82
    		}
83
    		IFFrameUseFMap[] fframes = l.getLayoutContext().getSelectedFFrames(IFFrameUseFMap.class);
84
    		if (fframes.length==1 && !(fframes[0] instanceof FFrameOverView) && ((IFFrameUseFMap)fframes[0]).getMapContext()!=null) {
85
    			return true;
86
    		}
87
    	}
88
    	return false;
89
    }
90

  
91
    /**
92
     * @see org.gvsig.andami.plugins.IExtension#isVisible()
93
     */
94
    public boolean isVisible() {
95
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
96

  
97
        if (f == null) {
98
            return false;
99
        }
100

  
101
        if (f instanceof LayoutPanel) {
102
            return true;
103
        } else {
104
            return false;
105
        }
106
    }
107
}
tags/org.gvsig.app.document.layout2.app-2.0.280/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
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff