Revision 47726
branches/org.gvsig.desktop-2.0.411-vcsgis1_0_96/license.txt | ||
---|---|---|
1 |
gvSIG. Desktop Geographic Information System. |
|
2 |
|
|
3 |
Copyright (C) 2007-2020 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 3 |
|
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, see <https://www.gnu.org/licenses/>. |
|
17 |
|
|
18 |
For any additional information, do not hesitate to contact us |
|
19 |
at info AT gvsig.com, or visit our website www.gvsig.com. |
branches/org.gvsig.desktop-2.0.411-vcsgis1_0_96/org.gvsig.desktop.library/org.gvsig.about/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 |
<name>org.gvsig.about</name> |
|
8 |
<description>"About us..." dialog library</description> |
|
9 |
<parent> |
|
10 |
<groupId>org.gvsig</groupId> |
|
11 |
<artifactId>org.gvsig.desktop.library</artifactId> |
|
12 |
<version>2.0.411</version> |
|
13 |
</parent> |
|
14 |
|
|
15 |
<modules> |
|
16 |
<module>org.gvsig.about.api</module> |
|
17 |
<module>org.gvsig.about.impl</module> |
|
18 |
</modules> |
|
19 |
</project> |
branches/org.gvsig.desktop-2.0.411-vcsgis1_0_96/org.gvsig.desktop.library/org.gvsig.about/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. |
branches/org.gvsig.desktop-2.0.411-vcsgis1_0_96/org.gvsig.desktop.library/org.gvsig.about/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 |
} |
branches/org.gvsig.desktop-2.0.411-vcsgis1_0_96/org.gvsig.desktop.library/org.gvsig.about/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 |
} |
branches/org.gvsig.desktop-2.0.411-vcsgis1_0_96/org.gvsig.desktop.library/org.gvsig.about/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 |
} |
branches/org.gvsig.desktop-2.0.411-vcsgis1_0_96/org.gvsig.desktop.library/org.gvsig.about/org.gvsig.about.impl/src/main/java/org/gvsig/about/swing/JAboutPanel.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.swing; |
|
23 |
|
|
24 |
import java.awt.BorderLayout; |
|
25 |
import java.awt.Dimension; |
|
26 |
import java.awt.event.ActionEvent; |
|
27 |
import java.awt.event.ActionListener; |
|
28 |
|
|
29 |
import javax.swing.BorderFactory; |
|
30 |
import javax.swing.JPanel; |
|
31 |
|
|
32 |
import org.gvsig.about.AboutParticipant; |
|
33 |
import org.gvsig.about.AboutProject; |
|
34 |
import org.gvsig.about.impl.DefaultAboutManager; |
|
35 |
|
|
36 |
/** |
|
37 |
* @author gvSIG Team |
|
38 |
* @version $Id$ |
|
39 |
* |
|
40 |
*/ |
|
41 |
public class JAboutPanel extends JPanel implements ActionListener { |
|
42 |
|
|
43 |
/** |
|
44 |
* |
|
45 |
*/ |
|
46 |
private static final long serialVersionUID = 5605530722128487156L; |
|
47 |
protected DefaultAboutManager manager; |
|
48 |
protected JAboutBrowser browser; |
|
49 |
protected JContentPanel content; |
|
50 |
|
|
51 |
public JAboutPanel(DefaultAboutManager manager) { |
|
52 |
this.manager = manager; |
|
53 |
|
|
54 |
setLayout(new BorderLayout()); |
|
55 |
|
|
56 |
browser = new JAboutBrowser(manager, manager.getProject()); |
|
57 |
browser.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); |
|
58 |
browser.addDefaultActionListener(this); |
|
59 |
add(browser, BorderLayout.WEST); |
|
60 |
|
|
61 |
content = new JContentPanel(manager, manager.getProject()); |
|
62 |
content.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); |
|
63 |
add(content, BorderLayout.CENTER); |
|
64 |
setPreferredSize(new Dimension(650, 400)); |
|
65 |
} |
|
66 |
|
|
67 |
public void actionPerformed(ActionEvent arg0) { |
|
68 |
|
|
69 |
if (arg0.getSource() instanceof JAboutBrowser) { |
|
70 |
JAboutBrowser browser = (JAboutBrowser) arg0.getSource(); |
|
71 |
|
|
72 |
if (browser.getSelectedNode() instanceof AboutProject) { |
|
73 |
AboutProject project = (AboutProject) browser.getSelectedNode(); |
|
74 |
content.setContent(project); |
|
75 |
} else |
|
76 |
if (browser.getSelectedNode() instanceof AboutParticipant) { |
|
77 |
AboutParticipant participant = |
|
78 |
(AboutParticipant) browser.getSelectedNode(); |
|
79 |
content.setContent(participant); |
|
80 |
} |
|
81 |
|
|
82 |
} |
|
83 |
} |
|
84 |
|
|
85 |
} |
branches/org.gvsig.desktop-2.0.411-vcsgis1_0_96/org.gvsig.desktop.library/org.gvsig.about/org.gvsig.about.impl/src/main/java/org/gvsig/about/swing/JContentPanel.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.swing; |
|
23 |
|
|
24 |
import java.awt.BorderLayout; |
|
25 |
|
|
26 |
import javax.swing.JPanel; |
|
27 |
|
|
28 |
import org.gvsig.about.AboutManager; |
|
29 |
import org.gvsig.about.AboutParticipant; |
|
30 |
import org.gvsig.about.AboutProject; |
|
31 |
import org.gvsig.htmlBrowser.HtmlBrowserPanel; |
|
32 |
import org.gvsig.htmlBrowser.SimpleHtmlBrowserPanel; |
|
33 |
|
|
34 |
/** |
|
35 |
* @author gvSIG Team |
|
36 |
* @version $Id$ |
|
37 |
* |
|
38 |
*/ |
|
39 |
public class JContentPanel extends JPanel /* implements HyperlinkListener */{ |
|
40 |
|
|
41 |
/** |
|
42 |
* |
|
43 |
*/ |
|
44 |
private static final long serialVersionUID = 5605530722128487156L; |
|
45 |
protected AboutManager manager; |
|
46 |
HtmlBrowserPanel htmlPane; |
|
47 |
|
|
48 |
public JContentPanel(AboutManager manager, AboutProject project) { |
|
49 |
this.manager = manager; |
|
50 |
this.htmlPane = null; |
|
51 |
|
|
52 |
setLayout(new BorderLayout()); |
|
53 |
this.htmlPane = new SimpleHtmlBrowserPanel(); |
|
54 |
add(this.htmlPane, BorderLayout.CENTER); |
|
55 |
|
|
56 |
this.setContent(manager.getProject()); |
|
57 |
setVisible(true); |
|
58 |
} |
|
59 |
|
|
60 |
public void setContent(AboutParticipant participant) { |
|
61 |
htmlPane.setText(participant.getInformationPage()); |
|
62 |
} |
|
63 |
|
|
64 |
public void setContent(AboutProject project) { |
|
65 |
htmlPane.setText(project.getInformationPage()); |
|
66 |
} |
|
67 |
|
|
68 |
} |
branches/org.gvsig.desktop-2.0.411-vcsgis1_0_96/org.gvsig.desktop.library/org.gvsig.about/org.gvsig.about.impl/src/main/java/org/gvsig/about/swing/JAboutBrowser.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.swing; |
|
23 |
|
|
24 |
import java.awt.Color; |
|
25 |
import java.awt.Component; |
|
26 |
import java.awt.Dimension; |
|
27 |
import java.awt.Graphics; |
|
28 |
import java.awt.GridLayout; |
|
29 |
import java.awt.event.ActionEvent; |
|
30 |
import java.awt.event.ActionListener; |
|
31 |
import java.awt.event.MouseEvent; |
|
32 |
import java.awt.event.MouseListener; |
|
33 |
import java.util.List; |
|
34 |
|
|
35 |
import javax.swing.Icon; |
|
36 |
import javax.swing.ImageIcon; |
|
37 |
import javax.swing.JLabel; |
|
38 |
import javax.swing.JPanel; |
|
39 |
import javax.swing.JScrollPane; |
|
40 |
import javax.swing.JTree; |
|
41 |
import javax.swing.UIManager; |
|
42 |
import javax.swing.tree.DefaultMutableTreeNode; |
|
43 |
import javax.swing.tree.DefaultTreeModel; |
|
44 |
import javax.swing.tree.TreeCellRenderer; |
|
45 |
import javax.swing.tree.TreePath; |
|
46 |
import javax.swing.tree.TreeSelectionModel; |
|
47 |
|
|
48 |
import org.gvsig.about.AboutManager; |
|
49 |
import org.gvsig.about.AboutParticipant; |
|
50 |
import org.gvsig.about.AboutProject; |
|
51 |
import org.gvsig.about.impl.DefaultAboutManager; |
|
52 |
|
|
53 |
/** |
|
54 |
* @author gvSIG Team |
|
55 |
* @version $Id$ |
|
56 |
* |
|
57 |
*/ |
|
58 |
public class JAboutBrowser extends JPanel { |
|
59 |
|
|
60 |
public static final int DEFAULT_ACTION = 1; |
|
61 |
public static final int SELECTION_ACTION = 2; |
|
62 |
public static final int DROPDOWN_ACTION = 3; |
|
63 |
/** |
|
64 |
* |
|
65 |
*/ |
|
66 |
private static final long serialVersionUID = 1L; |
|
67 |
|
|
68 |
protected DefaultAboutManager manager; |
|
69 |
protected DefaultMutableTreeNode rootNode; |
|
70 |
protected DefaultTreeModel treeModel; |
|
71 |
protected JTree tree; |
|
72 |
protected AboutProject root; |
|
73 |
protected ActionListener defaultActionlistener = null; |
|
74 |
protected ActionListener selectionActionlistener = null; |
|
75 |
protected ActionListener dropDownActionlistener = null; |
|
76 |
|
|
77 |
public static class BrowserActionEvent extends ActionEvent { |
|
78 |
|
|
79 |
/** |
|
80 |
* |
|
81 |
*/ |
|
82 |
private static final long serialVersionUID = -1474410768278633364L; |
|
83 |
private Object participant; |
|
84 |
|
|
85 |
public BrowserActionEvent(Object source, int id, String command, |
|
86 |
Object participant) { |
|
87 |
super(source, id, command); |
|
88 |
this.participant = participant; |
|
89 |
} |
|
90 |
|
|
91 |
public Object getParticipant() { |
|
92 |
return this.participant; |
|
93 |
} |
|
94 |
} |
|
95 |
|
|
96 |
public JAboutBrowser(DefaultAboutManager manager, AboutProject root) { |
|
97 |
super(new GridLayout(1, 2)); |
|
98 |
this.manager = manager; |
|
99 |
this.root = root; |
|
100 |
this.makeUI(); |
|
101 |
} |
|
102 |
|
|
103 |
public AboutManager getManager() { |
|
104 |
return this.manager; |
|
105 |
} |
|
106 |
|
|
107 |
public void addDefaultActionListener(ActionListener actionlistener) { |
|
108 |
this.defaultActionlistener = actionlistener; |
|
109 |
} |
|
110 |
|
|
111 |
public void addSelectionActionListener(ActionListener actionlistener) { |
|
112 |
this.selectionActionlistener = actionlistener; |
|
113 |
} |
|
114 |
|
|
115 |
public void addDropDownActionListener(ActionListener actionlistener) { |
|
116 |
this.dropDownActionlistener = actionlistener; |
|
117 |
} |
|
118 |
|
|
119 |
private void makeUI() { |
|
120 |
// Creamos el nodo raĆz |
|
121 |
|
|
122 |
ImageIcon icon = |
|
123 |
this.manager.getImageIcon(this.root.getIcon(), "gvSIG.png"); |
|
124 |
rootNode = |
|
125 |
new DefaultMutableTreeNode(new NodeData(icon, icon, this.root)); |
|
126 |
|
|
127 |
// Lo asignamos al modelo del Ɣrbol e iniciamos el Ɣrbol con ese |
|
128 |
// modelo |
|
129 |
treeModel = new DefaultTreeModel(rootNode); |
|
130 |
tree = new JTree(treeModel); |
|
131 |
|
|
132 |
// Cargamos la informaciĆ³n inicial del Ć”rbol |
|
133 |
this.initializeTree(); |
|
134 |
|
|
135 |
// Para asignar iconos especiales segĆŗn el tipo de objeto |
|
136 |
TreeCellRenderer renderer = new IconCellRenderer(); |
|
137 |
tree.setCellRenderer(renderer); |
|
138 |
|
|
139 |
// Para marcar que no son editables sus propiedades o nodos |
|
140 |
tree.setEditable(false); |
|
141 |
this.expandAll(); |
|
142 |
|
|
143 |
// Determina que sĆ³lo se puede seleccionar una linea |
|
144 |
tree.getSelectionModel().setSelectionMode( |
|
145 |
TreeSelectionModel.SINGLE_TREE_SELECTION); |
|
146 |
|
|
147 |
tree.addMouseListener(new MouseListener() { |
|
148 |
|
|
149 |
public void mouseClicked(MouseEvent arg0) { |
|
150 |
if (arg0.getClickCount() == 1) { |
|
151 |
JTree tree = (JTree) arg0.getSource(); |
|
152 |
if (!tree.isSelectionEmpty()) { |
|
153 |
throwEventElementSelected(tree.getSelectionPath()); |
|
154 |
} |
|
155 |
|
|
156 |
} |
|
157 |
} |
|
158 |
|
|
159 |
public void mouseEntered(MouseEvent arg0) { |
|
160 |
} |
|
161 |
|
|
162 |
public void mouseExited(MouseEvent arg0) { |
|
163 |
} |
|
164 |
|
|
165 |
public void mousePressed(MouseEvent arg0) { |
|
166 |
} |
|
167 |
|
|
168 |
public void mouseReleased(MouseEvent arg0) { |
|
169 |
} |
|
170 |
}); |
|
171 |
|
|
172 |
// Indica si el nodo raĆz actĆŗa como un nodo mĆ”s o queda desplegado |
|
173 |
// de |
|
174 |
// manera fija |
|
175 |
tree.setShowsRootHandles(true); |
|
176 |
|
|
177 |
// AƱadimos el Scroll |
|
178 |
JScrollPane scrollPane = new JScrollPane(tree); |
|
179 |
add(scrollPane); |
|
180 |
|
|
181 |
setPreferredSize(new Dimension(200, 300)); |
|
182 |
|
|
183 |
} |
|
184 |
|
|
185 |
public Object getSelectedNode() { |
|
186 |
DefaultMutableTreeNode node; |
|
187 |
if (tree.getSelectionPath() != null) { |
|
188 |
node = |
|
189 |
(DefaultMutableTreeNode) tree.getSelectionPath() |
|
190 |
.getLastPathComponent(); |
|
191 |
} else { |
|
192 |
node = this.rootNode; |
|
193 |
} |
|
194 |
NodeData nodeData = (NodeData) node.getUserObject(); |
|
195 |
if (nodeData.getParticipant() != null) { |
|
196 |
return nodeData.getParticipant(); |
|
197 |
} else |
|
198 |
if (nodeData.getProject() != null) { |
|
199 |
return nodeData.getProject(); |
|
200 |
} |
|
201 |
return null; |
|
202 |
} |
|
203 |
|
|
204 |
private void throwEventElementSelected(TreePath path) { |
|
205 |
DefaultMutableTreeNode node = |
|
206 |
(DefaultMutableTreeNode) path.getLastPathComponent(); |
|
207 |
NodeData nodeData = (NodeData) node.getUserObject(); |
|
208 |
if (nodeData.getParticipant() != null) { |
|
209 |
if (this.defaultActionlistener != null) { |
|
210 |
ActionEvent event = |
|
211 |
new BrowserActionEvent(this, DEFAULT_ACTION, "default", |
|
212 |
nodeData.getParticipant()); |
|
213 |
this.defaultActionlistener.actionPerformed(event); |
|
214 |
} |
|
215 |
} else |
|
216 |
if (nodeData.getProject() != null) { |
|
217 |
if (this.defaultActionlistener != null) { |
|
218 |
ActionEvent event = |
|
219 |
new BrowserActionEvent(this, DEFAULT_ACTION, "default", |
|
220 |
nodeData.getProject()); |
|
221 |
this.defaultActionlistener.actionPerformed(event); |
|
222 |
} |
|
223 |
} |
|
224 |
} |
|
225 |
|
|
226 |
/** |
|
227 |
* FunciĆ³n para la inicializaciĆ³n de los datos del Ć”rbol. |
|
228 |
**/ |
|
229 |
@SuppressWarnings("rawtypes") |
|
230 |
private void initializeTree() { |
|
231 |
|
|
232 |
AboutParticipant ap = null; |
|
233 |
List participants; |
|
234 |
ImageIcon icon; |
|
235 |
NodeData data; |
|
236 |
|
|
237 |
NodeData sponsors = |
|
238 |
new NodeData(this.manager.getImageIcon("folder.png"), |
|
239 |
this.manager.getImageIcon("folder-drag-accept.png"), "Sponsors"); |
|
240 |
DefaultMutableTreeNode sponsorsNode = |
|
241 |
this.addObject(this.rootNode, sponsors); |
|
242 |
participants = this.manager.getSponsors(); |
|
243 |
for (int i = 0; i < participants.size(); i++) { |
|
244 |
ap = (AboutParticipant) participants.get(i); |
|
245 |
icon = |
|
246 |
(this.manager).getImageIcon(ap.getIcon(), |
|
247 |
"applications-internet.png"); |
|
248 |
data = new NodeData(icon, icon, ap); |
|
249 |
this.addObject(sponsorsNode, data); |
|
250 |
} |
|
251 |
|
|
252 |
NodeData developers = |
|
253 |
new NodeData(this.manager.getImageIcon("edit.png"), |
|
254 |
this.manager.getImageIcon("edit.png"), "Developers"); |
|
255 |
DefaultMutableTreeNode developersNode = |
|
256 |
this.addObject(this.rootNode, developers); |
|
257 |
participants = this.manager.getDevelopers(); |
|
258 |
for (int i = 0; i < participants.size(); i++) { |
|
259 |
ap = (AboutParticipant) participants.get(i); |
|
260 |
icon = |
|
261 |
this.manager.getImageIcon(ap.getIcon(), |
|
262 |
"preferences-system.png"); |
|
263 |
data = new NodeData(icon, icon, ap); |
|
264 |
this.addObject(developersNode, data); |
|
265 |
} |
|
266 |
|
|
267 |
NodeData translators = |
|
268 |
new NodeData(this.manager.getImageIcon("system-users.png"), |
|
269 |
this.manager.getImageIcon("system-users.png"), "Contributors"); |
|
270 |
DefaultMutableTreeNode translatorsNode = |
|
271 |
this.addObject(this.rootNode, translators); |
|
272 |
participants = this.manager.getTranslators(); |
|
273 |
|
|
274 |
for (int i = 0; i < participants.size(); i++) { |
|
275 |
ap = (AboutParticipant) participants.get(i); |
|
276 |
icon = this.manager.getImageIcon(ap.getIcon(), "people.png"); |
|
277 |
data = new NodeData(icon, icon, ap); |
|
278 |
this.addObject(translatorsNode, data); |
|
279 |
} |
|
280 |
|
|
281 |
} |
|
282 |
|
|
283 |
public void expandAll() { |
|
284 |
int row = 0; |
|
285 |
while (row < this.tree.getRowCount()) { |
|
286 |
this.tree.expandRow(row); |
|
287 |
row++; |
|
288 |
} |
|
289 |
} |
|
290 |
|
|
291 |
/** |
|
292 |
* FunciĆ³n para aƱadir un hijo al nodo actual. |
|
293 |
**/ |
|
294 |
// private DefaultMutableTreeNode addObject(Object child) { |
|
295 |
// DefaultMutableTreeNode parentNode = rootNode; |
|
296 |
// return addObject(parentNode, child, true); |
|
297 |
// } |
|
298 |
|
|
299 |
private DefaultMutableTreeNode addObject(DefaultMutableTreeNode parent, |
|
300 |
Object child) { |
|
301 |
return addObject(parent, child, false); |
|
302 |
} |
|
303 |
|
|
304 |
private DefaultMutableTreeNode addObject(DefaultMutableTreeNode parent, |
|
305 |
Object child, boolean shouldBeVisible) { |
|
306 |
DefaultMutableTreeNode childNode = new DefaultMutableTreeNode(child); |
|
307 |
|
|
308 |
// Si no especificamos padre, lo colgarĆ” del raĆz |
|
309 |
if (parent == null) { |
|
310 |
parent = rootNode; |
|
311 |
} |
|
312 |
|
|
313 |
// Insertamos el nuevo nodo en el modelo del Ɣrbol |
|
314 |
treeModel.insertNodeInto(childNode, parent, parent.getChildCount()); |
|
315 |
|
|
316 |
// Para que el usuario pueda ver el nuevo nodo |
|
317 |
if (shouldBeVisible) { |
|
318 |
tree.scrollPathToVisible(new TreePath(childNode.getPath())); |
|
319 |
} |
|
320 |
|
|
321 |
return childNode; |
|
322 |
} |
|
323 |
|
|
324 |
/** |
|
325 |
* Clase IconData permite asociar hasta dos iconos (para cuando estĆ” |
|
326 |
* expandido y cuando no) a un objeto del Ɣrbol |
|
327 |
**/ |
|
328 |
static private class NodeData { |
|
329 |
|
|
330 |
private Icon m_icon; |
|
331 |
private Icon m_expandedIcon; |
|
332 |
private Object m_data; |
|
333 |
|
|
334 |
public NodeData(Icon icon, Icon expandedIcon, Object data) { |
|
335 |
m_icon = icon; |
|
336 |
m_expandedIcon = expandedIcon; |
|
337 |
m_data = data; |
|
338 |
} |
|
339 |
|
|
340 |
public Icon getIcon() { |
|
341 |
return m_icon; |
|
342 |
} |
|
343 |
|
|
344 |
public Icon getExpandedIcon() { |
|
345 |
return m_expandedIcon != null ? m_expandedIcon : m_icon; |
|
346 |
} |
|
347 |
|
|
348 |
public AboutParticipant getParticipant() { |
|
349 |
try { |
|
350 |
return (AboutParticipant) m_data; |
|
351 |
} catch (Exception e) { |
|
352 |
return null; |
|
353 |
} |
|
354 |
} |
|
355 |
|
|
356 |
public AboutProject getProject() { |
|
357 |
try { |
|
358 |
return (AboutProject) m_data; |
|
359 |
} catch (Exception e) { |
|
360 |
return null; |
|
361 |
} |
|
362 |
} |
|
363 |
|
|
364 |
@Override |
|
365 |
public String toString() { |
|
366 |
return m_data.toString(); |
|
367 |
} |
|
368 |
} |
|
369 |
|
|
370 |
private class IconCellRenderer extends JLabel implements TreeCellRenderer { |
|
371 |
|
|
372 |
/** |
|
373 |
* |
|
374 |
*/ |
|
375 |
private static final long serialVersionUID = 1L; |
|
376 |
protected Color m_textSelectionColor; |
|
377 |
protected Color m_textNonSelectionColor; |
|
378 |
protected Color m_bkSelectionColor; |
|
379 |
protected Color m_bkNonSelectionColor; |
|
380 |
protected Color m_borderSelectionColor; |
|
381 |
|
|
382 |
protected boolean m_selected; |
|
383 |
|
|
384 |
public IconCellRenderer() { |
|
385 |
super(); |
|
386 |
m_textSelectionColor = |
|
387 |
UIManager.getColor("Tree.selectionForeground"); |
|
388 |
m_textNonSelectionColor = UIManager.getColor("Tree.textForeground"); |
|
389 |
m_bkSelectionColor = UIManager.getColor("Tree.selectionBackground"); |
|
390 |
m_bkNonSelectionColor = UIManager.getColor("Tree.textBackground"); |
|
391 |
m_borderSelectionColor = |
|
392 |
UIManager.getColor("Tree.selectionBorderColor"); |
|
393 |
setOpaque(false); |
|
394 |
} |
|
395 |
|
|
396 |
public Component getTreeCellRendererComponent(JTree tree, Object value, |
|
397 |
boolean sel, boolean expanded, boolean leaf, int row, |
|
398 |
boolean hasFocus) { |
|
399 |
|
|
400 |
DefaultMutableTreeNode node = (DefaultMutableTreeNode) value; |
|
401 |
Object obj = node.getUserObject(); |
|
402 |
setText(obj.toString()); |
|
403 |
|
|
404 |
if (obj instanceof Boolean) { |
|
405 |
setText("Retrieving data..."); |
|
406 |
} |
|
407 |
if (obj instanceof NodeData) { |
|
408 |
NodeData nodeData = (NodeData) obj; |
|
409 |
if (expanded) { |
|
410 |
setIcon(nodeData.getExpandedIcon()); |
|
411 |
} else { |
|
412 |
setIcon(nodeData.getIcon()); |
|
413 |
} |
|
414 |
} else { |
|
415 |
setIcon(null); |
|
416 |
} |
|
417 |
|
|
418 |
setFont(tree.getFont()); |
|
419 |
setForeground(sel ? m_textSelectionColor : m_textNonSelectionColor); |
|
420 |
setBackground(sel ? m_bkSelectionColor : m_bkNonSelectionColor); |
|
421 |
m_selected = sel; |
|
422 |
return this; |
|
423 |
} |
|
424 |
|
|
425 |
@Override |
|
426 |
public void paintComponent(Graphics g) { |
|
427 |
Color bColor = getBackground(); |
|
428 |
Icon icon = getIcon(); |
|
429 |
|
|
430 |
g.setColor(bColor); |
|
431 |
int offset = 0; |
|
432 |
if ((icon != null) && (getText() != null)) { |
|
433 |
offset = (icon.getIconWidth() + getIconTextGap()); |
|
434 |
} |
|
435 |
g.fillRect(offset, 0, getWidth() - 1 - offset, getHeight() - 1); |
|
436 |
|
|
437 |
if (m_selected) { |
|
438 |
g.setColor(m_borderSelectionColor); |
|
439 |
g.drawRect(offset, 0, getWidth() - 1 - offset, getHeight() - 1); |
|
440 |
} |
|
441 |
super.paintComponent(g); |
|
442 |
} |
|
443 |
} |
|
444 |
|
|
445 |
} |
branches/org.gvsig.desktop-2.0.411-vcsgis1_0_96/org.gvsig.desktop.library/org.gvsig.about/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; |
|
186 |
} |
|
187 |
|
|
188 |
public List<AboutContribution> getContributions(AboutParticipant participant) { |
|
189 |
return participant.getContributions(); |
|
190 |
} |
|
191 |
|
|
192 |
public ImageIcon getImageIcon(String name) { |
|
193 |
return this.getImageIcon(name, null); |
|
194 |
} |
|
195 |
|
|
196 |
public ImageIcon getImageIcon(URL url) { |
|
197 |
return this.getImageIcon(url, null); |
|
198 |
} |
|
199 |
|
|
200 |
public ImageIcon getImageIcon(String name, String defaultName) { |
|
201 |
URL url = |
|
202 |
this.getClass().getClassLoader() |
|
203 |
.getResource("org/gvsig/about/images/i16x16/" + name); |
|
204 |
return this.getImageIcon(url, defaultName); |
|
205 |
} |
|
206 |
|
|
207 |
public ImageIcon getImageIcon(URL url, String defaultName) { |
|
208 |
if (url == null) { |
|
209 |
url = |
|
210 |
this.getClass() |
|
211 |
.getClassLoader() |
|
212 |
.getResource("org/gvsig/about/images/i16x16/" + defaultName); |
|
213 |
} |
|
214 |
if (url == null) { |
|
215 |
url = |
|
216 |
this.getClass() |
|
217 |
.getClassLoader() |
|
218 |
.getResource( |
|
219 |
"org/gvsig/about/images/i16x16/image-missing.png"); |
|
220 |
} |
|
221 |
if (url == null) { |
|
222 |
url = |
|
223 |
this.getClass() |
|
224 |
.getClassLoader() |
|
225 |
.getResource("org/gvsig/about/images/i16x16/" + defaultName); |
|
226 |
} |
|
227 |
if (url == null) { |
|
228 |
return new ImageIcon(); |
|
229 |
} |
|
230 |
return new ImageIcon(url); |
|
231 |
} |
|
232 |
|
|
233 |
public AboutProject getProject() { |
|
234 |
return this.root; |
|
235 |
} |
|
236 |
|
|
237 |
public List<AboutDeveloper> getDevelopers() { |
|
238 |
return this.developers; |
|
239 |
} |
|
240 |
|
|
241 |
public List<AboutSponsor> getSponsors() { |
|
242 |
return this.sponsors; |
|
243 |
} |
|
244 |
|
|
245 |
public List<AboutTranslator> getTranslators() { |
|
246 |
return this.translators; |
|
247 |
} |
|
248 |
|
|
249 |
// public ImageIcon validIconFormat(URL iconUrl){ |
|
250 |
// // comprobar si existe y comprobar si es imagen |
|
251 |
// if(iconUrl!=null){ |
|
252 |
// |
|
253 |
// File f = new File(iconUrl.getFile()); |
|
254 |
// String mimeType=null; |
|
255 |
// |
|
256 |
// try { |
|
257 |
// mimeType = iconUrl.openConnection().getContentType(); |
|
258 |
// } catch (IOException e) { |
|
259 |
// // TODO Auto-generated catch block |
|
260 |
// e.printStackTrace(); |
|
261 |
// } |
|
262 |
// boolean isImage = false; |
|
263 |
// String[] formatNames = ImageIO.getWriterMIMETypes(); |
|
264 |
// for(int i=0;i<formatNames.length;i++){ |
|
265 |
// if(formatNames[i].equals(mimeType)){ |
|
266 |
// isImage = true; |
|
267 |
// } |
|
268 |
// } |
|
269 |
// |
|
270 |
// if(f.exists() && isImage){ |
|
271 |
// ImageIcon image = new ImageIcon(iconUrl); |
|
272 |
// // Escalamos, si corresponde, el tamaƱo del icono |
|
273 |
// if(image.getIconHeight()>ICON_SIZE || image.getIconWidth()>ICON_SIZE){ |
|
274 |
// float height = image.getIconHeight(); |
|
275 |
// float width = image.getIconWidth(); |
|
276 |
// if(height>=width && height>ICON_SIZE){ |
|
277 |
// width = (width/height*ICON_SIZE); |
|
278 |
// height = ICON_SIZE; |
|
279 |
// }else if(width>height && width>ICON_SIZE){ |
|
280 |
// height = (height/width*ICON_SIZE); |
|
281 |
// width = ICON_SIZE; |
|
282 |
// } |
|
283 |
// Image im = image.getImage(); |
|
284 |
// image.setImage(im.getScaledInstance((int)width,(int)height, 0)); |
|
285 |
// } |
|
286 |
// return image; |
|
287 |
// } |
|
288 |
// } |
|
289 |
// |
|
290 |
// return null; |
|
291 |
// } |
|
292 |
|
|
293 |
@SuppressWarnings("rawtypes") |
|
294 |
private AboutParticipant getParticipantByName(List l, String name) { |
|
295 |
Iterator it = l.iterator(); |
|
296 |
while (it.hasNext()) { |
|
297 |
AboutParticipant ap = (AboutParticipant) it.next(); |
|
298 |
if (ap.getName().equals(name)) { |
|
299 |
return ap; |
|
300 |
} |
|
301 |
} |
|
302 |
return null; |
|
303 |
} |
|
304 |
|
|
305 |
public AboutDeveloper getDeveloper(String name) { |
|
306 |
AboutDeveloper ap = |
|
307 |
(AboutDeveloper) this.getParticipantByName(this.developers, name); |
|
308 |
if (ap != null) { |
|
309 |
return ap; |
|
310 |
} |
|
311 |
return null; |
|
312 |
} |
|
313 |
|
|
314 |
public AboutSponsor getSponsor(String name) { |
|
315 |
AboutSponsor ap = |
|
316 |
(AboutSponsor) this.getParticipantByName(this.sponsors, name); |
|
317 |
if (ap != null) { |
|
318 |
return ap; |
|
319 |
} |
|
320 |
return null; |
|
321 |
} |
|
322 |
|
|
323 |
public AboutTranslator getTranslator(String name) { |
|
324 |
AboutTranslator ap = |
|
325 |
(AboutTranslator) this.getParticipantByName(this.translators, name); |
|
326 |
if (ap != null) { |
|
327 |
return ap; |
|
328 |
} |
|
329 |
return null; |
|
330 |
} |
|
331 |
|
|
332 |
public String getStringFromFile(String filename) |
|
333 |
throws FileNotFoundException, IOException { |
|
334 |
|
|
335 |
BufferedReader b = new BufferedReader(new FileReader(filename)); |
|
336 |
StringBuffer sb = new StringBuffer(); |
|
337 |
String str; |
|
338 |
while ((str = b.readLine()) != null) { |
|
339 |
sb.append(str); |
|
340 |
sb.append('\n'); |
|
341 |
} |
|
342 |
return sb.toString(); |
|
343 |
|
|
344 |
} |
|
345 |
|
|
346 |
public String getStringFromUrl(URL url) { |
|
347 |
InputStream imp = null; |
|
348 |
try { |
|
349 |
imp = url.openStream(); |
|
350 |
} catch (IOException e) { |
|
351 |
return null; |
|
352 |
} |
|
353 |
BufferedReader b = new BufferedReader(new InputStreamReader(imp)); |
|
354 |
StringBuffer sb = new StringBuffer(); |
|
355 |
String str; |
|
356 |
try { |
|
357 |
while ((str = b.readLine()) != null) { |
|
358 |
sb.append(str); |
|
359 |
sb.append('\n'); |
|
360 |
} |
|
361 |
b.close(); |
|
362 |
} catch (IOException e) { |
|
363 |
// Ignore it |
|
364 |
} |
|
365 |
String data = sb.toString(); |
|
366 |
|
|
367 |
return addBaseURLTag(url, data); |
|
368 |
} |
|
369 |
|
|
370 |
/** |
|
371 |
* Add an HTML base tag to the document. |
|
372 |
*/ |
|
373 |
private String addBaseURLTag(URL url, String data) { |
|
374 |
String baseTag = "<base href=\"" + getURLBase(url) + "\"/>"; |
|
375 |
int index = data.indexOf("<head>"); |
|
376 |
// Document contains a head section |
|
377 |
if (index > -1) { |
|
378 |
data = |
|
379 |
data.substring(0, index) // HTML init |
|
380 |
+ "<head>" |
|
381 |
+ baseTag |
|
382 |
+ data.substring(index + "<head>".length()); |
|
383 |
} else { |
|
384 |
index = data.indexOf("<html>"); |
|
385 |
// Document contains an html section |
|
386 |
if (index > -1) { |
|
387 |
data = data.substring(0, index + "<html>".length()) // HTML init |
|
388 |
+ "<head>" + baseTag + "</head>" // Head |
|
389 |
+ data.substring(index + "<html>".length()); |
|
390 |
} else { |
|
391 |
// Document doesn't contain nor a head nor an html section |
|
392 |
data = "<head>" + baseTag + "</head>" // Head |
|
393 |
+ data; |
|
394 |
} |
|
395 |
} |
|
396 |
return data; |
|
397 |
} |
|
398 |
|
|
399 |
public String getStringFromUrl(URL url, Map<String, String> vars) { |
|
400 |
String data = this.getStringFromUrl(url); |
|
401 |
return this.expandVars(data, vars); |
|
402 |
} |
|
403 |
|
|
404 |
public String expandVars(String data, Map<String, String> vars) { |
|
405 |
Iterator<Map.Entry<String, String>> it = vars.entrySet().iterator(); |
|
406 |
while (it.hasNext()) { |
|
407 |
Map.Entry<String, String> entry = it.next(); |
|
408 |
data = replaceVariable(data, entry.getKey(), entry.getValue()); |
|
409 |
} |
|
410 |
return data; |
|
411 |
} |
|
412 |
|
|
413 |
private String replaceVariable(String text, String varName, |
|
414 |
String replacementString) { |
|
415 |
String searchString = "%(".concat(varName).concat(")"); |
|
416 |
StringBuffer sBuffer = new StringBuffer(); |
|
417 |
int pos = 0; |
|
418 |
while ((pos = text.indexOf(searchString)) != -1) { |
|
419 |
sBuffer.append(text.substring(0, pos) + replacementString); |
|
420 |
text = text.substring(pos + searchString.length()); |
|
421 |
} |
|
422 |
sBuffer.append(text); |
|
423 |
return sBuffer.toString(); |
|
424 |
} |
|
425 |
|
|
426 |
public String getURLBase(URL fileURL) { |
|
427 |
if (fileURL != null) { |
|
428 |
String urlStr = fileURL.toString(); |
|
429 |
int index = urlStr.lastIndexOf('/'); |
|
430 |
if (index == urlStr.length() - 1) { |
|
431 |
// It is a / ending the URL, get the previous one |
|
432 |
index = urlStr.substring(0, index).lastIndexOf('/'); |
|
433 |
} |
|
434 |
return urlStr.substring(0, index + 1); |
|
435 |
} |
|
436 |
return null; |
|
437 |
} |
|
438 |
|
|
439 |
// public String generateContributorsPage(AboutParticipant participant) { |
|
440 |
// String fileString=null; |
|
441 |
// |
|
442 |
// String page=null; |
|
443 |
// |
|
444 |
// URL resource = participant.getDescription(); |
|
445 |
// if( resource!=null ) { |
|
446 |
// page = this.getStringFromUrl(resource); |
|
447 |
// } |
|
448 |
// |
|
449 |
// if( page != null ) { |
|
450 |
// String[] s = fileString.split("</body>"); |
|
451 |
// String result = ""; |
|
452 |
// for(int i=0;i<s.length-1;i++){ |
|
453 |
// result = result + s[i]; |
|
454 |
// if(i<s.length-2){ |
|
455 |
// result = result + "</body>"; |
|
456 |
// } |
|
457 |
// } |
|
458 |
// } |
|
459 |
// |
|
460 |
// //Si tiene contribuciones |
|
461 |
// List contributions = participant.getContributions(); |
|
462 |
// if(contributions.size()>0){ |
|
463 |
// String table = "\t<div style=\"padding-top:5px\">\n" + |
|
464 |
// "\t\t<div style=\"background-color: white;padding-top: 5px\">\n" + |
|
465 |
// "\t\t\t<center><h3>Contribuciones realizadas</h3></center>\n" + |
|
466 |
// "\t\t\t<br>\n" + |
|
467 |
// "\t\t\t<table width=\"100%\" border=\"1\">\n" + |
|
468 |
// "\t\t\t\t<tr>\n" + |
|
469 |
// "\t\t\t\t\t<td valign=\"top\" align=\"center\">Nombre</td>\n" + |
|
470 |
// "\t\t\t\t\t<td valign=\"top\" align=\"center\">Descripcion</td>\n" + |
|
471 |
// "\t\t\t\t\t<td valign=\"top\" colspan=\"2\" align=\"center\">Periodo</td>\n" |
|
472 |
// + |
|
473 |
// "\t\t\t\t</tr>\n"; |
|
474 |
// Iterator it = contributions.iterator(); |
|
475 |
// SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy"); |
|
476 |
// while(it.hasNext()){ |
|
477 |
// AboutContribution ap = (AboutContribution)it.next(); |
|
478 |
// String cont = ""; |
|
479 |
// if(ap.getDescription()!=null){ |
|
480 |
// cont=ap.getDescription(); |
|
481 |
// } |
|
482 |
// |
|
483 |
// table = table + |
|
484 |
// "\t\t\t\t<tr>\n" + |
|
485 |
// "\t\t\t\t\t <td valign=\"top\">"+ap.getTitle()+"</td>\n" + |
|
486 |
// "\t\t\t\t\t <td valign=\"top\">"+cont+"</td>\n" + |
|
487 |
// "\t\t\t\t\t <td valign=\"top\">"+formatter.format(ap.getBegin().getTime())+"</td>\n" |
|
488 |
// + |
|
489 |
// "\t\t\t\t\t <td valign=\"top\">"+formatter.format(ap.getEnd().getTime())+"</td>\n" |
|
490 |
// + |
|
491 |
// "\t\t\t\t</tr>\n" ; |
|
492 |
// } |
|
493 |
// table = table + "\t\t\t</table>\n\t\t</div>\n\t</div>\n"; |
|
494 |
// result = result + table+"</body>\n"; |
|
495 |
// } |
|
496 |
// |
|
497 |
// |
|
498 |
// result = result+s[s.length-1]; |
|
499 |
// return result; |
|
500 |
// } |
|
501 |
|
|
502 |
} |
branches/org.gvsig.desktop-2.0.411-vcsgis1_0_96/org.gvsig.desktop.library/org.gvsig.about/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> |
branches/org.gvsig.desktop-2.0.411-vcsgis1_0_96/org.gvsig.desktop.library/org.gvsig.about/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() { |
Also available in: Unified diff