Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » How to refresh or force to redraw view part
How to refresh or force to redraw view part [message #333363] Fri, 05 December 2008 16:31
Young-Soo Roh is currently offline Young-Soo RohFriend
Messages: 10
Registered: July 2009
Junior Member
Hi.
I created a new view part like properties view. When the createPartControl
is called I create a Empty composite so that it can be filled with other
contents later depending on the selected item. However, when I changed the
content of this composite the view does not show added contents. I tried
to use refresh or update from the Composite, but that didn't work.
However, when I resize this view manually suddenly the contents show up. I
am trying to find out how I can update the current view programmatically
because whenever the selection is changed I need to put new contents to
the view. Any help would be appreciated.


Following is a test view. I want to add new label everytime the selection
is changed, but the content does not show up until I manually resize the
view from the workbench.

/**************************************
* Code
*****************************************/
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.part.ViewPart;


public class TestView
extends ViewPart
implements ISelectionListener {

private Composite pageContainer;

@Override
public void createPartControl(Composite parent) {

getSite().getPage().addSelectionListener(this);

pageContainer = createPageContainer(parent);

}

protected Composite createPageContainer(Composite parent) {

Composite composite = new Composite(parent, SWT.NULL);

{
GridLayout layout = new GridLayout();
FormData formData = new FormData();
formData.left = new FormAttachment(0, 0);
formData.right = new FormAttachment(100, 0);
formData.top = new FormAttachment(0, 0);
formData.bottom = new FormAttachment(100, 0);

composite.setLayout(layout);
composite.setLayoutData(formData);
composite.setBackground(new Color(null, 255, 255, 255));
}

return composite;
}

@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {

Label label = new Label(pageContainer, SWT.NULL);
label.setText(selection.toString());
pageContainer.update();
pageContainer.redraw();
/****************************************************
* I need to do something here to refresh the view
****************************************************/
}

@Override
public void setFocus() {
// TODO Auto-generated method stub

}
}
Previous Topic:howto provide context menu actions in a tree in a formeditor
Next Topic:Multiple versions of library wrapper plugins
Goto Forum:
  


Current Time: Sat Oct 19 20:46:10 GMT 2024

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

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

Back to the top