Revision f77fd7f6
Added by Patrick Plitzner almost 7 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/AbstractUtility.java | ||
---|---|---|
40 | 40 |
import org.eclipse.jface.operation.IRunnableWithProgress; |
41 | 41 |
import org.eclipse.jface.resource.ColorRegistry; |
42 | 42 |
import org.eclipse.jface.resource.FontRegistry; |
43 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
44 |
import org.eclipse.jface.viewers.SelectionChangedEvent; |
|
43 | 45 |
import org.eclipse.swt.graphics.Color; |
44 | 46 |
import org.eclipse.swt.graphics.Font; |
45 | 47 |
import org.eclipse.swt.widgets.Display; |
... | ... | |
779 | 781 |
} |
780 | 782 |
} |
781 | 783 |
} |
784 |
|
|
785 |
/** |
|
786 |
* @param event |
|
787 |
* @return |
|
788 |
*/ |
|
789 |
public static Object getElementsFromSelectionChangedEvent(SelectionChangedEvent event) { |
|
790 |
IStructuredSelection selection = (IStructuredSelection) event.getSelection(); |
|
791 |
Object selectionToSet; |
|
792 |
if(selection.size() == 1){ |
|
793 |
selectionToSet = selection.getFirstElement(); |
|
794 |
} |
|
795 |
else if(!selection.isEmpty()){ |
|
796 |
selectionToSet = selection.toArray(); |
|
797 |
} |
|
798 |
else{ |
|
799 |
selectionToSet = selection; |
|
800 |
} |
|
801 |
return selectionToSet; |
|
802 |
} |
|
782 | 803 |
} |
Also available in: Unified diff
Fix potential class cast exception during selection handling