Project

General

Profile

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

    
3
import java.util.List;
4

    
5
import org.eclipse.e4.ui.model.application.ui.basic.MTrimElement;
6
import org.eclipse.e4.ui.model.application.ui.menu.MToolBarElement;
7
import org.eclipse.e4.ui.model.application.ui.menu.impl.ToolBarImpl;
8
import org.eclipse.swt.graphics.Point;
9
import org.eclipse.ui.IWorkbenchWindow;
10
import org.eclipse.ui.PlatformUI;
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;
15
import org.eclipse.ui.internal.WorkbenchWindow;
16

    
17
import eu.etaxonomy.taxeditor.datasource.CdmDataSourceRepository;
18
import eu.etaxonomy.taxeditor.handler.update.P2Util;
19
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
20
import eu.etaxonomy.taxeditor.store.CdmStore;
21
import eu.etaxonomy.taxeditor.util.ApplicationUtil;
22

    
23
/**
24
 *
25
 * @author n.hoffmann
26
 * @version $Id: $
27
 */
28
public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
29

    
30
	public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
31
		super(configurer);
32
	}
33

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

    
40
	@Override
41
    public void preWindowOpen() {
42
		IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
43
		configurer.setInitialSize(new Point(1280, 720));
44
		configurer.setShowCoolBar(true);
45
		configurer.setShowStatusLine(true);
46
		configurer.setShowPerspectiveBar(true);
47
		configurer.setTitle(ApplicationUtil.getTitle());
48
		configurer.setShowProgressIndicator(true);
49

    
50
		CdmDataSourceRepository.createDefaultH2DataSource();
51
	}
52

    
53
	@Override
54
    public void postWindowOpen() {
55
	    IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
56

    
57
	    List<MTrimElement> elements =  ((WorkbenchWindow) workbenchWindow).getTopTrim().getChildren();
58
	    for (MTrimElement item : elements) {
59
	        if (item instanceof ToolBarImpl){
60
	            ToolBarImpl toolBar = (ToolBarImpl)item;
61
	            List<MToolBarElement> children = toolBar.getChildren();
62
	            for (MToolBarElement element: children){
63
	                if (element.getElementId().equals("eu.etaxonomy.taxeditor.workbench.menu.toolbar.new")) {
64
	                    element.setVisible(false);
65
	                }
66
	            }
67
	        }
68

    
69
        }
70
		PreferencesUtil.checkNomenclaturalCode();
71

    
72
		if(PreferencesUtil.shouldConnectAtStartUp()) {
73
            CdmStore.connect();
74
        }
75

    
76
		P2Util.setP2UpdateRepositories();
77

    
78
	}
79

    
80
	@Override
81
    public void postWindowClose() {
82
        P2Util.saveP2RepositoryPreferences();
83
    }
84
}
85

    
(4-4/7)