X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Fjalview%2Fgui%2FSequenceFetcher.java;h=35bc29ad3eae2d53cc4d84987f425e87f7f354b3;hb=aec85d6dfc1dd5970a50a53dc9d161635d1e9960;hp=bf522ef2fe30f5c932b043ab9ff09f8f4c141d8c;hpb=02b7dff05a9e2b9ce6a95caed86be256da906d3f;p=jalview.git
diff --git a/src/jalview/gui/SequenceFetcher.java b/src/jalview/gui/SequenceFetcher.java
index bf522ef..35bc29a 100755
--- a/src/jalview/gui/SequenceFetcher.java
+++ b/src/jalview/gui/SequenceFetcher.java
@@ -1,19 +1,22 @@
/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
- * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
- *
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
+ * Copyright (C) 2014 The Jalview Authors
+ *
* This file is part of Jalview.
- *
+ *
* Jalview is free software: you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
- *
- * Jalview is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with Jalview. If not, see .
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see .
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
*/
package jalview.gui;
@@ -31,6 +34,7 @@ import com.stevesoft.pat.Regex;
import jalview.datamodel.*;
import jalview.io.*;
import jalview.util.DBRefUtils;
+import jalview.util.MessageManager;
import jalview.ws.dbsources.das.api.DasSourceRegistryI;
import jalview.ws.seqfetcher.DbSourceProxy;
import java.awt.BorderLayout;
@@ -61,7 +65,7 @@ public class SequenceFetcher extends JPanel implements Runnable
/**
* Blocking method that initialises and returns the shared instance of the
* SequenceFetcher client
- *
+ *
* @param guiWindow
* - where the initialisation delay message should be shown
* @return the singleton instance of the sequence fetcher client
@@ -74,7 +78,7 @@ public class SequenceFetcher extends JPanel implements Runnable
if (guiWindow != null)
{
guiWindow.setProgressBar(
- "Waiting for Sequence Database Fetchers to initialise",
+ MessageManager.getString("status.waiting_sequence_database_fetchers_init"),
Thread.currentThread().hashCode());
}
// initting happening on another thread - so wait around to see if it
@@ -93,7 +97,7 @@ public class SequenceFetcher extends JPanel implements Runnable
if (guiWindow != null)
{
guiWindow.setProgressBar(
- "Waiting for Sequence Database Fetchers to initialise",
+ MessageManager.getString("status.waiting_sequence_database_fetchers_init"),
Thread.currentThread().hashCode());
}
}
@@ -111,7 +115,7 @@ public class SequenceFetcher extends JPanel implements Runnable
*/
if (guiWindow != null)
{
- guiWindow.setProgressBar("Initialising Sequence Database Fetchers",
+ guiWindow.setProgressBar(MessageManager.getString("status.init_sequence_database_fetchers"),
Thread.currentThread().hashCode());
}
dasRegistry = jalview.bin.Cache.getDasSourceRegistry();
@@ -120,7 +124,7 @@ public class SequenceFetcher extends JPanel implements Runnable
jalview.ws.SequenceFetcher sf = new jalview.ws.SequenceFetcher();
if (guiWindow != null)
{
- guiWindow.setProgressBar("Initialising Sequence Database Fetchers",
+ guiWindow.setProgressBar(MessageManager.getString("status.init_sequence_database_fetchers"),
Thread.currentThread().hashCode());
}
lastDasSourceRegistry = (dasRegistry.getDasRegistryURL() + dasRegistry
@@ -157,8 +161,8 @@ public class SequenceFetcher extends JPanel implements Runnable
JOptionPane
.showInternalMessageDialog(
Desktop.desktop,
- "Could not create the sequence fetcher client. Check error logs for details.",
- "Couldn't create SequenceFetcher",
+ MessageManager.getString("warn.couldnt_create_sequence_fetcher_client"),
+ MessageManager.getString("label.couldnt_create_sequence_fetcher"),
JOptionPane.ERROR_MESSAGE);
}
});
@@ -182,7 +186,7 @@ public class SequenceFetcher extends JPanel implements Runnable
/**
* called by thread spawned by constructor
- *
+ *
* @param guiWindow
*/
private void initGui(IProgressIndicator guiWindow)
@@ -215,8 +219,7 @@ public class SequenceFetcher extends JPanel implements Runnable
private String getFrameTitle()
{
- return ((alignFrame == null) ? "New " : "Additional ")
- + "Sequence Fetcher";
+ return ((alignFrame == null) ? MessageManager.getString("label.new_sequence_fetcher") : MessageManager.getString("label.additional_sequence_fetcher"));
}
private void jbInit() throws Exception
@@ -227,13 +230,15 @@ public class SequenceFetcher extends JPanel implements Runnable
dbeg.setFont(new java.awt.Font("Verdana", Font.BOLD, 11));
jLabel1.setFont(new java.awt.Font("Verdana", Font.ITALIC, 11));
jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
- jLabel1.setText("Separate multiple accession ids with semi colon \";\"");
+ jLabel1.setText(MessageManager
+ .getString("label.separate_multiple_accession_ids"));
replacePunctuation.setHorizontalAlignment(SwingConstants.CENTER);
replacePunctuation
.setFont(new java.awt.Font("Verdana", Font.ITALIC, 11));
- replacePunctuation.setText("Replace commas with semi-colons");
- ok.setText("OK");
+ replacePunctuation.setText(MessageManager
+ .getString("label.replace_commas_semicolons"));
+ ok.setText(MessageManager.getString("action.ok"));
ok.addActionListener(new ActionListener()
{
@Override
@@ -242,7 +247,7 @@ public class SequenceFetcher extends JPanel implements Runnable
ok_actionPerformed();
}
});
- clear.setText("Clear");
+ clear.setText(MessageManager.getString("action.clear"));
clear.addActionListener(new ActionListener()
{
@Override
@@ -252,7 +257,7 @@ public class SequenceFetcher extends JPanel implements Runnable
}
});
- example.setText("Example");
+ example.setText(MessageManager.getString("label.example"));
example.addActionListener(new ActionListener()
{
@Override
@@ -261,7 +266,7 @@ public class SequenceFetcher extends JPanel implements Runnable
example_actionPerformed();
}
});
- close.setText("Close");
+ close.setText(MessageManager.getString("action.close"));
close.addActionListener(new ActionListener()
{
@Override
@@ -304,9 +309,12 @@ public class SequenceFetcher extends JPanel implements Runnable
+ database.getSelectedSources().size()
+ " others)" : ""));
String eq = database.getExampleQueries();
- dbeg.setText("Example query: " + eq);
- boolean enablePunct=!(eq != null && eq.indexOf(",") > -1);
- for (DbSourceProxy dbs:database.getSelectedSources()) {
+ dbeg.setText(MessageManager.formatMessage(
+ "label.example_query_param", new String[]
+ { eq }));
+ boolean enablePunct = !(eq != null && eq.indexOf(",") > -1);
+ for (DbSourceProxy dbs : database.getSelectedSources())
+ {
if (dbs instanceof jalview.ws.dbsources.das.datamodel.DasSequenceSource)
{
enablePunct = false;
@@ -405,7 +413,8 @@ public class SequenceFetcher extends JPanel implements Runnable
public void ok_actionPerformed()
{
- database.setEnabled(false);
+ databaseButt.setEnabled(false);
+ example.setEnabled(false);
textArea.setEnabled(false);
ok.setEnabled(false);
close.setEnabled(false);
@@ -416,7 +425,8 @@ public class SequenceFetcher extends JPanel implements Runnable
private void resetDialog()
{
- database.setEnabled(true);
+ databaseButt.setEnabled(true);
+ example.setEnabled(true);
textArea.setEnabled(true);
ok.setEnabled(true);
close.setEnabled(true);
@@ -457,7 +467,7 @@ public class SequenceFetcher extends JPanel implements Runnable
return;
}
// indicate if successive sources should be merged into one alignment.
- boolean addToLast=false;
+ boolean addToLast = false;
ArrayList aresultq = new ArrayList(), presultTitle = new ArrayList();
ArrayList presult = new ArrayList(), aresult = new ArrayList();
Iterator proxies = database.getSelectedSources()
@@ -483,8 +493,7 @@ public class SequenceFetcher extends JPanel implements Runnable
try
{
// update status
- guiWindow.setProgressBar("Fetching " + nqueries
- + " sequence queries from " + proxy.getDbName(), Thread
+ guiWindow.setProgressBar(MessageManager.formatMessage("status.fetching_sequence_queries_from", new String[]{Integer.valueOf(nqueries).toString(),proxy.getDbName()}), Thread
.currentThread().hashCode());
isAliSource = proxy.isA(DBRefSource.ALIGNMENTDB);
if (proxy.getAccessionSeparator() == null)
@@ -573,15 +582,21 @@ public class SequenceFetcher extends JPanel implements Runnable
DBRefEntry dbr = new DBRefEntry(), found[] = null;
dbr.setSource(proxy.getDbSource());
dbr.setVersion(null);
- if (proxy.getAccessionValidator()!=null) {
- Regex vgr=proxy.getAccessionValidator();
+ if (proxy.getAccessionValidator() != null)
+ {
+ Regex vgr = proxy.getAccessionValidator();
vgr.search(q);
- if (vgr.numSubs()>0) {
+ if (vgr.numSubs() > 0)
+ {
dbr.setAccessionId(vgr.stringMatched(1));
- } else {
+ }
+ else
+ {
dbr.setAccessionId(vgr.stringMatched());
}
- } else {
+ }
+ else
+ {
dbr.setAccessionId(q);
}
boolean rfound = false;
@@ -641,7 +656,7 @@ public class SequenceFetcher extends JPanel implements Runnable
AlignmentI ar = null;
if (isAliSource)
{
- addToLast=false;
+ addToLast = false;
// new window for each result
while (aresult.size() > 0)
{
@@ -652,11 +667,11 @@ public class SequenceFetcher extends JPanel implements Runnable
}
else
{
- String titl=null;
- if (addToLast && presult.size()>0)
+ String titl = null;
+ if (addToLast && presult.size() > 0)
{
- ar=presult.remove(presult.size()-1);
- titl=presultTitle.remove(presultTitle.size()-1);
+ ar = presult.remove(presult.size() - 1);
+ titl = presultTitle.remove(presultTitle.size() - 1);
}
// concatenate all results in one window
while (aresult.size() > 0)
@@ -671,14 +686,16 @@ public class SequenceFetcher extends JPanel implements Runnable
}
;
}
- addToLast=true;
+ addToLast = true;
presult.add(ar);
presultTitle.add(titl);
}
}
- guiWindow.setProgressBar("Finished querying", Thread.currentThread().hashCode());
+ guiWindow.setProgressBar(MessageManager.getString("status.finshed_querying"), Thread.currentThread()
+ .hashCode());
}
- guiWindow.setProgressBar((presult.size()>0) ? "Parsing results.":"Processing ..", Thread.currentThread().hashCode());
+ guiWindow.setProgressBar((presult.size() > 0) ? MessageManager.getString("status.parsing_results")
+ : MessageManager.getString("status.processing"), Thread.currentThread().hashCode());
// process results
while (presult.size() > 0)
{
@@ -692,14 +709,14 @@ public class SequenceFetcher extends JPanel implements Runnable
sb.append("Didn't retrieve the following "
+ (nextfetch.size() == 1 ? "query" : nextfetch.size()
+ " queries") + ": \n");
- int l = sb.length(),lr=0;
+ int l = sb.length(), lr = 0;
for (String s : nextfetch)
{
if (l != sb.length())
{
sb.append("; ");
}
- if (lr-sb.length()>40)
+ if (lr - sb.length() > 40)
{
sb.append("\n");
}
@@ -740,7 +757,7 @@ public class SequenceFetcher extends JPanel implements Runnable
}
/**
- *
+ *
* @return a standard title for any results retrieved using the currently
* selected source and settings
*/
@@ -791,7 +808,8 @@ public class SequenceFetcher extends JPanel implements Runnable
Desktop.addInternalFrame(af, title, AlignFrame.DEFAULT_WIDTH,
AlignFrame.DEFAULT_HEIGHT);
- af.statusBar.setText("Successfully pasted alignment file");
+ af.statusBar.setText(MessageManager
+ .getString("label.successfully_pasted_alignment_file"));
try
{
@@ -832,7 +850,8 @@ public class SequenceFetcher extends JPanel implements Runnable
public void run()
{
JOptionPane.showInternalMessageDialog(Desktop.desktop, error,
- "Error Retrieving Data", JOptionPane.WARNING_MESSAGE);
+ MessageManager.getString("label.error_retrieving_data"),
+ JOptionPane.WARNING_MESSAGE);
}
});
}