Project

General

Profile

« Previous | Next » 

Revision 0a72efb6

Added by Cherian Mathew almost 9 years ago

#5009 Update plugin to use remoting handlers

View differences:

eu.etaxonomy.taxeditor.navigation/plugin.xml
513 513
            </reference>
514 514
         </activeWhen>
515 515
      </handler>
516
      <handler
517
            class="eu.etaxonomy.taxeditor.navigation.key.polytomous.handler.RemotingDeletePolytomousKeyHandler"
518
            commandId="eu.etaxonomy.taxeditor.navigation.key.polytomous.command.delete">
519
         <activeWhen>
520
            <reference
521
                  definitionId="isRemoting">
522
            </reference>
523
         </activeWhen>
524
      </handler>
525
      <handler
526
            class="eu.etaxonomy.taxeditor.navigation.key.polytomous.handler.RemotingUpdatePolytomousKeyAllNodesHandler"
527
            commandId="eu.etaxonomy.taxeditor.navigation.key.polytomous.refreshKeyNodes">
528
         <activeWhen>
529
            <reference
530
                  definitionId="isRemoting">
531
            </reference>
532
         </activeWhen>
533
      </handler>
516 534
   </extension>
517 535

  
518 536
      
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/PolytomousKeyViewPart.java
34 34
import org.eclipse.ui.part.ViewPart;
35 35

  
36 36
import eu.etaxonomy.cdm.api.application.CdmChangeEvent;
37
import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action;
37 38
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
38 39
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
39 40
import eu.etaxonomy.cdm.api.service.IPolytomousKeyService;
......
309 310
     */
310 311
    @Override
311 312
    public void onChange(CdmChangeEvent event) {
312
        // TODO Auto-generated method stub
313
        if(event.getSourceType().equals(PolytomousKeyViewPart.class) && event.getAction() == Action.Delete) {
314
            viewer.refresh();
315
        }
313 316

  
314 317
    }
315 318

  
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/handler/RemotingUpdatePolytomousKeyAllNodesHandler.java
12 12
import org.eclipse.core.commands.ExecutionEvent;
13 13
import org.eclipse.core.commands.operations.AbstractOperation;
14 14
import org.eclipse.core.runtime.IStatus;
15
import org.eclipse.core.runtime.Status;
15 16

  
16 17
import eu.etaxonomy.taxeditor.navigation.key.polytomous.PolytomousKeyViewLabels;
18
import eu.etaxonomy.taxeditor.navigation.key.polytomous.operation.RemotingUpdatePolytomousKeyAllNodesOperation;
17 19
import eu.etaxonomy.taxeditor.operation.RemotingCdmHandler;
18 20

  
19 21
/**
......
35 37
     */
36 38
    @Override
37 39
    public IStatus allowOperations(ExecutionEvent event) {
38
        // TODO Auto-generated method stub
39
        return null;
40
        return Status.OK_STATUS;
40 41
    }
41 42

  
42 43
    /* (non-Javadoc)
......
44 45
     */
45 46
    @Override
46 47
    public AbstractOperation prepareOperation(ExecutionEvent event) {
47
        // TODO Auto-generated method stub
48
        return null;
48
        return new RemotingUpdatePolytomousKeyAllNodesOperation(event.getTrigger(), false);
49 49
    }
50 50

  
51 51
    /* (non-Javadoc)
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/operation/RemotingUpdatePolytomousKeyAllNodesOperation.java
27 27
 */
28 28
public class RemotingUpdatePolytomousKeyAllNodesOperation extends RemotingCdmUpdateOperation {
29 29

  
30
    UUID polytomousKeyUuid;
30
    private final UUID polytomousKeyUuid;
31 31
    /**
32 32
     * @param label
33 33
     * @param action
......
42 42

  
43 43
    }
44 44

  
45
    public RemotingUpdatePolytomousKeyAllNodesOperation(Object source,
46
            boolean async) {
47
        super(LABEL, Action.Update, source, async);
48
        // this implies that we have to update all nodes of all keys
49
        this.polytomousKeyUuid = null;
50
    }
51

  
45 52
    private final static String LABEL = "Update All Polytomous Key Nodes operation";
46 53

  
47 54
    /* (non-Javadoc)
......
49 56
     */
50 57
    @Override
51 58
    protected UpdateResult doUpdateExecute(IProgressMonitor monitor, IAdaptable info) throws Exception {
52
        return CdmStore.getService(IPolytomousKeyService.class).updateAllNodeNumberings(polytomousKeyUuid);
59
        if(polytomousKeyUuid == null) {
60
            return CdmStore.getService(IPolytomousKeyService.class).updateAllNodeNumberings();
61
        } else {
62
            return CdmStore.getService(IPolytomousKeyService.class).updateAllNodeNumberings(polytomousKeyUuid);
63
        }
53 64
    }
54 65

  
55 66
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/RemotingCdmUpdateOperation.java
52 52
            } else {
53 53
                UpdateResult exceptionResult = new UpdateResult();
54 54
                exceptionResult.addException(e);
55
                exceptionResult.setError();
55
                exceptionResult.setAbort();
56 56
                updateResult = exceptionResult;
57 57
            }
58 58
        }
......
79 79
            int statusFlag = IStatus.OK;
80 80

  
81 81
            Collection<Exception> exceptions = updateResult.getExceptions();
82
            StringBuffer statusMsg = new StringBuffer();
82 83
            if(success && updateResult.isOk()) {
83 84
                if(exceptions.isEmpty()) {
84 85
                    return Status.OK_STATUS;
85 86
                } else {
86 87
                    statusFlag = IStatus.WARNING;
88
                    statusMsg.append(getLabel() + " executed sucessfully but with warnings." + System.lineSeparator());
87 89
                }
88
            } else {
90
            } else if (updateResult.isError()) {
89 91
                statusFlag = IStatus.ERROR;
92
                statusMsg.append(getLabel() + " failed." + System.lineSeparator());
93
            } else if (updateResult.isAbort()) {
94
                statusFlag = IStatus.ERROR;
95
                statusMsg.append(getLabel() + " aborted." + System.lineSeparator());
90 96
            }
91 97

  
92 98
            Status[] childStatus = new Status[exceptions.size()];
......
102 108
                childStatus[count] = status;
103 109
                count++;
104 110
            }
105
            StringBuffer statusMsg = new StringBuffer();
106
            for(String message : messages) {
107
                statusMsg.append(message);
108
                statusMsg.append(System.lineSeparator());
109
            }
111

  
112
            statusMsg.append("Please click on the 'Details' button to see all the errors / warnings");
113

  
110 114
            MultiStatus multiStatus = new MultiStatus("unknown",
111 115
                    statusFlag,
112 116
                    childStatus,

Also available in: Unified diff