2 * Copyright 2015 Samsung Electronics All Rights Reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package oic.simulator.serviceprovider.view.dialogs;
21 import oic.simulator.serviceprovider.Activator;
22 import oic.simulator.serviceprovider.resource.DeleteCategory;
23 import oic.simulator.serviceprovider.utils.Utility;
25 import org.eclipse.core.runtime.FileLocator;
26 import org.eclipse.core.runtime.IPath;
27 import org.eclipse.core.runtime.Path;
28 import org.eclipse.jface.dialogs.MessageDialog;
29 import org.eclipse.jface.resource.ImageDescriptor;
30 import org.eclipse.jface.wizard.Wizard;
31 import org.eclipse.swt.widgets.Shell;
32 import org.eclipse.ui.PlatformUI;
35 * This class creates a UI wizard for delete resource operation.
37 public class DeleteResourceWizard extends Wizard {
39 private DeleteResourcePage page;
41 public DeleteResourceWizard() {
42 setWindowTitle("Delete resources");
43 IPath path = new Path("/icons/oic_logo_64x64.png");
44 URL find = FileLocator.find(Activator.getDefault().getBundle(), path,
46 setDefaultPageImageDescriptor(ImageDescriptor.createFromURL(find));
50 public void addPages() {
51 page = new DeleteResourcePage();
56 public boolean performFinish() {
60 // Check the existence of the resource if the user has entered the uri
61 if (page.getDeleteCategory() == DeleteCategory.BY_URI) {
62 // Check whether the uri is in full form or short form
63 // If it is in short form, expand it to its full form.
64 String uri = page.getDeleteCandidate();
65 boolean uriComplete = Utility.isUriComplete(uri);
67 uri = Utility.displayNameToUri(uri);
69 boolean exist = Activator.getDefault().getResourceManager()
70 .isResourceExist(uri);
72 Shell activeShell = PlatformUI.getWorkbench().getDisplay()
74 MessageDialog dialog = new MessageDialog(activeShell,
75 "Resource Not Found", null,
76 "No resource exist with the given URI.",
77 MessageDialog.INFORMATION, new String[] { "OK" }, 0);
79 page.setFocusToTextBox();
86 public DeleteCategory getDeleteCategory() {
88 return DeleteCategory.NONE;
90 return page.getDeleteCategory();
93 public String getDeleteCandidate() {
97 return page.getDeleteCandidate();