Bug 88589 - [Perspectives] Empty folder layout should not consume space
Summary: [Perspectives] Empty folder layout should not consume space
Status: RESOLVED DUPLICATE of bug 58931
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M7   Edit
Assignee: Nick Edgar CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-20 02:00 EST by Setya Nugdjaja CLA
Modified: 2005-03-29 12:14 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Setya Nugdjaja CLA 2005-03-20 02:00:13 EST
I try to save and restore the view layout so I put the following code in the
WorkbenchAdvisor initialize method : 

public void initialize(IWorkbenchConfigurer configurer) 
{
    super.initialize(configurer);
    configurer.setSaveAndRestore(true);
}

and in Perspective.createInitialLayout I added the following code : 

public void createInitialLayout(IPageLayout layout)
{
layout.setEditorAreaVisible(false);
    
left = layout.createFolder(FOLDER_LEFT, IPageLayout.LEFT,0.25f,
layout.getEditorArea());
rightTop = layout.createFolder(FOLDER_RIGHT_TOP, IPageLayout.TOP,0.75f,
layout.getEditorArea());

left.addView(ModuleExplorerUI.ID);
}

When app starts it does automatically open the view (ModuleExplorerUI) but the
view is not contained in the IFolderLayout (left).

If I don't call setSaveAndRestore(true) the view will be placed inside the
IFolderLayout as expected.

Regards,


Setya
Comment 1 Nick Edgar CLA 2005-03-20 13:38:06 EST
Sorry, are you saying that the initial layout is correct (regardless of the
setSaveAndRestore setting), but that it's not properly restored when
setSaveAndRestore(true) is set?

I'd be very surprised if setSaveAndRestore had any effect on the initial layout.
Comment 2 Setya Nugdjaja CLA 2005-03-20 21:28:43 EST
(In reply to comment #1)
> Sorry, are you saying that the initial layout is correct (regardless of the
> setSaveAndRestore setting), but that it's not properly restored when
> setSaveAndRestore(true) is set?
> 
> I'd be very surprised if setSaveAndRestore had any effect on the initial layout.
> 

Thanks,

Yes, I know what you mean, since enabling save/restore feature won't call
createInitialLayout, you can not put the view in the IFolderLayout unless at
runtime we open the view and put in the Layout, but how to programmatically put
the view in a folder layout when user open it if we do not have a chance to
create the IFolderLayout in createInitialLayout ?

Regards,

Setya
Comment 3 Nick Edgar CLA 2005-03-21 10:53:23 EST
When saving/restoring workbench state between sessions, it remembers the folder
structure in addition to the set of open views.  If the user can open a view
after the perspective is first opened, you can control where it goes by defining
a placeholder for the view in the folder.  See IPageLayout.addPlaceholder(String
viewId, ...) and IPlaceholderFolderLayout.addPlaceholder(String viewId).  Note
that IFolderLayout extends IPlaceholderFolderLayout.

Does this work for you, or is there actually a bug here?
Comment 4 Setya Nugdjaja CLA 2005-03-21 21:15:36 EST
(In reply to comment #3)
> When saving/restoring workbench state between sessions, it remembers the folder
> structure in addition to the set of open views.  If the user can open a view
> after the perspective is first opened, you can control where it goes by defining
> a placeholder for the view in the folder.  See IPageLayout.addPlaceholder(String
> viewId, ...) and IPlaceholderFolderLayout.addPlaceholder(String viewId).  Note
> that IFolderLayout extends IPlaceholderFolderLayout.
> 
> Does this work for you, or is there actually a bug here?

OK, correct me if I'm wrong here, from what I understand so far the only place
IPageLayout exposed is in createInitialLayout but since this method is not get
called if you set setSaveAndRestore(true) where else can I call
IPlaceholderFolderLayout.addPlaceholder(String viewId) as you suggest ?

If I don't call setSaveAndRestore(true) the code in createInitialLayout works
fine to me.

Regards,


Setya
Comment 5 Setya Nugdjaja CLA 2005-03-21 21:17:17 EST
(In reply to comment #3)
> When saving/restoring workbench state between sessions, it remembers the folder
> structure in addition to the set of open views.  If the user can open a view
> after the perspective is first opened, you can control where it goes by defining
> a placeholder for the view in the folder.  See IPageLayout.addPlaceholder(String
> viewId, ...) and IPlaceholderFolderLayout.addPlaceholder(String viewId).  Note
> that IFolderLayout extends IPlaceholderFolderLayout.
> 
> Does this work for you, or is there actually a bug here?

OK, correct me if I'm wrong here, from what I understand so far the only place
IPageLayout exposed is in createInitialLayout but since this method is not get
called if you set setSaveAndRestore(true) where else can I call
IPlaceholderFolderLayout.addPlaceholder(String viewId) as you suggest ?

If I don't call setSaveAndRestore(true) the code in createInitialLayout works
fine to me.

Regards,


Setya
Comment 6 Nick Edgar CLA 2005-03-24 12:26:02 EST
Correct, IPageLayout, IPlaceholderFolderLayout and IFolderLayout, are only
available to the perspective factory, which is only run when the perspective is
first opened.  It is not used when restoring a saved workbench.  However, the
saved layout should come back in exactly the same shape as it was originally,
including placeholders.

So:
- can you add the placeholder at creation time?
- if you do this, does your view appear at the right place when opened in the
same session?
- if you shutdown and restart, does the view reappear at the right place?

Comment 7 Setya Nugdjaja CLA 2005-03-27 22:52:07 EST
(In reply to comment #6)
> Correct, IPageLayout, IPlaceholderFolderLayout and IFolderLayout, are only
> available to the perspective factory, which is only run when the perspective is
> first opened.  It is not used when restoring a saved workbench.  However, the
> saved layout should come back in exactly the same shape as it was originally,
> including placeholders.
> 
> So:
> - can you add the placeholder at creation time?

Yes, when the first time I run after starting the Eclipse IDE I've got the
following messages :

Unable to find element factory: org.eclipse.ui.internal.model.ResourceFactory
Unable to restore page - cannot instantiate input factory:
org.eclipse.ui.internal.model.ResourceFactory

This messages does not show up on subsequent run.

> - if you do this, does your view appear at the right place when opened in the
> same session?

Yes, it works fine.

> - if you shutdown and restart, does the view reappear at the right place?
> 
> 
Yes, it reappears at the right place if I don't call
layout.setEditorAreaVisible(false)

If I call the above method, the view will span the whole workbench eventhough
I've created the placeholder for it.


Regards,


Setya
Comment 8 Nick Edgar CLA 2005-03-28 10:23:09 EST
> Unable to find element factory: org.eclipse.ui.internal.model.ResourceFactory
> Unable to restore page - cannot instantiate input factory:
> org.eclipse.ui.internal.model.ResourceFactory

This appears to be unrelated.  You apparently opened an editor on a file in the
workspace, but for some reason the ResourceFactory in the org.eclipse.ui.ide
plug-in could not be instantiated to restore that editor's FileEditorInput.
If you run with -debug, does it give you any more info in the log about plug-in
activation problems?

> Yes, it reappears at the right place if I don't call
> layout.setEditorAreaVisible(false)

> If I call the above method, the view will span the whole workbench 
> even though I've created the placeholder for it.

If the code above still applies, I suspect what's happening is that in the
initial layout, you get a blank area for rightTop, because it has no views in
it, but on restart instead of getting a blank area for rightTop, rightTop is
hidden so the left folder gets all the space.  Is that correct?
In this case, the bug is actually in the initial layout.  If a folder has no
actual views added to it in the initial layout, it should act like a placeholder
folder, and not consume any space.
Comment 9 Setya Nugdjaja CLA 2005-03-28 21:19:01 EST
(In reply to comment #8)
> > Unable to find element factory: org.eclipse.ui.internal.model.ResourceFactory
> > Unable to restore page - cannot instantiate input factory:
> > org.eclipse.ui.internal.model.ResourceFactory
> 
> This appears to be unrelated.  You apparently opened an editor on a file in the
> workspace, but for some reason the ResourceFactory in the org.eclipse.ui.ide
> plug-in could not be instantiated to restore that editor's FileEditorInput.
> If you run with -debug, does it give you any more info in the log about plug-in
> activation problems?

OK, I've turned on the -debug, where can I find the .log file ? Also it only
happens on the 1st time I run after I get into the Eclipse IDE, the subsequent
launch runs fine.

> 
> > Yes, it reappears at the right place if I don't call
> > layout.setEditorAreaVisible(false)
> 
> > If I call the above method, the view will span the whole workbench 
> > even though I've created the placeholder for it.
> 
> If the code above still applies, I suspect what's happening is that in the
> initial layout, you get a blank area for rightTop, because it has no views in
> it, but on restart instead of getting a blank area for rightTop, rightTop is
> hidden so the left folder gets all the space.  Is that correct?
> In this case, the bug is actually in the initial layout.  If a folder has no
> actual views added to it in the initial layout, it should act like a placeholder
> folder, and not consume any space.
> 

Yes, your analysis is correct, so I should fill the placeholder with view on
initial layout ? 
I think I should not call setEditorAreaVisible(false) anyway, because initially
I don't want to use editors in my apps, since I thought this kind of view does
not appropriate for database entry. But after reading some articles I found that
editors can also be used for database entry. So I will just use them instead and
this solves my save/restore problem above.

Thanks for your support so far Mr. Nick. Keep up the good work with RCP.
Comment 10 Nick Edgar CLA 2005-03-28 22:07:08 EST
Thanks for confirming.  Changing title to reflect the actual problem, which is
not actually RCP-specific.

Basically, I think that calling IPageLayout.createFolder and then not adding any
concrete views to it should have the same effect as createPlaceholderFolder.

cc'ing Kim as I believe we've discussed this before.
Comment 11 Setya Nugdjaja CLA 2005-03-28 23:56:21 EST
(In reply to comment #10)
> Thanks for confirming.  Changing title to reflect the actual problem, which is
> not actually RCP-specific.
> 
> Basically, I think that calling IPageLayout.createFolder and then not adding any
> concrete views to it should have the same effect as createPlaceholderFolder.
> 
> cc'ing Kim as I believe we've discussed this before.
> 

Great, maybe my confusion originates from the fact that initially the views
position as expected, but when I restart they position differently.

Best Regards,

Setya
Comment 12 Nick Edgar CLA 2005-03-29 12:14:42 EST

*** This bug has been marked as a duplicate of 58931 ***