Merge branch 'Jalview-BH/JAL-3026-JAL-3063-JAXB' into trialMerge feature/JAL-3144noJTree
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 31 Oct 2018 16:30:24 +0000 (16:30 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 31 Oct 2018 16:30:24 +0000 (16:30 +0000)
Conflicts:
src/jalview/ext/ensembl/EnsemblRestClient.java
swingjs/timestamp

1  2 
src/jalview/ext/ensembl/EnsemblRestClient.java
src/jalview/gui/AlignFrame.java
swingjs/timestamp
utils/eclipse/JalviewCodeStyle.xml

@@@ -20,9 -20,6 +20,9 @@@
   */
  package jalview.ext.ensembl;
  
 +import jalview.bin.Jalview;
 +import jalview.io.DataSourceType;
 +import jalview.io.FileParse;
  import jalview.util.StringUtils;
  
  import java.io.BufferedReader;
@@@ -67,9 -64,9 +67,9 @@@ abstract class EnsemblRestClient extend
     * @see https://github.com/Ensembl/ensembl-rest/wiki/Change-log
     * @see http://rest.ensembl.org/info/rest?content-type=application/json
     */
-   private static final String LATEST_ENSEMBLGENOMES_REST_VERSION = "6.3";
+   private static final String LATEST_ENSEMBLGENOMES_REST_VERSION = "7.0";
  
-   private static final String LATEST_ENSEMBL_REST_VERSION = "6.3";
+   private static final String LATEST_ENSEMBL_REST_VERSION = "7.0";
  
    private static final String REST_CHANGE_LOG = "https://github.com/Ensembl/ensembl-rest/wiki/Change-log";
  
    protected abstract boolean useGetRequest();
  
    /**
-    * Return the desired value for the Content-Type request header
-    * 
-    * @param multipleIds
+    * Returns the desired value for the Content-Type request header. Default is
+    * application/json, override if required to vary this.
     * 
     * @return
     * @see https://github.com/Ensembl/ensembl-rest/wiki/HTTP-Headers
     */
-   protected abstract String getRequestMimeType(boolean multipleIds);
+   protected String getRequestMimeType()
+   {
+     return "application/json";
+   }
  
    /**
-    * Return the desired value for the Accept request header
+    * Return the desired value for the Accept request header. Default is
+    * application/json, override if required to vary this.
     * 
     * @return
     * @see https://github.com/Ensembl/ensembl-rest/wiki/HTTP-Headers
     */
-   protected abstract String getResponseMimeType();
+   protected String getResponseMimeType()
+   {
+     return "application/json";
+   }
  
    /**
     * Checks Ensembl's REST 'ping' endpoint, and returns true if response
    }
  
    /**
-    * returns a reader to a Fasta response from the Ensembl sequence endpoint
+    * Returns a reader to a (Json) response from the Ensembl sequence endpoint.
+    * If the request failed the return value may be null.
     * 
     * @param ids
     * @return
     * @throws IOException
     */
-   protected FileParse getSequenceReader(List<String> ids) throws IOException
+   protected BufferedReader getSequenceReader(List<String> ids)
+           throws IOException
    {
      URL url = getUrl(ids);
  
      BufferedReader reader = getHttpResponse(url, ids);
-     if (reader == null)
-     {
-       // request failed
-       return null;
-     }
-     FileParse fp = new FileParse(reader, url.toString(),
-             DataSourceType.URL);
-     return fp;
+     return reader;
    }
  
    /**
      boolean multipleIds = ids != null && ids.size() > 1;
      connection.setRequestMethod(
              multipleIds ? HttpMethod.POST : HttpMethod.GET);
-     connection.setRequestProperty("Content-Type",
-             getRequestMimeType(multipleIds));
+     connection.setRequestProperty("Content-Type", getRequestMimeType());
      connection.setRequestProperty("Accept", getResponseMimeType());
  
      connection.setDoInput(true);
      connection.setDoOutput(multipleIds);
  
 -    connection.setConnectTimeout(CONNECT_TIMEOUT_MS);
 -    connection.setReadTimeout(readTimeout);
 +    if (!Jalview.isJS()) 
 +    {
 +      connection.setUseCaches(false);
 +      connection.setConnectTimeout(CONNECT_TIMEOUT_MS);
 +      connection.setReadTimeout(readTimeout);
 +    }
  
      if (multipleIds)
      {
@@@ -760,9 -760,9 +760,9 @@@ public class AlignFrame extends GAlignF
  
      int aSize = alignPanels.size();
  
-     tabbedPane.setVisible(aSize > 1 || ap.av.viewName != null);
+     tabbedPane.setVisible(aSize > 1 || ap.av.getViewName() != null);
  
-     if (aSize == 1 && ap.av.viewName == null)
+     if (aSize == 1 && ap.av.getViewName() == null)
      {
        this.getContentPane().add(ap, BorderLayout.CENTER);
      }
  
        expandViews.setEnabled(true);
        gatherViews.setEnabled(true);
-       tabbedPane.addTab(ap.av.viewName, ap);
+       tabbedPane.addTab(ap.av.getViewName(), ap);
  
        ap.setVisible(false);
      }
      gatherViews.setEnabled(true);
      tabbedPane.setVisible(true);
      AlignmentPanel first = alignPanels.get(0);
-     tabbedPane.addTab(first.av.viewName, first);
+     tabbedPane.addTab(first.av.getViewName(), first);
      this.getContentPane().add(tabbedPane, BorderLayout.CENTER);
    }
  
     * @param av
     *          AlignViewport
     */
-   void setMenusFromViewport(AlignViewport av)
+   public void setMenusFromViewport(AlignViewport av)
    {
      padGapsMenuitem.setSelected(av.isPadGaps());
      colourTextMenuItem.setSelected(av.isShowColourText());
    }
  
    @Override
 -  public void fetchSequence_actionPerformed(ActionEvent e)
 +  public void fetchSequence_actionPerformed()
    {
 -    new jalview.gui.SequenceFetcher(this);
 +    new SequenceFetcher(this);
    }
  
    @Override
          shortName = shortName.substring(
                  shortName.lastIndexOf(File.separatorChar) + 1);
        }
-       lastSaveSuccessful = new Jalview2XML().saveAlignment(this, file,
+       lastSaveSuccessful = new jalview.project.Jalview2XML().saveAlignment(this, file,
                shortName);
+       
+       statusBar.setText(MessageManager.formatMessage(
+               "label.successfully_saved_to_file_in_format", new Object[]
+               { fileName, format }));
+       
        return;
      }
  
      /*
       * Create a new AlignmentPanel (with its own, new Viewport)
       */
-     AlignmentPanel newap = new Jalview2XML().copyAlignPanel(alignPanel);
+     AlignmentPanel newap = new jalview.project.Jalview2XML()
+             .copyAlignPanel(alignPanel);
      if (!copyAnnotation)
      {
        /*
  
      newap.av.setGatherViewsHere(false);
  
-     if (viewport.viewName == null)
+     if (viewport.getViewName() == null)
      {
-       viewport.viewName = MessageManager
-               .getString("label.view_name_original");
+       viewport.setViewName(MessageManager
+               .getString("label.view_name_original"));
      }
  
      /*
        newap.refresh(true); // adjust layout of annotations
      }
  
-     newap.av.viewName = getNewViewName(viewTitle);
+     newap.av.setViewName(getNewViewName(viewTitle));
  
      addAlignmentPanel(newap, true);
      newap.alignmentChanged();
        if (comp instanceof AlignmentPanel)
        {
          AlignmentPanel ap = (AlignmentPanel) comp;
-         if (!existingNames.contains(ap.av.viewName))
+         if (!existingNames.contains(ap.av.getViewName()))
          {
-           existingNames.add(ap.av.viewName);
+           existingNames.add(ap.av.getViewName());
          }
        }
      }
  
      frameTitle += " from ";
  
-     if (viewport.viewName != null)
+     if (viewport.getViewName() != null)
      {
-       frameTitle += viewport.viewName + " of ";
+       frameTitle += viewport.getViewName() + " of ";
      }
  
      frameTitle += this.title;
  
        if (reply != null)
        {
-         viewport.viewName = reply;
+         viewport.setViewName(reply);
          // TODO warn if reply is in getExistingViewNames()?
          tabbedPane.setTitleAt(tabbedPane.getSelectedIndex(), reply);
        }
  
      });
      rfetch.add(fetchr);
 -    final AlignFrame me = this;
      new Thread(new Runnable()
      {
        @Override
        public void run()
        {
          final jalview.ws.SequenceFetcher sf = jalview.gui.SequenceFetcher
 -                .getSequenceFetcherSingleton(me);
 +                .getSequenceFetcherSingleton();
          javax.swing.SwingUtilities.invokeLater(new Runnable()
          {
            @Override
            public void run()
            {
 -            String[] dbclasses = sf.getOrderedSupportedSources();
 -            // sf.getDbInstances(jalview.ws.dbsources.DasSequenceSource.class);
 -            // jalview.util.QuickSort.sort(otherdb, otherdb);
 +            String[] dbclasses = sf.getNonAlignmentSources();
              List<DbSourceProxy> otherdb;
              JMenu dfetch = new JMenu();
              JMenu ifetch = new JMenu();
                {
                  continue;
                }
 -              // List<DbSourceProxy> dbs=otherdb;
 -              // otherdb=new ArrayList<DbSourceProxy>();
 -              // for (DbSourceProxy db:dbs)
 -              // {
 -              // if (!db.isA(DBRefSource.ALIGNMENTDB)
 -              // }
                if (mname == null)
                {
                  mname = "From " + dbclass;
    {
      if (avc.createGroup())
      {
+       if (applyAutoAnnotationSettings.isSelected())
+       {
+         alignPanel.updateAnnotation(true, false);
+       }
        alignPanel.alignmentChanged();
      }
    }
     */
    public List<? extends AlignmentViewPanel> getAlignPanels()
    {
-     return alignPanels == null ? Arrays.asList(alignPanel) : alignPanels;
+     // alignPanels is never null
+     // return alignPanels == null ? Arrays.asList(alignPanel) : alignPanels;
+     return alignPanels;
    }
  
    /**
diff --combined swingjs/timestamp
@@@ -1,1 -1,1 +1,1 @@@
--20181030183630 
++20181030183630
  <setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/>
  <setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
  <setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="false"/>
--<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="8"/>
++<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="2"/>
  <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field" value="insert"/>
  <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable" value="insert"/>
  <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method" value="insert"/>