Revision 939829bc
Added by Patrick Plitzner about 7 years ago
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/PolytomousKeyViewPartDataChangeBehavior.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2007 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
... | ... | |
21 | 21 |
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeEvent.EventType; |
22 | 22 |
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap; |
23 | 23 |
import eu.etaxonomy.taxeditor.model.AbstractDataChangeBehaviour; |
24 |
import eu.etaxonomy.taxeditor.navigation.l10n.Messages; |
|
24 | 25 |
|
25 | 26 |
/** |
26 | 27 |
* @author n.hoffmann |
... | ... | |
30 | 31 |
public class PolytomousKeyViewPartDataChangeBehavior extends |
31 | 32 |
AbstractDataChangeBehaviour { |
32 | 33 |
|
33 |
private final PolytomousKeyViewPart source; |
|
34 |
private static final String UPDATING_POLYTOMOUS_KEY_VIEWER = Messages.PolytomousKeyViewPartDataChangeBehavior_UPDATE; |
|
35 |
private final PolytomousKeyViewPart source; |
|
34 | 36 |
|
35 | 37 |
/** |
36 | 38 |
* @param polytomousKeyViewPart |
... | ... | |
47 | 49 |
public void reactOnDataChange(CdmDataChangeMap changeEvents) { |
48 | 50 |
if(isRelevant(changeEvents)){ |
49 | 51 |
final Display display = Display.getCurrent(); |
50 |
Job job = new Job("Updating Polytomous Key Viewer") {
|
|
51 |
|
|
52 |
Job job = new Job(UPDATING_POLYTOMOUS_KEY_VIEWER) {
|
|
53 |
|
|
52 | 54 |
@Override |
53 | 55 |
protected IStatus run(IProgressMonitor monitor) { |
54 |
monitor.beginTask("Updating Polytomous Key Viewer", 3);
|
|
56 |
monitor.beginTask(UPDATING_POLYTOMOUS_KEY_VIEWER, 3);
|
|
55 | 57 |
monitor.worked(1); |
56 |
|
|
58 |
|
|
57 | 59 |
// clear the session completely |
58 |
monitor.subTask("Clearing Polytomous Key Viewer session");
|
|
60 |
monitor.subTask(Messages.PolytomousKeyViewPartDataChangeBehavior_CLEAR);
|
|
59 | 61 |
display.asyncExec(new Runnable() { |
60 |
public void run() { |
|
62 |
@Override |
|
63 |
public void run() { |
|
61 | 64 |
source.getConversationHolder().clear(); |
62 | 65 |
} |
63 |
});
|
|
64 |
// FIXME completely clearing the session is a brute force approach.
|
|
66 |
}); |
|
67 |
// FIXME completely clearing the session is a brute force approach. |
|
65 | 68 |
// It would be much more elegant to clear only those elements that have been changed. |
66 | 69 |
// I could not get that to work but we should consider workin on this because we might |
67 | 70 |
// run into serious performance issues, especially when it comes to large trees |
... | ... | |
69 | 72 |
// at least, we moved this to a job so it can run in a background thred |
70 | 73 |
// seems to improve the situation but not sure if final solution |
71 | 74 |
monitor.worked(1); |
72 |
|
|
73 |
monitor.subTask("Refreshing viewer");
|
|
74 |
|
|
75 |
|
|
76 |
monitor.subTask(Messages.PolytomousKeyViewPartDataChangeBehavior_REFRESH);
|
|
77 |
|
|
75 | 78 |
display.asyncExec(new Runnable() { |
76 |
public void run() { |
|
79 |
@Override |
|
80 |
public void run() { |
|
77 | 81 |
source.refresh(); |
78 | 82 |
} |
79 | 83 |
}); |
80 |
|
|
81 |
|
|
82 |
|
|
84 |
|
|
85 |
|
|
86 |
|
|
83 | 87 |
monitor.worked(1); |
84 | 88 |
monitor.done(); |
85 | 89 |
return Status.OK_STATUS; |
86 | 90 |
} |
87 | 91 |
}; |
88 |
|
|
92 |
|
|
89 | 93 |
job.setPriority(Job.SHORT); |
90 | 94 |
job.schedule(); |
91 |
|
|
95 |
|
|
92 | 96 |
} |
93 | 97 |
} |
94 |
|
|
98 |
|
|
95 | 99 |
/** |
96 | 100 |
* @return |
97 | 101 |
*/ |
... | ... | |
99 | 103 |
for(CdmDataChangeEvent event : changeEvents.getAllEvents()){ |
100 | 104 |
EventType eventType = event.getEventType(); |
101 | 105 |
CdmBase eventEntity = event.getEntity(); |
102 |
|
|
106 |
|
|
103 | 107 |
// all poyltomous key changes are relevant |
104 |
if((eventType == EventType.INSERT || eventType == EventType.DELETE || eventType == EventType.UPDATE)
|
|
108 |
if((eventType == EventType.INSERT || eventType == EventType.DELETE || eventType == EventType.UPDATE) |
|
105 | 109 |
&& eventEntity instanceof PolytomousKey){ |
106 | 110 |
return true; |
107 | 111 |
} |
Also available in: Unified diff
ref #4611 i18n for taxeditor.navigator plugin