editor now updatable via updateSite
[taxeditor.git] / taxeditor-application / src / main / java / eu / etaxonomy / taxeditor / ApplicationWorkbenchWindowAdvisor.java
1 package eu.etaxonomy.taxeditor;
2
3 import org.apache.log4j.Logger;
4 import org.eclipse.jface.dialogs.Dialog;
5 import org.eclipse.jface.dialogs.MessageDialog;
6 import org.eclipse.swt.graphics.Point;
7 import org.eclipse.swt.widgets.Shell;
8 import org.eclipse.ui.application.ActionBarAdvisor;
9 import org.eclipse.ui.application.IActionBarConfigurer;
10 import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
11 import org.eclipse.ui.application.WorkbenchWindowAdvisor;
12
13 import eu.etaxonomy.taxeditor.store.preference.InitNomenclaturalCodePrefDialog;
14 import eu.etaxonomy.taxeditor.store.preference.PreferencesUtil;
15
16 public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
17 private static final Logger logger = Logger.getLogger(ApplicationWorkbenchWindowAdvisor.class);
18
19 public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
20 super(configurer);
21 }
22
23 public ActionBarAdvisor createActionBarAdvisor(
24 IActionBarConfigurer configurer) {
25 return new ApplicationActionBarAdvisor(configurer);
26 }
27
28 public void preWindowOpen() {
29 IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
30 configurer.setInitialSize(new Point(963, 637));
31 configurer.setShowCoolBar(true);
32 configurer.setShowStatusLine(true);
33 configurer.setShowPerspectiveBar(true);
34 configurer.setTitle("EDIT Taxonomic Editor");
35 }
36
37 public void postWindowOpen() {
38 checkNomenclaturalCode();
39 }
40
41 private void checkNomenclaturalCode() {
42
43 // First time Editor is opened, no nomenclatural code has been set
44 if (PreferencesUtil.getPreferredNomenclaturalCode() == null) {
45
46 logger.debug("No nomencatural code set.");
47
48 Shell shell = TaxonomicEditorPlugin.getDefault().getWorkbench()
49 .getActiveWorkbenchWindow().getShell();
50
51 // Query user re: preferred nom. code
52 Dialog dialog = new InitNomenclaturalCodePrefDialog(shell);
53 dialog.open();
54
55 // Short message confirming user's choice
56 String code = PreferencesUtil.getPreferredNomenclaturalCodeAsString();
57 MessageDialog.openInformation(shell, "Nomenclatural code set",
58 "The following has been set as your preferred nomenclatural code:\n\n\t" +
59 code + "\n\nYou can change the nomenclatural code at any time in the \"Preferences\" menu.");
60 }
61 }
62 }
63