Project

General

Profile

Download (2.4 KB) Statistics
| Branch: | Tag: | Revision:
1
package eu.etaxonomy.taxeditor;
2

    
3
import org.eclipse.swt.graphics.Point;
4
import org.eclipse.swt.widgets.Shell;
5
import org.eclipse.ui.application.ActionBarAdvisor;
6
import org.eclipse.ui.application.IActionBarConfigurer;
7
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
8
import org.eclipse.ui.application.WorkbenchWindowAdvisor;
9

    
10
import eu.etaxonomy.taxeditor.datasource.CdmDataSourceRepository;
11
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
12
import eu.etaxonomy.taxeditor.store.CdmStore;
13
import eu.etaxonomy.taxeditor.ui.dialog.LoginDialog;
14
import eu.etaxonomy.taxeditor.update.P2Util;
15
import eu.etaxonomy.taxeditor.util.ApplicationUtil;
16

    
17
/**
18
 * <p>ApplicationWorkbenchWindowAdvisor class.</p>
19
 *
20
 * @author n.hoffmann
21
 * @version $Id: $
22
 */
23
public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
24

    
25
	/**
26
	 * <p>Constructor for ApplicationWorkbenchWindowAdvisor.</p>
27
	 *
28
	 * @param configurer a {@link org.eclipse.ui.application.IWorkbenchWindowConfigurer} object.
29
	 */
30
	public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
31
		super(configurer);
32
	}
33

    
34
	/** {@inheritDoc} */
35
	@Override
36
    public ActionBarAdvisor createActionBarAdvisor(
37
			IActionBarConfigurer configurer) {
38
		return new ApplicationActionBarAdvisor(configurer);
39
	}
40

    
41
	/**
42
	 * <p>preWindowOpen</p>
43
	 */
44
	@Override
45
    public void preWindowOpen() {
46
		IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
47
		configurer.setInitialSize(new Point(963, 637));
48
		configurer.setShowCoolBar(true);
49
		configurer.setShowStatusLine(true);
50
		configurer.setShowPerspectiveBar(true);
51
		configurer.setTitle(ApplicationUtil.getTitle());
52
		configurer.setShowProgressIndicator(true);
53

    
54
		CdmDataSourceRepository.createDefaultH2DataSource();
55
	}
56

    
57
	/**
58
	 * <p>postWindowOpen</p>
59
	 */
60
	@Override
61
    public void postWindowOpen() {
62
		PreferencesUtil.checkNomenclaturalCode();
63

    
64

    
65

    
66
		if(PreferencesUtil.shouldConnectAtStartUp()) {
67
            CdmStore.connect();
68
        }
69

    
70
		P2Util.setP2UpdateRepositories();
71

    
72
	}
73

    
74
	/* (non-Javadoc)
75
	 * @see org.eclipse.ui.application.WorkbenchWindowAdvisor#postWindowClose()
76
	 */
77
	@Override
78
    public void postWindowClose() {
79
        P2Util.saveP2RepositoryPreferences();
80
    }
81

    
82
	private int authenticate(){
83
		Shell shell = TaxonomicEditorPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell();
84

    
85
		LoginDialog loginDialog = new LoginDialog(shell);
86
		return loginDialog.open();
87
	}
88
}
89

    
(4-4/10)