List selection = getSelectedObjects();
List al=new ArrayList();
for(Object o: selection){
if(o instanceof GraphicalBasicBlockEditPart){
GraphicalBasicBlockEditPart gb=(GraphicalBasicBlockEditPart)o;
if(((GraphicalBasicBlock)gb.getModel()).getParent() instanceof GraphicalCompositeBlock){
}else{
al.add(o);
}
}
}
try{
selection.removeAll(al); }catch(Exception e){
System.out.println(e.getStackTrace());
}为什么总是输出异常java.lang.UnsupportedOperationException
List al=new ArrayList();
for(Object o: selection){
if(o instanceof GraphicalBasicBlockEditPart){
GraphicalBasicBlockEditPart gb=(GraphicalBasicBlockEditPart)o;
if(((GraphicalBasicBlock)gb.getModel()).getParent() instanceof GraphicalCompositeBlock){
}else{
al.add(o);
}
}
}
try{
selection.removeAll(al); }catch(Exception e){
System.out.println(e.getStackTrace());
}为什么总是输出异常java.lang.UnsupportedOperationException
List selection = getSelectedObjects();
List al=new ArrayList();
for(Object o: selection){
if(o满足某种条件){
al.add(o);
}
}
try{
selection.removeAll(al);
}catch(Exception e){
System.out.println(e.getStackTrace());
}为什么总是输出异常java.lang.UnsupportedOperationException
可用其它方法实现你的功能,如写个循环,用remove方法
或改用Set接口
getSelectedObjects();这个方法是不是返回了只读的list
比如
List getSelectedObjects() {
List list = new ArrayList();
list.add("xxx");
return Collections.unmodifiableList(list); //返回只读的list
}
这样的话,外面是不能修改它的