Skip to main content



      Home
Home » Newcomers » Newcomers » Repaint View
Repaint View [message #178951] Wed, 08 November 2006 05:53 Go to next message
Eclipse UserFriend
Originally posted by: dmarfil.citic.es

Hi everybody, I'm a newbie about RCP and I'm trying to do something that
I'm not sure about how can be done. First I've searched about it here but
didn't found anything...
I've got a view where I add widgets in createPartControl in an simple way.
I add a button too which must process the user's input, and then I want to
re-use the same view to load new widgets in it, but I have to remove the
old widgets from it before (I hope you understand my english). That is, I
need to repaint (re-init, reset) the view before I add more widgets.
I suppose it's not a difficult thing to do, but I don't know how to do
it...
Any help would be great!

Thanks in advance!
Re: Repaint View [message #178959 is a reply to message #178951] Wed, 08 November 2006 06:15 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dmarfil.citic.es

Ouch, sorry, I've discovered this is not the right place to post my
question.
But anyway, if anybody knows about it, I will appreciate the help ;-)


"Danny Marfil" <dmarfil@citic.es> escribi
Re: Repaint View [message #178975 is a reply to message #178959] Wed, 08 November 2006 09:22 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wayne.beaton._NOSPAM_eclipse.org

Danny Marfil wrote:
> Ouch, sorry, I've discovered this is not the right place to post my
> question.
> But anyway, if anybody knows about it, I will appreciate the help ;-)
>
>
> "Danny Marfil" <dmarfil@citic.es> escribió en el mensaje
> news:97a8591db230bf7ccafcb75854a940c2$1@www.eclipse.org...
>
>>Hi everybody, I'm a newbie about RCP and I'm trying to do something that
>>I'm not sure about how can be done. First I've searched about it here but
>>didn't found anything...
>>I've got a view where I add widgets in createPartControl in an simple way.
>>I add a button too which must process the user's input, and then I want to
>>re-use the same view to load new widgets in it, but I have to remove the
>>old widgets from it before (I hope you understand my english). That is, I
>>need to repaint (re-init, reset) the view before I add more widgets.
>>I suppose it's not a difficult thing to do, but I don't know how to do
>>it...
>>Any help would be great!
>>
>>Thanks in advance!
>>
>
>
>
Take a look at SWT Snippet98

http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/org. eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet98. java

Wayne
Re: Repaint View [message #178983 is a reply to message #178975] Wed, 08 November 2006 11:04 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dmarfil.citic.es

Thanks Wayne, but I'm trying to find a way to re-initialize a view, if that
is possible (I don't know).
Does not exist a way to tell eclipse "dispose every widget in the view and
start drawing again since now"?

Indeed, I'm using a form as container this way:
toolkit = new FormToolkit(parent.getDisplay());
form = toolkit.createScrolledForm(parent);

Then I use form.getBody() as every widget's container, for example:
Button btnExample = toolkit.createButton(form.getBody(), "", SWT.PUSH);

If the user clicks on the button (for example), I would like to reset the
view and start loading other widgets in it. I got the button's listener, but
what must I include there to reset the view?
Maybe if I could "reset" the form, that would be sufficient...

Anyway thanks very much for your help!

DANNY


"Wayne Beaton" <wayne.beaton@_NOSPAM_eclipse.org> escribi
Re: Repaint View [message #178997 is a reply to message #178983] Wed, 08 November 2006 12:01 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wayne.beaton._NOSPAM_eclipse.org

Danny Marfil wrote:
> Thanks Wayne, but I'm trying to find a way to re-initialize a view, if that
> is possible (I don't know).
> Does not exist a way to tell eclipse "dispose every widget in the view and
> start drawing again since now"?
>
> Indeed, I'm using a form as container this way:
> toolkit = new FormToolkit(parent.getDisplay());
> form = toolkit.createScrolledForm(parent);
>
> Then I use form.getBody() as every widget's container, for example:
> Button btnExample = toolkit.createButton(form.getBody(), "", SWT.PUSH);
>
> If the user clicks on the button (for example), I would like to reset the
> view and start loading other widgets in it. I got the button's listener, but
> what must I include there to reset the view?
> Maybe if I could "reset" the form, that would be sufficient...
>
> Anyway thanks very much for your help!
>
> DANNY
>
>
> "Wayne Beaton" <wayne.beaton@_NOSPAM_eclipse.org> escribió en el mensaje
> news:4551E82C.4070704@_NOSPAM_eclipse.org...
>
>>Danny Marfil wrote:
>>
>>>Ouch, sorry, I've discovered this is not the right place to post my
>>>question.
>>>But anyway, if anybody knows about it, I will appreciate the help ;-)
>>>
>>>
>>>"Danny Marfil" <dmarfil@citic.es> escribió en el mensaje
>>>news:97a8591db230bf7ccafcb75854a940c2$1@www.eclipse.org...
>>>
>>>
>>>>Hi everybody, I'm a newbie about RCP and I'm trying to do something that
>>>>I'm not sure about how can be done. First I've searched about it here but
>>>>didn't found anything...
>>>>I've got a view where I add widgets in createPartControl in an simple
>>>>way. I add a button too which must process the user's input, and then I
>>>>want to re-use the same view to load new widgets in it, but I have to
>>>>remove the old widgets from it before (I hope you understand my english).
>>>>That is, I need to repaint (re-init, reset) the view before I add more
>>>>widgets.
>>>>I suppose it's not a difficult thing to do, but I don't know how to do
>>>>it...
>>>>Any help would be great!
>>>>
>>>>Thanks in advance!
>>>>
>>>
>>>
>>>
>>Take a look at SWT Snippet98
>>
>> http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/org. eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet98. java
>>
>>Wayne
>
>
>
Look harder at the snippet.

To clear your view, dispose the widgets you want to get rid of. In the
snippet, they put the widgets on a composite and dispose the composite.
Then create a new composite.

Here's an example:

public class SampleView extends ViewPart {
private Composite contents;

public void createPartControl(final Composite parent) {
contents = new Composite(parent, SWT.NONE);
contents.setLayout(new GridLayout());
new Label(contents, SWT.NONE).setText("Some label");
Button button = new Button(contents, SWT.NONE);
button.setText("Hello");
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
contents.dispose();
contents = new Composite(parent, SWT.NONE);
contents.setLayout(new GridLayout());
new Label(contents, SWT.NONE).setText("A different label");
new Text(contents, SWT.BORDER).setText("World!");
parent.layout();
}
});
}

public void setFocus() {
contents.setFocus();
}
}

This will work with the form toolkit as well.
Re: Repaint View [message #179176 is a reply to message #178997] Thu, 09 November 2006 06:39 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dmarfil.citic.es

You were right, Wayne, and that was what I was trying to do.
I've tried your code and recoded it with forms, and it works fine ;-)
Now I have to take that into my "big" application, but the first step have
been walked.

Thank you very much for your help, I really appreciate it.


"Wayne Beaton" <wayne.beaton@_NOSPAM_eclipse.org> escribi
Re: Repaint View [message #179226 is a reply to message #179176] Thu, 09 November 2006 09:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wayne.beaton._NOSPAM_eclipse.org

Danny Marfil wrote:
> You were right, Wayne, and that was what I was trying to do.
> I've tried your code and recoded it with forms, and it works fine ;-)
> Now I have to take that into my "big" application, but the first step have
> been walked.
>
> Thank you very much for your help, I really appreciate it.
>
>

I wonder if this might be a good topic for an Eclipse Corner article.
Maybe after you've got it all working just right, you might consider
proposing an article.

Wayne
Re: Repaint View [message #179801 is a reply to message #179226] Mon, 13 November 2006 03:51 Go to previous message
Eclipse UserFriend
Originally posted by: dmarfil.citic.es

Hi Wayne,

since I'm quite newbie with Eclipse + RCP and my english is not so good, I
think it would be a hard work for me, but I would like to help in some way.
I offer my code and anything that could be useful for that, I would even try
to write something.
Anyway I think I haven't got the sufficient knowledge and experience about
this to write an article... I wish I could ;-)

Danny


"Wayne Beaton" <wayne.beaton@_NOSPAM_eclipse.org> escribi
Previous Topic:Problems!
Next Topic:how to enable and disable context menuitem ??
Goto Forum:
  


Current Time: Fri Jul 18 00:40:09 EDT 2025

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

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

Back to the top