Revision 625

View differences:

tags/org.gvsig.app.document.layout2.app-2.0.92/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.92</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.180</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.92</connection>
21
        <developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-app-document-layout/tags/org.gvsig.app.document.layout2.app-2.0.92</developerConnection>
22
        <url>https://devel.gvsig.org/redmine/projects/gvsig-app-document-layout/repository/show/tags/org.gvsig.app.document.layout2.app-2.0.92</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.92</version>
63
            </dependency>
64

  
65
        </dependencies>
66
    </dependencyManagement>
67

  
68
	<modules>
69
		<module>org.gvsig.app.document.layout2.app.mainplugin</module>
70
	</modules>
71

  
72
</project>
tags/org.gvsig.app.document.layout2.app-2.0.92/org.gvsig.app.document.layout2.app.mainplugin/buildNumber.properties
1
#Fri May 05 10:53:46 CEST 2017
2
buildNumber=111
tags/org.gvsig.app.document.layout2.app-2.0.92/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.92/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.92/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.92/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/math/intervals/IntervalUtils.java
1
package org.gvsig.math.intervals;
2

  
3
public class IntervalUtils {
4

  
5
	/**
6
	 * Calculates an nice round interval division. For instance, for
7
	 * intervalLenght = 1100000 and numberOfDivisions=5,
8
	 * the result would be 250000.
9
	 * 
10
	 * @param intervalLength The full interval to be divided
11
	 * @param numberOfDivisions The exact number of divisions to perform
12
	 * @return A nice round interval division. The calculated result
13
	 * ensures that the whole interval length is covered by the proposed
14
	 * division, so it always fulfills the following formula:
15
	 *  <code>result*numberOfDivisions>=intervalLength</code>
16
	 */
17
	public static double roundIntervalDivision(double intervalLength, int numberOfDivisions) {
18
		if (intervalLength<=0.0d || numberOfDivisions<=0) {
19
			return 0.0d;
20
		}
21

  
22
		double division = intervalLength/numberOfDivisions;
23
		if (division==0.0d) {
24
			return 0.0d;
25
		}
26
		double digitShift = Math.floor((Math.log10(division)));
27
		double scale = Math.pow(10, -digitShift);
28
		double firstSignificatDigit = Math.floor(scale*division);
29
		double result = firstSignificatDigit*Math.pow(10, digitShift);
30
		if (result*numberOfDivisions>=intervalLength) {
31
			return result;
32
		}
33
		else {
34
			result = (0.5+firstSignificatDigit)*Math.pow(10, digitShift);
35
			if (result*numberOfDivisions>=intervalLength) {
36
				return result;
37
			}
38
		}
39
		result = (1+firstSignificatDigit)*Math.pow(10, digitShift);
40
		return result;
41
	}
42
}
tags/org.gvsig.app.document.layout2.app-2.0.92/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/LayoutEditVertexExtension.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 que contiene todas las herramientas de edici?n.
35
 * 
36
 * @author Vicente Caballero Navarro
37
 */
38
public class LayoutEditVertexExtension extends Extension {
39

  
40
    private static final Logger logger = LoggerFactory
41
        .getLogger(LayoutEditVertexExtension.class);;
42
    private LayoutPanel layout = null;
43

  
44
    /**
45
     * DOCUMENT ME!
46
     */
47
    public void initialize() {
48
        // TODO Auto-generated method stub
49
        registerIcons();
50
    }
51

  
52
    private void registerIcons() {
53
        
54
        IconThemeHelper.registerIcon(
55
            "action", "layout-graphic-edit-vertex", this);
56
    }
57

  
58
    /**
59
     * DOCUMENT ME!
60
     * 
61
     * @param s
62
     *            DOCUMENT ME!
63
     */
64
    public void execute(String s) {
65
        layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
66

  
67
        logger.debug("Comand : " + s);
68
        if (s.compareTo("layout-graphic-edit-vertex") == 0) {
69
            layout.getLayoutControl().setTool("layoutedit");
70
            layout.getDocument().setModified(true);
71
        }
72
    }
73

  
74
    /**
75
     * DOCUMENT ME!
76
     * 
77
     * @return DOCUMENT ME!
78
     */
79
    public boolean isEnabled() {
80
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
81

  
82
        if (f == null) {
83
            return false;
84
        }
85

  
86
        if (f instanceof LayoutPanel) {
87
            LayoutPanel layout = (LayoutPanel) f;
88
            if (layout.getLayoutContext().isEditable()) {
89
                return true;
90
                // IFFrame[] fframes = layout.getFFrames();
91
                // for (int i = 0; i < fframes.length; i++) {
92
                // if (fframes[i].getSelected() != IFFrame.NOSELECT
93
                // && fframes[i] instanceof IFFrameEditableVertex) {
94
                // return true;
95
                // }
96
                // }
97
            }
98
        }
99
        return false;
100
    }
101

  
102
    /**
103
     * DOCUMENT ME!
104
     * 
105
     * @return DOCUMENT ME!
106
     */
107
    public boolean isVisible() {
108
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
109

  
110
        if (f == null) {
111
            return false;
112
        }
113

  
114
        if (f instanceof LayoutPanel) {
115
            // Layout layout = (Layout) f;
116
            return true; // layout.m_Display.getMapControl().getMapContext().getLayers().layerCount()
117
                         // > 0;
118
        } else {
119
            return false;
120
        }
121
    }
122
}
tags/org.gvsig.app.document.layout2.app-2.0.92/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/LayoutMainExtension.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
import java.beans.PropertyVetoException;
26
import java.io.File;
27
import java.io.FileInputStream;
28
import java.io.IOException;
29
import java.util.Iterator;
30
import java.util.prefs.Preferences;
31
import javax.swing.JOptionPane;
32
import org.gvsig.andami.IconThemeHelper;
33
import org.gvsig.andami.PluginServices;
34
import org.gvsig.andami.plugins.Extension;
35
import org.gvsig.andami.ui.mdiManager.IWindow;
36
import org.gvsig.andami.ui.mdiManager.MDIManager;
37
import org.gvsig.app.ApplicationLocator;
38
import org.gvsig.app.ApplicationManager;
39
import org.gvsig.app.project.Project;
40
import org.gvsig.app.project.ProjectManager;
41
import org.gvsig.app.project.documents.Document;
42
import org.gvsig.app.project.documents.layout.DefaultLayoutManager;
43
import org.gvsig.app.project.documents.layout.LayoutDocument;
44
import org.gvsig.app.project.documents.layout.LayoutManager;
45
import org.gvsig.app.project.documents.layout.contextmenu.gui.BeforeLayoutMenuEntry;
46
import org.gvsig.app.project.documents.layout.contextmenu.gui.BehindLayoutMenuEntry;
47
import org.gvsig.app.project.documents.layout.contextmenu.gui.CancelLayoutMenuEntry;
48
import org.gvsig.app.project.documents.layout.contextmenu.gui.CopyLayoutMenuEntry;
49
import org.gvsig.app.project.documents.layout.contextmenu.gui.CutLayoutMenuEntry;
50
import org.gvsig.app.project.documents.layout.contextmenu.gui.PasteLayoutMenuEntry;
51
import org.gvsig.app.project.documents.layout.contextmenu.gui.PositionLayoutMenuEntry;
52
import org.gvsig.app.project.documents.layout.contextmenu.gui.PropertyLayoutMenuEntry;
53
import org.gvsig.app.project.documents.layout.contextmenu.gui.RefreshLayoutMenuEntry;
54
import org.gvsig.app.project.documents.layout.contextmenu.gui.SelectAllLayoutMenuEntry;
55
import org.gvsig.app.project.documents.layout.contextmenu.gui.SimplifyLayoutMenuEntry;
56
import org.gvsig.app.project.documents.layout.contextmenu.gui.TerminateLayoutMenuEntry;
57
import org.gvsig.app.project.documents.layout.fframes.FFrame;
58
import org.gvsig.app.project.documents.layout.fframes.FFrameBasicFactory;
59
import org.gvsig.app.project.documents.layout.fframes.FFrameGraphics;
60
import org.gvsig.app.project.documents.layout.fframes.FFrameGraphicsFactory;
61
import org.gvsig.app.project.documents.layout.fframes.FFrameGrid;
62
import org.gvsig.app.project.documents.layout.fframes.FFrameGridFactory;
63
import org.gvsig.app.project.documents.layout.fframes.FFrameGroup;
64
import org.gvsig.app.project.documents.layout.fframes.FFrameGroupFactory;
65
import org.gvsig.app.project.documents.layout.fframes.FFrameLegend;
66
import org.gvsig.app.project.documents.layout.fframes.FFrameLegendFactory;
67
import org.gvsig.app.project.documents.layout.fframes.FFrameNorth;
68
import org.gvsig.app.project.documents.layout.fframes.FFrameNorthFactory;
69
import org.gvsig.app.project.documents.layout.fframes.FFrameOverView;
70
import org.gvsig.app.project.documents.layout.fframes.FFrameOverViewFactory;
71
import org.gvsig.app.project.documents.layout.fframes.FFramePicture;
72
import org.gvsig.app.project.documents.layout.fframes.FFramePictureFactory;
73
import org.gvsig.app.project.documents.layout.fframes.FFrameScaleBar;
74
import org.gvsig.app.project.documents.layout.fframes.FFrameScaleBarFactory;
75
import org.gvsig.app.project.documents.layout.fframes.FFrameSymbol;
76
import org.gvsig.app.project.documents.layout.fframes.FFrameSymbolFactory;
77
import org.gvsig.app.project.documents.layout.fframes.FFrameTable;
78
import org.gvsig.app.project.documents.layout.fframes.FFrameTableFactory;
79
import org.gvsig.app.project.documents.layout.fframes.FFrameText;
80
import org.gvsig.app.project.documents.layout.fframes.FFrameTextFactory;
81
import org.gvsig.app.project.documents.layout.fframes.FFrameView;
82
import org.gvsig.app.project.documents.layout.fframes.FFrameViewFactory;
83
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFrameBoxDialog;
84
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFrameGraphicsDialog;
85
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFrameGridDialog;
86
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFrameGroupDialog;
87
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFrameLegendDialog;
88
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFrameNorthDialog;
89
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFrameOverViewDialog;
90
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFramePictureDialog;
91
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFrameScaleBarDialog;
92
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFrameTextDialog;
93
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFrameViewDialog;
94
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
95
import org.gvsig.gui.beans.swing.JFileChooser;
96
import org.gvsig.i18n.Messages;
97
import org.gvsig.tools.ToolsLocator;
98
import org.gvsig.tools.extensionpoint.ExtensionPointManager;
99
import org.gvsig.tools.i18n.I18nManager;
100
import org.gvsig.tools.persistence.PersistenceManager;
101
import org.gvsig.tools.persistence.PersistentState;
102
import org.gvsig.tools.persistence.exception.PersistenceException;
103
import org.gvsig.utils.GenericFileFilter;
104
import org.slf4j.Logger;
105
import org.slf4j.LoggerFactory;
106

  
107
/**
108
 * Extension que proporciona controles para crear proyectos nuevos, abrirlos y
109
 * guardarlos. Adem?s los tipos de tabla que soporta el proyecto son a?adidos en
110
 * esta clase.
111
 * 
112
 * @author Fernando Gonz?lez Cort?s
113
 */
114
public class LayoutMainExtension extends Extension {
115

  
116
    private static final Logger logger = LoggerFactory
117
            .getLogger(FFrameView.class);
118

  
119
    private String templatesPath;
120

  
121
    public static final String LAYOUT_TEMPLATE_FILECHOOSER_ID = "LAYOUT_TEMPLATE_FILECHOOSER_ID";
122

  
123
    private void registerIcons() {
124

  
125
        IconThemeHelper.registerIcon("action",
126
                "application-layout-template-open", this);
127
        IconThemeHelper.registerIcon("action",
128
                "application-layout-new", this);
129
        
130
    }
131

  
132
    @Override
133
    public void initialize() {
134
        registerIcons();
135
    }
136

  
137
    @Override
138
    public void postInitialize() {
139
        super.postInitialize();
140
        initializeDocumentActionsExtensionPoint();
141
        registerDocuments();
142
        registerFFrames();
143
        registerContextMenuOptions();
144
    }
145

  
146

  
147
    @Override
148
    public void execute(String actionCommand) {
149
        if ("application-layout-template-open".equals(actionCommand)) {
150
            openLayout();
151
        } else if ("application-layout-new".equals(actionCommand)) { 
152
            newLayout();   
153
        }
154
    }
155

  
156
    private void newLayout() {
157
        ApplicationManager application = ApplicationLocator.getManager();
158
        ProjectManager projectManager = ApplicationLocator.getProjectManager();
159
        I18nManager i18nManager = ToolsLocator.getI18nManager();
160
        Project project = projectManager.getCurrentProject();
161
        
162
        Iterator<? extends Document> documents =
163
            projectManager.createDocumentsByUser(LayoutManager.TYPENAME);
164
        for (; (documents != null) && (documents.hasNext());) {
165
            try {
166
                Document document = documents.next();
167
                project.addDocument(document);
168
                IWindow window = document.getFactory().getMainWindow(document);
169
                if (window == null) {
170
                    application.messageDialog(
171
                            i18nManager.getTranslation("error_opening_the_document"), 
172
                            i18nManager.getTranslation("warning"), 
173
                            JOptionPane.WARNING_MESSAGE
174
                    );
175
                    continue;
176
                }
177
                application.getUIManager().addWindow(
178
                    window,
179
                    MDIManager.ALIGN_FIRST_LINE_END_CASCADE
180
                );
181
                try {
182
                    application.getUIManager().setMaximum(window, true);
183
                } catch (PropertyVetoException e) {
184
                    logger.info("Can't maximize layout.", e);
185
                }
186
                
187
            } catch (Exception e) {
188
                logger.warn("Problems creating a Layout document.",e);
189
            }
190
        }        
191
    }
192
    
193

  
194
    private void openLayout() {
195
        LayoutPanel layout = null;
196

  
197
        if (templatesPath == null) {
198
            Preferences prefs = Preferences.userRoot().node("gvsig.foldering");
199
            templatesPath = prefs.get("TemplatesFolder", null);
200
        }
201

  
202
        JFileChooser jfc = new JFileChooser(LAYOUT_TEMPLATE_FILECHOOSER_ID,
203
                templatesPath);
204
        GenericFileFilter layoutMainExtensionFilter = new GenericFileFilter(
205
                LayoutManager.TEMPLATE_FILE_POINTEXT,
206
                Messages.getText("_Layout_template") + " (*"
207
                        + LayoutManager.TEMPLATE_FILE_POINTEXT + ")");
208
        jfc.addChoosableFileFilter(layoutMainExtensionFilter);
209
        jfc.setFileFilter(layoutMainExtensionFilter);
210

  
211
        if (jfc.showOpenDialog((Component) PluginServices.getMainFrame()) == JFileChooser.APPROVE_OPTION) {
212
            File file = jfc.getSelectedFile();
213
            try {
214
                if (!file.exists()) {
215
                    /*
216
                     * The user has written a file name instead of clicking on
217
                     * one and it does not exist
218
                     */
219
                    File auxfile = new File(file.getPath()
220
                            + LayoutManager.TEMPLATE_FILE_POINTEXT);
221
                    if (!auxfile.exists()) {
222
                        /*
223
                         * Not even this one exists: error
224
                         */
225
                        throw new IOException("File does not exist: "
226
                                + file.getName());
227
                    }
228
                    else {
229
                        file = auxfile;
230
                    }
231
                }
232

  
233
                File xmlFile = new File(file.getAbsolutePath());
234
                FileInputStream is = new FileInputStream(xmlFile);
235

  
236
                PersistenceManager persistenceManager = ToolsLocator
237
                        .getPersistenceManager();
238
                PersistentState persistentState = persistenceManager
239
                        .loadState(is);
240
                layout = (LayoutPanel) persistenceManager
241
                        .create(persistentState);
242

  
243
            }
244
            catch (Exception e) {
245
                String tit = Messages.getText("_Layout_template");
246
                String msg;
247

  
248
                if (e instanceof PersistenceException) {
249
                    msg = Messages.getText("_Bad_format_in_layout_template");
250
                }
251
                else {
252
                    msg = Messages.getText("_Cant_load_layout_template");
253
                }
254

  
255
                msg = msg + ": " + file.getPath();
256
                msg = msg + "\n" + e.getMessage();
257
                logger.warn(msg, e);
258
                JOptionPane.showMessageDialog(ApplicationLocator.getManager()
259
                        .getRootComponent(), msg, tit,
260
                        JOptionPane.ERROR_MESSAGE);
261
            }
262

  
263
            if (layout == null) {
264
                return;
265
            }
266

  
267
            LayoutDocument layoutDocument = (LayoutDocument) layout
268
                    .getDocument();
269
            /*
270
             * (LayoutDocument) ProjectManager.getInstance().createDocument(
271
             * DefaultLayoutManager.TYPENAME, file.getName());
272
             */
273

  
274
            Project p = ApplicationLocator.getManager().getProjectManager()
275
                    .getCurrentProject();
276
            p.addDocument(layoutDocument);
277

  
278
            layout.getLayoutControl().setTool("layoutselect");
279

  
280
            LayoutManager lm = (LayoutManager) layoutDocument.getFactory();
281
            layout.setLayoutManager(lm);
282

  
283
            PluginServices.getMDIManager().addWindow(layout);
284

  
285
        }
286
    }
287

  
288
    private void registerDocuments() {
289
        DefaultLayoutManager.register();
290
    }
291

  
292
    private void registerFFrames() {
293
        DefaultLayoutManager layoutManager = (DefaultLayoutManager) ProjectManager
294
                .getInstance()
295
                .getDocumentManager(DefaultLayoutManager.TYPENAME);
296

  
297
        // Register Frames
298
        layoutManager.registerFrameFactory(new FFrameBasicFactory());
299
        layoutManager.registerFrameFactory(new FFrameGraphicsFactory());
300
        layoutManager.registerFrameFactory(new FFrameGroupFactory());
301
        layoutManager.registerFrameFactory(new FFrameLegendFactory());
302
        layoutManager.registerFrameFactory(new FFrameNorthFactory());
303
        layoutManager.registerFrameFactory(new FFrameOverViewFactory());
304
        layoutManager.registerFrameFactory(new FFramePictureFactory());
305
        layoutManager.registerFrameFactory(new FFrameScaleBarFactory());
306
        layoutManager.registerFrameFactory(new FFrameSymbolFactory());
307
        layoutManager.registerFrameFactory(new FFrameTableFactory());
308
        layoutManager.registerFrameFactory(new FFrameTextFactory());
309
        layoutManager.registerFrameFactory(new FFrameViewFactory());
310
        layoutManager.registerFrameFactory(new FFrameGridFactory());
311

  
312
        // Register FFrameDialogs forms
313
        layoutManager.registerFFrameDialog(
314
                FFrameGraphics.PERSISTENCE_DEFINITION_NAME,
315
                FFrameGraphicsDialog.class);
316
        layoutManager.registerFFrameDialog(
317
                FFrameSymbol.PERSISTENCE_DEFINITION_NAME,
318
                FFrameGraphicsDialog.class);
319
        layoutManager.registerFFrameDialog(
320
                FFrameGroup.PERSISTENCE_DEFINITION_NAME,
321
                FFrameGroupDialog.class);
322
        layoutManager.registerFFrameDialog(
323
                FFrameTable.PERSISTENCE_DEFINITION_NAME, FFrameBoxDialog.class);
324
        layoutManager.registerFFrameDialog(
325
                FFrameLegend.PERSISTENCE_DEFINITION_NAME,
326
                FFrameLegendDialog.class);
327
        layoutManager.registerFFrameDialog(
328
                FFramePicture.PERSISTENCE_DEFINITION_NAME,
329
                FFramePictureDialog.class);
330
        layoutManager.registerFFrameDialog(
331
                FFrameNorth.PERSISTENCE_DEFINITION_NAME,
332
                FFrameNorthDialog.class);
333
        layoutManager.registerFFrameDialog(
334
                FFrameScaleBar.PERSISTENCE_DEFINITION_NAME,
335
                FFrameScaleBarDialog.class);
336
        layoutManager.registerFFrameDialog(
337
                FFrameText.PERSISTENCE_DEFINITION_NAME, FFrameTextDialog.class);
338
        layoutManager.registerFFrameDialog(
339
                FFrameView.PERSISTENCE_DEFINITION_NAME, FFrameViewDialog.class);
340
        layoutManager.registerFFrameDialog(
341
                FFrameOverView.PERSISTENCE_DEFINITION_NAME,
342
                FFrameOverViewDialog.class);
343
        layoutManager.registerFFrameDialog(
344
                FFrameGrid.PERSISTENCE_DEFINITION_NAME, FFrameGridDialog.class);
345

  
346
        FFrame.initializeIcons();
347
        FFrameTable.initializeIcons();
348
    }
349

  
350
    private void registerContextMenuOptions() {
351
        LayoutManager layoutManager = (LayoutManager) ProjectManager
352
                .getInstance().getDocumentManager("project.document.layout");
353

  
354
        layoutManager.registerLayoutMenuAction("Terminate",
355
                TerminateLayoutMenuEntry.class);
356
        layoutManager.registerLayoutMenuAction("Cancel",
357
                CancelLayoutMenuEntry.class);
358
        layoutManager.registerLayoutMenuAction("Copy",
359
                CopyLayoutMenuEntry.class);
360
        layoutManager.registerLayoutMenuAction("Cut", CutLayoutMenuEntry.class);
361
        layoutManager.registerLayoutMenuAction("Paste",
362
                PasteLayoutMenuEntry.class);
363
        layoutManager.registerLayoutMenuAction("Simplify",
364
                SimplifyLayoutMenuEntry.class);
365
        layoutManager.registerLayoutMenuAction("Property",
366
                PropertyLayoutMenuEntry.class);
367
        layoutManager.registerLayoutMenuAction("SelectAll",
368
                SelectAllLayoutMenuEntry.class);
369
        layoutManager.registerLayoutMenuAction("Behind",
370
                BehindLayoutMenuEntry.class);
371
        layoutManager.registerLayoutMenuAction("Before",
372
                BeforeLayoutMenuEntry.class);
373
        layoutManager.registerLayoutMenuAction("Position",
374
                PositionLayoutMenuEntry.class);
375
        layoutManager.registerLayoutMenuAction("Refresh",
376
                RefreshLayoutMenuEntry.class);
377

  
378
    }
379

  
380
    private void initializeDocumentActionsExtensionPoint() {
381
        ExtensionPointManager epMan = ToolsLocator.getExtensionPointManager();
382
        epMan.add(
383
                "DocumentActions_Map",
384
                "Context menu options of the map document list"
385
                        + " in the project window "
386
                        + "(register instances of "
387
                        + "org.gvsig.app.project.AbstractDocumentContextMenuAction)");
388
    }
389

  
390
    @Override
391
    public boolean isEnabled() {
392
        return true;
393
    }
394

  
395
    @Override
396
    public boolean isVisible() {
397
        return true;
398
    }
399
}
tags/org.gvsig.app.document.layout2.app-2.0.92/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.92/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.92/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.92/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.92/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
    }
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff