Project

General

Profile

Download (1.28 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
import org.eclipse.jface.viewers.TreeNode;
6

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

    
10
public class BulkEditorSelectionPropertyTester extends PropertyTester {
11

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

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

    
35
}
(3-3/7)