Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » example with Property Columns in editor(Property Columns with editing and moving)
example with Property Columns in editor [message #559838] Sun, 19 September 2010 21:20
Jay Norwood is currently offline Jay NorwoodFriend
Messages: 155
Registered: July 2009
Senior Member
Here is an example using Property Columns in the emf generated editor. It will display properties "Value" and "Description" from your model. You can edit in the property cells in the table, and can move around the columns. This is derived from bits and pieces of posts on the web. I commented out the FilteredTree for now, which has some bug.

Some things I learned:
1. The default generated label provider has to come before the column label provider code since the default one provides a label provider for the whole table.

2. The table edit cells require selection of the associated tree node before selecting the cell. I've tried turning on SWT.FULL_SELECTION to see if that fixes the problem, but there are still sync issues.

So just call this createExtraPages() in your generated editor, in its createPages(), after the other pages are created.

private void createExtraPages(){
// This is the page for the filtered table tree viewer.
//
{
ViewerPane viewerPane =
new ViewerPane(getSite().getPage(), Nodes2Editor.this) {
@Override
public Viewer createViewer(Composite composite) {
// PatternFilter filter = new PatternFilter();
// Boolean useNewLook = false;
// FilteredTree ft = new FilteredTree(composite, SWT.FULL_SELECTION/*| SWT.MULTI */| SWT.H_SCROLL
// | SWT.V_SCROLL| SWT.BORDER, filter,useNewLook);
// TreeViewer tv = ft.getViewer();
// return (Viewer) tv;
return new TreeViewer(composite);
}
@Override
public void requestActivation() {
super.requestActivation();
setCurrentViewerPane(this);
}
};


viewerPane.createControl(getContainer());

treeViewerWithColumns = (TreeViewer)viewerPane.getViewer();


Tree tree = treeViewerWithColumns.getTree();
tree.setLayoutData(new FillLayout());
tree.setHeaderVisible(true);
tree.setLinesVisible(true);

TreeColumn objectColumn = new TreeColumn(tree, SWT.NONE);
objectColumn.setText(getString("_UI_ObjectColumn_label"));
objectColumn.setResizable(true);
objectColumn.setWidth(250);


treeViewerWithColumns.setColumnProperties(new String [] {"a", "b", "c"});
treeViewerWithColumns.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
treeViewerWithColumns.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));

{
TreeColumn treeColumn = new TreeColumn ( tree, SWT.NONE ) ;
treeColumn.setText ( "Value" ) ;
treeColumn.setResizable ( true ) ;
treeColumn.setWidth ( 200 ) ;
treeColumn.setMoveable(true);
TreeViewerColumn treeViewerColumn = new TreeViewerColumn ( treeViewerWithColumns, treeColumn ) ;
treeViewerColumn.setLabelProvider ( new PropertyColumnLabelProvider ( new AdapterFactoryContentProvider(adapterFactory), "Value" )) ;
treeViewerColumn.setEditingSupport ( new PropertyEditingSupport ( treeViewerWithColumns, new AdapterFactoryContentProvider(adapterFactory), "Value" )) ;
}
{
TreeColumn treeColumn = new TreeColumn ( tree, SWT.NONE ) ;
treeColumn.setText ( "Description" ) ;
treeColumn.setResizable ( true ) ;
treeColumn.setWidth ( 200 ) ;
treeColumn.setMoveable(true);
TreeViewerColumn treeViewerColumn = new TreeViewerColumn ( treeViewerWithColumns, treeColumn ) ;
treeViewerColumn.setLabelProvider ( new PropertyColumnLabelProvider ( new AdapterFactoryContentProvider(adapterFactory), "Description" )) ;
treeViewerColumn.setEditingSupport ( new PropertyEditingSupport ( treeViewerWithColumns, new AdapterFactoryContentProvider(adapterFactory), "Description" )) ;
}

createContextMenuFor(treeViewerWithColumns);
int pageIndex = addPage(viewerPane.getControl());
setPageText(pageIndex, "FilteredTree");
}

}
Previous Topic:example with Property Columns in editor
Next Topic:[CDO] Update site for CDO 3.0
Goto Forum:
  


Current Time: Mon Oct 14 17:43:12 GMT 2019

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

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

Back to the top