btnAdd.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
// IResource newFile = ResourcesPlugin.getWorkspace().getRoot();
// if(newFile != null) {
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider());
dialog.setValidator(new ISelectionStatusValidator() {
public IStatus validate(Object[] selection) {
if (selection.length > 0 && selection[0] instanceof IFile) {
return new Status(IStatus.OK, Plugin.PLUGIN_ID, IStatus.OK, "", null); //$NON-NLS-1$
}
return new Status(IStatus.ERROR, Plugin.PLUGIN_ID, IStatus.ERROR, "", null); //$NON-NLS-1$
}
});
dialog.setAllowMultiple(true);
dialog.setTitle("JAR File Selection");
dialog.setMessage("Select one or more JAR files.");
dialog.addFilter(new FileExtensionFilter("jar")); //$NON-NLS-1$
dialog.setInput(ResourcesPlugin.getWorkspace());
if (dialog.open() == Window.OK) {
Object[] files = dialog.getResult();
List<IPath> added = new ArrayList<IPath>(files.length);
for (Object file : files) {
added.add(((IResource) file).getFullPath().makeRelative());
}
if (!added.isEmpty()) {
addToPaths(added);
viewer.add(added.toArray(new IPath[added.size()]));
}
}
// }
update();
}
});
btnAddExternal.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
FileDialog dialog = new FileDialog(getShell(), SWT.OPEN | SWT.MULTI);
dialog.setFilterExtensions(new String[] {
"*.jar"}); //$NON-NLS-1$
String res = dialog.open();
if (res != null) {
IPath filterPath = new Path(dialog.getFilterPath());
String[] fileNames = dialog.getFileNames();
List<IPath> added = new ArrayList<IPath>(fileNames.length);
for (String fileName : fileNames) {
added.add(filterPath.append(fileName));
}
if (!added.isEmpty()) {