Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8991323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:41:53+00:00 2026-06-15T22:41:53+00:00

I have a little problem and I’m asking for help. I have a TableViewer

  • 0

I have a little problem and I’m asking for help.

I have a TableViewer in my Master part and a lot of entries updating it very quickly.
My details pages display the selected item infos.
I would like to make this details pages persistent and only be notified when selection is changing.

The problem I’m facing is that when a new item is added to the tableviewer, the selection changes automatically.

EDITING : I have a Handler which update the TableViewer, adding a new item at the beginning of a list which is the input of my TableViewer.

When the TableViewer is SWT.VIRTUAL the selection is on the index and when an item is added, the selected row is the same but items have moved.

When TableViewer is not SWT.VIRTUAL the selection occurs on the object but performances are very low !

Any piece of advice ?
Thank you

public void update(Object obj_p) {
    if (obj_p instanceof IMessageEvent) {
        IMessageEvent event = (IMessageEvent) obj_p;
        synchronized (_currentListEvents) {
            _currentListEvents.addFirst(event);
            if (_currentListEvents.size() > _maxEvents) {
                _currentListEvents.removeLast();
            }
        }
    }
    if (null == obj_p) {
        synchronized (_currentListEvents) {
            _currentListEvents.clear();
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T22:41:54+00:00Added an answer on June 15, 2026 at 10:41 pm

    When creating TableViewer use SWT.FULL_SELECTION style.

    There is a simple runable code. It behaves exactly as you posted, the selection is being changed, but when you use the commented TableViewer constructor, it works for me.

    import java.util.ArrayList;
    import java.util.List;
    
    import org.eclipse.jface.viewers.ArrayContentProvider;
    import org.eclipse.jface.viewers.ISelectionChangedListener;
    import org.eclipse.jface.viewers.LabelProvider;
    import org.eclipse.jface.viewers.SelectionChangedEvent;
    import org.eclipse.jface.viewers.StructuredSelection;
    import org.eclipse.jface.viewers.TableViewer;
    import org.eclipse.swt.SWT;
    import org.eclipse.swt.layout.FillLayout;
    import org.eclipse.swt.widgets.Display;
    import org.eclipse.swt.widgets.Shell;
    
    public class TestCase {
    
    private static List<String> model = new ArrayList<String>();
    private static TableViewer viewer;
    
    public static void main(String[] args) {
        final Display display = new Display();
        final Shell shell = new Shell(display);
        shell.setLayout(new FillLayout());
    
    //  viewer = new TableViewer(shell, SWT.SINGLE | SWT.FULL_SELECTION |    SWT.H_SCROLL | SWT.V_SCROLL | SWT.VIRTUAL);
        viewer = new TableViewer(shell, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.VIRTUAL);
    
        viewer.getTable().setHeaderVisible(true);
        viewer.getTable().setLinesVisible(true);
        viewer.setUseHashlookup(true);
    
        viewer.setContentProvider(ArrayContentProvider.getInstance());
        viewer.setLabelProvider(new LabelProvider());
    
        model.add("element2");
        model.add("element1");
        model.add("element0");
    
        viewer.setInput(model);
    
        viewer.setSelection(new StructuredSelection(model.get(1)));
    
        viewer.addSelectionChangedListener(new ISelectionChangedListener() {
    
            @Override
            public void selectionChanged(SelectionChangedEvent event) {
                System.out.println("selection changed");
            }
        });
    
        addContent();
    
        shell.setSize(400, 400);
        shell.open();
    
        while (!shell.isDisposed()) {
            if (!display.readAndDispatch()) {
                display.sleep();
            }
        }
    }
    
    private static void addContent() {
        Display.getCurrent().timerExec(2000, new Runnable() {
    
            @Override
            public void run() {
                model.add(0, "element" + model.size());
                viewer.refresh();
                addContent();
            }
        });
    }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have little problem with a replacement of a little part in an url.
I have a little problem with Jquery getJSON function. my json here { entries:
I have a little problem and I'm hopping that you can help me solve
I have little problem with deleting multiple lines with sed. I read a lot
I am very new to jQuery/JS and I have little problem with add or
I have a little problem that perhaps you can help me with. I try
I have little problem in regular expressin creation. Expected input: blahblahblah, blahblahblah, 'blahblahblah', blahblahblah,
I have little unusual problem to solve. I need some hint or links to
I have a little problem about the sort direction of a specific column in
I have a little Problem with the app that I'm developing. In the App

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.