}
}
}
});
Menu menu=new Menu();
final MenuItem follow = new MenuItem("关注(接收报警)",
new SelectionHandler<MenuItem>() {
@Override
public void onSelection(SelectionEvent<MenuItem> event) {
final GroupJobTreeModel model = tree.getSelectionModel().getSelectedItem();
int type = 0;
if (model.isGroup()) {
type = 1;
} else if (model.isJob()) {
type = 2;
}
RPCS.getTreeService().follow(type,
model.getId(),
new AbstractAsyncCallback<Void>() {
public void onSuccess(Void result) {
model.setFollow(true);
tree.refresh(model);
Info.display("成功", "关注成功");
}
});
}
});
final MenuItem unfollow = new MenuItem("取消关注",
new SelectionHandler<MenuItem>() {
@Override
public void onSelection(SelectionEvent<MenuItem> event) {
final GroupJobTreeModel model = tree
.getSelectionModel().getSelectedItem();
int type = 0;
if (model.isGroup()) {
type = 1;
} else if (model.isJob()) {
type = 2;
}
RPCS.getTreeService().unfollow(type,
model.getId(),
new AbstractAsyncCallback<Void>() {
public void onSuccess(Void result) {
model.setFollow(false);
tree.refresh(model);
Info.display("成功", "取消关注成功");
}
});
}
});
menu.add(follow);
menu.add(unfollow);
tree.setContextMenu(menu);
tree.addBeforeShowContextMenuHandler(new BeforeShowContextMenuHandler() {
public void onBeforeShowContextMenu(BeforeShowContextMenuEvent event) {
GroupJobTreeModel model=tree.getSelectionModel().getSelectedItem();
if(model!=null){
if(model.isFollow()){
follow.hide();
unfollow.show();
}else{
follow.show();
unfollow.hide();
}
}
}
});
filter=new StoreFilterField<GroupJobTreeModel>(){