Project

General

Profile

Download (1.81 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9

    
10
package eu.etaxonomy.taxeditor.view.datasource.e4.handler;
11

    
12
import javax.inject.Named;
13

    
14
import org.eclipse.core.runtime.IStatus;
15
import org.eclipse.e4.core.di.annotations.CanExecute;
16
import org.eclipse.e4.core.di.annotations.Execute;
17
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
18
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
19
import org.eclipse.e4.ui.services.IServiceConstants;
20
import org.eclipse.jface.wizard.WizardDialog;
21
import org.eclipse.swt.widgets.Shell;
22

    
23
import eu.etaxonomy.taxeditor.datasource.wizard.CdmDataSourceWizard;
24
import eu.etaxonomy.taxeditor.view.datasource.e4.CdmDataSourceViewPartE4;
25

    
26
/**
27
 *
28
 * @author pplitzner
29
 * @date 22.08.2017
30
 *
31
 */
32
public class CreateDataSourceHandlerE4 {
33

    
34
    @Execute
35
    public void execute(
36
            @Named(IServiceConstants.ACTIVE_SHELL)Shell shell,
37
            @Named(IServiceConstants.ACTIVE_PART)MPart thisPart) {
38

    
39
        CdmDataSourceViewPartE4 view = (CdmDataSourceViewPartE4) thisPart.getObject();
40

    
41
        CdmDataSourceWizard wizard = new CdmDataSourceWizard();
42

    
43
        WizardDialog dialog = new WizardDialog(shell, wizard);
44

    
45
        boolean refresh = dialog.open() == IStatus.OK;
46

    
47
        if(refresh) {
48
            view.refresh();
49
        }
50
    }
51

    
52
    @CanExecute
53
    public boolean canExecute(
54
            @Named(IServiceConstants.ACTIVE_PART)MPart thisPart,
55
            MHandledMenuItem menuItem) {
56
        boolean canExecute = false;
57
        canExecute = thisPart.getObject() instanceof CdmDataSourceViewPartE4;
58
        menuItem.setVisible(canExecute);
59
        return canExecute;
60
    }
61
}
(4-4/7)