2008년 07월 23일
[gmf] 다이어그램에서 node filtering하기
I was able to create a command to hide the view based using attribute
when i do hide all or unhide all it working fine but when try to hide some port node in this case let us take to hide all inport port and all unhide outport then it is not refreshing correctly elements i.e hide is working fine but unhide ports are not appearing back on editor if debug i can see the view.setVisible(true) but still it not visible ?
------------------------
I had a similar problem. To solve the problem, inside the BorderedShapeEditPart (the parent), I overwrote #handleNotificationEvent(Notification event). Now, it only refreshes the child EditPart, which visibility has changed:
I impl an action "hideAllConnectors" to hide all the connectors on diagram. It works well, all connectors disappeared, and as a result, the "visible=false" set on all edges . But when diagram refreash (such as, scroll the diagram), some of the connectors re-appeared without any changes on digram file.
Also notice that, these re-appeared connectors are connectors of non-top shapes.
It should be a bug? Any workaround here?
CompositeCommand cc = new CompositeCommand("Diagram_settings");
BorderedBorderItemEditPart compShapeEditPart = (BorderedBorderItemEditPart)object;
View hostView =(View)compShapeEditPart.getModel();
cc.add(new ShowHidePortsCommand(editingDomain,hostView,true));when i do hide all or unhide all it working fine but when try to hide some port node in this case let us take to hide all inport port and all unhide outport then it is not refreshing correctly elements i.e hide is working fine but unhide ports are not appearing back on editor if debug i can see the view.setVisible(true) but still it not visible ?
------------------------
I had a similar problem. To solve the problem, inside the BorderedShapeEditPart (the parent), I overwrote #handleNotificationEvent(Notification event). Now, it only refreshes the child EditPart, which visibility has changed:
if (NotationPackage.eINSTANCE.getView_Visible().equals( event.getFeature())) {
Node node = (Node) event.getNotifier();
refreshChild((GraphicalEditPart)getChildBySemanticHint( node.getType()));
}else {
super.handleNotificationEvent(event);
}I impl an action "hideAllConnectors" to hide all the connectors on diagram. It works well, all connectors disappeared, and as a result, the "visible=false" set on all edges . But when diagram refreash (such as, scroll the diagram), some of the connectors re-appeared without any changes on digram file.
Also notice that, these re-appeared connectors are connectors of non-top shapes.
It should be a bug? Any workaround here?
protected void doRun(IProgressMonitor progressMonitor) ...
IDiagramEditDomain dEditingDomain = getDiagramEditPart().getDiagramEditDomain();
TransactionalEditingDomain tEditingDomain = getDiagramEditPart().getEditingDomain();
AbstractTransactionalCommand atc = new AbstractTransactionalCommand(tEditingDomain, "Hide All Connections", null) {
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
for (Iterator iter = edges.iterator(); iter.hasNext();) {
ConnectionNodeEditPart ep = (ConnectionNodeEditPart) iter.next();
((Edge)ep.getModel()).setVisible(visible);
}
getDiagramEditPart().refresh();
return CommandResult.newOKCommandResult();
}
};
DiagramCommandStack cs = dEditingDomain.getDiagramCommandStack();
cs.execute(new ICommandProxy(atc));
..
}
# by | 2008/07/23 01:00 | GMF,GEF,EMF | 트랙백 | 덧글(0)




☞ 내 이글루에 이 글과 관련된 글 쓰기 (트랙백 보내기) [도움말]