package jalview.ext.cipres;
-/**
- * Example originally from cipres_java_client (Example.java there)
- */
-import java.io.Console;
+import jalview.bin.Cache;
+import jalview.io.JalviewFileChooser;
+
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
+import javax.swing.JOptionPane;
+
import org.ngbw.directclient.CiApplication;
import org.ngbw.directclient.CiCipresException;
import org.ngbw.directclient.CiClient;
import org.ngbw.directclient.CiJob;
import org.ngbw.directclient.CiResultFile;
-import org.ngbw.directclient.example.Example;
import org.ngbw.restdatatypes.ErrorData;
import org.ngbw.restdatatypes.LimitStatus;
import org.ngbw.restdatatypes.ParamError;
{
@SuppressWarnings("unused")
private static final Logger log = LoggerFactory
- .getLogger(Example.class.getName());
-
- private static Console console = System.console();
+ .getLogger(CipresExample.class.getName());
private static String entry;
public static void main(String[] args) throws Exception
{
- if (console == null)
- {
- System.out.println("No console");
- return;
- }
// If true, the example will use umbrella authentication
if (args.length > 0 && args[0].equals("-u"))
umbrella = true;
}
- // Copy example fasta file from jar to temp file on disk
- fastaFile = copyResource("ex1.fasta");
+ JalviewFileChooser chooser = new JalviewFileChooser(
+ Cache.getProperty("LAST_DIRECTORY")
+ );
+ int value = chooser.showOpenDialog(null);
+ if (value == JalviewFileChooser.APPROVE_OPTION)
+ {
+ fastaFile = chooser.getSelectedFile().getPath();
+ }
+ else
+ {
+ System.exit(0);
+ }
+
// Get username, password, app name, app id, url from pycipes.conf
CiApplication app = CiApplication.getInstance();
{
if (umbrella)
{
- System.out.println(
- "\nEnter s(submit), v(validate), l(list), d(delete), j(job status), r(retrieve results), t(show tools), u(change end user) or q(quit):");
+ command = JOptionPane.showInputDialog(
+ "\nEnter s(submit), v(validate), l(list), d(delete), j(job status), r(retrieve results), t(show tools), u(change end user) or q(quit):"
+ );
}
else
{
- System.out.println(
- "\nEnter s(submit), v(validate), l(list), d(delete), j(job status), r(retrieve results) or t(show tools) or q(quit):");
+ command = JOptionPane.showInputDialog(
+ "\nEnter s(submit), v(validate), l(list), d(delete), j(job status), r(retrieve results) or t(show tools) or q(quit):"
+ );
}
- command = console.readLine();
try
{
if (command.equals("q"))
private static void submitJob() throws CiCipresException
{
- System.out.println(
- "Will submit an example clustalw job. Enter a name for the job or enter a single 'n' to cancel");
- entry = console.readLine();
+
+ entry = JOptionPane.showInputDialog(
+ "Will submit an example clustalw job. Enter a name for the job or enter a single 'n' to cancel"
+ );
if (entry.equals("n"))
{
return;
private static void deleteJob() throws CiCipresException
{
- System.out.println("Enter url of job to delete or n(no, cancel)");
- entry = console.readLine();
+ entry = JOptionPane
+ .showInputDialog("Enter url of job to delete or n(no, cancel)"
+ );
if (!entry.startsWith("http"))
{
return;
throws CiCipresException, IOException
{
boolean finalResults = true;
- System.out.println("Enter url of job or n(no, cancel)");
- entry = console.readLine();
+ entry = JOptionPane
+ .showInputDialog("Enter url of job or n(no, cancel)"
+ );
if (!entry.startsWith("http"))
{
return;
CiJob job = myClient.getJob(entry);
if (job.isDone() == false)
{
- System.out.println(
- "Job is not finished. Enter y(yes, get working dir contents) or n(no, cancel)");
- entry = console.readLine();
+ entry = JOptionPane.showInputDialog(
+ "Job is not finished. Enter y(yes, get working dir contents) or n(no, cancel)"
+ );
if (entry.equals("n"))
{
return;
System.out.println(count + ". " + file.getName() + " ("
+ file.getLength() + " bytes )");
}
- System.out.println(
- "Enter name of file to download or a(all) or n(no, cancel)");
- entry = console.readLine();
+ entry = JOptionPane.showInputDialog(
+ "Enter name of file to download or a(all) or n(no, cancel)"
+ );
boolean all = false;
if (entry.equals("a"))
{
{
if (!umbrella)
{
- System.out.println("Enter jobhandle or n(no, cancel)");
- entry = console.readLine();
+ entry = JOptionPane
+ .showInputDialog("Enter jobhandle or n(no, cancel)"
+ );
if (!entry.startsWith("NGBW"))
{
return;
single job, using a CiClient configured for the owner of the job.
*/
- System.out.println(
- "Enter comma separated list of jobhandles or n(no, cancel)");
- entry = console.readLine();
+ entry = JOptionPane.showInputDialog(
+ "Enter comma separated list of jobhandles or n(no, cancel)"
+ );
if (!entry.startsWith("NGBW"))
{
return;
{
InputStream is;
- is = Example.class.getResourceAsStream("/" + name);
+ is = CipresExample.class.getResourceAsStream(name);
File dest = File.createTempFile("Example", ".txt");
dest.deleteOnExit();
System.out.println(
"\nEnter information about the current end user of this application.");
- System.out.println("Enter username or q(quit)");
- String username = console.readLine();
+ String username = JOptionPane
+ .showInputDialog("Enter username or q(quit)"
+ );
if (username.equals("q"))
{
return null;
}
- System.out.println("Enter user's email address or q(quit)");
- String email = console.readLine();
+ String email = JOptionPane
+ .showInputDialog("Enter user's email address or q(quit)"
+ );
if (email.equals("q"))
{
return null;
}
- System.out.println("Enter user's institution or q(quit)");
- String institution = console.readLine();
+ String institution = JOptionPane
+ .showInputDialog("Enter user's institution or q(quit)"
+ );
if (institution.equals("q"))
{
return null;
}
- System.out.println(
- "Enter user's country code (must be 2 letters, both uppercase) or q(quit)");
- String country = console.readLine();
+ String country = JOptionPane.showInputDialog(
+ "Enter user's country code (must be 2 letters, both uppercase) or q(quit)"
+ );
if (country.equals("q"))
{
return null;