2011-06-25 15 views

回答

1

我没有测试正常以下的时间,但它可能是一个很好的起点:

public class SetFileToROHandler extends AbstractHandler implements IHandler { 
    @Override 
    public Object execute(ExecutionEvent event) throws ExecutionException { 
    final ISelection s = HandlerUtil.getCurrentSelectionChecked(event); 
    if (!(s instanceof IStructuredSelection)) 
     return null; 
    final IStructuredSelection ss = (IStructuredSelection) s; 
    for (final Object o : ss.toArray()) { 
     if (!(o instanceof IFile)) { 
     continue; 
     } 
     IFile f = (IFile) o; 
     f.setReadOnly(true); 
    } 
    return null; 
    } 
} 
相关问题