Project

General

Profile

Download (1.63 KB) Statistics
| Branch: | Tag: | Revision:
1
package eu.etaxonomy.taxeditor.molecular.editor;
2

    
3

    
4
import org.eclipse.swt.widgets.Composite;
5
import org.eclipse.swt.widgets.Control;
6
import org.eclipse.swt.widgets.Event;
7
import org.eclipse.swt.widgets.Listener;
8
import org.eclipse.ui.PlatformUI;
9
import org.eclipse.ui.actions.ActionFactory;
10
import org.eclipse.ui.commands.ICommandService;
11

    
12
import eu.etaxonomy.taxeditor.molecular.handler.AbstractAlignmentEditorHandler;
13
import info.bioinfweb.libralign.alignmentarea.AlignmentArea;
14
import info.bioinfweb.libralign.alignmentarea.selection.SelectionChangeEvent;
15
import info.bioinfweb.libralign.alignmentarea.selection.SelectionListener;
16

    
17

    
18

    
19
/**
20
 * Listener used to update copy/paste events associated with {@link AlignmentEditor}.
21
 * 
22
 * @author Ben Stöver
23
 * @date 25.08.2015
24
 */
25
public class AlignmentEditorActionUpdater implements SelectionListener, Listener {
26
	private void updateEvents() {
27
        ((ICommandService)PlatformUI.getWorkbench().getService(ICommandService.class)).refreshElements(
28
                ActionFactory.COPY.getCommandId(), null);
29
	}
30
	
31
	
32
	@Override
33
	public void handleEvent(Event event) {
34
		AlignmentEditor editor = AbstractAlignmentEditorHandler.getActiveAlignmentEditor();
35
		if (editor != null) {
36
            updateEvents();
37
		}
38
	}
39

    
40
	
41
	@Override
42
	public void selectionChanged(SelectionChangeEvent e) {
43
		AlignmentEditor editor = AbstractAlignmentEditorHandler.getActiveAlignmentEditor();
44
		if (editor != null) {
45
			if ((e.getSource() == editor.getReadsArea().getSelection()) || 
46
					(e.getSource() == editor.getEditableConsensusArea().getSelection())) {
47
				
48
				updateEvents();
49
			}
50
		}
51
	}
52
}
(2-2/5)