001/* 002 * BioJava development code 003 * 004 * This code may be freely distributed and modified under the 005 * terms of the GNU Lesser General Public Licence. This should 006 * be distributed with the code. If you do not have a copy, 007 * see: 008 * 009 * http://www.gnu.org/copyleft/lesser.html 010 * 011 * Copyright for this code is held jointly by the individual 012 * authors. These should be listed in @author doc comments. 013 * 014 * For more information on the BioJava project and its aims, 015 * or to join the biojava-l mailing list, visit the home page 016 * at: 017 * 018 * http://www.biojava.org/ 019 * 020 */ 021package org.biojava.nbio.structure.align.webstart; 022 023import org.biojava.nbio.structure.align.FarmJob; 024import org.biojava.nbio.structure.align.client.FarmJobParameters; 025import org.biojava.nbio.structure.align.gui.GUIFarmJobRunnable; 026import org.biojava.nbio.structure.align.util.CliTools; 027import org.biojava.nbio.structure.align.util.ConfigurationException; 028 029import javax.swing.*; 030import java.util.Arrays; 031import java.util.List; 032 033 034 035 036/** A Web Start wrapper for a FarmJobRunnable. 037 * 038 */ 039public class WebStartDBSearch { 040 041 private static final String[] mandParams = new String[] {"pdbFilePath"}; 042 043 private static final List<String> mandatoryArgs= Arrays.asList(mandParams); 044 045 public WebStartDBSearch(){ 046 } 047 048 049 050 public static void main(String[] argv) { 051 052 FarmJob job = new FarmJob(); 053 054 055 if (argv.length == 0 ) { 056 job.printHelp(); 057 JOptionPane.showMessageDialog(null, 058 "Not enough arguments!"); 059 return; 060 061 062 } 063 064 if ( argv.length == 1){ 065 if (argv[0].equalsIgnoreCase("-h") || argv[0].equalsIgnoreCase("-help")|| argv[0].equalsIgnoreCase("--help")){ 066 job.printHelp(); 067 JOptionPane.showMessageDialog(null, 068 "Help not supported..."); 069 return; 070 } 071 } 072 073 FarmJobParameters params = new FarmJobParameters(); 074 075 076 for (int i = 0 ; i < argv.length; i++){ 077 String arg = argv[i]; 078 079 String value = null; 080 if ( i < argv.length -1) 081 value = argv[i+1]; 082 083 // if value starts with - then the arg does not have a value. 084 if (value != null && value.startsWith("-")) 085 value = null; 086 else 087 i++; 088 089 090 String[] tmp = {arg,value}; 091 092 try { 093 094 CliTools.configureBean(params, tmp); 095 096 } catch (ConfigurationException e){ 097 098 e.printStackTrace(); 099 100 if ( mandatoryArgs.contains(arg) ) { 101 // there must not be a ConfigurationException with mandatory arguments. 102 JOptionPane.showMessageDialog(null, 103 e.getMessage()); 104 return; 105 106 } else { 107 // but there can be with optional ... 108 } 109 } 110 } 111 112 params.setRunBackground(true); 113 GUIFarmJobRunnable runnable = new GUIFarmJobRunnable(params); 114 115 //javax.swing.SwingUtilities.invokeLater(runnable); 116 runnable.run(); 117 118 119 120 121 } 122 123 124}