Project

General

Profile

« Previous | Next » 

Revision d0eb8b9f

Added by Patrick Plitzner over 6 years ago

fix #7011 Migrate group authority editor

View differences:

eu.etaxonomy.taxeditor.bulkeditor/META-INF/MANIFEST.MF
9 9
 eu.etaxonomy.taxeditor.annotatedlineeditor.handler,
10 10
 eu.etaxonomy.taxeditor.bulkeditor,
11 11
 eu.etaxonomy.taxeditor.bulkeditor.command,
12
 eu.etaxonomy.taxeditor.bulkeditor.e4,
12 13
 eu.etaxonomy.taxeditor.bulkeditor.handler,
13 14
 eu.etaxonomy.taxeditor.bulkeditor.input,
14 15
 eu.etaxonomy.taxeditor.bulkeditor.internal,
eu.etaxonomy.taxeditor.bulkeditor/fragment.e4xmi
75 75
      <menus xsi:type="menu:PopupMenu" xmi:id="_B6IFsJcMEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.popupmenu.bulkeditor">
76 76
        <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_H83EMJcMEeeM745tzuPNCQ" coreExpressionId="isCdmStoreConnected"/>
77 77
        <children xsi:type="menu:DynamicMenuContribution" xmi:id="_Y49vAJfHEeeUB5KN7hGpYQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.e4.command.DynamicNewObjectMenuE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.bulkeditor/eu.etaxonomy.taxeditor.bulkeditor.e4.command.DynamicNewObjectMenuE4"/>
78
        <children xsi:type="menu:MenuSeparator" xmi:id="_LvKuoKz5EeeBIsZyvYlAaA" elementId="eu.etaxonomy.taxeditor.bulkeditor.menuseparator.afterNew"/>
78 79
        <children xsi:type="menu:DynamicMenuContribution" xmi:id="_3V-TQKK4EeeZb4PEjoRsuw" elementId="eu.etaxonomy.taxeditor.bulkeditor.dynamicmenucontribution.cdmViewer" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.view.CdmViewerContextMenuE4"/>
79 80
        <children xsi:type="menu:MenuSeparator" xmi:id="_VhML4JcMEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.menuseparator.1"/>
80 81
        <children xsi:type="menu:HandledMenuItem" xmi:id="_WOzf0JcMEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.handledmenuitem.setMergeTarget" label="%command.label.0" command="_GAm9cJcNEeeM745tzuPNCQ"/>
eu.etaxonomy.taxeditor.editor/fragment.e4xmi
217 217
        <children xsi:type="menu:HandledMenuItem" xmi:id="_Rf4A8KRREeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.polytomouskeylist.delete" label="%command.label.26" command="_uM4zsKO8EeeWePK798pdTw"/>
218 218
      </menus>
219 219
    </elements>
220
    <elements xsi:type="basic:PartDescriptor" xmi:id="_ARZyMKz2EeeBIsZyvYlAaA" elementId="eu.etaxonomy.taxeditor.editor.group.authority.e4.CdmAuthorityEditorE4" label="%editor.name.4" closeable="true" dirtyable="true" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.group.authority.e4.CdmAuthorityEditorE4"/>
220 221
  </fragments>
221 222
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="__mwtMDVpEee_b7RlBzTDRw" featurename="commands" parentElementId="xpath:/">
222 223
    <elements xsi:type="commands:Command" xmi:id="_BjF3ADVqEee_b7RlBzTDRw" elementId="eu.etaxonomy.taxeditor.editor.command.specimeneditor.create_field_unit" commandName="%command.commandname.1"/>
......
279 280
    <elements xsi:type="commands:Command" xmi:id="_tyHGwKO9EeeWePK798pdTw" elementId="eu.etaxonomy.taxeditor.key.polytomous.command.new.child" commandName="%command.name.28"/>
280 281
    <elements xsi:type="commands:Command" xmi:id="_mH1G8KRSEeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.key.polytomous.command.refresh" commandName="%command.name.30"/>
281 282
    <elements xsi:type="commands:Command" xmi:id="_ZolPMKTaEeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.editor.command.polytomouskeylist.openGraph" commandName="Open Graph Editor"/>
283
    <elements xsi:type="commands:Command" xmi:id="_cxTosKzzEeeBIsZyvYlAaA" elementId="eu.etaxonomy.taxeditor.group.cdmauthorities.edit" commandName="%command.name.34"/>
282 284
  </fragments>
283 285
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_pZmusEalEeeXMc6kSYO7Xg" featurename="children" parentElementId="eu.etaxonomy.taxeditor.menu.showView" positionInList="after:eu.etaxonomy.taxeditor.store.menuseparator.afterSupplemental">
284 286
    <elements xsi:type="menu:MenuSeparator" xmi:id="_eAVmMJ7SEee0IagNh8pHpQ" elementId="eu.etaxonomy.taxeditor.editor.menuseparator.14"/>
......
310 312
    <elements xsi:type="commands:Handler" xmi:id="_EYtGcJMmEeeR4YRjNqCKeA" elementId="eu.etaxonomy.taxeditor.editor.handler.defaultHandler.DefaultOpenTaxonEditorForTaxonNodeHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.handler.defaultHandler.DefaultOpenTaxonEditorForTaxonNodeHandler" command="_9S0o4JMlEeeR4YRjNqCKeA"/>
311 313
    <elements xsi:type="commands:Handler" xmi:id="_ihC9kJMnEeeR4YRjNqCKeA" elementId="eu.etaxonomy.taxeditor.editor.view.derivate.handler.OpenDerivativeEditorForSpecimenOrOBservationBase" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.view.derivate.handler.OpenDerivativeEditorForSpecimenOrOBservationBase" command="_j2cfsJMmEeeR4YRjNqCKeA"/>
312 314
    <elements xsi:type="commands:Handler" xmi:id="_9MRA4KNrEeee0INlRJv_6Q" elementId="eu.etaxonomy.taxeditor.editor.view.checklist.e4.handler.OpenChecklistEditorHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.view.checklist.e4.handler.OpenChecklistEditorHandlerE4" command="_Qi76oKNsEeee0INlRJv_6Q"/>
315
    <elements xsi:type="commands:Handler" xmi:id="_MAx1UKz0EeeBIsZyvYlAaA" elementId="eu.etaxonomy.taxeditor.editor.group.authority.e4.handler.EditCdmAuthoritiesHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.group.authority.e4.handler.EditCdmAuthoritiesHandlerE4" command="_cxTosKzzEeeBIsZyvYlAaA"/>
313 316
  </fragments>
314 317
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_OyvD8KNOEee5fYT78qEx0A" featurename="children" parentElementId="bulkeditor.menus.openmenu" positionInList="last">
315 318
    <elements xsi:type="menu:HandledMenuItem" xmi:id="_SZZBkKNOEee5fYT78qEx0A" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.specimen_editor" label="%command.label.DERIVATIVE_EDITOR" command="_WPjpoDSnEeek0dKsFNy--Q">
316 319
      <parameters xmi:id="_Z35agKNOEee5fYT78qEx0A" elementId="eu.etaxonomy.taxeditor.editor.showView.parameter.specimenEditor" name="eu.etaxonomy.taxeditor.workbench.commandparameter.partName" value="eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView"/>
317 320
    </elements>
318 321
  </fragments>
322
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_Fw06MKz0EeeBIsZyvYlAaA" featurename="children" parentElementId="eu.etaxonomy.taxeditor.bulkeditor.popupmenu.bulkeditor" positionInList="after:eu.etaxonomy.taxeditor.bulkeditor.menuseparator.afterNew">
323
    <elements xsi:type="menu:HandledMenuItem" xmi:id="_JzLVUKz0EeeBIsZyvYlAaA" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.commandname34" label="%command.name.34" command="_cxTosKzzEeeBIsZyvYlAaA"/>
324
  </fragments>
319 325
</fragment:ModelFragments>
eu.etaxonomy.taxeditor.editor/plugin.xml
20 20
            </adapter>
21 21
         </factory>
22 22
      </extension>
23
   <extension
24
         point="org.eclipse.ui.editors">
25
      <editor
26
            class="eu.etaxonomy.taxeditor.editor.group.authority.CdmAuthorityEditor"
27
            default="false"
28
            id="eu.etaxonomy.taxeditor.editor.group.authority"
29
            name="%editor.name.4">
30
      </editor>
31
   </extension>
32 23
      <extension
33 24
            point="org.eclipse.ui.views">
34 25
         <view
......
219 210
      
220 211
      
221 212
      
222
      <menuContribution
223
            allPopups="false"
224
            locationURI="popup:bulkeditor.editor?before=eu.etaxonomy.taxeditor.bulkeditor.separator1">
225
         <command
226
               commandId="eu.etaxonomy.taxeditor.group.cdmauthorities.edit"
227
               label="%command.label.45"
228
               style="push">
229
            <visibleWhen>
230
               <reference
231
                     definitionId="isGroupEditor">
232
               </reference>
233
            </visibleWhen>
234
         </command>
235
      </menuContribution>
236 213
      <menuContribution
237 214
            allPopups="false"
238 215
            locationURI="toolbar:org.eclipse.ui.main.toolbar?after=eu.etaxonomy.taxeditor.navigation.search.toolbar">
......
348 325
            id="eu.etaxonomy.taxeditor.bulkeditor.group.category"
349 326
            name="%category.name.7">
350 327
      </category>
351
      <command
352
            categoryId="eu.etaxonomy.taxeditor.bulkeditor.group.category"
353
            defaultHandler="eu.etaxonomy.taxeditor.editor.group.authority.handler.EditCdmAuthoritiesHandler"
354
            id="eu.etaxonomy.taxeditor.group.cdmauthorities.edit"
355
            name="%command.name.34">
356
      </command>
357 328
       <command
358 329
             id="eu.etaxonomy.taxeditor.editor.handler.OpenChecklistViewHandler"
359 330
             name="%command.name.38">
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/group/authority/e4/CdmAuthorityEditorE4.java
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
package eu.etaxonomy.taxeditor.editor.group.authority.e4;
10

  
11
import javax.annotation.PostConstruct;
12
import javax.annotation.PreDestroy;
13
import javax.inject.Inject;
14

  
15
import org.eclipse.core.runtime.IProgressMonitor;
16
import org.eclipse.e4.ui.di.Focus;
17
import org.eclipse.e4.ui.di.Persist;
18
import org.eclipse.e4.ui.model.application.ui.MDirtyable;
19
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
20
import org.eclipse.swt.SWT;
21
import org.eclipse.swt.layout.FillLayout;
22
import org.eclipse.swt.widgets.Composite;
23

  
24
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
25
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
26
import eu.etaxonomy.cdm.model.common.Group;
27
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
28
import eu.etaxonomy.taxeditor.editor.group.authority.CdmAuthorityEditorInput;
29
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
30
import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
31
import eu.etaxonomy.taxeditor.ui.group.grantedauthority.CdmAuthorityCompositeViewer;
32

  
33
/**
34
 * Editor responsible for editing authorities related to a particular {@link Group} entity.
35
 *
36
 * @author cmathew
37
 * @created Mar 28, 2013
38
 *
39
 */
40
public class CdmAuthorityEditorE4 implements IConversationEnabled, IDirtyMarkable {
41

  
42
	public static final String ID = "eu.etaxonomy.taxeditor.editor.group.authority"; //$NON-NLS-1$
43

  
44
	@Inject
45
	private MDirtyable dirty;
46
	private ConversationHolder conversation;
47
	private CdmAuthorityCompositeViewer viewer;
48

  
49
	private CdmAuthorityEditorInput input;
50

  
51
	@Inject
52
	private MPart thisPart;
53

  
54
    private Composite container;
55

  
56
	@Inject
57
	public CdmAuthorityEditorE4() {
58

  
59
	}
60

  
61
	/**
62
	 * Create contents of the editor part.
63
	 * @param parent
64
	 */
65
	@PostConstruct
66
	public void createPartControl(Composite parent) {
67
		container = new Composite(parent, SWT.NONE);
68
		container.setLayout(new FillLayout(SWT.HORIZONTAL));
69
	}
70

  
71
	@Focus
72
	public void setFocus() {
73
	    if(input!=null){
74
	        input.bind();
75
	    }
76
	}
77

  
78
	@Persist
79
	public void doSave(IProgressMonitor monitor) {
80
		try {
81
			monitor.beginTask(Messages.CdmAuthorityEditor_SAVING_AUTHORITY_EDITOR, 1);
82
			getConversationHolder().commit(true);
83
			input.merge();
84
			dirty.setDirty(false);
85
			monitor.worked(1);
86
		} finally {
87
			monitor.done();
88
			viewer.save();
89
		}
90
	}
91

  
92
	public void init(CdmAuthorityEditorInput input) {
93
	    this.input = input;
94

  
95
        conversation = input.getConversationHolder();
96

  
97
        this.viewer = new CdmAuthorityCompositeViewer(container, this,input.getGroup());
98

  
99
        thisPart.setLabel(input.getName());
100
	}
101

  
102
	public boolean isDirty() {
103
		return dirty.isDirty();
104
	}
105

  
106
	@Override
107
	public void update(CdmDataChangeMap changeEvents) {
108
	}
109

  
110
	@Override
111
	public void changed(Object element) {
112
		//FIXME : should be optimised to split changes into adding / removing authorities
113
		//        vs updating authorites
114
		dirty.setDirty(viewer.isDirty());
115
		// if the change has happened on the group then refresh the table
116
		if(element instanceof Group) {
117
			//FIXME: activating (setting focus) on the editor happens on every change
118
			//       This should be changed to only when the drop is successful
119
		    //FIXME E4 migrate/delete
120
//			getSite().getPage().activate(this);
121
		}
122

  
123
	}
124

  
125
	@Override
126
	public void forceDirty() {
127
	    changed(null);
128
	}
129

  
130
	@Override
131
	public ConversationHolder getConversationHolder() {
132
		return conversation;
133
	}
134

  
135
	@PreDestroy
136
	public void dispose() {
137
	    if(conversation!=null){
138
	        conversation.unregisterForDataStoreChanges(this);
139
	        conversation.close();
140
	    }
141
		if(input!=null){
142
		    input.getCdmEntitySession().dispose();
143
		}
144
	}
145
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/group/authority/e4/handler/EditCdmAuthoritiesHandlerE4.java
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
package eu.etaxonomy.taxeditor.editor.group.authority.e4.handler;
10

  
11
import javax.inject.Named;
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
import org.eclipse.e4.core.di.annotations.CanExecute;
18
import org.eclipse.e4.core.di.annotations.Execute;
19
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
20
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
21
import org.eclipse.e4.ui.services.IServiceConstants;
22
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

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

  
35
/**
36
 * Handler which opens an instance of the {@link CdmAuthorityEditor} for a2
37
 * particluar group.
38
 *
39
 * @author cmathew
40
 * @created Mar 28, 2013
41
 *
42
 */
43

  
44
public class EditCdmAuthoritiesHandlerE4 {
45

  
46
    private static final String OPENING_CDM_AUTHORITIES = Messages.EditCdmAuthoritiesHandler_OPEN_AUTHORITIES;
47

  
48
    @Execute
49
    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();
81
    }
82

  
83
    @CanExecute
84
    public boolean execute(@Named(IServiceConstants.ACTIVE_SELECTION) CdmBase selection,
85
            MHandledMenuItem menuItem){
86
        boolean canExecute = false;
87
        canExecute = selection instanceof Group;
88
        menuItem.setVisible(canExecute);
89
        return canExecute;
90

  
91
    }
92
}

Also available in: Unified diff