Line 18... |
Line 18... |
18 |
import org.openconcerto.erp.modules.ModuleManager.ModuleState;
|
18 |
import org.openconcerto.erp.modules.ModuleManager.ModuleState;
|
19 |
import org.openconcerto.erp.modules.ModuleTableModel.ModuleRow;
|
19 |
import org.openconcerto.erp.modules.ModuleTableModel.ModuleRow;
|
20 |
import org.openconcerto.erp.panel.UserExitConf;
|
20 |
import org.openconcerto.erp.panel.UserExitConf;
|
21 |
import org.openconcerto.sql.view.AbstractFileTransfertHandler;
|
21 |
import org.openconcerto.sql.view.AbstractFileTransfertHandler;
|
22 |
import org.openconcerto.ui.component.WaitIndeterminatePanel;
|
22 |
import org.openconcerto.ui.component.WaitIndeterminatePanel;
|
- |
|
23 |
import org.openconcerto.utils.CompareUtils;
|
23 |
import org.openconcerto.utils.ExceptionHandler;
|
24 |
import org.openconcerto.utils.ExceptionHandler;
|
24 |
import org.openconcerto.utils.FileUtils;
|
25 |
import org.openconcerto.utils.FileUtils;
|
25 |
|
26 |
|
26 |
import java.awt.Dialog.ModalityType;
|
27 |
import java.awt.Dialog.ModalityType;
|
27 |
import java.awt.event.ActionEvent;
|
28 |
import java.awt.event.ActionEvent;
|
Line 79... |
Line 80... |
79 |
done = answer == JOptionPane.CANCEL_OPTION;
|
80 |
done = answer == JOptionPane.CANCEL_OPTION;
|
80 |
}
|
81 |
}
|
81 |
return done;
|
82 |
return done;
|
82 |
}
|
83 |
}
|
83 |
|
84 |
|
84 |
static void applySolution(final ModuleManager mngr, final ModulePanel panel, final ModulesStateChange chosen, final boolean onlyInstall) {
|
85 |
static void applySolution(final ModuleManager mngr, final ModulePanel panel, final ModulesStateChange chosen, final ModuleState targetState) {
|
85 |
final String dialogTitle = "Gestion des modules";
|
86 |
final String dialogTitle = "Gestion des modules";
|
86 |
final ModuleState targetState = onlyInstall ? ModuleState.INSTALLED : ModuleState.STARTED;
|
- |
|
87 |
final int installSize = chosen.getReferencesToInstall().size();
|
87 |
final int installSize = chosen.getReferencesToInstall().size();
|
88 |
final int uninstallSize = chosen.getReferencesToRemove().size();
|
88 |
final int uninstallSize = chosen.getReferencesToRemove().size();
|
89 |
if (installSize == 0 && uninstallSize == 0) {
|
89 |
if (installSize == 0 && uninstallSize == 0) {
|
90 |
JOptionPane.showMessageDialog(panel, "Aucun changement à apporter", dialogTitle, JOptionPane.INFORMATION_MESSAGE);
|
90 |
JOptionPane.showMessageDialog(panel, "Aucun changement à apporter", dialogTitle, JOptionPane.INFORMATION_MESSAGE);
|
91 |
return;
|
91 |
return;
|
Line 116... |
Line 116... |
116 |
} else {
|
116 |
} else {
|
117 |
final JDialog dialog = displayDialog(panel, msg);
|
117 |
final JDialog dialog = displayDialog(panel, msg);
|
118 |
new SwingWorker<ModulesStateChangeResult, Object>() {
|
118 |
new SwingWorker<ModulesStateChangeResult, Object>() {
|
119 |
@Override
|
119 |
@Override
|
120 |
protected ModulesStateChangeResult doInBackground() throws Exception {
|
120 |
protected ModulesStateChangeResult doInBackground() throws Exception {
|
- |
|
121 |
// don't start the module in background (see below)
|
- |
|
122 |
// don't go farther than requested
|
- |
|
123 |
final ModuleState backgroundState = CompareUtils.min(targetState, ModuleState.REGISTERED);
|
121 |
return mngr.applyChange(chosen, ModuleState.REGISTERED);
|
124 |
return mngr.applyChange(chosen, backgroundState);
|
122 |
}
|
125 |
}
|
123 |
|
126 |
|
124 |
@Override
|
127 |
@Override
|
125 |
protected void done() {
|
128 |
protected void done() {
|
126 |
try {
|
129 |
try {
|
Line 159... |
Line 162... |
159 |
final Collection<ModuleRow> checkedRows = panel.getSelection();
|
162 |
final Collection<ModuleRow> checkedRows = panel.getSelection();
|
160 |
if (checkedRows.isEmpty()) {
|
163 |
if (checkedRows.isEmpty()) {
|
161 |
JOptionPane.showMessageDialog(panel, "Aucune ligne cochée", dialogTitle, JOptionPane.INFORMATION_MESSAGE);
|
164 |
JOptionPane.showMessageDialog(panel, "Aucune ligne cochée", dialogTitle, JOptionPane.INFORMATION_MESSAGE);
|
162 |
return;
|
165 |
return;
|
163 |
}
|
166 |
}
|
164 |
final ModuleManager mngr = ModuleManager.getInstance();
|
167 |
final ModuleManager mngr = panel.getModuleManager();
|
165 |
final Set<ModuleReference> refs = new HashSet<ModuleReference>();
|
168 |
final Set<ModuleReference> refs = new HashSet<ModuleReference>();
|
166 |
final Set<ModuleReference> deniedRefs = new HashSet<ModuleReference>();
|
169 |
final Set<ModuleReference> deniedRefs = new HashSet<ModuleReference>();
|
167 |
for (final ModuleRow f : checkedRows) {
|
170 |
for (final ModuleRow f : checkedRows) {
|
168 |
if (!mngr.canCurrentUser(ModuleAction.INSTALL, f))
|
171 |
if (!mngr.canCurrentUser(ModuleAction.INSTALL, f))
|
169 |
deniedRefs.add(f.getRef());
|
172 |
deniedRefs.add(f.getRef());
|
Line 193... |
Line 196... |
193 |
} else {
|
196 |
} else {
|
194 |
final DepSolverResultChooserPanel cPanel = new DepSolverResultChooserPanel(res.getSolutions());
|
197 |
final DepSolverResultChooserPanel cPanel = new DepSolverResultChooserPanel(res.getSolutions());
|
195 |
cPanel.setRunnable(new Runnable() {
|
198 |
cPanel.setRunnable(new Runnable() {
|
196 |
@Override
|
199 |
@Override
|
197 |
public void run() {
|
200 |
public void run() {
|
198 |
applySolution(mngr, panel, cPanel.getSolutionToApply(), onlyInstall);
|
201 |
applySolution(mngr, panel, cPanel.getSolutionToApply(), onlyInstall ? ModuleState.INSTALLED : ModuleState.STARTED);
|
199 |
}
|
202 |
}
|
200 |
});
|
203 |
});
|
201 |
final JDialog dialog = new JDialog(SwingUtilities.getWindowAncestor(panel), ModalityType.APPLICATION_MODAL);
|
204 |
final JDialog dialog = new JDialog(SwingUtilities.getWindowAncestor(panel), ModalityType.APPLICATION_MODAL);
|
202 |
dialog.add(cPanel);
|
205 |
dialog.add(cPanel);
|
203 |
dialog.pack();
|
206 |
dialog.pack();
|
Line 251... |
Line 254... |
251 |
} else {
|
254 |
} else {
|
252 |
JOptionPane.showMessageDialog(panel, "Impossible d'installer le module.\nVous devez disposer des droits en écriture sur le dossier:\n" + dir.getAbsolutePath());
|
255 |
JOptionPane.showMessageDialog(panel, "Impossible d'installer le module.\nVous devez disposer des droits en écriture sur le dossier:\n" + dir.getAbsolutePath());
|
253 |
return;
|
256 |
return;
|
254 |
}
|
257 |
}
|
255 |
try {
|
258 |
try {
|
256 |
ModuleManager.getInstance().addFactory(new JarModuleFactory(out));
|
259 |
panel.getModuleManager().addFactory(new JarModuleFactory(out));
|
257 |
} catch (IOException e) {
|
260 |
} catch (IOException e) {
|
258 |
JOptionPane.showMessageDialog(panel, "Impossible d'intégrer le module.\n" + e.getMessage());
|
261 |
JOptionPane.showMessageDialog(panel, "Impossible d'intégrer le module.\n" + e.getMessage());
|
259 |
return;
|
262 |
return;
|
260 |
}
|
263 |
}
|
261 |
SwingUtilities.invokeLater(new Runnable() {
|
264 |
SwingUtilities.invokeLater(new Runnable() {
|