Merge branch 'develop' into LibrAlign
authorPatrick Plitzner <p.plitzner@bgbm.org>
Tue, 12 Apr 2016 08:03:42 +0000 (10:03 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Tue, 12 Apr 2016 08:03:42 +0000 (10:03 +0200)
1  2 
.gitattributes
eu.etaxonomy.taxeditor.molecular/plugin.xml
eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/editor/AlignmentEditor.java

diff --cc .gitattributes
@@@ -1894,3 -1969,19 +1973,19 @@@ src/site/fml/troubleshooting.fml -tex
  src/site/resources/css/site.css -text
  src/site/resources/images/taxeditor_transformed.png -text
  src/site/site.xml -text
 -eu.etaxonomy.taxeditor/eu.etaxonomy.taxeditor.product.with.jre merge=ours
+ # The following files will be ignored when merging another
+ # branch into this branch in case of merge conflict and 
+ # if the 'ours' merge driver is configured.
+ # WARNING : This merge driver should NOT be set in development
+ #           environments. It is supposed to be used only in CI
+ #           environments.
+ # The driver can be configured by executing,
+ # git config --local merge.ours.driver true
+ **/pom.xml merge=ours
+ **/MANIFEST.MF merge=ours
+ **/feature.xml merge=ours
+ eu.etaxonomy.taxeditor.cdmlib/.classpath merge=ours
+ eu.etaxonomy.taxeditor.cdmlib/build.properties merge=ours
+ eu.etaxonomy.taxeditor/eu.etaxonomy.taxeditor.product merge=ours
++eu.etaxonomy.taxeditor/eu.etaxonomy.taxeditor.product.with.jre merge=ours
@@@ -129,9 -128,6 +129,9 @@@ public class AlignmentEditor extends Ed
                                        setDirty();
                                }
                        };
-       public final Clipboard CLIPBOARD = new Clipboard(Display.getCurrent());  //TODO Move to global EDITor class. 
-                       
 +      private final AlignmentEditorActionUpdater ACTION_UPDATER = new AlignmentEditorActionUpdater();
++      public final Clipboard CLIPBOARD = new Clipboard(Display.getCurrent());  //TODO Move to global EDITor class.
++
  
      private MultipleAlignmentsContainer alignmentsContainer = null;
      private final Map<Integer, SingleReadAlignment> cdmMap = new TreeMap<Integer, SingleReadAlignment>();  //TODO Move this to ContigSequenceDataProvider
                }
      }
  
-     
      private void registerEditSettingListener(MultipleAlignmentsContainer container) {
 -      container.getEditSettings().addListener(new EditSettingsListener() {
 -                                      @Override
 -                                      public void workingModeChanged(EditSettingsChangeEvent e) {}  // Currently nothing to do
 -
 -                                      @Override
 -                                      public void insertLeftInDataAreaChanged(EditSettingsChangeEvent e) {
 -                                              updateStatusBar();
 -                                      refreshToolbarElement(ToggleLeftRightInsertionHandler.COMMAND_ID);
 -                                      }
 -
 -                                      @Override
 -                                      public void insertChanged(EditSettingsChangeEvent e) {
 -                                              updateStatusBar();
 -                                      refreshToolbarElement(ToggleInsertOverwriteHandler.COMMAND_ID);
 -                                      }
 -                              });
 +        container.getEditSettings().addListener(new EditSettingsListener() {
 +            @Override
 +            public void workingModeChanged(EditSettingsChangeEvent e) {}  // Currently nothing to do
 +
 +            @Override
 +            public void insertLeftInDataAreaChanged(EditSettingsChangeEvent e) {
 +                updateStatusBar();
 +                refreshToolbarElement(ToggleLeftRightInsertionHandler.COMMAND_ID);
 +            }
 +
 +            @Override
 +            public void insertChanged(EditSettingsChangeEvent e) {
 +                updateStatusBar();
 +                refreshToolbarElement(ToggleInsertOverwriteHandler.COMMAND_ID);
 +            }
 +        });
      }
  
  
      private AlignmentArea createConsensusHintArea(MultipleAlignmentsContainer container,
                AlignmentArea labeledArea) {
  
 -              AlignmentArea result = new AlignmentArea(container);
 -              result.setAllowVerticalScrolling(false);
 -              result.getDataAreas().getBottomAreas().add(
 -                              new ConsensusSequenceArea(result.getContentArea(), labeledArea));
 -              return result;
 -        }
 +              AlignmentArea result = new AlignmentArea(container);
 +              result.setAllowVerticalScrolling(false);
 +              result.getDataAreas().getBottomAreas().add(
 +                              new ConsensusSequenceArea(result.getContentArea(), labeledArea));
 +              return result;
 +    }
  
-     
      private MultipleAlignmentsContainer getAlignmentsContainer() {
        if (alignmentsContainer == null) {
                alignmentsContainer = new MultipleAlignmentsContainer();
-               
                AlignmentAreaList list = alignmentsContainer.getAlignmentAreas();
                AlignmentArea readsArea = createEditableAlignmentArea(alignmentsContainer, true);
 +              readsArea.getSelection().addSelectionListener(ACTION_UPDATER);
            list.add(createIndexArea(alignmentsContainer, readsArea));
                list.add(readsArea);  // Make sure READS_AREA_INDEX is correct.
 -              list.add(createEditableAlignmentArea(alignmentsContainer, false));  // Make sure COMSENSUS_AREA_INDEX is correct.
 +              AlignmentArea editableConsensusArea = createEditableAlignmentArea(alignmentsContainer, false);
 +              editableConsensusArea.getSelection().addSelectionListener(ACTION_UPDATER);
 +              list.add(editableConsensusArea);  // Make sure COMSENSUS_AREA_INDEX is correct.
                list.add(createConsensusHintArea(alignmentsContainer, readsArea));
-               
                registerEditSettingListener(alignmentsContainer);
                }
                return alignmentsContainer;
        return getAlignmentsContainer().getAlignmentAreas().get(READS_AREA_INDEX);
      }
  
-     
 -    private AlignmentArea getEditableConsensusArea() {
 +    public AlignmentArea getEditableConsensusArea() {
        return getAlignmentsContainer().getAlignmentAreas().get(EDITABLE_CONSENSUS_AREA_INDEX);
      }
-     
-     
 +    /**
 +     * Checks whether {@link #getReadsArea()} or {@link #getEditableConsensusArea()} currently
-      * have the user focus and returns the according component. 
-      * 
++     * have the user focus and returns the according component.
++     *
 +     * @return either the reads or the consensus alignment area or {@code null} if none of these
 +     *         components is currently focused
 +     */
 +    public AlignmentArea getFocusedArea() {
 +      AlignmentArea result = getReadsArea();
 +      if (hasFocus(result)) {
 +              return result;
 +      }
 +      else {
 +              result = getEditableConsensusArea();
 +              if (hasFocus(result)) {
 +                      return result;
 +              }
 +              else {
 +                      return null;
 +              }
 +      }
 +    }
-     
-     
++
++
 +    /**
 +     * Checks whether the specified alignment area or one of its subcomponents currently has the
 +     * focus.
-      * 
-      * @param area the alignment area to be checked (Can only be {@link #getReadsArea()} or 
++     *
++     * @param area the alignment area to be checked (Can only be {@link #getReadsArea()} or
 +     *        {@link #getEditableConsensusArea()}.)
 +     * @return {@code true} if the specified component is focused and is either equal to
 +     *         {@link #getReadsArea()} or {@link #getEditableConsensusArea()}or {@code false} otherwise
 +     */
 +    private boolean hasFocus(AlignmentArea area) {
 +      return SWTUtils.childHasFocus((Composite)area.getToolkitComponent());
 +    }
-     
-     
++
++
      public boolean hasPherogram(int sequenceID) {
          return getReadsArea().getDataAreas().getSequenceAreas(sequenceID).size() > PHEROGRAM_AREA_INDEX;
      }
                //TODO Can the consensus sequence also be null? / Should it be created here, if nothing is in the DB?
      }
  
-     
 -      /* (non-Javadoc)
 -     * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
 -     */
      @Override
      public void createPartControl(Composite parent) {
                SWTComponentFactory.getInstance().getSWTComponent(getAlignmentsContainer(), parent, SWT.NONE);
                }
        }
  
-     
 -    private void updateStatusBar() {
 +    @Override
 +      public void dispose() {
 +              Display.getCurrent().removeFilter(SWT.FocusIn, ACTION_UPDATER);
 +              Display.getCurrent().removeFilter(SWT.FocusOut, ACTION_UPDATER);
 +              CLIPBOARD.dispose();
++        ((AlignmentEditorInput)getEditorInput()).dispose();
 +              super.dispose();
 +      }
 +
 +
 +      private void updateStatusBar() {
          IActionBars bars = getEditorSite().getActionBars();
          bars.getStatusLineManager().setMessage("Edit mode: " +
                        (getReadsArea().getEditSettings().isInsert() ? "Insert" : "Overwrite") + "  " +
        return shifts.toArray(new Shift[]{});
      }
  
-     
 -    /* (non-Javadoc)
 -     * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
 -     */
      @Override
      public void doSave(IProgressMonitor monitor) {
        if (getEditorInput() instanceof AlignmentEditorInput) {
        }
      }
  
-     
 -    /* (non-Javadoc)
 -     * @see org.eclipse.ui.part.EditorPart#doSaveAs()
 -     */
      @Override
      public void doSaveAs() {}
  
-     
 -    /* (non-Javadoc)
 -     * @see org.eclipse.ui.part.EditorPart#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)
 -     */
      @Override
      public void init(IEditorSite site, IEditorInput input) throws PartInitException {
          setSite(site);
          setInput(input);
 -        System.out.println("AlignmentEditor.init(): " + ActionFactory.COPY.getId());
 -        site.getActionBars().setGlobalActionHandler(ActionFactory.COPY.getId(), new Action(ActionFactory.COPY.getId()) {
 -            @Override
 -            public boolean isEnabled() {
 -                System.out.println("isEnabled()");
 -                return true;
 -            }
 -
 -            @Override
 -            public void run() {
 -                System.out.println("run");
 -                    super.run();
 -                }
 -            });
      }
  
-     
 -    /* (non-Javadoc)
 -     * @see org.eclipse.ui.part.EditorPart#isDirty()
 -     */
      @Override
      public boolean isDirty() {
          return dirty;
        firePropertyChange(IEditorPart.PROP_DIRTY);
      }
  
-     
 -    /* (non-Javadoc)
 -     * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
 -     */
      @Override
      public boolean isSaveAsAllowed() {
          return false;  // "Save as" not allowed.
      }
  
-     
      @Override
      public void setFocus() {
 -        if(conversationHolder!=null){
 +        if(conversationHolder != null){
              conversationHolder.bind();
          }
+         ((AlignmentEditorInput)getEditorInput()).bind();
      }
  
-     
 -    @Override
 -    public void dispose() {
 -        ((AlignmentEditorInput)getEditorInput()).dispose();
 -    }
 -
      public boolean isInsertMode() {
          return getAlignmentsContainer().getEditSettings().isInsert();
      }