Revision 430

View differences:

org.gvsig.about/tags/1.0.0/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0    http://maven.apache.org/xsd/maven-4.0.0.xsd">
3

  
4
	<modelVersion>4.0.0</modelVersion>
5
	<artifactId>org.gvsig.about</artifactId>
6
	<packaging>pom</packaging>
7
	<version>1.0.0</version>
8
	<name>org.gvsig.about</name>
9
	<description>"About us..." dialog library</description>
10
    <url>https://devel.gvsig.org/redmine/projects/gvsig-scripting/repository/show/org.gvsig.about</url>
11
	<parent>
12
		<groupId>org.gvsig</groupId>
13
		<artifactId>org.gvsig.maven.base.pom</artifactId>
14
		<version>1.0.9</version>
15
	</parent>
16
	<scm>
17
        <connection>scm:svn:https://devel.gvsig.org/svn/gvsig-scripting/org.gvsig.about/tags/1.0.0</connection>
18
        <developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-scripting/org.gvsig.about/tags/1.0.0</developerConnection>
19
        <url>https://devel.gvsig.org/redmine/projects/gvsig-scripting/repository/show/org.gvsig.about/tags/1.0.0</url>
20
    </scm>
21

  
22
	<developers>
23
		<developer>
24
			<id>jjdelcerro</id>
25
			<name>Joaquín José del Cerro</name>
26
			<email>jjdelcerro@gvsig.com</email>
27
			<roles>
28
				<role>Architect</role>
29
				<role>Developer</role>
30
			</roles>
31
		</developer>
32
		<developer>
33
			<id>jbadia</id>
34
			<name>José Badía</name>
35
			<email>badia_jos@gva.es</email>
36
			<roles>
37
				<role>Developer</role>
38
			</roles>
39
		</developer>
40
		<developer>
41
			<id>cordinyana</id>
42
			<name>Cèsar Ordiñana</name>
43
			<email>cordinyana@gvsig.com</email>
44
			<roles>
45
				<role>Architect</role>
46
				<role>Developer</role>
47
			</roles>
48
		</developer>
49
	</developers>
50

  
51
	<distributionManagement>
52
		<site>
53
			<id>gvsig-repository</id>
54
			<url>dav:https://devel.gvsig.org/sites/org.gvsig.about/${project.version}</url>
55
		</site>
56
	</distributionManagement>
57
	<repositories>
58
		<repository>
59
			<id>gvsig-public-http-repository</id>
60
			<name>gvSIG maven public HTTP repository</name>
61
			<url>http://devel.gvsig.org/m2repo/j2se</url>
62
			<releases>
63
				<enabled>true</enabled>
64
				<updatePolicy>daily</updatePolicy>
65
				<checksumPolicy>warn</checksumPolicy>
66
			</releases>
67
			<snapshots>
68
				<enabled>true</enabled>
69
				<updatePolicy>daily</updatePolicy>
70
				<checksumPolicy>warn</checksumPolicy>
71
			</snapshots>
72
		</repository>
73
	</repositories>
74
	<build>
75
		<plugins>
76
			<plugin>
77
				<groupId>org.apache.maven.plugins</groupId>
78
				<artifactId>maven-release-plugin</artifactId>
79
				<configuration>
80
					<tagBase>https://devel.gvsig.org/svn/gvsig-scripting/org.gvsig.about/tags</tagBase>
81
				</configuration>
82
			</plugin>
83
		</plugins>
84
	</build>
85
	<dependencyManagement>
86
		<dependencies>
87
			<dependency>
88
				<groupId>org.gvsig</groupId>
89
				<artifactId>org.gvsig.tools.lib</artifactId>
90
				<version>3.0.0</version>
91
			</dependency>
92
			<dependency>
93
				<groupId>org.gvsig</groupId>
94
				<artifactId>org.gvsig.i18n</artifactId>
95
				<version>2.0.1</version>
96
			</dependency>
97
			<dependency>
98
				<groupId>com.jgoodies</groupId>
99
				<artifactId>looks</artifactId>
100
				<version>2.2.2</version>
101
			</dependency>
102
		</dependencies>
103
	</dependencyManagement>
104
	<modules>
105
		<module>org.gvsig.about.api</module>
106
		<module>org.gvsig.about.impl</module>
107
		<module>org.gvsig.about.main</module>
108
	</modules>
109
</project>
org.gvsig.about/tags/1.0.0/org.gvsig.about.impl/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0    http://maven.apache.org/xsd/maven-4.0.0.xsd">
3

  
4
	<modelVersion>4.0.0</modelVersion>
5
	<artifactId>org.gvsig.about.impl</artifactId>
6
	<packaging>jar</packaging>
7
	<name>org.gvsig.about.impl</name>
8
	<description>"About us..." dialog library implementation</description>
9
	<parent>
10
		<groupId>org.gvsig</groupId>
11
		<artifactId>org.gvsig.about</artifactId>
12
		<version>1.0.0</version>
13
	</parent>
14
	<dependencies>
15
		<dependency>
16
			<groupId>org.gvsig</groupId>
17
			<artifactId>org.gvsig.about.api</artifactId>
18
			<version>1.0.0</version>
19
		</dependency>
20
		<dependency>
21
			<groupId>org.gvsig</groupId>
22
			<artifactId>org.gvsig.tools.lib</artifactId>
23
		</dependency>
24
		<dependency>
25
			<groupId>org.gvsig</groupId>
26
			<artifactId>org.gvsig.i18n</artifactId>
27
		</dependency>
28
		<dependency>
29
			<groupId>com.jgoodies</groupId>
30
			<artifactId>looks</artifactId>
31
		</dependency>
32
	</dependencies>
33
</project>
org.gvsig.about/tags/1.0.0/org.gvsig.about.impl/src/test/java/README.txt
1
#set( $symbol_pound = '#' )
2
#set( $symbol_dollar = '$' )
3
#set( $symbol_escape = '\' )
4
For each class you are going to test, create one Test class with the same
5
name as the class to test, ending with Test.
6

  
7
For example, the unit tests of the "ExampleLibrary" class are performed
8
by the "ExampleLibraryTest" class.
org.gvsig.about/tags/1.0.0/org.gvsig.about.impl/src/main/javadoc/overview.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.scripting package documentation</title>
7
</head>
8
<body>
9

  
10
	<p>TODO: Example library overview.</p>
11
	
12
	<p>See the <a href="http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/javadoc.html#overviewcomment">Javadoc Tool documentation about the overview file</a></p>
13

  
14
</body>
15
</html>
org.gvsig.about/tags/1.0.0/org.gvsig.about.impl/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.about.impl.AboutDefaultImplLibrary
org.gvsig.about/tags/1.0.0/org.gvsig.about.impl/src/main/resources/README.txt
1
Put into this folder the resources needed by your library classes.
2

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

  
6
By default, into this folder you can find some examples of resource bundle 
7
property files that may be used by your library classes.
org.gvsig.about/tags/1.0.0/org.gvsig.about.impl/src/main/java/org/gvsig/htmlBrowser/SimpleHtmlBrowserPanel.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.htmlBrowser;
23

  
24
import java.awt.BorderLayout;
25
import java.io.IOException;
26
import java.net.URL;
27

  
28
import javax.swing.JEditorPane;
29
import javax.swing.JScrollPane;
30
import javax.swing.event.HyperlinkEvent;
31
import javax.swing.event.HyperlinkListener;
32

  
33
import org.slf4j.Logger;
34
import org.slf4j.LoggerFactory;
35

  
36
/**
37
 * @author gvSIG Team
38
 * @version $Id$
39
 * 
40
 */
41
public class SimpleHtmlBrowserPanel extends HtmlBrowserPanel implements
42
    HyperlinkListener {
43

  
44
    private static final long serialVersionUID = 2222495134882233629L;
45
    private static final Logger LOG = LoggerFactory
46
        .getLogger(SimpleHtmlBrowserPanel.class);
47

  
48
    public JEditorPane htmlPane;
49
    public JScrollPane scroll;
50

  
51
    public SimpleHtmlBrowserPanel() {
52
        setLayout(new BorderLayout());
53

  
54
        this.htmlPane = new JEditorPane();
55
        this.htmlPane.setContentType("text/html");
56
        this.htmlPane.setEditable(false);
57

  
58
        this.scroll = new JScrollPane(htmlPane);
59
        // htmlPane.addHyperlinkListener(this);
60

  
61
        add(scroll, BorderLayout.CENTER);
62
    }
63

  
64
    @Override
65
    public void navigate(URL url) {
66
        try {
67
            this.htmlPane.setPage(url);
68
        } catch (IOException e) {
69
            this.htmlPane.setText("Error reading html content");
70
            LOG.error("Error reading html content from URL: " + url, e);
71
        }
72
    }
73

  
74
    @Override
75
    public void setText(String text) {
76
        this.htmlPane.setText(text);
77
        this.htmlPane.setCaretPosition(0);
78
    }
79

  
80
    public void hyperlinkUpdate(HyperlinkEvent event) {
81
        if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
82
            try {
83
                htmlPane.setPage(event.getURL());
84
            } catch (IOException ioe) {
85
                this.htmlPane.setText("Error reading html content");
86
                LOG.error(
87
                    "Error reading html content from URL: " + event.getURL(),
88
                    ioe);
89
            }
90
        }
91
    }
92

  
93
    public JEditorPane getJEditorPane() {
94
        return htmlPane;
95
    }
96

  
97
}
org.gvsig.about/tags/1.0.0/org.gvsig.about.impl/src/main/java/org/gvsig/htmlBrowser/LoboHtmlBrowserPanel.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.htmlBrowser;
23

  
24
import java.net.URL;
25

  
26
//import org.lobobrowser.gui.FramePanel;
27

  
28
/**
29
 * @author gvSIG Team
30
 * @version $Id$
31
 * 
32
 */
33
public class LoboHtmlBrowserPanel extends HtmlBrowserPanel {
34

  
35
    /**
36
	 * 
37
	 */
38
    private static final long serialVersionUID = 2789434542951170259L;
39

  
40
    // FramePanel framePanel = null;
41

  
42
    public LoboHtmlBrowserPanel() {
43
        super();
44
    }
45

  
46
    @Override
47
    public void navigate(URL url) {
48
        // this.framePanel.navigate(url);
49
    }
50

  
51
    @Override
52
    public void setText(String text) {
53

  
54
    }
55

  
56
}
org.gvsig.about/tags/1.0.0/org.gvsig.about.impl/src/main/java/org/gvsig/htmlBrowser/HtmlBrowserPanel.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.htmlBrowser;
23

  
24
import java.net.URL;
25

  
26
import javax.swing.JPanel;
27

  
28
/**
29
 * @author gvSIG Team
30
 * @version $Id$
31
 * 
32
 */
33
public abstract class HtmlBrowserPanel extends JPanel {
34

  
35
    private static final long serialVersionUID = 8497218072224309746L;
36

  
37
    abstract public void navigate(URL url);
38

  
39
    abstract public void setText(String text);
40

  
41
}
org.gvsig.about/tags/1.0.0/org.gvsig.about.impl/src/main/java/org/gvsig/about/impl/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.scripting.impl package documentation</title>
7
</head>
8
<body>
9

  
10
	<p>TODO: Example library default implementation description.</p>
11
	
12
	<p>See the <a href="http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/javadoc.html#packagecomment">Javadoc Tool documentation about the package file</a></p>
13

  
14
</body>
15
</html>
org.gvsig.about/tags/1.0.0/org.gvsig.about.impl/src/main/java/org/gvsig/about/impl/DefaultAboutContribution.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.about.impl;
23

  
24
import java.util.Date;
25

  
26
import org.gvsig.about.AboutContribution;
27
import org.gvsig.about.AboutManager;
28
import org.gvsig.about.AboutParticipant;
29

  
30
/**
31
 * @author gvSIG Team
32
 * @version $Id$
33
 * 
34
 */
35
public class DefaultAboutContribution implements AboutContribution {
36

  
37
    private AboutParticipant participant;
38
    private Date begin;
39
    private Date end;
40
    private String description;
41
    private String title;
42

  
43
    public DefaultAboutContribution(AboutParticipant participant, String title,
44
        String description, Date begin, Date end) {
45
        this.participant = participant;
46
        this.title = title;
47
        this.description = description;
48
        this.begin = begin;
49
        this.end = end;
50
    }
51

  
52
    public DefaultAboutContribution(AboutManager manager, String tipo,
53
        String participantName, String title, String description, Date begin,
54
        Date end) {
55
        AboutParticipant ap = null;
56
        if (tipo.equals("AboutDeveloper")) {
57
            ap = manager.getDeveloper(participantName);
58
        } else
59
            if (tipo.equals("AboutSponsor")) {
60
                ap = manager.getSponsor(participantName);
61
            } else
62
                if (tipo.equals("AboutTranslator")) {
63
                    ap = manager.getTranslator(participantName);
64
                }
65
        this.participant = ap;
66
        this.title = title;
67
        this.description = description;
68
        this.begin = begin;
69
        this.end = end;
70
    }
71

  
72
    public String getTitle() {
73
        return this.title;
74
    }
75

  
76
    public Date getEnd() {
77
        return this.end;
78
    }
79

  
80
    public Date getBegin() {
81
        return this.begin;
82
    }
83

  
84
    public AboutParticipant getParticipant() {
85
        return this.participant;
86
    }
87

  
88
    public String getDescription() {
89
        return this.description;
90
    }
91
}
org.gvsig.about/tags/1.0.0/org.gvsig.about.impl/src/main/java/org/gvsig/about/impl/AbstractParticipant.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.about.impl;
23

  
24
import java.net.URL;
25
import java.text.SimpleDateFormat;
26
import java.util.ArrayList;
27
import java.util.Calendar;
28
import java.util.Collections;
29
import java.util.Comparator;
30
import java.util.Date;
31
import java.util.HashMap;
32
import java.util.Iterator;
33
import java.util.List;
34
import java.util.Map;
35
import java.util.regex.Pattern;
36

  
37
import org.gvsig.about.AboutContribution;
38
import org.gvsig.about.AboutManager;
39
import org.gvsig.about.AboutParticipant;
40

  
41
/**
42
 * @author gvSIG Team
43
 * @version $Id$
44
 * 
45
 */
46
public class AbstractParticipant implements AboutParticipant {
47

  
48
    private String name;
49
    private URL description;
50
    private int priority;
51
    private URL icon;
52
    protected List<AboutContribution> contributions;
53
    private DefaultAboutManager manager;
54
    private Map<String, String> vars;
55

  
56
    public AbstractParticipant(AboutManager manager, String name,
57
        URL description, int priority, URL icon) {
58
        this.manager = (DefaultAboutManager) manager;
59
        this.name = name;
60
        this.description = description;
61
        this.priority = priority;
62
        this.icon = icon;
63
        this.contributions = new ArrayList<AboutContribution>();
64
        this.vars = new HashMap<String, String>();
65
    }
66

  
67
    public void addVariables(Map<String, String> vars) {
68
        this.vars.putAll(vars);
69
    }
70

  
71
    public void set(String name, String value) {
72
        this.vars.put(name, value);
73
    }
74

  
75
    public String getName() {
76
        return this.name;
77
    }
78

  
79
    public URL getDescription() {
80
        return this.description;
81
    }
82

  
83
    public int getPriority() {
84
        return this.priority;
85
    }
86

  
87
    @Override
88
    public String toString() {
89
        return this.name;
90
    }
91

  
92
    public URL getIcon() {
93
        return this.icon;
94
    }
95

  
96
    public AboutManager getManager() {
97
        return this.manager;
98
    }
99

  
100
    protected Date getDate(int year, int month, int day) {
101
        Calendar cal = Calendar.getInstance();
102
        cal.set(year, month, day);
103
        return cal.getTime();
104
    }
105

  
106
    public AboutContribution addContribution(String title, String description,
107
        int begin_year, int begin_month, int begin_day, int end_year,
108
        int end_month, int end_day) {
109
        return this.addContribution(title, description,
110
            getDate(begin_year, begin_month, begin_day),
111
            getDate(end_year, end_month, end_day));
112
    }
113

  
114
    public AboutContribution addContribution(String title, String description,
115
        Date begin, Date end) {
116
        AboutContribution contribution =
117
            new DefaultAboutContribution(this, title, description, begin, end);
118
        // Añadimos a la lista de contribuciones
119
        this.contributions.add(contribution);
120
        // Ordenamos por fecha de inicio
121
        Collections.sort(this.contributions,
122
            new Comparator<AboutContribution>() {
123

  
124
                public int compare(AboutContribution p1, AboutContribution p2) {
125
                    if (p1.getBegin().before(p2.getBegin())) {
126
                        return -1;
127
                    } else
128
                        if (p1.getBegin().after(p2.getBegin())) {
129
                            return 1;
130
                        } else {
131
                            return 0;
132
                        }
133
                }
134
            });
135

  
136
        return contribution;
137
    }
138

  
139
    public List<AboutContribution> getContributions() {
140
        return this.contributions;
141
    }
142

  
143
    public String getInformationPage() {
144
        String description = null;
145
        String contributionsTable = this.getContributionsTable();
146

  
147
        if (this.description != null) {
148
            description = manager.getStringFromUrl(this.description, this.vars);
149
        }
150
        if (description == null) {
151
            return "<html>\n" // Begin html
152
                + "<body>\n" + contributionsTable + "</body>\n" // Body
153
                + "</html>"; // End html
154
        }
155

  
156
        String baseTag =
157
            "<base href=\"" + manager.getURLBase(getDescription()) + "\"/>";
158

  
159
        int index = description.indexOf("<head>");
160
        if (index > -1) {
161
            description =
162
                description.substring(0, index) // HTML init
163
                    + "<head>"
164
                    + baseTag
165
                    + description.substring(index + "<head>".length());
166
        } else {
167
            index = description.indexOf("<html>");
168
            if (index > -1) {
169
                description =
170
                    description.substring(0, index + "<html>".length())
171
                        + "<head>" + baseTag + "</head>" // Head
172
                        + description.substring(index + "<html>".length());
173
            } else {
174
                description = "<head>" + baseTag + "</head>" // Head
175
                    + description;
176
            }
177
        }
178

  
179
        if (description.toLowerCase().indexOf("</body>") < 0) {
180
            return description + "\n" + contributionsTable;
181
        }
182
        return Pattern.compile("</body>", Pattern.CASE_INSENSITIVE)
183
            .matcher(description)
184
            .replaceFirst(contributionsTable + "\n</body>");
185
    }
186

  
187
    public String getContributionsTable() {
188
        List<AboutContribution> contributions = this.getContributions();
189
        if (contributions.size() < 1) {
190
            return "";
191
        }
192
        String table =
193
            "\t<div style=\"padding-top:5px\">\n"
194
                + "\t\t<div style=\"background-color: white;padding-top: 5px\">\n"
195
                + "\t\t\t<center><h3>Contribuciones realizadas</h3></center>\n"
196
                + "\t\t\t<br>\n"
197
                + "\t\t\t<table width=\"100%\" border=\"1\">\n"
198
                + "\t\t\t\t<tr>\n"
199
                + "\t\t\t\t\t<td valign=\"top\" align=\"center\">Nombre</td>\n"
200
                + "\t\t\t\t\t<td valign=\"top\" align=\"center\">Descripcion</td>\n"
201
                + "\t\t\t\t\t<td valign=\"top\" colspan=\"2\" align=\"center\">Periodo</td>\n"
202
                + "\t\t\t\t</tr>\n";
203
        Iterator<AboutContribution> it = contributions.iterator();
204
        SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
205
        while (it.hasNext()) {
206
            AboutContribution ap = it.next();
207
            String cont = "";
208
            if (ap.getDescription() != null) {
209
                cont = ap.getDescription();
210
            }
211

  
212
            table =
213
                table + "\t\t\t\t<tr>\n" + "\t\t\t\t\t <td valign=\"top\">"
214
                    + ap.getTitle() + "</td>\n"
215
                    + "\t\t\t\t\t <td valign=\"top\">" + cont + "</td>\n"
216
                    + "\t\t\t\t\t  <td valign=\"top\">"
217
                    + formatter.format(ap.getBegin().getTime()) + "</td>\n"
218
                    + "\t\t\t\t\t  <td valign=\"top\">"
219
                    + formatter.format(ap.getEnd().getTime()) + "</td>\n"
220
                    + "\t\t\t\t</tr>\n";
221
        }
222
        table = table + "\t\t\t</table>\n\t\t</div>\n\t</div>\n";
223
        return table;
224
    }
225

  
226
}
org.gvsig.about/tags/1.0.0/org.gvsig.about.impl/src/main/java/org/gvsig/about/impl/DefaultAboutSponsor.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.about.impl;
23

  
24
import java.net.URL;
25

  
26
import org.gvsig.about.AboutSponsor;
27

  
28
/**
29
 * @author gvSIG Team
30
 * @version $Id$
31
 * 
32
 */
33
public class DefaultAboutSponsor extends AbstractParticipant implements
34
    AboutSponsor {
35

  
36
    public DefaultAboutSponsor(DefaultAboutManager manager, String name,
37
        URL description, int priority, URL icon) {
38
        super(manager, name, description, priority, icon);
39
    }
40

  
41
    public DefaultAboutSponsor(DefaultAboutManager manager, String name,
42
        URL description, int priority) {
43
        super(manager, name, description, priority, null);
44
    }
45
}
org.gvsig.about/tags/1.0.0/org.gvsig.about.impl/src/main/java/org/gvsig/about/impl/DefaultAboutDeveloper.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.about.impl;
23

  
24
import java.net.URL;
25

  
26
import org.gvsig.about.AboutDeveloper;
27

  
28
/**
29
 * @author gvSIG Team
30
 * @version $Id$
31
 * 
32
 */
33
public class DefaultAboutDeveloper extends AbstractParticipant implements
34
    AboutDeveloper {
35

  
36
    public DefaultAboutDeveloper(DefaultAboutManager manager, String name,
37
        URL description, int priority, URL icon) {
38
        super(manager, name, description, priority, icon);
39
    }
40

  
41
    public DefaultAboutDeveloper(DefaultAboutManager manager, String name,
42
        URL description, int priority) {
43
        super(manager, name, description, priority, null);
44
    }
45

  
46
}
org.gvsig.about/tags/1.0.0/org.gvsig.about.impl/src/main/java/org/gvsig/about/impl/AboutDefaultImplLibrary.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.about.impl;
23

  
24
import org.gvsig.about.AboutLibrary;
25
import org.gvsig.about.AboutLocator;
26
import org.gvsig.tools.ToolsLibrary;
27
import org.gvsig.tools.library.AbstractLibrary;
28
import org.gvsig.tools.library.LibraryException;
29

  
30
/**
31
 * @author gvSIG Team
32
 * @version $Id$
33
 */
34
public class AboutDefaultImplLibrary extends AbstractLibrary {
35

  
36
    @Override
37
    public void doRegistration() {
38
        registerAsImplementationOf(AboutLibrary.class);
39
        require(ToolsLibrary.class);
40
    }
41

  
42
    @Override
43
    protected void doInitialize() throws LibraryException {
44
        AboutLocator.registerManager(DefaultAboutManager.class);
45
    }
46

  
47
    @Override
48
    protected void doPostInitialize() throws LibraryException {
49
        // Nothing to do
50
    }
51

  
52
}
org.gvsig.about/tags/1.0.0/org.gvsig.about.impl/src/main/java/org/gvsig/about/impl/DefaultAboutProject.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.about.impl;
23

  
24
import java.net.URL;
25
import java.util.HashMap;
26
import java.util.Map;
27

  
28
import org.gvsig.about.AboutProject;
29

  
30
/**
31
 * @author gvSIG Team
32
 * @version $Id$
33
 * 
34
 */
35
public class DefaultAboutProject implements AboutProject {
36

  
37
    protected String name;
38
    protected URL description;
39
    protected URL icon;
40
    private DefaultAboutManager manager;
41
    private Map<String, String> vars;
42

  
43
    public DefaultAboutProject(DefaultAboutManager manager, String name,
44
        URL description, URL icon) {
45
        this(manager, name, description, icon, null);
46
    }
47

  
48
    public DefaultAboutProject(DefaultAboutManager manager, String name,
49
        URL description, URL icon, Map<String, String> vars) {
50
        this.manager = manager;
51
        this.name = name;
52
        this.description = description;
53
        this.icon = icon;
54
        this.vars = new HashMap<String, String>();
55
        if (vars != null) {
56
            this.vars.putAll(vars);
57
        }
58
    }
59

  
60
    public void set(String name, String value) {
61
        this.vars.put(name, value);
62
    }
63

  
64
    public String getName() {
65
        return this.name;
66
    }
67

  
68
    public URL getDescription() {
69
        return this.description;
70
    }
71

  
72
    public URL getIcon() {
73
        return this.icon;
74
    }
75

  
76
    @Override
77
    public String toString() {
78
        return this.name;
79
    }
80

  
81
    public String getInformationPage() {
82
        String description = null;
83

  
84
        if (this.description != null) {
85
            description = manager.getStringFromUrl(this.description, this.vars);
86
        }
87
        if (description == null) {
88
            return "<html><body></body></html>";
89
        }
90
        return description;
91
    }
92

  
93
}
org.gvsig.about/tags/1.0.0/org.gvsig.about.impl/src/main/java/org/gvsig/about/impl/DefaultAboutTranslator.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.about.impl;
23

  
24
import java.net.URL;
25

  
26
import org.gvsig.about.AboutTranslator;
27

  
28
/**
29
 * @author gvSIG Team
30
 * @version $Id$
31
 * 
32
 */
33
public class DefaultAboutTranslator extends AbstractParticipant implements
34
    AboutTranslator {
35

  
36
    public DefaultAboutTranslator(DefaultAboutManager manager, String name,
37
        URL description, int priority, URL icon) {
38
        super(manager, name, description, priority, icon);
39
    }
40

  
41
    public DefaultAboutTranslator(DefaultAboutManager manager, String name,
42
        URL description, int priority) {
43
        super(manager, name, description, priority, null);
44
    }
45

  
46
}
org.gvsig.about/tags/1.0.0/org.gvsig.about.impl/src/main/java/org/gvsig/about/impl/DefaultAboutManager.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.about.impl;
23

  
24
import java.io.BufferedReader;
25
import java.io.FileNotFoundException;
26
import java.io.FileReader;
27
import java.io.IOException;
28
import java.io.InputStream;
29
import java.io.InputStreamReader;
30
import java.net.URL;
31
import java.util.ArrayList;
32
import java.util.Collections;
33
import java.util.Comparator;
34
import java.util.Iterator;
35
import java.util.List;
36
import java.util.Map;
37

  
38
import javax.swing.ImageIcon;
39
import javax.swing.JPanel;
40

  
41
import org.gvsig.about.AboutContribution;
42
import org.gvsig.about.AboutDeveloper;
43
import org.gvsig.about.AboutManager;
44
import org.gvsig.about.AboutParticipant;
45
import org.gvsig.about.AboutProject;
46
import org.gvsig.about.AboutSponsor;
47
import org.gvsig.about.AboutTranslator;
48
import org.gvsig.about.swing.JAboutPanel;
49

  
50
/**
51
 * @author gvSIG Team
52
 * @version $Id$
53
 * 
54
 */
55
public class DefaultAboutManager implements AboutManager {
56

  
57
    protected List<AboutDeveloper> developers;
58
    protected List<AboutTranslator> translators;
59
    protected List<AboutSponsor> sponsors;
60

  
61
    protected DefaultAboutProject root;
62

  
63
    protected int ICON_SIZE = 16;
64

  
65
    public DefaultAboutManager() {
66
        developers = new ArrayList<AboutDeveloper>();
67
        sponsors = new ArrayList<AboutSponsor>();
68
        translators = new ArrayList<AboutTranslator>();
69
    }
70

  
71
    public void setProject(String name, URL description, URL icon) {
72
        root = new DefaultAboutProject(this, name, description, icon);
73
    }
74

  
75
    public void setProject(String name, URL description, URL icon,
76
        Map<String, String> vars) {
77
        root = new DefaultAboutProject(this, name, description, icon, vars);
78

  
79
    }
80

  
81
    // public AboutContribution addContribution(AboutParticipant participant,
82
    // String title, String description) {
83
    // return participant.addContribution(title, description, null, null);
84
    // }
85
    //
86
    // public AboutContribution addContribution(AboutParticipant participant,
87
    // String title, String description, Date begin) {
88
    // return participant.addContribution(title, description, begin, null);
89
    // }
90
    //
91
    // public AboutContribution addContribution(AboutParticipant participant,
92
    // String title, String description, Date begin, Date end) {
93
    // return participant.addContribution(title, description, begin, end);
94
    // }
95

  
96
    public AboutParticipant addDeveloper(String name, URL description,
97
        int priority) {
98
        return addDeveloper(name, description, priority, null);
99
    }
100

  
101
    public AboutParticipant addDeveloper(String name, URL description,
102
        int priority, URL icon) {
103

  
104
        AboutDeveloper participant = this.getDeveloper(name);
105

  
106
        if (participant == null) {
107
            participant =
108
                new DefaultAboutDeveloper(this, name, description, priority,
109
                    icon);
110
            // Añadimos a la lista de contribuciones
111
            this.developers.add(participant);
112
            // Ordenamos por prioridad creciente
113
            Collections.sort(this.developers, new Comparator<AboutDeveloper>() {
114

  
115
                public int compare(AboutDeveloper p1, AboutDeveloper p2) {
116
                    return p1.getPriority() < p2.getPriority() ? -1 : (p1
117
                        .getPriority() > p2.getPriority() ? +1 : 0);
118
                }
119
            });
120
        }
121

  
122
        return participant;
123
    }
124

  
125
    public AboutParticipant addSponsor(String name, URL description,
126
        int priority) {
127
        return addSponsor(name, description, priority, null);
128
    }
129

  
130
    public AboutParticipant addSponsor(String name, URL description,
131
        int priority, URL icon) {
132

  
133
        AboutSponsor participant = this.getSponsor(name);
134

  
135
        if (participant == null) {
136
            participant =
137
                new DefaultAboutSponsor(this, name, description, priority, icon);
138
            // Añadimos a la lista de contribuciones
139
            this.sponsors.add(participant);
140
            // Ordenamos por prioridad creciente
141
            Collections.sort(this.sponsors, new Comparator<AboutSponsor>() {
142

  
143
                public int compare(AboutSponsor p1, AboutSponsor p2) {
144
                    return p1.getPriority() < p2.getPriority() ? -1 : (p1
145
                        .getPriority() > p2.getPriority() ? +1 : 0);
146
                }
147
            });
148
        }
149

  
150
        return participant;
151
    }
152

  
153
    public AboutParticipant addTranslator(String name, URL description,
154
        int priority) {
155
        return addTranslator(name, description, priority, null);
156
    }
157

  
158
    public AboutParticipant addTranslator(String name, URL description,
159
        int priority, URL icon) {
160

  
161
        AboutTranslator participant = this.getTranslator(name);
162

  
163
        if (participant == null) {
164
            participant =
165
                new DefaultAboutTranslator(this, name, description, priority,
166
                    icon);
167
            // Añadimos a la lista de contribuciones
168
            this.translators.add(participant);
169
            // Ordenamos por prioridad creciente
170
            Collections.sort(this.translators,
171
                new Comparator<AboutTranslator>() {
172

  
173
                    public int compare(AboutTranslator p1, AboutTranslator p2) {
174
                        return p1.getPriority() < p2.getPriority() ? -1 : (p1
175
                            .getPriority() > p2.getPriority() ? +1 : 0);
176
                    }
177
                });
178
        }
179

  
180
        return participant;
181
    }
182

  
183
    public JPanel getAboutPanel() {
184
        JPanel panel = new JAboutPanel(this);
185
        return panel;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff