Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to update/refresh a view in an eclipse plug-in?
    text
    copied!<p>I have an <strong>eclipse plug-in</strong> with a single <strong>view</strong> (like the eclipse helloworld-view-plugin-project). In the view-file I get an <strong>event when I want to update the view</strong>. </p> <p>In this view I have a GridData in a Group with multiple labels. I have several <strong>services which register to the programe and whose status should be shown</strong> in this GridData.</p> <p>Edit: In order to better show my problem I updated this post and added the whole code:</p> <hr> <p><strong>CreatePartControl():</strong></p> <pre><code>public void createPartControl(Composite _parent) { parent = _parent; createContents(); addBindings(); makeActions(); contributeToActionBars(); } </code></pre> <p><strong>CreateContents():</strong></p> <pre><code>protected void createContents() { // fixed checkIcon = //... errorIcon = //... smallFont = SWTResourceManager.getFont("Segoe UI", 7, SWT.NORMAL); // content gl_shell = new GridLayout(1, false); //margins, etc. for gl_shell parent.setLayout(gl_shell); final Label lblGreeting = new Label(parent, SWT.NONE); lblGreeting.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1)); lblGreeting.setText("Hi " + Preferences.getPreName()); // -- GROUP YOUR STATS (show all services) createStatusGroupBox(); } </code></pre> <p><strong>createStatusGroupBox():</strong></p> <pre><code>private Group grpYourStatus = null; // outside the method for access in listener (below) private void createStatusGroupBox() { grpYourStatus = new Group(parent, SWT.NONE); grpYourStatus.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1)); grpYourStatus.setText("Your upload status"); grpYourStatus.setLayout(new GridLayout(3, false)); // add message if no service is registered if ( r.getServiceList().size() == 0 ) { Label status = new Label(grpYourStatus, SWT.NONE); status.setText("No service registered."); new Label(grpYourStatus, SWT.NONE); //empty new Label(grpYourStatus, SWT.NONE); //empty } // add labels (status, message, name) for each registered service for ( IRecorderObject service : r.getServiceList() ) { Label name = new Label(grpYourStatus, SWT.NONE); Label status = new Label(grpYourStatus, SWT.NONE); Label message = new Label(grpYourStatus, SWT.NONE); message.setFont(smallFont); message.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1)); service.getServiceViewItem().setLabelsAndIcons(name, status, message, checkIcon, errorIcon); //this also sets the values of the labels (label.setText(...) via data binding) } </code></pre> <hr> <p>Unfortunately, I don't know what the right way is to update/reset it. I tried the following:</p> <p><strong>listener (which should update the view / the services-list):</strong></p> <pre><code>r.addPropertyChangeListener(BindingNames.SERVICE_ADDED, new PropertyChangeListener() { public void propertyChange(final PropertyChangeEvent evt) { Display.getDefault().asyncExec(new Runnable() { public void run() { // This "redraws" the view, but just places the whole content (generated in createStatusGroupBox()) above the other parts. //Display.getCurrent().update(); //createStatusGroupBox(); //parent.layout(true); //parent.redraw(); // disposes grpYourStatus-Group but doesn't show anything then grpYourStatus.dispose(); createStatusGroupBox(); grpYourStatus.layout(); grpYourStatus.redraw(); } }); } }); </code></pre> <p>I also tried the following statements (individually); all without success:</p> <pre><code>parent.redraw(); parent.update(); parent.layout(); parent.layout(true); parent.refresh(); </code></pre> <hr> <p>In this <a href="https://stackoverflow.com/questions/11352718/how-to-refresh-eclipse-view-plugin">post</a> I read the following:</p> <blockquote> <p>createPartControls is that time of the life cycle of a view, where its contained widgets are created (when the view becomes visible initially). This code is only executed once during the view life cycle, therefore you cannot add anything here directly to refresh your view.</p> <p>Eclipse parts typically update their content as a reaction to a changed selection inside of the workbench (e.g. the user might click on another stack frame in the debug view).</p> </blockquote> <p>Unfortunately, I don't know what to else I could try and I didn't find anything helpful with searches... <strong>thank's for your help and suggestions</strong>!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload