Project

General

Profile

« Previous | Next » 

Revision 7c8e41e0

Added by Cherian Mathew about 11 years ago

PolytomousKeyViewPart : added new method to get all the keys
plugin.xml: added menu and commands to refresh key list and key nodes
RefreshPolytomousKeyListHandler : handler to update list of keys
RefreshPolytomousKeyNodesHandler, RefreshNodesOperation : handler, operation to updated all keys nodes in the list

View differences:

.gitattributes
830 830
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/handler/DeleteHandler.java -text
831 831
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/handler/EditPolytomousKeyNodesHandler.java -text
832 832
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/handler/NewPolytomousKeyHandler.java -text
833
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/handler/RefreshPolytomousKeyListHandler.java -text
834
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/handler/RefreshPolytomousKeyNodesHandler.java -text
833 835
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/operation/DeleteOperation.java -text
836
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/operation/RefreshNodesOperation.java -text
834 837
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/ClassificationContentProvider.java -text
835 838
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/ClassificationLabelProvider.java -text
836 839
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/EmptyRoot.java -text
eu.etaxonomy.taxeditor.navigation/plugin.xml
224 224
               label="Edit"
225 225
               style="push">
226 226
         </command>
227
         <menu
228
               label="Refresh">
229
            <command
230
                  commandId="eu.etaxonomy.taxeditor.navigation.key.polytomous.refreshKeyList"
231
                  label="List"
232
                  style="push">
233
            </command>
234
            <command
235
                  commandId="eu.etaxonomy.taxeditor.navigation.key.polytomous.refreshKeyNodes"
236
                  label="Key Nodes"
237
                  style="push">
238
            </command>
239
         </menu>
227 240
         <separator
228 241
               name="eu.etaxonomy.eu.polytomousKeyView.separator2"
229 242
               visible="true">
......
283 296
            id="eu.etaxonomy.taxeditor.navigation.key.polytomous.editNodes"
284 297
            name="Edit Polytomous Key Nodes">
285 298
      </command>
299
      <command
300
            defaultHandler="eu.etaxonomy.taxeditor.navigation.key.polytomous.handler.RefreshPolytomousKeyListHandler"
301
            id="eu.etaxonomy.taxeditor.navigation.key.polytomous.refreshKeyList"
302
            name="Refresh Polytomous Key List">
303
      </command>
304
      <command
305
            defaultHandler="eu.etaxonomy.taxeditor.navigation.key.polytomous.handler.RefreshPolytomousKeyNodesHandler"
306
            id="eu.etaxonomy.taxeditor.navigation.key.polytomous.refreshKeyNodes"
307
            name="Refresh Polytomous Key Nodes">
308
      </command>
286 309
   </extension>
287 310
   <extension
288 311
         point="org.eclipse.ui.handlers">
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/PolytomousKeyViewPart.java
262 262
		List<PolytomousKey> input = CdmStore.getService(IPolytomousKeyService.class).list(PolytomousKey.class, null, null, null, null);			
263 263
		viewer.setInput(input);
264 264
	}
265
	
266
	public List<PolytomousKey> getKeys() {
267
		return (List<PolytomousKey>)viewer.getInput();
268
	}
265 269

  
266 270
}
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/handler/RefreshPolytomousKeyListHandler.java
1
// $Id$
2
/**
3
* Copyright (C) 2007 EDIT
4
* European Distributed Institute of Taxonomy 
5
* http://www.e-taxonomy.eu
6
* 
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10

  
11
package eu.etaxonomy.taxeditor.navigation.key.polytomous.handler;
12

  
13
import org.eclipse.core.commands.AbstractHandler;
14
import org.eclipse.core.commands.ExecutionEvent;
15
import org.eclipse.core.commands.ExecutionException;
16
import org.eclipse.core.commands.IHandler;
17

  
18
import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
19
import eu.etaxonomy.taxeditor.navigation.key.polytomous.PolytomousKeyViewPart;
20

  
21

  
22
/**
23
 * <p>Handler class which Refreshes each key node in the polytomous key navigation view</p>
24
 *
25
 * @author c.mathew
26
 * @created Jan 17 2013
27
 * @version 1.0
28
 */
29
public class RefreshPolytomousKeyListHandler extends AbstractHandler implements IHandler {
30

  
31
    /* (non-Javadoc)
32
     * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
33
     */
34
    /** {@inheritDoc} */
35
    public Object execute(ExecutionEvent event) throws ExecutionException {
36
    	PolytomousKeyViewPart view = (PolytomousKeyViewPart) NavigationUtil.getView(PolytomousKeyViewPart.ID, false); 
37
    	view.refresh();
38
        return null;
39
    }
40
}
41

  
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/handler/RefreshPolytomousKeyNodesHandler.java
1
// $Id$
2
/**
3
* Copyright (C) 2007 EDIT
4
* European Distributed Institute of Taxonomy 
5
* http://www.e-taxonomy.eu
6
* 
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10

  
11
package eu.etaxonomy.taxeditor.navigation.key.polytomous.handler;
12

  
13
import java.util.List;
14

  
15
import org.eclipse.core.commands.AbstractHandler;
16
import org.eclipse.core.commands.ExecutionEvent;
17
import org.eclipse.core.commands.ExecutionException;
18
import org.eclipse.core.commands.IHandler;
19
import org.eclipse.core.commands.operations.IUndoContext;
20
import org.eclipse.core.runtime.IProgressMonitor;
21
import org.eclipse.core.runtime.IStatus;
22
import org.eclipse.core.runtime.Status;
23
import org.eclipse.core.runtime.jobs.Job;
24

  
25
import org.eclipse.swt.widgets.Display;
26

  
27

  
28
import eu.etaxonomy.cdm.model.description.PolytomousKey;
29
import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
30
import eu.etaxonomy.taxeditor.navigation.key.polytomous.PolytomousKeyViewPart;
31
import eu.etaxonomy.taxeditor.navigation.key.polytomous.operation.RefreshNodesOperation;
32
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
33

  
34

  
35
/**
36
 * <p>RefreshPolytomousKeyNodesHandler class, which refreshes each key node in the polytomous key navigation view</p>
37
 *
38
 * @author c.mathew
39
 * @created Jan 17 2013
40
 * @version 1.0
41
 */
42
public class RefreshPolytomousKeyNodesHandler extends AbstractHandler implements IHandler {
43

  
44
	@Override
45
	public Object execute(ExecutionEvent event) throws ExecutionException {
46
		final PolytomousKeyViewPart view = (PolytomousKeyViewPart) NavigationUtil.getView(PolytomousKeyViewPart.ID, false);
47
		final List<PolytomousKey> keys = view.getKeys();
48
		
49
		final String label = "Refresh Polytomous Key Nodes";
50
		
51
		final IUndoContext undoContext = NavigationUtil.getUndoContext();
52
		if (keys.size() > 0) {
53
			Job job = new Job("Refreshing Polytomous Key Nodes"){
54
													
55
					@Override
56
					protected IStatus run(IProgressMonitor monitor) {
57
						monitor.beginTask("Refreshing Polytomous Key Nodes", keys.size());
58
						
59
						
60
							for (final PolytomousKey key : keys) {					
61
								if(key.getRoot() != null) {
62

  
63
									Display.getDefault().asyncExec(new Runnable(){
64

  
65
										@Override
66
										public void run() {								    
67
											AbstractPostOperation operation = new RefreshNodesOperation(label, undoContext, key, view);
68
											NavigationUtil.executeOperation(operation);
69
										}
70

  
71
									});
72
									monitor.worked(1);
73
								}
74
							}
75
							monitor.done();
76
							return Status.OK_STATUS;
77
						}
78

  
79
					};
80

  
81
					job.setPriority(Job.SHORT);
82
					job.schedule();
83

  
84
				}
85
				return null;
86
			}
87
		}
88

  
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/operation/RefreshNodesOperation.java
1
package eu.etaxonomy.taxeditor.navigation.key.polytomous.operation;
2

  
3
import java.util.UUID;
4

  
5
import org.eclipse.core.commands.ExecutionException;
6
import org.eclipse.core.commands.operations.IUndoContext;
7
import org.eclipse.core.runtime.IAdaptable;
8
import org.eclipse.core.runtime.IProgressMonitor;
9
import org.eclipse.core.runtime.IStatus;
10

  
11
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
12
import eu.etaxonomy.cdm.api.service.IPolytomousKeyNodeService;
13
import eu.etaxonomy.cdm.api.service.IPolytomousKeyService;
14
import eu.etaxonomy.cdm.api.service.ITermService;
15
import eu.etaxonomy.cdm.model.description.PolytomousKey;
16
import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
17
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
18
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
19
import eu.etaxonomy.taxeditor.store.CdmStore;
20

  
21
/**
22
 * Operation responsible for refreshing key nodes node numbers of the Polytomous Keys.
23
 * The refresh is performed on all keys/
24
 * 
25
 * @author c.mathew
26
 * @created Jan 17 2013
27
 * @version 1.0
28
 *
29
 */
30
public class RefreshNodesOperation extends AbstractPostOperation {
31

  
32
	PolytomousKey key;	
33
	
34
	public RefreshNodesOperation(String label,
35
			IUndoContext undoContext, 
36
			PolytomousKey key, 
37
			IPostOperationEnabled postOperationEnabled) {
38
		super(label, undoContext, postOperationEnabled);
39
		this.key = key;
40
	}
41
	
42
	/* (non-Javadoc)
43
	 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
44
	 */
45
	@Override
46
	public IStatus execute(IProgressMonitor monitor, IAdaptable info)
47
			throws ExecutionException {
48
		UUID polytomousKeyNodeUuid = key.getRoot().getUuid();
49
		ConversationHolder conversation = CdmStore.createConversation();
50
		PolytomousKeyNode root = CdmStore.getService(IPolytomousKeyNodeService.class).load(polytomousKeyNodeUuid, null);
51
		root.refreshNodeNumbering();	
52
		CdmStore.getService(IPolytomousKeyNodeService.class).saveOrUpdate(root);
53
		conversation.commit(true);
54
		return postExecute(root);
55
	}
56

  
57
	/* (non-Javadoc)
58
	 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
59
	 */
60
	@Override
61
	public IStatus redo(IProgressMonitor monitor, IAdaptable info)
62
			throws ExecutionException {
63
		// TODO Auto-generated method stub
64
		return null;
65
	}
66

  
67
	/* (non-Javadoc)
68
	 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
69
	 */
70
	@Override
71
	public IStatus undo(IProgressMonitor monitor, IAdaptable info)
72
			throws ExecutionException {
73
		// TODO Auto-generated method stub
74
		return null;
75
	}
76

  
77
}

Also available in: Unified diff