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
.application
.ActionBarAdvisor
;
9 import org
.eclipse
.ui
.application
.IActionBarConfigurer
;
10 import org
.eclipse
.ui
.application
.IWorkbenchWindowConfigurer
;
11 import org
.eclipse
.ui
.application
.WorkbenchWindowAdvisor
;
12 import org
.springframework
.security
.BadCredentialsException
;
14 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalCode
;
15 import eu
.etaxonomy
.taxeditor
.dialogs
.LoginDialog
;
16 import eu
.etaxonomy
.taxeditor
.model
.NomenclaturalCodeHelper
;
17 import eu
.etaxonomy
.taxeditor
.preference
.InitNomenclaturalCodePrefDialog
;
18 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
20 public class ApplicationWorkbenchWindowAdvisor
extends WorkbenchWindowAdvisor
{
21 private static final Logger logger
= Logger
.getLogger(ApplicationWorkbenchWindowAdvisor
.class);
23 public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer
) {
27 public ActionBarAdvisor
createActionBarAdvisor(
28 IActionBarConfigurer configurer
) {
29 return new ApplicationActionBarAdvisor(configurer
);
32 public void preWindowOpen() {
33 IWorkbenchWindowConfigurer configurer
= getWindowConfigurer();
34 configurer
.setInitialSize(new Point(963, 637));
35 configurer
.setShowCoolBar(true);
36 configurer
.setShowStatusLine(true);
37 configurer
.setShowPerspectiveBar(true);
38 configurer
.setTitle("EDIT Taxonomic Editor");
39 configurer
.setShowProgressIndicator(true);
42 public void postWindowOpen() {
45 }catch(BadCredentialsException e
){
46 logger
.error("Bad credentials", e
);
49 checkNomenclaturalCode();
52 private void checkNomenclaturalCode() {
54 // First time Editor is opened, no nomenclatural code has been set
55 if (PreferencesUtil
.getPreferredNomenclaturalCode() == null) {
57 logger
.info("No nomencatural code set.");
59 Shell shell
= TaxonomicEditorPlugin
.getDefault().getWorkbench()
60 .getActiveWorkbenchWindow().getShell();
62 // Query user re: preferred nom. code
63 Dialog dialog
= new InitNomenclaturalCodePrefDialog(shell
);
66 // Short message confirming user's choice
67 NomenclaturalCode code
= PreferencesUtil
.getPreferredNomenclaturalCode();
68 MessageDialog
.openInformation(shell
, "Nomenclatural code set",
69 "The following has been set as your preferred nomenclatural code:\n\n\t" +
70 NomenclaturalCodeHelper
.getDescription(code
) + "\n\nYou can change the nomenclatural code at any time in the \"Preferences\" menu.");
74 private int authenticate(){
75 Shell shell
= TaxonomicEditorPlugin
.getDefault().getWorkbench()
76 .getActiveWorkbenchWindow().getShell();
78 LoginDialog loginDialog
= new LoginDialog(shell
);
79 return loginDialog
.open();