public void dispose() {
}
@Override
public Object[] getElements(Object inputElement) {
UserIgnoreFileFilter filter = (UserIgnoreFileFilter) inputElement;
List<File> ignoredFiles = new LinkedList<File>();
for (String filename : filter.getIgnoredFileNames()) {
File file = new File(filename);
if (file.exists()) {
ignoredFiles.add(file);
}
}
return ignoredFiles.toArray();
}
});
final UserIgnoreFileFilter individualFilter = Renamer.getDefault().getUserFilters().getIndividualFilter();
viewer.setInput(individualFilter);
individualFilter.addFilterListener(new FilterListener() {
@Override
public void filterChanged(Filter<File> filter) {
viewer.refresh();
}
});
GridData tableLayoutData = new GridData(SWT.FILL, SWT.TOP, true, false, 1, 3);
tableLayoutData.heightHint = 150;
viewer.getTable().setLayoutData(tableLayoutData);
addFileButton = new Button(parent, SWT.PUSH);
addFileButton.setText("Add File...");
addFileButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
addFileButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String filePath = new FileDialog(parent.getShell()).open();
if (filePath != null) {
individualFilter.addIgnoredFile(new File(filePath));
}
}
});
addFolderButton = new Button(parent, SWT.PUSH);
addFolderButton.setText("Add Folder...");
addFolderButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
addFolderButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String folderPath = new DirectoryDialog(parent.getShell()).open();
if (folderPath != null) {
individualFilter.addIgnoredFile(new File(folderPath));
}
}
});
removeButton = new Button(parent, SWT.PUSH);
removeButton.setText("Remove");
removeButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
removeButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
TableItem[] selection = viewer.getTable().getSelection();
File[] filesToRemove = new File[selection.length];
int i = 0;
for (TableItem selectedItem : selection) {
filesToRemove[i++] = (File) selectedItem.getData();
}
for (File file : filesToRemove) {
individualFilter.removeIgnoredFile(file);
}
}
});
}