Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » How to set data in a dynamically created part
How to set data in a dynamically created part [message #1162377] Wed, 30 October 2013 06:33 Go to next message
Felix Funke is currently offline Felix Funke
Messages: 1
Registered: October 2013
Junior Member
Hello,

I'm new to e4, but I'm developing an application that creates and visualized multiple network connections. For each connection I want to create a new part. I had problems trying to pass the connection information from a handler showing a selection dialog to the part, that should visualize the connection. Now I pass the information throught the persisted state of the part. Is that the correct (e4) way to do this?

I create my parts in a handler like this:

MPart part = partService.createPart("de.walmar.project.partdescriptor.ConnectionPart");
part.setLabel(dialogData.getAddress());
part.getPersistedState().put("connection.address", address);
      
List<MPartStack> stacks = modelService.findElements(application, "de.walmar.project.partstack.econnections", MPartStack.class, null);
if (stacks.size() > 0) {
  stacks.get(0).getChildren().add(part);
}
partService.showPart(part, PartState.ACTIVATE);


In my ConnectionPart I inject the MPart and read from the persisted state to find the address:

@PostConstruct
public void createComposite(Composite parent, MPart part) {
    System.out.println("Create ConnectionPart " + part.getPersistedState().get("connection.address"));
  }


Thanks
Re: How to set data in a dynamically created part [message #1165509 is a reply to message #1162377] Fri, 01 November 2013 06:30 Go to previous message
Eclipse User
On 10/30/2013 12:47 PM, Felix Funke wrote:
> Hello,
>
> I'm new to e4, but I'm developing an application that creates and
> visualized multiple network connections. For each connection I want to
> create a new part. I had problems trying to pass the connection
> information from a handler showing a selection dialog to the part, that
> should visualize the connection. Now I pass the information throught the
> persisted state of the part. Is that the correct (e4) way to do this?
>
> I create my parts in a handler like this:
>
>
> MPart part =
> partService.createPart("de.walmar.project.partdescriptor.ConnectionPart");
> part.setLabel(dialogData.getAddress());
> part.getPersistedState().put("connection.address", address);
> List<MPartStack> stacks = modelService.findElements(application,
> "de.walmar.project.partstack.econnections", MPartStack.class, null);
> if (stacks.size() > 0) {
> stacks.get(0).getChildren().add(part);
> }
> partService.showPart(part, PartState.ACTIVATE);
>
>
> In my ConnectionPart I inject the MPart and read from the persisted
> state to find the address:
>
>
> @PostConstruct
> public void createComposite(Composite parent, MPart part) {
> System.out.println("Create ConnectionPart " +
> part.getPersistedState().get("connection.address"));
> }

Hi Felix,

you might wanna subscribe to bug #420817 which discusses a similar issue.

M.

[1] https://bugs.eclipse.org/420817
Previous Topic:Eclipse Perspective Bar? Open Perspective Dialog?
Next Topic:Eclipse 4 RCP book available in its second edition
Goto Forum:
  


Current Time: Thu Jul 31 03:32:38 EDT 2014

Powered by FUDForum. Page generated in 0.02578 seconds