1
|
package eu.etaxonomy.taxeditor;
|
2
|
|
3
|
import org.eclipse.swt.graphics.Point;
|
4
|
import org.eclipse.swt.widgets.Shell;
|
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
|
|
10
|
import eu.etaxonomy.taxeditor.datasource.CdmDataSourceRepository;
|
11
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
12
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
13
|
import eu.etaxonomy.taxeditor.ui.dialog.LoginDialog;
|
14
|
import eu.etaxonomy.taxeditor.update.P2Util;
|
15
|
import eu.etaxonomy.taxeditor.util.ApplicationUtil;
|
16
|
|
17
|
/**
|
18
|
* <p>ApplicationWorkbenchWindowAdvisor class.</p>
|
19
|
*
|
20
|
* @author n.hoffmann
|
21
|
* @version $Id: $
|
22
|
*/
|
23
|
public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
|
24
|
|
25
|
/**
|
26
|
* <p>Constructor for ApplicationWorkbenchWindowAdvisor.</p>
|
27
|
*
|
28
|
* @param configurer a {@link org.eclipse.ui.application.IWorkbenchWindowConfigurer} object.
|
29
|
*/
|
30
|
public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
|
31
|
super(configurer);
|
32
|
}
|
33
|
|
34
|
/** {@inheritDoc} */
|
35
|
@Override
|
36
|
public ActionBarAdvisor createActionBarAdvisor(
|
37
|
IActionBarConfigurer configurer) {
|
38
|
return new ApplicationActionBarAdvisor(configurer);
|
39
|
}
|
40
|
|
41
|
/**
|
42
|
* <p>preWindowOpen</p>
|
43
|
*/
|
44
|
@Override
|
45
|
public void preWindowOpen() {
|
46
|
IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
|
47
|
configurer.setInitialSize(new Point(963, 637));
|
48
|
configurer.setShowCoolBar(true);
|
49
|
configurer.setShowStatusLine(true);
|
50
|
configurer.setShowPerspectiveBar(true);
|
51
|
configurer.setTitle(ApplicationUtil.getTitle());
|
52
|
configurer.setShowProgressIndicator(true);
|
53
|
|
54
|
CdmDataSourceRepository.createDefaultH2DataSource();
|
55
|
}
|
56
|
|
57
|
/**
|
58
|
* <p>postWindowOpen</p>
|
59
|
*/
|
60
|
@Override
|
61
|
public void postWindowOpen() {
|
62
|
PreferencesUtil.checkNomenclaturalCode();
|
63
|
|
64
|
if(PreferencesUtil.shouldConnectAtStartUp()) {
|
65
|
CdmStore.connect();
|
66
|
}
|
67
|
|
68
|
P2Util.setP2UpdateRepositories();
|
69
|
|
70
|
}
|
71
|
|
72
|
/* (non-Javadoc)
|
73
|
* @see org.eclipse.ui.application.WorkbenchWindowAdvisor#postWindowClose()
|
74
|
*/
|
75
|
@Override
|
76
|
public void postWindowClose() {
|
77
|
P2Util.saveP2RepositoryPreferences();
|
78
|
}
|
79
|
|
80
|
private int authenticate(){
|
81
|
Shell shell = TaxonomicEditorPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell();
|
82
|
|
83
|
LoginDialog loginDialog = new LoginDialog(shell);
|
84
|
return loginDialog.open();
|
85
|
}
|
86
|
}
|
87
|
|