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;
19 import org.eclipse.core.runtime.FileLocator;
20 import org.eclipse.core.runtime.IPath;
21 import org.eclipse.core.runtime.IProgressMonitor;
22 import org.eclipse.core.runtime.Path;
23 import org.eclipse.jface.operation.IRunnableWithProgress;
24 import org.eclipse.jface.resource.ImageDescriptor;
25 import org.eclipse.jface.wizard.Wizard;
27 import java.lang.reflect.InvocationTargetException;
29 import java.util.Date;
32 import org.oic.simulator.ILogger.Level;
33 import org.oic.simulator.SimulatorException;
35 import oic.simulator.serviceprovider.Activator;
36 import oic.simulator.serviceprovider.manager.ResourceManager;
37 import oic.simulator.serviceprovider.model.Resource;
38 import oic.simulator.serviceprovider.model.SingleResource;
41 * This class creates a UI wizard for delete resource operation.
43 public class DeleteResourceWizard extends Wizard {
45 private DeleteResourcePage page;
47 private boolean success;
49 public DeleteResourceWizard() {
50 setWindowTitle("Delete resources");
51 IPath path = new Path("/icons/oic_logo_64x64.png");
52 URL find = FileLocator.find(Activator.getDefault().getBundle(), path,
54 setDefaultPageImageDescriptor(ImageDescriptor.createFromURL(find));
56 setNeedsProgressMonitor(true);
60 public void addPages() {
61 page = new DeleteResourcePage();
66 public boolean performFinish() {
71 getContainer().run(true, false, new IRunnableWithProgress() {
74 public void run(IProgressMonitor monitor)
75 throws InvocationTargetException, InterruptedException {
76 ResourceManager resourceManager = Activator.getDefault()
77 .getResourceManager();
79 monitor.beginTask("Resource Deletion", 2);
81 Set<SingleResource> singleResources = page
82 .getSelectedSingleResourcesList();
83 if (null != singleResources
84 && singleResources.size() > 0) {
85 Activator.getDefault().getResourceManager()
86 .removeSingleResources(singleResources);
88 Resource res = resourceManager
89 .getCurrentResourceInSelection();
90 if (null != res && res instanceof SingleResource) {
92 .contains((SingleResource) res)) {
94 .resourceSelectionChanged(null);
100 } catch (SimulatorException e) {
107 } catch (InvocationTargetException e) {
108 Activator.getDefault().getLogManager()
109 .log(Level.ERROR.ordinal(), new Date(), e.getMessage());
110 } catch (InterruptedException e) {
111 Activator.getDefault().getLogManager()
112 .log(Level.ERROR.ordinal(), new Date(), e.getMessage());
117 public boolean getStatus() {