Changeset 15156


Ignore:
Timestamp:
2008-03-29T18:21:07+13:00 (14 years ago)
Author:
ak19
Message:

Doesn't allow users to delete the currently open collection. Modified valueChanged() event-handler to disable delete button for it and show a tooltip over the confirmation checkbox and delete button explaining why the chosen collection can't be deleted

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gli/trunk/src/org/greenstone/gatherer/gui/DeleteCollectionPrompt.java

    r14045 r15156  
    251251        confirmation.setSelected(false);
    252252        if(!list.isSelectionEmpty()) {
    253         confirmation.setEnabled(true);
    254253        collection = (BasicCollectionConfiguration) list.getSelectedValue();
    255         args = new String[3];
    256         args[0] = collection.getCreator();
    257         args[1] = collection.getMaintainer();
    258         args[2] = collection.getDescription();
    259         details.setText(Dictionary.get("DeleteCollectionPrompt.Details", args));
    260         details.setCaretPosition(0);
     254
     255        String currentColName = (Gatherer.c_man.getCollection() == null) ? "" : Gatherer.c_man.getCollection().getName();
     256        if(!collection.getShortName().equals(currentColName)) {
     257            // the selected collection can only be deleted if it is NOT the collection that is currently open
     258            confirmation.setEnabled(true);
     259            confirmation.setToolTipText(null); // no tooltip
     260            ok_button.setToolTipText(null);
     261
     262            args = new String[3];
     263            args[0] = collection.getCreator();
     264            args[1] = collection.getMaintainer();
     265            args[2] = collection.getDescription();
     266            details.setText(Dictionary.get("DeleteCollectionPrompt.Details", args));
     267            details.setCaretPosition(0);
     268        } else { // trying to delete the collection that is open at present
     269            // add a tooltip saying to the confirmation checkbox saying that the current collection can't be deleted
     270            String tooltip = Dictionary.get("DeleteCollectionPrompt.Cannot_Delete_Open_Collection_Tooltip",
     271                            collection.getName());
     272            confirmation.setToolTipText(tooltip);
     273            ok_button.setToolTipText(tooltip);
     274            // delete/ok button and confirmation checkbox should be disabled
     275            ok_button.setEnabled(false);
     276            confirmation.setEnabled(false);
     277            confirmation.setSelected(false);
     278        }
    261279        }
    262280        else {
Note: See TracChangeset for help on using the changeset viewer.