Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [EMF Forms] Redraw custom control
[EMF Forms] Redraw custom control [message #1708950] Tue, 22 September 2015 17:54 Go to next message
Tobias Zangl is currently offline Tobias ZanglFriend
Messages: 15
Registered: May 2015
Junior Member
Hey,

how can i programmatically redraw a custom control or a complete view?
I already tried something like composite.layout()/pack()/redraw() or parent.layout() in a button listener but the control is not rendered again.. Any hints?

And one small question: Is it possible to remove the red X on the top right of model views so the user is not able to manually remove those model elements?

Thanks in advance.
Greetings,
Tobi
Re: [EMF Forms] Redraw custom control [message #1708991 is a reply to message #1708950] Wed, 23 September 2015 07:46 Go to previous messageGo to next message
Jonas Helming is currently offline Jonas HelmingFriend
Messages: 699
Registered: July 2009
Senior Member
Hi Tobi,



> Hey,
>
> how can i programmatically redraw a custom control or a complete view?
> I already tried something like composite.layout()/pack()/redraw() or
> parent.layout() in a button listener but the control is not rendered
> again.. Any hints?

Your calls seem right, I assume you are calling them on the wrong
composite. However, I wonder what you wanna achieve with this manual redraw?

>
> And one small question: Is it possible to remove the red X on the top
> right of model views so the user is not able to manually remove those
> model elements?

Are you using the demo application provided by ECP or which red X are we
talking about?

Best regards

Jonas


>
> Thanks in advance.
> Greetings,
> Tobi


--
--

Jonas Helming

Get professional Eclipse developer support:

http://eclipsesource.com/en/services/developer-support/
Re: [EMF Forms] Redraw custom control [message #1709026 is a reply to message #1708991] Wed, 23 September 2015 11:49 Go to previous messageGo to next message
Tobias Zangl is currently offline Tobias ZanglFriend
Messages: 15
Registered: May 2015
Junior Member
Hey Jonas,

Thanks for your fast response (as always)! Smile

My code looks something like this:

@Override
	public Control renderControl(SWTGridCell cell, Composite parent)
			throws NoRendererFoundException, NoPropertyDescriptorFoundExeption {

		Composite composite = new Composite(parent, SWT.NONE);
		
		final Composite finalParent = parent;
		
		Button refresh = new Button(composite, SWT.PUSH);
		refresh.setText("Refresh");
		refresh.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e) {
				...
				/*composite.layout();
				finalParent.pack();
				finalParent.layout();*/
			}
		});
...


I tried calling different methods on parent, finalParent and composite but it did not work. I had an instance integer variable which i incremented and rendered as a label but it did not get updated.

Usecase:
I have a rather complex custom control with an arbitrary amount of tables with input and depending on data which is calculated in the refresh method the amount of tables and their content changes thus i have to redraw the whole view. I know there might be better approaches with content provider but at the moment i just want to get it to work.. Confused


Red X:
Have a look at the attached image. It looks a little bit like it closes the view but it removes the model element and in my case the removing should not be possible for some model elements.

Greetings,
Tobi
Re: [EMF Forms] Redraw custom control [message #1709116 is a reply to message #1709026] Thu, 24 September 2015 07:39 Go to previous message
Jonas Helming is currently offline Jonas HelmingFriend
Messages: 699
Registered: July 2009
Senior Member
Hi Tobias,

I wonder how you bind the value to the label. I guess you just call
setText somewhere? This code will not be re-executed on a redraw of the
composite. I suggest you bind the label to the value using either
databinding (prefered) or another listener mechanism.

About the red cross: This is the standard Editor provided by ECP. If you
want to adapt this, you should implement your own editor.

To do that, have a look at the class MEEditor in
"org.eclipse.emf.ecp.editor.e3", it implements the editor itself and
internally it adds a "MEEditorPage", which adds the delete action.

After you have implemented your custom editor, you should implement an
ModelElementOpener to replace the existing one, see
http://eclipsesource.com/blogs/tutorials/tutorialshow-to-customize-the-emf-client-platform/#replaceeditor

As a template, have a look at the current ModelElementOpener:
"EditorModelElementOpener" in "org.eclipse.emf.ecp.explorereditorbridge"

Best regards

Jonas

Am 23.09.2015 um 13:49 schrieb Tobias Zangl:
> Hey Jonas,
>
> Thanks for your fast response (as always)! :)
>
> My code looks something like this:
>
> @Override
> public Control renderControl(SWTGridCell cell, Composite parent)
> throws NoRendererFoundException, NoPropertyDescriptorFoundExeption {
>
> Composite composite = new Composite(parent, SWT.NONE);
>
> final Composite finalParent = parent;
>
> Button refresh = new Button(composite, SWT.PUSH);
> refresh.setText("Refresh");
> refresh.addSelectionListener(new SelectionAdapter() {
> public void widgetSelected(SelectionEvent e) {
> ...
> /*composite.layout();
> finalParent.pack();
> finalParent.layout();*/
> }
> });
> ..
>
>
> I tried calling different methods on parent, finalParent and composite but it did not work. I had an instance integer variable which i incremented and rendered as a label but it did not get updated.
>
> Usecase:
> I have a rather complex custom control with an arbitrary amount of tables with input and depending on data which is calculated in the refresh method the amount of tables and their content changes thus i have to redraw the whole view. I know there might be better approaches with content provider but at the moment i just want to get it to work.. :?
>
>
> Red X:
> Have a look at the attached image. It looks a little bit like it closes the view but it removes the model element and in my case the removing should not be possible for some model elements.
>
> Greetings,
> Tobi
>


--
--

Jonas Helming

Get professional Eclipse developer support:

http://eclipsesource.com/en/services/developer-support/
Previous Topic:[EMFForms] View model handling of derived classes
Next Topic:ECP 1.7 and EMFStore 1.6
Goto Forum:
  


Current Time: Thu Apr 25 15:46:52 GMT 2024

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

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

Back to the top