* @param shell
*/
public void createContents(final Shell shell)
{
// Create an editor object to use for text editing
final TableEditor editor = new TableEditor(table);
editor.horizontalAlignment = SWT.LEFT;
editor.grabHorizontal = true;
editor.grabVertical = true;
// Use a selection listener to get seleceted row
table.addSelectionListener(new SelectionAdapter()
{
public void widgetSelected(SelectionEvent event)
{
// Dispose any existing editor
Control old = editor.getEditor();
if (old != null)
{
old.dispose();
}
// Determine which row was selected
final TableItem item = (TableItem) event.item;
if (item != null)
{
// COMBO
if (item.getText().equals("Style")
|| item.getText().equals("Arrow")
|| item.getText().equals("Shape"))
{
// Create the dropdown and add data to it
final CCombo combo = new CCombo(table, SWT.READ_ONLY);
if (item.getText().equals("Style"))
{
String[] styleOfEdge = {"Solid", "Dashed"};
combo.setItems(styleOfEdge);
}
else if (item.getText().equals("Arrow"))
{
String[] arrowOfEdge = {"None",
"Source",
"Target",
"Both"};
combo.setItems(arrowOfEdge);
}
else if (item.getText().equals("Shape"))
{
combo.setItems(NodeModel.shapes);
}
// Select the previously selected item from the cell
combo.select(combo.indexOf(item.getText(1)));
// combo.setFont(tableFont);
editor.setEditor(combo, item, 1);
// Add a listener to set the selected item back into the
// cell
combo.addSelectionListener(new SelectionAdapter()
{
public void widgetSelected(SelectionEvent event)
{
item.setText(1, combo.getText());
// They selected an item; end the editing
// session
combo.dispose();
}
});
}
// TEXT
else if (item.getText().equals("Text"))
{
// Create the Text object for our editor
final Text text = new Text(table, SWT.LEFT);
// text.setForeground(item.getForeground());
// Transfer any text from the cell to the Text control,
// set the color to match this row, select the text,
// and set focus to the control
text.setText(item.getText(1));
// text.setFont(tableFont);
// text.setForeground(item.getForeground());
text.selectAll();
text.setFocus();
editor.setEditor(text, item, 1);
// Add a handler to transfer the text back to the cell
// any time it's modified
text.addModifyListener(new ModifyListener()
{
public void modifyText(ModifyEvent event)
{
// Set the text of the editor's control back
// into the cell
item.setText(1, text.getText());
}
});
}
// NUMBER
else if (item.getText().equals("Margin")
|| item.getText().equals("Cluster ID")
|| item.getText().equals("Width"))
{
// Create the Text object for our editor
final Text text = new Text(table, SWT.LEFT);
// text.setForeground(item.getForeground());
// Transfer any text from the cell to the Text control,
// set the color to match this row, select the text,
// and set focus to the control
text.setText(item.getText(1));
// text.setFont(tableFont);
// text.setForeground(item.getForeground());
text.selectAll();
text.setFocus();
editor.setEditor(text, item, 1);
// Add a handler to transfer the text back to the cell
// any time it's modified
text.addModifyListener(new ModifyListener()
{