Revision 20d52c89
Added by Andreas Müller over 1 year ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/AbstractCdmEditorPart.java | ||
---|---|---|
82 | 82 |
private Object selection; |
83 | 83 |
private MPart activePart; |
84 | 84 |
private MPart thisPart; |
85 |
private EPartService partService; |
|
85 | 86 |
|
86 |
public DelaySelection(Object selection, MPart activePart, MPart thisPart) { |
|
87 |
public DelaySelection(Object selection, MPart activePart, MPart thisPart, EPartService partService) {
|
|
87 | 88 |
this.selection = selection; |
88 | 89 |
this.activePart= activePart; |
89 | 90 |
this.thisPart = thisPart; |
91 |
this.partService = partService; |
|
90 | 92 |
} |
91 | 93 |
|
92 | 94 |
@Override |
93 | 95 |
public void run() { |
96 |
//multiple selections are not supported |
|
97 |
if(activePart != null |
|
98 |
&& thisPart != null |
|
99 |
&& !activePart.equals(thisPart) |
|
100 |
&& selection instanceof IStructuredSelection |
|
101 |
&& ((IStructuredSelection) selection).size()>1){ |
|
102 |
showEmptyPage(); |
|
103 |
return; |
|
104 |
} |
|
105 |
|
|
106 |
// no active editor found |
|
107 |
if(activePart == thisPart && WorkbenchUtility.getActiveEditorPart(partService) == null && showEmptyIfNoActiveEditor()){ |
|
108 |
showEmptyPage(); |
|
109 |
return; |
|
110 |
} |
|
111 |
|
|
112 |
if (viewer != null && viewer.getControl()!= null && viewer.getInput() != null && !viewer.getControl().isDisposed()){ |
|
113 |
try{ |
|
114 |
viewer.getControl().setEnabled(isEnabled); |
|
115 |
}catch(SWTException e){ |
|
116 |
System.out.println("...exception3 ("+ (thisPart == null? "":thisPart.getLabel()) + ")"); |
|
117 |
logger.debug("Something went wrong for viewer.getControl().setEnabled(true) in " + this.getClass().getSimpleName(), e); |
|
118 |
} |
|
119 |
} |
|
94 | 120 |
|
95 | 121 |
//same as previous selection? => return |
96 | 122 |
if((previousSelection != null && selection != null) |
... | ... | |
126 | 152 |
public synchronized void setThisPart(MPart thisPart) { |
127 | 153 |
this.thisPart = thisPart; |
128 | 154 |
} |
155 |
|
|
156 |
public synchronized void setThisPartService(EPartService partService) { |
|
157 |
this.partService = partService; |
|
158 |
} |
|
129 | 159 |
} |
130 | 160 |
|
131 | 161 |
protected Viewer viewer; |
... | ... | |
160 | 190 |
@Optional@Named(IServiceConstants.ACTIVE_PART)MPart activePart, |
161 | 191 |
MPart thisPart, UISynchronize sync, EPartService partService){ |
162 | 192 |
|
163 |
//multiple selections are not supported |
|
164 |
if(activePart != null |
|
165 |
&& thisPart != null |
|
166 |
&& !activePart.equals(thisPart) |
|
167 |
&& selection instanceof IStructuredSelection |
|
168 |
&& ((IStructuredSelection) selection).size()>1){ |
|
169 |
showEmptyPage(); |
|
170 |
return; |
|
171 |
} |
|
172 |
|
|
173 |
// no active editor found |
|
174 |
if(activePart == thisPart && WorkbenchUtility.getActiveEditorPart(partService) == null && showEmptyIfNoActiveEditor()){ |
|
175 |
showEmptyPage(); |
|
176 |
return; |
|
177 |
} |
|
178 |
|
|
179 |
if (viewer != null && viewer.getControl()!= null && viewer.getInput() != null && !viewer.getControl().isDisposed()){ |
|
180 |
try{ |
|
181 |
viewer.getControl().setEnabled(isEnabled); |
|
182 |
}catch(SWTException e){ |
|
183 |
logger.debug("Something went wrong for viewer.getControl().setEnabled(true) in " + this.getClass().getSimpleName(), e); |
|
184 |
} |
|
185 |
} |
|
186 |
|
|
187 | 193 |
//set the delay selection which puts the change handling to the end |
188 | 194 |
if(delaySelection == null){ |
189 |
delaySelection = new DelaySelection(selection, activePart, thisPart); |
|
195 |
delaySelection = new DelaySelection(selection, activePart, thisPart, partService);
|
|
190 | 196 |
}else{ |
191 | 197 |
delaySelection.setSelection(selection); |
192 | 198 |
delaySelection.setActivePart(activePart); |
193 | 199 |
delaySelection.setThisPart(thisPart); |
200 |
delaySelection.setThisPartService(partService); |
|
194 | 201 |
} |
195 | 202 |
|
196 | 203 |
//as long as the delay thread is running, |
Also available in: Unified diff
ref #10186 fix incorrect delaySelection handling for multiselect and no active Editor