package eu.etaxonomy.taxeditor.editor.handler;\r
\r
\r
-import java.net.URI;\r
+import info.bioinfweb.libralign.pherogram.model.PherogramComponentModel;\r
\r
import org.eclipse.core.commands.AbstractHandler;\r
import org.eclipse.core.commands.ExecutionEvent;\r
import org.eclipse.core.commands.ExecutionException;\r
import org.eclipse.jface.viewers.ISelection;\r
import org.eclipse.jface.viewers.TreeNode;\r
+import org.eclipse.ui.PartInitException;\r
import org.eclipse.ui.handlers.HandlerUtil;\r
\r
import eu.etaxonomy.cdm.model.media.MediaUtils;\r
import eu.etaxonomy.cdm.model.molecular.SingleRead;\r
import eu.etaxonomy.taxeditor.editor.EditorUtil;\r
+import eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor;\r
import eu.etaxonomy.taxeditor.editor.molecular.PherogramViewPart;\r
import eu.etaxonomy.taxeditor.model.MessagingUtils;\r
\r
\r
/**\r
* Displays an undistorted pherogram with {@link PherogramViewPart}.\r
- * \r
+ *\r
* @author Ben Stöver\r
*\r
*/\r
public class ShowPherogramHandler extends AbstractHandler {\r
- public static void showPherogram(URI uri) {\r
- try {\r
- PherogramViewPart.createView(uri);\r
- }\r
- catch (Exception e) {\r
- MessagingUtils.errorDialog("Error", null, e.getLocalizedMessage(), "eu.etaxonomy.taxeditor.editor", //TODO Is null a valid value here? \r
- e, false); //TODO set pluginID\r
- } \r
+ public static void showPherogram(PherogramComponentModel model) throws PartInitException {\r
+ PherogramViewPart.createView(model);\r
}\r
- \r
- \r
+\r
+\r
@Override\r
public Object execute(ExecutionEvent event) throws ExecutionException {\r
ISelection currentSelection = HandlerUtil.getCurrentSelection(event);\r
TreeNode treeNodeOfSelection = EditorUtil.getTreeNodeOfSelection(currentSelection);\r
if (treeNodeOfSelection != null && treeNodeOfSelection.getValue() instanceof SingleRead) {\r
- showPherogram(MediaUtils.getFirstMediaRepresentationPart(\r
- ((SingleRead)treeNodeOfSelection.getValue()).getPherogram()).getUri());\r
+// SingleRead singleRead = (SingleRead)treeNodeOfSelection.getValue();\r
+// singleRead.get\r
+ //TODO Can the parent node (containing the cut positions) be extracted from SingleRead?\r
+\r
+ try {\r
+ showPherogram(new PherogramComponentModel(AlignmentEditor.readPherogram(MediaUtils.getFirstMediaRepresentationPart(\r
+ ((SingleRead)treeNodeOfSelection.getValue()).getPherogram()).getUri())));\r
+ }\r
+ catch (Exception e) {\r
+ MessagingUtils.errorDialog("Error", null, e.getLocalizedMessage(), "eu.etaxonomy.taxeditor.editor", //TODO Is null a valid value here?\r
+ e, false); //TODO set pluginID\r
+ }\r
}\r
return null;\r
}\r
}
// Add pherogram area to GUI:
- pherogramArea.addMouseListener(new PherogramMouseListener(pherogramURI));
+ pherogramArea.addMouseListener(new PherogramMouseListener(pherogramArea));
getReadsArea().getDataAreas().getSequenceAreas(id).add(pherogramArea);
// Save source URI:
\r
import info.bioinfweb.commons.tic.input.TICMouseAdapter;\r
import info.bioinfweb.commons.tic.input.TICMouseEvent;\r
+import info.bioinfweb.libralign.dataarea.implementations.pherogram.PherogramArea;\r
\r
-import java.net.URI;\r
+import org.eclipse.ui.PartInitException;\r
\r
import eu.etaxonomy.taxeditor.editor.handler.ShowPherogramHandler;\r
+import eu.etaxonomy.taxeditor.model.MessagingUtils;\r
\r
\r
\r
* @date 25.11.2014\r
*/\r
public class PherogramMouseListener extends TICMouseAdapter {\r
- private final URI uri;\r
+ private final PherogramArea area;\r
\r
\r
- public PherogramMouseListener(URI uri) {\r
+ public PherogramMouseListener(PherogramArea area) {\r
super();\r
- this.uri = uri;\r
+ this.area = area;\r
}\r
\r
\r
@Override\r
public void mousePressed(TICMouseEvent event) {\r
if (event.getClickCount() == 2) { // Double click\r
- ShowPherogramHandler.showPherogram(uri);\r
+ try {\r
+ ShowPherogramHandler.showPherogram(area.getModel());\r
+ }\r
+ catch (PartInitException e) {\r
+ MessagingUtils.errorDialog("Unable to create pherogram view", null, e.getLocalizedMessage(),\r
+ "eu.etaxonomy.taxeditor.editor", e, false); //TODO set pluginID\r
+ }\r
}\r
}\r
}\r
\r
\r
import info.bioinfweb.libralign.pherogram.PherogramFormats.QualityOutputType;\r
-import info.bioinfweb.libralign.pherogram.model.PherogramAreaModel;\r
import info.bioinfweb.libralign.pherogram.model.PherogramComponentModel;\r
-import info.bioinfweb.libralign.pherogram.view.PherogramTraceCurveView;\r
import info.bioinfweb.libralign.pherogram.view.PherogramView;\r
\r
-import java.io.IOException;\r
-import java.net.MalformedURLException;\r
-import java.net.URI;\r
-\r
-import org.biojava.bio.chromatogram.UnsupportedChromatogramFormatException;\r
import org.eclipse.swt.SWT;\r
import org.eclipse.swt.widgets.Composite;\r
import org.eclipse.ui.PartInitException;\r
public class PherogramViewPart extends ViewPart {\r
public static final String ID = "eu.etaxonomy.taxeditor.editor.molecular.PherogramView";\r
\r
- private URI uri = null;\r
private PherogramView pherogramView = null;\r
\r
\r
- public static PherogramViewPart createView(URI uri) throws PartInitException, MalformedURLException,\r
- UnsupportedChromatogramFormatException, IOException {\r
-\r
- PherogramViewPart view = (PherogramViewPart)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(ID);\r
- view.setURI(uri);\r
- return view;\r
+ public static PherogramViewPart createView(PherogramComponentModel model) throws PartInitException {\r
+ PherogramViewPart view = (PherogramViewPart)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(ID);\r
+ view.getPherogramView().getTraceCurveView().setModel(model);\r
+ view.getPherogramView().assignSize();\r
+ return view;\r
}\r
\r
\r
}\r
\r
\r
- public URI getURI() {\r
- return uri;\r
- }\r
-\r
-\r
- protected void setURI(URI uri) throws MalformedURLException, IOException, UnsupportedChromatogramFormatException {\r
- this.uri = uri;\r
- PherogramTraceCurveView view = getPherogramView().getTraceCurveView();\r
- if ((view.getModel() == null) || (view.getModel() instanceof PherogramAreaModel)) { // Avoid changing the provider of a model that is used elsewhere\r
- view.setModel(new PherogramComponentModel(AlignmentEditor.readPherogram(uri)));\r
- }\r
- else {\r
- getPherogramView().getTraceCurveView().getModel().setProvider(AlignmentEditor.readPherogram(uri));\r
- }\r
- //TODO Refactor to use model from PherogramArea, if present, to have cut positions.\r
- getPherogramView().assignSize();\r
- }\r
-\r
-\r
@Override\r
public void createPartControl(Composite parent) {\r
getPherogramView().createSWTWidget(parent, SWT.NONE);\r