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
;
13 import org
.springframework
.security
.userdetails
.UsernameNotFoundException
;
15 import eu
.etaxonomy
.taxeditor
.dialogs
.LoginDialog
;
16 import eu
.etaxonomy
.taxeditor
.preference
.InitNomenclaturalCodePrefDialog
;
17 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
19 public class ApplicationWorkbenchWindowAdvisor
extends WorkbenchWindowAdvisor
{
20 private static final Logger logger
= Logger
.getLogger(ApplicationWorkbenchWindowAdvisor
.class);
22 public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer
) {
26 public ActionBarAdvisor
createActionBarAdvisor(
27 IActionBarConfigurer configurer
) {
28 return new ApplicationActionBarAdvisor(configurer
);
31 public void preWindowOpen() {
32 IWorkbenchWindowConfigurer configurer
= getWindowConfigurer();
33 configurer
.setInitialSize(new Point(963, 637));
34 configurer
.setShowCoolBar(true);
35 configurer
.setShowStatusLine(true);
36 configurer
.setShowPerspectiveBar(true);
37 configurer
.setTitle("EDIT Taxonomic Editor");
41 public void postWindowOpen() {
44 }catch(BadCredentialsException e
){
45 logger
.error("Bad credentials", e
);
48 checkNomenclaturalCode();
51 private void checkNomenclaturalCode() {
53 // First time Editor is opened, no nomenclatural code has been set
54 if (PreferencesUtil
.getPreferredNomenclaturalCode() == null) {
56 logger
.debug("No nomencatural code set.");
58 Shell shell
= TaxonomicEditorPlugin
.getDefault().getWorkbench()
59 .getActiveWorkbenchWindow().getShell();
61 // Query user re: preferred nom. code
62 Dialog dialog
= new InitNomenclaturalCodePrefDialog(shell
);
65 // Short message confirming user's choice
66 String code
= PreferencesUtil
.getPreferredNomenclaturalCodeAsString();
67 MessageDialog
.openInformation(shell
, "Nomenclatural code set",
68 "The following has been set as your preferred nomenclatural code:\n\n\t" +
69 code
+ "\n\nYou can change the nomenclatural code at any time in the \"Preferences\" menu.");
73 private int authenticate(){
74 Shell shell
= TaxonomicEditorPlugin
.getDefault().getWorkbench()
75 .getActiveWorkbenchWindow().getShell();
77 LoginDialog loginDialog
= new LoginDialog(shell
);
78 return loginDialog
.open();