Changeset 5536 for trunk/gli/src/org/greenstone/gatherer/collection
- Timestamp:
- 2003-09-26T14:58:33+12:00 (21 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer/collection
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/collection/DeleteCollectionPrompt.java
r5347 r5536 1 package org.greenstone.gatherer.collection;2 1 /** 3 2 *######################################################################### … … 36 35 *######################################################################## 37 36 */ 37 package org.greenstone.gatherer.collection; 38 38 39 import java.awt.*; 39 40 import java.awt.event.*; … … 41 42 import javax.swing.*; 42 43 import javax.swing.event.*; 44 import org.greenstone.gatherer.Dictionary; 43 45 import org.greenstone.gatherer.Gatherer; 44 46 import org.greenstone.gatherer.collection.Collection; 45 import org.greenstone.gatherer.collection.CollectionManager;46 47 import org.greenstone.gatherer.gui.ModalDialog; 47 48 import org.greenstone.gatherer.gui.SimpleMenuBar; … … 50 51 import org.greenstone.gatherer.util.StaticStrings; 51 52 import org.greenstone.gatherer.util.Utility; 53 52 54 /** 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. 53 55 * @author John Thompson, Greenstone Digital Library, University of Waikato … … 60 62 /** The model behind the list. */ 61 63 private DefaultListModel list_model = null; 62 /** A reference to ourself so any inner-classes getdispose of us. */64 /** A reference to ourself so any inner-classes can dispose of us. */ 63 65 private DeleteCollectionPrompt prompt = null; 64 66 /** The close button, which exits the prompt without deleting anything. */ … … 82 84 /** The size of the delete prompt screen. */ 83 85 public static final Dimension SIZE = new Dimension(500, 500); 86 84 87 /** Constructor. 85 88 * @see org.greenstone.gatherer.collection.DeleteCollectionPrompt.CloseButtonListener … … 90 93 public DeleteCollectionPrompt() { 91 94 super(Gatherer.g_man); 92 this.close_button = new JButton(get("General.Close", null)); 93 this.confirmation = new JCheckBox(get("DeleteCollectionPrompt.Confirm_Delete", null)); 94 this.details = new JTextArea(); 95 this.details_label = new JLabel(get("DeleteCollectionPrompt.Collection_Details", null)); 96 this.list = new JList(); 97 this.list_label = new JLabel(get("DeleteCollectionPrompt.Collection_List", null)); 98 this.list_model = new DefaultListModel(); 99 this.ok_button = new JButton(get("General.OK", null)); 100 this.prompt = this; 101 this.setModal(true); 102 this.setSize(SIZE); 103 this.setTitle(get("DeleteCollectionPrompt.Title", null)); 104 this.setJMenuBar(new SimpleMenuBar("0")); // need to find an appropriate help page to open at 95 close_button = new JButton(); 96 Dictionary.setText(close_button, "General.Close"); 97 confirmation = new JCheckBox(); 98 Dictionary.setText(confirmation, "DeleteCollectionPrompt.Confirm_Delete"); 99 details = new JTextArea(); 100 details.setFont(Gatherer.config.getFont("general.tooltip_font", false)); 101 Dictionary.setText(details, "DeleteCollectionPrompt.No_Collection"); 102 details_label = new JLabel(); 103 Dictionary.setText(details_label, "DeleteCollectionPrompt.Collection_Details"); 104 list = new JList(); 105 list_label = new JLabel(); 106 Dictionary.setText(list_label, "DeleteCollectionPrompt.Collection_List"); 107 list_model = new DefaultListModel(); 108 ok_button = new JButton(); 109 Dictionary.setText(ok_button, "General.OK"); 110 prompt = this; 111 setModal(true); 112 setSize(SIZE); 113 // setTitle(); 114 Dictionary.setText(this, "DeleteCollectionPrompt.Title"); 115 116 setJMenuBar(new SimpleMenuBar("0")); // need to find an appropriate help page to open at 105 117 close_button.addActionListener(new CloseButtonListener()); 106 118 confirmation.addActionListener(new ConfirmationCheckBoxListener()); 107 119 confirmation.setEnabled(false); 108 120 confirmation.setSelected(false); 109 details.setFont(Gatherer.config.getFont("general.tooltip_font", false));110 details.setText(get("DeleteCollectionPrompt.No_Collection", null));111 121 list.addListSelectionListener(new CollectionListListener()); 112 122 list.clearSelection(); … … 117 127 scanForCollections(); 118 128 } 129 119 130 /** Destructor. */ 120 131 public void destroy() { … … 129 140 prompt = null; 130 141 } 142 131 143 /** This method causes the modal prompt to be displayed. 132 * returns true if it has deleted the collection that is currently open */144 * returns true if it has deleted the collection that is currently open */ 133 145 public boolean display() { 134 146 // Central pane … … 176 188 177 189 } 190 178 191 /** Shows a delete complete prompt. 179 180 181 192 * @param success A <strong>boolean</strong> indicating if the collection was successfully deleted. 193 * @see org.greenstone.gatherer.collection.Collection 194 */ 182 195 public void resultPrompt(boolean success) { 183 196 args = new String[1]; 184 197 args[0] = collection.getName(); 185 if (success) {186 JOptionPane.showMessageDialog(prompt, get("DeleteCollectionPrompt.Successful_Delete", args),get("DeleteCollectionPrompt.Successful_Title", null),JOptionPane.INFORMATION_MESSAGE);198 if (success) { 199 JOptionPane.showMessageDialog(prompt,Dictionary.newget("DeleteCollectionPrompt.Successful_Delete", args),Dictionary.newget("DeleteCollectionPrompt.Successful_Title"),JOptionPane.INFORMATION_MESSAGE); 187 200 } 188 201 else { 189 JOptionPane.showMessageDialog(prompt,get("DeleteCollectionPrompt.Failed_Delete", args),get("DeleteCollectionPrompt.Failed_Title", null),JOptionPane.WARNING_MESSAGE); 190 } 191 } 192 /** Retrieves a phrase from the <strong>Dictionary</strong> in <strong>Gatherer</strong>. 193 * @param key A <strong>String</strong> used to match against a specific phrase in the dictionary. 194 * @see org.greenstone.gatherer.Dictionary 195 * @see org.greenstone.gatherer.Gatherer 196 */ 197 private String get(String key, String args[]) { 198 if(key.indexOf(".") == -1) { 199 key = "DeleteCollectionPrompt." + key; 200 } 201 return Gatherer.dictionary.get(key, args); 202 } 202 JOptionPane.showMessageDialog(prompt,Dictionary.newget("DeleteCollectionPrompt.Failed_Delete", args),Dictionary.newget("DeleteCollectionPrompt.Failed_Title"),JOptionPane.WARNING_MESSAGE); 203 } 204 } 205 203 206 204 207 /** Method to scan the collect directory retrieving and reloading each collection it finds, while building the list of known collections. 205 206 207 208 209 208 * @see org.greenstone.gatherer.Configuration 209 * @see org.greenstone.gatherer.Gatherer 210 * @see org.greenstone.gatherer.util.ArrayTools 211 * @see org.greenstone.gatherer.util.Utility 212 */ 210 213 private void scanForCollections() { 211 214 // Start at the collect dir. … … 232 235 // Otherwise the collect directory doesn't actually exist, so there ain't much we can do. 233 236 } 237 234 238 /** A button listener implementation, which listens for actions on the close button and disposes of the dialog when detected. */ 235 239 private class CloseButtonListener … … 237 241 /** Any implementation of ActionListener must include this method so we can be informed when the button is actioned. 238 242 * @param event An <strong>ActionEvent</strong> containing all the relevant information garnered from the event itself. 239 243 */ 240 244 public void actionPerformed(ActionEvent event) { 241 245 // Ask the collection manager to refresh the 'Greenstone Collections' folder … … 245 249 } 246 250 } 251 247 252 /** This private class listens for selection events in from the list and then displays the appropriate details for that collection. 248 253 */ 249 254 private class CollectionListListener 250 255 implements ListSelectionListener { … … 264 269 args[3] = collection.getMaintainer(); 265 270 args[4] = collection.getDescription(); 266 details.setText(get("DeleteCollectionPrompt.Details", args));271 Dictionary.setText(details, "DeleteCollectionPrompt.Details", args); 267 272 details.setCaretPosition(0); 268 273 } 269 274 else { 270 275 confirmation.setEnabled(false); 271 details.setText(get("DeleteCollectionPrompt.No_Collection", null)); 272 } 273 } 274 } 275 /** A check box listener so we can tell if the users selected confirm. */ 276 Dictionary.setText(details, "DeleteCollectionPrompt.No_Collection"); 277 } 278 } 279 } 280 281 /** A check box listener so we can tell if the user has confirmed the deletion */ 276 282 private class ConfirmationCheckBoxListener 277 283 implements ActionListener { 278 284 /** Any implementation of ActionListener must include this method so we can be informed when the button is actioned. 279 285 * @param event An <strong>ActionEvent</strong> containing all the relevant information garnered from the event itself. 280 286 */ 281 287 public void actionPerformed(ActionEvent event) { 282 if(confirmation.isSelected()) { 283 ok_button.setEnabled(true); 284 } 285 else { 286 ok_button.setEnabled(false); 287 } 288 // OK button is only enabled if the confirmation check box is ticked 289 ok_button.setEnabled(confirmation.isSelected()); 288 290 } 289 291 } 292 290 293 /** The OK button listener implementation. */ 291 294 private class OKButtonListener … … 314 317 resultPrompt(true); 315 318 list_model.removeElement(collection); 316 details.setText(get("DeleteCollectionPrompt.No_Collection", null));319 Dictionary.setText(details, "DeleteCollectionPrompt.No_Collection"); 317 320 confirmation.setEnabled(false); 318 321 confirmation.setSelected(false); … … 355 358 return config.getMaintainer(); 356 359 } 360 357 361 public String toString() { 358 return config.getName(); 359 362 return config.getName(); 360 363 } 361 364 } -
trunk/gli/src/org/greenstone/gatherer/collection/SaveCollectionBox.java
r5355 r5536 94 94 } 95 95 /** Displays the prompt by first building the controls, then waits for a user selection. 96 97 96 * @param name The name of the current collection as a <strong>String</strong>. 97 */ 98 98 public int getUserOption(String name) { 99 99 JPanel content_pane = (JPanel) this.getContentPane(); … … 145 145 } 146 146 /** Method to retrieve a phrase from the dictionary based of a key. 147 148 149 147 * @param key A <strong>String</strong> used to find the correct phrase. 148 * @return A <strong>String</strong> containing the correct phrase with the correct formatting. 149 */ 150 150 private String get(String key) { 151 151 return get(key, null); 152 152 } 153 153 /** Method to retrieve a phrase from the dictionary based of a key and including arguments. 154 155 156 157 154 * @param key A <strong>String</strong> used to find the correct phrase. 155 * @param args A <strong>String[]</strong> of arguments used in formatting and filling out the phrase. 156 * @return A <strong>String</strong> containing the correct phrase with the correct formatting. 157 */ 158 158 private String get(String key, String args[]) { 159 159 if(key.indexOf('.') == -1) { … … 167 167 /** Any extension of KeyAdapter can override this method so that we can be informed whenever a key is released (ie after a keyTyped event). In this case we map the key press to an appropriate click on one of the buttons (not necessarily the one the key release was detected on). 168 168 * @param event A <strong>KeyEvent</strong> containing details about the key release event. 169 169 */ 170 170 public void keyReleased(KeyEvent event) { 171 171 if(event.getKeyCode() == KeyEvent.VK_Y) {
Note:
See TracChangeset
for help on using the changeset viewer.