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

  • SEARCH
  • Home
  • 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 8986509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:34:04+00:00 2026-06-15T21:34:04+00:00

A 2-sash sashform. A 3-level TreeViewer in one and a TableViewer in the other.

  • 0

A 2-sash sashform. A 3-level TreeViewer in one and a TableViewer in the other. When it starts no item is selected in the TreeViewer
and the TableViewer shows a list of all the first level objects available. To achieve this, the TreeViewerContainer instantiates the TableViewerContainer and then calls its showFirstLevelItemList( ) method :

public class TableViewerContainer {
private Table table;
private TableViewer tableViewer;
private TableColumnLayout layout;

public TableViewerContainer(SashForm sashForm) {

    Composite composite = new Composite(sashForm, SWT.NONE);
    composite.setLayout(new GridLayout(1, false));      
    tableViewer = new TableViewer(composite, SWT.BORDER
            | SWT.FULL_SELECTION);
    table = tableViewer.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);

    // Add TableColumnLayout
    layout = new TableColumnLayout();
    composite.setLayout(layout);
}

public void showFirstLevelItemList( FirstLevelItemListContainer obj ) {
    // Add the only column
    TableViewerColumn tableViewerColumn = new TableViewerColumn(
            tableViewer, SWT.NONE);
    TableColumn tblclmnFirst = tableViewerColumn.getColumn();

    layout.setColumnData(tblclmnFirst, new ColumnWeightData(10,
            ColumnWeightData.MINIMUM_WIDTH, false));

    tblclmnFirst.setText("Description");

    // assign providers and show the table 
    tableViewer.setLabelProvider(new FirstLevelItemLabelProvider());
    tableViewer.setContentProvider(new FirstLevelItemContentProvider());
    tableViewer.setInput(obj);      
} 

This works fine.

Next, selecting an item in the TreeViewer causes the tableViewer to update the data accordingly. To effect this I added a SelectionChangedListener():

treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event
                    .getSelection();
            Object obj = selection.getFirstElement();
            if (obj instanceof firsLevelDetail ) {  
                FirstLevelDetail fld = (FirstLevelDetail) obj;
                tableViewer.showFirstLevelDetail(fld);               

            } else if (obj instanceof SecondLevelDetail )
                SecondLevelDetail sld = (SecondLevelDetail) obj;
                tableViewer.showSecondLevelDetail(sld);              

            else if (obj instanceof ThirdLevelDetail)
            ThirdLevelDetail tld = (ThirdLevelDetail) obj;
                tableViewer.showSecondLevelDetail(tld);
        }
    });`

So that when the user selects a firstLevelItem the TableViewer shows the corresponding data. All the methods called follow the following pattern :

private void showFirstLevelDetail( FirstLevelDetailObj obj ) {

    Table tbl = tableViewer.getTable();
    tbl.setRedraw(false);

    // Dispose former columns 
    while (tbl.getColumnCount() > 0) {
        tbl.getColumns()[0].dispose();
    }

    // add new columns  
    TableViewerColumn tableViewerColumn = new TableViewerColumn(
            tableViewer, SWT.NONE);
    TableColumn tblclmn = tableViewerColumn.getColumn();
    layout.setColumnData(tblclmn, new ColumnWeightData(1,
            ColumnWeightData.MINIMUM_WIDTH, true));
    tblclmn.setText("Code FL Item");

    tableViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
    tblclmn = tableViewerColumn.getColumn();
    layout.setColumnData(tblclmn, new ColumnWeightData(1,
            ColumnWeightData.MINIMUM_WIDTH, true));
    tblclmn.setText("Description FL Item");

    tbl.setRedraw(true);

    // to avoid an Exception 
    tableViewer.setInput(null);

    // Assign new providers and show the data
    tableViewer.setLabelProvider(new FirstLevelDetailLabelProvider());
    tableViewer.setContentProvider(new FirstLevelDetailContentProvider());
    tableViewer.setInput(obj);
}

The ContentProviders’ getElements() methods follow the next patern:

public Object[] getElements(Object inputElement) {
return ((FirstLevelDetail)inputElement).getArrayItems();                
}

My problem is after this process the table doesn’t show a header or any data until it is resized. Then it works normally until another item is selected, no matter what level the item is.

tableViewer.refresh() does not work.
tableViewer.getTable().redraw() does not work.

All the showXxxxLevelDetail () work properly if they are called in the first place, instead of showFirstLevelItemList() method, provided tableViewer.setInput(null) is commented out.

I’m running Eclipse Indigo, jface 3.8, Windows XP.

  • 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-15T21:34:05+00:00Added an answer on June 15, 2026 at 9:34 pm

    I would try to call

    composite.layout();
    

    after calling any of those showXXXLevelDetail() methods.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My application's got one horizontal SashForm with two children. The leftmost one should always
I need the first two letter of the first name and the last name
I have the following SWT layout: TabItem SashForm Composite (GridLayout) Label (Fill W, Grab
I'm not too good at JS, but have survived thus far. I'm creating a
I have an Eclipse RCP application with a sort of three column layout: The
Update: I can't get Balancing to work, because I cannot get doAVLBalance to recognize
How do I read values ​​from the formAttachment in Java? here is my code:
I have an eclipse RCP application that uses and Editor Area. I have a

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.