Project

General

Profile

Download (2.23 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2015 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10
package eu.etaxonomy.taxeditor.molecular.handler;
11

    
12

    
13
import info.bioinfweb.libralign.alignmentarea.AlignmentArea;
14
import info.bioinfweb.libralign.dataarea.implementations.pherogram.PherogramArea;
15
import info.bioinfweb.libralign.pherogram.PherogramComponent;
16

    
17
import java.util.Iterator;
18

    
19
import org.eclipse.core.commands.AbstractHandler;
20
import org.eclipse.core.commands.ExecutionEvent;
21
import org.eclipse.core.commands.ExecutionException;
22
import org.eclipse.ui.IWorkbenchPart;
23

    
24
import eu.etaxonomy.taxeditor.model.AbstractUtility;
25
import eu.etaxonomy.taxeditor.molecular.editor.AlignmentEditor;
26
import eu.etaxonomy.taxeditor.molecular.editor.PherogramViewPart;
27

    
28

    
29

    
30
/**
31
 * Abstract handler implementation allows to performs the concrete operation either on an instance of
32
 * {@link PherogramViewPart} or all {@link AlignmentArea}s inside an instance of {@link AlignmentEditor}.
33
 *
34
 * @author Ben Stöver
35
 * @date 23.06.2015
36
 */
37
public abstract class AbstractPherogramComponentHandler extends AbstractHandler {
38
    @Override
39
    public Object execute(ExecutionEvent event) throws ExecutionException {
40
        IWorkbenchPart activePart = AbstractUtility.getActivePart();
41

    
42
        if (activePart instanceof AlignmentEditor) {
43
            AlignmentEditor editor = (AlignmentEditor)activePart;
44
            Iterator<Integer> idIterator = editor.getReadsArea().getAlignmentModel().sequenceIDIterator();
45
            while (idIterator.hasNext()) {
46
                PherogramArea area = editor.getPherogramArea(idIterator.next());
47
                if (area != null) {
48
                    doExecute(event, area);
49
                }
50
            }
51
        }
52
        else if (activePart instanceof PherogramViewPart) {
53
            doExecute(event, ((PherogramViewPart)activePart).getPherogramView().getTraceCurveView());
54
        }
55
        return null;
56
    }
57

    
58

    
59
    public abstract void doExecute(ExecutionEvent event, PherogramComponent component) throws ExecutionException;
60
}
(2-2/18)