Revision 38982

View differences:

tags/v2_0_0_Build_2055/extensions/org.gvsig.mkmvnproject/build.xml
1
<project name="gvSIG-build-config" default="mvn-install" xmlns:artifact="antlib:org.apache.maven.artifact.ant">
2

  
3
	<property name="maven.folder" 
4
		location="${basedir}/src/main/resources/maven" />
5
	
6
	<!-- Maven ant tasks registration -->
7
	<path id="maven-ant-tasks.classpath" 
8
		path="${maven.folder}/lib/maven-ant-tasks-2.0.10.jar" />
9
	<typedef resource="org/apache/maven/artifact/ant/antlib.xml" 
10
		uri="antlib:org.apache.maven.artifact.ant"
11
		classpathref="maven-ant-tasks.classpath" />
12
	
13
	<!-- Maven targets -->
14
	<macrodef name="maven">
15
		<attribute name="arg" />
16
		<sequential>
17
			<echo>mvn @{arg}</echo>
18
			<artifact:mvn mavenHome="${maven.folder}" fork="true"
19
				failonerror="true" maxmemory="256M">
20
				<arg line="@{arg}" />
21
				<jvmarg value="-XX:MaxPermSize=64M" />
22
			</artifact:mvn>
23
		</sequential>
24
	</macrodef>
25

  
26
	<!-- Utility targets -->
27
	<target name="cancel">
28
		<fail>User canceled</fail>
29
	</target>
30

  
31
	<target name="mvn-clean" description="Cleans all artifacts">
32
		<maven arg="clean" />
33
	</target>
34

  
35
	<target name="mvn-compile" description="Compiles all source code">
36
		<maven arg="compile" />
37
	</target>
38

  
39
	<target name="mvn-test" description="Launches unit tests">
40
		<maven arg="test" />
41
	</target>
42

  
43
	<target name="mvn-install" description="Compiles and installs">
44
		<maven arg="install" />
45
	</target>
46
	
47
	<target name="mvn-install-ignore-tests" description="Compiles and installs and ignore tests">
48
	        <maven arg="install -Dmaven.test.failure.ignore" />
49
	    </target>
50
	
51
	<target name="mvn-install-without-tests"
52
		description="Compiles and installs without launching tests">
53
		<maven arg="-Dmaven.test.skip=true install" />
54
	</target>
55

  
56
	<target name="mvn-reinstall" 
57
		description="Performs a clean install">
58
		<maven arg="clean install" />
59
	</target>
60

  
61
	<target name="mvn-reinstall-without-tests"
62
		description="Performs a clean install without launching tests">
63
		<maven arg="-Dmaven.test.skip=true clean install" />
64
	</target>
65

  
66
	<target name="mvn-deploy" 
67
		description="Compiles, installs and deploys">
68
		<maven arg="deploy" />
69
	</target>
70

  
71
	<target name="mvn-deploy-release" 
72
			description="Compiles, installs and deploys for release">
73
		<maven arg="-P release deploy" />
74
	</target>
75

  
76
	<target name="mvn-eclipse-clean"
77
		description="Cleans the maven generated eclipse project files">
78
		<maven arg="eclipse:clean" />
79
	</target>
80

  
81
	<target name="mvn-eclipse-eclipse"
82
		description="Generates an eclipse project configuration from the pom.xml">
83
		<maven arg="eclipse:eclipse" />
84
	</target>
85

  
86
	<target name="mvn-site"
87
		description="Generates the project site documentation">
88
		<maven arg="site" />
89
	</target>
90
</project>
0 91

  
tags/v2_0_0_Build_2055/extensions/org.gvsig.mkmvnproject/distribution/distribution.xml
1
<assembly>
2
	<id>distribution</id>
3
	<formats>
4
		<format>dir</format>
5
	</formats>
6
	<fileSets>
7
		<!-- Estructure for the extension -->
8
		<fileSet>
9
			<directory>src/main/resources/scripts</directory>
10
			<outputDirectory>${extension.install.dir.name}/scripts</outputDirectory>
11
		</fileSet>
12
		<fileSet>
13
			<directory>src/main/resources/compilationcheck</directory>
14
			<outputDirectory>${extension.install.dir.name}/compilationcheck</outputDirectory>
15
		</fileSet>
16
		<fileSet>
17
			<directory>src/main/resources/config</directory>
18
			<outputDirectory>${extension.install.dir.name}</outputDirectory>
19
		</fileSet>
20
		<fileSet>
21
			<directory>target/templates-zips</directory>
22
			<outputDirectory>${extension.install.dir.name}/templates
23
			</outputDirectory>
24
		</fileSet>
25
	</fileSets>
26
    <files>
27
        <file>
28
            <source>package.info</source>
29
            <outputDirectory>${extension.install.dir.name}
30
            </outputDirectory>
31
        </file>
32
    </files>
33
	<dependencySets>
34
		<dependencySet>
35
			<outputDirectory>${extension.install.dir.name}/${library-dir}
36
			</outputDirectory>
37
			<includes>
38
				<include>org.gvsig:org.gvsig.mkmvnproject</include>
39
				<include>ant-contrib:ant-contrib</include>
40
				<include>org.apache.ant:ant</include>
41
				<include>org.apache.ant:ant-launcher</include>
42
				<include>org.apache.ant:ant-nodeps</include>
43
                <include>org.apache.ant:ant-apache-oro</include>
44
				<include>com.sardak:antform</include>
45
				<include>org.tigris.antelope:antelopetasks</include>				
46
			</includes>
47
		</dependencySet>
48
	</dependencySets>
49
</assembly>
0 50

  
tags/v2_0_0_Build_2055/extensions/org.gvsig.mkmvnproject/buildNumber.properties
1
#maven.buildNumber.plugin properties file
2
#Tue Oct 02 13:26:46 CEST 2012
3
buildNumber=2068
tags/v2_0_0_Build_2055/extensions/org.gvsig.mkmvnproject/src/main/java/org/gvsig/mkmvnproject/MakeMavenProjectExtension.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.mkmvnproject;
23

  
24
import java.awt.Component;
25
import java.awt.GridBagConstraints;
26
import java.io.File;
27
import java.io.IOException;
28
import java.net.URL;
29

  
30
import javax.swing.JOptionPane;
31

  
32
import org.apache.tools.ant.BuildListener;
33
import org.apache.tools.ant.DefaultLogger;
34
import org.apache.tools.ant.Project;
35
import org.apache.tools.ant.ProjectHelper;
36
import org.slf4j.Logger;
37
import org.slf4j.LoggerFactory;
38

  
39
import org.gvsig.andami.PluginServices;
40
import org.gvsig.andami.messages.NotificationManager;
41
import org.gvsig.andami.plugins.Extension;
42
import org.gvsig.andami.ui.mdiManager.IWindow;
43
import org.gvsig.i18n.Messages;
44
import org.gvsig.mkmvnproject.gui.CreatePluginConsoleWindow;
45
import org.gvsig.mkmvnproject.gui.settings.PlatformPropertiesWindow;
46

  
47
/**
48
 * Extension to launch the project creation from templates.
49
 * 
50
 * @author gvSIG team
51
 * @version $Id$
52
 */
53
public class MakeMavenProjectExtension extends Extension {
54

  
55
    private static final String ANT_BUILD_FILE = "mkmvnproject.xml";
56
    private static final String ANT_CHECK_JDK = "checkjdk.xml";
57

  
58
	private static final String ANT_TARGET = "mkproject";
59
	
60
	public static final String GVSIG_PLATFORM_PROPERTIES_FILE_NAME =
61
	    ".gvsig.platform.properties";
62

  
63
	private static final Logger LOG = LoggerFactory
64
			.getLogger(MakeMavenProjectExtension.class);
65

  
66
	private boolean enabled = true;
67

  
68
	private final Object lock = new Object();
69

  
70
	public void execute(String actionCommand) {
71
	    
72
	    if (!checkJDK()) {
73
	        return;
74
	    }
75

  
76
	    if (!checkPlatformProperties()) {
77
	        return;
78
	    }
79
	    
80
        // ==========================================================
81
		// TODO: add support to parallel executions in Andami??
82

  
83
        // Create messages console
84
	    CreatePluginConsoleWindow console = null;
85

  
86
        if (console == null) {
87
            try {
88
                console = new CreatePluginConsoleWindow();
89
            } catch (IOException e) {
90
                NotificationManager.addWarning("Error creating the console", e);
91
            }
92
        }
93
        if (console != null) {
94
            PluginServices.getMDIManager().addWindow(console, GridBagConstraints.LAST_LINE_START);
95
        }
96

  
97
		try {
98
			// Disable extension so it can't be executed again.
99
			synchronized (lock) {
100
				enabled = false;
101
			}
102
			new CreatePluginThread(console).start();
103
		} finally {
104
			synchronized (lock) {
105
				// create plugin process finish. Enable extension.
106
				enabled = true;
107
			}
108
		}
109
	}
110

  
111
	/**
112
	 * Checks existence of file:
113
	 * 
114
	 * USER_HOME/.gvsig.platform.properties
115
	 * 
116
	 * If not present, show text area with suggested content.
117
	 * 
118
     * @return whether the mentioned file is present or the
119
     * user has created it here and accepts to continue.
120
     *  
121
     */
122
    private boolean checkPlatformProperties() {
123
        
124
        String user_home = System.getProperty("user.home");
125
        File the_file = new File(
126
            user_home +
127
            File.separator +
128
            GVSIG_PLATFORM_PROPERTIES_FILE_NAME);
129

  
130
        Component parent_window = getActiveWindowComponent();
131

  
132
        try {
133
            if (the_file.exists()) {
134
                // ok file exists
135
                LOG.info("Found platform properties file: "
136
                    + the_file.getAbsolutePath());
137
                return true;
138
            }
139
            
140
            boolean is_windows = isThisWindows();
141
            PlatformPropertiesWindow ppw = new PlatformPropertiesWindow(
142
                the_file, is_windows);
143
            PluginServices.getMDIManager().addCentredWindow(ppw);
144
            // it's a modal dialog
145
            return ppw.validSettings();
146
            
147
        } catch (Exception ex) {
148
            
149
            String _msg =
150
                Messages.getText("_Error_while_checking_platform_properties")
151
                + "\n\n[ " + ex.getMessage() + " ]";
152
            String _tit = Messages.getText(
153
                "_Checking_platform_properties");
154
            JOptionPane.showMessageDialog(
155
                parent_window,
156
                _msg, _tit,
157
                JOptionPane.ERROR_MESSAGE);
158
        }
159
        return false;
160
        
161
    }
162

  
163

  
164
    /**
165
     * @return whether we are running on a windows system
166
     */
167
    private boolean isThisWindows() {
168
        String os = System.getProperty("os.name").toLowerCase();
169
        return (os.indexOf("win") >= 0);
170
    }
171

  
172
    /**
173
     * Check and possibly show JDK and JAVA_HOME settings and
174
     * prompt user with suggestion.
175
     * 
176
     * @return whether JDK is detected or user accepts to
177
     * continue anyway
178
     */
179
    private boolean checkJDK() {
180
        
181
        boolean this_is_jdk = false;
182
        try {
183
            this_is_jdk = jdkAvailable();
184
        } catch (Exception ex) {
185
            LOG.info("While searching for JDK : " + ex.getMessage(), ex);
186
            this_is_jdk = false;
187
        }
188
        
189
        if (this_is_jdk) {
190
            return true;
191
        }
192
        
193
        String env_j_h = System.getenv("JAVA_HOME");
194
        
195
        String jdk_str = null;
196
        if (this_is_jdk) {
197
            jdk_str = Messages.getText("_gvSIG_is_running_on_JDK");
198
        } else {
199
            jdk_str = Messages.getText("_gvSIG_is_not_running_on_JDK");
200
        }
201
        
202
        String jh_str = null;
203
        if (env_j_h == null) {
204
            jh_str = Messages.getText("_JAVA_HOME_is_not_set");
205
        } else {
206
            jh_str = Messages.getText("_JAVA_HOME_is_set_to")
207
                + " '" + env_j_h + "'";
208
        }
209
        
210
        String recomm = "";
211
        if (true) { // !this_is_jdk && env_j_h == null) {
212
            recomm = "\n\n"
213
                + Messages.getText("_Requirements_for_this_plugin") + ":\n\n"
214
                + "- " + Messages.getText("_On_Linux_make_JAVA_HOME_point_to_JDK_1_5_higher");
215
            recomm = recomm + ".    \n- "
216
            + Messages.getText("_On_Windows_run_JDK_use_devel_exe") + ".";
217
        }
218
        
219
        String tot_msg = Messages.getText("_Detected_settings") + ":"
220
            + "\n\n"
221
            + "- " + jdk_str + "\n"
222
            + "- " + jh_str + "     " + recomm + "\n\n"
223
                + Messages.getText("_Continue_question");
224
            
225
        int opt = JOptionPane.showConfirmDialog(
226
            null, // getActiveWindowComponent(),
227
            tot_msg,
228
            Messages.getText("_Make_maven_project_plugin") + " - " + 
229
            Messages.getText("_Searching_JDK"),
230
            JOptionPane.YES_NO_OPTION,
231
            (recomm.length() == 0) ?
232
                JOptionPane.INFORMATION_MESSAGE : JOptionPane.WARNING_MESSAGE
233
            );
234
        
235
        return (opt == JOptionPane.YES_OPTION);
236
    }
237

  
238
    /**
239
     * @return
240
     */
241
    private Component getActiveWindowComponent() {
242
        
243
        IWindow iw = PluginServices.getMDIManager().getActiveWindow();
244
        if (iw instanceof Component) {
245
            return (Component) iw;
246
        } else {
247
            return null;
248
        }
249
    }
250

  
251

  
252
    private boolean jdkAvailable() throws Exception {
253
        
254
        ClassLoader loader = this.getClass().getClassLoader();
255
        URL class_file_url = loader.getResource("compilationcheck/DummyClass.class");
256
        File class_file = null;
257
        
258
        // deleting compiled test file if existed
259
        if (class_file_url != null) {
260
            class_file = new File(class_file_url.getFile());
261
            if (class_file.exists()) {
262
                class_file.delete();
263
            }
264
        }
265
        
266
        URL build = loader.getResource("scripts/" + ANT_CHECK_JDK);
267

  
268
        String execut = null;
269
        /*
270
        // first attempt: javac from JAVA_HOME
271
        execut =
272
            System.getenv().get("JAVA_HOME")
273
            + File.separator + "bin" + File.separator + "javac";
274
        
275
        if (execut != null) {
276
            this.runScript(build, "default", null, "executable", execut);
277
            class_file_url = loader.getResource("compilationcheck/DummyClass.class");
278
            if (class_file_url != null) {
279
                // OK, test file is not compiled
280
                return true;
281
            }
282
        }
283
        */
284
        
285
        // second attempt: java.home (jre)
286
        execut = System.getProperty("java.home");
287
        int ind = execut.lastIndexOf(File.separator);
288
        // one up, then bin/javac
289
        execut = execut.substring(0, ind)
290
            + File.separator
291
            + "bin" + File.separator + "javac";
292
        
293
        this.runScript(build, "default", null, "executable", execut);
294
        class_file_url = loader.getResource("compilationcheck/DummyClass.class");
295
        // if test file not compiled, then false
296
        return (class_file_url != null);
297
    }
298

  
299
    /**
300
	 * Thread to launch the ant base plugin creation project.
301
	 * 
302
	 * @author gvSIG Team
303
	 * @version $Id$
304
	 */
305
	private final class CreatePluginThread extends Thread {
306

  
307
		private final CreatePluginConsoleWindow console;
308

  
309
		/**
310
		 * Constructor.
311
		 * 
312
		 * @param console
313
		 */
314
		public CreatePluginThread(CreatePluginConsoleWindow console) {
315
			this.console = console;
316
			setName("Create plugin execution thread");
317
			setDaemon(true);
318
		}
319

  
320
		@Override
321
		public void run() {
322
			DefaultLogger log = new DefaultLogger();
323
			log.setMessageOutputLevel(Project.MSG_INFO);
324

  
325
			if (console != null) {
326
				log.setErrorPrintStream(console.getErrorPrintStream());
327
				log.setOutputPrintStream(console.getPrintStream());
328
			} else {
329
				LOG.warn("Console window not available, will use the default console for Ant");
330
				log.setErrorPrintStream(System.err);
331
				log.setOutputPrintStream(System.out);
332
			}
333

  
334
			
335
			
336
            ClassLoader loader = this.getClass().getClassLoader();
337
            URL build = loader.getResource("scripts/" + ANT_BUILD_FILE);
338
            runScript(build, ANT_TARGET, log);
339
		}
340
	}
341

  
342

  
343
	private void runScript(
344
	        URL build,
345
	        String target,
346
	        BuildListener blistener) {
347
	    
348
        runScript(build, target, blistener, null, null);
349
	    
350
	}
351

  
352
	private void runScript(
353
	    URL build,
354
	    String target,
355
	    BuildListener blistener,
356
	    String prop, String val) {
357
	    
358
	    LOG.info("Starting runScript:\n"
359
	        + "    build = " + build.toString() + "\n"
360
	        + "    property name = " + prop + "\n"
361
            + "    property value = " + val);
362
	        
363

  
364
        File file = new File(build.getFile());
365

  
366
        final Project ant = new Project();
367
        if (blistener != null) {
368
            ant.addBuildListener(blistener);
369
        }
370
        ant.setUserProperty("ant.file", file.getAbsolutePath());
371
        
372
        if (prop != null && val != null) {
373
            ant.setUserProperty(prop, val);
374
        }
375
        
376
        ant.init();
377
        ProjectHelper.getProjectHelper().parse(ant, file);
378

  
379
        LOG.info("Starting ant task with the file {} and the target {}",
380
                file, target);
381
        ant.executeTarget(target);
382
	}
383

  
384
	public void initialize() {
385
		// Nothing to do
386
	}
387

  
388
	public boolean isEnabled() {
389
		return enabled;
390
	}
391

  
392
	public boolean isVisible() {
393
		return true;
394
	}
395
	
396

  
397
}
0 398

  
tags/v2_0_0_Build_2055/extensions/org.gvsig.mkmvnproject/src/main/java/org/gvsig/mkmvnproject/package.html
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
<html xmlns="http://www.w3.org/1999/xhtml">
4
<head>
5
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6
<title>org.gvsig.fortunecookies package documentation</title>
7
</head>
8
<body>
9

  
10
	<p>gvSIG Project creation from templates plugins.</p>
11
	
12
	<p>
13
	It allows to create new development projects for gvSIG from templates.
14
	</p>
15

  
16
</body>
17
</html>
tags/v2_0_0_Build_2055/extensions/org.gvsig.mkmvnproject/src/main/java/org/gvsig/mkmvnproject/gui/CreatePluginConsoleWindow.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.mkmvnproject.gui;
23

  
24
import java.awt.Dimension;
25
import java.io.IOException;
26

  
27
import org.gvsig.andami.ui.mdiManager.IWindow;
28
import org.gvsig.andami.ui.mdiManager.IWindowListener;
29
import org.gvsig.andami.ui.mdiManager.WindowInfo;
30

  
31
/**
32
 * A gvSIG window which shows the execution log messages of the create plugin
33
 * process.
34
 * 
35
 * @author gvSIG Team
36
 * @version $Id$
37
 */
38
public class CreatePluginConsoleWindow extends CreatePluginConsolePanel
39
		implements IWindow, IWindowListener {
40

  
41
	private static final long serialVersionUID = -5589080107545290284L;
42

  
43
	private WindowInfo info;
44

  
45
	private Object profile = WindowInfo.EDITOR_PROFILE;
46

  
47
	/**
48
	 * Constructor.
49
	 * 
50
	 * @throws IOException
51
	 *             if there is an error creating the console streams
52
	 */
53
	public CreatePluginConsoleWindow() throws IOException {
54
		super();
55
		initializeWindow();
56
	}
57

  
58
	/**
59
	 * Constructor.
60
	 * 
61
	 * @param isDoubleBuffered
62
	 *            if the panel must be double buffered.
63
	 * @throws IOException
64
	 *             if there is an error creating the console streams
65
	 */
66
	public CreatePluginConsoleWindow(boolean isDoubleBuffered) throws IOException {
67
		super(isDoubleBuffered);
68
		initializeWindow();
69
	}
70

  
71
	/**
72
	 * Initializes the window.
73
	 */
74
	private void initializeWindow() {
75
		Dimension dimension = new Dimension(600, 300);
76
		setSize(dimension);
77
		int code = WindowInfo.ICONIFIABLE | WindowInfo.MAXIMIZABLE
78
				| WindowInfo.RESIZABLE | WindowInfo.MODELESSDIALOG;
79
		profile = WindowInfo.EDITOR_PROFILE;
80
		info = new WindowInfo(code);
81
		info.setTitle("Console");
82
		info.setMinimumSize(dimension);
83
	}
84

  
85
	public WindowInfo getWindowInfo() {
86
		return info;
87
	}
88

  
89
	public Object getWindowProfile() {
90
		return profile;
91
	}
92

  
93
	public void windowActivated() {
94
		// Nothing to do
95
	}
96

  
97
	public void windowClosed() {
98
		super.closeConsole();
99
	}
100

  
101
}
tags/v2_0_0_Build_2055/extensions/org.gvsig.mkmvnproject/src/main/java/org/gvsig/mkmvnproject/gui/settings/PlatformPropertiesWindow.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2012 gvSIG Association
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.mkmvnproject.gui.settings;
24

  
25
import java.awt.BorderLayout;
26
import java.awt.Font;
27
import java.awt.GridBagConstraints;
28
import java.awt.GridBagLayout;
29
import java.awt.GridLayout;
30
import java.awt.Insets;
31
import java.awt.event.ActionEvent;
32
import java.awt.event.ActionListener;
33
import java.io.File;
34
import java.io.FileOutputStream;
35
import java.io.IOException;
36

  
37
import javax.swing.JButton;
38
import javax.swing.JLabel;
39
import javax.swing.JOptionPane;
40
import javax.swing.JPanel;
41
import javax.swing.JScrollBar;
42
import javax.swing.JScrollPane;
43
import javax.swing.JTextArea;
44
import javax.swing.event.DocumentEvent;
45
import javax.swing.event.DocumentListener;
46

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

  
50
import org.gvsig.andami.PluginServices;
51
import org.gvsig.andami.ui.mdiManager.IWindow;
52
import org.gvsig.andami.ui.mdiManager.WindowInfo;
53
import org.gvsig.i18n.Messages;
54

  
55

  
56
/**
57
 * This dialog lets the user write the file .gvsig.platform.properties
58
 * 
59
 * @author jldominguez
60
 *
61
 */
62
public class PlatformPropertiesWindow extends JPanel
63
implements IWindow, ActionListener, DocumentListener {
64
    
65
    private static final Logger logger =
66
        LoggerFactory.getLogger(PlatformPropertiesWindow.class);
67
    
68
    private WindowInfo winfo = null;
69
    private File targetFile = null;
70
    private boolean isWindows = false;
71
    
72
    private JPanel northPanel = null;
73
    
74
    private JTextArea contentArea = null;
75
    
76
    private JPanel southPanel = null;
77
    private JButton saveButton = null;
78
    private JButton suggButton = null;
79
    private JButton okButton = null;
80
    private JButton cancelButton = null;
81
    
82
    private boolean validSettings = false; 
83
    
84
    public PlatformPropertiesWindow(
85
        File non_existing_file, boolean is_win) {
86
        
87
        targetFile = non_existing_file;
88
        isWindows = is_win;
89
        init();
90
    }
91

  
92
    private void init() {
93
        
94
        this.setLayout(new BorderLayout());
95
        
96
        northPanel = new JPanel(new GridBagLayout());
97
        GridBagConstraints c = new GridBagConstraints();  
98
        c.insets = new Insets(1, 10, 1, 10);
99
        c.weightx = 0.5; // 
100
        c.fill = GridBagConstraints.HORIZONTAL;
101
        c.gridx = 0;
102
        
103
        c.gridy = 0;
104
        northPanel.add(new JLabel(" "), c);
105
        c.gridy = 1;
106
        northPanel.add(new JLabel(Messages.getText(
107
            "_Mandatory_platform_properties_file_not_found")), c);
108
        c.gridy = 2;
109
        northPanel.add(new JLabel(Messages.getText(
110
            "_Use_this_text_editor_to_write_it")), c);
111
        c.gridy = 3;
112
        northPanel.add(new JLabel(" "), c);
113
        // =============================================
114
        // =============================================
115
        southPanel = new JPanel();
116
        southPanel.setLayout(new GridLayout(1, 5, 8, 4));
117
        // ------------
118
        southPanel.add(getSaveButton());
119
        southPanel.add(getSuggButton());
120
        // ------------
121
        southPanel.add(new JLabel(" "));
122
        // ------------
123
        southPanel.add(getOkButton());
124
        southPanel.add(getCancelButton());
125
        // =============================================
126
        
127
        this.add(northPanel, BorderLayout.NORTH);
128
        
129
        JScrollPane scroll = new JScrollPane();
130
        scroll.setViewportView(getContentArea());
131
        scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
132
        scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
133
        this.add(scroll, BorderLayout.CENTER);
134
        
135
        JPanel south2 = new JPanel(new GridBagLayout());
136
        GridBagConstraints cs = new GridBagConstraints();
137
        cs.insets = new Insets(15,15,15,15);
138
        south2.add(southPanel, cs);
139
        
140
        this.add(south2, BorderLayout.SOUTH);
141
    }
142

  
143
    private JTextArea getContentArea() {
144
        
145
        if (contentArea == null) {
146
            contentArea = new JTextArea();
147
            loadSuggested(contentArea);
148
            contentArea.getDocument().addDocumentListener(this);
149
        }
150
        return contentArea;
151
    }
152

  
153
    private JButton getCancelButton() {
154
        if (cancelButton == null) {
155
            cancelButton = new JButton(Messages.getText("_Cancel"));
156
            cancelButton.addActionListener(this);
157
        }
158
        return cancelButton;
159
    }
160

  
161
    private JButton getSuggButton() {
162
        if (suggButton == null) {
163
            suggButton = new JButton(Messages.getText("_Suggested"));
164
            suggButton.addActionListener(this);
165
        }
166
        return suggButton;
167
    }
168

  
169
    private JButton getOkButton() {
170
        if (okButton == null) {
171
            okButton = new JButton(Messages.getText("_Accept"));
172
            okButton.addActionListener(this);
173
            okButton.setEnabled(false);
174
        }
175
        return okButton;
176
    }
177

  
178
    private JButton getSaveButton() {
179
        if (saveButton == null) {
180
            saveButton = new JButton(Messages.getText("_Save"));
181
            Font fnt = saveButton.getFont();
182
            fnt = fnt.deriveFont(Font.BOLD);
183
            saveButton.setFont(fnt);
184
            saveButton.addActionListener(this);
185
        }
186
        return saveButton;
187
    }
188

  
189
    // ===================================================
190
    // ===================================================
191

  
192
    public WindowInfo getWindowInfo() {
193
        if (winfo == null) {
194
            winfo = new WindowInfo(WindowInfo.MODALDIALOG);
195
            winfo.setWidth(550);
196
            winfo.setHeight(350);
197
            winfo.setTitle(
198
                Messages.getText("_Checking_platform_properties"));
199
        }
200
        return winfo;
201
    }
202

  
203
    public Object getWindowProfile() {
204
        return WindowInfo.DIALOG_PROFILE;
205
    }
206
    
207
    public static final String SUGGESTED_WINDOWN_CONTENT =
208
        "native_platform=win\n" +
209
        "native_distribution=nt\n" +
210
        "native_compiler=vs8\n" +
211
        "native_arch=i386\n" +
212
        "native_libraryType=dynamic";
213
    
214
    public static final String SUGGESTED_NON_WINDOWS_CONTENT =
215
            "native_platform=linux\n" +
216
            "native_distribution=all\n" +
217
            "native_compiler=gcc4\n" +
218
            "native_arch=i386\n" +
219
            "native_libraryType=dynamic";
220

  
221

  
222
    public void actionPerformed(ActionEvent e) {
223
        
224
        Object src = e.getSource();
225
        if (src == getOkButton()) {
226
            if (getSaveButton().isEnabled()) {
227
                if (!userAcceptsNotSaving()) {
228
                    return;
229
                }
230
            }
231
            validSettings = true;
232
            PluginServices.getMDIManager().closeWindow(this);
233
        }
234
        
235
        if (src == getCancelButton()) {
236
            validSettings = false;
237
            PluginServices.getMDIManager().closeWindow(this);
238
        }
239
        
240
        if (src == getSaveButton()) {
241
            if (saveContent()) {
242
                this.getSaveButton().setEnabled(false);
243
            }
244
            this.refreshOkButton();
245
        }
246
        
247
        if (src == getSuggButton()) {
248
            loadSuggested(getContentArea());
249
            this.getSaveButton().setEnabled(true);
250
        }
251
        
252
    }
253

  
254

  
255
    /**
256
     * @return
257
     */
258
    private boolean userAcceptsNotSaving() {
259
        
260
        String _msg =
261
            Messages.getText("_There_are_unsaved_changes_Continue_question");
262
        String _tit =
263
            Messages.getText("_Not_saved");
264
        int usr_opt = JOptionPane.showConfirmDialog(
265
            this, _msg, _tit, JOptionPane.YES_NO_OPTION,
266
            JOptionPane.WARNING_MESSAGE);
267
        return (usr_opt == JOptionPane.YES_OPTION);
268
    }
269

  
270
    private boolean saveContent() {
271
        
272
        try {
273
            if (targetFile.exists()) {
274
                targetFile.delete();
275
            }
276
            targetFile.createNewFile();
277
            
278
            FileOutputStream fos = new FileOutputStream(targetFile);
279
            String contnt = getContentArea().getText();
280
            fos.write(contnt.getBytes());
281
            fos.flush();
282
            fos.close();
283
            return true;
284
        } catch (IOException ioe) {
285
            logger.info("While writing file: " + ioe.getMessage(), ioe);
286
            String _msg = Messages.getText("_Unable_to_store_file")
287
                + ": " + targetFile.getAbsolutePath();
288
            String _tit = Messages.getText("_Error");
289
            JOptionPane.showMessageDialog(
290
                this, _msg, _tit, JOptionPane.ERROR_MESSAGE);
291
            return false;
292
        }
293
        
294
    }
295

  
296
    private void loadSuggested(JTextArea ta) {
297

  
298
        if (isWindows) {
299
            ta.setText(SUGGESTED_WINDOWN_CONTENT);
300
        } else {
301
            ta.setText(SUGGESTED_NON_WINDOWS_CONTENT);
302
        }
303
    }
304

  
305
    public void insertUpdate(DocumentEvent e) {
306
        this.getSaveButton().setEnabled(true);
307
    }
308

  
309
    public void removeUpdate(DocumentEvent e) {
310
        this.getSaveButton().setEnabled(true);
311
    }
312

  
313
    public void changedUpdate(DocumentEvent e) {
314
        // should not be called because this text area is simple
315
    }
316
    
317
    public boolean validSettings() {
318
        return validSettings;
319
    }
320
    
321
    private void refreshOkButton() {
322
        this.getOkButton().setEnabled(targetFile.exists());
323
    }
324

  
325
}
tags/v2_0_0_Build_2055/extensions/org.gvsig.mkmvnproject/src/main/java/org/gvsig/mkmvnproject/gui/CreatePluginConsolePanel.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.mkmvnproject.gui;
23

  
24
import java.awt.BorderLayout;
25
import java.awt.Color;
26
import java.awt.Dimension;
27
import java.io.BufferedReader;
28
import java.io.IOException;
29
import java.io.InputStreamReader;
30
import java.io.PipedInputStream;
31
import java.io.PipedOutputStream;
32
import java.io.PrintStream;
33

  
34
import javax.swing.JPanel;
35
import javax.swing.JScrollPane;
36
import javax.swing.JTextArea;
37
import javax.swing.SwingUtilities;
38

  
39
import org.slf4j.Logger;
40
import org.slf4j.LoggerFactory;
41

  
42
/**
43
 * A panel which shows the execution log messages of the create plugin process.
44
 * 
45
 * @author gvSIG Team
46
 * @version $Id$
47
 */
48
public class CreatePluginConsolePanel extends JPanel {
49

  
50
	private static final long serialVersionUID = -7213048219847956909L;
51

  
52
	private static final Logger logger = LoggerFactory
53
			.getLogger(CreatePluginConsolePanel.class);
54

  
55
	private JTextArea console;
56

  
57
	private PrintStream printStream;
58
	private PipedOutputStream pipedos;
59
	private PipedInputStream pipedis;
60
	private Thread consoleThread;
61

  
62
	/**
63
	 * Constructor.
64
	 * 
65
	 * @throws IOException
66
	 *             if there is an error creating the console streams
67
	 */
68
	public CreatePluginConsolePanel() throws IOException {
69
		super();
70
		initialize();
71
	}
72

  
73
	/**
74
	 * Constructor.
75
	 * 
76
	 * @param isDoubleBuffered
77
	 *            if the panel must be double buffered.
78
	 * @throws IOException
79
	 *             if there is an error creating the console streams
80
	 */
81
	public CreatePluginConsolePanel(boolean isDoubleBuffered)
82
			throws IOException {
83
		super(isDoubleBuffered);
84
		initialize();
85
	}
86

  
87
	/**
88
	 * Initializes the panel GUI.
89
	 * 
90
	 * @throws IOException
91
	 */
92
	private void initialize() throws IOException {
93
		Dimension dimension = new Dimension(600, 200);
94
		setSize(dimension);
95
		setLayout(new BorderLayout());
96

  
97
		console = new JTextArea();
98
		console.setEditable(false);
99
		// console.setColumns(20);
100
		// console.setRows(5);
101
		console.setBackground(Color.WHITE);
102
		console.setLineWrap(true);
103
		console.setWrapStyleWord(true);
104

  
105
		JScrollPane consoleScrollPane = new JScrollPane(console);
106
		add(consoleScrollPane, BorderLayout.CENTER);
107

  
108
		pipedis = new PipedInputStream();
109

  
110
		pipedos = new PipedOutputStream(pipedis);
111

  
112
		printStream = new PrintStream(pipedos);
113
		
114
        logger.info("===================================");
115
        logger.info("= Opening plugin creation console =");
116
        logger.info("===================================");
117

  
118
		consoleThread = new ConsoleThread(pipedis, console);
119
		consoleThread.start();
120
	}
121

  
122
	/**
123
	 * Returns a {@link PrintStream} which allows to write messages to the
124
	 * console.
125
	 * 
126
	 * @return a {@link PrintStream} which allows to write messages to the
127
	 *         console
128
	 */
129
	public PrintStream getPrintStream() {
130
		return printStream;
131
	}
132

  
133
	/**
134
	 * Returns a {@link PrintStream} which allows to write error messages to the
135
	 * console.
136
	 * 
137
	 * @return a {@link PrintStream} which allows to write error messages to the
138
	 *         console
139
	 */
140
	public PrintStream getErrorPrintStream() {
141
		return getPrintStream();
142
	}
143

  
144
	/**
145
	 * Closes the console. Once this method is called, any more calls to the
146
	 * console {@link PrintStream} will throw an exception.
147
	 */
148
	public void closeConsole() {
149
	    
150
        logger.info("===================================");
151
        logger.info("= Closing plugin creation console =");
152
        logger.info("===================================");
153
	    
154
		printStream.flush();
155
		printStream.close();
156
		try {
157
			pipedos.close();
158
			pipedis.close();
159
			// Wait for the thread to finish
160
			consoleThread.join(500);
161
		} catch (IOException e) {
162
		    logger.warn("Error closing the internal piped streams", e);
163
		} catch (InterruptedException e) {
164
			// Nothing special to do
165
		    logger.debug("Console thread interrupted while waiting to finish", e);
166
		}
167
	}
168

  
169
	private static final class ConsoleThread extends Thread {
170

  
171
		private final PipedInputStream pipedis;
172
		private final JTextArea console;
173

  
174
		/**
175
		 * Constructor.
176
		 */
177
		public ConsoleThread(PipedInputStream pipedis, JTextArea console) {
178
			super("Create plugin console update thread");
179
			setDaemon(true);
180
			this.pipedis = pipedis;
181
			this.console = console;
182
		}
183

  
184
		@Override
185
		public void run() {
186
			try {
187
				BufferedReader reader = new BufferedReader(
188
						new InputStreamReader(pipedis));
189
				String line;
190
				while ((line = reader.readLine()) != null) {
191
				    // =========== Writing lines to log too 
192
		            logger.info(line);
193
                    // =====================================
194
					SwingUtilities.invokeLater(new ConsoleUpdateRunnable(
195
							console, line));
196
				}
197
				logger.debug("Console input stream end, finish reading");
198
				reader.close();
199
			} catch (IOException e) {
200
			    logger.warn("Error reading from the console string", e);
201
			}
202
		}
203

  
204
	}
205

  
206
	/**
207
	 * Runnable used to update the console text field.
208
	 * 
209
	 * @author gvSIG Team
210
	 * @version $Id$
211
	 */
212
	private static final class ConsoleUpdateRunnable implements Runnable {
213
		private final String newLine;
214
		private final JTextArea console;
215

  
216
		/**
217
		 * Constructor.
218
		 */
219
		public ConsoleUpdateRunnable(JTextArea console, String newLine) {
220
			this.console = console;
221
			this.newLine = newLine;
222
		}
223

  
224
		public void run() {
225
			console.append(newLine);
226
			console.append("\n");
227
		}
228
	}
229
}
tags/v2_0_0_Build_2055/extensions/org.gvsig.mkmvnproject/src/main/resources/scripts/landregistryviewer.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<project name="gvSIG-make-maven-project" default="mkproject-build" basedir=".">
3

  
4
	<!-- Get current file location folder -->
5
	<dirname property="gvSIG-make-maven-project.basedir" file="${ant.file.gvSIG-make-maven-project}" />
6

  
7
	<!-- Libraries folder in the gvSIG extension -->
8
	<property name="lib.folder" location="${gvSIG-make-maven-project.basedir}/../lib" />
9
	<!-- Templates folder in the gvSIG extension -->
10
	<property name="templates.folder" location="${gvSIG-make-maven-project.basedir}/../templates" />
11

  
12
	<property name="gvsiglogo" location="${basedir}/../gvSIG.png" />
13

  
14
	<!-- Load some ant external utility tasks -->
15
	<property name="antform.lib" location="${lib.folder}/antform-2.0.jar" />
16
	<property name="antcontrib.lib" location="${lib.folder}/ant-contrib-1.0b3.jar" />
17
	<property name="antelope.lib" location="${lib.folder}/antelopetasks-3.2.10.jar" />
18

  
19
	<taskdef resource="net/sf/antcontrib/antlib.xml">
20
		<classpath>
21
			<pathelement location="${antcontrib.lib}" />
22
		</classpath>
23
	</taskdef>
24

  
25
	<taskdef name="antform" classname="com.sardak.antform.AntForm" classpath="${antform.lib}" />
26

  
27
	<taskdef name="antmenu" classname="com.sardak.antform.AntMenu" classpath="${antform.lib}" />
28

  
29
	<taskdef name="stringutil" classname="ise.antelope.tasks.StringUtilTask" classpath="${antelope.lib}" />
30

  
31
	<target name="mkproject-build-cancelled">
32
		<antform title="Project creation cancelled" width="${form.width}" image="${gvsiglogo}">
33
			<textProperty label="" editable="false" columns="40" property="form.title" />
34
			<label>Creation cancelled.</label>
35
			<separator />
36
			<controlbar>
37
				<button type="cancel" label=" Close " />
38
			</controlbar>
39
		</antform>
40
	</target>
41

  
42
	<target name="mkproject-build">
43
		<echo>
44
  Project name: "${project.name}"
45
  Project name capitalized: "${project.name.capitalized}"
46
  Project name lowercase: ${project.name.lowercase}"
47
  Group id: "${project.group.id}"
48
  ArtifactId: "${project.artifact.id}"
49
  Project folder: "${project.folder}"
50
        </echo>
51

  
52
		<echo>Unzipping the basic template project</echo>
53
		<unzip src="${templates.folder}/landregistryviewer.zip" dest="${project.folder}" />
54

  
55
		<!-- Calculate the project artifact id as PATH -->
56
		<propertyregex property="project.artifact.id.folder" input="${project.artifact.id}" regexp="([^\.]*).([^\.]*)" replace="\1${file.separator}\2" />
57

  
58
		<echo>Renaming folder ${project.folder}/org.gvsig.landregistryviewer to 
59
            ${project.folder}/${project.artifact.id}</echo>
60

  
61
		<move todir="${project.folder}">
62
			<fileset dir="${project.folder}">
63
				<include name="org.gvsig.landregistryviewer/**/*.txt" />
64
				<include name="org.gvsig.landregistryviewer/**/*.java" />
65
				<include name="org.gvsig.landregistryviewer/**/*.xml" />
66
				<include name="org.gvsig.landregistryviewer/**/org.gvsig.tools.library.Library" />
67
				<include name="org.gvsig.landregistryviewer.app/**/org.gvsig.tools.library.Library" />
68
				<include name="org.gvsig.landregistryviewer.app/**/*.txt" />
69
				<include name="org.gvsig.landregistryviewer.app/**/*.xml" />
70
				<include name="org.gvsig.landregistryviewer.app/**/*.java" />
71
 			</fileset>
72
			<mapper>
73
				<filtermapper>
74
					<replacestring from="org.gvsig.landregistryviewer" to="${project.artifact.id}" />
75
					<replacestring from="org${file.separator}gvsig${file.separator}landregistryviewer" to="${project.artifact.id.folder}" />
76
					<replacestring from="LandRegistryViewer" to="${project.name.capitalized}" />
77
				</filtermapper>
78
			</mapper>
79
			<filterchain>
80
				<tokenfilter>
81
					<replacestring from="org.gvsig.landregistryviewer" to="${project.artifact.id}" />
82
				</tokenfilter>
83
				<tokenfilter>
84
					<replacestring from="LandRegistryViewer" to="${project.name.capitalized}" />
85
					<replacestring from="Land Registry Viewer" to="${project.name.capitalized}" />
86
					<replacestring from="gvsig-landregistryviewer" to="gvsig-${project.name.lowercase}" />
87
				</tokenfilter>
88
				<tokenfilter>
89
					<replacestring from="LandRegistryViewer" to="${project.name.capitalized}" />
90
					<replacestring from="Land Registry Viewer" to="${project.name.capitalized}" />
91
					<replacestring from="gvsig-landregistryviewer" to="gvsig-${project.name.lowercase}" />
92
				</tokenfilter>
93
			</filterchain>
94
		</move>
95
		<move todir="${project.folder}">
96
			<fileset dir="${project.folder}">
97
                                <include name="org.gvsig.landregistryviewer/**" />
98
                                <include name="org.gvsig.landregistryviewer.app/**" />
99
			</fileset>
100
			<mapper>
101
				<filtermapper>
102
					<replacestring from="org.gvsig.landregistryviewer" to="${project.artifact.id}" />
103
					<replacestring from="org${file.separator}gvsig${file.separator}landregistryviewer" to="${project.artifact.id.folder}" />
104
					<replacestring from="LandRegistryViewer" to="${project.name.capitalized}" />
105
				</filtermapper>
106
			</mapper>
107
		</move>
108
<!--
109
		<delete dir="${project.folder}/org.gvsig.landregistryviewer"/>
110
		<delete dir="${project.folder}/org.gvsig.landregistryviewer.app"/>
111
-->
112
	</target>
113

  
114

  
115
</project>
0 116

  
tags/v2_0_0_Build_2055/extensions/org.gvsig.mkmvnproject/src/main/resources/scripts/fortunecookies-basic.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<project name="gvSIG-make-cookies-basic-project" default="mkproject-build" basedir=".">
3

  
4
	<!-- Get current file location folder -->
5
	<dirname property="gvSIG-make-cookies-basic-project.basedir" file="${ant.file.gvSIG-make-cookies-basic-project}" />
6

  
7
	<target name="mkproject-build">
8
	    <ant dir="${gvSIG-make-cookies-basic-project.basedir}" antfile="fortunecookies.xml" target="mkproject-build-basic" />
9
	</target>
10

  
11
</project>
tags/v2_0_0_Build_2055/extensions/org.gvsig.mkmvnproject/src/main/resources/scripts/fortunecookies.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<project name="gvSIG-make-maven-project" default="mkproject-build-basic" basedir=".">
3

  
4
	<!-- Get current file location folder -->
5
	<dirname property="gvSIG-make-maven-project.basedir" file="${ant.file.gvSIG-make-maven-project}" />
6

  
7
	<!-- Libraries folder in the gvSIG extension -->
8
	<property name="lib.folder" location="${gvSIG-make-maven-project.basedir}/../lib" />
9
	<!-- Templates folder in the gvSIG extension -->
10
	<property name="templates.folder" location="${gvSIG-make-maven-project.basedir}/../templates" />
11

  
12
	<property name="gvsiglogo" location="${basedir}/../gvSIG.png" />
13

  
14
	<!-- Load some ant external utility tasks -->
15
	<property name="antform.lib" location="${lib.folder}/antform-2.0.jar" />
16
	<property name="antcontrib.lib" location="${lib.folder}/ant-contrib-1.0b3.jar" />
17
	<property name="antelope.lib" location="${lib.folder}/antelopetasks-3.2.10.jar" />
18

  
19
	<taskdef resource="net/sf/antcontrib/antlib.xml">
20
		<classpath>
21
			<pathelement location="${antcontrib.lib}" />
22
		</classpath>
23
	</taskdef>
24

  
25
	<taskdef name="antform" classname="com.sardak.antform.AntForm" classpath="${antform.lib}" />
26

  
27
	<taskdef name="antmenu" classname="com.sardak.antform.AntMenu" classpath="${antform.lib}" />
28

  
29
	<taskdef name="stringutil" classname="ise.antelope.tasks.StringUtilTask" classpath="${antelope.lib}" />
30

  
31
	<target name="mkproject-build-cancelled">
32
		<antform title="Project creation cancelled" width="${form.width}" image="${gvsiglogo}">
33
			<textProperty label="" editable="false" columns="40" property="form.title" />
34
			<label>Creation cancelled.</label>
35
			<separator />
36
			<controlbar>
37
				<button type="cancel" label=" Close " />
38
			</controlbar>
39
		</antform>
40
	</target>
41

  
42
    <target name="mkproject-build-basic">
43
        <antcall target="mkproject-build">
44
            <param name="project.type" value="1" />
45
        </antcall>
46
    </target>
47
    
48
    <target name="mkproject-build-provider">
49
        <antcall target="mkproject-build">
50
            <param name="project.type" value="2" />
51
        </antcall>
52
    </target>
53
    
54
	<target name="mkproject-build">
55
		<echo>
56
  Project name: "${project.name}"
57
  Project name capitalized: "${project.name.capitalized}"
58
  Project name lowercase: ${project.name.lowercase}"
59
  Group id: "${project.group.id}"
60
  ArtifactId: "${project.artifact.id}"
61
  Project folder: "${project.folder}"
62
  Project type: "${project.type}"
63
        </echo>
64

  
65
		<if>
66
			<equals arg1="${project.type}" arg2="1" />
67
			<then>
68
				<echo>Unzipping the basic template project</echo>
69
				<unzip src="${templates.folder}/fortunecookies-basic.zip" dest="${project.folder}" />
70
			</then>
71
			<else>
72
				<echo>Unzipping the provider based implementation template project</echo>
73
				<unzip src="${templates.folder}/fortunecookies-pbi.zip" dest="${project.folder}" />
74
			</else>
75
		</if>
76

  
77
		<!-- Calculate the project artifact id as PATH -->
78
		<propertyregex property="project.artifact.id.folder" input="${project.artifact.id}" regexp="([^\.]*).([^\.]*)" replace="\1${file.separator}\2" />
79

  
80
		<echo>Renaming folder ${project.folder}/org.gvsig.fortunecookies to 
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff