Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » TableViewer ICellModifier not working on Dialog
TableViewer ICellModifier not working on Dialog [message #459954] Sun, 21 August 2005 10:04 Go to next message
ddd is currently offline ddd
Messages: 33
Registered: July 2009
Member
Hello,

I created a dialog for editing prefered propertys for added component in my
Graphical Editor, but when I want to edit cells it seems like ICellModifier
is not present. Should I add some Listeners...


My code:

public class PreferedProperyInputDialog extends Dialog
{
private AbstractComponentModel m_abstractComponentModel;

private TableViewer m_tableViewer;

public PreferedProperyInputDialog(Shell parent, AbstractComponentModel
abstractComponentModel)
{
super(parent);
m_abstractComponentModel = abstractComponentModel;
}

protected Control createDialogArea(Composite parent)
{
Composite area = (Composite) super.createDialogArea(parent);

m_tableViewer = new TableViewer(area);
Table table = m_tableViewer.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);

TableColumn name = new TableColumn(table, SWT.NONE, 0);
name.setText("Property name");
name.setWidth(150);

TableColumn value = new TableColumn(table, SWT.NONE, 1);
value.setText("Property value");
value.setWidth(400);

final CellEditor[] editors = new CellEditor[2];
TextCellEditor editor = new TextCellEditor(table);
editor.activate();
editors[1] = editor;

m_tableViewer.setLabelProvider(new
PreferedPropertyTableLabelProvider());
m_tableViewer.setContentProvider(new ArrayContentProvider());
m_tableViewer.setCellEditors(editors);
m_tableViewer.setCellModifier(new PreferedPropertyTableCellModifier());
m_tableViewer.getCellModifier();
initContent();

return area;
}

private void initContent()
{
List content = new ArrayList();
Collections.addAll(content,
m_abstractComponentModel.getAbstractValuePropertyDataManager ()
.getPropertyDescriptors());
m_tableViewer.setInput(content);
}

private class PreferedPropertyTableLabelProvider implements
ITableLabelProvider
{

public Image getColumnImage(Object element, int columnIndex)
{
return null;
}

public String getColumnText(Object element, int columnIndex)
{
PropertyDescriptor propertyDescriptor = (PropertyDescriptor) element;

if (columnIndex == 0)
{
return propertyDescriptor.getDisplayName();
}

return
m_abstractComponentModel.getPropertyValue(propertyDescriptor .getId())
.toString();
}

public void addListener(ILabelProviderListener listener)
{

}

public void dispose()
{

}

public boolean isLabelProperty(Object element, String property)
{
return false;
}

public void removeListener(ILabelProviderListener listener)
{
}
}

private class PreferedPropertyTableCellModifier implements ICellModifier
{

public boolean canModify(Object element, String property)
{
return property.equals(m_tableViewer.getColumnProperties()[1]);
}

public Object getValue(Object element, String property)
{
if (property.equals(m_tableViewer.getColumnProperties()[1]))
{
PropertyDescriptor propertyDescriptor = (PropertyDescriptor)
element;
return
m_abstractComponentModel.getPropertyValue(propertyDescriptor .getId())
.toString();
}
return null;
}

public void modify(Object element, String property, Object value)
{
if (property.equals(m_tableViewer.getColumnProperties()[1]))
{
PropertyDescriptor propertyDescriptor = (PropertyDescriptor)
element;

m_abstractComponentModel.setPropertyValue(propertyDescriptor .getId(),
value);
}
}
}
}



Thank you,

Danijel
Re: TableViewer ICellModifier not working on Dialog [message #460067 is a reply to message #459954] Sun, 21 August 2005 19:15 Go to previous message
Chris is currently offline Chris
Messages: 17
Registered: July 2009
Junior Member
What is the AbstractComponentModel?
Previous Topic:TableTree refresh does not preserve expansions
Next Topic:How to implement animation in canvas
Goto Forum:
  


Current Time: Thu Jul 24 18:59:34 EDT 2014

Powered by FUDForum. Page generated in 0.01445 seconds