1 package oic.simulator.serviceprovider.view.dialogs;
5 import oic.simulator.serviceprovider.Activator;
6 import oic.simulator.serviceprovider.resource.DeleteCategory;
7 import oic.simulator.serviceprovider.utils.Utility;
9 import org.eclipse.core.runtime.FileLocator;
10 import org.eclipse.core.runtime.IPath;
11 import org.eclipse.core.runtime.Path;
12 import org.eclipse.jface.dialogs.MessageDialog;
13 import org.eclipse.jface.resource.ImageDescriptor;
14 import org.eclipse.jface.wizard.Wizard;
15 import org.eclipse.swt.widgets.Shell;
16 import org.eclipse.ui.PlatformUI;
18 public class DeleteResourceWizard extends Wizard {
20 private DeleteResourcePage page;
22 public DeleteResourceWizard() {
23 setWindowTitle("Delete resources");
24 IPath path = new Path("/icons/oic_logo_64x64.png");
25 URL find = FileLocator.find(Activator.getDefault().getBundle(), path,
27 setDefaultPageImageDescriptor(ImageDescriptor.createFromURL(find));
31 public void addPages() {
32 page = new DeleteResourcePage();
37 public boolean performFinish() {
38 // Check the existence of the resource if the user has entered the uri
39 if (page.getDeleteCategory() == DeleteCategory.BY_URI) {
40 // Check whether the uri is in full form or short form
41 // If it is in short form, expand it to its full form.
42 String uri = page.getDeleteCandidate();
43 boolean uriComplete = Utility.isUriComplete(uri);
45 uri = Utility.displayNameToUri(uri);
47 boolean exist = Activator.getDefault().getResourceManager()
48 .isResourceExist(uri);
50 Shell activeShell = PlatformUI.getWorkbench().getDisplay()
52 MessageDialog dialog = new MessageDialog(activeShell,
53 "Resource Not Found", null,
54 "No resource exist with the given URI.",
55 MessageDialog.INFORMATION, new String[] { "OK" }, 0);
57 page.setFocusToTextBox();
64 public DeleteCategory getDeleteCategory() {
65 return page.getDeleteCategory();
68 public String getDeleteCandidate() {
69 return page.getDeleteCandidate();