Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » TableViewer in the tabbed properties view fails to scroll
TableViewer in the tabbed properties view fails to scroll [message #489507] Sun, 04 October 2009 08:57
Eclipse User
Originally posted by: wbeckwith.gmail.com

I have the following sample view that creates a static list of
parameters, displays them in a table and exports the same list as the
selection to the tabbed properties view. This view can be scrolled with
the mouse wheel with no problem. However, if I create a property
section for the tabbed properties view, using the exact same static
method in the SampleView to create and configure a TableViewer and
display that in the tabbed properties view, then the mouse wheel no
longer works. Also clicking on the vertical scroll arrows for the
tabbed properties view moves the content by what looks to be 1 pixel at
a time. None of this behavior is present in the SampleView.

In eclipse 3.3.2, I can see the correct behavior with the Project
Explorer view open as it will contribute a tabbed property sheet and the
correct mouse wheel behavior is present if you shrink the view to make
the vertical scroll bar presnet. However, when using eclipse 3.5 and
3.6M2, even the Project Explorer displays the craptastic behavior of no
wheel support and 1 pixel movement with the arrows.

What in the #$%& world am I missing?

Wb


package org.examples.tabbed.properties.views;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.jface.layout.TableColumnLayout;
import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.ui.part.ViewPart;
import org.eclipse.ui.views.properties.IPropertySheetPage;
import
org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetP ageContributor;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPa ge;

public class SampleView extends ViewPart implements
ITabbedPropertySheetPageContributor
{
/**
* The ID of the view as specified by the extension.
*/
public static final String ID =
"org.examples.tabbed.properties.views.SampleView";
private TableViewer tableViewer;
private List<Parameter> parameters;

/**
* The constructor.
*/
public SampleView()
{
}

/**
* This is a callback that will allow us to create the viewer and
initialize it.
*/
public void createPartControl(Composite parent)
{
createParameters();
Composite composite = new Composite(parent, SWT.None);
TableColumnLayout layout = new TableColumnLayout();
composite.setLayout(layout);
tableViewer = createParameterTable(composite, layout);
tableViewer.setInput(parameters.toArray());
getSite().setSelectionProvider(new ISelectionProvider()
{
public void setSelection(ISelection selection)
{
}

public void removeSelectionChangedListener(ISelectionChangedListener
listener)
{
}

public ISelection getSelection()
{
return new StructuredSelection(parameters);
}

public void addSelectionChangedListener(ISelectionChangedListener
listener)
{
}
});
}

/**
* @param composite
* @param layout
*/
public static TableViewer createParameterTable(Composite composite,
TableColumnLayout layout)
{
Table table = new Table(composite, SWT.H_SCROLL | SWT.V_SCROLL
| SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER);
table.setHeaderVisible(true);
table.setLinesVisible(true);
TableColumn keyColumn = new TableColumn(table, SWT.LEFT);
keyColumn.setText("Key");
layout.setColumnData(keyColumn, new ColumnWeightData(25, true));
TableColumn valueColumn = new TableColumn(table, SWT.LEFT);
valueColumn.setText("Value");
layout.setColumnData(valueColumn, new ColumnWeightData(75, true));
TableViewer tableViewer = new TableViewer(table);
tableViewer.setUseHashlookup(true);
tableViewer.setLabelProvider(new ParameterLabelProvider());
tableViewer.setContentProvider(new ParameterContentProvider());
return tableViewer;
}

/**
*
*/
private void createParameters()
{
parameters = new ArrayList<Parameter>(50);
for (int i = 0; i < 50; ++i)
{
parameters.add(new Parameter("Key " + i, "Value " + i));
}
}

/**
* Passing the focus request to the viewer's control.
*/
public void setFocus()
{
tableViewer.getControl().setFocus();
}

/*
* @see
org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetP ageContributor#getContributorId()
*/
public String getContributorId()
{
return ID;
}

/*
* @see org.eclipse.ui.part.WorkbenchPart#getAdapter(java.lang.Class )
*/
@SuppressWarnings("unchecked")
@Override
public Object getAdapter(Class adapter)
{
Object result = null;
if (adapter == IPropertySheetPage.class)
{
result = new TabbedPropertySheetPage(this);
}
else
{
result = super.getAdapter(adapter);
}
return result;
}
}

============================================================ ====================

public class DemoPropertySection extends AbstractPropertySection
{
private TableViewer tableViewer;

/**
*
*/
public DemoPropertySection()
{
}

/*
* @see
org.eclipse.ui.views.properties.tabbed.AbstractPropertySecti on#createControls(org.eclipse.swt.widgets.Composite,
org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPa ge)
*/
@Override
public void createControls(Composite parent, TabbedPropertySheetPage
tabbedPropertySheetPage)
{
super.createControls(parent, tabbedPropertySheetPage);
Composite composite = getWidgetFactory().createFlatFormComposite(parent);
TableColumnLayout layout = new TableColumnLayout();
composite.setLayout(layout);
tableViewer = SampleView.createParameterTable(composite, layout);
}

/*
* @see
org.eclipse.ui.views.properties.tabbed.AbstractPropertySecti on#refresh()
*/
@Override
public void refresh()
{
tableViewer.refresh();
}

/*
* @see
org.eclipse.ui.views.properties.tabbed.AbstractPropertySecti on#setInput(org.eclipse.ui.IWorkbenchPart,
org.eclipse.jface.viewers.ISelection)
*/
@Override
public void setInput(IWorkbenchPart part, ISelection selection)
{
super.setInput(part, selection);
IStructuredSelection structuredSelection = (IStructuredSelection)
selection;
tableViewer.setInput(structuredSelection.toArray());
}
}
Previous Topic:Prevent eclipse launcher from showing splash
Next Topic:'workspace' folder
Goto Forum:
  


Current Time: Sun Sep 21 10:09:17 GMT 2014

Powered by FUDForum. Page generated in 0.01838 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software