Button addButton = new Button(composite, SWT.PUSH);
addButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL
| GridData.VERTICAL_ALIGN_BEGINNING));
addButton.setText("Add");
addButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
// never called
}
/**
* Opens a file dialog and adds the selected files to the file table viewer.
*/
public void widgetSelected(SelectionEvent e) {
// open a file dialog
FileDialog fd = new FileDialog(Display.getCurrent().getActiveShell(), SWT.MULTI);
fd.setText("Choose text files");
fd.setFilterExtensions(new String[] { "*.txt", "*.rtf" });
if (fd.open() != null) {
for (String fileItem : fd.getFileNames()) {
fileTable.add(new File(fd.getFilterPath() + File.separator + fileItem));
}
computePageComplete();
}
}
});
Button removeButton = new Button(composite, SWT.PUSH);
removeButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL
| GridData.VERTICAL_ALIGN_BEGINNING));
removeButton.setText("Remove");
removeButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
// never called
}
/**
* Removes selected elements from the file table viewer.
*/
public void widgetSelected(SelectionEvent e) {
IStructuredSelection selection = (IStructuredSelection) fileTable.getSelection();
Iterator seletionIterator = selection.iterator();
Object selectedElements[] = new Object[selection.size()];
for (int i = 0; i < selection.size(); i++) {
selectedElements[i] = seletionIterator.next();
}
fileTable.remove(selectedElements);
computePageComplete();
}
});
Button selectAllButton = new Button(composite, SWT.PUSH);
selectAllButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL
| GridData.VERTICAL_ALIGN_BEGINNING));
selectAllButton.setText("Select All");
selectAllButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
// never called
}
/**
* Selects all elements in the file table viewer.
*/
public void widgetSelected(SelectionEvent e) {
fileTable.getTable().selectAll();
fileTable.setSelection(fileTable.getSelection());
}
});
Button deselectAllButton = new Button(composite, SWT.PUSH);
deselectAllButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL
| GridData.VERTICAL_ALIGN_BEGINNING));
deselectAllButton.setText("Deselect All");
deselectAllButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
// never called
}
/**
* Deselects all elements in the file table viewer.
*/
public void widgetSelected(SelectionEvent e) {
fileTable.getTable().deselectAll();
fileTable.setSelection(fileTable.getSelection());
}
});
Label corpusFolderLabel = new Label(composite, SWT.NONE);
corpusFolderLabel.setText("Into corpus:");
final Text corpusText = new Text(composite, SWT.READ_ONLY | SWT.BORDER);
corpusText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
if (importDestinationPath != null) {
corpusText.setText(importDestinationPath.toString());
computePageComplete();
}
Button browseForCorpusFolder = new Button(composite, SWT.NONE);
browseForCorpusFolder.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL
| GridData.VERTICAL_ALIGN_BEGINNING));
browseForCorpusFolder.setText("Browse");
browseForCorpusFolder.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
// never called
}