|
Re: How Can i Reach Dynamicly Created Text ? [message #1011417 is a reply to message #1011402] |
Tue, 19 February 2013 14:44 |
|
Hello serhat,
by part you mean org.eclipse.ui.IViewPart?
Could you please explain your use case?
A button in a view, which modifies text in a second view sound a bit weird.
I guess I could offer a better solution for you, if you would tell us more about for intent.
Best regards,
Simon
|
|
|
|
Re: How Can i Reach Dynamicly Created Text ? [message #1011561 is a reply to message #1011438] |
Tue, 19 February 2013 19:54 |
|
Serhat,
Get your desire ViewPart by Id by using following code. Cast it and call your method to update text.
public static IViewPart getView(IWorkbenchWindow window, String viewId) {
IViewReference[] refs = window.getActivePage().getViewReferences();
for (IViewReference viewReference : refs) {
if (viewReference.getId().equals(viewId)) {
return viewReference.getView(true);
}
}
return null;
}
-Omer Gillani
|
|
|
|
Re: How Can i Reach Dynamicly Created Text ? [message #1011748 is a reply to message #1011594] |
Wed, 20 February 2013 07:34 |
|
After getting your ViewPart. Type cast it to your ViewPart class
like...
....
if (event.widget == generateButton) {
IViewPart viewPart = getView(window, viewId);
MyViewPart myViewPart = (MyViewPart)viewPart;
myViewPart.updateText(...);
}
...
Make the method in your MyViewPart class that will update the text.
-Omer Gillani
|
|
|
Re: How Can i Reach Dynamicly Created Text ? [message #1011775 is a reply to message #1011748] |
Wed, 20 February 2013 08:32 |
|
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.03150 seconds