Changeset 6041
- Timestamp:
- 2003-11-28T17:48:22+13:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/gui/NewCollectionDetailsPrompt.java
r5716 r6041 23 23 private JDialog self; 24 24 private JTextArea description; 25 /* Suppress email 25 26 private JTextField address; 26 27 private JTextField host; 28 */ 27 29 private JTextField title; 28 private RestrictedTextField file;30 //private RestrictedTextField file; 29 31 private String description_final; 30 private String email_final;31 private String name_final;32 // private String email_final; no more email 33 // private String name_final; 32 34 private String title_final; 33 35 static private Dimension label_size = new Dimension(230, 25); 34 36 /** The size of this new collection dialog box. */ 35 static private Dimension size = new Dimension( 700, 375);37 static private Dimension size = new Dimension(600, 280); 36 38 static private int FILENAME_SIZE = 8; 37 39 … … 91 93 JLabel name_label = new JLabel(); 92 94 Dictionary.setText(name_label, "NewCollectionPrompt.Collection_Name"); 93 JPanel file_pane = new JPanel(); 94 file = new RestrictedTextField(new RestrictedTextDocument(FILENAME_SIZE), "", FILENAME_SIZE); 95 Dictionary.setTooltip(file, "NewCollectionPrompt.Collection_Name_Tooltip"); 96 JLabel file_label = new JLabel(".col"); 95 //JPanel file_pane = new JPanel(); 96 //file = new RestrictedTextField(new RestrictedTextDocument(FILENAME_SIZE), "", FILENAME_SIZE); 97 //Dictionary.setTooltip(file, "NewCollectionPrompt.Collection_Name_Tooltip"); 98 //JLabel file_label = new JLabel(".col"); 99 /* Suppress Email 97 100 JPanel email_pane = new JPanel(); 98 101 JLabel email_label = new JLabel(); 99 102 Dictionary.setText(email_label, "NewCollectionPrompt.Collection_Email"); 100 103 JPanel host_pane = new JPanel(); 101 104 JPanel address_pane = new JPanel(); … … 105 108 host = new JTextField(); 106 109 Dictionary.setTooltip(host, "CDM.General.Email.Creator_Tooltip"); 110 */ 107 111 108 112 JPanel center_pane = new JPanel(); … … 131 135 cancel_button.setMnemonic(KeyEvent.VK_C); 132 136 Dictionary.setBoth(cancel_button, "General.Cancel", "General.Cancel_Tooltip"); 133 ColorListener email_color_listener = new ColorListener(address, host); 137 138 //ColorListener email_color_listener = new ColorListener(address, host); No more email 134 139 135 140 // Connection 136 141 cancel_button.addActionListener(new CancelListener()); 137 142 create_button.addActionListener(new CreateListener()); 138 address.addKeyListener(email_color_listener);143 //address.addKeyListener(email_color_listener); suppress email 139 144 description.addKeyListener(new ColorListener(description)); 140 145 description.addKeyListener(new DescriptionListener()); 141 file.addKeyListener(new ColorListener(file));142 host.addKeyListener(email_color_listener);146 //file.addKeyListener(new ColorListener(file)); 147 //host.addKeyListener(email_color_listener); suppress email 143 148 title.addKeyListener(new ColorListener(title)); 144 title.getDocument().addDocumentListener(new TitleListener());149 //title.getDocument().addDocumentListener(new TitleListener()); 145 150 // Layout 146 151 title_label.setPreferredSize(label_size); … … 150 155 title_pane.add(title, BorderLayout.CENTER); 151 156 157 /* suppress filename 152 158 file_pane.setLayout(new BorderLayout()); 153 159 file_pane.add(file, BorderLayout.WEST); … … 159 165 name_pane.add(name_label, BorderLayout.WEST); 160 166 name_pane.add(file_pane, BorderLayout.CENTER); 161 167 */ 168 169 /* suppress email 162 170 email_label.setPreferredSize(label_size); 163 171 … … 173 181 email_pane.add(email_label, BorderLayout.WEST); 174 182 email_pane.add(host_pane, BorderLayout.CENTER); 175 176 upper_pane.setLayout(new GridLayout(4,1)); 183 */ 184 185 upper_pane.setLayout(new GridLayout(2,1)); 177 186 upper_pane.add(instructions_label); 178 187 upper_pane.add(title_pane); 179 upper_pane.add(name_pane);180 upper_pane.add(email_pane);188 //upper_pane.add(name_pane); 189 //upper_pane.add(email_pane); no email anymore 181 190 182 191 description_pane.setLayout(new BorderLayout()); … … 227 236 } 228 237 238 /* No more email 229 239 public String getEmail() { 230 240 return email_final; 231 241 } 232 242 */ 243 244 /** Generates the collection short filename by taking the first eight characters of the title (spaces removed) and then adjusting by further truncating and then adding an unique suffix as necessary. 245 * @return the filename as a String 246 */ 233 247 public String getName() { 234 return name_final; 248 // Retrieve the first 8 non-whitespace characters of title_final. 249 StringBuffer name_buffer = new StringBuffer(""); 250 int i = 0; 251 while(i < title_final.length() && name_buffer.length() < 8) { 252 char c = title_final.charAt(i); 253 if(!Character.isWhitespace(c)) { 254 name_buffer.append(Character.toLowerCase(c)); 255 } 256 i++; 257 } 258 // We need to ensure the filename is unique 259 int counter = 0; 260 while(filenameClashes(name_buffer.toString())) { 261 counter++; 262 String suffix = String.valueOf(counter); 263 name_buffer.replace(name_buffer.length() - suffix.length(), name_buffer.length(), suffix); 264 } 265 // All done 266 return name_buffer.toString(); 267 } 268 269 private boolean filenameClashes(String filename) { 270 File collection_directory = new File(Utility.getCollectionDir(Gatherer.config.gsdl_path)); 271 File children[] = collection_directory.listFiles(); 272 for(int i = 0; children != null && i < children.length; i++) { 273 if(children[i].getName().equals(filename)) { 274 return true; 275 } 276 } 277 return false; 235 278 } 236 279 … … 304 347 return; 305 348 } 349 // We must ensure that the collection title is unique. This is a pain in the nether regions as we are forced to load the collect.cfg of each other collection in turn looking for a conflicting title 350 else { 351 352 353 } 354 /* Suppress filename 306 355 name_final = file.getText(); 307 356 if(name_final.length() > 0) { … … 324 373 return; 325 374 } 375 */ 376 /* Suppress email 326 377 email_final = address.getText() + "@" + host.getText(); 327 378 if(email_final.length() == 0 || email_final.startsWith("@") || email_final.endsWith("@")) { … … 333 384 return; 334 385 } 386 */ 335 387 description_final = description.getText(); 336 388 if(description_final.length() == 0) { … … 382 434 } 383 435 436 /* 384 437 private class RestrictedTextField 385 438 extends JTextField { … … 438 491 } 439 492 } 440 493 */ 494 495 /* Suppress filename 441 496 private class TitleListener 442 497 implements DocumentListener { 443 /** Gives notification that an attribute or set of attributes changed. */498 ** Gives notification that an attribute or set of attributes changed. * 444 499 public void changedUpdate(DocumentEvent e) { 445 500 updateFilename(); 446 501 } 447 502 448 /** Gives notification that there was an insert into the document. */503 ** Gives notification that there was an insert into the document. * 449 504 public void insertUpdate(DocumentEvent e) { 450 505 updateFilename(); 451 506 } 452 507 453 /** Gives notification that a portion of the document has been removed. */508 ** Gives notification that a portion of the document has been removed. * 454 509 public void removeUpdate(DocumentEvent e) { 455 510 updateFilename(); … … 473 528 } 474 529 } 530 */ 475 531 } 532 533 534
Note:
See TracChangeset
for help on using the changeset viewer.