1 package org.eparapher.rcp;
2
3 import org.apache.log4j.Logger;
4 import org.eclipse.swt.graphics.Point;
5 import org.eclipse.ui.application.ActionBarAdvisor;
6 import org.eclipse.ui.application.IActionBarConfigurer;
7 import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
8 import org.eclipse.ui.application.WorkbenchWindowAdvisor;
9 import org.eparapher.core.EParapherManager;
10 import org.eparapher.core.crypto.EPCryptoProviderManager;
11 import org.eparapher.core.crypto.EPKeystoreManager;
12 import org.eparapher.core.crypto.JCEPolicyTest;
13 import org.eparapher.core.tools.JVMSettings;
14 import org.eparapher.core.tools.OODaemonManager;
15 import org.eparapher.rcp.tools.RCPGUI;
16 import org.eparapher.rcp.tools.RCPSettings;
17 import org.eparapher.rcp.tools.eParapherTools;
18 import org.eparapher.rcp.tray.TrayIconManager;
19
20
21 public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
22
23 private static Logger log = Logger.getLogger(ApplicationWorkbenchWindowAdvisor.class);
24
25 private TrayIconManager trayIcon;
26 private EPKeystoreManager epkeystoremgr;
27
28 private boolean inittks;
29
30 public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
31 super(configurer);
32 }
33
34 public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) {
35 return new ApplicationActionBarAdvisor(configurer);
36 }
37
38 public void preWindowOpen() {
39
40 IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
41 configurer.setInitialSize(new Point(1024,768));
42 configurer.setShowCoolBar(true);
43 configurer.setShowProgressIndicator(true);
44 configurer.setShowPerspectiveBar(true);
45 configurer.setShowStatusLine(true);
46 configurer.setShowMenuBar(true);
47 configurer.setShowFastViewBars(false);
48 configurer.setTitle("eParapher");
49
50
51 EParapherManager.getInstance().setUI(new RCPGUI());
52 EParapherManager.getInstance().setSettings(new RCPSettings());
53
54 EPReferences.getInstance().setWindowConfigurer(getWindowConfigurer());
55
56 trayIcon = new TrayIconManager(getWindowConfigurer());
57
58
59 EPCryptoProviderManager.initCryptoProviders();
60
61
62 epkeystoremgr = EPKeystoreManager.getInstance();
63 inittks = epkeystoremgr.initTrustKeystore();
64
65 }
66
67 public void postWindowOpen() {
68
69
70 if (!JCEPolicyTest.QuickJCEPolicyTest())
71 EParapherManager.getInstance().getUI().warnMessage("The Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files has not been applied on the JRE/JDK.\r\nPlease Download it and install it if you want to use strong cryptograpy algorithms.");
72
73
74 EParapherManager.setLogLevel(EParapherManager.getInstance().getSettings().getEPLogLevel());
75
76
77 EPReferences.getInstance().setStatusline(getWindowConfigurer().getActionBarConfigurer().getStatusLineManager());
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101 eParapherTools.createSignatureImage();
102
103 if (!JVMSettings.isJava16Min())
104 RCPGUI.infoMessage("Java 1.5 limitation", "XML digital signatures are not avalaible with Java 1.5");
105
106
107 epkeystoremgr.startTrackingThread();
108
109
110 if (EParapherManager.getInstance().getSettings().isOpenOfficeAutostart()) {
111 OODaemonManager.getInstance().start();
112 }
113
114 EPReferences.getInstance().getStatusline().setMessage(null, "eParapher is ready");
115 }
116
117
118
119
120
121
122 public void postWindowCreate() {
123
124
125 trayIcon.StartupFinished();
126 }
127
128
129
130
131 public boolean preWindowShellClose() {
132 getWindowConfigurer().getWindow().getShell().setVisible(false);
133 return false;
134 }
135
136 @Override
137 public void postWindowClose() {
138 super.postWindowClose();
139 if (EParapherManager.getInstance().getSettings().isOpenOfficeAutostart())
140 OODaemonManager.getInstance().stop();
141 }
142
143 }