Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » NatTable eample EditorExmple not visible in Composite (ViewPart Eclipse 3.7)
NatTable eample EditorExmple not visible in Composite (ViewPart Eclipse 3.7) [message #1795571] Tue, 25 September 2018 11:48 Go to next message
Pedro Cervezahombre is currently offline Pedro CervezahombreFriend
Messages: 1
Registered: September 2018
Junior Member
Hi,

I am trying to run the an exmple (_5113_RowGroupingExample) in a Composite embedded in a ViewPart (Eclipse 3.7) without creating a new Shell (Popup).

Therefore I tried to understand both runners
StandaloneNatExampleRunner
TabbedNatExampleRunner

I can access the content of the table via data provider. This works fine.

IRowDataProvider<Data> data = (IRowDataProvider<Data>) tableControl.getDataProvider();
m_dialog.infoDialog("NatTable", data.getDataValue(0, 0).toString());

But the table is still invisible :-(

Does somebody know how the ViewPart should look like to solve my problem?

Regards,
Pedro


###########################################


////////////////////////////////////////////////////
// view part
////////////////////////////////////////////////////

@Override
public void createPartControl(final Composite parent) {
parent.setLayout(new FillLayout());

final ScrolledComposite scrolledContainer = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
scrolledContainer.setLayout(new FillLayout());
scrolledContainer.setExpandHorizontal(true);
scrolledContainer.setExpandVertical(true);

m_containerMain = m_formToolkit.createComposite(scrolledContainer, SWT.NONE);
m_containerMain.setBackground(resource.getColorWhite());
m_formToolkit.paintBordersFor(m_containerMain);
m_containerMain.setLayout(null);

scrolledContainer.setContent(m_containerMain);
scrolledContainer.setAlwaysShowScrollBars(true);

scrolledContainer.addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent e) {
scrolledContainer.setMinSize(m_containerMain.computeSize(SWT.DEFAULT, SWT.DEFAULT));
}
});

// ............

m_tabFolderMain = new TabFolder(m_containerMain, SWT.NONE);
m_tabFolderMain.setFont(resource.getFontBold());
m_tabFolderMain.setBounds(10, 50, 1059, 849);
m_tabFolderMain.setBackground(resource.getColorWhite());
m_formToolkit.paintBordersFor(m_tabFolderMain);

// ...........

m_containerContainer = new Composite(m_tabFolderMain, SWT.NONE);
m_tabItemContainer.setControl(m_containerContainer);
m_formToolkit.paintBordersFor(m_containerContainer);
m_containerContainer.setBackground(resource.getColorWhite());
m_containerContainer.setFont(resource.getFont());
m_containerContainer.setLayout(new GridLayout(1, false));

m_commonRowGroupingDataTable = new RowGroupingDataTable();
if (!m_commonRowGroupingDataTable.createTable(m_containerContainer)) {
m_logger.warn("createPartControl: can not create NatTable.");
}
}

////////////////////////////////////////////////////
// class RowGroupingDataTable
////////////////////////////////////////////////////

import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;

import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;

import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.nebula.widgets.nattable.NatTable;
import org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration;
import org.eclipse.nebula.widgets.nattable.data.IRowDataProvider;
import org.eclipse.nebula.widgets.nattable.grid.data.DefaultBodyDataProvider;
import org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider;
import org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider;
import org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider;
import org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer;
import org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer;
import org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer;
import org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer;
import org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer;
import org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer;
import org.eclipse.nebula.widgets.nattable.group.RowGroupExpandCollapseLayer;
import org.eclipse.nebula.widgets.nattable.group.RowGroupHeaderLayer;
import org.eclipse.nebula.widgets.nattable.group.model.RowGroupModel;
import org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer;
import org.eclipse.nebula.widgets.nattable.hideshow.RowHideShowLayer;
import org.eclipse.nebula.widgets.nattable.layer.DataLayer;
import org.eclipse.nebula.widgets.nattable.layer.ILayer;
import org.eclipse.nebula.widgets.nattable.layer.config.DefaultRowHeaderLayerConfiguration;
import org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer;
import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer;
import org.eclipse.nebula.widgets.nattable.style.theme.ModernNatTableThemeConfiguration;
import org.eclipse.nebula.widgets.nattable.ui.menu.HeaderMenuConfiguration;
import org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer;

public abstract class ARowGroupingTable<T> extends ANatTable {
private static final Logger m_logger = Logger.getLogger(ARowGroupingTable.class);

protected NatTable m_natTable;
protected IRowDataProvider<T> m_bodyDataProvider;
protected RowGroupModel<T> m_rowGroupModel;

public ARowGroupingTable() {
super();
}

abstract protected String[] getPropertyNames();
abstract protected Map<String,String> getPropertyToLabelMap();
abstract protected void mapDataToRowGroup();
abstract protected List<T> createData();

@Override
public boolean createTable(Composite parent) {

boolean result = false;

try {
if (m_natTable != null) {
return false;
}

// Body

// property names of the Person class
String[] propertyNames = getPropertyNames();

// mapping from property to label, needed for column header labels
Map<String,String> propertyToLabelMap = getPropertyToLabelMap();

// build the body layer stack
// Usually you would create a new layer stack by extending
// AbstractIndexLayerTransform and
// setting the ViewportLayer as underlying layer. But in this case using
// the ViewportLayer
// directly as body layer is also working.
m_bodyDataProvider = new DefaultBodyDataProvider<T>(createData(), propertyNames);
DataLayer bodyDataLayer = new DataLayer(m_bodyDataProvider);

ColumnReorderLayer columnReorderLayer = new ColumnReorderLayer(bodyDataLayer);
ColumnHideShowLayer columnHideShowLayer = new ColumnHideShowLayer(columnReorderLayer);

RowHideShowLayer rowHideShowLayer = new RowHideShowLayer(columnHideShowLayer);
m_rowGroupModel = new RowGroupModel<T>();
m_rowGroupModel.setDataProvider(m_bodyDataProvider);
RowGroupExpandCollapseLayer<T> rowExpandCollapseLayer = new RowGroupExpandCollapseLayer<T>(rowHideShowLayer, m_rowGroupModel);

SelectionLayer selectionLayer = new SelectionLayer(rowExpandCollapseLayer);
ViewportLayer viewportLayer = new ViewportLayer(selectionLayer);

// Column header

DefaultColumnHeaderDataProvider defaultColumnHeaderDataProvider = new DefaultColumnHeaderDataProvider(propertyNames, propertyToLabelMap);
DefaultColumnHeaderDataLayer columnHeaderDataLayer = new DefaultColumnHeaderDataLayer(defaultColumnHeaderDataProvider);
ColumnHeaderLayer columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer, viewportLayer, selectionLayer);

// Row header

DefaultRowHeaderDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(m_bodyDataProvider);
DefaultRowHeaderDataLayer rowHeaderDataLayer = new DefaultRowHeaderDataLayer(rowHeaderDataProvider);

RowHeaderLayer rowHeaderLayer = new RowHeaderLayer(rowHeaderDataLayer, viewportLayer, selectionLayer, false);
rowHeaderLayer.addConfiguration(new RowHeaderConfiguration());

RowGroupHeaderLayer<T> rowGroupHeaderLayer = new RowGroupHeaderLayer<T>(rowHeaderLayer, selectionLayer, m_rowGroupModel);
rowGroupHeaderLayer.setColumnWidth(20);

mapDataToRowGroup();

// Corner
final DefaultCornerDataProvider cornerDataProvider = new DefaultCornerDataProvider(defaultColumnHeaderDataProvider, rowHeaderDataProvider);
DataLayer cornerDataLayer = new DataLayer(cornerDataProvider);
ILayer cornerLayer = new CornerLayer(cornerDataLayer, rowGroupHeaderLayer, columnHeaderLayer);

// Grid
GridLayer gridLayer = new GridLayer(viewportLayer, columnHeaderLayer, rowGroupHeaderLayer, cornerLayer);

m_natTable = new NatTable(parent, gridLayer, false);

m_natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
m_natTable.addConfiguration(new HeaderMenuConfiguration(m_natTable));

m_natTable.configure();

m_natTable.setTheme(new ModernNatTableThemeConfiguration());

m_natTable.setLayoutData(new GridData(GridData.FILL_BOTH));

GridDataFactory.fillDefaults().grab(true, true).applyTo(m_natTable);

result = true;
}
catch (Exception e) {
ExceptionLogger.logWarn(methodName, e);
result = false;
}

return result;
}

private class RowHeaderConfiguration extends DefaultRowHeaderLayerConfiguration {
@Override
protected void addRowHeaderUIBindings() {
// We're suppressing the row resize bindings.
}
}
}
Re: NatTable eample EditorExmple not visible in Composite (ViewPart Eclipse 3.7) [message #1795680 is a reply to message #1795571] Wed, 26 September 2018 18:27 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2682
Registered: July 2012
Senior Member
I suppose there is a layout problem in your code. As it is quite complicated you should probably try to simplify the layout first to only contain the NatTable and then extend it to the expected format.
Previous Topic:What is the best way to lock/unlock rows for editing
Next Topic:Resizing Columns for a Single Row
Goto Forum:
  


Current Time: Mon May 20 00:20:52 GMT 2019

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

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

Back to the top