Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Expand/Collapse Custom Feature
Expand/Collapse Custom Feature [message #897246] Mon, 23 July 2012 11:51 Go to next message
Surya Kathayat is currently offline Surya KathayatFriend
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.

index.php/fa/10807/0/

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

Re: Expand/Collapse Custom Feature [message #897256 is a reply to message #897246] Mon, 23 July 2012 12:32 Go to previous messageGo to next message
Matthias Gorning is currently offline Matthias GorningFriend
Messages: 81
Registered: April 2010
Location: Germany
Member
I assume that you already have an add feature for your Task nodes.

Hence you can simply add these lines to the execute method of your custom feature:

AreaContext areaContext = new AreaContext();
areaContext.setLocation(20, 20);
areaContext.setSize(100, 100);
AddContext addContext = new AddContext(areaContext, <your business object>); // Tasks or Links
addContext.setTargetContainer(getDiagram());
getFeatureProvider().addIfPossible(addContext);
Re: Expand/Collapse Custom Feature [message #897271 is a reply to message #897256] Mon, 23 July 2012 13:21 Go to previous messageGo to next message
Surya Kathayat is currently offline Surya KathayatFriend
Messages: 44
Registered: July 2012
Member
Thank you Matthias. Razz
It works as you said.
How can I change the icon of collapse context button dynamically?

BR
Surya
Re: Expand/Collapse Custom Feature [message #900759 is a reply to message #897271] Wed, 08 August 2012 12:13 Go to previous message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
You should be able to do that by simply setting a new image id for the image
object (the string identifier defined in the image provider).

Michael
Previous Topic:DirectEditing in two or more texts
Next Topic:Diagram Layout
Goto Forum:
  


Current Time: Fri Apr 26 04:59:46 GMT 2024

Powered by FUDForum. Page generated in 0.03214 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top