dialog.setFilterExtensions(new String[] { "*.jar" });
dialog.setText("Choose a bundle");
if (dialog.open() != null) {
ISelection selection = viewer.getSelection();
TreeObject selectedItem = (TreeObject) ((IStructuredSelection) selection).getFirstElement();
ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(getShell());
try {
String[] files = dialog.getFileNames();
String path = dialog.getFilterPath();
for (int i = 0; i < files.length; i++) {
files[i] = path + File.separatorChar + files[i];
}
progressDialog.run(true, false, new BundleDeployJob(getRepositoryLocation(selectedItem), files));
viewer.refresh();
} catch (InvocationTargetException e) {
MessageDialog.openError(getShell(), "Add bundle", "Could not add bundle\n"
+ e.getTargetException().getMessage());
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
};
actionAddBundle.setText("Add Bundles...");
actionAddBundle.setToolTipText("Add bundles to a repository");
actionAddBundle.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(
ISharedImages.IMG_TOOL_NEW_WIZARD));
actionRemoveBundle = new Action() {
public void run() {
ISelection selection = viewer.getSelection();
TreeObject selectedItem = (TreeObject) ((IStructuredSelection) selection).getFirstElement();
BundleDescriptor descriptor = (BundleDescriptor) selectedItem.getValue();
if (MessageDialog.openConfirm(getShell(), "Removing bundle", "Are you sure to remove bundle\n"
+ descriptor.getBundleSymbolicName() + " (" + descriptor.getBundleVersion() + ")")) {
ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(getShell());
try {
progressDialog.run(true, false, new BundleUndeployJob(getRepositoryLocation(selectedItem.getParent()),
descriptor.getBundleSymbolicName(), descriptor.getBundleVersion()));
viewer.refresh();
} catch (InvocationTargetException e) {
MessageDialog.openError(getShell(), "Add bundle", "Could not remove bundle\n"
+ e.getTargetException().getMessage());