Skip to content
Snippets Groups Projects
Commit f5f25a00 authored by aburn's avatar aburn
Browse files

Improved uninstaller logic

parent c47d5727
Branches
No related merge requests found
...@@ -786,6 +786,9 @@ The home directory is where DocExplore will store all of the data you create.&lt ...@@ -786,6 +786,9 @@ The home directory is where DocExplore will store all of the data you create.&lt
<entry key="transcriptEditorLabel">Transcription</entry> <entry key="transcriptEditorLabel">Transcription</entry>
<entry key="transcriptName">Transcriptions</entry> <entry key="transcriptName">Transcriptions</entry>
<entry key="transposeParts">Transpose poster</entry> <entry key="transposeParts">Transpose poster</entry>
<entry key="uninstallCleanMessage">&lt;html>Some DocExplore tools have been used during this session and might interfere with the removal.
You must retart the program and choose this option first to continue.
Would you like to restart DocExplore immediately?</entry>
<entry key="uninstallConfirmMessage">The following items will be permanently deleted. Are you sure you wish to continue?</entry> <entry key="uninstallConfirmMessage">The following items will be permanently deleted. Are you sure you wish to continue?</entry>
<entry key="uninstallErrorMessage">&lt;html>Some items could not be removed. This could be due to them being still in use.&lt;br/> <entry key="uninstallErrorMessage">&lt;html>Some items could not be removed. This could be due to them being still in use.&lt;br/>
You should restart DocExplore and try again without launching any other tools.&lt;/html></entry> You should restart DocExplore and try again without launching any other tools.&lt;/html></entry>
...@@ -796,6 +799,7 @@ The home directory is where DocExplore will store all of the data you create.&lt ...@@ -796,6 +799,7 @@ The home directory is where DocExplore will store all of the data you create.&lt
(first make sure the program isn't running and you've removed the unwanted directories below).</entry> (first make sure the program isn't running and you've removed the unwanted directories below).</entry>
<entry key="uninstallMessage">&lt;b>Select the components you would like to remove from your computer.&lt;/b>&lt;br/>&lt;br/> <entry key="uninstallMessage">&lt;b>Select the components you would like to remove from your computer.&lt;/b>&lt;br/>&lt;br/>
You may choose to keep some directories for different DocExplore version or later installs.</entry> You may choose to keep some directories for different DocExplore version or later installs.</entry>
<entry key="uninstallRestartMessage">DocExplore must restart to validate to the changes.</entry>
<entry key="uriCopyLabel">Copy URI</entry> <entry key="uriCopyLabel">Copy URI</entry>
<entry key="uriPasteLabel">Paste URI</entry> <entry key="uriPasteLabel">Paste URI</entry>
<entry key="useLayoutLabel">Use current layout?</entry> <entry key="useLayoutLabel">Use current layout?</entry>
......
...@@ -782,6 +782,9 @@ L'espace de travail est utilisé pour stocker les données que vous créez.&lt;/ ...@@ -782,6 +782,9 @@ L'espace de travail est utilisé pour stocker les données que vous créez.&lt;/
<entry key="transcriptEditorLabel">Transcription</entry> <entry key="transcriptEditorLabel">Transcription</entry>
<entry key="transcriptName">Transcriptions</entry> <entry key="transcriptName">Transcriptions</entry>
<entry key="transposeParts">Transposition du poster</entry> <entry key="transposeParts">Transposition du poster</entry>
<entry key="uninstallCleanMessage">&lt;html>Des outils DocExplore ont été ouverts lors de cette session et peuvent perturber la désinstallation.
Il faut relancer l'application et sélectionner cette option directement pour continuer.
Souhaitez-vous relancer DocExplore immédiatement?</entry>
<entry key="uninstallConfirmMessage">Les éléments suivants vont être définitivement supprimés. Etes-vous sur de vouloir continuer?</entry> <entry key="uninstallConfirmMessage">Les éléments suivants vont être définitivement supprimés. Etes-vous sur de vouloir continuer?</entry>
<entry key="uninstallErrorMessage">&lt;html>Certains éléments n'ont pas pu être supprimés. Cela peut être dû au fait qu'ils sont en cours d'utilisation.&lt;br/> <entry key="uninstallErrorMessage">&lt;html>Certains éléments n'ont pas pu être supprimés. Cela peut être dû au fait qu'ils sont en cours d'utilisation.&lt;br/>
Vous devriez relancer DocExplore et essayer à nouveau sans lancer d'autres outils.&lt;/html></entry> Vous devriez relancer DocExplore et essayer à nouveau sans lancer d'autres outils.&lt;/html></entry>
...@@ -792,6 +795,7 @@ L'espace de travail est utilisé pour stocker les données que vous créez.&lt;/ ...@@ -792,6 +795,7 @@ L'espace de travail est utilisé pour stocker les données que vous créez.&lt;/
(assurez-vous d'abord que le programme n'est pas lancé et que vous avez supprimé le nécessaire ci-dessous).</entry> (assurez-vous d'abord que le programme n'est pas lancé et que vous avez supprimé le nécessaire ci-dessous).</entry>
<entry key="uninstallMessage">&lt;b>Sélectionnez les composants que vous souhaitez désinstaller.&lt;/b>&lt;br/>&lt;br/> <entry key="uninstallMessage">&lt;b>Sélectionnez les composants que vous souhaitez désinstaller.&lt;/b>&lt;br/>&lt;br/>
Vous pouvez conserver certains répertoires pour des versions différentes de DocExplore ou pour une réinstallation future.</entry> Vous pouvez conserver certains répertoires pour des versions différentes de DocExplore ou pour une réinstallation future.</entry>
<entry key="uninstallRestartMessage">DocExplore doit être relancé pour valider les changements.</entry>
<entry key="uriCopyLabel"></entry> <entry key="uriCopyLabel"></entry>
<entry key="uriPasteLabel"></entry> <entry key="uriPasteLabel"></entry>
<entry key="useLayoutLabel">Utiliser la configuration actuelle?</entry> <entry key="useLayoutLabel">Utiliser la configuration actuelle?</entry>
......
...@@ -31,6 +31,7 @@ import javax.swing.JDialog; ...@@ -31,6 +31,7 @@ import javax.swing.JDialog;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JMenuItem; import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JPopupMenu; import javax.swing.JPopupMenu;
import javax.swing.SwingConstants; import javax.swing.SwingConstants;
...@@ -55,6 +56,7 @@ public class DocExplore extends DocExploreTool ...@@ -55,6 +56,7 @@ public class DocExplore extends DocExploreTool
public static String mainApp() {return mainApp;} public static String mainApp() {return mainApp;}
private static String readerApp = null; private static String readerApp = null;
public static String readerApp() {return readerApp;} public static String readerApp() {return readerApp;}
static boolean toolUsed = false;
@SuppressWarnings("serial") @SuppressWarnings("serial")
public static void main(final String [] args) public static void main(final String [] args)
...@@ -73,7 +75,7 @@ public class DocExplore extends DocExploreTool ...@@ -73,7 +75,7 @@ public class DocExplore extends DocExploreTool
if (safeMode == null) if (safeMode == null)
safeMode = StringUtils.getBoolean(safe); safeMode = StringUtils.getBoolean(safe);
else if (safeMode.booleanValue() != StringUtils.getBoolean(safe)) else if (safeMode.booleanValue() != StringUtils.getBoolean(safe))
relaunch(null); relaunch(Lang.s("restartMessage"), null);
} }
String display = StringUtils.getTagContent(config, "display"); String display = StringUtils.getTagContent(config, "display");
...@@ -97,6 +99,7 @@ public class DocExplore extends DocExploreTool ...@@ -97,6 +99,7 @@ public class DocExplore extends DocExploreTool
{ {
new Thread() {public void run() new Thread() {public void run()
{ {
toolUsed = true;
try {AT.main(args);} try {AT.main(args);}
catch (Exception e) {ErrorHandler.defaultHandler.submit(e); System.exit(0);} catch (Exception e) {ErrorHandler.defaultHandler.submit(e); System.exit(0);}
}}.start(); }}.start();
...@@ -120,6 +123,7 @@ public class DocExplore extends DocExploreTool ...@@ -120,6 +123,7 @@ public class DocExplore extends DocExploreTool
win.setVisible(false); win.setVisible(false);
new Thread() {public void run() new Thread() {public void run()
{ {
toolUsed = true;
try {MMT.main(args);} try {MMT.main(args);}
catch (Exception e) {ErrorHandler.defaultHandler.submit(e); System.exit(0);} catch (Exception e) {ErrorHandler.defaultHandler.submit(e); System.exit(0);}
}}.start(); }}.start();
...@@ -131,6 +135,7 @@ public class DocExplore extends DocExploreTool ...@@ -131,6 +135,7 @@ public class DocExplore extends DocExploreTool
win.setVisible(false); win.setVisible(false);
new Thread() {public void run() new Thread() {public void run()
{ {
toolUsed = true;
try {AT.main(args);} try {AT.main(args);}
catch (Exception e) {ErrorHandler.defaultHandler.submit(e); System.exit(0);} catch (Exception e) {ErrorHandler.defaultHandler.submit(e); System.exit(0);}
}}.start(); }}.start();
...@@ -142,6 +147,7 @@ public class DocExplore extends DocExploreTool ...@@ -142,6 +147,7 @@ public class DocExplore extends DocExploreTool
win.setVisible(false); win.setVisible(false);
new Thread() {public void run() new Thread() {public void run()
{ {
toolUsed = true;
try {ReaderElectronApp.main(args);} try {ReaderElectronApp.main(args);}
catch (Exception e) {ErrorHandler.defaultHandler.submit(e); System.exit(0);} catch (Exception e) {ErrorHandler.defaultHandler.submit(e); System.exit(0);}
}}.start(); }}.start();
...@@ -156,6 +162,7 @@ public class DocExplore extends DocExploreTool ...@@ -156,6 +162,7 @@ public class DocExplore extends DocExploreTool
win.setVisible(false); win.setVisible(false);
new Thread() {public void run() new Thread() {public void run()
{ {
toolUsed = true;
try {ReaderApp.main(args);} try {ReaderApp.main(args);}
catch (Exception e) {ErrorHandler.defaultHandler.submit(e); System.exit(0);} catch (Exception e) {ErrorHandler.defaultHandler.submit(e); System.exit(0);}
}}.start(); }}.start();
...@@ -227,7 +234,7 @@ public class DocExplore extends DocExploreTool ...@@ -227,7 +234,7 @@ public class DocExplore extends DocExploreTool
try try
{ {
setHome(home); setHome(home);
SwingUtilities.invokeLater(new Runnable() {public void run() {relaunch(win);}}); SwingUtilities.invokeLater(new Runnable() {public void run() {relaunch(Lang.s("restartMessage"), win);}});
} }
catch (Exception e) {ErrorHandler.defaultHandler.submit(e, true);} catch (Exception e) {ErrorHandler.defaultHandler.submit(e, true);}
}}) {{setEnabled(!home.equals(current[0]));}}); }}) {{setEnabled(!home.equals(current[0]));}});
...@@ -241,7 +248,7 @@ public class DocExplore extends DocExploreTool ...@@ -241,7 +248,7 @@ public class DocExplore extends DocExploreTool
try try
{ {
setHome(where.getCanonicalPath()); setHome(where.getCanonicalPath());
SwingUtilities.invokeLater(new Runnable() {public void run() {relaunch(win);}}); SwingUtilities.invokeLater(new Runnable() {public void run() {relaunch(Lang.s("restartMessage"), win);}});
} }
catch (Exception e) {ErrorHandler.defaultHandler.submit(e, true);} catch (Exception e) {ErrorHandler.defaultHandler.submit(e, true);}
}})); }}));
...@@ -254,6 +261,16 @@ public class DocExplore extends DocExploreTool ...@@ -254,6 +261,16 @@ public class DocExplore extends DocExploreTool
uninstallPanel.add(new JLabel("<html><b>"+Lang.s("cfgUninstallLabel")+"</b><br>")); uninstallPanel.add(new JLabel("<html><b>"+Lang.s("cfgUninstallLabel")+"</b><br>"));
uninstallPanel.add(new JButton(new AbstractAction("", ImageUtils.getIcon("trash-24x24.png")) {public void actionPerformed(ActionEvent arg0) uninstallPanel.add(new JButton(new AbstractAction("", ImageUtils.getIcon("trash-24x24.png")) {public void actionPerformed(ActionEvent arg0)
{ {
if (toolUsed)
{
if (JOptionPane.showConfirmDialog(win, Lang.s("uninstallCleanMessage"), Lang.s("restartLabel"), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)
{
try {doRelaunch();}
catch (Exception e) {e.printStackTrace();}
System.exit(0);
}
return;
}
try {Uninstaller.show();} try {Uninstaller.show();}
catch (Exception e) {ErrorHandler.defaultHandler.submit(e);} catch (Exception e) {ErrorHandler.defaultHandler.submit(e);}
}})); }}));
...@@ -271,38 +288,40 @@ public class DocExplore extends DocExploreTool ...@@ -271,38 +288,40 @@ public class DocExplore extends DocExploreTool
} }
@SuppressWarnings("serial") @SuppressWarnings("serial")
private static void relaunch(Component comp) public static void relaunch(String msg, Component comp)
{ {
final JDialog dialog = new JDialog((Frame)null, Lang.s("restartLabel"), true); final JDialog dialog = new JDialog((Frame)null, Lang.s("restartLabel"), true);
JPanel content = new JPanel(new LooseGridLayout(0, 1, 10, 10, false, false, SwingConstants.CENTER, SwingConstants.TOP, true, false)); JPanel content = new JPanel(new LooseGridLayout(0, 1, 10, 10, false, false, SwingConstants.CENTER, SwingConstants.TOP, true, false));
content.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10)); content.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10));
JLabel message = new JLabel(Lang.s("restartMessage"), ImageUtils.getIcon("free-32x32.png"), SwingConstants.LEFT); JLabel message = new JLabel(msg, ImageUtils.getIcon("free-32x32.png"), SwingConstants.LEFT);
message.setIconTextGap(20); message.setIconTextGap(20);
content.add(message); content.add(message);
content.add(new JButton(new AbstractAction(SystemUtils.IS_OS_MAC_OSX ? Lang.s("quitLabel") : Lang.s("restartLabel")) {public void actionPerformed(ActionEvent arg0) content.add(new JButton(new AbstractAction(SystemUtils.IS_OS_MAC_OSX ? Lang.s("quitLabel") : Lang.s("restartLabel")) {public void actionPerformed(ActionEvent arg0)
{ {
try {doRelaunch();}
try
{
if (SystemUtils.IS_OS_WINDOWS)
{
new ProcessBuilder(new File(DocExploreTool.getExecutableDir(), "Launch.bat").getAbsolutePath()).start();
}
else if (SystemUtils.IS_OS_MAC_OSX)
{
//new ProcessBuilder("open", "-a", "DocExplore").start();
}
else
{
new ProcessBuilder(new File(DocExploreTool.getExecutableDir(), "launch.sh").getAbsolutePath()).start();
}
}
catch (Exception e) {e.printStackTrace();} catch (Exception e) {e.printStackTrace();}
System.exit(0); System.exit(0);
}})); }}));
dialog.add(content); dialog.add(content);
dialog.pack(); dialog.pack();
GuiUtils.centerOnComponent(dialog, comp); if (comp != null)
GuiUtils.centerOnComponent(dialog, comp);
else GuiUtils.centerOnScreen(dialog);
dialog.setVisible(true); dialog.setVisible(true);
}
private static void doRelaunch() throws Exception
{
if (SystemUtils.IS_OS_WINDOWS)
{
new ProcessBuilder(new File(DocExploreTool.getExecutableDir(), "Launch.bat").getAbsolutePath()).start();
}
else if (SystemUtils.IS_OS_MAC_OSX)
{
//new ProcessBuilder("open", "-a", "DocExplore").start();
}
else
{
new ProcessBuilder(new File(DocExploreTool.getExecutableDir(), "launch.sh").getAbsolutePath()).start();
}
} }
} }
...@@ -246,6 +246,28 @@ public class Uninstaller ...@@ -246,6 +246,28 @@ public class Uninstaller
}, null, script.getParentFile()); }, null, script.getParentFile());
System.exit(0); System.exit(0);
} }
}
private static boolean doUninstall(List<String> homes, List<String> plugins, List<String []> binaries)
{
String msg = "<html>"+Lang.s("uninstallConfirmMessage")+"<br/><br/>";
for (String home : homes) msg += " - <b>"+home+"</b><br/>";
for (String plugin : plugins) msg += " - <b>"+plugin+"</b><br/>";
for (String [] binary : binaries) msg += " - <b>"+binary[0]+"</b><br/>";
msg += "</html>";
int res = JOptionPane.showConfirmDialog(null, msg, Lang.s("cfgUninstallLabel")+"?", JOptionPane.YES_NO_OPTION);
if (res == JOptionPane.YES_OPTION) try
{
if (homes.size() > 0) removeHomes(homes);
if (plugins.size() > 0) removePlugins(plugins);
if (binaries.size() > 0) removeBinaries(binaries);
if (!DocExploreTool.getPluginDir().exists() || !DocExploreTool.getHomeDir().exists())
DocExplore.relaunch(Lang.s("uninstallRestartMessage"), null);
}
catch (Exception e) {ErrorHandler.defaultHandler.submit(Lang.s("uninstallErrorMessage"), e);}
else return false;
return true;
} }
@SuppressWarnings("serial") @SuppressWarnings("serial")
...@@ -256,6 +278,10 @@ public class Uninstaller ...@@ -256,6 +278,10 @@ public class Uninstaller
List<String> foundHomeDirs = DocExploreTool.getHomes(); List<String> foundHomeDirs = DocExploreTool.getHomes();
final List<String> homeDirs = foundHomeDirs == null ? new ArrayList<String>() : foundHomeDirs; final List<String> homeDirs = foundHomeDirs == null ? new ArrayList<String>() : foundHomeDirs;
final List<String []> pluginDirs = getPluginDirs(); final List<String []> pluginDirs = getPluginDirs();
final boolean [] ok = {false};
List<String> homes = new ArrayList<String>();
List<String> plugins = new ArrayList<String>();
List<String []> binaries = new ArrayList<String []>();
dialog.getContentPane().setLayout(new LooseGridLayout(0, 1, 10, 10, false, false, SwingConstants.CENTER, SwingConstants.CENTER, false, false)); dialog.getContentPane().setLayout(new LooseGridLayout(0, 1, 10, 10, false, false, SwingConstants.CENTER, SwingConstants.CENTER, false, false));
JPanel messagePanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 10)); JPanel messagePanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 10));
...@@ -288,49 +314,39 @@ public class Uninstaller ...@@ -288,49 +314,39 @@ public class Uninstaller
dialog.getContentPane().add(boxPanel); dialog.getContentPane().add(boxPanel);
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
buttonPanel.add(new JButton(new AbstractAction("OK") {public void actionPerformed(ActionEvent arg0) buttonPanel.add(new JButton(new AbstractAction(Lang.s("cfgOkLabel")) {public void actionPerformed(ActionEvent arg0)
{ {
List<String> homes = new ArrayList<String>(); ok[0] = true;
homes.clear();
for (int i=0;i<homeDirs.size();i++) for (int i=0;i<homeDirs.size();i++)
if (homeBoxes[i].isSelected()) if (homeBoxes[i].isSelected())
homes.add(homeDirs.get(i)); homes.add(homeDirs.get(i));
List<String> plugins = new ArrayList<String>(); plugins.clear();
for (int i=0;i<pluginDirs.size();i++) for (int i=0;i<pluginDirs.size();i++)
if (pluginBoxes[i].isSelected()) if (pluginBoxes[i].isSelected())
plugins.add(pluginDirs.get(i)[0]); plugins.add(pluginDirs.get(i)[0]);
List<String []> binaries = new ArrayList<String []>(); binaries.clear();
for (int i=0;i<binaryDirs.size();i++) for (int i=0;i<binaryDirs.size();i++)
if (binaryBoxes[i].isSelected()) if (binaryBoxes[i].isSelected())
binaries.add(binaryDirs.get(i)); binaries.add(binaryDirs.get(i));
String msg = "<html>"+Lang.s("uninstallConfirmMessage")+"<br/><br/>"; dialog.setVisible(false);
for (String home : homes) msg += " - <b>"+home+"</b><br/>";
for (String plugin : plugins) msg += " - <b>"+plugin+"</b><br/>";
for (String [] binary : binaries) msg += " - <b>"+binary[0]+"</b><br/>";
msg += "</html>";
int res = JOptionPane.showConfirmDialog(null, msg, Lang.s("cfgUninstallLabel")+"?", JOptionPane.YES_NO_OPTION);
if (res == JOptionPane.YES_OPTION) try
{
if (homes.size() > 0) removeHomes(homes);
if (plugins.size() > 0) removePlugins(plugins);
if (binaries.size() > 0) removeBinaries(binaries);
if (!DocExploreTool.getPluginDir().exists())
{
JOptionPane.showMessageDialog(null, Lang.s("uninstallExitMessage"));
System.exit(0);
}
dialog.setVisible(false);
}
catch (Exception e) {ErrorHandler.defaultHandler.submit(Lang.s("uninstallErrorMessage"), e);}
}})); }}));
buttonPanel.add(new JButton(new AbstractAction("Cancel") {public void actionPerformed(ActionEvent arg0) buttonPanel.add(new JButton(new AbstractAction(Lang.s("cfgCancelLabel")) {public void actionPerformed(ActionEvent arg0)
{ {
ok[0] = false;
dialog.setVisible(false); dialog.setVisible(false);
}})); }}));
dialog.getContentPane().add(buttonPanel); dialog.getContentPane().add(buttonPanel);
dialog.pack(); dialog.pack();
GuiUtils.centerOnScreen(dialog); GuiUtils.centerOnScreen(dialog);
dialog.setVisible(true);
while (true)
{
dialog.setVisible(true);
if (!ok[0] || (!homes.isEmpty() || !plugins.isEmpty() || !binaries.isEmpty()) && doUninstall(homes, plugins, binaries))
return;
}
} }
} }
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment