Project

General

Profile

« Previous | Next » 

Revision 907fd6eb

Added by Katja Luther about 5 years ago

fix #7011: open the cdm authorities editor in editor area and fix that it is grayed

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/EditorUtil.java
37 37
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
38 38
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
39 39
import eu.etaxonomy.taxeditor.editor.e4.TaxonEditorInputE4;
40
import eu.etaxonomy.taxeditor.editor.group.authority.CdmAuthorityEditorInput;
41
import eu.etaxonomy.taxeditor.editor.group.authority.e4.CdmAuthorityEditorE4;
40 42
import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin;
41 43
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
42 44
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
......
141 143
        TaxonNameEditorE4 editor = (TaxonNameEditorE4) part.getObject();
142 144
        editor.init(input);
143 145
    }
146
    public static void openRightsEditor(CdmAuthorityEditorInput input, EModelService modelService, EPartService partService, MApplication application){
147
        MPart part = partService.createPart("eu.etaxonomy.taxeditor.editor.group.authority.e4.CdmAuthorityEditorE4");
148
        MPartStack editorAreaPartStack = WorkbenchUtility.getEditorAreaPartStack(application, modelService);
149
        if(editorAreaPartStack!=null){
150
            editorAreaPartStack.getChildren().add(part);
151
        }
152
        part = partService.showPart(part, PartState.ACTIVATE);
153
        CdmAuthorityEditorE4 authorityView = (CdmAuthorityEditorE4) part.getObject();
154
        authorityView.init(input);
155
    }
144 156

  
145 157
	/**
146 158
	 * An uninitialized taxon is one that hasn't been saved yet. As such, it
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/group/authority/e4/CdmAuthorityEditorE4.java
66 66
	public void createPartControl(Composite parent) {
67 67
		container = new Composite(parent, SWT.NONE);
68 68
		container.setLayout(new FillLayout(SWT.HORIZONTAL));
69

  
69 70
	}
70 71

  
71 72
	@Focus
......
97 98
        this.viewer = new CdmAuthorityCompositeViewer(container, this,input.getGroup());
98 99

  
99 100
        thisPart.setLabel(input.getName());
101
        container.layout();
100 102
	}
101 103

  
102 104
	public boolean isDirty() {
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/group/authority/e4/handler/EditCdmAuthoritiesHandlerE4.java
10 10

  
11 11
import javax.inject.Named;
12 12

  
13
import org.eclipse.core.runtime.IProgressMonitor;
14
import org.eclipse.core.runtime.IStatus;
15
import org.eclipse.core.runtime.Status;
16
import org.eclipse.core.runtime.jobs.Job;
17 13
import org.eclipse.e4.core.di.annotations.CanExecute;
18 14
import org.eclipse.e4.core.di.annotations.Execute;
19
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
15
import org.eclipse.e4.ui.model.application.MApplication;
20 16
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
21 17
import org.eclipse.e4.ui.services.IServiceConstants;
18
import org.eclipse.e4.ui.workbench.modeling.EModelService;
22 19
import org.eclipse.e4.ui.workbench.modeling.EPartService;
23
import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState;
24
import org.eclipse.swt.widgets.Display;
25 20

  
26 21
import eu.etaxonomy.cdm.model.common.CdmBase;
27 22
import eu.etaxonomy.cdm.model.common.Group;
28 23
import eu.etaxonomy.taxeditor.editor.EditorUtil;
29 24
import eu.etaxonomy.taxeditor.editor.group.authority.CdmAuthorityEditor;
30 25
import eu.etaxonomy.taxeditor.editor.group.authority.CdmAuthorityEditorInput;
31
import eu.etaxonomy.taxeditor.editor.group.authority.e4.CdmAuthorityEditorE4;
32 26
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
33
import eu.etaxonomy.taxeditor.model.MessagingUtils;
34 27

  
35 28
/**
36 29
 * Handler which opens an instance of the {@link CdmAuthorityEditor} for a2
......
47 40

  
48 41
    @Execute
49 42
    public void execute(@Named(IServiceConstants.ACTIVE_SELECTION) CdmBase selection,
50
            EPartService partService) {
51
        Job job = new Job(OPENING_CDM_AUTHORITIES) {
52
            @Override
53
            protected IStatus run(IProgressMonitor monitor) {
54
                monitor.beginTask(OPENING_CDM_AUTHORITIES, 1);//selection.size());
55

  
56
                if (selection instanceof Group) {
57
                    Display.getDefault().asyncExec(new Runnable() {
58
                        @Override
59
                        public void run() {
60
                            try {
61
                                MPart part = partService.createPart("eu.etaxonomy.taxeditor.editor.group.authority.e4.CdmAuthorityEditorE4");
62
                                part = partService.showPart(part, PartState.ACTIVATE);
63
                                CdmAuthorityEditorE4 editor = (CdmAuthorityEditorE4) part.getObject();
64
                                editor.init(CdmAuthorityEditorInput.NewInstance(((Group) selection).getUuid()));
65
                            } catch (Exception e) {
66
                                MessagingUtils.warningDialog(
67
                                        Messages.EditCdmAuthoritiesHandler_COULD_NOT_OPEN_AUTHORITIES,
68
                                        EditorUtil.class, e.getMessage());
69
                            }
70
                        }
71

  
72
                    });
73
                    monitor.worked(1);
74
                }
75
                monitor.done();
76
                return Status.OK_STATUS;
77
            }
78
        };
79
        job.setPriority(Job.SHORT);
80
        job.schedule();
43
            EPartService partService, EModelService modelService, MApplication application) {
44
        try {
45
            EditorUtil.openRightsEditor(CdmAuthorityEditorInput.NewInstance(((Group) selection).getUuid()), modelService, partService, application);
46
        } catch (Exception e) {
47
            // TODO Auto-generated catch block
48
            e.printStackTrace();
49
        }
50
//        Job job = new Job(OPENING_CDM_AUTHORITIES) {
51
//            @Override
52
//            protected IStatus run(IProgressMonitor monitor) {
53
//                monitor.beginTask(OPENING_CDM_AUTHORITIES, 1);//selection.size());
54
//
55
//                if (selection instanceof Group) {
56
//                    Display.getDefault().asyncExec(new Runnable() {
57
//                        @Override
58
//                        public void run() {
59
//                            try {
60
////                                MPart part = partService.createPart("eu.etaxonomy.taxeditor.editor.group.authority.e4.CdmAuthorityEditorE4");
61
////                                part = partService.showPart(part, PartState.ACTIVATE);
62
////                                CdmAuthorityEditorE4 editor = (CdmAuthorityEditorE4) part.getObject();
63
////                                editor.init(CdmAuthorityEditorInput.NewInstance(((Group) selection).getUuid()));
64
//
65
//                            } catch (Exception e) {
66
//                                MessagingUtils.warningDialog(
67
//                                        Messages.EditCdmAuthoritiesHandler_COULD_NOT_OPEN_AUTHORITIES,
68
//                                        EditorUtil.class, e.getMessage());
69
//                            }
70
//                        }
71
//
72
//                    });
73
//                    monitor.worked(1);
74
//                }
75
//                monitor.done();
76
//                return Status.OK_STATUS;
77
//            }
78
//        };
79
//        job.setPriority(Job.SHORT);
80
//        job.schedule();
81 81
    }
82 82

  
83 83
    @CanExecute

Also available in: Unified diff