Revision 32290

View differences:

branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.lib/org.gvsig.installer.lib.impl/src/main/java/org/gvsig/installer/lib/impl/DefaultInstallerInfo.java
28 28
package org.gvsig.installer.lib.impl;
29 29

  
30 30
import java.io.File;
31
import java.io.InputStream;
32
import java.io.OutputStream;
31
import java.util.ArrayList;
32
import java.util.List;
33 33

  
34 34
import org.gvsig.installer.lib.api.InstallerInfo;
35 35

  
......
44 44
	protected int build = 0;
45 45
	protected String state = "Testing";
46 46
	protected boolean official;
47
	protected List<File> selectedFiles = null;
48
	
49
	public DefaultInstallerInfo() {
50
		super();
51
		selectedFiles = new ArrayList<File>();
52
	}
47 53

  
48 54
	public String getCode() {
49 55
		return code;
......
102 108
	}
103 109

  
104 110
	public void addFileToCopy(File file) {
105
		// TODO Auto-generated method stub
106
		
111
		selectedFiles.add(file);		
107 112
	}
108 113

  
109 114
	public File getFileToCopyAt(int index) {
110
		// TODO Auto-generated method stub
111
		return null;
115
		return selectedFiles.get(index);
112 116
	}
113 117

  
114 118
	public int getFileToCopySize() {
115
		// TODO Auto-generated method stub
116
		return 0;
119
		return selectedFiles.size();
117 120
	}
118 121

  
119 122
	public void removeFileToCopy(int index) {
120
		// TODO Auto-generated method stub
121
		
123
		selectedFiles.remove(index);		
122 124
	}
123 125

  
124 126
}
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.lib/org.gvsig.installer.lib.impl/src/main/java/org/gvsig/installer/lib/impl/creation/DefaultInstallerCreationService.java
29 29

  
30 30
import java.io.File;
31 31
import java.io.FileInputStream;
32
import java.io.FileOutputStream;
33
import java.io.IOException;
34
import java.io.InputStream;
32 35
import java.io.OutputStream;
33 36

  
34 37
import org.gvsig.installer.lib.api.InstallerInfo;
......
44 47
 */
45 48
public class DefaultInstallerCreationService extends DefaultInstallerInfo implements InstallerCreationService {
46 49
	public static final String INSTALLINFO_FILE_NAME = "install.info";
50
	public static final String COPIED_FILES_DIRECTORY_NAME = "files";
47 51
	private File pluginDirectory;
48 52

  
49 53

  
......
52 56
		if (pluginDirectory == null){
53 57
			throw new InstallerCreationServiceException("The plugin directory has to be set");
54 58
		}
55
		
59

  
60
		//Write the install.info file
56 61
		writeInstallInfo();
57 62

  
63
		//Copy the selected files
64
		writeSelectedFiles();
65

  
58 66
		Compress compress = new Compress();
59 67
		compress.compressPlugin(pluginDirectory, installerStream);			
60 68
	}
61 69

  
70
	private void writeSelectedFiles() throws InstallerCreationServiceException {
71
		try{
72
			String copiedFilesDirectory = getCopiedFilesDirectoryName();
73

  
74
			//Deleting the previous files folder
75
			File copiedFilesDirectoryfile = new File(copiedFilesDirectory);
76
			deleteDirectory(copiedFilesDirectoryfile);
77

  
78
			String parentDirectory = pluginDirectory.getParent();
79
			for (int i=0 ; i<selectedFiles.size() ; i++){
80
				String destFile = selectedFiles.get(i).getAbsolutePath();
81

  
82
				//Deleting the root where the gvSIG plugins are located
83
				destFile = destFile.substring(parentDirectory.length(), destFile.length());
84

  
85
				//Create the final path
86
				destFile = copiedFilesDirectory + destFile;
87

  
88
				//Copy the files
89
				copy(selectedFiles.get(i), new File(destFile));
90
			}
91
		}catch(IOException e){
92
			throw new InstallerCreationServiceException("Exception copying the files");
93
		}
94
	}
95

  
96
	static public boolean deleteDirectory(File path) {
97
		if( path.exists() ) {
98
			File[] files = path.listFiles();
99
			for(int i=0; i<files.length; i++) {
100
				if(files[i].isDirectory()) {
101
					deleteDirectory(files[i]);
102
				}
103
				else {
104
					files[i].delete();
105
				}
106
			}
107
		}
108
		return( path.delete() );
109
	}
110

  
111

  
112
	void copy(File sourceLocation , File targetLocation) throws IOException { 
113
		if (sourceLocation.isDirectory()) {
114
			if (!targetLocation.exists()) {
115
				targetLocation.mkdir();
116
			}
117

  
118
			String[] children = sourceLocation.list();
119
			for (int i=0; i<children.length; i++) {
120
				copy(new File(sourceLocation, children[i]),
121
						new File(targetLocation, children[i]));
122
			}
123
		} else {
124
			targetLocation.getParentFile().mkdirs();
125

  
126
			InputStream in = new FileInputStream(sourceLocation);
127
			OutputStream out = new FileOutputStream(targetLocation);
128

  
129
			// Copy the bits from instream to outstream
130
			byte[] buf = new byte[1024];
131
			int len;
132
			while ((len = in.read(buf)) > 0) {
133
				out.write(buf, 0, len);
134
			}
135
			in.close();
136
			out.close();
137
		}		 
138
	}
139

  
62 140
	public void setPluginDirectory(File pluginDirectory) throws InstallerCreationServiceException {
63 141
		if (!pluginDirectory.isDirectory()){
64 142
			throw new InstallerCreationServiceException("The plugin directory has to be a directory");
......
79 157
		InstallerInfoFileReader installerInfoFileReader = new InstallerInfoFileReader();
80 158
		installerInfoFileReader.read(this, getInstallerInfoFileName());
81 159
	}	
82
	
160

  
83 161
	private void writeInstallInfo() throws InstallerInfoFileException{
84 162
		InstallerInfoFileWriter installerInfoFileWriter = new InstallerInfoFileWriter();
85 163
		installerInfoFileWriter.write(this, new File(getInstallerInfoFileName()));
86 164
	}
87 165

  
166
	private String getCopiedFilesDirectoryName(){
167
		return pluginDirectory + File.separator + COPIED_FILES_DIRECTORY_NAME;
168
	}
169

  
88 170
	private String getInstallerInfoFileName(){
89 171
		return pluginDirectory + File.separator + INSTALLINFO_FILE_NAME;
90 172
	}
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/creation/DefaultInstallerCreationWizard.java
126 126

  
127 127
	@Override
128 128
	public void setPluginsDirectory(File pluginsDirectory) {
129
		selectPlugintoInstallWizard.setPluginsDirectory(pluginsDirectory);		
129
		selectPlugintoInstallWizard.setPluginsDirectory(pluginsDirectory);	
130
		selectFilesWizard.setPluginsDirectory(pluginsDirectory);
130 131
	}	
131 132

  
132 133

  
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/creation/panel/AntScriptPanel.java
1 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
*/
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 22

  
23 23
/*
24
* AUTHORS (In addition to CIT):
25
* 2010 {Prodevelop}   {Task}
26
*/
27
 
24
 * AUTHORS (In addition to CIT):
25
 * 2010 {Prodevelop}   {Task}
26
 */
27

  
28 28
package org.gvsig.installer.swing.impl.creation.panel;
29 29

  
30
import javax.swing.JEditorPane;
30 31
import javax.swing.JPanel;
32
import javax.swing.JScrollPane;
31 33

  
32 34
import org.gvsig.installer.swing.api.SwingInstallerLocator;
33 35
import org.gvsig.installer.swing.impl.DefaultSwingInstallerManager;
......
37 39
 */
38 40
public class AntScriptPanel extends JPanel {
39 41
	protected DefaultSwingInstallerManager swingInstallerManager = null;
42
	private JEditorPane scriptEditorPane;
43
	private JScrollPane scriptScrollPane;
40 44

  
41 45
	public AntScriptPanel() {
42 46
		super();
......
45 49
	}
46 50

  
47 51
	private void initComponents() {
48
		
52
		java.awt.GridBagConstraints gridBagConstraints;
53

  
54
		scriptScrollPane = new javax.swing.JScrollPane();
55
		scriptEditorPane = new javax.swing.JEditorPane();
56

  
57
		setLayout(new java.awt.GridBagLayout());
58

  
59
		scriptScrollPane.setViewportView(scriptEditorPane);
60

  
61
		gridBagConstraints = new java.awt.GridBagConstraints();
62
		gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
63
		gridBagConstraints.weightx = 1.0;
64
		gridBagConstraints.weighty = 1.0;
65
		add(scriptScrollPane, gridBagConstraints);
49 66
	}
50 67
}
51 68

  
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/creation/panel/AdvancedModeSelectionPanel.java
27 27

  
28 28
package org.gvsig.installer.swing.impl.creation.panel;
29 29

  
30
import java.awt.BorderLayout;
31

  
32
import javax.swing.BorderFactory;
33
import javax.swing.JCheckBox;
30 34
import javax.swing.JPanel;
35
import javax.swing.JScrollPane;
36
import javax.swing.JTextArea;
31 37

  
32 38
import org.gvsig.installer.swing.api.SwingInstallerLocator;
33 39
import org.gvsig.installer.swing.impl.DefaultSwingInstallerManager;
......
37 43
 */
38 44
public class AdvancedModeSelectionPanel extends JPanel{
39 45
	protected DefaultSwingInstallerManager swingInstallerManager = null;
40
	private javax.swing.JCheckBox advancedModeCheckBox;
46
	private JCheckBox advancedModeCheckBox;
41 47

  
42
	private javax.swing.JScrollPane advancedModeScrollPane;
43
	private javax.swing.JTextArea advancedModeTextArea;
44
	private javax.swing.JPanel northPanel;
48
	private JScrollPane advancedModeScrollPane;
49
	private JTextArea advancedModeTextArea;
50
	private JPanel northPanel;
45 51

  
46 52
	public AdvancedModeSelectionPanel() {
47 53
		super();
......
55 61
	}
56 62

  
57 63
	private void initComponents() {
58
		advancedModeCheckBox = new javax.swing.JCheckBox();
59
        advancedModeScrollPane = new javax.swing.JScrollPane();
60
        advancedModeTextArea = new javax.swing.JTextArea();
64
		advancedModeCheckBox = new JCheckBox();
65
        advancedModeScrollPane = new JScrollPane();
66
        advancedModeTextArea = new JTextArea();
61 67

  
62 68
        setLayout(new java.awt.BorderLayout());
63 69

  
64 70
        advancedModeCheckBox.setText("Activar el modo avanzado");
65
        add(advancedModeCheckBox, java.awt.BorderLayout.NORTH);
71
        add(advancedModeCheckBox, BorderLayout.NORTH);
66 72

  
67
        advancedModeScrollPane.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
73
        advancedModeScrollPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
68 74

  
69 75
        advancedModeTextArea.setBackground(this.getBackground());
70 76
        advancedModeTextArea.setColumns(20);
71 77
        advancedModeTextArea.setLineWrap(true);
72 78
        advancedModeTextArea.setRows(5);
73
        advancedModeTextArea.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
79
        advancedModeTextArea.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
74 80
        advancedModeScrollPane.setViewportView(advancedModeTextArea);
75 81

  
76
        add(advancedModeScrollPane, java.awt.BorderLayout.CENTER);
82
        add(advancedModeScrollPane, BorderLayout.CENTER);
77 83
	}
78 84
	
79 85
	/**
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/creation/panel/PlugintoInstallTablePanel.java
27 27

  
28 28
package org.gvsig.installer.swing.impl.creation.panel;
29 29

  
30
import java.awt.GridBagConstraints;
31
import java.awt.GridBagLayout;
32
import java.awt.Insets;
33

  
30 34
import javax.swing.JPanel;
35
import javax.swing.JScrollPane;
36
import javax.swing.JTable;
37
import javax.swing.JTextArea;
31 38

  
32 39
import org.gvsig.installer.swing.api.SwingInstallerLocator;
33 40
import org.gvsig.installer.swing.impl.DefaultSwingInstallerManager;
......
37 44
 */
38 45
public class PlugintoInstallTablePanel extends JPanel{
39 46
	protected DefaultSwingInstallerManager swingInstallerManager = null;
40
	private javax.swing.JScrollPane jScrollPane2;
41
	private javax.swing.JTextArea jTextArea1;
42
	private javax.swing.JTable pluginTable;
43
	private javax.swing.JScrollPane pluginjScrollPane;
47
	private JScrollPane jScrollPane2;
48
	private JTextArea jTextArea1;
49
	private JTable pluginTable;
50
	private JScrollPane pluginjScrollPane;
44 51

  
45 52
	public PlugintoInstallTablePanel() {
46 53
		super();
......
51 58
	private void initComponents() {
52 59
        java.awt.GridBagConstraints gridBagConstraints;
53 60

  
54
        pluginjScrollPane = new javax.swing.JScrollPane();
55
        pluginTable = new javax.swing.JTable();
56
        jScrollPane2 = new javax.swing.JScrollPane();
57
        jTextArea1 = new javax.swing.JTextArea();
61
        pluginjScrollPane = new JScrollPane();
62
        pluginTable = new JTable();
63
        jScrollPane2 = new JScrollPane();
64
        jTextArea1 = new JTextArea();
58 65

  
59
        setLayout(new java.awt.GridBagLayout());
66
        setLayout(new GridBagLayout());
60 67

  
61 68
        pluginjScrollPane.setViewportView(pluginTable);
62 69

  
63
        gridBagConstraints = new java.awt.GridBagConstraints();
64
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
70
        gridBagConstraints = new GridBagConstraints();
71
        gridBagConstraints.fill = GridBagConstraints.BOTH;
65 72
        gridBagConstraints.weightx = 1.0;
66 73
        gridBagConstraints.weighty = 0.5;
67
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
74
        gridBagConstraints.insets = new Insets(2, 2, 2, 2);
68 75
        add(pluginjScrollPane, gridBagConstraints);
69 76

  
70 77
        jTextArea1.setColumns(20);
71 78
        jTextArea1.setRows(5);
72 79
        jScrollPane2.setViewportView(jTextArea1);
73 80

  
74
        gridBagConstraints = new java.awt.GridBagConstraints();
81
        gridBagConstraints = new GridBagConstraints();
75 82
        gridBagConstraints.gridx = 0;
76 83
        gridBagConstraints.gridy = 1;
77
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
84
        gridBagConstraints.fill = GridBagConstraints.BOTH;
78 85
        gridBagConstraints.weightx = 1.0;
79 86
        gridBagConstraints.weighty = 0.5;
80
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
87
        gridBagConstraints.insets = new Insets(2, 2, 2, 2);
81 88
        add(jScrollPane2, gridBagConstraints);
82 89
	}
83 90

  
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/creation/panel/SelectOutputFilePanel.java
27 27

  
28 28
package org.gvsig.installer.swing.impl.creation.panel;
29 29

  
30
import java.awt.BorderLayout;
31
import java.awt.GridBagConstraints;
32
import java.awt.GridBagLayout;
30 33
import java.io.File;
31 34

  
35
import javax.swing.JLabel;
32 36
import javax.swing.JPanel;
33 37

  
34 38
import org.gvsig.gui.beans.openfile.FileTextField;
......
40 44
 */
41 45
public class SelectOutputFilePanel extends JPanel{
42 46
	protected DefaultSwingInstallerManager swingInstallerManager = null;
43
	private javax.swing.JLabel fileLabel;
47
	private JLabel fileLabel;
44 48
	private FileTextField fileTextField;
45 49
    private javax.swing.JPanel northPanel;
46 50

  
......
60 64
	private void initComponents() {
61 65
        java.awt.GridBagConstraints gridBagConstraints;
62 66

  
63
        northPanel = new javax.swing.JPanel();
64
        fileLabel = new javax.swing.JLabel();
67
        northPanel = new JPanel();
68
        fileLabel = new JLabel();
65 69
        fileTextField = new FileTextField();
66 70

  
67
        setLayout(new java.awt.BorderLayout());
71
        setLayout(new BorderLayout());
68 72

  
69
        northPanel.setLayout(new java.awt.GridBagLayout());
73
        northPanel.setLayout(new GridBagLayout());
70 74
       
71
        northPanel.add(fileLabel, new java.awt.GridBagConstraints());
75
        northPanel.add(fileLabel, new GridBagConstraints());
72 76

  
73
        gridBagConstraints = new java.awt.GridBagConstraints();
77
        gridBagConstraints = new GridBagConstraints();
74 78
        gridBagConstraints.gridx = 1;
75 79
        gridBagConstraints.gridy = 0;
76
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
80
        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
77 81
        gridBagConstraints.weightx = 1.0;
78 82
        northPanel.add(fileTextField, gridBagConstraints);
79 83

  
80
        add(northPanel, java.awt.BorderLayout.NORTH);
84
        add(northPanel, BorderLayout.NORTH);
81 85
	}
82 86
	
83 87
	public File getSelectedFile(){
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/creation/panel/PluginDescriptionPanel.java
27 27

  
28 28
package org.gvsig.installer.swing.impl.creation.panel;
29 29

  
30
import java.awt.Dimension;
31
import java.awt.GridBagConstraints;
32
import java.awt.Insets;
33

  
30 34
import javax.swing.JCheckBox;
31 35
import javax.swing.JComboBox;
32 36
import javax.swing.JLabel;
......
78 82
	private void initComponents() {
79 83
		java.awt.GridBagConstraints gridBagConstraints;
80 84

  
81
		nameLabel = new javax.swing.JLabel();
82
		naemText = new javax.swing.JTextField();
83
		descriptionScrollPane = new javax.swing.JScrollPane();
84
		descriptionArea = new javax.swing.JTextArea();
85
		descriptionLabel = new javax.swing.JLabel();
86
		versionLabel = new javax.swing.JLabel();
87
		versionText = new javax.swing.JTextField();
88
		buildLabel = new javax.swing.JLabel();
89
		buildText = new javax.swing.JTextField();
90
		statusLabel = new javax.swing.JLabel();
85
		nameLabel = new JLabel();
86
		naemText = new JTextField();
87
		descriptionScrollPane = new JScrollPane();
88
		descriptionArea = new JTextArea();
89
		descriptionLabel = new JLabel();
90
		versionLabel = new JLabel();
91
		versionText = new JTextField();
92
		buildLabel = new JLabel();
93
		buildText = new JTextField();
94
		statusLabel = new JLabel();
91 95
		offcialLabel = new javax.swing.JLabel();
92
		statusCombo = new javax.swing.JComboBox();
93
		offcicialCheckBox = new javax.swing.JCheckBox();
94
		codeLabel = new javax.swing.JLabel();
95
		codeText = new javax.swing.JTextField();
96
		statusCombo = new JComboBox();
97
		offcicialCheckBox = new JCheckBox();
98
		codeLabel = new JLabel();
99
		codeText = new JTextField();
96 100

  
97 101
		setLayout(new java.awt.GridBagLayout());
98 102

  
99 103
		nameLabel.setText("Name");
100
		gridBagConstraints = new java.awt.GridBagConstraints();
104
		gridBagConstraints = new GridBagConstraints();
101 105
		gridBagConstraints.gridx = 0;
102 106
		gridBagConstraints.gridy = 1;
103
		gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
104
		gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
107
		gridBagConstraints.anchor = GridBagConstraints.EAST;
108
		gridBagConstraints.insets = new Insets(2, 2, 2, 2);
105 109
		add(nameLabel, gridBagConstraints);
106
		gridBagConstraints = new java.awt.GridBagConstraints();
110
		gridBagConstraints = new GridBagConstraints();
107 111
		gridBagConstraints.gridx = 1;
108 112
		gridBagConstraints.gridy = 1;
109
		gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
113
		gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
110 114
		gridBagConstraints.weightx = 1.0;
111
		gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
115
		gridBagConstraints.insets = new Insets(2, 2, 2, 2);
112 116
		add(naemText, gridBagConstraints);
113 117

  
114 118
		descriptionArea.setColumns(20);
115 119
		descriptionArea.setRows(5);
116 120
		descriptionScrollPane.setViewportView(descriptionArea);
117 121

  
118
		gridBagConstraints = new java.awt.GridBagConstraints();
122
		gridBagConstraints = new GridBagConstraints();
119 123
		gridBagConstraints.gridx = 1;
120 124
		gridBagConstraints.gridy = 2;
121
		gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
125
		gridBagConstraints.fill = GridBagConstraints.BOTH;
122 126
		gridBagConstraints.weightx = 1.0;
123 127
		gridBagConstraints.weighty = 1.0;
124
		gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
128
		gridBagConstraints.insets = new Insets(2, 2, 2, 2);
125 129
		add(descriptionScrollPane, gridBagConstraints);
126 130

  
127 131
		descriptionLabel.setText("Description");
128
		gridBagConstraints = new java.awt.GridBagConstraints();
132
		gridBagConstraints = new GridBagConstraints();
129 133
		gridBagConstraints.gridx = 0;
130 134
		gridBagConstraints.gridy = 2;
131
		gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
132
		gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
135
		gridBagConstraints.anchor = GridBagConstraints.NORTH;
136
		gridBagConstraints.insets = new Insets(2, 2, 2, 2);
133 137
		add(descriptionLabel, gridBagConstraints);
134 138

  
135 139
		versionLabel.setText("Version");
136
		gridBagConstraints = new java.awt.GridBagConstraints();
140
		gridBagConstraints = new GridBagConstraints();
137 141
		gridBagConstraints.gridx = 0;
138 142
		gridBagConstraints.gridy = 3;
139
		gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
140
		gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
143
		gridBagConstraints.anchor = GridBagConstraints.EAST;
144
		gridBagConstraints.insets = new Insets(2, 2, 2, 2);
141 145
		add(versionLabel, gridBagConstraints);
142 146

  
143
		versionText.setPreferredSize(new java.awt.Dimension(100, 27));
147
		versionText.setPreferredSize(new Dimension(100, 27));
144 148
		gridBagConstraints = new java.awt.GridBagConstraints();
145 149
		gridBagConstraints.gridx = 1;
146 150
		gridBagConstraints.gridy = 3;
147
		gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
148
		gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
151
		gridBagConstraints.anchor = GridBagConstraints.WEST;
152
		gridBagConstraints.insets = new Insets(2, 2, 2, 2);
149 153
		add(versionText, gridBagConstraints);
150 154

  
151 155
		buildLabel.setText("Build");
152
		gridBagConstraints = new java.awt.GridBagConstraints();
156
		gridBagConstraints = new GridBagConstraints();
153 157
		gridBagConstraints.gridx = 0;
154 158
		gridBagConstraints.gridy = 4;
155
		gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
156
		gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
159
		gridBagConstraints.anchor = GridBagConstraints.EAST;
160
		gridBagConstraints.insets = new Insets(2, 2, 2, 2);
157 161
		add(buildLabel, gridBagConstraints);
158 162

  
159 163
		buildText.setPreferredSize(new java.awt.Dimension(100, 27));
160
		gridBagConstraints = new java.awt.GridBagConstraints();
164
		gridBagConstraints = new GridBagConstraints();
161 165
		gridBagConstraints.gridx = 1;
162 166
		gridBagConstraints.gridy = 4;
163
		gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
164
		gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
167
		gridBagConstraints.anchor = GridBagConstraints.WEST;
168
		gridBagConstraints.insets = new Insets(2, 2, 2, 2);
165 169
		add(buildText, gridBagConstraints);
166 170

  
167 171
		statusLabel.setText("Status");
168
		gridBagConstraints = new java.awt.GridBagConstraints();
172
		gridBagConstraints = new GridBagConstraints();
169 173
		gridBagConstraints.gridx = 0;
170 174
		gridBagConstraints.gridy = 5;
171
		gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
172
		gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
175
		gridBagConstraints.anchor = GridBagConstraints.EAST;
176
		gridBagConstraints.insets = new Insets(2, 2, 2, 2);
173 177
		add(statusLabel, gridBagConstraints);
174 178

  
175 179
		offcialLabel.setText("Is official");
176
		gridBagConstraints = new java.awt.GridBagConstraints();
180
		gridBagConstraints = new GridBagConstraints();
177 181
		gridBagConstraints.gridx = 0;
178 182
		gridBagConstraints.gridy = 6;
179
		gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
183
		gridBagConstraints.anchor = GridBagConstraints.EAST;
180 184
		gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
181 185
		add(offcialLabel, gridBagConstraints);
182 186

  
183 187
		statusCombo.setPreferredSize(new java.awt.Dimension(100, 27));
184
		gridBagConstraints = new java.awt.GridBagConstraints();
188
		gridBagConstraints = new GridBagConstraints();
185 189
		gridBagConstraints.gridx = 1;
186 190
		gridBagConstraints.gridy = 5;
187
		gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
188
		gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
191
		gridBagConstraints.anchor = GridBagConstraints.WEST;
192
		gridBagConstraints.insets = new Insets(2, 2, 2, 2);
189 193
		add(statusCombo, gridBagConstraints);
190
		gridBagConstraints = new java.awt.GridBagConstraints();
194
		gridBagConstraints = new GridBagConstraints();
191 195
		gridBagConstraints.gridx = 1;
192 196
		gridBagConstraints.gridy = 6;
193
		gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
197
		gridBagConstraints.anchor = GridBagConstraints.WEST;
194 198
		gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
195 199
		add(offcicialCheckBox, gridBagConstraints);
196 200

  
197 201
		codeLabel.setText("Code");
198
		gridBagConstraints = new java.awt.GridBagConstraints();
199
		gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
200
		gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
202
		gridBagConstraints = new GridBagConstraints();
203
		gridBagConstraints.anchor = GridBagConstraints.EAST;
204
		gridBagConstraints.insets = new Insets(2, 2, 2, 2);
201 205
		add(codeLabel, gridBagConstraints);
202
		gridBagConstraints = new java.awt.GridBagConstraints();
203
		gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
206
		gridBagConstraints = new GridBagConstraints();
207
		gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
204 208
		gridBagConstraints.weightx = 1.0;
205
		gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
209
		gridBagConstraints.insets = new Insets(2, 2, 2, 2);
206 210
		add(codeText, gridBagConstraints);
207 211
	}
208 212

  
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/creation/panel/SelectFilesPanel.java
1 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
*/
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 22

  
23 23
/*
24
* AUTHORS (In addition to CIT):
25
* 2010 {Prodevelop}   {Task}
26
*/
27
 
24
 * AUTHORS (In addition to CIT):
25
 * 2010 {Prodevelop}   {Task}
26
 */
27

  
28 28
package org.gvsig.installer.swing.impl.creation.panel;
29 29

  
30
import java.awt.GridBagConstraints;
31
import java.awt.GridBagLayout;
32
import java.io.File;
33
import java.util.List;
34

  
30 35
import javax.swing.JPanel;
36
import javax.swing.JScrollPane;
31 37

  
32 38
import org.gvsig.installer.swing.api.SwingInstallerLocator;
33 39
import org.gvsig.installer.swing.impl.DefaultSwingInstallerManager;
40
import org.gvsig.installer.swing.impl.creation.model.SelectFilesTree;
34 41

  
35 42
/**
36 43
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
37 44
 */
38 45
public class SelectFilesPanel extends JPanel{
39 46
	protected DefaultSwingInstallerManager swingInstallerManager = null;
47
	private JScrollPane resourcesScrollPane;
48
	private SelectFilesTree resourcesTree;
49
	private File pluginsDirectory = null;
40 50

  
41 51
	public SelectFilesPanel() {
42 52
		super();
......
44 54
		initComponents();
45 55
	}
46 56

  
57
	public void setPluginsDirectory(File pluginsDirectory)
58
	{
59
		resourcesTree.setDirectory(pluginsDirectory);
60
		this.pluginsDirectory = pluginsDirectory;
61
	}
62

  
47 63
	private void initComponents() {
48
		
64
		GridBagConstraints gridBagConstraints;
65

  
66
		resourcesScrollPane = new JScrollPane();
67
		resourcesTree = new SelectFilesTree();		
68

  
69
		setLayout(new GridBagLayout());
70

  
71
		resourcesScrollPane.setViewportView(resourcesTree);
72

  
73
		gridBagConstraints = new GridBagConstraints();
74
		gridBagConstraints.fill = GridBagConstraints.BOTH;
75
		gridBagConstraints.weightx = 1.0;
76
		gridBagConstraints.weighty = 1.0;
77
		add(resourcesScrollPane, gridBagConstraints);
78
	}	
79
	
80
	public List<File> getSelectedFiles(){
81
		return resourcesTree.getSelectedFiles();
49 82
	}
50 83
}
51 84

  
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/creation/panel/ProgressPanel.java
27 27

  
28 28
package org.gvsig.installer.swing.impl.creation.panel;
29 29

  
30
import java.awt.Font;
31
import java.awt.GridBagConstraints;
32
import java.awt.GridBagLayout;
33
import java.awt.Insets;
34

  
35
import javax.swing.JLabel;
30 36
import javax.swing.JPanel;
37
import javax.swing.JProgressBar;
31 38

  
32 39
import org.gvsig.installer.lib.api.creation.InstallerCreationServiceException;
33 40
import org.gvsig.installer.swing.api.SwingInstallerLocator;
......
38 45
 */
39 46
public class ProgressPanel extends JPanel {
40 47
	protected DefaultSwingInstallerManager swingInstallerManager = null;
41
	private javax.swing.JLabel pluginLabel;
42
	private javax.swing.JProgressBar progressBar;
43
	private javax.swing.JLabel progressLabel;
48
	private JLabel pluginLabel;
49
	private JProgressBar progressBar;
50
	private JLabel progressLabel;
44 51

  
45 52
	public ProgressPanel() {
46 53
		super();
......
56 63
	private void initComponents() {
57 64
		java.awt.GridBagConstraints gridBagConstraints;
58 65

  
59
		progressBar = new javax.swing.JProgressBar();
60
		progressLabel = new javax.swing.JLabel();
61
		pluginLabel = new javax.swing.JLabel();
66
		progressBar = new JProgressBar();
67
		progressLabel = new JLabel();
68
		pluginLabel = new JLabel();
62 69

  
63
		setLayout(new java.awt.GridBagLayout());
64
		gridBagConstraints = new java.awt.GridBagConstraints();
70
		setLayout(new GridBagLayout());
71
		gridBagConstraints = new GridBagConstraints();
65 72
		gridBagConstraints.gridx = 0;
66 73
		gridBagConstraints.gridy = 2;
67
		gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
74
		gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
68 75
		gridBagConstraints.weightx = 1.0;
69
		gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
76
		gridBagConstraints.insets = new Insets(2, 2, 2, 2);
70 77
		add(progressBar, gridBagConstraints);
71 78

  
72
		progressLabel.setFont(new java.awt.Font("DejaVu Sans", 0, 11)); // NOI18N
79
		progressLabel.setFont(new Font("DejaVu Sans", 0, 11)); // NOI18N
73 80
		progressLabel.setText("task");
74
		gridBagConstraints = new java.awt.GridBagConstraints();
81
		gridBagConstraints = new GridBagConstraints();
75 82
		gridBagConstraints.gridx = 0;
76 83
		gridBagConstraints.gridy = 1;
77
		gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
78
		gridBagConstraints.insets = new java.awt.Insets(5, 2, 2, 2);
84
		gridBagConstraints.anchor = GridBagConstraints.WEST;
85
		gridBagConstraints.insets = new Insets(5, 2, 2, 2);
79 86
		add(progressLabel, gridBagConstraints);
80 87

  
81 88
		pluginLabel.setText("plugin");
82
		gridBagConstraints = new java.awt.GridBagConstraints();
83
		gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
84
		gridBagConstraints.insets = new java.awt.Insets(5, 2, 2, 2);
89
		gridBagConstraints = new GridBagConstraints();
90
		gridBagConstraints.anchor = GridBagConstraints.WEST;
91
		gridBagConstraints.insets = new Insets(5, 2, 2, 2);
85 92
		add(pluginLabel, gridBagConstraints);
86 93
	}
87 94

  
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/creation/model/SelectFilesTreeCellRenderer.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

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2010 {Prodevelop}   {Task}
26
 */
27

  
28
package org.gvsig.installer.swing.impl.creation.model;
29

  
30
import java.awt.Color;
31
import java.awt.Component;
32
import java.awt.Dimension;
33
import java.awt.Graphics;
34

  
35
import javax.swing.Icon;
36
import javax.swing.JCheckBox;
37
import javax.swing.JLabel;
38
import javax.swing.JPanel;
39
import javax.swing.JTree;
40
import javax.swing.UIManager;
41
import javax.swing.plaf.ColorUIResource;
42
import javax.swing.tree.TreeCellRenderer;
43

  
44
/**
45
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
46
 */
47
public class SelectFilesTreeCellRenderer extends JPanel implements TreeCellRenderer {
48
	protected JCheckBox check;
49

  
50
	public SelectFilesTreeCellRenderer() {
51
		setLayout(null);
52
		add(check = new JCheckBox());
53
		check.setBackground(UIManager.getColor("Tree.textBackground"));
54
	}
55

  
56
	public Component getTreeCellRendererComponent(JTree tree, Object value,
57
			boolean isSelected, boolean expanded, boolean leaf, int row,
58
			boolean hasFocus) {		
59
		String stringValue = tree.convertValueToText(value, isSelected,
60
				expanded, leaf, row, hasFocus);
61
		
62
		setEnabled(tree.isEnabled());
63
		check.setSelected(((SelectFilesTreeCheckNode) value).isSelected());
64
		check.setText(stringValue);
65
		return this;
66
	}
67

  
68
	public Dimension getPreferredSize() {
69
		Dimension d_check = check.getPreferredSize();	
70
		return new Dimension(d_check.width , d_check.height );
71

  
72
	}
73

  
74
	public void doLayout() {
75
		Dimension d_check = check.getPreferredSize();
76
		int y_check = 0;
77
		int y_label = 0;
78
		check.setLocation(0, y_check);
79
		check.setBounds(0, y_check, d_check.width, d_check.height);
80
	}
81

  
82
	public void setBackground(Color color) {
83
		if (color instanceof ColorUIResource)
84
			color = null;
85
		super.setBackground(color);
86
	}
87

  
88
	public class TreeLabel extends JLabel {
89
		boolean isSelected;
90

  
91
		boolean hasFocus;
92

  
93
		public TreeLabel() {
94
		}
95

  
96
		public void setBackground(Color color) {
97
			if (color instanceof ColorUIResource)
98
				color = null;
99
			super.setBackground(color);
100
		}
101

  
102
		public void paint(Graphics g) {
103
			String str;
104
			if ((str = getText()) != null) {
105
				if (0 < str.length()) {
106
					if (isSelected) {
107
						g.setColor(UIManager
108
								.getColor("Tree.selectionBackground"));
109
					} else {
110
						g.setColor(UIManager.getColor("Tree.textBackground"));
111
					}
112
					Dimension d = getPreferredSize();
113
					int imageOffset = 0;
114
					Icon currentI = getIcon();
115
					if (currentI != null) {
116
						imageOffset = currentI.getIconWidth()
117
						+ Math.max(0, getIconTextGap() - 1);
118
					}
119
					g.fillRect(imageOffset, 0, d.width - 1 - imageOffset,
120
							d.height);
121
					if (hasFocus) {
122
						g.setColor(UIManager
123
								.getColor("Tree.selectionBorderColor"));
124
						g.drawRect(imageOffset, 0, d.width - 1 - imageOffset,
125
								d.height - 1);
126
					}
127
				}
128
			}
129
			super.paint(g);
130
		}
131

  
132
		public Dimension getPreferredSize() {
133
			Dimension retDimension = super.getPreferredSize();
134
			if (retDimension != null) {
135
				retDimension = new Dimension(retDimension.width + 3,
136
						retDimension.height);
137
			}
138
			return retDimension;
139
		}
140

  
141
		public void setSelected(boolean isSelected) {
142
			this.isSelected = isSelected;
143
		}
144

  
145
		public void setFocus(boolean hasFocus) {
146
			this.hasFocus = hasFocus;
147
		}
148
	}
149
}
0 150

  
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/creation/model/SelectFilesTree.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

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2010 {Prodevelop}   {Task}
26
*/
27
 
28
package org.gvsig.installer.swing.impl.creation.model;
29

  
30
import java.io.File;
31
import java.util.ArrayList;
32
import java.util.List;
33

  
34
import javax.swing.JTree;
35
import javax.swing.tree.TreePath;
36
import javax.swing.tree.TreeSelectionModel;
37

  
38
/**
39
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
40
 */
41
public class SelectFilesTree extends JTree{
42
	private File directory = null;
43

  
44
	public SelectFilesTree() {
45
		super();		
46
	}
47
	
48
	public void setDirectory(File directory){		
49
		setModel(new SelectFilesTreeModel(directory));
50
		setCellRenderer(new SelectFilesTreeCellRenderer());
51
		getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);		
52
		addMouseListener(new SelectFilesTreeNodeSelectionListener(this));
53
	}
54
	
55
	public List<File> getSelectedFiles(){
56
		List<File> selectedFiles = new ArrayList<File>();	
57
		addSelectedFiles((SelectFilesTreeCheckNode)getModel().getRoot(), selectedFiles);		
58
		return selectedFiles;		
59
	}
60
	
61
	public void addSelectedFiles(SelectFilesTreeCheckNode node, List<File> selectedFiles){
62
		if (node.isSelected){
63
			selectedFiles.add(node.getFile());			
64
		}else{
65
			if (node.getFile().isDirectory()){				
66
				for (int i=0 ; i< node.getChildCount() ; i++){
67
					addSelectedFiles((SelectFilesTreeCheckNode)node.getChildAt(i), selectedFiles);
68
				}
69
			}
70
		}
71
	}	
72
}
73

  
0 74

  
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/creation/model/SelectFilesTreeModel.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

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2010 {Prodevelop}   {Task}
26
 */
27

  
28
package org.gvsig.installer.swing.impl.creation.model;
29

  
30
import java.io.File;
31

  
32
import javax.swing.tree.DefaultTreeModel;
33

  
34
/**
35
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
36
 */
37
public class SelectFilesTreeModel extends DefaultTreeModel{
38
	
39
	public SelectFilesTreeModel(File pluginsDirectory) {
40
		super(new SelectFilesTreeCheckNode(pluginsDirectory));		
41
	}
42
}
43

  
0 44

  
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/creation/model/SelectFilesTreeNodeSelectionListener.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

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2010 {Prodevelop}   {Task}
26
 */
27

  
28
package org.gvsig.installer.swing.impl.creation.model;
29

  
30
import java.awt.event.MouseAdapter;
31
import java.awt.event.MouseEvent;
32

  
33
import javax.swing.JTree;
34
import javax.swing.tree.TreePath;
35

  
36
/**
37
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
38
 */
39
public class SelectFilesTreeNodeSelectionListener extends MouseAdapter {
40
	JTree tree;
41

  
42
	public SelectFilesTreeNodeSelectionListener(JTree tree) {
43
		this.tree = tree;
44
	}
45

  
46
	public void mouseClicked(MouseEvent e) {
47
		int x = e.getX();
48
		int y = e.getY();
49
		int row = tree.getRowForLocation(x, y);
50
		TreePath  path = tree.getPathForRow(row);
51
		//TreePath  path = tree.getSelectionPath();
52
		if (path != null) {
53
			SelectFilesTreeCheckNode node = (SelectFilesTreeCheckNode)path.getLastPathComponent();
54
			boolean isSelected = ! (node.isSelected());
55
			node.setSelected(isSelected);
56
			if (node.getSelectionMode() == SelectFilesTreeCheckNode.DIG_IN_SELECTION) {
57
				if ( isSelected) {
58
					tree.expandPath(path);
59
				} else {
60
					tree.collapsePath(path);
61
				}
62
			}
63
			((SelectFilesTreeModel) tree.getModel()).nodeChanged(node);
64
			// I need revalidate if node is root.  but why?
65
			if (row == 0) {
66
				tree.revalidate();
67
				tree.repaint();
68
			}
69
		}
70
	}
71
}
0 72

  
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/creation/model/SelectFilesTreeCheckNode.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

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2010 {Prodevelop}   {Task}
26
 */
27

  
28
package org.gvsig.installer.swing.impl.creation.model;
29

  
30
import java.io.File;
31
import java.util.Enumeration;
32

  
33
import javax.swing.tree.DefaultMutableTreeNode;
34
import javax.swing.tree.TreeNode;
35

  
36
/**
37
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
38
 */
39
public class SelectFilesTreeCheckNode  extends DefaultMutableTreeNode {
40
	public final static int SINGLE_SELECTION = 0;
41
	public final static int DIG_IN_SELECTION = 4;
42
	protected int selectionMode;
43
	protected boolean isSelected;
44

  
45
	private File file = null;
46

  
47
	public SelectFilesTreeCheckNode(File file) {
48
		this(file, true, false);	    
49
	}
50

  
51
	public SelectFilesTreeCheckNode(File file, boolean allowsChildren,
52
			boolean isSelected) {
53
		super(file, allowsChildren);
54
		this.isSelected = isSelected;
55
		setSelectionMode(DIG_IN_SELECTION);
56
		this.file = file;	    
57
		if (file.isDirectory()){
58
			retrieveChildren();
59
		}
60
	}
61

  
62
	public void setSelectionMode(int mode) {
63
		selectionMode = mode;
64
	}
65

  
66
	public int getSelectionMode() {
67
		return selectionMode;
68
	}
69

  
70
	public void setSelected(boolean isSelected) {
71
		this.isSelected = isSelected;
72

  
73
		if ((selectionMode == DIG_IN_SELECTION) && (children != null)) {
74
			Enumeration e = children.elements();
75
			while (e.hasMoreElements()) {
76
				SelectFilesTreeCheckNode node = (SelectFilesTreeCheckNode) e.nextElement();
77
				node.setSelected(isSelected);
78
			}
79
		}
80
	}
81

  
82
	public boolean isSelected() {
83
		return isSelected;
84
	}
85

  
86

  
87
	public boolean isFile() {
88
		return file.isFile();
89
	}
90

  
91
	/*
92
	 * (non-Javadoc)
93
	 * @see javax.swing.tree.DefaultMutableTreeNode#getChildAt(int)
94
	 */
95
	@Override
96
	public TreeNode getChildAt(int index) {
97
		return super.getChildAt(index);		
98
	}
99

  
100
	/* (non-Javadoc)
101
	 * @see javax.swing.tree.DefaultMutableTreeNode#getChildCount()
102
	 */
103
	@Override
104
	public int getChildCount() {
105
		return super.getChildCount();
106
	}
107

  
108
	private void retrieveChildren()
109
	{
110
		File[] files = file.listFiles();
111
		for (int i=0 ; i<files.length ; i++){
112
			add(new SelectFilesTreeCheckNode(files[i]));
113
		}				
114
	}
115
	
116
	/**
117
	 * @return the file
118
	 */
119
	public File getFile() {
120
		return file;
121
	}
122

  
123
	/* (non-Javadoc)
124
	 * @see javax.swing.tree.DefaultMutableTreeNode#toString()
125
	 */
126
	@Override
127
	public String toString() {
128
		return file.getName();
129
	}
130
	
131

  
132
	// If you want to change "isSelected" by CellEditor,
133

  
134
//	public void setUserObject(Object obj) { 
135
//		if (obj instanceof Boolean) {
136
//			setSelected(((Boolean)obj).booleanValue()); 
137
//		}else{
138
//			super.setUserObject(obj); 
139
//		}
140
//	}
141

  
142

  
143
}
0 144

  
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/creation/wizard/SelectFilesWizard.java
1 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
*/
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 22

  
23 23
/*
24
* AUTHORS (In addition to CIT):
25
* 2010 {Prodevelop}   {Task}
26
*/
27
 
24
 * AUTHORS (In addition to CIT):
25
 * 2010 {Prodevelop}   {Task}
26
 */
27

  
28 28
package org.gvsig.installer.swing.impl.creation.wizard;
29 29

  
30
import java.io.File;
31
import java.util.List;
32

  
30 33
import javax.swing.JPanel;
31 34

  
35
import org.gvsig.installer.lib.api.InstallerInfo;
36
import org.gvsig.installer.lib.api.InstallerLocator;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff