Project

General

Profile

« Previous | Next » 

Revision e9c96f29

Added by Cherian Mathew almost 9 years ago

#5010, #5046 Integrate remoting in polytomous key editor

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/EditorUtil.java
387 387
		open(input);
388 388
	}
389 389

  
390
	public static void openPolytomousKeyEditor(UUID polytomousKeyUuid, String name)
391
	        throws Exception {
392
	    PolytomousKeyEditorInput input = new PolytomousKeyEditorInput(polytomousKeyUuid, name);
393
	    open(input);
394
	}
395

  
390 396
	public static void openCdmAuthorities(UUID groupUuid)
391 397
			throws Exception {
392 398
		CdmAuthorityEditorInput input = CdmAuthorityEditorInput.NewInstance(groupUuid);
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/KeyEditor.java
10 10

  
11 11
package eu.etaxonomy.taxeditor.editor.key;
12 12

  
13
import java.util.Arrays;
14
import java.util.List;
15

  
13 16
import org.eclipse.core.runtime.IProgressMonitor;
17
import org.eclipse.ui.IEditorInput;
14 18
import org.eclipse.ui.IEditorPart;
19
import org.eclipse.ui.IEditorSite;
15 20
import org.eclipse.ui.PartInitException;
16 21
import org.eclipse.ui.forms.editor.FormEditor;
17 22

  
23
import eu.etaxonomy.cdm.api.application.CdmChangeEvent;
18 24
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
19 25
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
20 26
import eu.etaxonomy.cdm.api.service.IPolytomousKeyService;
......
27 33
import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
28 34
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
29 35
import eu.etaxonomy.taxeditor.model.MessagingUtils;
36
import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
37
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
30 38
import eu.etaxonomy.taxeditor.store.CdmStore;
31 39

  
32 40
/**
......
35 43
 * @version 1.0
36 44
 */
37 45
public class KeyEditor extends FormEditor implements IConversationEnabled,
38
		IDirtyMarkable, IPartContentHasDetails {
46
		IDirtyMarkable, IPartContentHasDetails, ICdmEntitySessionEnabled {
39 47

  
40 48
	public static final String ID = "eu.etaxonomy.taxeditor.editor.key";
41 49

  
......
44 52
	private boolean dirty;
45 53

  
46 54
	private KeyEditorDataChangeBehaviour dataChangeBehavior;
55
	private ICdmEntitySession cdmEntitySession;
56
	private PolytomousKeyEditorInput polytomousKeyEditorInput;
57

  
58
	/*
59
     * (non-Javadoc)
60
     *
61
     * @see org.eclipse.ui.part.EditorPart#init(org.eclipse.ui.IEditorSite,
62
     * org.eclipse.ui.IEditorInput)
63
     */
64
    @Override
65
    public void init(IEditorSite site, IEditorInput input)
66
            throws PartInitException {
67
        cdmEntitySession = CdmStore.getCurrentSessionManager().newSession(this, true);
68
        polytomousKeyEditorInput = (PolytomousKeyEditorInput)input;
69
        if(CdmStore.getCurrentSessionManager().isRemoting()) {
70
            polytomousKeyEditorInput.init();
71
        }
72
        super.init(site, input);
73
    }
47 74

  
48 75
	/*
49 76
	 * (non-Javadoc)
......
88 115
	@Override
89 116
	public void setFocus() {
90 117
		getConversationHolder().bind();
118
		cdmEntitySession.bind();
91 119
		super.setFocus();
92 120
	}
93 121
	/*
......
184 212
	public void dispose() {
185 213
		conversation.unregisterForDataStoreChanges(this);
186 214
		conversation.close();
187
		((PolytomousKeyEditorInput)getEditorInput()).dispose();
215
		cdmEntitySession.dispose();
188 216
		super.dispose();
189 217
	}
190 218

  
......
195 223
	 */
196 224
	@Override
197 225
	protected void addPages() {
198
		AbstractIdentificationEditorInput input = (AbstractIdentificationEditorInput) getEditorInput();
199
		conversation = input.getConversationHolder();
226
		conversation = polytomousKeyEditorInput.getConversationHolder();
200 227
		conversation.registerForDataStoreChanges(this);
201 228

  
202 229
		try {
203
			addPage(0, new PolytomousKeyListEditor(this), input);
230
			addPage(0, new PolytomousKeyListEditor(this), polytomousKeyEditorInput);
204 231
			setPageText(0, "List");
205
			addPage(1, new PolytomousKeyGraphEditor(this), input);
232
			addPage(1, new PolytomousKeyGraphEditor(this), polytomousKeyEditorInput);
206 233
			setPageText(1, "Graph");
207 234
		} catch (PartInitException e) {
208 235
			MessagingUtils.error(getClass(), e);
......
218 245
	 *
219 246
	 */
220 247
	public void setPartName() {
221
		AbstractIdentificationEditorInput input = (AbstractIdentificationEditorInput) getEditorInput();
222
		PolytomousKey key = (PolytomousKey) input.getKey();
248
		PolytomousKey key = polytomousKeyEditorInput.getKey();
223 249
		setPartName(key.getTitleCache());
224 250
	}
225
	
226
	
251

  
252
    /* (non-Javadoc)
253
     * @see eu.etaxonomy.cdm.api.application.ICdmChangeListener#onChange(eu.etaxonomy.cdm.api.application.CdmChangeEvent)
254
     */
255
    @Override
256
    public void onChange(CdmChangeEvent event) {
257
        // TODO Auto-generated method stub
258

  
259
    }
260

  
261
    /* (non-Javadoc)
262
     * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getCdmEntitySession()
263
     */
264
    @Override
265
    public ICdmEntitySession getCdmEntitySession() {
266
        return cdmEntitySession;
267
    }
268

  
269
    /* (non-Javadoc)
270
     * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getRootEntities()
271
     */
272
    @Override
273
    public List<PolytomousKey> getRootEntities() {
274
        return Arrays.asList(polytomousKeyEditorInput.getKey());
275
    }
276

  
277

  
227 278

  
228 279
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/PolytomousKeyEditorInput.java
3 3
 */
4 4
package eu.etaxonomy.taxeditor.editor.key.polytomous;
5 5

  
6
import java.util.Arrays;
7
import java.util.List;
8 6
import java.util.UUID;
9 7

  
10
import eu.etaxonomy.cdm.api.application.CdmChangeEvent;
11 8
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
12 9
import eu.etaxonomy.cdm.api.service.IPolytomousKeyService;
13 10
import eu.etaxonomy.cdm.model.description.PolytomousKey;
14 11
import eu.etaxonomy.taxeditor.editor.key.AbstractIdentificationEditorInput;
15
import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
16
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
17 12
import eu.etaxonomy.taxeditor.store.CdmStore;
18 13

  
19 14
/**
20 15
 * @author n.hoffmann
21 16
 *
22 17
 */
23
public class PolytomousKeyEditorInput extends AbstractIdentificationEditorInput<PolytomousKey> implements ICdmEntitySessionEnabled {
18
public class PolytomousKeyEditorInput extends AbstractIdentificationEditorInput<PolytomousKey> {
24 19

  
25
	private final PolytomousKey key;
26
	private final ICdmEntitySession cdmEntitySession;
20
    private final String name;
21
    private final UUID keyUuid;
22
    private PolytomousKey key;
27 23

  
28
	protected PolytomousKeyEditorInput(ConversationHolder conversation,
29
			PolytomousKey key) {
30
		super(conversation);
31
		cdmEntitySession = CdmStore.getCurrentSessionManager().newSession(this, true);
32 24

  
33
		this.key = key;
34
	}
35

  
36

  
37

  
38
	public static PolytomousKeyEditorInput NewInstance(UUID polytomousKeyUuid) throws Exception{
39
		try{
40
			ConversationHolder conversation = CdmStore.createConversation();
41

  
42
			return NewInstance(polytomousKeyUuid, conversation);
43
		}catch(Exception e){
44
			throw e;
45
		}
46
	}
47

  
48
	public static PolytomousKeyEditorInput NewInstance(UUID polytomousKeyUuid, ConversationHolder conversation) throws Exception{
49
		PolytomousKey polytomousKey = CdmStore.getService(IPolytomousKeyService.class).load(polytomousKeyUuid, null);
50

  
51
		return new PolytomousKeyEditorInput(conversation, polytomousKey);
52
	}
53

  
54
	/* (non-Javadoc)
55
	 * @see org.eclipse.ui.IEditorInput#getName()
56
	 */
57
	@Override
58
	public String getName() {
59
		return key.getTitleCache();
60
	}
61

  
62
	@Override
63
	public PolytomousKey getKey() {
64
		return key;
65
	}
25
    protected PolytomousKeyEditorInput(ConversationHolder conversation,
26
            UUID polytomousKeyUuid) {
27
        super(conversation);
28
        this.keyUuid = polytomousKeyUuid;
29
        this.key = CdmStore.getService(IPolytomousKeyService.class).load(polytomousKeyUuid, null);
30
        this.name = key.getTitleCache();
31
    }
66 32

  
67
	/* (non-Javadoc)
68
	 * @see java.lang.Object#equals(java.lang.Object)
69
	 */
70
	@Override
71
	public boolean equals(Object object) {
72
		if (object instanceof PolytomousKeyEditorInput
73
				&& getKey() != null
74
				&& getKey().equals(((PolytomousKeyEditorInput) object).getKey())
75
		){
76
			return true;
77
		}
78
		return super.equals(object);
79
	}
33
    public PolytomousKeyEditorInput(UUID polytomousKeyUuid, String name) {
34
        super(CdmStore.createConversation());
35
        this.keyUuid = polytomousKeyUuid;
36
        this.name = name;
37
    }
80 38

  
81
	public void dispose() {
82
		cdmEntitySession.dispose();
83
	}
39
    public void init() {
40
        this.key = CdmStore.getService(IPolytomousKeyService.class).load(keyUuid, null);
41
    }
84 42

  
43
    public static PolytomousKeyEditorInput NewInstance(UUID polytomousKeyUuid) throws Exception{
44
        try{
45
            ConversationHolder conversation = CdmStore.createConversation();
46
            return new PolytomousKeyEditorInput(conversation, polytomousKeyUuid);
47
        }catch(Exception e){
48
            throw e;
49
        }
50
    }
85 51

  
86 52

  
87 53
    /* (non-Javadoc)
88
     * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getCdmEntitySession()
54
     * @see org.eclipse.ui.IEditorInput#getName()
89 55
     */
90 56
    @Override
91
    public ICdmEntitySession getCdmEntitySession() {
92
        return cdmEntitySession;
57
    public String getName() {
58
        return name;
93 59
    }
94 60

  
95

  
96

  
97
    /* (non-Javadoc)
98
     * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getRootEntities()
99
     */
100 61
    @Override
101
    public  List<PolytomousKey> getRootEntities() {
102
        return Arrays.asList(key);
62
    public PolytomousKey getKey() {
63
        return key;
103 64
    }
104 65

  
105

  
106

  
107 66
    /* (non-Javadoc)
108
     * @see eu.etaxonomy.cdm.api.application.ICdmChangeListener#onChange(eu.etaxonomy.cdm.api.application.CdmChangeEvent)
67
     * @see java.lang.Object#equals(java.lang.Object)
109 68
     */
110 69
    @Override
111
    public void onChange(CdmChangeEvent event) {
112
        // TODO Auto-generated method stub
113

  
70
    public boolean equals(Object object) {
71
        if (object instanceof PolytomousKeyEditorInput
72
                && getKey() != null
73
                && getKey().equals(((PolytomousKeyEditorInput) object).getKey())
74
                ){
75
            return true;
76
        }
77
        return super.equals(object);
114 78
    }
79

  
115 80
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/PolytomousKeyListEditor.java
47 47
import eu.etaxonomy.taxeditor.editor.key.KeyEditor;
48 48
import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
49 49
import eu.etaxonomy.taxeditor.model.MessagingUtils;
50
import eu.etaxonomy.taxeditor.store.CdmStore;
51 50

  
52 51
/**
53 52
 * @author n.hoffmann
......
302 301
	 */
303 302
	@Override
304 303
	public void setFocus() {
305
		CdmStore.getCurrentSessionManager().bind((PolytomousKeyEditorInput)getEditorInput());
306 304
		PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().setFocus();
307 305
	}
308 306

  
eu.etaxonomy.taxeditor.navigation/plugin.xml
531 531
            </reference>
532 532
         </activeWhen>
533 533
      </handler>
534
      <handler
535
            class="eu.etaxonomy.taxeditor.navigation.key.polytomous.handler.RemotingEditPolytomousKeyNodesHandler"
536
            commandId="eu.etaxonomy.taxeditor.navigation.key.polytomous.editNodes">
537
         <activeWhen>
538
            <reference
539
                  definitionId="isRemoting">
540
            </reference>
541
         </activeWhen>
542
      </handler>
534 543
   </extension>
535 544

  
536 545
      
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/PolytomousKeyViewLabels.java
19 19
    public static final String DELETE_POLYTOMOUS_KEY_LABEL = "Delete Polytomous Key";
20 20
    public static final String UPDATE_ALL_POLYTOMOUS_KEY_NODES_LABEL = "Update All Polytomous Key Nodes";
21 21

  
22
    public static final String ERROR_OPENING_KEY_EDITOR_MESSAGE = "Error opening Polytomous Key Editor";
23

  
24

  
22 25
}

Also available in: Unified diff