Project

General

Profile

« Previous | Next » 

Revision 7efcfaee

Added by Patrick Plitzner almost 6 years ago

ref #7095 Fix possible class cast exception

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/l10n/Messages.java
271 271
    public static String WorkingSetComposite_RANK_MAX;
272 272
    public static String WorkingSetComposite_RANK_MIN;
273 273
    public static String WorkingSetComposite_TAXON_FILTER;
274
    public static String WorkingSetEditor_DELETE_FAIL_MESSAGE;
275
    public static String WorkingSetEditor_DELETE_FAIL_TITLE;
274 276
    static {
275 277
        // initialize resource bundle
276 278
        NLS.initializeMessages(BUNDLE_NAME, Messages.class);
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/l10n/messages.properties
250 250
WorkingSetComposite_RANK_MAX=Rank max
251 251
WorkingSetComposite_RANK_MIN=Rank min
252 252
WorkingSetComposite_TAXON_FILTER=Taxon filter
253
WorkingSetEditor_DELETE_FAIL_MESSAGE=You can only select top level elements
254
WorkingSetEditor_DELETE_FAIL_TITLE=Could not delete
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/l10n/messages_de.properties
250 250
WorkingSetComposite_RANK_MAX=max. Rang
251 251
WorkingSetComposite_RANK_MIN=min. Rang
252 252
WorkingSetComposite_TAXON_FILTER=Taxonfilter
253
WorkingSetEditor_DELETE_FAIL_MESSAGE=Es k?nnen nur Elemente auf erster Ebene ausgew?hlt werden
254
WorkingSetEditor_DELETE_FAIL_TITLE=L?schen fehlgesschlagen
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/WorkingSetEditor.java
57 57
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
58 58
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
59 59
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
60
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
60 61
import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
61 62
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
63
import eu.etaxonomy.taxeditor.model.MessagingUtils;
62 64
import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
63 65
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
64 66
import eu.etaxonomy.taxeditor.store.CdmStore;
......
152 154
            public void keyPressed(KeyEvent e) {
153 155
                if(e.character==SWT.DEL){
154 156
                    IStructuredSelection selection = (IStructuredSelection) composite.getTaxonNodeTree().getSelection();
155
                    Iterator<TaxonNode> iterator = selection.iterator();
157
                    if(selection.toList().stream().anyMatch(object->!(object instanceof TaxonNode))){
158
                        MessagingUtils.warningDialog(Messages.WorkingSetEditor_DELETE_FAIL_TITLE, this.getClass(), Messages.WorkingSetEditor_DELETE_FAIL_MESSAGE);
159
                        return;
160
                    }
161
                    Iterator<Object> iterator = selection.iterator();
156 162
                    while(iterator.hasNext()){
157
                        TaxonNode taxonNode = iterator.next();
163
                        Object next = iterator.next();
164
                        TaxonNode taxonNode = (TaxonNode) next;
158 165
                        removeTaxonNode(taxonNode);
159 166
                    }
160 167
                }

Also available in: Unified diff