Revision 2d49766c
Added by Patrick Plitzner over 5 years ago
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/AggregateTaxonDescriptionsHandler.java | ||
---|---|---|
21 | 21 |
import eu.etaxonomy.taxeditor.operation.e4.RemotingCdmHandlerE4; |
22 | 22 |
|
23 | 23 |
public class AggregateTaxonDescriptionsHandler extends RemotingCdmHandlerE4 { |
24 |
private TaxonNavigatorE4 navigator; |
|
25 | 24 |
|
26 | 25 |
public AggregateTaxonDescriptionsHandler() { |
27 | 26 |
super("Aggregate taxon descriptions"); |
... | ... | |
59 | 58 |
} |
60 | 59 |
|
61 | 60 |
@CanExecute |
62 |
private boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection, MHandledMenuItem menuItem){ |
|
61 |
private boolean canExecute( |
|
62 |
@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection, |
|
63 |
@Named(IServiceConstants.ACTIVE_PART)MPart activePart, |
|
64 |
MHandledMenuItem menuItem){ |
|
63 | 65 |
boolean canExecute = false; |
64 |
canExecute = selection.getFirstElement() instanceof TaxonNodeDto |
|
66 |
canExecute = activePart.getObject() instanceof TaxonNavigatorE4 |
|
67 |
&& selection.getFirstElement() instanceof TaxonNodeDto |
|
65 | 68 |
&& ((TaxonNodeDto)selection.getFirstElement()).getTaxonUuid() != null; |
66 | 69 |
menuItem.setVisible(canExecute); |
67 | 70 |
return canExecute; |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/AggregateTaxonDescriptionsOperation.java | ||
---|---|---|
14 | 14 |
import org.eclipse.core.runtime.IProgressMonitor; |
15 | 15 |
import org.eclipse.swt.widgets.Display; |
16 | 16 |
|
17 |
import eu.etaxonomy.cdm.api.application.CdmApplicationState; |
|
17 | 18 |
import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action; |
18 |
import eu.etaxonomy.cdm.api.service.IDescriptionService;
|
|
19 |
import eu.etaxonomy.cdm.api.service.IProgressMonitorService;
|
|
19 | 20 |
import eu.etaxonomy.cdm.api.service.UpdateResult; |
20 | 21 |
import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor; |
21 | 22 |
import eu.etaxonomy.taxeditor.event.EventUtility; |
... | ... | |
24 | 25 |
import eu.etaxonomy.taxeditor.navigation.navigator.e4.TaxonNavigatorE4; |
25 | 26 |
import eu.etaxonomy.taxeditor.operation.IPostMoniteredOperationEnabled; |
26 | 27 |
import eu.etaxonomy.taxeditor.operation.RemotingCdmUpdateOperation; |
27 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
28 | 28 |
|
29 | 29 |
/** |
30 | 30 |
* |
... | ... | |
34 | 34 |
*/ |
35 | 35 |
public class AggregateTaxonDescriptionsOperation extends RemotingCdmUpdateOperation implements IPostMoniteredOperationEnabled { |
36 | 36 |
|
37 |
private TaxonNavigatorE4 taxonNavigator; |
|
38 | 37 |
private UUID nodeUuid; |
38 |
private UUID monitorUuid; |
|
39 | 39 |
|
40 | 40 |
public AggregateTaxonDescriptionsOperation(Object source, |
41 | 41 |
boolean async, |
... | ... | |
52 | 52 |
} |
53 | 53 |
|
54 | 54 |
public void runMoniteredOperation() { |
55 |
UUID uuid = CdmStore.getService(IDescriptionService.class).aggregateComputedTaxonDescriptions(nodeUuid); |
|
56 |
|
|
57 |
Display.getDefault().asyncExec(new Runnable() { |
|
58 |
@Override |
|
59 |
public void run() { |
|
60 |
AbstractUtility.executeMoniteredOperation("Aggregate taxon descriptions: ", |
|
61 |
uuid, |
|
62 |
500, |
|
63 |
false, |
|
64 |
AggregateTaxonDescriptionsOperation.this, |
|
65 |
null, |
|
66 |
true); |
|
67 |
} |
|
68 |
}); |
|
55 |
monitorUuid = CdmApplicationState.getLongRunningTasksService().aggregateComputedTaxonDescriptions(nodeUuid); |
|
69 | 56 |
|
57 |
Display.getDefault().asyncExec(new Runnable() { |
|
58 |
@Override |
|
59 |
public void run() { |
|
60 |
AbstractUtility.executeMoniteredOperation("Move Taxon to new parent: ", |
|
61 |
monitorUuid, |
|
62 |
500, |
|
63 |
false, |
|
64 |
AggregateTaxonDescriptionsOperation.this, |
|
65 |
null, |
|
66 |
true); |
|
67 |
} |
|
68 |
}); |
|
70 | 69 |
|
71 | 70 |
} |
72 | 71 |
|
... | ... | |
74 | 73 |
public void postOperation(IRemotingProgressMonitor monitor) { |
75 | 74 |
monitor.done(); |
76 | 75 |
EventUtility.postEvent(WorkbenchEventConstants.REFRESH_NAVIGATOR, true); |
77 |
|
|
78 | 76 |
} |
79 | 77 |
|
80 | 78 |
} |
Also available in: Unified diff
ref #7597 Use LongRunningTaskService for taxon aggregation