- Timestamp:
- 2004-01-27T16:35:34+13:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/gui/MirrorPane.java
r6590 r6622 51 51 import org.greenstone.gatherer.file.FileNode; 52 52 import org.greenstone.gatherer.gui.GLIButton; 53 import org.greenstone.gatherer.gui.URLField; 54 import org.greenstone.gatherer.util.StaticStrings; 53 55 import org.greenstone.gatherer.util.Utility; 54 56 … … 60 62 extends JPanel { 61 63 64 private boolean download_button_enabled = false; 65 private boolean ready = false; 62 66 private JButton download_button; 63 67 private JCheckBox higher_checkbox; … … 66 70 private JScrollPane list_scroll; 67 71 private JComboBox depth_combobox; 68 private JTextField url_textfield;72 private URLField url_field; 69 73 private Vector depth_model; 70 74 private WGet getter; … … 86 90 url_label.setPreferredSize(Utility.LABEL_SIZE); 87 91 Dictionary.registerText(url_label, "Mirroring.Source_URL"); 88 url_ textfield = new JTextField();89 Dictionary.registerTooltip(url_ textfield, "Mirroring.Source_URL_Tooltip");92 url_field = new URLField(Gatherer.config.getColor("coloring.editable_foreground", false), Gatherer.config.getColor("coloring.editable_background", false), Gatherer.config.getColor("coloring.error_foreground", false), Gatherer.config.getColor("coloring.error_background", false)); 93 Dictionary.registerTooltip(url_field, "Mirroring.Source_URL_Tooltip"); 90 94 91 95 depth_model = new Vector(); 92 96 /* @todo - add to dictionary */ 93 depth_model.add(new DepthEntry(0, " 0 (this page only)"));94 /* @todo - add to dictionary */ 95 depth_model.add(new DepthEntry(1, "1"));96 /* @todo - add to dictionary */ 97 depth_model.add(new DepthEntry(2, "2"));98 /* @todo - add to dictionary */ 99 depth_model.add(new DepthEntry(3, "3"));100 /* @todo - add to dictionary */ 101 depth_model.add(new DepthEntry(4, "4"));102 /* @todo - add to dictionary */ 103 depth_model.add(new DepthEntry(5, "5"));104 /* @todo - add to dictionary */ 105 depth_model.add(new DepthEntry(-1, " Unlimited"));97 depth_model.add(new DepthEntry(0, "Mirroring.Download_Depth.Zero")); 98 /* @todo - add to dictionary */ 99 depth_model.add(new DepthEntry(1, String.valueOf(1))); 100 /* @todo - add to dictionary */ 101 depth_model.add(new DepthEntry(2, String.valueOf(3))); 102 /* @todo - add to dictionary */ 103 depth_model.add(new DepthEntry(3, String.valueOf(3))); 104 /* @todo - add to dictionary */ 105 depth_model.add(new DepthEntry(4, String.valueOf(4))); 106 /* @todo - add to dictionary */ 107 depth_model.add(new DepthEntry(5, String.valueOf(5))); 108 /* @todo - add to dictionary */ 109 depth_model.add(new DepthEntry(-1, "Mirroring.Download_Depth.Unlimited")); 106 110 JPanel depth_pane = new JPanel(); 107 111 JLabel depth_label = new JLabel(); … … 121 125 122 126 /* @todo - add to dictionary */ 123 JLabel further_label = new JLabel(" For further options see File->Preferences->Connection");127 JLabel further_label = new JLabel("Mirroring.Further_Options"); 124 128 125 129 JPanel button_pane = new JPanel(); … … 130 134 // Connect 131 135 download_button.addActionListener(new DownloadButtonListener()); 136 url_field.getDocument().addDocumentListener(new DownloadButtonEnabler()); 132 137 133 138 // Layout 134 139 url_pane.setLayout(new BorderLayout()); 135 140 url_pane.add(url_label, BorderLayout.WEST); 136 url_pane.add(url_ textfield, BorderLayout.CENTER);141 url_pane.add(url_field, BorderLayout.CENTER); 137 142 138 143 depth_pane.setLayout(new GridLayout(1,3)); … … 165 170 } 166 171 172 public void afterDisplay() { 173 ready = true; 174 } 175 167 176 public void collectionChanged(boolean ready) { 168 177 } 169 178 179 /** This method is called whenever the Mirror pane is brought into focus and is a good time to display a warning message if WGet is not available or of an older, problematic, version. 180 */ 181 public void gainFocus() { 182 if(!ready) { 183 return; 184 } 185 // Lets see what warning message we should display, if any. 186 String wget_version_str = Gatherer.config.getWGetVersion(); 187 if(wget_version_str.equals(StaticStrings.NO_WGET_STR)) { 188 // If there was no WGet available then downloading is disabled entirely 189 download_button_enabled = false; 190 // And we tell the user why. 191 /** @todo - add to dictionary */ 192 JOptionPane.showMessageDialog(Gatherer.g_man, "Mirroring.No_WGet", "Mirroring.No_WGet_Title", JOptionPane.ERROR_MESSAGE); 193 } 194 else if(wget_version_str.equals(StaticStrings.WGET_OLD_STR)) { 195 // Downloading is enabled 196 download_button_enabled = true; 197 // But we display a preventable warning message about the path problems. 198 WarningDialog dialog = new WarningDialog("warning.OldWGet", false); 199 dialog.display(); 200 dialog.dispose(); 201 dialog = null; 202 } 203 // Otherwise version must be ok 204 else { 205 download_button_enabled = true; 206 } 207 // It is also a good time to determine if the download should be enabled - ie if its allowed to be enabled and a valid URL is present in the field. 208 download_button.setEnabled(download_button_enabled && !url_field.isEmpty() && url_field.validateURL()); 209 } 210 170 211 public void setURL(String url) { 171 url_ textfield.setText(url);212 url_field.setText(url); 172 213 } 173 214 … … 175 216 static public FileNode getWebCacheMapping() 176 217 { 177 if (Gatherer.config.get("workflow.mirror", false) && Gatherer.c_man.ready()) {218 if (Gatherer.config.get("workflow.mirror", true) || Gatherer.config.get("workflow.mirror", false)) { 178 219 /* @todo - add to dictionary */ 179 return new FileNode(Utility.getCacheDir(), "Mirror 220 return new FileNode(Utility.getCacheDir(), "Mirroring.Mirror_Cache"); 180 221 } 181 222 return null; … … 235 276 } 236 277 278 private class DownloadButtonEnabler 279 implements DocumentListener { 280 /** Gives notification that an attribute or set of attributes changed. */ 281 public void changedUpdate(DocumentEvent e) { 282 validateDownloadButton(); 283 } 284 /** Gives notification that there was an insert into the document. */ 285 public void insertUpdate(DocumentEvent e) { 286 validateDownloadButton(); 287 } 288 /** Gives notification that a portion of the document has been removed. */ 289 public void removeUpdate(DocumentEvent e) { 290 validateDownloadButton(); 291 } 292 private void validateDownloadButton() { 293 download_button.setEnabled(download_button_enabled && !url_field.isEmpty() && url_field.validateURL()); 294 } 295 } 296 237 297 private class DownloadButtonListener 238 298 implements ActionListener { … … 240 300 public void actionPerformed(ActionEvent event) { 241 301 // Retrieve the current url and confirm it is valid 242 String url_str = url_ textfield.getText();302 String url_str = url_field.getText(); 243 303 URL url = null; 244 304 try { … … 273 333 catch(Exception exception) { 274 334 /* @todo - add to dictionary */ 275 JOptionPane.showMessageDialog(Gatherer.g_man, " The depth value you have entered is not valid.\nPlease choose an item from the list, or type in\na number.", "Invalid Depth", JOptionPane.ERROR_MESSAGE);335 JOptionPane.showMessageDialog(Gatherer.g_man, "Mirroring.Mirror_Depth.Invalid_Depth", "Mirroring.Mirror_Depth.Invalid_Depth_Title", JOptionPane.ERROR_MESSAGE); 276 336 return; 277 337 }
Note:
See TracChangeset
for help on using the changeset viewer.