Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » e4 custom renderer not working(custom renderer not working)
e4 custom renderer not working [message #851439] Fri, 20 April 2012 21:01 Go to next message
ishk gunathilake is currently offline ishk gunathilake
Messages: 27
Registered: April 2012
Junior Member
hi
i change the default renderer as this

   <property
               name="rendererFactoryUri"
               value="platform:/plugin/com.rcp.myproject.renderer/com.rcp.myproject.renderer.MyRendererFactory">
         </property>


and i created a renderer as this

public class NewElementRenderer extends SWTPartRenderer {
	public Object createWidget(final MUIElement element, Object parent) {
          Label label = new Label((Composite)parent, SWT.NONE);
          label.setText("test widget");
          return label;
       }
   }


and my rendererFactory class is as follows

public class MyRendererFactory extends WorkbenchRendererFactory {

	protected NewElementRenderer newElementRenderer;

	
	@Override
	   public AbstractPartRenderer getRenderer(MUIElement uiElement, Object parent) {
		
		if(uiElement instanceof Label){
            if(newElementRenderer == null) {
                newElementRenderer = new NewElementRenderer();
                initRenderer(newElementRenderer);
            }
            return newElementRenderer;
        }
        return super.getRenderer(uiElement, parent);
    }



but what when i run this, i can only see an empty shell without that label.plz help me on this.

regards
}

Re: e4 custom renderer not working [message #851732 is a reply to message #851439] Sat, 21 April 2012 04:29 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5256
Registered: July 2009
Senior Member
a) the URI has to use the new bundleclass://
b) the renderer only deals with elments from the workbench model and
not very SWT-Widgets so your code makes no sense at all

Tom

Am 21.04.12 03:01, schrieb ishara gunathilake:
> hi
> i change the default renderer as this
>
> <property
> name="rendererFactoryUri"
>
> value="platform:/plugin/com.rcp.myproject.renderer/com.rcp.myproject.renderer.MyRendererFactory">
>
> </property>
>
> and i created a renderer as this
>
> public class NewElementRenderer extends SWTPartRenderer {
> public Object createWidget(final MUIElement element, Object parent) {
> Label label = new Label((Composite)parent, SWT.NONE);
> label.setText("test widget");
> return label;
> }
> }
>
> and my rendererFactory class is as follows
>
> public class MyRendererFactory extends WorkbenchRendererFactory {
>
> protected NewElementRenderer newElementRenderer;
>
>
> @Override
> public AbstractPartRenderer getRenderer(MUIElement uiElement,
> Object parent) {
>
> if(uiElement instanceof Label){
> if(newElementRenderer == null) {
> newElementRenderer = new NewElementRenderer();
> initRenderer(newElementRenderer);
> }
> return newElementRenderer;
> }
> return super.getRenderer(uiElement, parent);
> }
>
>
>
> but what when i run this, i can only see an empty shell without that
> label.plz help me on this.
>
> regards
> }
>
>
Re: e4 custom renderer not working [message #851815 is a reply to message #851732] Sat, 21 April 2012 06:41 Go to previous messageGo to next message
ishk gunathilake is currently offline ishk gunathilake
Messages: 27
Registered: April 2012
Junior Member
hi tom,
thanks for your reply.i am new to this. what do you mean by new bundleclass. previously my project ran under eclipse 3.2 platform.and currently i upgraded it to 4.1 to re skin the UI with css.but some of the 3.2 api calls are not working with 4.1 eclipse(WorkbenchWindowAdvisor.createWindowContents(Shell)).so all the UI components are disabled from my app UI because of this reason.. so im trying to re implement the code. Can you please give me some advice regarding this context.I appreciate your advice.

regards
Re: e4 custom renderer not working [message #851843 is a reply to message #851815] Sat, 21 April 2012 07:15 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5256
Registered: July 2009
Senior Member
a) Please use 4.2 builds (M6 or even better nightly builds)

b) We changed the URL format in 4.2 to bundleclass:// instead of
platform:/

c) You are correct with the createWindowContents which somehow part of
the old presentation API we are unable to support.

=> You want to handle the MTrimmedWindow-model type if the current
WBWRenderer doesn't suite your need

What did you do in your createWindowContents-method? Maybe you can solve
your problem in other ways in Eclipse 4.

Tom

Am 21.04.12 12:41, schrieb ishara gunathilake:
> hi tom,
> thanks for your reply.i am new to this. what do you mean by new
> bundleclass. previously my project ran under eclipse 3.2 platform.and
> currently i upgraded it to 4.1 to re skin the UI with css.but some of
> the 3.2 api calls are not working with 4.1
> eclipse(WorkbenchWindowAdvisor.createWindowContents(Shell)).so all the
> UI components are disabled from my app UI because of this reason.. so im
> trying to re implement the code. Can you please give me some advice
> regarding this context.I appreciate your advice.
>
> regards
Re: e4 custom renderer not working [message #851859 is a reply to message #851843] Sat, 21 April 2012 07:46 Go to previous messageGo to next message
ishk gunathilake is currently offline ishk gunathilake
Messages: 27
Registered: April 2012
Junior Member
this is the code which i use to create the window content. i set the menu bar and i create header footer and center using the MainPageComposite class
which construct the page components using createComposite method.
@Override
public void createWindowContents(final Shell shell)
{
IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
final Menu menu = configurer.createMenuBar();
shell.setMenuBar(menu);
shell.setLayout(new FillLayout());
mainPageComposite = new MainPageComposite(shell, SWT.NONE, this);
}

im getting empty workbench as this is not called by eclipse 4.1. currently i m trying to create renderers for all of these components.but still i dont have a clear picture of how to solve this using custom renderers. i appreciate your suggestions.
Re: e4 custom renderer not working [message #851870 is a reply to message #851859] Sat, 21 April 2012 07:59 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5256
Registered: July 2009
Senior Member
But why are you doing this your own? Why doesn't the default
implementation suite your needs? And please upgrade to 4.2 - we can't
give your support for 4.1.

Tom

Am 21.04.12 13:46, schrieb ishara gunathilake:
> this is the code which i use to create the window content. i set the
> menu bar and i create header footer and center using the
> MainPageComposite class
> which construct the page components using createComposite method.
> @Override
> public void createWindowContents(final Shell shell)
> {
> IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
> final Menu menu = configurer.createMenuBar();
> shell.setMenuBar(menu);
> shell.setLayout(new FillLayout());
> mainPageComposite = new MainPageComposite(shell, SWT.NONE, this);
> }
>
> im getting empty workbench as this is not called by eclipse 4.1.
> currently i m trying to create renderers for all of these components.but
> still i dont have a clear picture of how to solve this using custom
> renderers. i appreciate your suggestions.
Re: e4 custom renderer not working [message #851882 is a reply to message #851870] Sat, 21 April 2012 08:15 Go to previous messageGo to next message
ishk gunathilake is currently offline ishk gunathilake
Messages: 27
Registered: April 2012
Junior Member
this is a large project which consist of more than 20 plugins and more than 10 UIs.I did this to enable e4 css functionality so that i can change the UI very quickly. this is the main reason for upgrading 3.2 to 4.1. If i upgrade this to 4.2 what are the benefits i can get, coz i have to give another effort to upgrade this to 4.2.Why you are telling me to upgrade it to 4.2, does that mean 4.1 is not a stable release?
Re: e4 custom renderer not working [message #851901 is a reply to message #851882] Sat, 21 April 2012 08:36 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5256
Registered: July 2009
Senior Member
Am 21.04.12 14:15, schrieb ishara gunathilake:
> this is a large project which consist of more than 20 plugins and more
> than 10 UIs.I did this to enable e4 css functionality so that i can
> change the UI very quickly. this is the main reason for upgrading 3.2 to
> 4.1. If i upgrade this to 4.2 what are the benefits i can get, coz i
> have to give another effort to upgrade this to 4.2.Why you are telling
> me to upgrade it to 4.2, does that mean 4.1 is not a stable release?

There are many things that have been fixed in 4.2 most of them in the so
called compat layer which makes old plugins run on the new platform.

So even if you manage to get things up you'll notice many things who are
not working as expected.

The question was more what special things are you doing in
createWindowContents? Why can't you simply life with the default
implementation?

Tom
Re: e4 custom renderer not working [message #851979 is a reply to message #851901] Sat, 21 April 2012 10:38 Go to previous messageGo to next message
ishk gunathilake is currently offline ishk gunathilake
Messages: 27
Registered: April 2012
Junior Member
the application UI consist of default workbench components with custom header(cosist of product banner and buttons other windows) and a side bar which consist of several quick search components).here the problem is the new reskin ui consist of different new styles(as an example buttons with rounded edges, different colors). so it may take lot of effort if i am going to do this with default implementation.I thought e4 tooling will be a fast solution to my project.
if i upgrade this to 4.2, can i assure the old methods (such as WorkbenchWindowAdvisor.createWindowContents(Shell))will work with the 4.2 ?
Re: e4 custom renderer not working [message #852014 is a reply to message #851979] Sat, 21 April 2012 11:22 Go to previous messageGo to next message
Sopot Cela is currently offline Sopot Cela
Messages: 596
Registered: December 2010
Senior Member

Ishara,
Regardless if it's the right thing to do, rewriting the render is not a trivial thing. To do that you need to have understood the eclipse emf model that represents the applicaion at runtime. This model is then 'translated' into widgets by the renderer. The line
If uiElement instanceof Label

will never return true because uiElement is the model object that is supposed to be translated into a widget through the renderer, not the widget itself.

For the 4.1 point, migrating from 4.1 to 4.2 is not the same effort as migrating from 3.2 to 4.1. In the latter case the conversion introduces the compatibility layer which makes your application believe it is still running on 3.x while it is on 4.x. When you go from 4.1 to the nightly builds you get a much better compatibility layer without any effort.

As to whether implementing your own renderer or not i would suggest you take a look at what the the main concepts introduced in e4 through various online resources and then if css isn't enough for your needs go and extend the renderers but it would be difficult to do so whithout deep knowledge of at least the modeled workbench.

Good luck.
Re: e4 custom renderer not working [message #852202 is a reply to message #851979] Sat, 21 April 2012 15:35 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5256
Registered: July 2009
Senior Member
Am 21.04.12 16:38, schrieb ishara gunathilake:
> the application UI consist of default workbench components with custom
> header(cosist of product banner and buttons other windows) and a side
> bar which consist of several quick search components).here the problem
> is the new reskin ui consist of different new styles(as an example
> buttons with rounded edges, different colors). so it may take lot of
> effort if i am going to do this with default implementation.I thought e4
> tooling will be a fast solution to my project.
> if i upgrade this to 4.2, can i assure the old methods (such as
> WorkbenchWindowAdvisor.createWindowContents(Shell))will work with the 4.2 ?

No WorkbenchWindowAdvisor.createWindowContents will never be called
because it is part of the Presentation API and we said from Day 1 that
this is the *only* thing we are NOT going to support in 4.x.

Tom
Re: e4 custom renderer not working [message #856539 is a reply to message #852202] Wed, 25 April 2012 15:16 Go to previous messageGo to next message
ishk gunathilake is currently offline ishk gunathilake
Messages: 27
Registered: April 2012
Junior Member
hi,
I completed the platform change successfully. But still getting the empty workbench. As you(tom) mentioned, some of the functions which weren't run on 4.1 platform are enabled as a result of platform change to 4.2.Would like to know how do i resolve the WorkbenchWindowAdvisor.createWindowContents(Shell)) problem in 4.2 platform and enable the hidden components.do i have to written renderers? Please give your suggestions. I used Eclipse 4.2.0 Nightly Build: N20120421-2021 for this platform change.

regards
Re: e4 custom renderer not working [message #857202 is a reply to message #856539] Thu, 26 April 2012 06:35 Go to previous messageGo to next message
Brian de Alwis is currently offline Brian de Alwis
Messages: 242
Registered: July 2009
Senior Member
Ishara, the E4 CSS support should work in 3.7. Raise a bug if it doesn't.
Re: e4 custom renderer not working [message #858096 is a reply to message #857202] Thu, 26 April 2012 22:06 Go to previous messageGo to next message
ishk gunathilake is currently offline ishk gunathilake
Messages: 27
Registered: April 2012
Junior Member
hi brian,
but i dont think i can do this using the limited api provided by 3.x. Im gonna change the UI as IBM-Lotus Symphony theming.I want to find a way how
can be done this using 4.2 api. Now I have my project runs on 4.2 platform but under the 3.x overridden api calls.I want to change these api calls in a way which they will compatible with the 4.2 api.
Re: e4 custom renderer not working [message #1059848 is a reply to message #858096] Tue, 21 May 2013 18:15 Go to previous messageGo to next message
Miroslav Lazarevic is currently offline Miroslav Lazarevic
Messages: 25
Registered: July 2009
Location: Sabac, Serbia
Junior Member
I'm using createWindowContents in my 3.x RCP application to adopt application window so it support my app logo and title of plugins. This is basically a composite with some image and labels and code which puts this composite on top of other RCP standard components is presented as shown.

        @Override
	public void createWindowContents(final Shell shell) {
		super.createWindowContents(shell);
		WorkbenchWindow window = (WorkbenchWindow) getWindowConfigurer()
				.getWindow();
		ITrimManager defaultLayout = window.getTrimManager();
		logo = new ApplicationLogo(shell, SWT.NONE);
		Application.setApplicationLogo(((ApplicationLogo) logo));
		logoTrim = new WindowTrimProxy(logo, "com.birosoft.workday.logo",
				"birosLogo", SWT.NONE, true);
		defaultLayout.addTrim(ITrimManager.TOP, logoTrim, defaultLayout
				.getTrim(WorkbenchMessages.TrimCommon_Main_TrimName));
	}


Now for Eclipse 4.2 and 4.3 I know I must do this now through application model. But now I wonder what I should add to Trimmed window in application model so this composite is always shown no matter which plugins UI is shown or not? If it's needed I can provide some screenshots. I want to know is this possible through new e4 model or not so I will not waste my time on this issue and find some another solution.
Re: e4 custom renderer not working [message #1059930 is a reply to message #1059848] Wed, 22 May 2013 04:30 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1227
Registered: July 2012
Senior Member
Not sure if I understand you correctly, but I think what you are searching for is adding a tool control to your trimbar. Is that correct?

Well you can specify trim bars for your trimmed window in the application model and specify what should be included there. Lars Vogel showed an example for adding a simple progress monitor to the trim bar here http://www.vogella.com/articles/EclipseJobs/article.html#eclipsejobs_progress4x
Re: e4 custom renderer not working [message #1059962 is a reply to message #1059930] Wed, 22 May 2013 07:22 Go to previous messageGo to next message
Miroslav Lazarevic is currently offline Miroslav Lazarevic
Messages: 25
Registered: July 2009
Location: Sabac, Serbia
Junior Member
I think that's correct. I'll try this and post the results. Thanks
Re: e4 custom renderer not working [message #1060062 is a reply to message #1059930] Wed, 22 May 2013 14:42 Go to previous message
Miroslav Lazarevic is currently offline Miroslav Lazarevic
Messages: 25
Registered: July 2009
Location: Sabac, Serbia
Junior Member
Ok I played with Vogella's To-do RCP and got what I want with TrimBars and ToolControl. Thanks once more for help.

[Updated on: Wed, 22 May 2013 14:44]

Report message to a moderator

Previous Topic:How to reuse the Eclipse 4 IDE Perspective Features in an RCP Application
Next Topic:Prevent part from closing
Goto Forum:
  


Current Time: Wed Jul 30 03:08:18 EDT 2014

Powered by FUDForum. Page generated in 0.03933 seconds