Project

General

Profile

Download (1.07 KB) Statistics
| Branch: | Tag: | Revision:
1
package eu.etaxonomy.taxeditor.bulkeditor.command;
2

    
3
import org.eclipse.core.expressions.PropertyTester;
4
import org.eclipse.jface.viewers.IStructuredSelection;
5

    
6
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
7
import eu.etaxonomy.taxeditor.bulkeditor.input.BulkEditorInputType;
8

    
9
public class BulkEditorSelectionPropertyTester extends PropertyTester {
10

    
11
    public static final String IS_BULK_EDITOR_SUPPORTED = "isBulkEditorSupported";
12

    
13
	@Override
14
	public boolean test(Object receiver, String property, Object[] args,
15
			Object expectedValue) {
16
		if(IS_BULK_EDITOR_SUPPORTED.equals(property)){
17
			if(receiver instanceof IStructuredSelection){
18
				IStructuredSelection selection = (IStructuredSelection) receiver;
19
				Object selectedElement = selection.getFirstElement();
20
				if(selectedElement!=null){
21
				    if(selectedElement instanceof UuidAndTitleCache){
22
				        return BulkEditorInputType.getByType(((UuidAndTitleCache) selectedElement).getType())!=null;
23
				    }
24
					return BulkEditorInputType.getByType(selectedElement.getClass())!=null;
25
				}
26
			}
27
		}
28
		return false;
29
	}
30

    
31
}
(3-3/7)