[Dvlp plugin] CastException classe File dans méthode selectionChanged
Bonjour,
Je tatonne dans le développement de plugin, et je suis confronté à un problème que je ne m'explique pas.
Donc, j'ai ma classe MyAction qui implemente IObjectActionDelegate, et je veux récupérer la sélection en surchargeant la méthode selectionChanged(IAction action, ISelection selection) tel que :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
public void selectionChanged(IAction action, ISelection selection) {
if(!selection.isEmpty()){
if(selection instanceof IStructuredSelection){
IStructuredSelection ss = (IStructuredSelection)selection;
Object file=ss.getFirstElement();
try{
m_selectedFile=(org.eclipse.core.internal.resources.File)file;
}catch(Exception e){
System.out.println("EXCEP");
e.printStackTrace();
}
}
}
} |
Le problème c'est qu'une exception est levée de type java.lang.ClassCastException: org.eclipse.core.internal.resources.File alors que quand je fais file.getClass() il me retourne bien org.eclipse.core.internal.resources.File ??
Quelqu'un a-t-il déjà eu ce problème ??
Merci