Changeset 12497
- Timestamp:
- 2006-08-22T15:13:47+12:00 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/cdm/download/ServerInfoDialog.java
r12468 r12497 10 10 import org.greenstone.gatherer.cdm.Argument; 11 11 import org.greenstone.gatherer.Configuration; 12 import org.greenstone.gatherer.DebugStream; 12 13 import org.greenstone.gatherer.Dictionary; 14 import org.greenstone.gatherer.LocalGreenstone; 13 15 import org.greenstone.gatherer.gui.*; 14 16 import org.greenstone.gatherer.cdm.download.Download; … … 17 19 public class ServerInfoDialog extends JDialog 18 20 { 21 static private Dimension SIZE = new Dimension(500, 300); 19 22 private String url; 20 23 private String mode; 21 24 private JPanel info_list_pane; 22 25 private JScrollPane info_scroll_pane; 23 private JDialog me;26 private JDialog info_dialog; 24 27 private Download download; 25 28 private String proxy_url; 26 29 27 30 public ServerInfoDialog(String url, String proxy_url, String mode, Download download) { 28 31 super(); … … 31 34 this.download = download; 32 35 this.proxy_url = proxy_url; 36 this.info_dialog = this; 37 38 this.setSize(SIZE); 33 39 34 this.setSize(300,400);35 36 JButton close_button = new GLIButton(Dictionary.get("Download.ServerInformation.close"),Dictionary.get("Download.ServerInformation.close_Tooltip")); 37 close_button.setEnabled(true); 38 close_button.setMnemonic(KeyEvent.VK_C);39 40 close_button.addActionListener(new CloseBtnListener());41 40 JButton close_button = new GLIButton(Dictionary.get("General.Close"),Dictionary.get("General.Close_Tooltip")); 41 close_button.setEnabled(true); 42 close_button.addActionListener(new ActionListener() { 43 public void actionPerformed(ActionEvent event) { 44 info_dialog.dispose(); 45 } 46 }); 47 42 48 JPanel button_pane = new JPanel(); 43 49 button_pane.setLayout(new FlowLayout()); … … 65 71 Container main_container = this.getContentPane(); 66 72 main_container.add(main_pane); 67 me = this; 73 74 // Show 75 Dimension screen_size = Configuration.screen_size; 76 setLocation((screen_size.width - SIZE.width) / 2, (screen_size.height - SIZE.height) / 2); 77 setVisible(true); 78 68 79 } 69 80 70 81 private void getServerInfo() 71 82 { 72 String command =""; 73 if (Utility.isWindows()) { 74 command = "perl -S \"" + Configuration.gsdl_path + "bin" + File.separator + "script" + File.separator + "downloadfrom.pl "+"\"" + " -info -download_mode " + mode + " "; 75 } 76 else{ 77 command =Configuration.gsdl_path + "bin" + File.separator + "script" + File.separator + "downloadfrom.pl -info -download_mode " + mode + " "; 83 ArrayList commands = new ArrayList(); 84 if (Utility.isWindows()) { 85 commands.add(Configuration.perl_path); 86 commands.add("-S"); 78 87 } 79 88 commands.add(LocalGreenstone.getBinScriptDirectoryPath()+"downloadfrom.pl"); 89 commands.add("-info"); 90 commands.add("-download_mode"); 91 commands.add(mode); 92 80 93 ArrayList all_arg = download.getArguments(true,false); 81 for (int i = 0; i < all_arg.size(); i++) {94 for (int i = 0; i < all_arg.size(); i++) { 82 95 Argument argument = (Argument) all_arg.get(i); 83 96 84 if(argument.isAssigned()) 85 { 86 command +="-" + argument.getName()+" "; 87 if(argument.getType() != Argument.FLAG) 88 { 89 command +=argument.getValue()+" "; 90 } 97 if(argument.isAssigned()) { 98 commands.add("-" + argument.getName()); 99 if(argument.getType() != Argument.FLAG) { 100 commands.add(argument.getValue()); 91 101 } 92 102 } 93 103 } 94 95 try { 96 String [] env = null; 97 Process prcs = null; 98 Runtime rt = Runtime.getRuntime(); 104 105 String[] command = (String[]) commands.toArray(new String[0]); 106 DebugStream.println("Getting server info: "+commands); 107 try { 108 String [] env = null; 109 Process prcs = null; 110 Runtime rt = Runtime.getRuntime(); 99 111 100 112 if (Utility.isWindows()) { 101 113 prcs = rt.exec(command); 102 114 } 103 else {104 //for lunix115 else { 116 ArrayList env_list = new ArrayList(); 105 117 if (proxy_url != null && !proxy_url.equals("")) { 106 env = new String[4];107 118 proxy_url = proxy_url.replaceAll("http://",""); 108 env[0] = "http_proxy=http://"+proxy_url; 109 env[1] = "ftp_proxy=ftp://"+proxy_url; 110 env[2] = "GSDLHOME="+Configuration.gsdl_path; 111 env[3] = "GSDLOS="+System.getProperty("os.name"); 112 prcs = rt.exec(command,env); 113 } 114 else{ 115 env = new String[2]; 116 117 env[0] = "GSDLHOME="+Configuration.gsdl_path; 118 env[1] = "GSDLOS="+System.getProperty("os.name"); 119 prcs = rt.exec(command,env); 120 } 119 env_list.add("http_proxy=http://"+proxy_url); 120 env_list.add("ftp_proxy=ftp://"+proxy_url); 121 } 122 env_list.add("GSDLHOME="+Configuration.gsdl_path); 123 env_list.add("GSDLOS="+System.getProperty("os.name")); 124 env = (String []) env_list.toArray(new String[0]); 125 prcs = rt.exec(command,env); 126 121 127 } 122 128 123 // System.out.println(command); 124 125 InputStreamReader isr = new InputStreamReader(prcs.getErrorStream()); 129 InputStreamReader isr = new InputStreamReader(prcs.getErrorStream()); 126 130 BufferedReader br = new BufferedReader(isr); 127 131 String line; … … 133 137 info_list_pane.add(a_label); 134 138 } 135 }catch (Exception ioe) { 139 140 } catch (Exception ioe) { 136 141 137 142 } 138 143 139 144 } 140 145 141 private class CloseBtnListener implements ActionListener142 {143 public void actionPerformed(ActionEvent event)144 {145 me.dispose();146 }147 }148 149 146 }
Note:
See TracChangeset
for help on using the changeset viewer.