blob: bc49a0fe2d142e68547cb46317a1e1312abd0deb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
/*****************************************************************************
* Copyright (c) 2011, 2013 CEA LIST.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
* Christian W. Damus (CEA) - Factor out workspace storage for pluggable storage providers (CDO)
*****************************************************************************/
package org.eclipse.papyrus.views.properties.toolsmiths.ui;
import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.papyrus.infra.properties.contexts.Context;
import org.eclipse.papyrus.infra.properties.internal.ui.runtime.IInternalConfigurationManager;
import org.eclipse.papyrus.infra.properties.ui.runtime.PropertiesRuntime;
import org.eclipse.papyrus.views.properties.toolsmiths.Activator;
import org.eclipse.papyrus.views.properties.toolsmiths.storage.actions.IContextDeleteAction;
import org.eclipse.swt.widgets.Display;
/**
* An action to delete an existing context. This action cannot be undone.
* If you simply want to disable an existing context, see {@link ConfigurationManager#disableContext(Context)}
*
* @author Camille Letavernier
*/
public class RemoveContextAction {
private IContextDeleteAction delegate;
public RemoveContextAction(IContextDeleteAction delegate) {
super();
this.delegate = delegate;
}
/**
* Deletes the given context.
*
* @param sourceContext
* The context to delete
*/
public void removeContext(final Context sourceContext) {
// TODO : Close editors for the context being deleted
ProgressMonitorDialog dialog = new ProgressMonitorDialog(Display.getCurrent().getActiveShell());
try {
dialog.run(false, false, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
IInternalConfigurationManager mgr = (IInternalConfigurationManager) PropertiesRuntime.getConfigurationManager();
delegate.delete(sourceContext, monitor);
mgr.deleteContext(sourceContext);
} catch (CoreException ex) {
Activator.log.error(ex);
}
}
});
} catch (Exception ex) {
Activator.log.error(ex);
}
}
}
|