Expand/Collapse Custom Feature [message #897246] |
Mon, 23 July 2012 11:51 |
Surya Kathayat Messages: 44 Registered: July 2012 |
Member |
|
|
Hi,
I am trying to write a custom feature to a Task node in graphical editor.
The feature shall do the following.
- Update the icon of collapse context button dynamically i.e. after the node is collabpse expladable icon shall be shown.
- When expanded some extra nodes will be added/shown in adiagram editor. For example in the attached figure, when "expand" on "X" node is clicked, then nodes "A", "B" and links X->A, X->B will be shown. The case will be opposite on collapse.
The following is execute method of my custom feature class. The question is how can I add/delete nodes and links to the diagram from the "execute" method of my custom feature class?
@Override
public void execute(ICustomContext context) {
MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Information",
"The 'Collapse Feature' is intentionally not implemented yet.");
PictogramElement[] pes = context.getPictogramElements();
if (pes != null && pes.length == 1) {
Object bo = getBusinessObjectForPictogramElement(pes[0]);
if (bo instanceof Task) {
Task task = (Task) bo;
if((task.getHasSubtasks() !=null) && task.getHasSubtasks()==1){
// set the icon flag
this.isExpanded = true;
// get db connection
TaskDaoProxy taskDaoProxy = new TaskDaoProxyImpl(task.getIdCenterName());
// I will get list of links and tasks nodes here
List<Link> links = taskDaoProxy.getChildTaskLinksForGraph(Integer.valueOf(task.getMcTaskId()), false);
// then HOW TO ADD THEM IN DIAGRAM ???
}
else {
// set the icon flag
this.isExpanded = false;
}
// update pictogram
updatePictogramElement(pes[0]);
// set the done flag
this.hasDoneChanges = true;
}
}
}
@Override
public boolean hasDoneChanges() {
return this.hasDoneChanges;
}
[Updated on: Mon, 23 July 2012 11:52] Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03933 seconds