本文整理汇总了Java中org.eclipse.core.runtime.ISafeRunnable类的典型用法代码示例。如果您正苦于以下问题:Java ISafeRunnable类的具体用法?Java ISafeRunnable怎么用?Java ISafeRunnable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ISafeRunnable类属于org.eclipse.core.runtime包,在下文中一共展示了ISafeRunnable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: executeExtension
import org.eclipse.core.runtime.ISafeRunnable; //导入依赖的package包/类
/**
* Execute extension.
* @param object the object instance found
*/
private void executeExtension(final Object object) {
ISafeRunnable runnable = new ISafeRunnable() {
@Override
public void handleException(Throwable e) {
System.out.println("Exception in client");
}
@Override
public void run() throws Exception {
System.err.println(object.toString());
}
};
SafeRunner.run(runnable);
}
示例2: broadcastSyncInfoChanges
import org.eclipse.core.runtime.ISafeRunnable; //导入依赖的package包/类
/**
* This method is called by SyncFileChangeListener when metafiles have
* changed
*/
public static void broadcastSyncInfoChanges(final IResource[] resources, final boolean initializeListeners) {
IResourceStateChangeListener[] toNotify;
synchronized(listeners) {
toNotify = (IResourceStateChangeListener[])listeners.toArray(new IResourceStateChangeListener[listeners.size()]);
}
for (int i = 0; i < toNotify.length; ++i) {
final IResourceStateChangeListener listener = toNotify[i];
ISafeRunnable code = new ISafeRunnable() {
public void run() throws Exception {
if (initializeListeners) listener.initialize();
listener.resourceSyncInfoChanged(resources);
}
public void handleException(Throwable e) {
// don't log the exception....it is already being logged in
// Platform#run
}
};
SafeRunner.run(code);
}
}
示例3: broadcastModificationStateChanges
import org.eclipse.core.runtime.ISafeRunnable; //导入依赖的package包/类
/**
* This method is called by FileModificationManager when some resources have
* changed
*/
public static void broadcastModificationStateChanges(
final IResource[] resources) {
IResourceStateChangeListener[] toNotify;
synchronized(listeners) {
toNotify = (IResourceStateChangeListener[])listeners.toArray(new IResourceStateChangeListener[listeners.size()]);
}
for (int i = 0; i < toNotify.length; ++i) {
final IResourceStateChangeListener listener = toNotify[i];
ISafeRunnable code = new ISafeRunnable() {
public void run() throws Exception {
listener.resourceModified(resources);
}
public void handleException(Throwable e) {
// don't log the exception....it is already being logged in
// Platform#run
}
};
SafeRunner.run(code);
}
}
示例4: broadcastProjectConfigured
import org.eclipse.core.runtime.ISafeRunnable; //导入依赖的package包/类
/**
* This method is called by SVNTeamProvider.configureProject which is
* invoked when a project is mapped
*/
protected static void broadcastProjectConfigured(final IProject project) {
IResourceStateChangeListener[] toNotify;
synchronized(listeners) {
toNotify = (IResourceStateChangeListener[])listeners.toArray(new IResourceStateChangeListener[listeners.size()]);
}
for (int i = 0; i < toNotify.length; ++i) {
final IResourceStateChangeListener listener = toNotify[i];
ISafeRunnable code = new ISafeRunnable() {
public void run() throws Exception {
listener.projectConfigured(project);
}
public void handleException(Throwable e) {
// don't log the exception....it is already being logged in
// Platform#run
}
};
SafeRunner.run(code);
}
}
示例5: broadcastProjectDeconfigured
import org.eclipse.core.runtime.ISafeRunnable; //导入依赖的package包/类
/**
* This method is called by SVNTeamProvider.deconfigured which is invoked
* after a provider has been unmaped
*/
protected static void broadcastProjectDeconfigured(final IProject project) {
IResourceStateChangeListener[] toNotify;
synchronized(listeners) {
toNotify = (IResourceStateChangeListener[])listeners.toArray(new IResourceStateChangeListener[listeners.size()]);
}
for (int i = 0; i < toNotify.length; ++i) {
final IResourceStateChangeListener listener = toNotify[i];
ISafeRunnable code = new ISafeRunnable() {
public void run() throws Exception {
listener.projectDeconfigured(project);
}
public void handleException(Throwable e) {
// don't log the exception....it is already being logged in
// Platform#run
}
};
SafeRunner.run(code);
}
}
示例6: preferencesChanged
import org.eclipse.core.runtime.ISafeRunnable; //导入依赖的package包/类
private void preferencesChanged(Preferences oldPreferences, Preferences newPreferences) {
for (final IPreferencesChangeListener listener : preferencesChangeListeners) {
ISafeRunnable job = new ISafeRunnable() {
@Override
public void handleException(Throwable e) {
JavaLanguageServerPlugin.log(new CoreException(StatusFactory.newErrorStatus(e.getMessage(), e)));
}
@Override
public void run() throws Exception {
listener.preferencesChange(oldPreferences, newPreferences);
}
};
SafeRunner.run(job);
}
}
示例7: getBundleExtensionResult
import org.eclipse.core.runtime.ISafeRunnable; //导入依赖的package包/类
private String getBundleExtensionResult() {
IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSIONPOINT_ID);
assertEquals("Expect one extension point", 1, elements.length);
final String[] resultValues = new String[] { "" };
for (IConfigurationElement e : elements) {
if ("java".equals(e.getAttribute("type"))) {
SafeRunner.run(new ISafeRunnable() {
@Override
public void run() throws Exception {
final Object extInstance = e.createExecutableExtension("class");
resultValues[0] = extInstance.toString();
}
@Override
public void handleException(Throwable ex) {
IStatus status = new Status(IStatus.ERROR, JavaLanguageServerPlugin.PLUGIN_ID, IStatus.OK, "Error in JDT Core during launching debug server", ex); //$NON-NLS-1$
JavaLanguageServerPlugin.log(status);
}
});
}
}
return resultValues[0];
}
示例8: fireMappingAdded
import org.eclipse.core.runtime.ISafeRunnable; //导入依赖的package包/类
private void fireMappingAdded(BookmarkId bookmarkFolderId) {
Object[] listeners = listenerList.getListeners();
for (int i = 0; i < listeners.length; i++) {
final IBookmarkMappingsListener listener = (IBookmarkMappingsListener) listeners[i];
SafeRunner.run(new ISafeRunnable() {
public void run() throws Exception {
listener.mappingAdded(bookmarkFolderId);
}
public void handleException(Throwable exception) {
StatusHelper.logError("Error when mapping added", exception);
}
});
}
}
示例9: fire
import org.eclipse.core.runtime.ISafeRunnable; //导入依赖的package包/类
protected void fire() {
IElementChangedListener[] listeners;
synchronized (elementChangedListeners) {
listeners = new IElementChangedListener[elementChangedListeners.size()];
elementChangedListeners.toArray(listeners);
}
int offset = editor.getCursorOffset();
IElement part = partAtOffset(offset);
final ElementChangedEvent event = new ElementChangedEvent(this, part, ElementChangedEvent.POST_CHANGE);
for (IElementChangedListener listener : listeners) {
SafeRunner.run(new ISafeRunnable() {
@Override
public void run() throws Exception {
listener.elementChanged(event);
}
@Override
public void handleException(Throwable exception) {
Log.error("Exception during change notification", exception);
}
});
}
}
示例10: workspaceChanged
import org.eclipse.core.runtime.ISafeRunnable; //导入依赖的package包/类
public void workspaceChanged() {
long currentTime = System.currentTimeMillis();
if (currentTime - fTimeStamp < LIFE_TIME) return;
fValidationState =
RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.DynamicValidationStateChange_workspace_changed);
// remove listener from workspace tracker
WorkspaceTracker.INSTANCE.removeListener(this);
fListenerRegistered = false;
// clear up the children to not hang onto too much memory
Change[] children = clear();
for (int i = 0; i < children.length; i++) {
final Change change = children[i];
SafeRunner.run(
new ISafeRunnable() {
public void run() throws Exception {
change.dispose();
}
public void handleException(Throwable exception) {
JavaPlugin.log(exception);
}
});
}
}
示例11: notifyTypeHierarchies
import org.eclipse.core.runtime.ISafeRunnable; //导入依赖的package包/类
private void notifyTypeHierarchies(IElementChangedListener[] listeners, int listenerCount) {
for (int i = 0; i < listenerCount; i++) {
final IElementChangedListener listener = listeners[i];
if (!(listener instanceof TypeHierarchy)) continue;
// wrap callbacks with Safe runnable for subsequent listeners to be called when some are
// causing grief
SafeRunner.run(
new ISafeRunnable() {
public void handleException(Throwable exception) {
Util.log(
exception,
"Exception occurred in listener of Java element change notification"); // $NON-NLS-1$
}
public void run() throws Exception {
TypeHierarchy typeHierarchy = (TypeHierarchy) listener;
if (typeHierarchy.hasFineGrainChanges()) {
// case of changes in primary working copies
typeHierarchy.needsRefresh = true;
typeHierarchy.fireChange();
}
}
});
}
}
示例12: fireAboutToPerformChange
import org.eclipse.core.runtime.ISafeRunnable; //导入依赖的package包/类
private void fireAboutToPerformChange(final Change change) {
if (fListeners == null) return;
Object[] listeners = fListeners.getListeners();
for (int i = 0; i < listeners.length; i++) {
final IUndoManagerListener listener = (IUndoManagerListener) listeners[i];
SafeRunner.run(
new ISafeRunnable() {
public void run() throws Exception {
listener.aboutToPerformChange(UndoManager2.this, change);
}
public void handleException(Throwable exception) {
RefactoringCorePlugin.log(exception);
}
});
}
}
示例13: fireChangePerformed
import org.eclipse.core.runtime.ISafeRunnable; //导入依赖的package包/类
private void fireChangePerformed(final Change change) {
if (fListeners == null) return;
Object[] listeners = fListeners.getListeners();
for (int i = 0; i < listeners.length; i++) {
final IUndoManagerListener listener = (IUndoManagerListener) listeners[i];
SafeRunner.run(
new ISafeRunnable() {
public void run() throws Exception {
listener.changePerformed(UndoManager2.this, change);
}
public void handleException(Throwable exception) {
RefactoringCorePlugin.log(exception);
}
});
}
}
示例14: fireUndoStackChanged
import org.eclipse.core.runtime.ISafeRunnable; //导入依赖的package包/类
private void fireUndoStackChanged() {
if (fListeners == null) return;
Object[] listeners = fListeners.getListeners();
for (int i = 0; i < listeners.length; i++) {
final IUndoManagerListener listener = (IUndoManagerListener) listeners[i];
SafeRunner.run(
new ISafeRunnable() {
public void run() throws Exception {
listener.undoStackChanged(UndoManager2.this);
}
public void handleException(Throwable exception) {
RefactoringCorePlugin.log(exception);
}
});
}
}
示例15: fireRedoStackChanged
import org.eclipse.core.runtime.ISafeRunnable; //导入依赖的package包/类
private void fireRedoStackChanged() {
if (fListeners == null) return;
Object[] listeners = fListeners.getListeners();
for (int i = 0; i < listeners.length; i++) {
final IUndoManagerListener listener = (IUndoManagerListener) listeners[i];
SafeRunner.run(
new ISafeRunnable() {
public void run() throws Exception {
listener.redoStackChanged(UndoManager2.this);
}
public void handleException(Throwable exception) {
RefactoringCorePlugin.log(exception);
}
});
}
}