adapting to chages in CdmUtils
[taxeditor.git] / eu.etaxonomy.taxeditor.molecular / src / main / java / eu / etaxonomy / taxeditor / molecular / handler / AbstractPherogramComponentHandler.java
1 /**
2 * Copyright (C) 2015 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9 package eu.etaxonomy.taxeditor.molecular.handler;
10
11
12 import info.bioinfweb.libralign.alignmentarea.AlignmentArea;
13 import info.bioinfweb.libralign.dataarea.implementations.pherogram.PherogramArea;
14 import info.bioinfweb.libralign.pherogram.PherogramComponent;
15
16 import java.util.Iterator;
17
18 import org.eclipse.core.commands.AbstractHandler;
19 import org.eclipse.core.commands.ExecutionEvent;
20 import org.eclipse.core.commands.ExecutionException;
21 import org.eclipse.ui.IWorkbenchPart;
22
23 import eu.etaxonomy.taxeditor.model.AbstractUtility;
24 import eu.etaxonomy.taxeditor.molecular.editor.AlignmentEditor;
25 import eu.etaxonomy.taxeditor.molecular.editor.PherogramViewPart;
26
27
28
29 /**
30 * Abstract handler implementation allows to performs the concrete operation either on an instance of
31 * {@link PherogramViewPart} or all {@link AlignmentArea}s inside an instance of {@link AlignmentEditor}.
32 *
33 * @author Ben Stöver
34 * @date 23.06.2015
35 */
36 public abstract class AbstractPherogramComponentHandler extends AbstractHandler {
37 @Override
38 public Object execute(ExecutionEvent event) throws ExecutionException {
39 IWorkbenchPart activePart = AbstractUtility.getActivePart();
40
41 if (activePart instanceof AlignmentEditor) {
42 AlignmentEditor editor = (AlignmentEditor)activePart;
43 Iterator<String> idIterator = editor.getReadsArea().getAlignmentModel().sequenceIDIterator();
44 while (idIterator.hasNext()) {
45 PherogramArea area = editor.getPherogramArea(idIterator.next());
46 if (area != null) {
47 doExecute(event, area);
48 }
49 }
50 }
51 else if (activePart instanceof PherogramViewPart) {
52 doExecute(event, ((PherogramViewPart)activePart).getPherogramView().getTraceCurveView());
53 }
54 return null;
55 }
56
57
58 public abstract void doExecute(ExecutionEvent event, PherogramComponent component) throws ExecutionException;
59 }