Revision 479060ec
Added by Ben Stöver over 8 years ago
eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/editor/AlignmentEditor.java | ||
---|---|---|
128 | 128 |
setDirty(); |
129 | 129 |
} |
130 | 130 |
}; |
131 |
private final AlignmentEditorActionUpdater ACTION_UPDATER = new AlignmentEditorActionUpdater(); |
|
131 | 132 |
|
132 | 133 |
|
133 | 134 |
private MultipleAlignmentsContainer alignmentsContainer = null; |
... | ... | |
207 | 208 |
private MultipleAlignmentsContainer getAlignmentsContainer() { |
208 | 209 |
if (alignmentsContainer == null) { |
209 | 210 |
alignmentsContainer = new MultipleAlignmentsContainer(); |
210 |
|
|
211 |
|
|
211 | 212 |
AlignmentAreaList list = alignmentsContainer.getAlignmentAreas(); |
212 | 213 |
AlignmentArea readsArea = createEditableAlignmentArea(alignmentsContainer, true); |
214 |
readsArea.getSelection().addSelectionListener(ACTION_UPDATER); |
|
213 | 215 |
list.add(createIndexArea(alignmentsContainer, readsArea)); |
214 | 216 |
list.add(readsArea); // Make sure READS_AREA_INDEX is correct. |
215 |
list.add(createEditableAlignmentArea(alignmentsContainer, false)); // Make sure COMSENSUS_AREA_INDEX is correct. |
|
217 |
AlignmentArea editableConsensusArea = createEditableAlignmentArea(alignmentsContainer, false); |
|
218 |
editableConsensusArea.getSelection().addSelectionListener(ACTION_UPDATER); |
|
219 |
list.add(editableConsensusArea); // Make sure COMSENSUS_AREA_INDEX is correct. |
|
216 | 220 |
list.add(createConsensusHintArea(alignmentsContainer, readsArea)); |
217 |
|
|
221 |
|
|
218 | 222 |
registerEditSettingListener(alignmentsContainer); |
219 | 223 |
} |
220 | 224 |
return alignmentsContainer; |
... | ... | |
264 | 268 |
* @return {@code true} if the specified component is focused and is either equal to |
265 | 269 |
* {@link #getReadsArea()} or {@link #getEditableConsensusArea()}or {@code false} otherwise |
266 | 270 |
*/ |
267 |
public boolean hasFocus(AlignmentArea area) { |
|
268 |
Composite areaComponent = (Composite)area.getToolkitComponent(); |
|
269 |
Control control = Display.getCurrent().getFocusControl(); |
|
270 |
while ((control != areaComponent) && (control != null)) { |
|
271 |
control = control.getParent(); |
|
271 |
private boolean hasFocus(AlignmentArea area) { |
|
272 |
return childHasFocus((Composite)area.getToolkitComponent()); |
|
273 |
} |
|
274 |
|
|
275 |
|
|
276 |
public static boolean childHasFocus(Composite parent) { //TODO Move to bioinfweb.commons.swt |
|
277 |
return isChildComponent(parent, Display.getCurrent().getFocusControl()); |
|
278 |
} |
|
279 |
|
|
280 |
|
|
281 |
public static boolean isChildComponent(Composite parent, Control child) { //TODO Move to bioinfweb.commons.swt |
|
282 |
while ((child != parent) && (child != null)) { |
|
283 |
child = child.getParent(); |
|
272 | 284 |
} |
273 |
return (control == areaComponent);
|
|
285 |
return (child == parent);
|
|
274 | 286 |
} |
275 | 287 |
|
276 | 288 |
|
... | ... | |
359 | 371 |
@Override |
360 | 372 |
public void createPartControl(Composite parent) { |
361 | 373 |
SWTComponentFactory.getInstance().getSWTComponent(getAlignmentsContainer(), parent, SWT.NONE); |
374 |
Display.getCurrent().addFilter(SWT.FocusIn, ACTION_UPDATER); |
|
375 |
Display.getCurrent().addFilter(SWT.FocusOut, ACTION_UPDATER); |
|
362 | 376 |
updateStatusBar(); |
363 | 377 |
|
364 | 378 |
if (getEditorInput() instanceof AlignmentEditorInput) { |
... | ... | |
381 | 395 |
} |
382 | 396 |
|
383 | 397 |
|
384 |
private void updateStatusBar() { |
|
398 |
@Override |
|
399 |
public void dispose() { |
|
400 |
Display.getCurrent().removeFilter(SWT.FocusIn, ACTION_UPDATER); |
|
401 |
Display.getCurrent().removeFilter(SWT.FocusOut, ACTION_UPDATER); |
|
402 |
super.dispose(); |
|
403 |
} |
|
404 |
|
|
405 |
|
|
406 |
private void updateStatusBar() { |
|
385 | 407 |
IActionBars bars = getEditorSite().getActionBars(); |
386 | 408 |
bars.getStatusLineManager().setMessage("Edit mode: " + |
387 | 409 |
(getReadsArea().getEditSettings().isInsert() ? "Insert" : "Overwrite") + " " + |
Also available in: Unified diff
AlignmentEditorCopyHandler now sets current action status.