GridData.HORIZONTAL_ALIGN_BEGINNING);
buttonDuplicateGridData.widthHint = 80;
duplicate.setLayoutData(buttonDuplicateGridData);
duplicate.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
CSVRow row = (CSVRow) ((IStructuredSelection) tableViewer
.getSelection()).getFirstElement();
if (row != null) {
model.duplicateRow(row);
tableModified();
}
}
});
Button insert = new Button(canvas, SWT.PUSH | SWT.CENTER);
insert.setText("Insert Row");
insert.setToolTipText("Insert a new row before the current one");
GridData buttonInsertGridData = new GridData (GridData.HORIZONTAL_ALIGN_BEGINNING);
buttonInsertGridData.widthHint = 80;
insert.setLayoutData(buttonInsertGridData);
insert.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
CSVRow row = (CSVRow) ((IStructuredSelection)
tableViewer.getSelection()).getFirstElement();
if (row != null) {
model.addRowAfterElement(row);
tableModified();
}
}
});
/*
insert.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
//if(((e.stateMask & SWT.CTRL) != 0) & (e.keyCode == 'd')) {
//if (e.stateMask == SWT.CTRL && e.keyCode == 'd') {
if (e.character == SWT.DEL) {
CSVRow row = (CSVRow) ((IStructuredSelection)
tableViewer.getSelection()).getFirstElement();
if (row != null) {
model.addLineAfterElement(row);
tableViewer.refresh();
tableModified();
}
}
}
});
*/
Button add = new Button(canvas, SWT.PUSH | SWT.CENTER);
add.setText("Add Row");
add.setToolTipText("Add a new row at the end of the file");
GridData buttonAddGridData = new GridData (GridData.HORIZONTAL_ALIGN_BEGINNING);
buttonAddGridData.widthHint = 80;
add.setLayoutData(buttonAddGridData);
add.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
model.addRow();
tableModified();
}
});
Button delete = new Button(canvas, SWT.PUSH | SWT.CENTER);
delete.setText("Delete Row");
delete.setToolTipText("Delete the current row");
GridData buttonDelGridData = new GridData (GridData.HORIZONTAL_ALIGN_BEGINNING);
buttonDelGridData.widthHint = 80;
delete.setLayoutData(buttonDelGridData);
delete.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
CSVRow row = (CSVRow) ((IStructuredSelection) tableViewer
.getSelection()).getFirstElement();
while(row != null){
row = (CSVRow) ((IStructuredSelection) tableViewer.getSelection()).getFirstElement();
if (row != null) {