How Can i Reach Dynamicly Created Text ? [message #1011402] |
Tue, 19 February 2013 09:15  |
Eclipse User |
|
|
|
Hi,
I'm new on Eclipse rcp and i little confused.
I have two part (part1, part2). And i want to;
on button click action from part1, i need to reach part2's Text field and change its text
but i can't do. What i must use anyone can help me ?
|
|
|
|
|
|
|
|
Re: How Can i Reach Dynamicly Created Text ? [message #1011775 is a reply to message #1011748] |
Wed, 20 February 2013 03:32  |
Eclipse User |
|
|
|
Hello serhat,
I am still not sure what you want to archieve with this "button and text thing", so I´ll just give you the easiest solution I can imagine:
Button button = new Button(parent, SWT.PUSH);
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Button button = (Button) e.widget;
IViewPart findView = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage()
.findView("Part 2 viewId, which is defined in the plugin.xml");
if (findView instanceof Part2View) {
Part2View part2View = (Part2View) findView;
part2View.setText(button.getText());
}
}
});
An even better approach would be to make Part1 offer an org.eclipse.jface.viewers.ISelectionProvider and register Part2 as org.eclipse.ui.ISelectionListener.
Will there be several buttons in Part1, which set the text in Part2?
Why don´t you use a TreeViewer or something simimar?
A TreeViewer for instance is a ISelectionProvider itself, so that it can easily pass it´s selection to other Parts, which are registered as ISelectionListener.
Let me know, if you want to know more about Eclipse´s SelectionServices or if the solution above satisfies you.
Best regards,
Simon
|
|
|
Powered by
FUDForum. Page generated in 0.05551 seconds