Changeset 4677
- Timestamp:
- 2003-06-16T11:10:16+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/collection/DeleteCollectionPrompt.java
r4675 r4677 43 43 import org.greenstone.gatherer.Gatherer; 44 44 import org.greenstone.gatherer.collection.Collection; 45 import org.greenstone.gatherer.gui.ModalDialog; 46 import org.greenstone.gatherer.gui.SimpleMenuBar; 45 47 import org.greenstone.gatherer.util.ArrayTools; 48 import org.greenstone.gatherer.util.GSDLSiteConfig; 46 49 import org.greenstone.gatherer.util.Utility; 47 50 /** This class provides the functionality to delete current collections from the GSDLHOME/collect/ directory. The user chooses the collection from a list, where each entry also displays details about itself, confirms the delete of a collection by checking a checkbox then presses the ok button to actually delete the collection. … … 50 53 */ 51 54 public class DeleteCollectionPrompt 52 extends JDialog {55 extends ModalDialog { 53 56 /** The currently selected collection for deletion. */ 54 private Collection Configurationcollection = null;57 private CollectionEntry collection = null; 55 58 /** The model behind the list. */ 56 59 private DefaultListModel list_model = null; … … 73 76 /** A string array used to pass arguments to the phrase retrieval method. */ 74 77 private String args[] = null; 78 79 private boolean current_coll_deleted = false; 75 80 /** The size of the delete prompt screen. */ 76 81 public static final Dimension SIZE = new Dimension(500, 500); … … 82 87 */ 83 88 public DeleteCollectionPrompt() { 84 super( );89 super(Gatherer.g_man); 85 90 this.close_button = new JButton(get("General.Close", null)); 86 91 this.confirmation = new JCheckBox(get("Confirm_Delete", null)); … … 95 100 this.setSize(SIZE); 96 101 this.setTitle(get("Title", null)); 102 this.setJMenuBar(new SimpleMenuBar("0")); // need to find an appropriate help page to open at 97 103 close_button.addActionListener(new CloseButtonListener()); 98 104 confirmation.addActionListener(new ConfirmationCheckBoxListener()); … … 121 127 prompt = null; 122 128 } 123 /** This method causes the modal prompt to be displayed. */ 124 public void display() { 129 /** This method causes the modal prompt to be displayed. 130 * returns true if it has deleted the collection that is currently open*/ 131 public boolean display() { 125 132 // Central pane 126 133 JPanel list_pane = new JPanel(new BorderLayout()); … … 163 170 Dimension screen_size = Gatherer.config.screen_size; 164 171 this.setLocation((screen_size.width - SIZE.width) / 2, (screen_size.height - SIZE.height) / 2); 165 this.show(); 166 } 167 168 /** Shows a delete complete prompt. 172 this.setVisible(true); // blocks until the dialog is killed 173 return current_coll_deleted; 174 175 } 176 /** Shows a delete complete prompt. 169 177 * @param success A <strong>boolean</strong> indicating if the collection was successfully deleted. 170 178 * @see org.greenstone.gatherer.collection.Collection … … 180 188 } 181 189 } 182 183 190 /** Retrieves a phrase from the <strong>Dictionary</strong> in <strong>Gatherer</strong>. 184 191 * @param key A <strong>String</strong> used to match against a specific phrase in the dictionary. … … 204 211 File collect_directory = new File(collect_directory_name); 205 212 if(collect_directory.exists()) { 206 // Now for each child directory see if it contains a .col file and if so try to load it.. 213 // Now for each child directory see if it contains a .col file and 214 // if so try to load it.. 207 215 File collections[] = collect_directory.listFiles(); 208 216 ArrayTools.sort(collections); 209 217 for(int i = 0; collections != null && i < collections.length; i++) { 210 File children[] = collections[i].listFiles(); 211 for(int j = 0; children != null && j < children.length; j++) { 212 if(children[j].getAbsolutePath().endsWith(".col")) { 213 list_model.addElement(new CollectionConfiguration(children[j])); 214 } 218 File config_file = Utility.findConfigFile(collections[i]); 219 if (config_file != null) { 220 CollectionConfiguration config = new CollectionConfiguration(config_file); 221 if (config != null) { 222 CollectionEntry col = new CollectionEntry(collections[i].getName(), config); 223 list_model.addElement(col); 224 } 215 225 } 216 226 } … … 219 229 } 220 230 /** A button listener implementation, which listens for actions on the close button and disposes of the dialog when detected. */ 221 private class CloseButtonListener 231 private class CloseButtonListener 222 232 implements ActionListener { 223 233 /** Any implementation of ActionListener must include this method so we can be informed when the button is actioned. … … 230 240 /** This private class listens for selection events in from the list and then displays the appropriate details for that collection. 231 241 */ 232 private class CollectionListListener 242 private class CollectionListListener 233 243 implements ListSelectionListener { 234 244 /** Any implementation of ListSelectionListener must include this method so we can be informed when the list selection changes. … … 238 248 if(!list.isSelectionEmpty()) { 239 249 confirmation.setEnabled(true); 240 collection = (Collection Configuration) list.getSelectedValue();241 args = new String[ 5];242 args[0] = collection.get Name();243 args[1] = collection.get ShortName();250 collection = (CollectionEntry) list.getSelectedValue(); 251 args = new String[4]; 252 args[0] = collection.getTitle(); 253 args[1] = collection.getName(); 244 254 args[2] = collection.getCreator(); 245 255 args[3] = collection.getMaintainer(); 246 256 args[4] = collection.getDescription(); 247 257 details.setText(get("Details", args)); 258 details.setCaretPosition(0); 248 259 } 249 260 else { … … 267 278 } 268 279 } 269 } 280 } 270 281 /** The OK button listener implementation. */ 271 private class OKButtonListener 282 private class OKButtonListener 272 283 implements ActionListener { 273 284 /** Any implementation of ActionListener must include this method so we can be informed when the button is actioned. … … 278 289 */ 279 290 public void actionPerformed(ActionEvent event) { 280 // Delete the selected collection. 281 File delete_me = collection.getFile().getParentFile().getParentFile(); 291 // Delete the selected collection. 292 293 // first of all we must release it from the local library 294 if(Gatherer.config.exec_file != null) { 295 ///ystem.err.println("Local Library Found!"); 296 Gatherer.g_man.preview_pane.configServer(GSDLSiteConfig.RELEASE_COMMAND + collection.getName()); 297 } 298 299 File delete_me = new File(Utility.getCollectionDir(Gatherer.config.gsdl_path) + collection.getName() + File.separator); 282 300 if(Utility.delete(delete_me)) { 301 if (Gatherer.c_man.getCollection()!=null && collection.getName().equals(Gatherer.c_man.getCollection().getName())) { 302 current_coll_deleted = true; 303 } 304 283 305 resultPrompt(true); 284 306 list_model.removeElement(collection); … … 294 316 } 295 317 } 318 319 private class CollectionEntry { 320 321 private String name = null; 322 private CollectionConfiguration config = null; 323 324 public CollectionEntry(String name, CollectionConfiguration config) { 325 this.name = name; 326 this.config = config; 327 } 328 329 public String getName() { 330 return name; 331 } 332 333 public String getTitle() { 334 return config.getName(); 335 } 336 337 public String getCreator() { 338 return config.getCreator(); 339 } 340 341 public String getDescription() { 342 return config.getDescription(); 343 } 344 345 public String getMaintainer() { 346 return config.getMaintainer(); 347 } 348 public String toString() { 349 return config.getName(); 350 351 } 352 } 296 353 } 297 354
Note:
See TracChangeset
for help on using the changeset viewer.