Project

General

Profile

« Previous | Next » 

Revision 9aa59538

Added by Andreas Müller over 6 years ago

fix #6961 fix NPE for TaxonNode d&d when hovering classification in AdapterAssistant class

View differences:

eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TreeNodeDropAdapterAssistant.java
47 47
 *
48 48
 * @author p.ciardelli
49 49
 * @created 03.06.2009
50
 * @version 1.0
51 50
 */
52 51
public class TreeNodeDropAdapterAssistant extends CommonDropAdapterAssistant implements IPostOperationEnabled {
53 52

  
......
58 57

  
59 58
	private static final EnumSet<CRUD> UPDATE = EnumSet.of(CRUD.UPDATE);
60 59

  
61
	/* (non-Javadoc)
62
	 * @see org.eclipse.ui.navigator.CommonDropAdapterAssistant#handleDrop(org.eclipse.ui.navigator.CommonDropAdapter, org.eclipse.swt.dnd.DropTargetEvent, java.lang.Object)
63
	 */
64 60
	/** {@inheritDoc} */
65 61
	@Override
66 62
	public IStatus handleDrop(CommonDropAdapter dropAdapter,
......
107 103
		return taxonNodes.size() > 0 ? taxonNodes : null;
108 104
	}
109 105

  
110
	/* (non-Javadoc)
111
	 * @see org.eclipse.ui.navigator.CommonDropAdapterAssistant#validateDrop(java.lang.Object, int, org.eclipse.swt.dnd.TransferData)
112
	 */
113 106
	/** {@inheritDoc} */
114 107
	@Override
115 108
	public IStatus validateDrop(Object target, int operation,
......
119 112
		    // check users permissions with target taxonnode and taxon
120 113
		    if (target instanceof TaxonNode) {
121 114
		        TaxonNode targetNode = (TaxonNode)target;
122
		        Boolean hasTargetNodePermission = CdmStore.currentAuthentiationHasPermission(targetNode, UPDATE);
123
                Boolean hasTargetTaxonPermission = CdmStore.currentAuthentiationHasPermission(targetNode.getTaxon(), UPDATE);
115
		        boolean hasTargetNodePermission = CdmStore.currentAuthentiationHasPermission(targetNode, UPDATE);
116
                boolean hasTargetTaxonPermission = targetNode.getTaxon() == null ?
117
	        			true :
118
	        			CdmStore.currentAuthentiationHasPermission(targetNode.getTaxon(), UPDATE);
124 119

  
125 120
                if(logger.isDebugEnabled()){
126 121
                    logger.debug("target: " + targetNode.getTaxon().getTitleCache()); //$NON-NLS-1$
......
128 123

  
129 124
		        if(!hasTargetNodePermission || ! hasTargetNodePermission){
130 125
		            if(logger.isDebugEnabled()){
131
		                logger.debug("CANCEL_STATUS for target node: " + hasTargetNodePermission.toString() + " " + hasTargetTaxonPermission.toString() + " "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
126
		                logger.debug("CANCEL_STATUS for target node: " + hasTargetNodePermission + " " + hasTargetTaxonPermission + " "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
132 127
		            }
133 128
		            return Status.CANCEL_STATUS;
134 129
		        }
......
138 133
		    // check users permissions with all selected taxon nodes and taxa
139 134
		    for(TaxonNode taxonNode : getSelectedTaxa()){
140 135
			    logger.debug("selectedTaxa: " + taxonNode.getTaxon().getTitleCache()); //$NON-NLS-1$
141
				Boolean isSameTaxonNode = taxonNode.equals(target);
142
				Boolean hasTaxonNodePermission = CdmStore.currentAuthentiationHasPermission(taxonNode, UPDATE);
143
				Boolean hasTaxonPermission = CdmStore.currentAuthentiationHasPermission(taxonNode.getTaxon(), UPDATE);
136
				boolean isSameTaxonNode = taxonNode.equals(target);
137
				boolean hasTaxonNodePermission = CdmStore.currentAuthentiationHasPermission(taxonNode, UPDATE);
138
				boolean hasTaxonPermission = CdmStore.currentAuthentiationHasPermission(taxonNode.getTaxon(), UPDATE);
144 139
                if (
145 140
			        isSameTaxonNode
146 141
			        || !hasTaxonNodePermission
147 142
    	            || !hasTaxonPermission
148 143
	                ) {
149 144
                    if(logger.isDebugEnabled()){
150
                        logger.debug("CANCEL_STATUS for selected  " + isSameTaxonNode.toString() + " " + hasTaxonNodePermission.toString() + " " + hasTaxonPermission.toString() + " "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
145
                        logger.debug("CANCEL_STATUS for selected  " + isSameTaxonNode + " " + hasTaxonNodePermission + " " + hasTaxonPermission + " "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
151 146
                    }
152 147
					return Status.CANCEL_STATUS;
153 148
				}
......
257 252
		}
258 253
	}
259 254

  
260
	/* (non-Javadoc)
261
	 * @see eu.etaxonomy.taxeditor.operations.IPostOperationEnabled#postOperation(eu.etaxonomy.cdm.model.common.CdmBase)
262
	 */
263 255
	/** {@inheritDoc} */
264 256
	@Override
265 257
    public boolean postOperation(CdmBase objectAffectedByOperation) {

Also available in: Unified diff