1
|
/*******************************************************************************
|
2
|
* Copyright (c) 2010 IBM Corporation and others.
|
3
|
* All rights reserved. This program and the accompanying materials
|
4
|
* are made available under the terms of the Eclipse Public License v1.0
|
5
|
* which accompanies this distribution, and is available at
|
6
|
* http://www.eclipse.org/legal/epl-v10.html
|
7
|
*
|
8
|
* Contributors:
|
9
|
* IBM Corporation - initial API and implementation
|
10
|
******************************************************************************/
|
11
|
|
12
|
package org.eclipse.ui.internal.navigator;
|
13
|
|
14
|
import org.eclipse.core.runtime.IConfigurationElement;
|
15
|
import org.eclipse.core.runtime.IStatus;
|
16
|
import org.eclipse.jface.util.SafeRunnable;
|
17
|
import org.eclipse.osgi.util.NLS;
|
18
|
|
19
|
/**
|
20
|
* @since 3.5
|
21
|
*
|
22
|
*/
|
23
|
public abstract class NavigatorSafeRunnable extends SafeRunnable {
|
24
|
|
25
|
protected String _message;
|
26
|
protected IConfigurationElement _element;
|
27
|
protected Object _object;
|
28
|
|
29
|
/**
|
30
|
*
|
31
|
*/
|
32
|
public NavigatorSafeRunnable() {
|
33
|
super();
|
34
|
}
|
35
|
|
36
|
/**
|
37
|
* @param message
|
38
|
*/
|
39
|
public NavigatorSafeRunnable(String message) {
|
40
|
_message = message;
|
41
|
}
|
42
|
|
43
|
/**
|
44
|
* @param element
|
45
|
*/
|
46
|
public NavigatorSafeRunnable(IConfigurationElement element) {
|
47
|
_element = element;
|
48
|
}
|
49
|
|
50
|
/**
|
51
|
* @param element
|
52
|
* @param object
|
53
|
* an object to provide additional context
|
54
|
*/
|
55
|
public NavigatorSafeRunnable(IConfigurationElement element, Object object) {
|
56
|
_element = element;
|
57
|
_object = object;
|
58
|
}
|
59
|
|
60
|
public abstract void run() throws Exception;
|
61
|
|
62
|
public void handleException(Throwable e) {
|
63
|
String msg = _message;
|
64
|
if (msg == null)
|
65
|
msg = e.getMessage() != null ? e.getMessage() : e.toString();
|
66
|
if (_element != null) {
|
67
|
msg += ": " + //$NON-NLS-1$
|
68
|
NLS.bind(CommonNavigatorMessages.Exception_Invoking_Extension, new Object[] {
|
69
|
_element.getAttribute("id") + ": " + _element.getName(), _object }); //$NON-NLS-1$ //$NON-NLS-2$
|
70
|
}
|
71
|
NavigatorPlugin.log(IStatus.ERROR, 0, msg, e);
|
72
|
}
|
73
|
|
74
|
}
|