1 package eu
.etaxonomy
.taxeditor
;
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
.IPartListener
;
9 import org
.eclipse
.ui
.IPartListener2
;
10 import org
.eclipse
.ui
.IWorkbenchPartReference
;
11 import org
.eclipse
.ui
.application
.ActionBarAdvisor
;
12 import org
.eclipse
.ui
.application
.IActionBarConfigurer
;
13 import org
.eclipse
.ui
.application
.IWorkbenchWindowConfigurer
;
14 import org
.eclipse
.ui
.application
.WorkbenchWindowAdvisor
;
16 import eu
.etaxonomy
.taxeditor
.editor
.EditorUtil
;
17 import eu
.etaxonomy
.taxeditor
.editor
.MultiPageTaxonEditor
;
18 import eu
.etaxonomy
.taxeditor
.store
.preference
.InitNomenclaturalCodePrefDialog
;
19 import eu
.etaxonomy
.taxeditor
.store
.preference
.PreferencesUtil
;
21 public class ApplicationWorkbenchWindowAdvisor
extends WorkbenchWindowAdvisor
{
22 private static final Logger logger
= Logger
.getLogger(ApplicationWorkbenchWindowAdvisor
.class);
24 private IPartListener2 propertySheetListener
;
26 public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer
) {
30 public ActionBarAdvisor
createActionBarAdvisor(
31 IActionBarConfigurer configurer
) {
32 return new ApplicationActionBarAdvisor(configurer
);
35 public void preWindowOpen() {
36 IWorkbenchWindowConfigurer configurer
= getWindowConfigurer();
37 configurer
.setInitialSize(new Point(963, 637));
38 configurer
.setShowCoolBar(true);
39 configurer
.setShowStatusLine(true);
40 configurer
.setShowPerspectiveBar(true);
41 configurer
.setTitle("EDIT Taxonomic Editor");
44 public void postWindowOpen() {
45 checkNomenclaturalCode();
47 // setPropertySheetListener();
53 // private void setPropertySheetListener() {
54 // propertySheetListener = new IPartListener2() {
56 // public void partActivated(IWorkbenchPartReference partRef) {
57 // if (partRef.getId().equals(MultiPageTaxonEditor.ID)) {
58 // EditorUtil.showPropertySheet();
62 // public void partOpened(IWorkbenchPartReference partRef) {
63 //// if (partRef.getId().equals(MultiPageTaxonEditor.ID)) {
64 //// EditorUtil.showPropertySheet();
68 // public void partClosed(IWorkbenchPartReference partRef) {
69 //// if (partRef.getId().equals(MultiPageTaxonEditor.ID)) {
70 //// EditorUtil.checkHidePropertySheet();
74 // public void partBroughtToTop(IWorkbenchPartReference partRef) {}
76 // public void partDeactivated(IWorkbenchPartReference partRef) {
77 // EditorUtil.checkHidePropertySheet();
80 // public void partHidden(IWorkbenchPartReference partRef) {}
82 // public void partInputChanged(IWorkbenchPartReference partRef) {}
84 // public void partVisible(IWorkbenchPartReference partRef) {}
87 //// getWindowConfigurer().getWindow().getActivePage().addPartListener(propertySheetListener);
90 private void checkNomenclaturalCode() {
92 // First time Editor is opened, no nomenclatural code has been set
93 if (PreferencesUtil
.getPreferredNomenclaturalCode() == null) {
95 Shell shell
= TaxonomicEditorPlugin
.getDefault().getWorkbench()
96 .getActiveWorkbenchWindow().getShell();
98 // Query user re: preferred nom. code
99 Dialog dialog
= new InitNomenclaturalCodePrefDialog(shell
);
100 int returnCode
= dialog
.open();
102 // Short message confirming user's choice
103 String code
= PreferencesUtil
.getPreferredNomenclaturalCodeAsString();
104 MessageDialog
.openInformation(shell
, "Nomenclatural code set",
105 "The following has been set as your preferred nomenclatural code:\n\n\t" +
106 code
+ "\n\nYou can change the nomenclatural code at any time in the \"Preferences\" menu.");