Bug 94274 - [ViewMgmt] Gray views if are openned in not default placeholder
Summary: [ViewMgmt] Gray views if are openned in not default placeholder
Status: RESOLVED WORKSFORME
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 RC4   Edit
Assignee: Stefan Xenos CLA
QA Contact:
URL:
Whiteboard:
Keywords: investigate
Depends on:
Blocks:
 
Reported: 2005-05-10 07:36 EDT by joseantonio.cardin CLA
Modified: 2005-06-21 09:32 EDT (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 joseantonio.cardin CLA 2005-05-10 07:36:20 EDT
Fails in eclipse 3.1M6 the same code that works fine in 3.1M5a.
I want to create a view (from other view) in the placeholder that is not the 
default placeholder.

Example:

I work with rcp.browser example.
I create a new view that shows a text (a parameter)

package org.eclipse.ui.examples.rcp.browser;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.part.ViewPart;

public class BlankView extends ViewPart {
  Label nameLabel;
  Composite mainPanel;

  public void createPartControl(Composite parent) {
    mainPanel = new Composite(parent, SWT.NONE);
    mainPanel.setLayout(new GridLayout());
    nameLabel = new Label(mainPanel, SWT.NONE);
  }

  public void setFocus() {
    //   nothing
  }

  public void setText(String text) {
    nameLabel.setText(text);
    mainPanel.layout(true);
  }
}

I create 2 place holder: The left to HistoryView & BlankView and the 
rigth to browser view. I want that history view is visible always.

Modify BrowserPerspectiveFactory.createInitialLayout as :

public void createInitialLayout(IPageLayout layout) {
  layout.addView(IBrowserConstants.BROWSER_VIEW_ID, IPageLayout.RIGHT, .25f, 
IPageLayout.ID_EDITOR_AREA);
  IFolderLayout left = layout.createFolder("left", IPageLayout.TOP, 0.3f, 
IPageLayout.ID_EDITOR_AREA);
  left.addPlaceholder(IBrowserConstants.BLANK_VIEW_ID);  // added constant 
to IBrowserConstants
  left.addView(IBrowserConstants.HISTORY_VIEW_ID);

  IViewLayout historyLayout = 
layout.getViewLayout(IBrowserConstants.HISTORY_VIEW_ID);
  historyLayout.setCloseable(true);
  layout.setEditorAreaVisible(false);
 }

and when HistoryView is created, open the BlankView. This is the 
HistoryView.createPartControl()
public void createPartControl(Composite parent) {
  viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
  drillDownAdapter = new DrillDownAdapter(viewer);
  viewer.setContentProvider(new ViewContentProvider());
  viewer.setLabelProvider(new ViewLabelProvider());
  viewer.setInput(getViewSite());
  makeActions();
  hookContextMenu();
  hookDoubleClickAction();

  // new code added
  try {
    BlankView view = (BlankView) 
getSite().getWorkbenchWindow().getActivePage().showView
(IBrowserConstants.BLANK_VIEW_ID);
    view.setText("Hello world");
  }
  catch (PartInitException exception) {
    exception.printStackTrace();
  }

 }

When HistoryView is created, open the blankView on the left place holder.
When i use eclipse 3.1M5a, works fine, but this same code, when use 3.1M6 
BlankView & HistoryView are gray views. When click more times on this views, 
show fine.

More: if comment this line 
left.addPlaceholder(IBrowserConstants.BLANK_VIEW_ID);  in 
BrowserPerspectiveFactory.createInitialLayout the views works fine on the 
rigth place holder.
Comment 1 Nick Edgar CLA 2005-06-07 21:54:32 EDT
Stefan, this is hitting the re-entrant view creation case you mentioned
recently: HistoryView's createPartControl method is calling showView to show the
BlankView.

Getting grey views does not seem like the expected behaviour though (whether in
the same stack or not).  Either it should fail, or allow the re-entrant creation.

Any suggestions?
Comment 2 Nick Edgar CLA 2005-06-08 19:59:15 EDT
Should investigate whether there's a real problem here for RC3.
Comment 3 Stefan Xenos CLA 2005-06-08 20:25:23 EDT
Re-entrant creation is permitted. The only re-entrant creation that is forbidden
is when a part attempts to recursively create itself (which - obviously - can't
work).

I believe the problem here is due to reentrant activation, which is currently
not permitted. The expected behavior is that both parts are created properly,
but the history view remains active and the workbench logs an exception
indicating that an attempt was made to activate blankview while still in the
process of activating historyview.
Comment 4 Michael Van Meekeren CLA 2005-06-14 15:50:15 EDT
need to investigate why this part is gray for RC3 before requesting approval to fix
Comment 5 Douglas Pollock CLA 2005-06-17 14:45:23 EDT
Moving to 3.1 RC4 for investigation.
Comment 6 Michael Van Meekeren CLA 2005-06-21 09:32:54 EDT
This works for me in Version: 3.1.0 Build id: N20050621-0010.  I open the
browser example and see both views with the contents correctly.  Closing this
bug, please re-test and reopen if you disagree.