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

Added uninstaller

parent 7921b0a7
Branches
No related merge requests found
...@@ -99,6 +99,7 @@ ...@@ -99,6 +99,7 @@
<entry key="cfgTimeoutLabel">Idleness timer (in seconds, default is 300, 0 means never)</entry> <entry key="cfgTimeoutLabel">Idleness timer (in seconds, default is 300, 0 means never)</entry>
<entry key="cfgTitleLabel">Title</entry> <entry key="cfgTitleLabel">Title</entry>
<entry key="cfgTypeLabel">Type</entry> <entry key="cfgTypeLabel">Type</entry>
<entry key="cfgUninstallLabel">Uninstall</entry>
<entry key="cfgUseACLabel">Use auto-connect</entry> <entry key="cfgUseACLabel">Use auto-connect</entry>
<entry key="cfgUseCursorLabel">Use native cursor</entry> <entry key="cfgUseCursorLabel">Use native cursor</entry>
<entry key="cfgUseLabel">Use</entry> <entry key="cfgUseLabel">Use</entry>
...@@ -785,6 +786,16 @@ The home directory is where DocExplore will store all of the data you create.&lt ...@@ -785,6 +786,16 @@ 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="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/>
You should restart DocExplore and try again without launching any other tools.&lt;/html></entry>
<entry key="uninstallExitMac">DocExplore will now exit. Move the following applications to the trash to complete the operation.</entry>
<entry key="uninstallExitMessage">&lt;html>DocExplore will now exit to complete the operation.&lt;br/>
You might be prompted for administrative rights.</entry>
<entry key="uninstallMacMessage">To remove the main program, drag the icon from the &lt;i>Applications&lt;/i> folder to the trash bin&lt;br/>
(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/>
You may choose to keep some directories for different DocExplore version or later installs.</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>
......
...@@ -99,6 +99,7 @@ ...@@ -99,6 +99,7 @@
<entry key="cfgTimeoutLabel">Compteur d'inactivité (en secondes, 300 par défaut, 0 pour désactiver)</entry> <entry key="cfgTimeoutLabel">Compteur d'inactivité (en secondes, 300 par défaut, 0 pour désactiver)</entry>
<entry key="cfgTitleLabel">Titre</entry> <entry key="cfgTitleLabel">Titre</entry>
<entry key="cfgTypeLabel">Type</entry> <entry key="cfgTypeLabel">Type</entry>
<entry key="cfgUninstallLabel">Désinstaller</entry>
<entry key="cfgUseACLabel">Utiliser la connection automatique</entry> <entry key="cfgUseACLabel">Utiliser la connection automatique</entry>
<entry key="cfgUseCursorLabel">Utiliser le curseur natif</entry> <entry key="cfgUseCursorLabel">Utiliser le curseur natif</entry>
<entry key="cfgUseLabel">Actif</entry> <entry key="cfgUseLabel">Actif</entry>
...@@ -781,6 +782,16 @@ L'espace de travail est utilisé pour stocker les données que vous créez.&lt;/ ...@@ -781,6 +782,16 @@ 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="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/>
Vous devriez relancer DocExplore et essayer à nouveau sans lancer d'autres outils.&lt;/html></entry>
<entry key="uninstallExitMac">DocExplore va à présent quitter. Déplacez les applications suivantes à la corbeille pour terminer.</entry>
<entry key="uninstallExitMessage">&lt;html>DocExplore va à présent quitter afin de terminer l'opération.&lt;br/>
Vous serez peut-être sollicité pour les droits administrateur.</entry>
<entry key="uninstallMacMessage">Pour enlever le programme principal, glissez l'icône depuis le dossier &lt;i>Applications&lt;/i> jusqu'à la corbeille&lt;br/>
(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/>
Vous pouvez conserver certains répertoires pour des versions différentes de DocExplore ou pour une réinstallation future.</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>
......
...@@ -46,7 +46,7 @@ public class ConfigPanel extends JPanel ...@@ -46,7 +46,7 @@ public class ConfigPanel extends JPanel
this.tabs = new JTabbedPane(); this.tabs = new JTabbedPane();
int pw = 600, ph = 650; int pw = 600, ph = 700;
this.server = new ServerConfigPanel(this, config, serverDir); this.server = new ServerConfigPanel(this, config, serverDir);
this.general = new GeneralConfigPanel(this, config); this.general = new GeneralConfigPanel(this, config);
......
...@@ -12,12 +12,13 @@ In this respect, the user's attention is drawn to the risks associated with load ...@@ -12,12 +12,13 @@ In this respect, the user's attention is drawn to the risks associated with load
The fact that you are presently reading this means that you have had knowledge of the CeCILL license and that you accept its terms. The fact that you are presently reading this means that you have had knowledge of the CeCILL license and that you accept its terms.
*/ */
package org.interreg.docexplore; package org.interreg.docexplore;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Component; import java.awt.Component;
import java.awt.FlowLayout; import java.awt.FlowLayout;
import java.awt.Frame; import java.awt.Frame;
import java.awt.Toolkit;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
...@@ -45,111 +46,112 @@ import org.interreg.docexplore.reader.ReaderApp; ...@@ -45,111 +46,112 @@ import org.interreg.docexplore.reader.ReaderApp;
import org.interreg.docexplore.reader.ReaderElectronApp; import org.interreg.docexplore.reader.ReaderElectronApp;
import org.interreg.docexplore.util.GuiUtils; import org.interreg.docexplore.util.GuiUtils;
import org.interreg.docexplore.util.ImageUtils; import org.interreg.docexplore.util.ImageUtils;
import org.interreg.docexplore.util.StringUtils; import org.interreg.docexplore.util.StringUtils;
public class DocExplore extends DocExploreTool public class DocExplore extends DocExploreTool
{ {
static Boolean safeMode = null; static Boolean safeMode = null;
private static String mainApp = null; private static String mainApp = null;
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;}
@SuppressWarnings("serial") @SuppressWarnings("serial")
public static void main(final String [] args) public static void main(final String [] args)
{ {
//read only the language from the config file //read only the language from the config file
try try
{ {
File file = new File(getHomeDir(), "config.xml"); File file = new File(getHomeDir(), "config.xml");
if (file.exists()) if (file.exists())
{ {
String config = StringUtils.readFile(file); String config = StringUtils.readFile(file);
String safe = StringUtils.getTagContent(config, "safe"); String safe = StringUtils.getTagContent(config, "safe");
if (safe != null) if (safe != null)
{ {
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(null);
} }
String display = StringUtils.getTagContent(config, "display"); String display = StringUtils.getTagContent(config, "display");
if (display != null) if (display != null)
{ {
String langXml = StringUtils.getTagContent(display, "lang"); String langXml = StringUtils.getTagContent(display, "lang");
if (langXml != null) if (langXml != null)
{ {
if (langXml.toLowerCase().startsWith("fr")) if (langXml.toLowerCase().startsWith("fr"))
Locale.setDefault(Locale.FRENCH); Locale.setDefault(Locale.FRENCH);
else Locale.setDefault(Locale.ENGLISH); else Locale.setDefault(Locale.ENGLISH);
} }
} }
} }
} }
catch (Exception e) {e.printStackTrace();} catch (Exception e) {e.printStackTrace();}
for (int i=0;i<args.length;i++) for (int i=0;i<args.length;i++)
{ {
if (args[i].endsWith(".pres")) if (args[i].endsWith(".pres"))
{ {
new Thread() {public void run() new Thread() {public void run()
{ {
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();
return; return;
} }
else if (args[i].startsWith("-readerApp=")) else if (args[i].startsWith("-readerApp="))
readerApp = args[i].substring("-readerApp=".length()); readerApp = args[i].substring("-readerApp=".length());
else if (args[i].startsWith("-mainApp=")) else if (args[i].startsWith("-mainApp="))
mainApp = args[i].substring("-mainApp=".length()); mainApp = args[i].substring("-mainApp=".length());
} }
final JFrame win = new JFrame("DocExplore "+version()); final JFrame win = new JFrame("DocExplore "+version());
win.setLayout(new BorderLayout()); win.setLayout(new BorderLayout());
JPanel panel = new JPanel(new LooseGridLayout(0, 2, 10, 10, true, false, SwingConstants.CENTER, SwingConstants.CENTER, true, false)); JPanel panel = new JPanel(new LooseGridLayout(0, 2, 10, 10, true, false, SwingConstants.CENTER, SwingConstants.CENTER, true, false));
win.add(panel, BorderLayout.CENTER); win.add(panel, BorderLayout.CENTER);
panel.add(new JButton(new AbstractAction("", ImageUtils.getIcon("mmt-logo.png", 192, 192)) {public void actionPerformed(ActionEvent arg0)
{
win.setVisible(false);
new Thread() {public void run()
{
try {MMT.main(args);}
catch (Exception e) {ErrorHandler.defaultHandler.submit(e); System.exit(0);}
}}.start();
}}));
panel.add(new JLabel("<html><b>"+Lang.s("mmtLabel")+"</b><br>"+Lang.s("mmtMessage")+"</html>"));
panel.add(new JButton(new AbstractAction("", ImageUtils.getIcon("at-logo.png", 192, 192)) {public void actionPerformed(ActionEvent arg0)
{
win.setVisible(false);
new Thread() {public void run()
{
try {AT.main(args);}
catch (Exception e) {ErrorHandler.defaultHandler.submit(e); System.exit(0);}
}}.start();
}}));
panel.add(new JLabel("<html><b>"+Lang.s("atLabel")+"</b><br>"+Lang.s("atMessage")+"</html>"));
panel.add(new JButton(new AbstractAction("", ImageUtils.getIcon("reader-logo.png", 192, 192)) {public void actionPerformed(ActionEvent arg0) int iconSize = Math.min(192, Toolkit.getDefaultToolkit().getScreenSize().height/7);
{ panel.add(new JButton(new AbstractAction("", ImageUtils.getIcon("mmt-logo.png", iconSize, iconSize)) {public void actionPerformed(ActionEvent arg0)
win.setVisible(false); {
new Thread() {public void run() win.setVisible(false);
{ new Thread() {public void run()
try {ReaderElectronApp.main(args);} {
catch (Exception e) {ErrorHandler.defaultHandler.submit(e); System.exit(0);} try {MMT.main(args);}
}}.start(); catch (Exception e) {ErrorHandler.defaultHandler.submit(e); System.exit(0);}
}})); }}.start();
}}));
panel.add(new JLabel("<html><b>"+Lang.s("mmtLabel")+"</b><br>"+Lang.s("mmtMessage")+"</html>"));
panel.add(new JButton(new AbstractAction("", ImageUtils.getIcon("at-logo.png", iconSize, iconSize)) {public void actionPerformed(ActionEvent arg0)
{
win.setVisible(false);
new Thread() {public void run()
{
try {AT.main(args);}
catch (Exception e) {ErrorHandler.defaultHandler.submit(e); System.exit(0);}
}}.start();
}}));
panel.add(new JLabel("<html><b>"+Lang.s("atLabel")+"</b><br>"+Lang.s("atMessage")+"</html>"));
panel.add(new JButton(new AbstractAction("", ImageUtils.getIcon("reader-logo.png", iconSize, iconSize)) {public void actionPerformed(ActionEvent arg0)
{
win.setVisible(false);
new Thread() {public void run()
{
try {ReaderElectronApp.main(args);}
catch (Exception e) {ErrorHandler.defaultHandler.submit(e); System.exit(0);}
}}.start();
}}));
panel.add(new JLabel("<html><b>"+Lang.s("readerLabel")+"</b><br>"+Lang.s("readerMessage")+"</html>")); panel.add(new JLabel("<html><b>"+Lang.s("readerLabel")+"</b><br>"+Lang.s("readerMessage")+"</html>"));
if (!SystemUtils.IS_OS_MAC_OSX) if (!SystemUtils.IS_OS_MAC_OSX)
{ {
JPanel oldReaderPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 0)); JPanel oldReaderPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 0));
oldReaderPanel.add(new JButton(new AbstractAction("", ImageUtils.getIcon("reader-logo-old.png", 64, 64)) {public void actionPerformed(ActionEvent arg0) oldReaderPanel.add(new JButton(new AbstractAction("", ImageUtils.getIcon("reader-logo-old.png", iconSize/3, iconSize/3)) {public void actionPerformed(ActionEvent arg0)
{ {
win.setVisible(false); win.setVisible(false);
new Thread() {public void run() new Thread() {public void run()
...@@ -161,115 +163,125 @@ public class DocExplore extends DocExploreTool ...@@ -161,115 +163,125 @@ public class DocExplore extends DocExploreTool
panel.add(oldReaderPanel); panel.add(oldReaderPanel);
panel.add(new JLabel("<html><b>"+Lang.s("readerOldLabel")+"</b><br>"+Lang.s("readerOldMessage")+"</html>")); panel.add(new JLabel("<html><b>"+Lang.s("readerOldLabel")+"</b><br>"+Lang.s("readerOldMessage")+"</html>"));
} }
// panel.add(new JLabel(" ")); panel.add(new JLabel(" ")); panel.add(new JLabel(" ")); panel.add(new JLabel(" ")); // panel.add(new JLabel(" ")); panel.add(new JLabel(" ")); panel.add(new JLabel(" ")); panel.add(new JLabel(" "));
// //
// panel.add(new JButton(new AbstractAction("", ImageUtils.getIcon("conf-logo.png")) {public void actionPerformed(ActionEvent arg0) // panel.add(new JButton(new AbstractAction("", ImageUtils.getIcon("conf-logo.png")) {public void actionPerformed(ActionEvent arg0)
// { // {
// //win.setVisible(false); // //win.setVisible(false);
// new Thread() {public void run() // new Thread() {public void run()
// { // {
// try // try
// { // {
// if (ConfigPanel.showConfigDialog()) // if (ConfigPanel.showConfigDialog())
// { // {
// win.setVisible(false); // win.setVisible(false);
// main(new String [0]); // main(new String [0]);
// } // }
// } // }
// catch (Exception e) {ErrorHandler.defaultHandler.submit(e); System.exit(0);} // catch (Exception e) {ErrorHandler.defaultHandler.submit(e); System.exit(0);}
// }}.start(); // }}.start();
// }})); // }}));
// panel.add(new JLabel("<html><b>"+XMLResourceBundle.getBundledString("confLabel")+"</b><br>"+XMLResourceBundle.getBundledString("confMessage")+"</html>")); // panel.add(new JLabel("<html><b>"+XMLResourceBundle.getBundledString("confLabel")+"</b><br>"+XMLResourceBundle.getBundledString("confMessage")+"</html>"));
panel.add(new JLabel(" ")); panel.add(new JLabel(" "));
JPanel configPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JPanel configPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
configPanel.add(new JLabel("<html><b>"+Lang.s("confLabel")+"</b><br>")); configPanel.add(new JLabel("<html><b>"+Lang.s("confLabel")+"</b><br>"));
configPanel.add(new JButton(new AbstractAction("", ImageUtils.getIcon("gears-24x24.png")) {public void actionPerformed(ActionEvent arg0) configPanel.add(new JButton(new AbstractAction("", ImageUtils.getIcon("gears-24x24.png")) {public void actionPerformed(ActionEvent arg0)
{ {
//win.setVisible(false); //win.setVisible(false);
new Thread() {public void run() new Thread() {public void run()
{ {
try try
{ {
if (ConfigPanel.showConfigDialog()) if (ConfigPanel.showConfigDialog())
{ {
win.setVisible(false); win.setVisible(false);
main(new String [0]); main(new String [0]);
} }
} }
catch (Exception e) {ErrorHandler.defaultHandler.submit(e); System.exit(0);} catch (Exception e) {ErrorHandler.defaultHandler.submit(e); System.exit(0);}
}}.start(); }}.start();
}})); }}));
panel.add(configPanel); panel.add(configPanel);
panel.add(new JLabel(" "));
JPanel homePanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
JPanel rootPanel = new JPanel(new LooseGridLayout(0, 1, 5, 2, false, false, SwingConstants.RIGHT, SwingConstants.CENTER, false, false));
rootPanel.add(new JLabel("<html><b>"+Lang.s("homeLabel")+"</b><br>"));
rootPanel.add(new JLabel(getHomeDir().getAbsolutePath()));
homePanel.add(rootPanel);
homePanel.add(new JButton(new AbstractAction("", ImageUtils.getIcon("home-24x24.png")) {public void actionPerformed(ActionEvent e)
{
final String [] current = {null};
try {current[0] = getHomeDir().getCanonicalPath();}
catch (Exception ex) {ErrorHandler.defaultHandler.submit(ex, true);}
JPopupMenu menu = new JPopupMenu();
List<String> homes = getHomes();
if (homes != null)
for (final String home : homes)
menu.add(new JMenuItem(new AbstractAction(home) {public void actionPerformed(ActionEvent arg0)
{
try
{
setHome(home);
SwingUtilities.invokeLater(new Runnable() {public void run() {relaunch(win);}});
}
catch (Exception e) {ErrorHandler.defaultHandler.submit(e, true);}
}}) {{setEnabled(!home.equals(current[0]));}});
if (menu.getComponentCount() > 0)
menu.addSeparator();
menu.add(new JMenuItem(new AbstractAction(Lang.s("switchHomeLabel")) {public void actionPerformed(ActionEvent arg0)
{
File where = askForHome(Lang.s("switchHomeMessage"));
if (where == null)
return;
try
{
setHome(where.getCanonicalPath());
SwingUtilities.invokeLater(new Runnable() {public void run() {relaunch(win);}});
}
catch (Exception e) {ErrorHandler.defaultHandler.submit(e, true);}
}}));
menu.show((JButton)e.getSource(), 0, 0);
}}));
panel.add(homePanel);
panel.add(new JLabel(" ")); panel.add(new JLabel(" "));
JPanel homePanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JPanel uninstallPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
JPanel rootPanel = new JPanel(new LooseGridLayout(0, 1, 5, 2, false, false, SwingConstants.RIGHT, SwingConstants.CENTER, false, false)); uninstallPanel.add(new JLabel("<html><b>"+Lang.s("cfgUninstallLabel")+"</b><br>"));
rootPanel.add(new JLabel("<html><b>"+Lang.s("homeLabel")+"</b><br>")); uninstallPanel.add(new JButton(new AbstractAction("", ImageUtils.getIcon("trash-24x24.png")) {public void actionPerformed(ActionEvent arg0)
rootPanel.add(new JLabel(getHomeDir().getAbsolutePath()));
homePanel.add(rootPanel);
homePanel.add(new JButton(new AbstractAction("", ImageUtils.getIcon("home-24x24.png")) {public void actionPerformed(ActionEvent e)
{ {
final String [] current = {null}; try {Uninstaller.show();}
try {current[0] = getHomeDir().getCanonicalPath();} catch (Exception e) {ErrorHandler.defaultHandler.submit(e);}
catch (Exception ex) {ErrorHandler.defaultHandler.submit(ex, true);}
JPopupMenu menu = new JPopupMenu();
List<String> homes = getHomes();
if (homes != null)
for (final String home : homes)
menu.add(new JMenuItem(new AbstractAction(home) {public void actionPerformed(ActionEvent arg0)
{
try
{
setHome(home);
SwingUtilities.invokeLater(new Runnable() {public void run() {relaunch(win);}});
}
catch (Exception e) {ErrorHandler.defaultHandler.submit(e, true);}
}}) {{setEnabled(!home.equals(current[0]));}});
if (menu.getComponentCount() > 0)
menu.addSeparator();
menu.add(new JMenuItem(new AbstractAction(Lang.s("switchHomeLabel")) {public void actionPerformed(ActionEvent arg0)
{
File where = askForHome(Lang.s("switchHomeMessage"));
if (where == null)
return;
try
{
setHome(where.getCanonicalPath());
SwingUtilities.invokeLater(new Runnable() {public void run() {relaunch(win);}});
}
catch (Exception e) {ErrorHandler.defaultHandler.submit(e, true);}
}}));
menu.show((JButton)e.getSource(), 0, 0);
}})); }}));
panel.add(homePanel); panel.add(uninstallPanel);
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
win.add(buttonPanel, BorderLayout.SOUTH); win.add(buttonPanel, BorderLayout.SOUTH);
buttonPanel.add(new JButton(new AbstractAction(Lang.s("exitLabel")) { buttonPanel.add(new JButton(new AbstractAction(Lang.s("exitLabel")) {
public void actionPerformed(ActionEvent e) {System.exit(0);}})); public void actionPerformed(ActionEvent e) {System.exit(0);}}));
win.pack(); win.pack();
win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GuiUtils.centerOnScreen(win); GuiUtils.centerOnScreen(win);
win.setVisible(true); win.setVisible(true);
} }
@SuppressWarnings("serial") @SuppressWarnings("serial")
private static void relaunch(Component comp) private static void relaunch(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(Lang.s("restartMessage"), 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(Lang.s("quitLabel")) {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 try
{ {
if (SystemUtils.IS_OS_WINDOWS) if (SystemUtils.IS_OS_WINDOWS)
...@@ -280,17 +292,17 @@ public class DocExplore extends DocExploreTool ...@@ -280,17 +292,17 @@ public class DocExplore extends DocExploreTool
{ {
//new ProcessBuilder("open", "-a", "DocExplore").start(); //new ProcessBuilder("open", "-a", "DocExplore").start();
} }
else if (SystemUtils.IS_OS_LINUX) else
{ {
new ProcessBuilder(new File(DocExploreTool.getExecutableDir(), "launch.sh").getAbsolutePath()).start(); 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); GuiUtils.centerOnComponent(dialog, comp);
dialog.setVisible(true); dialog.setVisible(true);
} }
} }
...@@ -53,7 +53,6 @@ import org.interreg.docexplore.util.ZipUtils; ...@@ -53,7 +53,6 @@ import org.interreg.docexplore.util.ZipUtils;
public class DocExploreTool public class DocExploreTool
{ {
private static String version = "?.?.?"; private static String version = "?.?.?";
private static String familyVersion() {return version.substring(0, version.lastIndexOf('.'));}
private static File homeDir = null, execDir = null, pluginDir = null; private static File homeDir = null, execDir = null, pluginDir = null;
static {initDirectories();} static {initDirectories();}
...@@ -166,7 +165,8 @@ public class DocExploreTool ...@@ -166,7 +165,8 @@ public class DocExploreTool
+StringUtils.getTagContent(xml, "minor").trim()+"." +StringUtils.getTagContent(xml, "minor").trim()+"."
+StringUtils.getTagContent(xml, "build").trim(); +StringUtils.getTagContent(xml, "build").trim();
} }
public static String version() {return version;} public static String version() {return version;}
public static String familyVersion() {return version.substring(0, version.lastIndexOf('.'));}
@SuppressWarnings("serial") @SuppressWarnings("serial")
protected static File askForHome(String text) protected static File askForHome(String text)
......
...@@ -241,11 +241,11 @@ public class GeneralConfigPanel extends JPanel ...@@ -241,11 +241,11 @@ public class GeneralConfigPanel extends JPanel
JPanel miscPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 20, 0)); JPanel miscPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 20, 0));
miscPanel.add(safeMode = new JCheckBox(Lang.s("cfgSafeModeLabel"))); miscPanel.add(safeMode = new JCheckBox(Lang.s("cfgSafeModeLabel")));
miscPanel.add(new JButton(new AbstractAction(Lang.s("cfgUninstallLabel")) {@Override public void actionPerformed(ActionEvent arg0) // miscPanel.add(new JButton(new AbstractAction(Lang.s("cfgUninstallLabel")) {@Override public void actionPerformed(ActionEvent arg0)
{ // {
try {Uninstaller.show();} // try {Uninstaller.show();}
catch (Exception e) {ErrorHandler.defaultHandler.submit(e);} // catch (Exception e) {ErrorHandler.defaultHandler.submit(e);}
}})); // }}));
add(miscPanel); add(miscPanel);
// autoConnectType.addItemListener(new ItemListener() {public void itemStateChanged(ItemEvent e) // autoConnectType.addItemListener(new ItemListener() {public void itemStateChanged(ItemEvent e)
......
...@@ -17,11 +17,15 @@ package org.interreg.docexplore; ...@@ -17,11 +17,15 @@ package org.interreg.docexplore;
import java.awt.FlowLayout; import java.awt.FlowLayout;
import java.awt.Frame; import java.awt.Frame;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.io.ObjectOutputStream; import java.io.ObjectOutputStream;
import java.lang.management.ManagementFactory; import java.lang.management.ManagementFactory;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import javax.swing.AbstractAction; import javax.swing.AbstractAction;
...@@ -63,6 +67,33 @@ public class Uninstaller ...@@ -63,6 +67,33 @@ public class Uninstaller
return -1; return -1;
return Integer.parseInt(pid); return Integer.parseInt(pid);
} }
static String [] getCommandOutput(String [] cmd)
{
List<String> res = new LinkedList<String>();
try
{
Process p = Runtime.getRuntime().exec(cmd);
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = null;
while ((line = in.readLine()) != null)
res.add(line);
}
catch (Exception e) {e.printStackTrace();}
return res.toArray(new String [0]);
}
public static File getWindowsStartMenu()
{
String [] out = getCommandOutput(new String [] {"reg", "query", "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", "/v", "Common Start Menu"});
String val = null;
if (out != null)
for (int i=0;i<out.length;i++)
if (out[i].trim().startsWith("Common Start Menu"))
{
val = out[i].trim().split("REG_SZ")[1].trim();
break;
}
return new File(val == null ? System.getenv("ProgramData")+"\\Microsoft\\Windows\\Start Menu\\Programs" : val);
}
static List<String []> getPluginDirs() throws Exception static List<String []> getPluginDirs() throws Exception
{ {
...@@ -83,23 +114,19 @@ public class Uninstaller ...@@ -83,23 +114,19 @@ public class Uninstaller
static List<String []> getBinaryDirs() throws Exception static List<String []> getBinaryDirs() throws Exception
{ {
List<String []> binaryDirs = new ArrayList<String []>(); List<String []> binaryDirs = new ArrayList<String []>();
if (SystemUtils.IS_OS_MAC)
return binaryDirs;
binaryDirs.add(new String [] {DocExploreTool.getExecutableDir().getCanonicalPath(), DocExploreTool.familyVersion()}); binaryDirs.add(new String [] {DocExploreTool.getExecutableDir().getCanonicalPath(), DocExploreTool.familyVersion()});
if (SystemUtils.IS_OS_WINDOWS) File oldBinary = SystemUtils.IS_OS_WINDOWS ? new File(System.getenv("ProgramFiles")+"\\DocExplore") :
{ SystemUtils.IS_OS_MAC ? new File("/Applications/DocExplore.app") :
File oldBinary = new File(System.getenv("ProgramFiles")+"\\DocExplore"); new File("/usr/lib/docexplore");
if (oldBinary.exists() && !new File(oldBinary, "jre/release").exists()) if (oldBinary.exists())
binaryDirs.add(new String [] {oldBinary.getCanonicalPath(), "2.0"}); binaryDirs.add(new String [] {oldBinary.getCanonicalPath(), "2.0"});
}
return binaryDirs; return binaryDirs;
} }
static void removeHomes(List<String> homeDirs, JCheckBox [] homeBoxes) throws Exception static void removeHomes(List<String> homeDirs) throws Exception
{ {
//remove checked home dirs //remove checked home dirs
for (int i=0;i<homeDirs.size();i++) for (int i=0;i<homeDirs.size();i++)
if (homeBoxes[i].isSelected())
{ {
File home = new File(homeDirs.get(i)); File home = new File(homeDirs.get(i));
if (!home.exists()) if (!home.exists())
...@@ -129,13 +156,12 @@ public class Uninstaller ...@@ -129,13 +156,12 @@ public class Uninstaller
} }
} }
static void removePlugins(List<String []> pluginDirs, JCheckBox [] pluginBoxes) throws Exception static void removePlugins(List<String> pluginDirs) throws Exception
{ {
//delete plugins and look out for nested dirs //delete plugins and look out for nested dirs
for (int i=0;i<pluginDirs.size();i++) for (int i=0;i<pluginDirs.size();i++)
if (pluginBoxes[i].isSelected())
{ {
File dir = new File(pluginDirs.get(i)[0]); File dir = new File(pluginDirs.get(i));
if (!dir.exists()) if (!dir.exists())
continue; continue;
File [] children = dir.listFiles(); File [] children = dir.listFiles();
...@@ -154,15 +180,78 @@ public class Uninstaller ...@@ -154,15 +180,78 @@ public class Uninstaller
FileUtils.deleteDirectory(basePluginDir); FileUtils.deleteDirectory(basePluginDir);
} }
static void removeBinaries(List<String []> binaryDirs, JCheckBox [] binaryBoxes) throws Exception static void removeBinaries(List<String []> binaryDirs) throws Exception
{ {
if (SystemUtils.IS_OS_MAC)
{
String msg = "<html>"+Lang.s("uninstallExitMacMessage")+"<br/><br/>";
for (String [] binary : binaryDirs)
msg += " - <b>"+new File(binary[0]).getName()+"</b><br/>";
msg += "</html>";
JOptionPane.showMessageDialog(null, msg);
Runtime.getRuntime().exec("open /Applications/");
System.exit(0);
}
else if (SystemUtils.IS_OS_WINDOWS)
{
File script = new File(System.getProperty("user.home")+"/.docexplore-uninstall.bat");
FileWriter out = new FileWriter(script, false);
out.write(":loop\r\n");
out.write("tasklist | find \" "+getPID()+" \" >nul\r\n");
out.write("if not errorlevel 1 (\r\n");
out.write(" timeout /t 1 >nul\r\n");
out.write(" goto :loop\r\n");
out.write(")\r\n");
for (int i=0;i<binaryDirs.size();i++)
{
out.write("rmdir /S /Q \""+binaryDirs.get(i)[0]+"\"\r\n");
File appEntry = new File(getWindowsStartMenu(), "DocExplore"+(binaryDirs.get(i)[1].equals("2.0") ? "" : " "+binaryDirs.get(i)[1]));
if (appEntry.exists())
out.write("rmdir /S /Q \""+appEntry.getCanonicalPath()+"\"\r\n");
}
out.write("DEL \"%~f0\"\r\n");
out.close();
JOptionPane.showMessageDialog(null, Lang.s("uninstallExitMessage"));
Runtime.getRuntime().exec(new String [] {
"powershell",
"-command",
"Start-Process "+script.getName()+" -Verb runas"
}, null, script.getParentFile());
System.exit(0);
}
else
{
File script = new File(System.getProperty("user.home")+"/.docexplore-uninstall.sh");
FileWriter out = new FileWriter(script, false);
out.write("#!/bin/bash\n");
out.write("while kill -0 "+getPID()+" 2> /dev/null; do sleep 1; done;\n");
for (int i=0;i<binaryDirs.size();i++)
{
out.write("sudo rm -rf \""+binaryDirs.get(i)[0]+"\"\n");
if (!binaryDirs.get(i)[1].equals("2.0"))
{
File appEntry = new File(System.getProperty("user.home")+"/.local/share/applications/docexplore-"+binaryDirs.get(i)[1]+".desktop");
if (appEntry.exists())
out.write("sudo rm -f \""+appEntry.getCanonicalPath()+"\"\n");
}
}
out.write("rm $0\n");
out.close();
script.setExecutable(true);
JOptionPane.showMessageDialog(null, Lang.s("uninstallExitMessage"));
Runtime.getRuntime().exec(new String [] {
"x-terminal-emulator",
"-e",
"./"+script.getName()
}, null, script.getParentFile());
System.exit(0);
}
} }
@SuppressWarnings("serial") @SuppressWarnings("serial")
static void show() throws Exception static void show() throws Exception
{ {
final JDialog dialog = new JDialog((Frame)null, "Uninstall DocExplore", true); final JDialog dialog = new JDialog((Frame)null, Lang.s("cfgUninstallLabel"), true);
final List<String []> binaryDirs = getBinaryDirs(); final List<String []> binaryDirs = getBinaryDirs();
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;
...@@ -201,17 +290,38 @@ public class Uninstaller ...@@ -201,17 +290,38 @@ public class Uninstaller
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("OK") {public void actionPerformed(ActionEvent arg0)
{ {
int res = JOptionPane.showConfirmDialog(dialog, Lang.s("uninstallConfirmMessage")); List<String> homes = new ArrayList<String>();
for (int i=0;i<homeDirs.size();i++)
if (homeBoxes[i].isSelected())
homes.add(homeDirs.get(i));
List<String> plugins = new ArrayList<String>();
for (int i=0;i<pluginDirs.size();i++)
if (pluginBoxes[i].isSelected())
plugins.add(pluginDirs.get(i)[0]);
List<String []> binaries = new ArrayList<String []>();
for (int i=0;i<binaryDirs.size();i++)
if (binaryBoxes[i].isSelected())
binaries.add(binaryDirs.get(i));
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 (res == JOptionPane.YES_OPTION) try
{ {
removeHomes(homeDirs, homeBoxes); if (homes.size() > 0) removeHomes(homes);
removePlugins(pluginDirs, pluginBoxes); if (plugins.size() > 0) removePlugins(plugins);
removeBinaries(binaryDirs, binaryBoxes); 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);} catch (Exception e) {ErrorHandler.defaultHandler.submit(Lang.s("uninstallErrorMessage"), e);}
else if (res == JOptionPane.NO_OPTION)
return;
dialog.setVisible(false);
}})); }}));
buttonPanel.add(new JButton(new AbstractAction("Cancel") {public void actionPerformed(ActionEvent arg0) buttonPanel.add(new JButton(new AbstractAction("Cancel") {public void actionPerformed(ActionEvent arg0)
{ {
......
<version> <version>
<major>3</major> <major>3</major>
<minor>0</minor> <minor>0</minor>
<build>2</build> <build>27</build>
</version> </version>
\ No newline at end of file
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