Massive refactoring of the methodology in former class UiUtils
[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.controller.GlobalController;
24 import eu.etaxonomy.taxeditor.preference.InitNomenclaturalCodePrefDialog;
25 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
26
27 /**
28 * @author p.ciardelli
29 * @created 15.05.2008
30 * @version 1.0
31 */
32 public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
33 private static final Logger logger = Logger.getLogger(ApplicationWorkbenchWindowAdvisor.class);
34
35 public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
36 super(configurer);
37 }
38
39 public ActionBarAdvisor createActionBarAdvisor(
40 IActionBarConfigurer configurer) {
41 return new ApplicationActionBarAdvisor(configurer);
42 }
43
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");
51 }
52
53 public void postWindowOpen() {
54 checkNomenclaturalCode();
55 }
56
57 private void checkNomenclaturalCode() {
58
59 // First time Editor is opened, no nomenclatural code has been set
60 if (PreferencesUtil.getPreferredNomenclaturalCode() == null) {
61
62 // Query user re: preferred nom. code
63 Dialog dialog = new InitNomenclaturalCodePrefDialog(GlobalController.getShell());
64 int returnCode = dialog.open();
65
66 // Short message confirming user's choice
67 String code = PreferencesUtil.getPreferredNomenclaturalCodeAsString();
68 MessageDialog.openInformation(GlobalController.getShell(), "Nomenclatural code set",
69 "The following has been set as your preferred nomenclatural code:\n\n\t" +
70 code + "\n\nYou can change the botanical code at any time in the \"Preferences\" menu.");
71 }
72 }
73
74 }