Hello everyone!
I 've got a question about RCP views. There is a view in my application that has a file and a string attribute. The file contains an image which is displayed with the string underneath it. Getters are available for changing the attributes during runtime. All is working fine at first, but how can I force the view to update itself, when the string and/or the file has changed?
Code:
public class TestView extends ViewPart {
public static final String ID = "TestView";
private File imageFile;
private String imageName;
public TestView() {
}
public void createPartControl( Composite parent ) {
final Image image = new Image( Display.getDefault(), imageFile.getAbsolutePath() );
Canvas imageCanvas = new Canvas( parent, SWT.BORDER );
imageCanvas.addPaintListener( new PaintListener() {
public void paintControl( PaintEvent e ) {
if ( previewImage == null ) {
e.gc.drawString( "Error: No image", 0, 0 );
} else {
e.gc.drawImage( previewImage, 0, 0 );
}
}
});
Label imageLabel = new Label( parent, SWT.CENTER );
imageLabel.setText(imageName);
}
public void setFile( File imageFile ) {
this.imageFile = imageFile;
}
public void setName( String imageName ) {
this.imageName = imageName
}
This is a short version of my class, I am thankful for any advice.
Greets,
Benedikt