Project

General

Profile

« Previous | Next » 

Revision 960d1a20

Added by Patrick Plitzner over 6 years ago

ref #6902 migrate alignment editor and pherogram view

View differences:

eu.etaxonomy.taxeditor.molecular/META-INF/MANIFEST.MF
19 19
 org.eclipse.core.databinding.property;bundle-version="1.4.0",
20 20
 org.eclipse.e4.core.di.annotations,
21 21
 org.eclipse.e4.ui.services,
22
 org.eclipse.e4.ui.model.workbench
22
 org.eclipse.e4.ui.model.workbench,
23
 org.eclipse.e4.ui.workbench,
24
 org.eclipse.e4.ui.di
23 25
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
24 26
Bundle-ActivationPolicy: lazy
25 27
Bundle-Vendor: EDIT
eu.etaxonomy.taxeditor.molecular/fragment.e4xmi
1 1
<?xml version="1.0" encoding="ASCII"?>
2
<fragment:ModelFragments xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:commands="http://www.eclipse.org/ui/2010/UIModel/application/commands" xmlns:fragment="http://www.eclipse.org/ui/2010/UIModel/fragment" xmlns:menu="http://www.eclipse.org/ui/2010/UIModel/application/ui/menu" xmi:id="_OhwnQCTfEeeiN5lBIuqN3g">
2
<fragment:ModelFragments xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:basic="http://www.eclipse.org/ui/2010/UIModel/application/descriptor/basic" xmlns:commands="http://www.eclipse.org/ui/2010/UIModel/application/commands" xmlns:fragment="http://www.eclipse.org/ui/2010/UIModel/fragment" xmlns:menu="http://www.eclipse.org/ui/2010/UIModel/application/ui/menu" xmlns:ui="http://www.eclipse.org/ui/2010/UIModel/application/ui" xmi:id="_OhwnQCTfEeeiN5lBIuqN3g">
3
  <imports xsi:type="commands:Command" xmi:id="_q2vnsKUDEeejf7ggYkp-TA" elementId="org.eclipse.ui.edit.copy"/>
4
  <imports xsi:type="commands:Command" xmi:id="_rlhZQKUDEeejf7ggYkp-TA" elementId="org.eclipse.ui.edit.cut"/>
5
  <imports xsi:type="commands:Command" xmi:id="_tLkxEKUDEeejf7ggYkp-TA" elementId="org.eclipse.ui.edit.paste"/>
3 6
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="__mwtMDVpEee_b7RlBzTDRw" featurename="commands" parentElementId="xpath:/">
4 7
    <elements xsi:type="commands:Command" xmi:id="_JZdQ0H2sEeeVL5aZ55YsWA" elementId="eu.etaxonomy.taxeditor.molecular.editSequence" commandName="%command.EDIT_SEQUENCE"/>
5 8
    <elements xsi:type="commands:Command" xmi:id="_IXQocH22EeeVL5aZ55YsWA" elementId="eu.etaxonomy.taxeditor.molecular.exportSequenceToFile" commandName="%command.label.EXPORT_SEQUENCE_TO_FILE"/>
6 9
    <elements xsi:type="commands:Command" xmi:id="_m9gZAH22EeeVL5aZ55YsWA" elementId="eu.etaxonomy.taxeditor.molecular.showPherogram" commandName="%command.name.SHOW_PHEROGRAM"/>
10
    <elements xsi:type="commands:Command" xmi:id="_YLPrgKT7Eeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.molecular.AlignmentEditor.cutPherogramLeft" commandName="%command.name.CUT_PHEROGRAM_LEFT"/>
11
    <elements xsi:type="commands:Command" xmi:id="_akezwKT7Eeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.molecular.AlignmentEditor.cutPherogramRight" commandName="%command.name.CUT_PHEROGRAM_RIGHT"/>
12
    <elements xsi:type="commands:Command" xmi:id="_cnIoAKT7Eeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.molecular.AlignmentEditor.reverseComplementRows" commandName="%command.name.REVERSE_COMPLEMENT_SELECTED_ROWS"/>
13
    <elements xsi:type="commands:Command" xmi:id="_d28DAKT7Eeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.molecular.AlignmentEditor.createConsensus" commandName="%command.name.CREATE_CONSENUS_SEQUENCE"/>
14
    <elements xsi:type="commands:Command" xmi:id="_gnsTYKT7Eeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.molecular.AlignmentEditor.updateConsensus" commandName="%command.name.UPDATE_CONSENSUS_SEQUENCE"/>
15
    <elements xsi:type="commands:Command" xmi:id="_h1lC0KT7Eeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.molecular.pherogramComponent.toggleShowProbabilities" commandName="%command.name.TOGGLE_SHOW_PROBABILITY_VALUES"/>
16
    <elements xsi:type="commands:Command" xmi:id="_j-w84KT7Eeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.molecular.pherogramComponent.toggleShowBaseCallLines" commandName="%command.name.TOGGLE_SHOW_BASE_CALL_LINES"/>
17
    <elements xsi:type="commands:Command" xmi:id="_lyJmEKT7Eeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.molecular.pherogramComponent.changeQualityOutput" commandName="%command.name.CHANGE_QUALITY_OUTPUT"/>
18
    <elements xsi:type="commands:Command" xmi:id="_ncVP8KT7Eeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.molecular.AlignmentEditor.loadPherogram" commandName="%command.name.LOAD_PHEROGRAM"/>
19
    <elements xsi:type="commands:Command" xmi:id="_pfKDUKT7Eeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.molecular.AlignmentEditor.toggleInsertOverwrite" commandName="%command.name.TOGGLE_INSERT_OVERWRITE"/>
20
    <elements xsi:type="commands:Command" xmi:id="_rz8wcKT7Eeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.molecular.AlignmentEditor.toggleLeftRightInsertion" commandName="%command.name.TOGGLE_LEFT_RIGHT_INSERTION"/>
7 21
  </fragments>
8 22
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_RCmzgH2sEeeVL5aZ55YsWA" featurename="handlers" parentElementId="eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView">
9
    <elements xsi:type="commands:Handler" xmi:id="_XuBioH2sEeeVL5aZ55YsWA" elementId="eu.etaxonomy.taxeditor.molecular.handler.EditSequenceHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.molecular/eu.etaxonomy.taxeditor.molecular.handler.EditSequenceHandler" command="_JZdQ0H2sEeeVL5aZ55YsWA"/>
10
    <elements xsi:type="commands:Handler" xmi:id="_QwuNwH22EeeVL5aZ55YsWA" elementId="eu.etaxonomy.taxeditor.molecular.handler.ExportSequenceToFileHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.molecular/eu.etaxonomy.taxeditor.molecular.handler.ExportSequenceToFileHandler" command="_IXQocH22EeeVL5aZ55YsWA"/>
11
    <elements xsi:type="commands:Handler" xmi:id="_reIrkH22EeeVL5aZ55YsWA" elementId="eu.etaxonomy.taxeditor.molecular.handler.ShowPherogramHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.molecular/eu.etaxonomy.taxeditor.molecular.handler.ShowPherogramHandler" command="_m9gZAH22EeeVL5aZ55YsWA"/>
23
    <elements xsi:type="commands:Handler" xmi:id="_XuBioH2sEeeVL5aZ55YsWA" elementId="eu.etaxonomy.taxeditor.molecular.editor.e4.handler.EditSequenceHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.molecular/eu.etaxonomy.taxeditor.molecular.editor.e4.handler.EditSequenceHandlerE4" command="_JZdQ0H2sEeeVL5aZ55YsWA"/>
24
    <elements xsi:type="commands:Handler" xmi:id="_QwuNwH22EeeVL5aZ55YsWA" elementId="eu.etaxonomy.taxeditor.molecular.editor.e4.handler.ExportSequenceToFileHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.molecular/eu.etaxonomy.taxeditor.molecular.editor.e4.handler.ExportSequenceToFileHandlerE4" command="_IXQocH22EeeVL5aZ55YsWA"/>
25
    <elements xsi:type="commands:Handler" xmi:id="_reIrkH22EeeVL5aZ55YsWA" elementId="eu.etaxonomy.taxeditor.molecular.editor.e4.handler.ShowPherogramHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.molecular/eu.etaxonomy.taxeditor.molecular.editor.e4.handler.ShowPherogramHandlerE4" command="_m9gZAH22EeeVL5aZ55YsWA"/>
12 26
  </fragments>
13 27
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_o08AQH2sEeeVL5aZ55YsWA" featurename="children" parentElementId="eu.etaxonomy.taxeditor.editor.popupmenu.specimeneditor" positionInList="before:eu.etaxonomy.taxeditor.editor.menuseparator.beforeDelete">
14 28
    <elements xsi:type="menu:HandledMenuItem" xmi:id="_txARoH2sEeeVL5aZ55YsWA" elementId="eu.etaxonomy.taxeditor.molecular.handledmenuitem.commandlabeledit_sequence" label="%command.label.EDIT_SEQUENCE" command="_JZdQ0H2sEeeVL5aZ55YsWA"/>
15 29
    <elements xsi:type="menu:HandledMenuItem" xmi:id="_VRC-UH22EeeVL5aZ55YsWA" elementId="eu.etaxonomy.taxeditor.molecular.handledmenuitem.commandlabelexport_sequence_to_file" label="%command.label.EXPORT_SEQUENCE_TO_FILE" command="_IXQocH22EeeVL5aZ55YsWA"/>
16 30
    <elements xsi:type="menu:HandledMenuItem" xmi:id="_xftzgH22EeeVL5aZ55YsWA" elementId="eu.etaxonomy.taxeditor.molecular.handledmenuitem.commandnameshow_pherogram" label="%command.name.SHOW_PHEROGRAM" command="_m9gZAH22EeeVL5aZ55YsWA"/>
17 31
  </fragments>
32
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_paaYIKT5Eeejf7ggYkp-TA" featurename="descriptors" parentElementId="org.eclipse.e4.legacy.ide.application">
33
    <elements xsi:type="basic:PartDescriptor" xmi:id="_sAK5cKT5Eeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.molecular.editor.e4.AlignmentEditorE4" label="%editor.ALIGNMENT_EDITOR" closeable="true" dirtyable="true" contributionURI="bundleclass://eu.etaxonomy.taxeditor.molecular/eu.etaxonomy.taxeditor.molecular.editor.e4.AlignmentEditorE4">
34
      <handlers xmi:id="_8S4OwKUAEeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.molecular.editor.e4.handler.UpdateConsensusSequenceHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.molecular/eu.etaxonomy.taxeditor.molecular.editor.e4.handler.UpdateConsensusSequenceHandlerE4" command="_gnsTYKT7Eeejf7ggYkp-TA"/>
35
      <handlers xmi:id="__mR5MKUAEeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.molecular.editor.e4.handler.CreateConsensusSequenceHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.molecular/eu.etaxonomy.taxeditor.molecular.editor.e4.handler.CreateConsensusSequenceHandlerE4" command="_d28DAKT7Eeejf7ggYkp-TA"/>
36
      <handlers xmi:id="_DD3aYKUBEeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.molecular.editor.e4.handler.ReverseComplementHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.molecular/eu.etaxonomy.taxeditor.molecular.editor.e4.handler.ReverseComplementHandlerE4" command="_cnIoAKT7Eeejf7ggYkp-TA"/>
37
      <handlers xmi:id="_FoONgKUBEeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.molecular.editor.e4.handler.CutPherogramRightHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.molecular/eu.etaxonomy.taxeditor.molecular.editor.e4.handler.CutPherogramRightHandlerE4" command="_akezwKT7Eeejf7ggYkp-TA"/>
38
      <handlers xmi:id="_I78oEKUBEeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.molecular.editor.e4.handler.CutPherogramLeftHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.molecular/eu.etaxonomy.taxeditor.molecular.editor.e4.handler.CutPherogramLeftHandlerE4" command="_YLPrgKT7Eeejf7ggYkp-TA"/>
39
      <handlers xmi:id="_NLSWUKUBEeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.molecular.editor.e4.handler.ToggleLeftRightInsertionHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.molecular/eu.etaxonomy.taxeditor.molecular.editor.e4.handler.ToggleLeftRightInsertionHandlerE4" command="_rz8wcKT7Eeejf7ggYkp-TA"/>
40
      <handlers xmi:id="_WV0zQKUBEeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.molecular.editor.e4.handler.ToggleInsertOverwriteHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.molecular/eu.etaxonomy.taxeditor.molecular.editor.e4.handler.ToggleInsertOverwriteHandlerE4" command="_pfKDUKT7Eeejf7ggYkp-TA"/>
41
      <handlers xmi:id="_ar1KMKUBEeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.molecular.editor.e4.handler.LoadPherogramHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.molecular/eu.etaxonomy.taxeditor.molecular.editor.e4.handler.LoadPherogramHandlerE4" command="_ncVP8KT7Eeejf7ggYkp-TA"/>
42
      <handlers xmi:id="_myRFoKUDEeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.molecular.editor.e4.handler.AlignmentEditorCutHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.molecular/eu.etaxonomy.taxeditor.molecular.editor.e4.handler.AlignmentEditorCutHandlerE4" command="_rlhZQKUDEeejf7ggYkp-TA"/>
43
      <handlers xmi:id="_vvnbIKUDEeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.molecular.editor.e4.handler.AlignmentEditorCopyHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.molecular/eu.etaxonomy.taxeditor.molecular.editor.e4.handler.AlignmentEditorCopyHandlerE4" command="_q2vnsKUDEeejf7ggYkp-TA"/>
44
      <handlers xmi:id="_x70M8KUDEeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.molecular.editor.e4.handler.AlignmentEditorPasteHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.molecular/eu.etaxonomy.taxeditor.molecular.editor.e4.handler.AlignmentEditorPasteHandlerE4" command="_tLkxEKUDEeejf7ggYkp-TA"/>
45
    </elements>
46
    <elements xsi:type="basic:PartDescriptor" xmi:id="_v8GjgKT5Eeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.molecular.editor.e4.PherogramPartE4" label="%view.PHEROGRAM_VIEW" allowMultiple="true" closeable="true" contributionURI="bundleclass://eu.etaxonomy.taxeditor.molecular/eu.etaxonomy.taxeditor.molecular.editor.e4.PherogramPartE4">
47
      <handlers xmi:id="_6ioEAKT-Eeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.molecular.editor.e4.handler.ToggleShowPherogramProbabilitiesHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.molecular/eu.etaxonomy.taxeditor.molecular.editor.e4.handler.ToggleShowPherogramProbabilitiesHandlerE4" command="_h1lC0KT7Eeejf7ggYkp-TA"/>
48
      <handlers xmi:id="_-IewYKT-Eeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.molecular.editor.e4.handler.ToggleShowPherogramBaseCallLinesHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.molecular/eu.etaxonomy.taxeditor.molecular.editor.e4.handler.ToggleShowPherogramBaseCallLinesHandlerE4" command="_j-w84KT7Eeejf7ggYkp-TA"/>
49
      <handlers xmi:id="_36J7AKUAEeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.molecular.editor.e4.handler.ChangePherogramQualityOutputTypeE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.molecular/eu.etaxonomy.taxeditor.molecular.editor.e4.handler.ChangePherogramQualityOutputTypeE4" command="_lyJmEKT7Eeejf7ggYkp-TA"/>
50
    </elements>
51
  </fragments>
52
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_1hS_gKT7Eeejf7ggYkp-TA" featurename="children" parentElementId="eu.etaxonomy.taxeditor.workbench.menu">
53
    <elements xsi:type="menu:Menu" xmi:id="_nWX8cKT8Eeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.molecular.menu.editoralignment_editor" label="%editor.ALIGNMENT_EDITOR">
54
      <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_wWCx4KUXEeejf7ggYkp-TA"/>
55
      <children xsi:type="menu:HandledMenuItem" xmi:id="__HWTwKT7Eeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.molecular.handledmenuitem.mainmenu.alignmenteditor.loadpherogram" label="%command.name.LOAD_PHEROGRAM" command="_ncVP8KT7Eeejf7ggYkp-TA"/>
56
      <children xsi:type="menu:HandledMenuItem" xmi:id="_J3mKQKT8Eeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.molecular.handledmenuitem.mainmenu.alignmenteditor.cutleft" label="%command.name.CUT_PHEROGRAM_LEFT" command="_YLPrgKT7Eeejf7ggYkp-TA"/>
57
      <children xsi:type="menu:HandledMenuItem" xmi:id="_OCpOYKT8Eeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.molecular.handledmenuitem.mainmenu.alignmenteditor.cutright" label="%command.name.CUT_PHEROGRAM_RIGHT" command="_akezwKT7Eeejf7ggYkp-TA"/>
58
      <children xsi:type="menu:HandledMenuItem" xmi:id="_PYK24KT8Eeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.molecular.handledmenuitem.mainmenu.alignmenteditor.reversecomplement" label="%command.name.REVERSE_COMPLEMENT_SELECTED_ROWS" command="_cnIoAKT7Eeejf7ggYkp-TA"/>
59
      <children xsi:type="menu:HandledMenuItem" xmi:id="_RRcFoKT8Eeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.molecular.handledmenuitem.mainmenu.alignmenteditor.createconsensus" label="%command.name.CREATE_CONSENUS_SEQUENCE" command="_d28DAKT7Eeejf7ggYkp-TA"/>
60
      <children xsi:type="menu:HandledMenuItem" xmi:id="_TUGg8KT8Eeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.molecular.handledmenuitem.mainmenu.alignmenteditor.updateconsensus" label="%command.name.UPDATE_CONSENSUS_SEQUENCE" command="_gnsTYKT7Eeejf7ggYkp-TA"/>
61
    </elements>
62
    <elements xsi:type="menu:Menu" xmi:id="_yuMJQKT8Eeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.molecular.menu.viewpherogram_view" label="%view.PHEROGRAM_VIEW">
63
      <children xsi:type="menu:HandledMenuItem" xmi:id="_0r-EkKT8Eeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.molecular.handledmenuitem.mainmenu.pherogrameditor.changeQuality" label="%command.name.CHANGE_QUALITY_OUTPUT" command="_lyJmEKT7Eeejf7ggYkp-TA"/>
64
      <children xsi:type="menu:HandledMenuItem" xmi:id="_7_ShMKT8Eeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.molecular.handledmenuitem.mainmenu.pherogrameditor.toggleProbabilities" label="%command.name.TOGGLE_SHOW_PROBABILITY_VALUES" command="_h1lC0KT7Eeejf7ggYkp-TA"/>
65
      <children xsi:type="menu:HandledMenuItem" xmi:id="_93JasKT8Eeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.molecular.handledmenuitem.mainmenu.pherogrameditor.toggleBaseCallLines" label="%command.name.TOGGLE_SHOW_BASE_CALL_LINES" command="_j-w84KT7Eeejf7ggYkp-TA"/>
66
    </elements>
67
  </fragments>
18 68
</fragment:ModelFragments>
eu.etaxonomy.taxeditor.molecular/plugin.xml
1 1
<?xml version="1.0" encoding="UTF-8"?>
2 2
<?eclipse version="3.4"?>
3 3
<plugin>
4
   <extension
5
         point="org.eclipse.ui.editors">
6
      <editor
7
            class="eu.etaxonomy.taxeditor.molecular.editor.AlignmentEditor"
8
            default="false"
9
            id="eu.etaxonomy.taxeditor.molecular.AlignmentEditor"
10
            name="%editor.ALIGNMENT_EDITOR">
11
      </editor>
12
   </extension>
13
      <extension
14
            point="org.eclipse.ui.views">
15
         <view
16
               allowMultiple="true"
17
               class="eu.etaxonomy.taxeditor.molecular.editor.PherogramViewPart"
18
               id="eu.etaxonomy.taxeditor.molecular.PherogramView"
19
               name="%view.PHEROGRAM_VIEW"
20
               restorable="true">
21
         </view>
22
      </extension>
23
      <extension
24
            point="org.eclipse.ui.commands">
25
         <command
26
               id="eu.etaxonomy.taxeditor.molecular.AlignmentEditor.cutPherogramLeft"
27
               name="%command.name.CUT_PHEROGRAM_LEFT">
28
         </command>
29
         <command
30
               id="eu.etaxonomy.taxeditor.molecular.AlignmentEditor.cutPherogramRight"
31
               name="%command.name.CUT_PHEROGRAM_RIGHT">
32
         </command>
33
         <command
34
               id="eu.etaxonomy.taxeditor.molecular.AlignmentEditor.reverseComplementRows"
35
               name="%command.name.REVERSE_COMPLEMENT_SELECTED_ROWS">
36
         </command>
37
         <command
38
               id="eu.etaxonomy.taxeditor.molecular.AlignmentEditor.createConsensus"
39
               name="%command.name.CREATE_CONSENUS_SEQUENCE">
40
         </command>
41
         <command
42
               id="eu.etaxonomy.taxeditor.molecular.AlignmentEditor.updateConsensus"
43
               name="%command.name.UPDATE_CONSENSUS_SEQUENCE">
44
         </command>
45
         <command
46
               id="eu.etaxonomy.taxeditor.molecular.pherogramComponent.toggleShowProbabilities"
47
               name="%command.name.TOGGLE_SHOW_PROBABILITY_VALUES">
48
         </command>
49
         <command
50
               id="eu.etaxonomy.taxeditor.molecular.pherogramComponent.toggleShowBaseCallLines"
51
               name="%command.name.TOGGLE_SHOW_BASE_CALL_LINES">
52
         </command>
53
         <command
54
               id="eu.etaxonomy.taxeditor.molecular.pherogramComponent.changeQualityOutput"
55
               name="%command.name.CHANGE_QUALITY_OUTPUT">
56
         </command>
57
         <command
58
               id="eu.etaxonomy.taxeditor.molecular.AlignmentEditor.loadPherogram"
59
               name="%command.name.LOAD_PHEROGRAM">
60
         </command>
61
         <command
62
               id="eu.etaxonomy.taxeditor.molecular.AlignmentEditor.toggleInsertOverwrite"
63
               name="%command.name.TOGGLE_INSERT_OVERWRITE">
64
         </command>
65
         <command
66
               id="eu.etaxonomy.taxeditor.molecular.AlignmentEditor.toggleLeftRightInsertion"
67
               name="%command.name.TOGGLE_LEFT_RIGHT_INSERTION">
68
         </command>
69
      </extension>
70 4
      <extension
71 5
            point="org.eclipse.ui.menus">
72 6
         <menuContribution
......
103 37
               </command>
104 38
            </toolbar>
105 39
         </menuContribution>
106
         <menuContribution
107
               allPopups="false"
108
               locationURI="menu:org.eclipse.ui.main.menu">
109
            <menu
110
                  label="%menu.ALIGNMENT_EDITOR">
111
               <command
112
                     commandId="eu.etaxonomy.taxeditor.molecular.AlignmentEditor.loadPherogram"
113
                     style="push">
114
               </command>
115
               <command
116
                     commandId="eu.etaxonomy.taxeditor.molecular.AlignmentEditor.cutPherogramLeft"
117
                     id="eu.etaxonomy.taxeditor.molecular.AlignmentEditor.cutPherogramLeft"
118
                     name="Cut pherogram left">
119
               </command>
120
               <command
121
                     commandId="eu.etaxonomy.taxeditor.molecular.AlignmentEditor.cutPherogramRight"
122
                     id="eu.etaxonomy.taxeditor.molecular.AlignmentEditor.cutPherogramRight"
123
                     style="push">
124
               </command>
125
               <command
126
                     commandId="eu.etaxonomy.taxeditor.molecular.AlignmentEditor.reverseComplementRows"
127
                     mnemonic="r"
128
                     style="push">
129
               </command>
130
               <command
131
                     commandId="eu.etaxonomy.taxeditor.molecular.AlignmentEditor.createConsensus"
132
                     style="push">
133
               </command>
134
               <command
135
                     commandId="eu.etaxonomy.taxeditor.molecular.AlignmentEditor.updateConsensus"
136
                     style="push">
137
               </command>
138
               <visibleWhen
139
                     checkEnabled="true">
140
                  <with
141
                        variable="activePartId">
142
                     <equals
143
                           value="eu.etaxonomy.taxeditor.molecular.AlignmentEditor">
144
                     </equals>
145
                  </with>
146
               </visibleWhen>
147
            </menu>
148
            <menu
149
                  label="%menu.label.PHEROGRAM_VIEW">
150
               <command
151
                     commandId="eu.etaxonomy.taxeditor.molecular.pherogramComponent.changeQualityOutput"
152
                     style="push">
153
               </command>
154
               <command
155
                     commandId="eu.etaxonomy.taxeditor.molecular.pherogramComponent.toggleShowProbabilities"
156
                     style="push">
157
               </command>
158
               <command
159
                     commandId="eu.etaxonomy.taxeditor.molecular.pherogramComponent.toggleShowBaseCallLines"
160
                     style="push">
161
               </command>
162
               <visibleWhen
163
                     checkEnabled="true">
164
                  <with
165
                        variable="activePartId">
166
                     <equals
167
                           value="eu.etaxonomy.taxeditor.molecular.PherogramView">
168
                     </equals>
169
                  </with>
170
               </visibleWhen>
171
            </menu>
172
         </menuContribution>
173
      </extension>
174
      <extension
175
            point="org.eclipse.ui.handlers">
176
         <handler
177
               class="eu.etaxonomy.taxeditor.molecular.handler.LoadPherogramHandler"
178
               commandId="eu.etaxonomy.taxeditor.molecular.AlignmentEditor.loadPherogram">
179
            <activeWhen>
180
               <with
181
                     variable="activePartId">
182
                  <equals
183
                        value="eu.etaxonomy.taxeditor.molecular.AlignmentEditor">
184
                  </equals>
185
               </with>
186
            </activeWhen>
187
         </handler>
188
         <handler
189
               class="eu.etaxonomy.taxeditor.molecular.handler.ToggleInsertOverwriteHandler"
190
               commandId="eu.etaxonomy.taxeditor.molecular.AlignmentEditor.toggleInsertOverwrite">
191
         </handler>
192
         <handler
193
               class="eu.etaxonomy.taxeditor.molecular.handler.ToggleLeftRightInsertionHandler"
194
               commandId="eu.etaxonomy.taxeditor.molecular.AlignmentEditor.toggleLeftRightInsertion">
195
         </handler>
196
         <handler
197
               class="eu.etaxonomy.taxeditor.molecular.handler.CutPherogramLeftHandler"
198
               commandId="eu.etaxonomy.taxeditor.molecular.AlignmentEditor.cutPherogramLeft">
199
         </handler>
200
         <handler
201
               class="eu.etaxonomy.taxeditor.molecular.handler.CutPherogramRightHandler"
202
               commandId="eu.etaxonomy.taxeditor.molecular.AlignmentEditor.cutPherogramRight">
203
         </handler>
204
         <handler
205
               class="eu.etaxonomy.taxeditor.molecular.handler.ReverseComplementHandler"
206
               commandId="eu.etaxonomy.taxeditor.molecular.AlignmentEditor.reverseComplementRows">
207
         </handler>
208
         <handler
209
               class="eu.etaxonomy.taxeditor.molecular.handler.CreateConsensusSequenceHandler"
210
               commandId="eu.etaxonomy.taxeditor.molecular.AlignmentEditor.createConsensus">
211
         </handler>
212
         <handler
213
               class="eu.etaxonomy.taxeditor.molecular.handler.UpdateConsensusSequenceHandler"
214
               commandId="eu.etaxonomy.taxeditor.molecular.AlignmentEditor.updateConsensus">
215
         </handler>
216
         <handler
217
               class="eu.etaxonomy.taxeditor.molecular.handler.ToggleShowPherogramProbabilitiesHandler"
218
               commandId="eu.etaxonomy.taxeditor.molecular.pherogramComponent.toggleShowProbabilities">
219
         </handler>
220
         <handler
221
               class="eu.etaxonomy.taxeditor.molecular.handler.ToggleShowPherogramBaseCallLinesHandler"
222
               commandId="eu.etaxonomy.taxeditor.molecular.pherogramComponent.toggleShowBaseCallLines">
223
         </handler>
224
         <handler
225
               class="eu.etaxonomy.taxeditor.molecular.handler.ChangePherogramQualityOutputType"
226
               commandId="eu.etaxonomy.taxeditor.molecular.pherogramComponent.changeQualityOutput">
227
         </handler>
228
         <handler
229
               class="eu.etaxonomy.taxeditor.molecular.handler.AlignmentEditorCopyHandler"
230
               commandId="org.eclipse.ui.edit.copy">
231
            <activeWhen>
232
               <with
233
                     variable="activePartId">
234
                  <equals
235
                        value="eu.etaxonomy.taxeditor.molecular.AlignmentEditor">
236
                  </equals>
237
               </with>
238
            </activeWhen>
239
         </handler>
240
         <handler
241
               class="eu.etaxonomy.taxeditor.molecular.handler.AlignmentEditorCutHandler"
242
               commandId="org.eclipse.ui.edit.cut">
243
            <activeWhen>
244
               <with
245
                     variable="activePartId">
246
                  <equals
247
                        value="eu.etaxonomy.taxeditor.molecular.AlignmentEditor">
248
                  </equals>
249
               </with>
250
            </activeWhen>
251
         </handler>
252
         <handler
253
               class="eu.etaxonomy.taxeditor.molecular.handler.AlignmentEditorPasteHandler"
254
               commandId="org.eclipse.ui.edit.paste">
255
            <activeWhen>
256
               <with
257
                     variable="activePartId">
258
                  <equals
259
                        value="eu.etaxonomy.taxeditor.molecular.AlignmentEditor">
260
                  </equals>
261
               </with>
262
            </activeWhen>
263
         </handler>
264 40
      </extension>
265 41
      <extension
266 42
            point="org.eclipse.ui.bindings">
eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/editor/e4/AlignmentEditorE4.java
1
/**
2
* Copyright (C) 2014 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.editor.e4;
10

  
11

  
12
import java.io.File;
13
import java.io.IOException;
14
import java.io.InputStream;
15
import java.net.URI;
16
import java.util.ArrayList;
17
import java.util.Collection;
18
import java.util.Collections;
19
import java.util.Iterator;
20
import java.util.List;
21
import java.util.Map;
22
import java.util.TreeMap;
23

  
24
import javax.annotation.PostConstruct;
25
import javax.annotation.PreDestroy;
26
import javax.inject.Inject;
27

  
28
import org.biojava.bio.chromatogram.ChromatogramFactory;
29
import org.biojava.bio.chromatogram.UnsupportedChromatogramFormatException;
30
import org.eclipse.core.runtime.IProgressMonitor;
31
import org.eclipse.e4.ui.di.Focus;
32
import org.eclipse.e4.ui.di.Persist;
33
import org.eclipse.e4.ui.model.application.ui.MDirtyable;
34
import org.eclipse.swt.SWT;
35
import org.eclipse.swt.dnd.Clipboard;
36
import org.eclipse.swt.widgets.Composite;
37
import org.eclipse.swt.widgets.Display;
38
import org.eclipse.ui.PartInitException;
39
import org.eclipse.ui.PlatformUI;
40
import org.eclipse.ui.commands.ICommandService;
41

  
42
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
43
import eu.etaxonomy.cdm.api.service.molecular.ISequenceService;
44
import eu.etaxonomy.cdm.model.media.MediaUtils;
45
import eu.etaxonomy.cdm.model.molecular.Sequence;
46
import eu.etaxonomy.cdm.model.molecular.SequenceString;
47
import eu.etaxonomy.cdm.model.molecular.SingleRead;
48
import eu.etaxonomy.cdm.model.molecular.SingleReadAlignment;
49
import eu.etaxonomy.taxeditor.model.MessagingUtils;
50
import eu.etaxonomy.taxeditor.molecular.TaxeditorMolecularPlugin;
51
import eu.etaxonomy.taxeditor.molecular.editor.AlignmentEditorActionUpdater;
52
import eu.etaxonomy.taxeditor.molecular.editor.AlignmentEditorInput;
53
import eu.etaxonomy.taxeditor.molecular.editor.PherogramMouseListener;
54
import eu.etaxonomy.taxeditor.molecular.handler.ToggleInsertOverwriteHandler;
55
import eu.etaxonomy.taxeditor.molecular.handler.ToggleLeftRightInsertionHandler;
56
import eu.etaxonomy.taxeditor.molecular.l10n.Messages;
57
import eu.etaxonomy.taxeditor.store.CdmStore;
58
import eu.etaxonomy.taxeditor.view.derivateSearch.DerivateLabelProvider;
59
import info.bioinfweb.commons.swt.SWTUtils;
60
import info.bioinfweb.libralign.alignmentarea.AlignmentArea;
61
import info.bioinfweb.libralign.alignmentarea.selection.SelectionModel;
62
import info.bioinfweb.libralign.alignmentarea.tokenpainter.NucleotideTokenPainter;
63
import info.bioinfweb.libralign.dataarea.implementations.ConsensusSequenceArea;
64
import info.bioinfweb.libralign.dataarea.implementations.pherogram.PherogramArea;
65
import info.bioinfweb.libralign.dataarea.implementations.sequenceindex.SequenceIndexArea;
66
import info.bioinfweb.libralign.editsettings.EditSettingsChangeEvent;
67
import info.bioinfweb.libralign.editsettings.EditSettingsListener;
68
import info.bioinfweb.libralign.model.AlignmentModel;
69
import info.bioinfweb.libralign.model.AlignmentModelChangeListener;
70
import info.bioinfweb.libralign.model.adapters.StringAdapter;
71
import info.bioinfweb.libralign.model.events.SequenceChangeEvent;
72
import info.bioinfweb.libralign.model.events.SequenceRenamedEvent;
73
import info.bioinfweb.libralign.model.events.TokenChangeEvent;
74
import info.bioinfweb.libralign.model.implementations.PackedAlignmentModel;
75
import info.bioinfweb.libralign.model.tokenset.CharacterTokenSet;
76
import info.bioinfweb.libralign.model.tokenset.TokenSet;
77
import info.bioinfweb.libralign.model.utils.AlignmentModelUtils;
78
import info.bioinfweb.libralign.multiplealignments.AlignmentAreaList;
79
import info.bioinfweb.libralign.multiplealignments.MultipleAlignmentsContainer;
80
import info.bioinfweb.libralign.pherogram.model.PherogramAlignmentRelation;
81
import info.bioinfweb.libralign.pherogram.model.PherogramAreaModel;
82
import info.bioinfweb.libralign.pherogram.model.ShiftChange;
83
import info.bioinfweb.libralign.pherogram.provider.BioJavaPherogramProvider;
84
import info.bioinfweb.libralign.pherogram.provider.PherogramProvider;
85
import info.bioinfweb.libralign.pherogram.provider.ReverseComplementPherogramProvider;
86
import info.bioinfweb.tic.SWTComponentFactory;
87

  
88

  
89

  
90
/**
91
 * Editor component to edit a contig alignment used to combine different overlapping pherograms from Sanger sequencing to
92
 * a consensus sequence.
93
 * <p>
94
 * The contained GUI components used to edit the alignment come from <a href="http://bioinfweb.info/LibrAlign/">LibrAlign</a>.
95
 *
96
 * @author Ben Stöver
97
 * @author pplitzner
98
 * @date 04.08.2014
99
 */
100
public class AlignmentEditorE4 {
101
    public static final String ID = "eu.etaxonomy.taxeditor.molecular.AlignmentEditor"; //$NON-NLS-1$
102

  
103
	public static final int READS_AREA_INDEX = 1;
104
    public static final int EDITABLE_CONSENSUS_AREA_INDEX = READS_AREA_INDEX + 1;
105
    public static final int CONSENSUS_HINT_AREA_INDEX = EDITABLE_CONSENSUS_AREA_INDEX + 1;
106
	public static final int PHEROGRAM_AREA_INDEX = 0;
107
	public static final int CONSENSUS_DATA_AREA_INDEX = 0;
108
	public static final String DEFAULT_READ_NAME_PREFIX = "Read "; //$NON-NLS-1$
109
	public static final String CONSENSUS_NAME = "Consensus"; //$NON-NLS-1$
110

  
111

  
112
    private ConversationHolder conversationHolder;
113
	private final AlignmentModelChangeListener DIRTY_LISTENER = new AlignmentModelChangeListener() {
114
				@Override
115
				public <T> void afterTokenChange(TokenChangeEvent<T> e) {
116
					setDirty();
117
				}
118

  
119
				@Override
120
				public <T> void afterSequenceRenamed(SequenceRenamedEvent<T> e) {
121
					setDirty();
122
				}
123

  
124
				@Override
125
				public <T> void afterSequenceChange(SequenceChangeEvent<T> e) {
126
					setDirty();
127
				}
128

  
129
				@Override
130
				public <T, U> void afterProviderChanged(AlignmentModel<T> oldProvider,
131
						AlignmentModel<U> newProvider) {  // Not expected.
132

  
133
					setDirty();
134
				}
135
			};
136
	private final AlignmentEditorActionUpdater ACTION_UPDATER = new AlignmentEditorActionUpdater();
137
	public final Clipboard CLIPBOARD = new Clipboard(Display.getCurrent());  //TODO Move to global EDITor class.
138

  
139

  
140
    private MultipleAlignmentsContainer alignmentsContainer = null;
141
    private final Map<String, SingleReadAlignment> cdmMap = new TreeMap<String, SingleReadAlignment>();  //TODO Move this to ContigSequenceDataProvider
142

  
143

  
144
    @Inject
145
    private MDirtyable dirty;
146

  
147
    private AlignmentEditorInput input;
148

  
149
    @Inject
150
    public AlignmentEditorE4() {
151
    }
152

  
153

  
154
    private void refreshToolbarElement(String id) {
155
		ICommandService commandService =
156
				PlatformUI.getWorkbench().getActiveWorkbenchWindow().getService(ICommandService.class);
157
		if (commandService != null) {
158
			commandService.refreshElements(id, Collections.EMPTY_MAP);
159
		}
160
    }
161

  
162

  
163
    private void registerEditSettingListener(MultipleAlignmentsContainer container) {
164
        container.getEditSettings().addListener(new EditSettingsListener() {
165
            @Override
166
            public void workingModeChanged(EditSettingsChangeEvent e) {}  // Currently nothing to do
167

  
168
            @Override
169
            public void insertLeftInDataAreaChanged(EditSettingsChangeEvent e) {
170
                updateStatusBar();
171
                refreshToolbarElement(ToggleLeftRightInsertionHandler.COMMAND_ID);
172
            }
173

  
174
            @Override
175
            public void insertChanged(EditSettingsChangeEvent e) {
176
                updateStatusBar();
177
                refreshToolbarElement(ToggleInsertOverwriteHandler.COMMAND_ID);
178
            }
179
        });
180
    }
181

  
182

  
183
    private AlignmentArea createIndexArea(MultipleAlignmentsContainer container, AlignmentArea labeledArea) {
184
		AlignmentArea result = new AlignmentArea(container);
185
		result.setAllowVerticalScrolling(false);
186
		result.getDataAreas().getTopAreas().add(new SequenceIndexArea(result.getContentArea(), labeledArea));
187
		return result;
188
    }
189

  
190

  
191
    private AlignmentArea createEditableAlignmentArea(MultipleAlignmentsContainer container, boolean allowVerticalScrolling) {
192
		AlignmentArea result = new AlignmentArea(container);
193
		result.setAllowVerticalScrolling(allowVerticalScrolling);
194

  
195
		CharacterTokenSet tokenSet = CharacterTokenSet.newDNAInstance();  //TODO Should NUCLEOTIDE be used instead?
196
		AlignmentModel<Character> model = new PackedAlignmentModel<Character>(tokenSet);
197
		result.setAlignmentModel(model, false);
198
		model.getChangeListeners().add(DIRTY_LISTENER);
199
		result.getPaintSettings().getTokenPainterList().set(0, new NucleotideTokenPainter());
200

  
201
		return result;
202
	}
203

  
204

  
205
    private AlignmentArea createConsensusHintArea(MultipleAlignmentsContainer container,
206
    		AlignmentArea labeledArea) {
207

  
208
		AlignmentArea result = new AlignmentArea(container);
209
		result.setAllowVerticalScrolling(false);
210
		result.getDataAreas().getBottomAreas().add(
211
				new ConsensusSequenceArea(result.getContentArea(), labeledArea));
212
		return result;
213
    }
214

  
215

  
216
    private MultipleAlignmentsContainer getAlignmentsContainer() {
217
    	if (alignmentsContainer == null) {
218
    		alignmentsContainer = new MultipleAlignmentsContainer();
219

  
220
    		AlignmentAreaList list = alignmentsContainer.getAlignmentAreas();
221
    		AlignmentArea readsArea = createEditableAlignmentArea(alignmentsContainer, true);
222
    		readsArea.getSelection().addSelectionListener(ACTION_UPDATER);
223
    	    list.add(createIndexArea(alignmentsContainer, readsArea));
224
    		list.add(readsArea);  // Make sure READS_AREA_INDEX is correct.
225
    		AlignmentArea editableConsensusArea = createEditableAlignmentArea(alignmentsContainer, false);
226
    		editableConsensusArea.getSelection().addSelectionListener(ACTION_UPDATER);
227
    		list.add(editableConsensusArea);  // Make sure COMSENSUS_AREA_INDEX is correct.
228
    		list.add(createConsensusHintArea(alignmentsContainer, readsArea));
229

  
230
    		registerEditSettingListener(alignmentsContainer);
231
       	}
232
		return alignmentsContainer;
233
	}
234

  
235

  
236
    public AlignmentArea getReadsArea() {
237
    	return getAlignmentsContainer().getAlignmentAreas().get(READS_AREA_INDEX);
238
    }
239

  
240

  
241
    public AlignmentArea getEditableConsensusArea() {
242
    	return getAlignmentsContainer().getAlignmentAreas().get(EDITABLE_CONSENSUS_AREA_INDEX);
243
    }
244

  
245

  
246
    /**
247
     * Checks whether {@link #getReadsArea()} or {@link #getEditableConsensusArea()} currently
248
     * have the user focus and returns the according component.
249
     *
250
     * @return either the reads or the consensus alignment area or {@code null} if none of these
251
     *         components is currently focused
252
     */
253
    public AlignmentArea getFocusedArea() {
254
    	AlignmentArea result = getReadsArea();
255
    	if (hasFocus(result)) {
256
    		return result;
257
    	}
258
    	else {
259
    		result = getEditableConsensusArea();
260
        	if (hasFocus(result)) {
261
        		return result;
262
        	}
263
        	else {
264
        		return null;
265
        	}
266
    	}
267
    }
268

  
269

  
270
    /**
271
     * Checks whether the specified alignment area or one of its subcomponents currently has the
272
     * focus.
273
     *
274
     * @param area the alignment area to be checked (Can only be {@link #getReadsArea()} or
275
     *        {@link #getEditableConsensusArea()}.)
276
     * @return {@code true} if the specified component is focused and is either equal to
277
     *         {@link #getReadsArea()} or {@link #getEditableConsensusArea()}or {@code false} otherwise
278
     */
279
    private boolean hasFocus(AlignmentArea area) {
280
    	return SWTUtils.childHasFocus((Composite)area.getToolkitComponent());
281
    }
282

  
283

  
284
    public boolean hasPherogram(String sequenceID) {
285
        return getReadsArea().getDataAreas().getSequenceAreas(sequenceID).size() > PHEROGRAM_AREA_INDEX;
286
    }
287

  
288

  
289
    public PherogramArea getPherogramArea(String sequenceID) {
290
        if (hasPherogram(sequenceID)) {
291
            return (PherogramArea)getReadsArea().getDataAreas().getSequenceAreas(sequenceID).get(PHEROGRAM_AREA_INDEX);
292
        }
293
        else {
294
            return null;
295
        }
296
    }
297

  
298

  
299
    private ConsensusSequenceArea getConsensusHintDataArea() {
300
        return (ConsensusSequenceArea)getAlignmentsContainer().getAlignmentAreas().
301
                get(CONSENSUS_HINT_AREA_INDEX).getDataAreas().getBottomAreas().
302
                get(CONSENSUS_DATA_AREA_INDEX);
303
    }
304

  
305

  
306
    @Deprecated  //TODO Remove as soon as testing period is over
307
    private void createTestContents() {
308
		// Just for testing:
309
		try {
310
			addRead(new File("D:/Users/BenStoever/ownCloud/Dokumente/Projekte/EDITor/Quelltexte/LibrAlign branch/Repository/eu.etaxonomy.taxeditor.editor/src/main/resources/AlignmentTestData/JR430_JR-P01.ab1").toURI(), false); //$NON-NLS-1$
311
            //addRead(new File("D:/Users/BenStoever/ownCloud/Dokumente/Projekte/EDITor/Quelltexte/LibrAlign branch/Repository/eu.etaxonomy.taxeditor.editor/src/main/resources/AlignmentTestData/JR444_JR-P05.ab1").toURI(), false);
312
            addRead(new File("D:/Users/BenStoever/ownCloud/Dokumente/Projekte/EDITor/Quelltexte/LibrAlign branch/Repository/eu.etaxonomy.taxeditor.editor/src/main/resources/AlignmentTestData/Test_qualityScore.scf").toURI(), false); //$NON-NLS-1$
313

  
314
			// Add test consensus sequence:
315
			AlignmentModel consensusModel = getEditableConsensusArea().getAlignmentModel();
316
			String id = consensusModel.addSequence(CONSENSUS_NAME);
317
			Collection<Object> tokens = new ArrayList<Object>();  // First save tokens in a collection to avoid GUI updated for each token.
318
			tokens.add(consensusModel.getTokenSet().tokenByRepresentation("A")); //$NON-NLS-1$
319
			tokens.add(consensusModel.getTokenSet().tokenByRepresentation("C")); //$NON-NLS-1$
320
			tokens.add(consensusModel.getTokenSet().tokenByRepresentation("G")); //$NON-NLS-1$
321
			tokens.add(consensusModel.getTokenSet().tokenByRepresentation("T")); //$NON-NLS-1$
322
			consensusModel.insertTokensAt(id, 0, tokens);
323
		}
324
		catch (Exception e) {
325
			throw new RuntimeException(e);
326
		}
327
    }
328

  
329

  
330
    private void readCDMData(Sequence sequenceNode) {
331
    	//TODO If called from somewhere else than createPartControl() the editorInput needs to be checked and previous contents need to be cleared (or updated).
332

  
333
		// Add reads:
334
		for (SingleReadAlignment singleReadAlignment : sequenceNode.getSingleReadAlignments()) {
335
			try {
336
				SingleRead pherogramInfo = singleReadAlignment.getSingleRead();
337
				String id = addRead(DerivateLabelProvider.getDerivateText(pherogramInfo, conversationHolder),
338
						getPherogramURI(pherogramInfo),
339
						singleReadAlignment.isReverseComplement(),
340
						singleReadAlignment.getEditedSequence(),
341
						singleReadAlignment.getFirstSeqPosition(),
342
						singleReadAlignment.getLeftCutPosition(),
343
						singleReadAlignment.getRightCutPosition(),
344
						singleReadAlignment.getShifts());
345
				cdmMap.put(id, singleReadAlignment);
346
			}
347
			catch (Exception e) {  // Usually due to an error while trying to read the pherogram (e.g. due to an unsupported format or an invalid URI).
348
                MessagingUtils.errorDialog(Messages.AlignmentEditor_ERROR_SINGLE_READ, null, Messages.AlignmentEditor_ERROR_SINGLE_READ_MESSAGE +
349
                        e.getLocalizedMessage(), TaxeditorMolecularPlugin.PLUGIN_ID, e, false);
350
			}
351
		}
352

  
353
		// Set consensus sequence:
354
		AlignmentModel consensusModel = getEditableConsensusArea().getAlignmentModel();
355
		String id = consensusModel.addSequence(CONSENSUS_NAME);
356
		consensusModel.insertTokensAt(id, 0, AlignmentModelUtils.charSequenceToTokenList(
357
				sequenceNode.getConsensusSequence().getString(), consensusModel.getTokenSet()));
358
		//TODO Can the consensus sequence also be null? / Should it be created here, if nothing is in the DB?
359
    }
360

  
361

  
362
    @PostConstruct
363
    public void createPartControl(Composite parent) {
364
        if (CdmStore.isActive()){
365
            if(conversationHolder == null){
366
                conversationHolder = CdmStore.createConversation();
367
            }
368
        }
369
        else{
370
            return;
371
        }
372
        SWTComponentFactory.getInstance().getSWTComponent(getAlignmentsContainer(), parent, SWT.NONE);
373
        Display.getCurrent().addFilter(SWT.FocusIn, ACTION_UPDATER);
374
        Display.getCurrent().addFilter(SWT.FocusOut, ACTION_UPDATER);
375
	}
376

  
377

  
378
    @PreDestroy
379
	public void dispose() {
380
		Display.getCurrent().removeFilter(SWT.FocusIn, ACTION_UPDATER);
381
		Display.getCurrent().removeFilter(SWT.FocusOut, ACTION_UPDATER);
382
		CLIPBOARD.dispose();
383
        input.dispose();
384
	}
385

  
386

  
387
	private void updateStatusBar() {
388
	    //FIXME E4 migrate
389
//        IActionBars bars = getEditorSite().getActionBars();
390
//        bars.getStatusLineManager().setMessage(
391
//                Messages.AlignmentEditor_EDIT_MODE + (getReadsArea().getEditSettings().isInsert() ? Messages.AlignmentEditor_INSERT : Messages.AlignmentEditor_OVERWRITE) + "  " + //$NON-NLS-1$
392
//        		Messages.AlignmentEditor_INSERTION_PHEROGRAM +
393
//	       		(getReadsArea().getEditSettings().isInsertLeftInDataArea() ? Messages.AlignmentEditor_LEFT : Messages.AlignmentEditor_RIGHT));  //TODO multi language
394
    }
395

  
396

  
397
    private SingleReadAlignment.Shift[] convertToCDMShifts(PherogramAreaModel model) {
398
    	Iterator<ShiftChange> iterator = model.shiftChangeIterator();
399
    	List<SingleReadAlignment.Shift> shifts = new ArrayList<SingleReadAlignment.Shift>();
400
    	while (iterator.hasNext()) {
401
    		ShiftChange shiftChange = iterator.next();
402
    		shifts.add(new SingleReadAlignment.Shift(shiftChange.getBaseCallIndex(), shiftChange.getShiftChange()));
403
    	}
404
    	return shifts.toArray(new SingleReadAlignment.Shift[shifts.size()]);
405
    }
406

  
407

  
408
    @Persist
409
    public void doSave(IProgressMonitor monitor) {
410
        String taskName = Messages.AlignmentEditor_SAVING_ALIGNMENT;  //TODO multi language
411
        monitor.beginTask(taskName, 3);
412

  
413
        //re-loading sequence to avoid session conflicts
414
        Sequence sequenceNode = CdmStore.getService(ISequenceService.class).load(input.getSequenceNodeUuid());
415
        input.setSequenceNode(sequenceNode);
416
        StringAdapter stringProvider = new StringAdapter(getEditableConsensusArea().getAlignmentModel(), false);  // Throws an exception if a token has more than one character.
417

  
418
        // Write consensus sequence:
419
        SequenceString consensusSequenceObj = sequenceNode.getConsensusSequence();
420
        String newConsensusSequence = stringProvider.getSequence(
421
                getEditableConsensusArea().getAlignmentModel().sequenceIDByName(CONSENSUS_NAME));
422
        if (consensusSequenceObj == null) {
423
            sequenceNode.setConsensusSequence(SequenceString.NewInstance(newConsensusSequence));
424
        }
425
        else {
426
            consensusSequenceObj.setString(newConsensusSequence);
427
        }
428

  
429
        // Write single reads:
430
        stringProvider.setUnderlyingModel(getReadsArea().getAlignmentModel());
431
        sequenceNode.getSingleReadAlignments().retainAll(cdmMap.values());  // Remove all reads that are not in the alignment anymore.
432
        Iterator<String> iterator = getReadsArea().getAlignmentModel().sequenceIDIterator();
433
        while (iterator.hasNext()) {
434
            String id = iterator.next();
435
            SingleReadAlignment singleRead = cdmMap.get(id);
436
            if (singleRead == null) {
437
                throw new InternalError(Messages.AlignmentEditor_NEW_READ_FAILURE);  //TODO multi language
438
                //TODO Create new read object. => Shall it be allowed to add reads in the alignment editor which are not represented in the CDM tree before the alignment editor is saved?
439
                //singleRead = SingleReadAlignment.NewInstance(consensusSequence, singleRead, shifts, editedSequence);
440
            }
441

  
442
            singleRead.setEditedSequence(stringProvider.getSequence(id));
443

  
444
            PherogramArea pherogramArea = getPherogramArea(id);
445
            if (pherogramArea != null) {
446
                PherogramAreaModel model = pherogramArea.getModel();
447
                singleRead.setReverseComplement(model.getPherogramProvider() instanceof ReverseComplementPherogramProvider);  // Works only if ReverseComplementPherogramProvider instances are not nested.
448
                singleRead.setShifts(convertToCDMShifts(getPherogramArea(id).getModel()));
449
                singleRead.setFirstSeqPosition(model.getFirstSeqPos());
450
                singleRead.setLeftCutPosition(model.getLeftCutPosition());
451
                singleRead.setRightCutPosition(model.getRightCutPosition());
452
            }
453
        }
454

  
455
        if (!conversationHolder.isBound()) {
456
            conversationHolder.bind();
457
        }
458
        monitor.worked(1);
459

  
460
        input.merge();
461
        // Commit the conversation and start a new transaction immediately:
462
        conversationHolder.commit(true);
463
        monitor.worked(1);
464

  
465
        dirty.setDirty(false);
466
        monitor.worked(1);
467
        monitor.done();
468
    }
469

  
470

  
471
    public void init(AlignmentEditorInput input) throws PartInitException {
472
        this.input = input;
473

  
474
        updateStatusBar();
475

  
476
        if (input.getSequenceNodeUuid() != null) {
477
            Sequence sequenceNode = CdmStore.getService(ISequenceService.class).load(input.getSequenceNodeUuid());
478
            //re-load into the current session if it is already persisted in the DB
479
            if(sequenceNode!=null && sequenceNode.getId()!=0){
480
                sequenceNode = CdmStore.getService(ISequenceService.class).load(sequenceNode.getUuid());
481
            }
482
            readCDMData(sequenceNode);
483
        }
484
        else {
485
            createTestContents();  // This case will removed after the test phase and an exception should probably be thrown.
486
        }
487
    }
488

  
489

  
490
    public boolean isDirty() {
491
        return dirty.isDirty();
492
    }
493

  
494

  
495
    private void setDirty() {
496
    	dirty.setDirty(true);
497
    }
498

  
499

  
500
    @Focus
501
    public void setFocus() {
502
        if(conversationHolder != null){
503
            conversationHolder.bind();
504
        }
505
        if(input!=null){
506
            input.bind();
507
        }
508
    }
509

  
510
    public boolean isInsertMode() {
511
        return getAlignmentsContainer().getEditSettings().isInsert();
512
    }
513

  
514

  
515
    public boolean isInsertLeftInPherogram() {
516
        return getAlignmentsContainer().getEditSettings().isInsertLeftInDataArea();
517
    }
518

  
519

  
520
    public void toggleLeftRightInsertionInPherogram() {
521
    	getAlignmentsContainer().getEditSettings().toggleInsertLeftInDataArea();
522
    }
523

  
524

  
525
    public void toggleInsertOverwrite() {
526
    	getAlignmentsContainer().getEditSettings().toggleInsert();
527
    }
528

  
529

  
530
    private String cutPherogram(boolean left) {
531
        SelectionModel selection = getReadsArea().getSelection();
532
        if (selection.getCursorHeight() != 1) {
533
            return Messages.AlignmentEditor_CUTTING_FAILURE;  //TODO multi language
534
        }
535
        else {
536
            PherogramArea pherogramArea =
537
                    getPherogramArea(getReadsArea().getSequenceOrder().idByIndex(selection.getCursorRow()));
538
            if (pherogramArea == null) {
539
                return Messages.AlignmentEditor_NO_ATTACHED_PHEROGRAM;  //TODO multi language
540
            }
541
            else {
542
                if (left) {
543
                    if (pherogramArea.setLeftCutPositionBySelection()) {
544
                        return null;
545
                    }
546
                    else {
547
                        return Messages.AlignmentEditor_LEFT_END_OUTSIDE;  //TODO multi language
548
                    }
549
                }
550
                else {
551
                    if (pherogramArea.setRightCutPositionBySelection()) {
552
                        return null;
553
                    }
554
                    else {
555
                        return Messages.AlignmentEditor_RIGHT_END_OUTSIDE;  //TODO multi language
556
                    }
557
                }
558
            }
559
        }
560
    }
561

  
562

  
563
    public String cutPherogramLeft() {
564
        return cutPherogram(true);
565
    }
566

  
567

  
568
    public String cutPherogramRight() {
569
        return cutPherogram(false);
570
    }
571

  
572

  
573
    public void reverseComplementSelectedSequences() {
574
    	SelectionModel selection = getReadsArea().getSelection();
575
    	AlignmentModel<?> model = getReadsArea().getAlignmentModel();
576
    	for (int row = selection.getFirstRow(); row < selection.getFirstRow() + selection.getCursorHeight(); row++) {
577
    		String sequenceID = getReadsArea().getSequenceOrder().idByIndex(row);
578
			PherogramArea area = getPherogramArea(sequenceID);
579
			PherogramAreaModel pherogramAlignmentModel = area.getModel();
580

  
581
            PherogramAlignmentRelation rightRelation = pherogramAlignmentModel.editableIndexByBaseCallIndex(
582
                    pherogramAlignmentModel.getRightCutPosition());
583
            int rightBorder;
584
            if (rightRelation.getCorresponding() == PherogramAlignmentRelation.OUT_OF_RANGE) {
585
                rightBorder = rightRelation.getBeforeValidIndex() + 1;
586
            }
587
            else {
588
                rightBorder = rightRelation.getAfterValidIndex();
589
            }
590

  
591
			AlignmentModelUtils.reverseComplement(model, sequenceID,
592
			        pherogramAlignmentModel.editableIndexByBaseCallIndex(
593
			                pherogramAlignmentModel.getLeftCutPosition()).getBeforeValidIndex(),
594
			        rightBorder);
595
			pherogramAlignmentModel.reverseComplement();
596
		}
597
    }
598

  
599

  
600
    /**
601
     * Recreates the whole consensus sequence from all single read sequences. The previous consensus
602
     * sequence is overwritten.
603
     */
604
    @SuppressWarnings("unchecked")
605
    public <T> void createConsensusSequence() {
606
        ConsensusSequenceArea area = getConsensusHintDataArea();
607
        AlignmentModel<T> model = (AlignmentModel<T>)getEditableConsensusArea().getAlignmentModel();
608
        String sequenceID = model.sequenceIDIterator().next();  // There is always one sequence contained.
609
        int length = getReadsArea().getAlignmentModel().getMaxSequenceLength();
610

  
611
        Collection<T> tokens = new ArrayList<T>(length);
612
        for (int column = 0; column < length; column++) {
613
            tokens.add(model.getTokenSet().tokenByRepresentation(area.getConsensusToken(column)));
614
        }
615

  
616
        model.removeTokensAt(sequenceID, 0, model.getSequenceLength(sequenceID));
617
        model.insertTokensAt(sequenceID, 0, tokens);
618
    }
619

  
620

  
621
    /**
622
     * Updates the current consensus sequence by replacing gaps by the according consensus tokens
623
     * calculated from the single read sequences and extends the consensus sequence if necessary.
624
     */
625
    @SuppressWarnings("unchecked")
626
    public <T> void updateConsensusSequence() {
627
        ConsensusSequenceArea area = getConsensusHintDataArea();
628
        AlignmentModel<T> model = (AlignmentModel<T>)getEditableConsensusArea().getAlignmentModel();
629
        TokenSet<T> tokenSet = model.getTokenSet();
630
        String sequenceID = model.sequenceIDIterator().next();  // There is always one sequence contained.
631
        int currentConsensusLength = model.getSequenceLength(sequenceID);
632
        int overallLength = getReadsArea().getAlignmentModel().getMaxSequenceLength();
633

  
634
        // Replace gaps by new information:
635
        for (int column = 0; column < currentConsensusLength; column++) {
636
            if (tokenSet.isGapToken(model.getTokenAt(sequenceID, column))) {
637
                T newToken = tokenSet.tokenByRepresentation(area.getConsensusToken(column));
638
                if (!tokenSet.isGapToken(newToken)) {
639
                    model.setTokenAt(sequenceID, column, newToken);
640
                }
641
            }
642
        }
643

  
644
        // Append additional tokens:
645
        if (overallLength > currentConsensusLength) {
646
            Collection<T> tokens = new ArrayList<T>(overallLength);
647
            for (int column = currentConsensusLength; column < overallLength; column++) {
648
                tokens.add(tokenSet.tokenByRepresentation(area.getConsensusToken(column)));
649
            }
650
            model.appendTokens(sequenceID, tokens);
651
        }
652
    }
653

  
654

  
655
	public static PherogramProvider readPherogram(URI uri) throws IOException, UnsupportedChromatogramFormatException {
656
	    PherogramProvider result;
657
		InputStream stream = uri.toURL().openStream();
658
		try {
659
			result = new BioJavaPherogramProvider(ChromatogramFactory.create(stream));
660
		}
661
		finally {
662
			stream.close();
663
		}
664
		return result;
665
	}
666

  
667

  
668
	private String newReadName() {
669
		int index = 1;
670
		while (getReadsArea().getAlignmentModel().sequenceIDByName(DEFAULT_READ_NAME_PREFIX + index) != null) {
671
			index++;
672
		}
673
		return DEFAULT_READ_NAME_PREFIX + index;
674
	}
675

  
676

  
677
    public void addRead(URI pherogramURI, boolean reverseComplemented) throws IOException, UnsupportedChromatogramFormatException {
678
    	addRead(newReadName(), pherogramURI, reverseComplemented, null, null, null, null, null);
679
    }
680

  
681

  
682
    /**
683
     * Adds a new sequence with attached phergram data area to the reads alignment.
684
     * <p>
685
     * If {@code null} is specified as {@code editedSequence} the base call sequence from the pherogram will
686
     * be set as the edited sequence. If {@code null} is specified as {@code shifts} no shifts between the edited
687
     * and the base calls sequence are assumed.
688
     *
689
     * @param name the name of the new sequence
690
     * @param pherogramURI the URI where the associated pherogram file is located
691
     * @param reverseComplemented Specify {@code true} here, if the reverse complement of the pherogram data should
692
     *        be added, {@code false} otherwise.
693
     * @param editedSequence the edited version of the base call sequence (May be {@code null}.)
694
     * @param shifts the alignment information that links the edited and the base call sequence (May be {@code null}.)
695
     * @return the sequence ID of the added read
696
     * @throws IOException if an error occurred when trying to read the pherogram file
697
     * @throws UnsupportedChromatogramFormatException if the format of the pherogram file is not supported
698
     */
699
    public String addRead(String name, URI pherogramURI, boolean reverseComplemented, String editedSequence,
700
            Integer firstSeqPos, Integer leftCutPos, Integer rightCutPos, SingleReadAlignment.Shift[] shifts)
701
            throws IOException, UnsupportedChromatogramFormatException {
702

  
703
		AlignmentModel model = getReadsArea().getAlignmentModel();
704
		PherogramProvider pherogramProvider = null;
705
		if (pherogramURI != null) {
706
		    pherogramProvider = readPherogram(pherogramURI);  // Must happen before a sequence is added, because it might throw an exception.
707
            if (reverseComplemented) {
708
                pherogramProvider = new ReverseComplementPherogramProvider(pherogramProvider);
709
            }
710
		}
711

  
712
        // Create sequence:
713
		model.addSequence(name);
714
		String id = model.sequenceIDByName(name);
715

  
716
		// Set edited sequence:
717
		Collection<Object> tokens = null;  // First save tokens in a collection to avoid GUI updated for each token.
718
		if (editedSequence != null) {
719
			tokens = AlignmentModelUtils.charSequenceToTokenList(editedSequence, model.getTokenSet());
720
		}
721
		else if (pherogramProvider != null) {  // Copy base call sequence into alignment:
722
			tokens = new ArrayList<Object>();
723
			for (int i = 0; i < pherogramProvider.getSequenceLength(); i++) {
724
				tokens.add(model.getTokenSet().tokenByRepresentation(
725
					Character.toString(pherogramProvider.getBaseCall(i))));
726
			}
727
			setDirty();
728
		}
729

  
730
		if (tokens != null) {  // If either an edited sequence or a pherogram URI was provided.
731
		    model.insertTokensAt(id, 0, tokens);
732

  
733
		    if (pherogramProvider != null) {
734
		        // Create pherogram area:
735
		        PherogramArea pherogramArea = new PherogramArea(getReadsArea().getContentArea(),
736
		                new PherogramAreaModel(pherogramProvider));
737

  
738
		        // Set position properties and shifts:
739
		        PherogramAreaModel phergramModel = pherogramArea.getModel();
740
		        if ((firstSeqPos != null) && (leftCutPos != null)) {
741
		            phergramModel.setFirstSeqLeftCutPos(firstSeqPos, leftCutPos);
742
		        }
743
		        if (rightCutPos != null) {
744
		            phergramModel.setRightCutPosition(rightCutPos);
745
		        }
746
		        if ((shifts != null) && (shifts.length > 0)) {
747
		            for (int i = 0; i < shifts.length; i++) {
748
		                phergramModel.addShiftChange(shifts[i].position, shifts[i].shift);
749
		            }
750
		            setDirty();
751
		        }
752

  
753
		        // Add pherogram area to GUI:
754
		        pherogramArea.addMouseListener(new PherogramMouseListener(pherogramArea));
755
		        getReadsArea().getDataAreas().getSequenceAreas(id).add(pherogramArea);
756
		    }
757
		}
758
		return id;
759
	}
760

  
761

  
762
    public static URI getPherogramURI(SingleRead pherogramInfo) {
763
        if (pherogramInfo.getPherogram() != null) {
764
            return MediaUtils.getFirstMediaRepresentationPart(pherogramInfo.getPherogram()).getUri();
765
        }
766
        else {
767
            return null;
768
        }
769
    }
770
}
eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/editor/e4/PherogramPartE4.java
1
/**
2
* Copyright (C) 2007 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.editor.e4;
10

  
11

  
12
import javax.annotation.PostConstruct;
13

  
14
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.widgets.Composite;
16

  
17
import eu.etaxonomy.taxeditor.molecular.editor.AlignmentEditor;
18
import info.bioinfweb.libralign.pherogram.PherogramFormats.QualityOutputType;
19
import info.bioinfweb.libralign.pherogram.model.PherogramComponentModel;
20
import info.bioinfweb.libralign.pherogram.view.PherogramView;
21
import info.bioinfweb.tic.SWTComponentFactory;
22

  
23

  
24

  
25
/**
26
 * Component that allows to view a pherogram without the distortion due to aligning it to a sequence as in
27
 * {@link AlignmentEditor}.
28
 *
29
 * @author Ben Stöver
30
 * @date Nov 20, 2014
31
 */
32
public class PherogramPartE4 {
33
    public static final String ID = "eu.etaxonomy.taxeditor.molecular.PherogramView"; //$NON-NLS-1$
34

  
35
    private PherogramView pherogramView = null;
36

  
37
    public PherogramView getPherogramView() {
38
		if (pherogramView == null) {
39
			pherogramView = new PherogramView();
40
			pherogramView.getTraceCurveView().getFormats().setShowProbabilityValues(true);
41
			pherogramView.getTraceCurveView().setHorizontalScale(1);
42
			pherogramView.getTraceCurveView().setVerticalScale(100);
43
			pherogramView.getTraceCurveView().getFormats().setQualityOutputType(QualityOutputType.NONE);  //TODO Make this user defined
44
			pherogramView.getTraceCurveView().getFormats().setShowProbabilityValues(false);
45
		}
46
		return pherogramView;
47
	}
48

  
49

  
50
	@PostConstruct
51
	public void createPartControl(Composite parent) {
52
		SWTComponentFactory.getInstance().getSWTComponent(getPherogramView(), parent, SWT.NONE);
53
		getPherogramView().assignSize();
54
	}
55

  
56
	public void init(PherogramComponentModel model){
57
	    getPherogramView().getTraceCurveView().setModel(model);
58
	    getPherogramView().assignSize();
59
	}
60

  
61
}
eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/editor/e4/handler/AlignmentEditorCopyHandlerE4.java
1
package eu.etaxonomy.taxeditor.molecular.editor.e4.handler;
2

  
3

  
4
import javax.inject.Named;
5

  
6
import org.eclipse.e4.core.di.annotations.CanExecute;
7
import org.eclipse.e4.core.di.annotations.Execute;
8
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
9
import org.eclipse.e4.ui.services.IServiceConstants;
10
import org.eclipse.swt.dnd.TextTransfer;
11
import org.eclipse.swt.dnd.Transfer;
12

  
13
import eu.etaxonomy.taxeditor.molecular.editor.e4.AlignmentEditorE4;
14
import info.bioinfweb.libralign.alignmentarea.AlignmentArea;
15
import info.bioinfweb.libralign.alignmentarea.selection.SelectionModel;
16
import info.bioinfweb.libralign.model.utils.AlignmentModelUtils;
17

  
18

  
19

  
20
/**
21
 * Handler that copies the currently selected nucleotides from an alignment editor to the clipboard.
22
 * <p>
23
 * The copied contents either come from the single reads or the consensus sequence alignment area,
24
 * depending on which component currently has the focus. If none of these components has the focus,
25
 * nothing will be copied, even if nucleotides are currently selected.
26
 * <p>
27
 * If the selection contains parts of multiple sequence, these are separated by the line separator
28
 * of the current operating system.
29
 *
30
 * @author Ben Stöver
31
 * @date 25.08.2015
32
 */
33
public class AlignmentEditorCopyHandlerE4 {
34

  
35
    @Execute
36
	protected void doExecute2(@Named(IServiceConstants.ACTIVE_PART)MPart activePart) {
37
        AlignmentEditorE4 editor = (AlignmentEditorE4) activePart.getObject();
38
        AlignmentArea focusedArea = editor.getFocusedArea();
39
    	SelectionModel selection = focusedArea.getSelection();
40
    	if (!selection.isEmpty()) {
41
    		editor.CLIPBOARD.setContents(new Object[]{AlignmentModelUtils.selectionAsString(focusedArea, false)},
42
            		new Transfer[]{TextTransfer.getInstance()});
43
    	}
44
	}
45

  
46

  
47
	@CanExecute
48
	public boolean isEnabled(@Named(IServiceConstants.ACTIVE_PART)MPart activePart) {
49
        AlignmentEditorE4 editor = (AlignmentEditorE4) activePart.getObject();
50
		if (editor != null) {
51
			AlignmentArea focusedArea = editor.getFocusedArea();
52
			if (focusedArea != null) {
53
				return !focusedArea.getSelection().isEmpty();
54
			}
55
		}
56
		return false;
57
	}
58

  
59
}
eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/editor/e4/handler/AlignmentEditorCutHandlerE4.java
1
package eu.etaxonomy.taxeditor.molecular.editor.e4.handler;
2

  
3

  
4
import javax.inject.Named;
5

  
6
import org.eclipse.e4.core.di.annotations.CanExecute;
7
import org.eclipse.e4.core.di.annotations.Execute;
8
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
9
import org.eclipse.e4.ui.services.IServiceConstants;
10

  
11
import eu.etaxonomy.taxeditor.molecular.editor.e4.AlignmentEditorE4;
12
import info.bioinfweb.libralign.alignmentarea.AlignmentArea;
13

  
14

  
15

  
16
/**
17
 * Handler that cuts the currently selected nucleotides from an alignment editor to the clipboard.
18
 * <p>
19
 * The cut contents either come from the single reads or the consensus sequence alignment area,
20
 * depending on which component currently has the focus. If none of these components has the focus,
21
 * nothing will be cut, even if nucleotides are currently selected.
22
 * <p>
23
 * If the selection contains parts of multiple sequence, these are separated by the line separator
24
 * of the current operating system.
25
 *
26
 * @author Ben Stöver
27
 * @date 25.08.2015
28
 */
29
public class AlignmentEditorCutHandlerE4 extends AlignmentEditorCopyHandlerE4 {
30

  
31
    @Override
32
    @Execute
33
    protected void doExecute2(@Named(IServiceConstants.ACTIVE_PART)MPart activePart) {
34
        super.doExecute2(activePart);  // Copy selected contents.
35
        AlignmentEditorE4 editor = (AlignmentEditorE4) activePart.getObject();
36
        AlignmentArea focusedArea = editor.getFocusedArea();
37
        focusedArea.getActionProvider().deleteSelection();
38
    }
39

  
40

  
41
    @Override
42
    @CanExecute
43
    public boolean isEnabled(@Named(IServiceConstants.ACTIVE_PART)MPart activePart) {
44
        AlignmentEditorE4 editor = (AlignmentEditorE4) activePart.getObject();
45
        if (editor != null) {
46
            AlignmentArea focusedArea = editor.getFocusedArea();
47
            if (focusedArea != null) {
48
                return !focusedArea.getSelection().isEmpty();
49
            }
50
        }
51
        return false;
52
    }
53

  
54
}
eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/editor/e4/handler/AlignmentEditorPasteHandlerE4.java
1
package eu.etaxonomy.taxeditor.molecular.editor.e4.handler;
2

  
3

  
4
import java.util.ArrayList;
5
import java.util.List;
6
import java.util.Scanner;
7

  
8
import javax.inject.Named;
9

  
10
import org.eclipse.e4.core.di.annotations.CanExecute;
11
import org.eclipse.e4.core.di.annotations.Execute;
12
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
13
import org.eclipse.e4.ui.services.IServiceConstants;
14
import org.eclipse.jface.dialogs.MessageDialog;
15
import org.eclipse.swt.dnd.TextTransfer;
16
import org.eclipse.swt.widgets.Shell;
17

  
18
import eu.etaxonomy.taxeditor.molecular.editor.AlignmentEditor;
19
import eu.etaxonomy.taxeditor.molecular.editor.e4.AlignmentEditorE4;
20
import eu.etaxonomy.taxeditor.molecular.l10n.Messages;
21
import info.bioinfweb.libralign.alignmentarea.AlignmentArea;
22
import info.bioinfweb.libralign.alignmentarea.order.SequenceOrder;
23
import info.bioinfweb.libralign.alignmentarea.selection.SelectionModel;
24
import info.bioinfweb.libralign.model.AlignmentModel;
25
import info.bioinfweb.libralign.model.utils.AlignmentModelUtils;
26

  
27

  
28

  
29
/**
30
 * Handler that pastes the current contents of the clipboard into an active instance of {@link AlignmentEditor}.
31
 *
32
 * @author Ben Stöver
33
 * @date 26.08.2015
34
 */
35
public class AlignmentEditorPasteHandlerE4 {
36

  
37
	private void pasteString(AlignmentArea area, String sequenceID, String content) {
38
		area.getActionProvider().deleteSelection();  // Overwrite selected tokens.
39
		area.getActionProvider().elongateSequence(sequenceID, area.getSelection().getCursorColumn());
40

  
41
		@SuppressWarnings("unchecked")
42
		AlignmentModel<Object> alignmentModel = (AlignmentModel<Object>)area.getAlignmentModel();
43
		alignmentModel.insertTokensAt(sequenceID, area.getSelection().getCursorColumn(),
44
				AlignmentModelUtils.charSequenceToTokenList(content, alignmentModel.getTokenSet(),
45
						true, alignmentModel.getTokenSet().getGapToken()));
46
	}
47

  
48

  
49
	@Execute
50
	protected void execute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart,
51
	        @Named(IServiceConstants.ACTIVE_SHELL)Shell shell) {
52
        AlignmentEditorE4 editor = (AlignmentEditorE4) activePart.getObject();
53
        AlignmentArea focusedArea = editor.getFocusedArea();
54

  
55
		SelectionModel selection = focusedArea.getSelection();
56
		String clipboardText = (String)editor.CLIPBOARD.getContents(TextTransfer.getInstance());
57
		if (clipboardText != null) {
58
			List<String> lines = new ArrayList<String>();
59
			Scanner scanner = new Scanner(clipboardText);
60
			try {
61
				while (scanner.hasNext()) {
62
					lines.add(scanner.nextLine());
63
				}
64
				if (lines.get(lines.size() - 1).equals("")) { //$NON-NLS-1$
65
					lines.remove(lines.size() - 1);
66
				}
67
			}
68
			finally {
69
				scanner.close();
70
			}
71

  
72
			if (!lines.isEmpty()) { //TODO Can lines be empty? (Can an empty string "" be copied to the clipboard?)
73
				if (selection.getCursorHeight() == 1) {  // If the consensus sequence is focused, this is the only possible case.
74
					String sequenceID = focusedArea.getSequenceOrder().idByIndex(selection.getCursorRow());
75
					if (lines.size() == 1) {
76
						pasteString(focusedArea, sequenceID, lines.get(0));
77
					}
78
					else {
79
						MessageDialog dialog = new MessageDialog(shell,
80
								Messages.AlignmentEditorPasteHandler_PASTING_LINES, null,
81
								String.format(Messages.AlignmentEditorPasteHandler_PASTING_LINES_QUESTION, lines.size()),
82
								MessageDialog.QUESTION,
83
								new String[]{Messages.AlignmentEditorPasteHandler_PASTING_LINES_IGNORE,
84
										Messages.AlignmentEditorPasteHandler_PASTING_LINES_FIRST_LINE, Messages.AlignmentEditorPasteHandler_CANCEL},
85
								0);
86
						//TODO Does the dialog have to be disposed in some way?
87

  
88
						switch (dialog.open()) {
89
							case 0:  // Paste all lines in one sequence.
90
								pasteString(focusedArea, sequenceID, clipboardText);
91
								break;
92
							case 1:  // Paste only first line.
93
								pasteString(focusedArea, sequenceID, lines.get(0));
94
								break;
95
						}
96
					}
97
				}
98
				else {
99
					if (selection.getCursorHeight() == lines.size()) {
100
						SequenceOrder order = focusedArea.getSequenceOrder();
101
						for (int i = 0; i < selection.getCursorHeight(); i++) {
102
							pasteString(focusedArea, order.idByIndex(selection.getCursorRow() + i), lines.get(i));  // Multiple calls of deleteSelection() in here are unnecessary, but should have no effect.
103
						}
104
					}
105
					else {
106
						MessageDialog.openError(shell,
107
								Messages.AlignmentEditorPasteHandler_PASTE_FAILURE,
108
								String.format(Messages.AlignmentEditorPasteHandler_PASTE_FAILURE_MESSAGE, selection.getCursorHeight(), lines.size(), System.getProperty("line.separator"))); //$NON-NLS-1$
109
					}
110
				}
111
			}
112
		}
113
	}
114

  
115

  
116
	@CanExecute
117
	public boolean isEnabled(@Named(IServiceConstants.ACTIVE_PART)MPart activePart) {
118
        AlignmentEditorE4 editor = (AlignmentEditorE4) activePart.getObject();
119
        AlignmentArea focusedArea = editor.getFocusedArea();
120
        focusedArea = editor.getFocusedArea();
121
        return (focusedArea != null);
122
	}
123

  
124
}
eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/editor/e4/handler/ChangePherogramQualityOutputTypeE4.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.editor.e4.handler;
10

  
11

  
12
import javax.inject.Named;
13

  
14
import org.eclipse.e4.core.di.annotations.Execute;
15
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
16
import org.eclipse.e4.ui.services.IServiceConstants;
17

  
18
import eu.etaxonomy.taxeditor.molecular.editor.e4.PherogramPartE4;
19

  
20

  
21

  
22
/**
23
 * Switches between the quality output types available for components displaying pherograms.
24
 *
25
 * @author Ben Stöver
26
 * @date 19.06.2015
27
 */
28
public class ChangePherogramQualityOutputTypeE4 {
29

  
30
    @Execute
31
    public void doExecute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart) {
32
        PherogramPartE4 pherogramPart = (PherogramPartE4) activePart.getObject();
33
        pherogramPart.getPherogramView().getTraceCurveView().getFormats().changeQualityOutputType();
34
    }
35
}
eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/editor/e4/handler/CreateConsensusSequenceHandlerE4.java
1
/**
2
* Copyright (C) 2007 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.editor.e4.handler;
10

  
11

  
12
import javax.inject.Named;
13

  
14
import org.eclipse.e4.core.di.annotations.Execute;
15
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
16
import org.eclipse.e4.ui.services.IServiceConstants;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff