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;
24 import org.eclipse.core.runtime.FileLocator;
25 import org.eclipse.core.runtime.IPath;
26 import org.eclipse.core.runtime.Path;
27 import org.eclipse.jface.dialogs.MessageDialog;
28 import org.eclipse.jface.resource.ImageDescriptor;
29 import org.eclipse.jface.wizard.Wizard;
30 import org.eclipse.swt.widgets.Shell;
31 import org.eclipse.ui.PlatformUI;
34 * This class creates a UI wizard for delete resource operation.
36 public class DeleteResourceWizard extends Wizard {
38 private DeleteResourcePage page;
40 public DeleteResourceWizard() {
41 setWindowTitle("Delete resources");
42 IPath path = new Path("/icons/oic_logo_64x64.png");
43 URL find = FileLocator.find(Activator.getDefault().getBundle(), path,
45 setDefaultPageImageDescriptor(ImageDescriptor.createFromURL(find));
49 public void addPages() {
50 page = new DeleteResourcePage();
55 public boolean performFinish() {
59 // Check the existence of the resource if the user has entered the uri
60 if (page.getDeleteCategory() == DeleteCategory.BY_URI) {
61 // Check whether the uri is in full form or short form
62 // If it is in short form, expand it to its full form.
63 String uri = page.getDeleteCandidate();
64 boolean dispName = Activator.getDefault().getResourceManager()
67 uri = Activator.getDefault().getResourceManager()
68 .getCompleteUriFromDisplayName(uri);
70 boolean exist = Activator.getDefault().getResourceManager()
71 .isResourceExist(uri);
73 Shell activeShell = PlatformUI.getWorkbench().getDisplay()
75 MessageDialog dialog = new MessageDialog(activeShell,
76 "Resource Not Found", null,
77 "No resource exist with the given URI.",
78 MessageDialog.INFORMATION, new String[] { "OK" }, 0);
80 page.setFocusToTextBox();
87 public DeleteCategory getDeleteCategory() {
89 return DeleteCategory.NONE;
91 return page.getDeleteCategory();
94 public String getDeleteCandidate() {
98 return page.getDeleteCandidate();