Project

General

Profile

Download (2.5 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.preference.PreferencesUtil;
19
import eu.etaxonomy.taxeditor.store.CdmStore;
20
import eu.etaxonomy.taxeditor.util.ApplicationUtil;
21

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

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

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

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

    
49
		CdmDataSourceRepository.createDefaultH2DataSource();
50
	}
51

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

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

    
68
        }
69
		PreferencesUtil.checkNomenclaturalCode();
70

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

    
75
	}
76

    
77
}
78

    
(4-4/7)