Changeset 6152
- Timestamp:
- 2003-12-08T14:29:18+13:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/cdm/GeneralManager.java
r6088 r6152 42 42 import org.greenstone.gatherer.cdm.Control; 43 43 import org.greenstone.gatherer.gui.EmailField; 44 import org.greenstone.gatherer.gui.NewCollectionDetailsPrompt; 44 45 import org.greenstone.gatherer.gui.OpenCollectionDialog; 46 import org.greenstone.gatherer.gui.WarningDialog; 45 47 import org.greenstone.gatherer.util.StaticStrings; 46 48 import org.greenstone.gatherer.util.Utility; … … 220 222 name_textfield = new JTextField("CDM.General.Collection_Name"); 221 223 Dictionary.registerTooltip(name_textfield, "CDM.General.Collection_Name_Tooltip"); 224 JPanel short_name_panel = new JPanel(); 225 JLabel short_name_label = new JLabel(); 226 short_name_label.setPreferredSize(LABEL_SIZE); 227 Dictionary.registerText(short_name_label, "NewCollectionPrompt.Collection_Name"); 228 JTextField short_name_textfield = new JTextField(Gatherer.c_man.getCollection().getName()); 229 short_name_textfield.setEditable(false); 230 short_name_textfield.setBackground(Gatherer.config.getColor("coloring.collection_tree_background", false)); 222 231 JPanel icon_panel = new JPanel(); 223 232 icon_label = new JLabel(); … … 245 254 // Connection 246 255 beta_checkbox.addActionListener(CollectionDesignManager.change_listener); 247 browse_about_icon_button.addActionListener(new BrowseListener(StaticStrings.IMAGES_PATH_RELATIVE_TO_COLLECTION_PREFIX)); 248 browse_home_icon_button.addActionListener(new BrowseListener(StaticStrings.IMAGES_PATH_RELATIVE_TO_GSDL_PREFIX)); 256 BrowseListener browse_listener = new BrowseListener(StaticStrings.IMAGES_PATH_RELATIVE_TO_GSDL_PREFIX); 257 browse_about_icon_button.addActionListener(browse_listener); 258 browse_home_icon_button.addActionListener(browse_listener); 259 browse_listener = null; 249 260 public_checkbox.addActionListener(CollectionDesignManager.change_listener); 250 261 creator_emailfield.getDocument().addDocumentListener(CollectionDesignManager.change_listener); … … 253 264 maintainer_emailfield.getDocument().addDocumentListener(CollectionDesignManager.change_listener); 254 265 name_textfield.getDocument().addDocumentListener(CollectionDesignManager.change_listener); 266 name_textfield.getDocument().addDocumentListener(new CollectionTitleUpdater()); 255 267 small_icon_textfield.getDocument().addDocumentListener(CollectionDesignManager.change_listener); 256 268 … … 273 285 name_panel.add(name_textfield, BorderLayout.CENTER); 274 286 287 short_name_panel.setLayout(new BorderLayout()); 288 short_name_panel.add(short_name_label, BorderLayout.WEST); 289 short_name_panel.add(short_name_textfield, BorderLayout.CENTER); 290 275 291 icon_panel.setLayout(new BorderLayout()); 276 292 icon_panel.add(icon_label, BorderLayout.WEST); … … 283 299 small_icon_panel.add(browse_home_icon_button, BorderLayout.EAST); 284 300 285 details_panel.setLayout(new GridLayout( 7,1,5,0));301 details_panel.setLayout(new GridLayout(8,1,5,2)); 286 302 details_panel.add(creator_panel); 287 303 details_panel.add(maintainer_panel); … … 289 305 details_panel.add(beta_checkbox); 290 306 details_panel.add(name_panel); 307 details_panel.add(short_name_panel); 291 308 details_panel.add(icon_panel); 292 309 details_panel.add(small_icon_panel); … … 350 367 icon_collection_collectionmeta.setValue(icon_textfield.getText()); 351 368 maintainer_collectionmeta.setValue(maintainer_emailfield.getText()); 352 collection_name_collectionmeta.setValue(name_textfield.getText());353 369 icon_collection_small_collectionmeta.setValue(small_icon_textfield.getText()); 370 371 // Oh, and if the collection title is already in use warn them about it 372 String title = name_textfield.getText(); 373 // I just happen to have a handy method in the new details prompt to detect this very thing 374 if(NewCollectionDetailsPrompt.titleClashes(title)) { 375 // Determine if the user wants to be warned about this 376 WarningDialog dialog = new WarningDialog("warning.TitleClashes", true); 377 if(dialog.display() == JOptionPane.OK_OPTION) { 378 // If they have said yes, then carry on with the assignement 379 collection_name_collectionmeta.setValue(title); 380 } 381 // Otherwise we don't assign anything. In fact we have to restore the frame title back to its original value 382 else { 383 String collection_title = collection_name_collectionmeta.getValue(CollectionMeta.TEXT); 384 String collection_name = Gatherer.c_man.getCollection().getName(); 385 Gatherer.g_man.setTitle(collection_title, collection_name); 386 collection_name = null; 387 collection_title = null; 388 } 389 dialog.dispose(); 390 dialog = null; 391 } 392 // No clash, no worries. 393 else { 394 collection_name_collectionmeta.setValue(title); 395 } 396 title = null; 397 354 398 ready = false; 355 } 399 } 356 400 } 357 401 … … 362 406 private String prefix; 363 407 364 public BrowseListener(String prefix ) {365 this.prefix = prefix ;408 public BrowseListener(String prefix_raw) { 409 this.prefix = prefix_raw.replaceAll(StaticStrings.COLNAME_PATTERN, Gatherer.c_man.getCollection().getName()); 366 410 } 367 411 … … 438 482 } 439 483 } 484 485 private class CollectionTitleUpdater 486 implements DocumentListener { 487 /** Gives notification that an attribute or set of attributes changed. */ 488 public void changedUpdate(DocumentEvent e) { 489 setTitle(); 490 } 491 /** Gives notification that there was an insert into the document. */ 492 public void insertUpdate(DocumentEvent e) { 493 setTitle(); 494 } 495 /** Gives notification that a portion of the document has been removed. */ 496 public void removeUpdate(DocumentEvent e) { 497 setTitle(); 498 } 499 500 private void setTitle() { 501 // Set the title 502 String collection_title = name_textfield.getText(); 503 String collection_name = Gatherer.c_man.getCollection().getName(); 504 Gatherer.g_man.setTitle(collection_title, collection_name); 505 collection_title = null; 506 collection_name = null; 507 } 508 } 440 509 } 441 510
Note:
See TracChangeset
for help on using the changeset viewer.