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