Version 1.01
[taxeditor.git] / eclipseprojects / eu.etaxonomy.taxeditor / src / eu / etaxonomy / taxeditor / ApplicationWorkbenchWindowAdvisor.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9
10 package eu.etaxonomy.taxeditor;
11
12 import org.apache.log4j.Logger;
13 import org.eclipse.jface.dialogs.Dialog;
14 import org.eclipse.jface.dialogs.MessageDialog;
15 import org.eclipse.jface.window.Window;
16 import org.eclipse.swt.graphics.Point;
17 import org.eclipse.ui.application.ActionBarAdvisor;
18 import org.eclipse.ui.application.IActionBarConfigurer;
19 import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
20 import org.eclipse.ui.application.WorkbenchWindowAdvisor;
21
22 import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
23 import eu.etaxonomy.taxeditor.preference.InitNomenclaturalCodePrefDialog;
24 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
25
26 /**
27 * @author p.ciardelli
28 * @created 15.05.2008
29 * @version 1.0
30 */
31 public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
32 private static final Logger logger = Logger.getLogger(ApplicationWorkbenchWindowAdvisor.class);
33
34 public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
35 super(configurer);
36 }
37
38 public ActionBarAdvisor createActionBarAdvisor(
39 IActionBarConfigurer configurer) {
40 return new ApplicationActionBarAdvisor(configurer);
41 }
42
43 public void preWindowOpen() {
44 IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
45 configurer.setInitialSize(new Point(963, 637));
46 configurer.setShowCoolBar(true);
47 configurer.setShowStatusLine(true);
48 configurer.setShowPerspectiveBar(true);
49 configurer.setTitle("EDIT Taxonomic Editor");
50 }
51
52 public void postWindowOpen() {
53 checkNomenclaturalCode();
54 }
55
56 private void checkNomenclaturalCode() {
57
58 // First time Editor is opened, no nomenclatural code has been set
59 if (PreferencesUtil.getPreferredNomenclaturalCode() == null) {
60
61 // Query user re: preferred nom. code
62 Dialog dialog = new InitNomenclaturalCodePrefDialog(UiUtil.getShell());
63 int returnCode = dialog.open();
64
65 // Short message confirming user's choice
66 String code = PreferencesUtil.getPreferredNomenclaturalCodeAsString();
67 MessageDialog.openInformation(UiUtil.getShell(), "Nomenclatural code set",
68 "The following has been set as your preferred nomenclatural code:\n\n\t" +
69 code + "\n\nYou can change the botanical code at any time in the \"Preferences\" menu.");
70 }
71 }
72
73 }