SWT Java TableViewer

69 views Asked by At

I have a tableviewer implemented in my code and I'd like to hide or skip any duplicating cells. For example my data looks like:

Part Number, Value
123,         "Test"
123,         "Test1"
123,         "Test2"
124,         "Test"
124,         "test1"
124,         "test2"

I'd like it to look like:

Part Number, Value
123,         "Test"
             "test1"
             "test2"
124,         "test"
             "test1"
             "test2"

I don't think this is formatting correctly but I want to skip any duplicate value in the PartNumber column.

1

There are 1 answers

0
kevin On

I figured it out by implementing the following code:

        tcvc1.setLabelProvider(new ColumnLabelProvider()
        {
            @Override
            public String getText(Object element)
            {
                Result r = (Result) element;
                String sReturn = "";
                int index = 0;

                index = results.indexOf(r);
                sReturn = r.getPartNumber();

                if (index > 0)
                {
                    if (results.get(index-1).getPartNumber().equalsIgnoreCase(r.getPartNumber()))
                    {
                        sReturn="";                         
                    }
                }

                return sReturn;
            }
        });