I've run into a design problem with the way I'm using XViewer and wanted to 
bounce
this off the other XViewer users before I start re-designing what I've done so 
far.

I've got a tree of "gadgets" that I use in several different places in our
app.  Depending on where in our app it appears, the tree should show different
fields by default, have different filters and sorting in place. And in some
cases the ITreeContentProvider is different, to structure the data relationships
based on the context. In all cases, the XViewerLabelProvider is the same, since
it is basically the same data just arranged in different ways.  But in all cases
even if a column is not shown by default, we want the user to be able to show
any column if desired.

I approached the design this way:

I created a GadgetViewerSettings class that holds the various options that
need to be in place depending on the context.  That settings object is passed
to the factory so it knows, for instance, what the default visible columns
should be so it can set them in getDefaultTableCustomizeData().

Each of the columns that is available is defined like this in my GadgetViewer 
class:

    public final static XViewerColumn COLUMN_NAME = new XViewerColumn("Name", 
"Name", 200, SWT.LEFT,
true, XViewerColumn.SortDataType.String, false, "tooltip...");

and a list of all available columns is defined in GadgetViewer like this:

    public final static XViewerColumn[] COLUMNS = { COLUMN_NAME, COLUMN_TYPE, 
... };

This makes it very easy to share a single GadgetLabelProvider, that can do 
something
like this in the getColumnText() method:

        if (column.equals(GadgetViewer.COLUMN_NAME))
                return ((Gadget)element).getName();


It also allows my GadgetViewerFactory to register the list of columns by 
referencing
the GadgetViewerFactory.COLUMNS collection.

        registerColumns(GadgetViewer.COLUMNS);

However, I think I'm now in trouble if I want my 
GadgetViewerFactory.getDefaultTableCustomizeData()
method to be able to return a CustomizeData that has different columns visible 
by default
for each context.  If I am understanding the design correctly, this method 
would be the
place that I would set the visibility of each column for the table default. 
However, this is
done on the column itself, not the customization. This implies that sharing 
columns between
different contexts (that could be in use at the same time) is not the 
recommended way to
approach this - since the instantiation in one context would now affect the 
visibility of
columns in another context.


If I understand the code correctly (which I'm not sure I do), then I need to 
get rid of
those static XViewerColumn definitions and instantiate new XViewerColumns each 
time my
GadgetViewer is instantiated. I should perhaps be using the column id to decide 
what to
return in GadgetLabelProvider.getColumnText().

Does that sound right? Or am I missing something?

TIA!
Chris





-- 
------------------------------------------------------------------------ -
Chris Merrill                           |  Web Performance, Inc.
[email protected]                |  http://webperformance.com
919-433-1762                            |  919-845-7601

Web Performance: Website Load Testing Software & Services
------------------------------------------------------------------------ -
_______________________________________________
nebula-dev mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/nebula-dev

Reply via email to