How to change the label of a ToolControlImpl [message #1033286] |
Thu, 04 April 2013 04:17 |
Mark Leone Messages: 69 Registered: April 2012 |
Member |
|
|
I have a ToolControlImpl added to the trim for various views, and I'm able to retrieve it with the model service. Now I want to do a couple things with it, and I haven't been able to find out how:
I need to get a reference to the Control that was created as a child of 'parent' in ToolControlImpl#createPartControl. It happens to be a Label in my case. I don't see any way to get access to it. I tried casting the retrieved model object to its actual class, which is a subclass of ToolControlImpl, but the cast fails. WHat I'm trying to do is dynamically change the label text and the listener on the Label inside the ToolControlImpl.
If I call getWidget() on the ToolControlImpl, I get a Composite, but its list of children is empty. Yet a Label was added to it when the part control was created. Here's the code for my ToolControlImpl:
public class CustomButton1 extends ToolControlImpl {
private Label label;
@PostConstruct
public void createPartControl(Composite parent) {
GridLayoutFactory.fillDefaults().applyTo(parent);
label = new Label(parent, SWT.NONE);
label.setText("Label");
GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER);
label.addMouseMoveListener(new MouseMoveListener() {
@Override
public void mouseMove(MouseEvent e) {
System.err.println("MOUSE MOVE Label 1");
}
});
}
public Control getControl() {
return this.label;
}
}
[Updated on: Thu, 04 April 2013 04:19] Report message to a moderator
|
|
|
Re: How to change the label of a ToolControlImpl [message #1033748 is a reply to message #1033286] |
Thu, 04 April 2013 15:43 |
Mark Leone Messages: 69 Registered: April 2012 |
Member |
|
|
So I think the problem is that the model service is not returning the proper ToolControlImpl. In the model editor, I add a ToolControl to
Application -> Windows -> Trimmed Window -> TrimBars -> Window Trim -> Toolbar .
I also add a ToolControl to
Application -> Windows -> Trimmed Window -> Main Menu -> Controls -> Perspective Stack -> Perspective -> Controls -> PartSashContainer -> Part Stack -> Part -> Toolbar
for each of three Parts.
But when I search via the model service, I only find the ToolControl added to the toolbar of the TrimBars, and not the ones added to the toolbar of each Part, even though the Part's ToolControls are displayed and active.
I tried searching by element type
elements = modelService.findElements(application, null, ToolControlImpl.class, null)
This returns only the TrimBars ToolControl.
by ID:
elements = modelService.findElements(application, controlId ,null, null)
This returns the TrimBars ToolControl when I give it that ID, empty list when I give it the ID of either of the Part ToolControl items.
and by tag
elements = modelService.findElements(application, null, null, tags)
This returns an empty list when I specify a tag that was assigned to one of the Part's ToolControl items.
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05652 seconds