gvsig-desktop-customize / trunk / org.gvsig.customize.app / org.gvsig.customize.app.mainplugin / src / main / java / org / gvsig / customize / CustomizeExtension.java @ 1
History | View | Annotate | Download (4.44 KB)
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.dynform.spi.DynFormSPILocator; |
18 |
import org.gvsig.tools.dynform.spi.DynFormSPIManager; |
19 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
20 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
21 |
import org.slf4j.Logger; |
22 |
import org.slf4j.LoggerFactory; |
23 |
|
24 |
/**
|
25 |
*
|
26 |
* @author usuario
|
27 |
*/
|
28 |
public class CustomizeExtension extends Extension { |
29 |
|
30 |
private final static Logger logger = LoggerFactory.getLogger(CustomizeExtension.class); |
31 |
|
32 |
@Override
|
33 |
public void initialize() { |
34 |
PluginsManager pluginsManager = PluginsLocator.getManager(); |
35 |
pluginsManager.addStartupTask("Customize", new CustomizeTask(), false, 2000); |
36 |
DynFormSPIManager manager = DynFormSPILocator.getDynFormSPIManager(); |
37 |
if( manager != null ) { |
38 |
manager.addServiceFactory(new JDynFormFieldLocaleFactory());
|
39 |
} |
40 |
} |
41 |
|
42 |
@Override
|
43 |
public void execute(String actionCommand) { |
44 |
if ("tools-customize-create-distribution".equalsIgnoreCase(actionCommand)) { |
45 |
final DistributionParametersPanel panel = new DistributionParametersPanel(); |
46 |
panel.setCloseAndCreateVisible(true);
|
47 |
panel.addActionListener(new ActionListener() { |
48 |
@Override
|
49 |
public void actionPerformed(ActionEvent ae) { |
50 |
doCreateDistributionTask(panel); |
51 |
} |
52 |
}); |
53 |
WindowManager windowManager = ToolsSwingLocator.getWindowManager(); |
54 |
windowManager.showWindow(panel, "Create distribution", WindowManager.MODE.WINDOW);
|
55 |
} else if ("tools-customize-edit-configuration".equalsIgnoreCase(actionCommand)) { |
56 |
Configuration config = new Configuration(); |
57 |
config.edit(); |
58 |
} |
59 |
} |
60 |
|
61 |
|
62 |
|
63 |
private void doCreateDistributionTask(final DistributionParametersPanel panel) { |
64 |
ApplicationManager application = ApplicationLocator.getManager(); |
65 |
|
66 |
if( panel.getOnlineInstaller()==null ) { |
67 |
application.messageDialog( |
68 |
"Shall specify the online installer to use",
|
69 |
"Parameter required",
|
70 |
JOptionPane.WARNING_MESSAGE);
|
71 |
return;
|
72 |
} |
73 |
if( panel.getWorkingFolder()==null ) { |
74 |
application.messageDialog( |
75 |
"Shall specify the working folder to use",
|
76 |
"Parameter required",
|
77 |
JOptionPane.WARNING_MESSAGE);
|
78 |
return;
|
79 |
} |
80 |
// if( panel.getPackageSet()==null ) {
|
81 |
// application.messageDialog(
|
82 |
// "Shall specify the package set to use",
|
83 |
// "Parameter required",
|
84 |
// JOptionPane.WARNING_MESSAGE);
|
85 |
// return;
|
86 |
// }
|
87 |
if( panel.getDistributionId()==null ) { |
88 |
application.messageDialog( |
89 |
"Shall specify the identifier of the new distribution",
|
90 |
"Parameter required",
|
91 |
JOptionPane.WARNING_MESSAGE);
|
92 |
return;
|
93 |
} |
94 |
|
95 |
panel.setCloseAndCreateEnabled(false);
|
96 |
|
97 |
final DistributionBuilder builder = new DistributionBuilder(panel); |
98 |
builder.setDistributionId(panel.getDistributionId()); |
99 |
builder.setOnlineInstaller(panel.getOnlineInstaller()); |
100 |
builder.setPackageSet(panel.getPackageSetFolder()); |
101 |
builder.setWorkingFolder(panel.getWorkingFolder()); |
102 |
builder.setIncludeCustomizePlugin(panel.getIncludeCustomizePlugin()); |
103 |
|
104 |
Thread task = new Thread(new Runnable() { |
105 |
@Override
|
106 |
public void run() { |
107 |
try {
|
108 |
builder.build(); |
109 |
} finally {
|
110 |
panel.setCloseAndCreateEnabled(true);
|
111 |
} |
112 |
} |
113 |
}); |
114 |
task.start(); |
115 |
} |
116 |
|
117 |
public boolean isEnabled() { |
118 |
return true; |
119 |
} |
120 |
|
121 |
public boolean isVisible() { |
122 |
return true; |
123 |
} |
124 |
} |