Revision 70
tags/org.gvsig.customize.app-1.2.3/org.gvsig.customize.app.mainplugin/buildNumber.properties | ||
---|---|---|
1 |
#Wed Oct 07 10:40:39 CEST 2015 |
|
2 |
buildNumber=13 |
tags/org.gvsig.customize.app-1.2.3/org.gvsig.customize.app.mainplugin/src/main/assembly/gvsig-plugin-package.xml | ||
---|---|---|
1 |
<!-- |
|
2 |
|
|
3 |
gvSIG. Desktop Geographic Information System. |
|
4 |
|
|
5 |
Copyright (C) 2007-2013 gvSIG Association. |
|
6 |
|
|
7 |
This program is free software; you can redistribute it and/or |
|
8 |
modify it under the terms of the GNU General Public License |
|
9 |
as published by the Free Software Foundation; either version 3 |
|
10 |
of the License, or (at your option) any later version. |
|
11 |
|
|
12 |
This program is distributed in the hope that it will be useful, |
|
13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 |
GNU General Public License for more details. |
|
16 |
|
|
17 |
You should have received a copy of the GNU General Public License |
|
18 |
along with this program; if not, write to the Free Software |
|
19 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
20 |
MA 02110-1301, USA. |
|
21 |
|
|
22 |
For any additional information, do not hesitate to contact us |
|
23 |
at info AT gvsig.com, or visit our website www.gvsig.com. |
|
24 |
|
|
25 |
--> |
|
26 |
<assembly> |
|
27 |
<id>gvsig-plugin-package</id> |
|
28 |
<formats> |
|
29 |
<format>zip</format> |
|
30 |
</formats> |
|
31 |
<baseDirectory>${project.artifactId}</baseDirectory> |
|
32 |
<includeBaseDirectory>true</includeBaseDirectory> |
|
33 |
<files> |
|
34 |
<file> |
|
35 |
<source>target/${project.artifactId}-${project.version}.jar</source> |
|
36 |
<outputDirectory>lib</outputDirectory> |
|
37 |
</file> |
|
38 |
<file> |
|
39 |
<source>target/package.info</source> |
|
40 |
</file> |
|
41 |
</files> |
|
42 |
|
|
43 |
<fileSets> |
|
44 |
<fileSet> |
|
45 |
<directory>src/main/resources-plugin</directory> |
|
46 |
<outputDirectory>.</outputDirectory> |
|
47 |
</fileSet> |
|
48 |
</fileSets> |
|
49 |
|
|
50 |
|
|
51 |
<!-- |
|
52 |
Si le quito los comentarios y dejo la seccion includes vacia, me incluye |
|
53 |
si o si, todas depedencias, como si no hiciese caso del parametro |
|
54 |
useTransitiveDependencies |
|
55 |
<dependencySets> |
|
56 |
<dependencySet> |
|
57 |
<useProjectArtifact>false</useProjectArtifact> |
|
58 |
<useTransitiveDependencies>false</useTransitiveDependencies> |
|
59 |
<outputDirectory>lib</outputDirectory> |
|
60 |
<includes> |
|
61 |
</includes> |
|
62 |
</dependencySet> |
|
63 |
</dependencySets> |
|
64 |
--> |
|
65 |
|
|
66 |
</assembly> |
|
67 |
|
tags/org.gvsig.customize.app-1.2.3/org.gvsig.customize.app.mainplugin/src/main/java/org/gvsig/customize/Installkit.java | ||
---|---|---|
1 |
package org.gvsig.customize; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.io.IOException; |
|
5 |
import java.nio.file.Files; |
|
6 |
import java.nio.file.Path; |
|
7 |
import java.nio.file.Paths; |
|
8 |
import java.nio.file.attribute.PosixFilePermission; |
|
9 |
import java.util.HashSet; |
|
10 |
import java.util.Set; |
|
11 |
import org.gvsig.andami.PluginServices; |
|
12 |
import org.gvsig.andami.PluginsLocator; |
|
13 |
import org.gvsig.andami.PluginsManager; |
|
14 |
import org.slf4j.Logger; |
|
15 |
import org.slf4j.LoggerFactory; |
|
16 |
|
|
17 |
public class Installkit { |
|
18 |
|
|
19 |
private static final Logger logger = LoggerFactory.getLogger(Installkit.class); |
|
20 |
|
|
21 |
File folder; |
|
22 |
|
|
23 |
public Installkit() { |
|
24 |
PluginsManager pluginsManager = PluginsLocator.getManager(); |
|
25 |
PluginServices plugin = pluginsManager.getPlugin(CustomizeExtension.class); |
|
26 |
this.folder = new File(plugin.getPluginDirectory(), "installkit"); |
|
27 |
setExecutePermission(); |
|
28 |
} |
|
29 |
|
|
30 |
private File getInstallkitExefile() { |
|
31 |
File file = new File(folder.getAbsolutePath(), "installkit"); |
|
32 |
return file; |
|
33 |
} |
|
34 |
|
|
35 |
public void addpks(String arg1, String arg2) throws IOException, InterruptedException { |
|
36 |
String cmd = getInstallkitExefile().getAbsolutePath() |
|
37 |
+ " " |
|
38 |
+ folder.getAbsolutePath() |
|
39 |
+ "/main.tcl addpks " |
|
40 |
+ arg1 |
|
41 |
+ " " |
|
42 |
+ arg2; |
|
43 |
|
|
44 |
Process child = Runtime.getRuntime().exec(cmd); |
|
45 |
child.waitFor(); |
|
46 |
} |
|
47 |
|
|
48 |
private void setExecutePermission() { |
|
49 |
Path path = Paths.get(getInstallkitExefile().toURI()); |
|
50 |
Set<PosixFilePermission> perms = new HashSet<PosixFilePermission>(); |
|
51 |
//add owners permission |
|
52 |
perms.add(PosixFilePermission.OWNER_READ); |
|
53 |
perms.add(PosixFilePermission.OWNER_EXECUTE); |
|
54 |
//add group permissions |
|
55 |
perms.add(PosixFilePermission.GROUP_READ); |
|
56 |
perms.add(PosixFilePermission.GROUP_EXECUTE); |
|
57 |
//add others permissions |
|
58 |
perms.add(PosixFilePermission.OTHERS_READ); |
|
59 |
perms.add(PosixFilePermission.OTHERS_EXECUTE); |
|
60 |
|
|
61 |
try { |
|
62 |
Files.setPosixFilePermissions(path, perms); |
|
63 |
} catch (IOException ex) { |
|
64 |
logger.warn("Can't add execution permissions to '"+getInstallkitExefile()+"'.",ex); |
|
65 |
} |
|
66 |
} |
|
67 |
} |
tags/org.gvsig.customize.app-1.2.3/org.gvsig.customize.app.mainplugin/src/main/java/org/gvsig/customize/locale/JDynFormFieldLocaleFactory.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
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 3 |
|
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 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.customize.locale; |
|
25 |
|
|
26 |
import org.gvsig.tools.ToolsLocator; |
|
27 |
import org.gvsig.tools.dataTypes.DataTypes; |
|
28 |
import org.gvsig.tools.dynform.spi.DynFormSPILocator; |
|
29 |
import org.gvsig.tools.dynform.spi.DynFormSPIManager; |
|
30 |
import org.gvsig.tools.dynform.spi.JDynFormFieldFactory; |
|
31 |
import org.gvsig.tools.dynobject.DynField; |
|
32 |
import org.gvsig.tools.dynobject.DynObject; |
|
33 |
import org.gvsig.tools.dynobject.DynObjectManager; |
|
34 |
import org.gvsig.tools.dynobject.DynStruct; |
|
35 |
import org.gvsig.tools.service.Service; |
|
36 |
import org.gvsig.tools.service.ServiceException; |
|
37 |
import org.gvsig.tools.service.spi.ServiceManager; |
|
38 |
|
|
39 |
public class JDynFormFieldLocaleFactory implements JDynFormFieldFactory { |
|
40 |
|
|
41 |
private String name = null; |
|
42 |
private DynStruct parametersDefinition = null; |
|
43 |
|
|
44 |
public String getName() { |
|
45 |
if( name == null ) { |
|
46 |
DynFormSPIManager manager = DynFormSPILocator.getDynFormSPIManager(); |
|
47 |
this.name = manager.makeServiceName(DataTypes.STRING, "locale"); |
|
48 |
} |
|
49 |
return this.name; |
|
50 |
} |
|
51 |
|
|
52 |
|
|
53 |
public Service create(DynObject parameters, ServiceManager serviceManager) |
|
54 |
throws ServiceException { |
|
55 |
return new JDynFormFieldLocale(parameters, serviceManager); |
|
56 |
} |
|
57 |
|
|
58 |
public DynObject createParameters() { |
|
59 |
return ToolsLocator.getDynObjectManager().createDynObject(parametersDefinition); |
|
60 |
} |
|
61 |
|
|
62 |
public void initialize() { |
|
63 |
if( this.parametersDefinition == null ) { |
|
64 |
String serviceName = this.getName(); |
|
65 |
DynObjectManager manager = ToolsLocator.getDynObjectManager(); |
|
66 |
this.parametersDefinition = manager.createDynClass( |
|
67 |
serviceName, "Parameters definition for locale fields in dynamic forms"); |
|
68 |
this.parametersDefinition.addDynFieldObject(DynFormSPIManager.FIELD_FIELDDEFINITION) |
|
69 |
.setClassOfValue(DynField.class).setMandatory(true); |
|
70 |
this.parametersDefinition.addDynFieldObject(DynFormSPIManager.FIELD_VALUE) |
|
71 |
.setClassOfValue(DynField.class).setMandatory(true); |
|
72 |
} |
|
73 |
} |
|
74 |
|
|
75 |
|
|
76 |
} |
tags/org.gvsig.customize.app-1.2.3/org.gvsig.customize.app.mainplugin/src/main/java/org/gvsig/customize/locale/JDynFormFieldLocale.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
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 3 |
|
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 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.customize.locale; |
|
25 |
|
|
26 |
import java.util.Locale; |
|
27 |
import java.util.Set; |
|
28 |
import javax.swing.JComboBox; |
|
29 |
import org.apache.commons.lang3.StringUtils; |
|
30 |
import org.gvsig.andami.LocaleManager; |
|
31 |
import org.gvsig.andami.PluginsLocator; |
|
32 |
import org.gvsig.tools.dynform.spi.dynformfield.AbstractJDynFormFieldWithValueList; |
|
33 |
import org.gvsig.tools.dynobject.DynObject; |
|
34 |
import org.gvsig.tools.dynobject.DynObjectValueItem; |
|
35 |
import org.gvsig.tools.service.spi.ServiceManager; |
|
36 |
|
|
37 |
public class JDynFormFieldLocale extends AbstractJDynFormFieldWithValueList { |
|
38 |
|
|
39 |
public JDynFormFieldLocale(DynObject parameters, |
|
40 |
ServiceManager serviceManager) { |
|
41 |
super(parameters, serviceManager); |
|
42 |
} |
|
43 |
|
|
44 |
protected String getDefaultValue(){ |
|
45 |
return ""; |
|
46 |
} |
|
47 |
|
|
48 |
public Object getValue() { |
|
49 |
Object value = null; |
|
50 |
String s = this.getValueFromJComponent(); |
|
51 |
if( StringUtils.isBlank(s) ) { |
|
52 |
Object x = this.getDefinition().getDefaultValue(); |
|
53 |
if( x != null ) { |
|
54 |
value = x.toString(); |
|
55 |
} |
|
56 |
} else { |
|
57 |
value = s; |
|
58 |
} |
|
59 |
return value; |
|
60 |
} |
|
61 |
|
|
62 |
@Override |
|
63 |
public void initComponent() { |
|
64 |
LocaleManager localeManager = PluginsLocator.getLocaleManager(); |
|
65 |
Set<Locale> localesSet = localeManager.getInstalledLocales(); |
|
66 |
DynObjectValueItem[] locales = new DynObjectValueItem[localesSet.size()]; |
|
67 |
int i=0; |
|
68 |
for( Locale locale : localesSet ) { |
|
69 |
locales[i++] = new DynObjectValueItem( |
|
70 |
locale.toString(), |
|
71 |
localeManager.getLocaleDisplayName(locale) |
|
72 |
); |
|
73 |
} |
|
74 |
this.contents = new JComboBox(locales); |
|
75 |
if( locales.length>0 ) { |
|
76 |
this.getJComboBox().setSelectedIndex(0); |
|
77 |
} |
|
78 |
this.contents.addFocusListener(this); |
|
79 |
if( this.getDefinition().isReadOnly() ) { |
|
80 |
this.getJComboBox().setEditable(false); |
|
81 |
} |
|
82 |
this.setValue(this.assignedValue); |
|
83 |
} |
|
84 |
|
|
85 |
} |
tags/org.gvsig.customize.app-1.2.3/org.gvsig.customize.app.mainplugin/src/main/java/org/gvsig/customize/CustomizeExtension.java | ||
---|---|---|
1 |
/* |
|
2 |
* To change this license header, choose License Headers in Project Properties. |
|
3 |
* To change this template file, choose Tools | Templates |
|
4 |
* and open the template in the editor. |
|
5 |
*/ |
|
6 |
package org.gvsig.customize; |
|
7 |
|
|
8 |
import java.awt.event.ActionEvent; |
|
9 |
import java.awt.event.ActionListener; |
|
10 |
import javax.swing.JOptionPane; |
|
11 |
import org.gvsig.andami.PluginsLocator; |
|
12 |
import org.gvsig.andami.PluginsManager; |
|
13 |
import org.gvsig.andami.plugins.Extension; |
|
14 |
import org.gvsig.app.ApplicationLocator; |
|
15 |
import org.gvsig.app.ApplicationManager; |
|
16 |
import org.gvsig.customize.locale.JDynFormFieldLocaleFactory; |
|
17 |
import org.gvsig.tools.ToolsLocator; |
|
18 |
import org.gvsig.tools.dynform.spi.DynFormSPILocator; |
|
19 |
import org.gvsig.tools.dynform.spi.DynFormSPIManager; |
|
20 |
import org.gvsig.tools.packageutils.PackageManager; |
|
21 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
22 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
|
23 |
import org.slf4j.Logger; |
|
24 |
import org.slf4j.LoggerFactory; |
|
25 |
|
|
26 |
/** |
|
27 |
* |
|
28 |
* @author usuario |
|
29 |
*/ |
|
30 |
public class CustomizeExtension extends Extension { |
|
31 |
|
|
32 |
private final static Logger logger = LoggerFactory.getLogger(CustomizeExtension.class); |
|
33 |
|
|
34 |
@Override |
|
35 |
public void initialize() { |
|
36 |
PluginsManager pluginsManager = PluginsLocator.getManager(); |
|
37 |
pluginsManager.addStartupTask("Customize", new CustomizeTask(), false, 2000); |
|
38 |
DynFormSPIManager manager = DynFormSPILocator.getDynFormSPIManager(); |
|
39 |
if( manager != null ) { |
|
40 |
manager.addServiceFactory(new JDynFormFieldLocaleFactory()); |
|
41 |
} |
|
42 |
} |
|
43 |
|
|
44 |
@Override |
|
45 |
public void execute(String actionCommand) { |
|
46 |
if ("tools-customize-create-distribution".equalsIgnoreCase(actionCommand)) { |
|
47 |
final DistributionParametersPanel panel = new DistributionParametersPanel(); |
|
48 |
panel.setCloseAndCreateVisible(true); |
|
49 |
panel.addActionListener(new ActionListener() { |
|
50 |
@Override |
|
51 |
public void actionPerformed(ActionEvent ae) { |
|
52 |
doCreateDistributionTask(panel); |
|
53 |
} |
|
54 |
}); |
|
55 |
WindowManager windowManager = ToolsSwingLocator.getWindowManager(); |
|
56 |
windowManager.showWindow(panel, "Create distribution", WindowManager.MODE.WINDOW); |
|
57 |
} else if ("tools-customize-edit-configuration".equalsIgnoreCase(actionCommand)) { |
|
58 |
Configuration config = new Configuration(); |
|
59 |
config.edit(); |
|
60 |
} |
|
61 |
} |
|
62 |
|
|
63 |
|
|
64 |
|
|
65 |
private void doCreateDistributionTask(final DistributionParametersPanel panel) { |
|
66 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
67 |
|
|
68 |
if( panel.getOnlineInstaller()==null ) { |
|
69 |
application.messageDialog( |
|
70 |
"Shall specify the online installer to use", |
|
71 |
"Parameter required", |
|
72 |
JOptionPane.WARNING_MESSAGE); |
|
73 |
return; |
|
74 |
} |
|
75 |
if( panel.getWorkingFolder()==null ) { |
|
76 |
application.messageDialog( |
|
77 |
"Shall specify the working folder to use", |
|
78 |
"Parameter required", |
|
79 |
JOptionPane.WARNING_MESSAGE); |
|
80 |
return; |
|
81 |
} |
|
82 |
// if( panel.getPackageSet()==null ) { |
|
83 |
// application.messageDialog( |
|
84 |
// "Shall specify the package set to use", |
|
85 |
// "Parameter required", |
|
86 |
// JOptionPane.WARNING_MESSAGE); |
|
87 |
// return; |
|
88 |
// } |
|
89 |
if( panel.getDistributionId()==null ) { |
|
90 |
application.messageDialog( |
|
91 |
"Shall specify the identifier of the new distribution", |
|
92 |
"Parameter required", |
|
93 |
JOptionPane.WARNING_MESSAGE); |
|
94 |
return; |
|
95 |
} |
|
96 |
|
|
97 |
panel.setCloseAndCreateEnabled(false); |
|
98 |
|
|
99 |
final DistributionBuilder builder = new DistributionBuilder(panel); |
|
100 |
builder.setDistributionId(panel.getDistributionId()); |
|
101 |
builder.setOnlineInstaller(panel.getOnlineInstaller()); |
|
102 |
builder.setPackageSet(panel.getPackageSetFolder()); |
|
103 |
builder.setWorkingFolder(panel.getWorkingFolder()); |
|
104 |
builder.setIncludeCustomizePlugin(panel.getIncludeCustomizePlugin()); |
|
105 |
|
|
106 |
Thread task = new Thread(new Runnable() { |
|
107 |
@Override |
|
108 |
public void run() { |
|
109 |
try { |
|
110 |
builder.build(); |
|
111 |
} finally { |
|
112 |
panel.setCloseAndCreateEnabled(true); |
|
113 |
} |
|
114 |
} |
|
115 |
}); |
|
116 |
task.start(); |
|
117 |
} |
|
118 |
|
|
119 |
public boolean isEnabled() { |
|
120 |
return true; |
|
121 |
} |
|
122 |
|
|
123 |
public boolean isVisible() { |
|
124 |
PackageManager pkgmanager = ToolsLocator.getPackageManager(); |
|
125 |
if( PackageManager.OS.LINUX.equalsIgnoreCase(pkgmanager.getOperatingSystem()) ) { |
|
126 |
return true; |
|
127 |
} |
|
128 |
return false; |
|
129 |
} |
|
130 |
} |
tags/org.gvsig.customize.app-1.2.3/org.gvsig.customize.app.mainplugin/src/main/java/org/gvsig/customize/DistributionParametersPanelLayout.java | ||
---|---|---|
1 |
/* |
|
2 |
* To change this license header, choose License Headers in Project Properties. |
|
3 |
* To change this template file, choose Tools | Templates |
|
4 |
* and open the template in the editor. |
|
5 |
*/ |
|
6 |
package org.gvsig.customize; |
|
7 |
|
|
8 |
/** |
|
9 |
* |
|
10 |
* @author jjdelcerro |
|
11 |
*/ |
|
12 |
public class DistributionParametersPanelLayout extends javax.swing.JPanel { |
|
13 |
|
|
14 |
/** |
|
15 |
* Creates new form DistributionPanelLayout |
|
16 |
*/ |
|
17 |
public DistributionParametersPanelLayout() { |
|
18 |
initComponents(); |
|
19 |
} |
|
20 |
|
|
21 |
/** |
|
22 |
* This method is called from within the constructor to initialize the form. |
|
23 |
* WARNING: Do NOT modify this code. The content of this method is always |
|
24 |
* regenerated by the Form Editor. |
|
25 |
*/ |
|
26 |
@SuppressWarnings("unchecked") |
|
27 |
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents |
|
28 |
private void initComponents() { |
|
29 |
java.awt.GridBagConstraints gridBagConstraints; |
|
30 |
|
|
31 |
filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(2, 2), new java.awt.Dimension(2, 2), new java.awt.Dimension(2, 2)); |
|
32 |
filler2 = new javax.swing.Box.Filler(new java.awt.Dimension(2, 2), new java.awt.Dimension(2, 2), new java.awt.Dimension(2, 2)); |
|
33 |
jTabbedPane1 = new javax.swing.JTabbedPane(); |
|
34 |
jPanel2 = new javax.swing.JPanel(); |
|
35 |
filler3 = new javax.swing.Box.Filler(new java.awt.Dimension(4, 4), new java.awt.Dimension(4, 4), new java.awt.Dimension(4, 4)); |
|
36 |
lblOnlineInstaller = new javax.swing.JLabel(); |
|
37 |
txtOnlineInstaller = new javax.swing.JTextField(); |
|
38 |
butBrowseOnlineInstaller = new javax.swing.JButton(); |
|
39 |
lblDistributionId = new javax.swing.JLabel(); |
|
40 |
txtDistributionId = new javax.swing.JTextField(); |
|
41 |
lblPackageSet = new javax.swing.JLabel(); |
|
42 |
txtPackageSet = new javax.swing.JTextField(); |
|
43 |
butBrowsePackageSet = new javax.swing.JButton(); |
|
44 |
lblWorkingFolder = new javax.swing.JLabel(); |
|
45 |
txtWorkingFolder = new javax.swing.JTextField(); |
|
46 |
butBrowseWorkingFolder = new javax.swing.JButton(); |
|
47 |
lblIncludeCustomizePlugin = new javax.swing.JLabel(); |
|
48 |
chkIncludeCustomizePlugin = new javax.swing.JCheckBox(); |
|
49 |
filler7 = new javax.swing.Box.Filler(new java.awt.Dimension(4, 4), new java.awt.Dimension(4, 4), new java.awt.Dimension(4, 4)); |
|
50 |
filler4 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 32767)); |
|
51 |
jPanel1 = new javax.swing.JPanel(); |
|
52 |
filler6 = new javax.swing.Box.Filler(new java.awt.Dimension(4, 4), new java.awt.Dimension(4, 4), new java.awt.Dimension(4, 4)); |
|
53 |
butAddPackage = new javax.swing.JButton(); |
|
54 |
butRemovePackage = new javax.swing.JButton(); |
|
55 |
jScrollPane2 = new javax.swing.JScrollPane(); |
|
56 |
lstPackages = new javax.swing.JList(); |
|
57 |
lblPackagesToInclude = new javax.swing.JLabel(); |
|
58 |
lblCheckToInstallByDefault = new javax.swing.JLabel(); |
|
59 |
filler9 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(32767, 0)); |
|
60 |
filler10 = new javax.swing.Box.Filler(new java.awt.Dimension(4, 4), new java.awt.Dimension(4, 4), new java.awt.Dimension(4, 4)); |
|
61 |
butCheckAll = new javax.swing.JButton(); |
|
62 |
butUncheckAll = new javax.swing.JButton(); |
|
63 |
butClose = new javax.swing.JButton(); |
|
64 |
butCreate = new javax.swing.JButton(); |
|
65 |
filler5 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(32767, 0)); |
|
66 |
lblMessages = new javax.swing.JLabel(); |
|
67 |
|
|
68 |
java.awt.GridBagLayout layout = new java.awt.GridBagLayout(); |
|
69 |
layout.columnWidths = new int[] {0, 5, 0, 5, 0, 5, 0, 5, 0}; |
|
70 |
layout.rowHeights = new int[] {0, 5, 0, 5, 0, 5, 0}; |
|
71 |
setLayout(layout); |
|
72 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
73 |
gridBagConstraints.gridx = 8; |
|
74 |
gridBagConstraints.gridy = 6; |
|
75 |
add(filler1, gridBagConstraints); |
|
76 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
77 |
gridBagConstraints.gridx = 0; |
|
78 |
gridBagConstraints.gridy = 0; |
|
79 |
add(filler6, gridBagConstraints); |
|
80 |
|
|
81 |
java.awt.GridBagLayout jPanel2Layout = new java.awt.GridBagLayout(); |
|
82 |
jPanel2Layout.columnWidths = new int[] {0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0}; |
|
83 |
jPanel2Layout.rowHeights = new int[] {0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0}; |
|
84 |
jPanel2.setLayout(jPanel2Layout); |
|
85 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
86 |
gridBagConstraints.gridx = 0; |
|
87 |
gridBagConstraints.gridy = 0; |
|
88 |
jPanel2.add(filler3, gridBagConstraints); |
|
89 |
|
|
90 |
lblOnlineInstaller.setText("Online installer"); |
|
91 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
92 |
gridBagConstraints.gridx = 2; |
|
93 |
gridBagConstraints.gridy = 4; |
|
94 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; |
|
95 |
jPanel2.add(lblOnlineInstaller, gridBagConstraints); |
|
96 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
97 |
gridBagConstraints.gridx = 4; |
|
98 |
gridBagConstraints.gridy = 4; |
|
99 |
gridBagConstraints.gridwidth = 5; |
|
100 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
101 |
gridBagConstraints.weightx = 0.1; |
|
102 |
jPanel2.add(txtOnlineInstaller, gridBagConstraints); |
|
103 |
|
|
104 |
butBrowseOnlineInstaller.setText("Browse..."); |
|
105 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
106 |
gridBagConstraints.gridx = 10; |
|
107 |
gridBagConstraints.gridy = 4; |
|
108 |
jPanel2.add(butBrowseOnlineInstaller, gridBagConstraints); |
|
109 |
|
|
110 |
lblDistributionId.setText("Distribution id"); |
|
111 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
112 |
gridBagConstraints.gridx = 2; |
|
113 |
gridBagConstraints.gridy = 2; |
|
114 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; |
|
115 |
jPanel2.add(lblDistributionId, gridBagConstraints); |
|
116 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
117 |
gridBagConstraints.gridx = 4; |
|
118 |
gridBagConstraints.gridy = 2; |
|
119 |
gridBagConstraints.gridwidth = 7; |
|
120 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
121 |
gridBagConstraints.weightx = 0.5; |
|
122 |
jPanel2.add(txtDistributionId, gridBagConstraints); |
|
123 |
|
|
124 |
lblPackageSet.setText("Package set"); |
|
125 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
126 |
gridBagConstraints.gridx = 2; |
|
127 |
gridBagConstraints.gridy = 6; |
|
128 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; |
|
129 |
jPanel2.add(lblPackageSet, gridBagConstraints); |
|
130 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
131 |
gridBagConstraints.gridx = 4; |
|
132 |
gridBagConstraints.gridy = 6; |
|
133 |
gridBagConstraints.gridwidth = 5; |
|
134 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
135 |
gridBagConstraints.weightx = 0.1; |
|
136 |
jPanel2.add(txtPackageSet, gridBagConstraints); |
|
137 |
|
|
138 |
butBrowsePackageSet.setText("Browse..."); |
|
139 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
140 |
gridBagConstraints.gridx = 10; |
|
141 |
gridBagConstraints.gridy = 6; |
|
142 |
jPanel2.add(butBrowsePackageSet, gridBagConstraints); |
|
143 |
|
|
144 |
lblWorkingFolder.setText("Working folder"); |
|
145 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
146 |
gridBagConstraints.gridx = 2; |
|
147 |
gridBagConstraints.gridy = 8; |
|
148 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; |
|
149 |
jPanel2.add(lblWorkingFolder, gridBagConstraints); |
|
150 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
151 |
gridBagConstraints.gridx = 4; |
|
152 |
gridBagConstraints.gridy = 8; |
|
153 |
gridBagConstraints.gridwidth = 5; |
|
154 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
155 |
gridBagConstraints.weightx = 0.1; |
|
156 |
jPanel2.add(txtWorkingFolder, gridBagConstraints); |
|
157 |
|
|
158 |
butBrowseWorkingFolder.setText("Browse..."); |
|
159 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
160 |
gridBagConstraints.gridx = 10; |
|
161 |
gridBagConstraints.gridy = 8; |
|
162 |
jPanel2.add(butBrowseWorkingFolder, gridBagConstraints); |
|
163 |
|
|
164 |
lblIncludeCustomizePlugin.setText("Include Customize Plugin"); |
|
165 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
166 |
gridBagConstraints.gridx = 2; |
|
167 |
gridBagConstraints.gridy = 10; |
|
168 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; |
|
169 |
jPanel2.add(lblIncludeCustomizePlugin, gridBagConstraints); |
|
170 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
171 |
gridBagConstraints.gridx = 4; |
|
172 |
gridBagConstraints.gridy = 10; |
|
173 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; |
|
174 |
jPanel2.add(chkIncludeCustomizePlugin, gridBagConstraints); |
|
175 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
176 |
gridBagConstraints.gridx = 12; |
|
177 |
gridBagConstraints.gridy = 12; |
|
178 |
jPanel2.add(filler7, gridBagConstraints); |
|
179 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
180 |
gridBagConstraints.gridx = 0; |
|
181 |
gridBagConstraints.gridy = 12; |
|
182 |
gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL; |
|
183 |
gridBagConstraints.weighty = 0.4; |
|
184 |
jPanel2.add(filler4, gridBagConstraints); |
|
185 |
|
|
186 |
jTabbedPane1.addTab("General", jPanel2); |
|
187 |
|
|
188 |
java.awt.GridBagLayout jPanel1Layout = new java.awt.GridBagLayout(); |
|
189 |
jPanel1Layout.columnWidths = new int[] {0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0}; |
|
190 |
jPanel1Layout.rowHeights = new int[] {0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0}; |
|
191 |
jPanel1.setLayout(jPanel1Layout); |
|
192 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
193 |
gridBagConstraints.gridx = 0; |
|
194 |
gridBagConstraints.gridy = 0; |
|
195 |
jPanel1.add(filler6, gridBagConstraints); |
|
196 |
|
|
197 |
butAddPackage.setText("Add"); |
|
198 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
199 |
gridBagConstraints.gridx = 8; |
|
200 |
gridBagConstraints.gridy = 8; |
|
201 |
jPanel1.add(butAddPackage, gridBagConstraints); |
|
202 |
|
|
203 |
butRemovePackage.setText("Remove"); |
|
204 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
205 |
gridBagConstraints.gridx = 10; |
|
206 |
gridBagConstraints.gridy = 8; |
|
207 |
jPanel1.add(butRemovePackage, gridBagConstraints); |
|
208 |
|
|
209 |
jScrollPane2.setViewportView(lstPackages); |
|
210 |
|
|
211 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
212 |
gridBagConstraints.gridx = 2; |
|
213 |
gridBagConstraints.gridy = 6; |
|
214 |
gridBagConstraints.gridwidth = 9; |
|
215 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
|
216 |
gridBagConstraints.weightx = 0.1; |
|
217 |
gridBagConstraints.weighty = 0.1; |
|
218 |
jPanel1.add(jScrollPane2, gridBagConstraints); |
|
219 |
|
|
220 |
lblPackagesToInclude.setText("Packages to include in the distribution"); |
|
221 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
222 |
gridBagConstraints.gridx = 2; |
|
223 |
gridBagConstraints.gridy = 2; |
|
224 |
gridBagConstraints.gridwidth = 5; |
|
225 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
226 |
jPanel1.add(lblPackagesToInclude, gridBagConstraints); |
|
227 |
|
|
228 |
lblCheckToInstallByDefault.setText("Check the pacakges to install by default"); |
|
229 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
230 |
gridBagConstraints.gridx = 2; |
|
231 |
gridBagConstraints.gridy = 4; |
|
232 |
gridBagConstraints.gridwidth = 5; |
|
233 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
234 |
jPanel1.add(lblCheckToInstallByDefault, gridBagConstraints); |
|
235 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
236 |
gridBagConstraints.gridx = 2; |
|
237 |
gridBagConstraints.gridy = 8; |
|
238 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
239 |
gridBagConstraints.weightx = 0.2; |
|
240 |
jPanel1.add(filler9, gridBagConstraints); |
|
241 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
242 |
gridBagConstraints.gridx = 12; |
|
243 |
gridBagConstraints.gridy = 10; |
|
244 |
jPanel1.add(filler10, gridBagConstraints); |
|
245 |
|
|
246 |
butCheckAll.setText("Check all"); |
|
247 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
248 |
gridBagConstraints.gridx = 6; |
|
249 |
gridBagConstraints.gridy = 8; |
|
250 |
jPanel1.add(butCheckAll, gridBagConstraints); |
|
251 |
|
|
252 |
butUncheckAll.setText("Uncheck all"); |
|
253 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
254 |
gridBagConstraints.gridx = 4; |
|
255 |
gridBagConstraints.gridy = 8; |
|
256 |
jPanel1.add(butUncheckAll, gridBagConstraints); |
|
257 |
|
|
258 |
jTabbedPane1.addTab("Package set", jPanel1); |
|
259 |
|
|
260 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
261 |
gridBagConstraints.gridx = 2; |
|
262 |
gridBagConstraints.gridy = 2; |
|
263 |
gridBagConstraints.gridwidth = 5; |
|
264 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
|
265 |
gridBagConstraints.weightx = 0.1; |
|
266 |
gridBagConstraints.weighty = 0.1; |
|
267 |
add(jTabbedPane1, gridBagConstraints); |
|
268 |
jTabbedPane1.getAccessibleContext().setAccessibleName("tab2"); |
|
269 |
|
|
270 |
butClose.setText("Close"); |
|
271 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
272 |
gridBagConstraints.gridx = 4; |
|
273 |
gridBagConstraints.gridy = 4; |
|
274 |
add(butClose, gridBagConstraints); |
|
275 |
|
|
276 |
butCreate.setText("Create"); |
|
277 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
278 |
gridBagConstraints.gridx = 6; |
|
279 |
gridBagConstraints.gridy = 4; |
|
280 |
add(butCreate, gridBagConstraints); |
|
281 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
282 |
gridBagConstraints.gridx = 2; |
|
283 |
gridBagConstraints.gridy = 4; |
|
284 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
285 |
gridBagConstraints.weightx = 0.3; |
|
286 |
add(filler5, gridBagConstraints); |
|
287 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
288 |
gridBagConstraints.gridx = 2; |
|
289 |
gridBagConstraints.gridy = 6; |
|
290 |
gridBagConstraints.gridwidth = 5; |
|
291 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
292 |
add(lblMessages, gridBagConstraints); |
|
293 |
}// </editor-fold>//GEN-END:initComponents |
|
294 |
|
|
295 |
|
|
296 |
// Variables declaration - do not modify//GEN-BEGIN:variables |
|
297 |
protected javax.swing.JButton butAddPackage; |
|
298 |
protected javax.swing.JButton butBrowseOnlineInstaller; |
|
299 |
protected javax.swing.JButton butBrowsePackageSet; |
|
300 |
protected javax.swing.JButton butBrowseWorkingFolder; |
|
301 |
protected javax.swing.JButton butCheckAll; |
|
302 |
protected javax.swing.JButton butClose; |
|
303 |
protected javax.swing.JButton butCreate; |
|
304 |
protected javax.swing.JButton butRemovePackage; |
|
305 |
protected javax.swing.JButton butUncheckAll; |
|
306 |
protected javax.swing.JCheckBox chkIncludeCustomizePlugin; |
|
307 |
protected javax.swing.Box.Filler filler1; |
|
308 |
protected javax.swing.Box.Filler filler10; |
|
309 |
protected javax.swing.Box.Filler filler2; |
|
310 |
protected javax.swing.Box.Filler filler3; |
|
311 |
protected javax.swing.Box.Filler filler4; |
|
312 |
protected javax.swing.Box.Filler filler5; |
|
313 |
protected javax.swing.Box.Filler filler6; |
|
314 |
protected javax.swing.Box.Filler filler7; |
|
315 |
protected javax.swing.Box.Filler filler9; |
|
316 |
protected javax.swing.JPanel jPanel1; |
|
317 |
protected javax.swing.JPanel jPanel2; |
|
318 |
protected javax.swing.JScrollPane jScrollPane2; |
|
319 |
protected javax.swing.JTabbedPane jTabbedPane1; |
|
320 |
protected javax.swing.JLabel lblCheckToInstallByDefault; |
|
321 |
protected javax.swing.JLabel lblDistributionId; |
|
322 |
protected javax.swing.JLabel lblIncludeCustomizePlugin; |
|
323 |
protected javax.swing.JLabel lblMessages; |
|
324 |
protected javax.swing.JLabel lblOnlineInstaller; |
|
325 |
protected javax.swing.JLabel lblPackageSet; |
|
326 |
protected javax.swing.JLabel lblPackagesToInclude; |
|
327 |
protected javax.swing.JLabel lblWorkingFolder; |
|
328 |
protected javax.swing.JList lstPackages; |
|
329 |
protected javax.swing.JTextField txtDistributionId; |
|
330 |
protected javax.swing.JTextField txtOnlineInstaller; |
|
331 |
protected javax.swing.JTextField txtPackageSet; |
|
332 |
protected javax.swing.JTextField txtWorkingFolder; |
|
333 |
// End of variables declaration//GEN-END:variables |
|
334 |
} |
tags/org.gvsig.customize.app-1.2.3/org.gvsig.customize.app.mainplugin/src/main/java/org/gvsig/customize/DistributionParametersPanel.java | ||
---|---|---|
1 |
package org.gvsig.customize; |
|
2 |
|
|
3 |
import java.awt.event.ActionEvent; |
|
4 |
import java.awt.event.ActionListener; |
|
5 |
import java.io.File; |
|
6 |
import java.io.FileOutputStream; |
|
7 |
import java.io.IOException; |
|
8 |
import java.nio.file.DirectoryIteratorException; |
|
9 |
import java.nio.file.DirectoryStream; |
|
10 |
import java.nio.file.FileSystem; |
|
11 |
import java.nio.file.FileSystems; |
|
12 |
import java.nio.file.Files; |
|
13 |
import java.nio.file.Path; |
|
14 |
import java.nio.file.Paths; |
|
15 |
import java.util.ArrayList; |
|
16 |
import java.util.Arrays; |
|
17 |
import java.util.Collections; |
|
18 |
import java.util.HashMap; |
|
19 |
import java.util.HashSet; |
|
20 |
import java.util.List; |
|
21 |
import java.util.Map; |
|
22 |
import java.util.Set; |
|
23 |
import javax.swing.DefaultListModel; |
|
24 |
import javax.swing.JTextField; |
|
25 |
import javax.swing.ListModel; |
|
26 |
import javax.swing.ListSelectionModel; |
|
27 |
import javax.swing.SwingUtilities; |
|
28 |
import javax.swing.event.ListSelectionEvent; |
|
29 |
import javax.swing.event.ListSelectionListener; |
|
30 |
import org.apache.commons.io.FileUtils; |
|
31 |
import org.apache.commons.io.IOUtils; |
|
32 |
import org.apache.commons.lang3.BooleanUtils; |
|
33 |
import org.apache.commons.lang3.StringUtils; |
|
34 |
import org.gvsig.andami.PluginServices; |
|
35 |
import org.gvsig.andami.PluginsLocator; |
|
36 |
import org.gvsig.andami.PluginsManager; |
|
37 |
import org.gvsig.app.ApplicationLocator; |
|
38 |
import org.gvsig.app.ApplicationManager; |
|
39 |
import org.gvsig.tools.dynobject.DynObject; |
|
40 |
import org.slf4j.Logger; |
|
41 |
import org.slf4j.LoggerFactory; |
|
42 |
|
|
43 |
public class DistributionParametersPanel extends DistributionParametersPanelLayout implements MessageBar { |
|
44 |
|
|
45 |
private static final Logger logger = LoggerFactory.getLogger(DistributionParametersPanel.class); |
|
46 |
|
|
47 |
private List<ActionListener> listeners = new ArrayList<ActionListener>(); |
|
48 |
private final DynObject pluginProperties; |
|
49 |
private final PluginServices plugin; |
|
50 |
private JListWithCheckbox lchkPackages; |
|
51 |
private Set<String> defaultPackages = new HashSet<String>(); |
|
52 |
|
|
53 |
public DistributionParametersPanel() { |
|
54 |
super(); |
|
55 |
PluginsManager pluginManager = PluginsLocator.getManager(); |
|
56 |
this.plugin = pluginManager.getPlugin(CustomizeExtension.class); |
|
57 |
this.pluginProperties = plugin.getPluginProperties(); |
|
58 |
this.initComponents(); |
|
59 |
} |
|
60 |
|
|
61 |
private String getPropertyPath(String name) { |
|
62 |
File f = (File) pluginProperties.getDynValue(name); |
|
63 |
if (f == null) { |
|
64 |
return ""; |
|
65 |
} |
|
66 |
return f.getAbsolutePath(); |
|
67 |
} |
|
68 |
|
|
69 |
private void initComponents() { |
|
70 |
this.lchkPackages = new JListWithCheckbox(this.lstPackages); |
|
71 |
|
|
72 |
this.setCloseAndCreateVisible(false); |
|
73 |
this.txtOnlineInstaller.setEditable(false); |
|
74 |
this.txtPackageSet.setEditable(false); |
|
75 |
this.txtWorkingFolder.setEditable(false); |
|
76 |
this.chkIncludeCustomizePlugin.setSelected(false); |
|
77 |
loadFormValues(); |
|
78 |
|
|
79 |
this.butBrowseOnlineInstaller.addActionListener(new ActionListener() { |
|
80 |
@Override |
|
81 |
public void actionPerformed(ActionEvent ae) { |
|
82 |
doBrowseFile(getOnlineInstaller(), "Select the online installer", txtOnlineInstaller); |
|
83 |
} |
|
84 |
}); |
|
85 |
this.butBrowsePackageSet.addActionListener(new ActionListener() { |
|
86 |
@Override |
|
87 |
public void actionPerformed(ActionEvent ae) { |
|
88 |
doBrowseFile(getPackageSetFolder(), "Select the package set", txtPackageSet); |
|
89 |
unzipPackagset(); |
|
90 |
} |
|
91 |
}); |
|
92 |
this.butBrowseWorkingFolder.addActionListener(new ActionListener() { |
|
93 |
@Override |
|
94 |
public void actionPerformed(ActionEvent ae) { |
|
95 |
doBrowseFolder(getWorkingFolder(), "Select the working folder", txtWorkingFolder); |
|
96 |
unzipPackagset(); |
|
97 |
} |
|
98 |
}); |
|
99 |
this.butClose.addActionListener(new ActionListener() { |
|
100 |
@Override |
|
101 |
public void actionPerformed(ActionEvent ae) { |
|
102 |
doClose(); |
|
103 |
} |
|
104 |
}); |
|
105 |
this.butCreate.addActionListener(new ActionListener() { |
|
106 |
@Override |
|
107 |
public void actionPerformed(ActionEvent ae) { |
|
108 |
doCreate(); |
|
109 |
} |
|
110 |
}); |
|
111 |
this.butAddPackage.addActionListener(new ActionListener() { |
|
112 |
@Override |
|
113 |
public void actionPerformed(ActionEvent ae) { |
|
114 |
doAddPackage(); |
|
115 |
} |
|
116 |
}); |
|
117 |
this.butRemovePackage.addActionListener(new ActionListener() { |
|
118 |
@Override |
|
119 |
public void actionPerformed(ActionEvent ae) { |
|
120 |
doRemovePackage(); |
|
121 |
} |
|
122 |
}); |
|
123 |
this.lchkPackages.addChecksListener(new ListSelectionListener() { |
|
124 |
@Override |
|
125 |
public void valueChanged(ListSelectionEvent lse) { |
|
126 |
doChecksValueChanged(lse); |
|
127 |
} |
|
128 |
}); |
|
129 |
this.butCheckAll.addActionListener(new ActionListener() { |
|
130 |
@Override |
|
131 |
public void actionPerformed(ActionEvent ae) { |
|
132 |
doCheckAll(); |
|
133 |
} |
|
134 |
}); |
|
135 |
this.butUncheckAll.addActionListener(new ActionListener() { |
|
136 |
@Override |
|
137 |
public void actionPerformed(ActionEvent ae) { |
|
138 |
doUncheckAll(); |
|
139 |
} |
|
140 |
}); |
|
141 |
|
|
142 |
} |
|
143 |
|
|
144 |
private void doCheckAll() { |
|
145 |
ListModel model = this.lchkPackages.getModel(); |
|
146 |
this.lchkPackages.getCheckedModel().addSelectionInterval(0, model.getSize() - 1); |
|
147 |
for (int i = 0; i < model.getSize(); i++) { |
|
148 |
String filename = (String) model.getElementAt(i); |
|
149 |
String code = getPackageCode(filename); |
|
150 |
this.defaultPackages.add(code); |
|
151 |
} |
|
152 |
} |
|
153 |
|
|
154 |
private void doUncheckAll() { |
|
155 |
this.lchkPackages.getCheckedModel().clearSelection(); |
|
156 |
this.defaultPackages.clear(); |
|
157 |
} |
|
158 |
|
|
159 |
private void doChecksValueChanged(ListSelectionEvent lse) { |
|
160 |
ListSelectionModel checkedsModel = this.lchkPackages.getCheckedModel(); |
|
161 |
ListModel model = this.lchkPackages.getModel(); |
|
162 |
for (int i = lse.getFirstIndex(); i <= lse.getLastIndex(); i++) { |
|
163 |
String packageCode = getPackageCode((String) model.getElementAt(i)); |
|
164 |
if (checkedsModel.isSelectedIndex(i)) { |
|
165 |
this.defaultPackages.add(packageCode); |
|
166 |
} else { |
|
167 |
this.defaultPackages.remove(packageCode); |
|
168 |
} |
|
169 |
} |
|
170 |
} |
|
171 |
|
|
172 |
private void loadFormValues() { |
|
173 |
this.txtDistributionId.setText((String) pluginProperties.getDynValue("distributionID")); |
|
174 |
this.txtOnlineInstaller.setText(getPropertyPath("onlineInstaller")); |
|
175 |
this.txtPackageSet.setText(getPropertyPath("packageSet")); |
|
176 |
this.txtWorkingFolder.setText(getPropertyPath("WorkingFolder")); |
|
177 |
this.chkIncludeCustomizePlugin.setSelected(BooleanUtils.isTrue((Boolean) pluginProperties.getDynValue("includeCustomizePlugin"))); |
|
178 |
unzipPackagset(); |
|
179 |
fillPackageList(); |
|
180 |
} |
|
181 |
|
|
182 |
private void saveFormValues() { |
|
183 |
pluginProperties.setDynValue("onlineInstaller", getOnlineInstaller()); |
|
184 |
pluginProperties.setDynValue("packageSet", getPackageSet()); |
|
185 |
pluginProperties.setDynValue("WorkingFolder", getWorkingFolder()); |
|
186 |
pluginProperties.setDynValue("distributionID", getDistributionId()); |
|
187 |
pluginProperties.setDynValue("includeCustomizePlugin", getIncludeCustomizePlugin()); |
|
188 |
plugin.savePluginProperties(); |
|
189 |
} |
|
190 |
|
|
191 |
private void updateDefaultPackagesFile() { |
|
192 |
ArrayList lines = new ArrayList(); |
|
193 |
lines.addAll(this.defaultPackages); |
|
194 |
if (this.getIncludeCustomizePlugin()) { |
|
195 |
lines.add(this.plugin.getPluginName()); |
|
196 |
} |
|
197 |
Collections.sort(lines); |
|
198 |
try { |
|
199 |
FileUtils.writeLines( |
|
200 |
new File(this.getPackageSetFolder(), "defaultPackages"), |
|
201 |
lines |
|
202 |
); |
|
203 |
} catch (IOException ex) { |
|
204 |
this.message("Can't write defaultPackages. " + ex.getMessage()); |
|
205 |
logger.warn("Can't write defaultPackages.", ex); |
|
206 |
} |
|
207 |
} |
|
208 |
|
|
209 |
private void doCreate() { |
|
210 |
saveFormValues(); |
|
211 |
updateDefaultPackagesFile(); |
|
212 |
this.fireActionPerformed(); |
|
213 |
} |
|
214 |
|
|
215 |
private void doClose() { |
|
216 |
saveFormValues(); |
|
217 |
this.setVisible(false); |
|
218 |
} |
|
219 |
|
|
220 |
private void doBrowseFile(File currentValue, String label, JTextField field) { |
|
221 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
222 |
File folder = currentValue; |
|
223 |
if (folder != null) { |
|
224 |
folder = folder.getParentFile(); |
|
225 |
} |
|
226 |
File[] folders = application.showOpenFileDialog(label, folder); |
|
227 |
if (folders != null && folders.length == 1) { |
|
228 |
field.setText(folders[0].getAbsolutePath()); |
|
229 |
} |
|
230 |
} |
|
231 |
|
|
232 |
private void doBrowseFolder(File currentValue, String label, JTextField field) { |
|
233 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
234 |
File folder = currentValue; |
|
235 |
if (folder != null) { |
|
236 |
folder = folder.getParentFile(); |
|
237 |
} |
|
238 |
File[] folders = application.showOpenDirectoryDialog(label, folder); |
|
239 |
if (folders != null && folders.length == 1) { |
|
240 |
field.setText(folders[0].getAbsolutePath()); |
|
241 |
} |
|
242 |
} |
|
243 |
|
|
244 |
public void message(final String msg) { |
|
245 |
if (!SwingUtilities.isEventDispatchThread()) { |
|
246 |
SwingUtilities.invokeLater(new Runnable() { |
|
247 |
@Override |
|
248 |
public void run() { |
|
249 |
message(msg); |
|
250 |
} |
|
251 |
}); |
|
252 |
return; |
|
253 |
} |
|
254 |
this.lblMessages.setText("<html>" + msg.replace("\n", "<br>\n") + "</html>"); |
|
255 |
} |
|
256 |
|
|
257 |
public File getOnlineInstaller() { |
|
258 |
String path = this.txtOnlineInstaller.getText(); |
|
259 |
if (StringUtils.isBlank(path)) { |
|
260 |
return null; |
|
261 |
} |
|
262 |
return new File(path); |
|
263 |
} |
|
264 |
|
|
265 |
private File getPackageSet() { |
|
266 |
String path = this.txtPackageSet.getText(); |
|
267 |
if (StringUtils.isBlank(path)) { |
|
268 |
return null; |
|
269 |
} |
|
270 |
return new File(path); |
|
271 |
} |
|
272 |
|
|
273 |
public File getPackageSetFolder() { |
|
274 |
File packagesetFolder = new File(getWorkingFolder(), "packages"); |
|
275 |
return packagesetFolder; |
|
276 |
} |
|
277 |
|
|
278 |
public File getWorkingFolder() { |
|
279 |
String path = this.txtWorkingFolder.getText(); |
|
280 |
if (StringUtils.isBlank(path)) { |
|
281 |
return null; |
|
282 |
} |
|
283 |
return new File(path); |
|
284 |
} |
|
285 |
|
|
286 |
public String getDistributionId() { |
|
287 |
String id = this.txtDistributionId.getText(); |
|
288 |
if (StringUtils.isBlank(id)) { |
|
289 |
return null; |
|
290 |
} |
|
291 |
return id.trim(); |
|
292 |
} |
|
293 |
|
|
294 |
public boolean getIncludeCustomizePlugin() { |
|
295 |
return this.chkIncludeCustomizePlugin.isSelected(); |
|
296 |
} |
|
297 |
|
|
298 |
public void setCloseAndCreateVisible(boolean visible) { |
|
299 |
this.butClose.setVisible(visible); |
|
300 |
this.butCreate.setVisible(visible); |
|
301 |
} |
|
302 |
|
|
303 |
public void setCloseAndCreateEnabled(final boolean enabled) { |
|
304 |
if (!SwingUtilities.isEventDispatchThread()) { |
|
305 |
SwingUtilities.invokeLater(new Runnable() { |
|
306 |
@Override |
|
307 |
public void run() { |
|
308 |
setCloseAndCreateEnabled(enabled); |
|
309 |
} |
|
310 |
}); |
|
311 |
return; |
|
312 |
} |
|
313 |
this.butClose.setEnabled(enabled); |
|
314 |
this.butCreate.setEnabled(enabled); |
|
315 |
} |
|
316 |
|
|
317 |
public void addActionListener(ActionListener l) { |
|
318 |
if (this.listeners.contains(l)) { |
|
319 |
return; |
|
320 |
} |
|
321 |
this.listeners.add(l); |
|
322 |
} |
|
323 |
|
|
324 |
protected void fireActionPerformed() { |
|
325 |
ActionEvent event = new ActionEvent(this, 0, "create_distribution"); |
|
326 |
|
|
327 |
for (ActionListener listener : listeners) { |
|
328 |
try { |
|
329 |
listener.actionPerformed(event); |
|
330 |
} catch (Exception ex) { |
|
331 |
logger.warn("Error triggering event", ex); |
|
332 |
} |
|
333 |
} |
|
334 |
} |
|
335 |
|
|
336 |
private void loadDefaultPackages(File packages) { |
|
337 |
message("Loading default packages information"); |
|
338 |
try { |
|
339 |
this.defaultPackages = new HashSet<String>(); |
|
340 |
|
|
341 |
List<String> lines = FileUtils.readLines(packages); |
|
342 |
this.defaultPackages.clear(); |
|
343 |
for (String line : lines) { |
|
344 |
line = line.trim(); |
|
345 |
if (line.startsWith("#") || line.startsWith(";")) { |
|
346 |
continue; |
|
347 |
} |
|
348 |
this.defaultPackages.add(line.toLowerCase()); |
|
349 |
} |
|
350 |
} catch (IOException ex) { |
|
351 |
logger.warn("Can't load defaultPackages from '" + packages.getAbsolutePath() + "'.", ex); |
|
352 |
} finally { |
|
353 |
message(""); |
|
354 |
} |
|
355 |
} |
|
356 |
|
|
357 |
private String getPackageCode(String filename) { |
|
358 |
if (StringUtils.isEmpty(filename)) { |
|
359 |
return filename; |
|
360 |
} |
|
361 |
String[] ss = filename.split("-"); |
|
362 |
if (ss.length > 3) { |
|
363 |
return ss[3].toLowerCase(); |
|
364 |
} |
|
365 |
return ""; |
|
366 |
} |
|
367 |
|
|
368 |
private void fillPackageList() { |
|
369 |
File f = this.getWorkingFolder(); |
|
370 |
if (f == null) { |
|
371 |
return; |
|
372 |
} |
|
373 |
DefaultListModel model = new DefaultListModel(); |
|
374 |
int first = this.lchkPackages.getFirstVisibleIndex(); |
|
375 |
File packagesetFolder = new File(f, "packages"); |
|
376 |
if (packagesetFolder.exists()) { |
|
377 |
File[] packagesArray = packagesetFolder.listFiles(); |
|
378 |
List<File> packages = Arrays.asList(packagesArray); |
|
379 |
Collections.sort(packages); |
|
380 |
for (File package1 : packages) { |
|
381 |
String filename = package1.getName(); |
|
382 |
if (!"defaultPackages".equalsIgnoreCase(filename)) { |
|
383 |
model.addElement(filename); |
|
384 |
} |
|
385 |
} |
|
386 |
} |
|
387 |
this.lchkPackages.setModel(model); |
|
388 |
updateCheckeds(); |
|
389 |
this.lchkPackages.ensureIndexIsVisible(first); |
|
390 |
} |
|
391 |
|
|
392 |
private void updateCheckeds() { |
|
393 |
this.lchkPackages.getCheckedModel().clearSelection(); |
|
394 |
ListModel model = this.lchkPackages.getModel(); |
|
395 |
for (int i = 0; i < model.getSize(); i++) { |
|
396 |
String filename = (String) model.getElementAt(i); |
|
397 |
String code = getPackageCode(filename); |
|
398 |
if (this.defaultPackages.contains(code)) { |
|
399 |
this.lchkPackages.getCheckedModel().addSelectionInterval(i, i); |
|
400 |
} |
|
401 |
} |
|
402 |
} |
|
403 |
|
|
404 |
private void unzipPackagset() { |
|
405 |
final Runnable updategui = new Runnable() { |
|
406 |
|
|
407 |
@Override |
|
408 |
public void run() { |
|
409 |
fillPackageList(); |
|
410 |
updateCheckeds(); |
|
411 |
lchkPackages.setEnabled(true); |
|
412 |
butBrowsePackageSet.setEnabled(true); |
|
413 |
butAddPackage.setEnabled(true); |
|
414 |
butRemovePackage.setEnabled(true); |
|
415 |
butClose.setEnabled(true); |
|
416 |
butCreate.setEnabled(true); |
|
417 |
} |
|
418 |
}; |
|
419 |
final Runnable task = new Runnable() { |
|
420 |
|
|
421 |
@Override |
|
422 |
public void run() { |
|
423 |
FileSystem zipfs = null; |
|
424 |
try { |
|
425 |
File packageSet = getPackageSet(); |
|
426 |
if (packageSet == null) { |
|
427 |
return; |
|
428 |
} |
|
429 |
if (getWorkingFolder() == null) { |
|
430 |
return; |
|
431 |
} |
|
432 |
|
|
433 |
message("Updating package set"); |
|
434 |
File packagesetFolder = getPackageSetFolder(); |
|
435 |
if (packagesetFolder.exists()) { |
|
436 |
try { |
|
437 |
FileUtils.deleteDirectory(packagesetFolder); |
|
438 |
} catch (IOException ex) { |
|
439 |
message("Can't delete 'packages' directory. " + ex.getMessage()); |
|
440 |
} |
|
441 |
} |
|
442 |
packagesetFolder.mkdir(); |
|
443 |
|
|
444 |
Map<String, String> env = new HashMap<>(); |
|
445 |
env.put("create", "true"); |
|
446 |
|
|
447 |
Path zippath = Paths.get(packageSet.getAbsolutePath()); |
|
448 |
zipfs = FileSystems.newFileSystem(zippath, null); |
|
449 |
Iterable<Path> dirs = zipfs.getRootDirectories(); |
|
450 |
for (Path name : dirs) { |
|
451 |
DirectoryStream<Path> stream = Files.newDirectoryStream(name); |
|
452 |
for (Path file : stream) { |
|
453 |
FileOutputStream fos = null; |
|
454 |
try { |
|
455 |
message("Extracting " + file.getFileName() + "..."); |
|
456 |
fos = new FileOutputStream(new File(packagesetFolder, file.getFileName().toString())); |
|
457 |
Files.copy(file, fos); |
|
458 |
} catch (IOException | DirectoryIteratorException x) { |
|
459 |
// Do nothing |
|
460 |
} finally { |
|
461 |
if (fos != null) { |
|
462 |
IOUtils.closeQuietly(fos); |
|
463 |
} |
|
464 |
} |
|
465 |
} |
|
466 |
} |
|
467 |
loadDefaultPackages(new File(packagesetFolder, "defaultPackages")); |
|
468 |
} catch (Exception ex) { |
|
469 |
|
|
470 |
} finally { |
|
471 |
message(""); |
|
472 |
if (zipfs != null) { |
|
473 |
try { |
|
474 |
zipfs.close(); |
|
475 |
} catch (IOException ex) { |
|
476 |
} |
|
477 |
} |
|
478 |
SwingUtilities.invokeLater(updategui); |
|
479 |
} |
|
480 |
} |
|
481 |
}; |
|
482 |
File packageSet = getPackageSet(); |
|
483 |
if (packageSet == null) { |
|
484 |
return; |
|
485 |
} |
|
486 |
lchkPackages.setEnabled(false); |
|
487 |
butBrowsePackageSet.setEnabled(false); |
|
488 |
butAddPackage.setEnabled(false); |
|
489 |
butRemovePackage.setEnabled(false); |
|
490 |
butClose.setEnabled(false); |
|
491 |
butCreate.setEnabled(false); |
|
492 |
Thread thread = new Thread(task); |
|
493 |
thread.start(); |
|
494 |
} |
|
495 |
|
|
496 |
private void doRemovePackage() { |
|
497 |
List<String> filenames = this.lchkPackages.getSelectedValuesList(); |
|
498 |
if (filenames == null || filenames.isEmpty()) { |
|
499 |
return; |
|
500 |
} |
|
501 |
File packagesetFolder = new File(getWorkingFolder(), "packages"); |
|
502 |
for (String filename : filenames) { |
|
503 |
File filetoremove = new File(packagesetFolder, filename); |
|
504 |
filetoremove.delete(); |
|
505 |
} |
|
506 |
fillPackageList(); |
|
507 |
} |
|
508 |
|
|
509 |
private void doAddPackage() { |
|
510 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
511 |
File[] files = application.showOpenFileDialog("Select package to add", this.getWorkingFolder()); |
|
512 |
if (files == null) { |
|
513 |
return; |
|
514 |
} |
|
515 |
File packagesetFolder = new File(getWorkingFolder(), "packages"); |
|
516 |
for (File file : files) { |
|
517 |
try { |
|
518 |
FileUtils.copyFileToDirectory(file, packagesetFolder); |
|
519 |
} catch (IOException ex) { |
|
520 |
this.message("Can't copy package to working folder. " + ex.getMessage()); |
|
521 |
} |
|
522 |
} |
|
523 |
fillPackageList(); |
|
524 |
} |
|
525 |
} |
tags/org.gvsig.customize.app-1.2.3/org.gvsig.customize.app.mainplugin/src/main/java/org/gvsig/customize/InstallPackagesPanelLayout.java | ||
---|---|---|
1 |
/* |
|
2 |
* To change this license header, choose License Headers in Project Properties. |
|
3 |
* To change this template file, choose Tools | Templates |
|
4 |
* and open the template in the editor. |
|
5 |
*/ |
|
6 |
package org.gvsig.customize; |
|
7 |
|
|
8 |
/** |
|
9 |
* |
|
10 |
* @author jjdelcerro |
|
11 |
*/ |
|
12 |
public class InstallPackagesPanelLayout extends javax.swing.JPanel { |
|
13 |
|
|
14 |
/** |
|
15 |
* Creates new form InstallPackagesPanelLayout |
|
16 |
*/ |
|
17 |
public InstallPackagesPanelLayout() { |
|
18 |
initComponents(); |
|
19 |
} |
|
20 |
|
|
21 |
/** |
|
22 |
* This method is called from within the constructor to initialize the form. |
|
23 |
* WARNING: Do NOT modify this code. The content of this method is always |
|
24 |
* regenerated by the Form Editor. |
|
25 |
*/ |
|
26 |
@SuppressWarnings("unchecked") |
|
27 |
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents |
|
28 |
private void initComponents() { |
|
29 |
java.awt.GridBagConstraints gridBagConstraints; |
|
30 |
|
|
31 |
lblTitle = new javax.swing.JLabel(); |
|
32 |
filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(4, 4), new java.awt.Dimension(4, 4), new java.awt.Dimension(4, 4)); |
|
33 |
filler2 = new javax.swing.Box.Filler(new java.awt.Dimension(4, 4), new java.awt.Dimension(4, 4), new java.awt.Dimension(4, 4)); |
|
34 |
pnlProgress = new javax.swing.JPanel(); |
|
35 |
butClose = new javax.swing.JButton(); |
|
36 |
filler3 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 32767)); |
|
37 |
lblMessage = new javax.swing.JLabel(); |
|
38 |
|
|
39 |
setPreferredSize(new java.awt.Dimension(400, 115)); |
|
40 |
java.awt.GridBagLayout layout = new java.awt.GridBagLayout(); |
|
41 |
layout.columnWidths = new int[] {0, 5, 0, 5, 0}; |
|
42 |
layout.rowHeights = new int[] {0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0}; |
|
43 |
setLayout(layout); |
|
44 |
|
|
45 |
lblTitle.setText("Configuring installation"); |
|
46 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
47 |
gridBagConstraints.gridx = 2; |
|
48 |
gridBagConstraints.gridy = 2; |
|
49 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
50 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; |
|
51 |
gridBagConstraints.weightx = 0.3; |
|
52 |
add(lblTitle, gridBagConstraints); |
|
53 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
54 |
gridBagConstraints.gridx = 4; |
|
55 |
gridBagConstraints.gridy = 0; |
|
56 |
add(filler1, gridBagConstraints); |
|
57 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
58 |
gridBagConstraints.gridx = 0; |
|
59 |
gridBagConstraints.gridy = 0; |
|
60 |
add(filler2, gridBagConstraints); |
|
61 |
|
|
62 |
pnlProgress.setPreferredSize(new java.awt.Dimension(300, 80)); |
|
63 |
|
|
64 |
javax.swing.GroupLayout pnlProgressLayout = new javax.swing.GroupLayout(pnlProgress); |
|
65 |
pnlProgress.setLayout(pnlProgressLayout); |
|
66 |
pnlProgressLayout.setHorizontalGroup( |
|
67 |
pnlProgressLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
|
68 |
.addGap(0, 382, Short.MAX_VALUE) |
|
69 |
); |
|
70 |
pnlProgressLayout.setVerticalGroup( |
|
71 |
pnlProgressLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
|
72 |
.addGap(0, 80, Short.MAX_VALUE) |
|
73 |
); |
|
74 |
|
|
75 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
76 |
gridBagConstraints.gridx = 2; |
|
77 |
gridBagConstraints.gridy = 4; |
|
78 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
|
79 |
add(pnlProgress, gridBagConstraints); |
|
80 |
|
|
81 |
butClose.setText("Close"); |
|
82 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
83 |
gridBagConstraints.gridx = 2; |
|
84 |
gridBagConstraints.gridy = 8; |
|
85 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END; |
|
86 |
add(butClose, gridBagConstraints); |
|
87 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
88 |
gridBagConstraints.gridx = 4; |
|
89 |
gridBagConstraints.gridy = 10; |
|
90 |
gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL; |
|
91 |
gridBagConstraints.weighty = 0.1; |
|
92 |
add(filler3, gridBagConstraints); |
|
93 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
94 |
gridBagConstraints.gridx = 2; |
|
95 |
gridBagConstraints.gridy = 6; |
|
96 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
97 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; |
|
98 |
add(lblMessage, gridBagConstraints); |
|
99 |
}// </editor-fold>//GEN-END:initComponents |
|
100 |
|
|
101 |
|
|
102 |
// Variables declaration - do not modify//GEN-BEGIN:variables |
|
103 |
protected javax.swing.JButton butClose; |
|
104 |
protected javax.swing.Box.Filler filler1; |
|
105 |
protected javax.swing.Box.Filler filler2; |
|
106 |
protected javax.swing.Box.Filler filler3; |
|
107 |
protected javax.swing.JLabel lblMessage; |
|
108 |
protected javax.swing.JLabel lblTitle; |
|
109 |
protected javax.swing.JPanel pnlProgress; |
|
110 |
// End of variables declaration//GEN-END:variables |
|
111 |
} |
tags/org.gvsig.customize.app-1.2.3/org.gvsig.customize.app.mainplugin/src/main/java/org/gvsig/customize/InstallPackagesPanel.java | ||
---|---|---|
1 |
|
|
2 |
package org.gvsig.customize; |
|
3 |
|
|
4 |
import java.awt.BorderLayout; |
|
5 |
import java.awt.event.ActionEvent; |
|
6 |
import java.awt.event.ActionListener; |
|
7 |
import javax.swing.SwingUtilities; |
|
8 |
import javax.swing.Timer; |
|
9 |
import org.gvsig.tools.ToolsLocator; |
|
10 |
import org.gvsig.tools.i18n.I18nManager; |
|
11 |
import org.gvsig.tools.observer.Observable; |
|
12 |
import org.gvsig.tools.observer.Observer; |
|
13 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
14 |
import org.gvsig.tools.swing.api.task.JTaskStatus; |
|
15 |
import org.gvsig.tools.task.TaskStatus; |
|
16 |
|
|
17 |
|
|
18 |
public class InstallPackagesPanel extends InstallPackagesPanelLayout { |
|
19 |
private TaskStatus taskStatus; |
|
20 |
private JTaskStatus jtaskStatus; |
|
21 |
// private Timer autoCloseTimer = null; |
|
22 |
|
|
23 |
public InstallPackagesPanel(TaskStatus taskStatus) { |
|
24 |
this.taskStatus = taskStatus; |
|
25 |
initComponents(); |
|
26 |
} |
|
27 |
|
|
28 |
private void initComponents() { |
|
29 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
30 |
|
|
31 |
this.lblTitle.setText(i18nManager.getTranslation("_Configuring_installation")); |
|
32 |
|
|
33 |
this.butClose.setEnabled(false); |
|
34 |
this.butClose.setText(i18nManager.getTranslation("_Close")); |
|
35 |
this.butClose.addActionListener(new ActionListener() { |
|
36 |
|
|
37 |
@Override |
|
38 |
public void actionPerformed(ActionEvent e) { |
|
39 |
doClose(); |
|
40 |
} |
|
41 |
}); |
|
42 |
|
|
43 |
this.jtaskStatus = ToolsSwingLocator.getTaskStatusSwingManager().createJTaskStatus(); |
|
44 |
|
|
45 |
this.pnlProgress.setLayout(new BorderLayout()); |
|
46 |
this.pnlProgress.add(this.jtaskStatus, BorderLayout.CENTER); |
|
47 |
|
|
48 |
this.taskStatus.addObserver(new Observer() { |
|
49 |
@Override |
|
50 |
public void update(Observable o, Object o1) { |
|
51 |
if( SwingUtilities.isEventDispatchThread() ) { |
|
52 |
doCheckTaskStatus(); |
|
53 |
} else { |
|
54 |
SwingUtilities.invokeLater(new Runnable() { |
Also available in: Unified diff