How to refresh or force to redraw view part [message #333363] |
Fri, 05 December 2008 16:31 |
Young-Soo Roh 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
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.04276 seconds