Java 类org.eclipse.core.runtime.ISafeRunnable 实例源码

项目:AgentWorkbench    文件:EvaluateContributionsHandler.java   
/**
 * 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);
}
项目:subclipse    文件:SVNProviderPlugin.java   
/**
 * 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);
    }
}
项目:subclipse    文件:SVNProviderPlugin.java   
/**
 * 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);
    }
}
项目:subclipse    文件:SVNProviderPlugin.java   
/**
 * 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);
    }
}
项目:subclipse    文件:SVNProviderPlugin.java   
/**
 * 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);
    }
}
项目:eclipse.jdt.ls    文件:PreferenceManager.java   
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);
    }
}
项目:eclipse.jdt.ls    文件:BundleUtilsTest.java   
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];
}
项目:mesfavoris    文件:BookmarkMappingsStore.java   
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);
            }
        });
    }
}
项目:fluentmark    文件:PageRoot.java   
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);
            }
        });
    }
}
项目:che    文件:DynamicValidationStateChange.java   
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);
          }
        });
  }
}
项目:che    文件:DeltaProcessor.java   
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();
            }
          }
        });
  }
}
项目:che    文件:UndoManager2.java   
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);
          }
        });
  }
}
项目:che    文件:UndoManager2.java   
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);
          }
        });
  }
}
项目:che    文件:UndoManager2.java   
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);
          }
        });
  }
}
项目:che    文件:UndoManager2.java   
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);
          }
        });
  }
}
项目:che    文件:RefactoringHistoryService.java   
private void fireRefactoringExecutionEvent(
    final RefactoringDescriptorProxy proxy, final int eventType) {
  Assert.isNotNull(proxy);
  final Object[] listeners = fExecutionListeners.getListeners();
  for (int index = 0; index < listeners.length; index++) {
    final IRefactoringExecutionListener listener =
        (IRefactoringExecutionListener) listeners[index];
    SafeRunner.run(
        new ISafeRunnable() {

          public void handleException(final Throwable throwable) {
            RefactoringCorePlugin.log(throwable);
          }

          public void run() throws Exception {
            listener.executionNotification(
                new RefactoringExecutionEvent(RefactoringHistoryService.this, eventType, proxy));
          }
        });
  }
}
项目:che    文件:RefactoringHistoryService.java   
private void fireRefactoringHistoryEvent(
    final RefactoringDescriptorProxy proxy, final int eventType) {
  Assert.isNotNull(proxy);
  final Object[] listeners = fHistoryListeners.getListeners();
  for (int index = 0; index < listeners.length; index++) {
    final IRefactoringHistoryListener listener = (IRefactoringHistoryListener) listeners[index];
    SafeRunner.run(
        new ISafeRunnable() {

          public void handleException(final Throwable throwable) {
            RefactoringCorePlugin.log(throwable);
          }

          public void run() throws Exception {
            listener.historyNotification(
                new RefactoringHistoryEvent(RefactoringHistoryService.this, eventType, proxy));
          }
        });
  }
}
项目:che    文件:CompositeChange.java   
/**
 * {@inheritDoc}
 *
 * <p>The composite change sends <code>dispose</code> to all its children. It is guaranteed that
 * all children receive the <code>dispose</code> call.
 */
public void dispose() {
  for (Iterator iter = fChanges.iterator(); iter.hasNext(); ) {
    final Change change = (Change) iter.next();
    SafeRunner.run(
        new ISafeRunnable() {
          public void run() throws Exception {
            change.dispose();
          }

          public void handleException(Throwable exception) {
            RefactoringCorePlugin.log(exception);
          }
        });
  }
}
项目:SecureBPMN    文件:ExportMarshallerRunnable.java   
private void invokeExportMarshaller(final ExportMarshaller exportMarshaller, final Diagram diagram, final IProgressMonitor monitor) {

    ISafeRunnable runnable = new ISafeRunnable() {

      @Override
      public void handleException(Throwable exception) {
        System.out.println("An exception occurred while running ExportMarshaller " + exportMarshaller.getMarshallerName() + ": " + exception.getMessage());
      }

      @Override
      public void run() throws Exception {
        exportMarshaller.marshallDiagram(diagram, monitor);
      }
    };
    SafeRunner.run(runnable);
  }
项目:PDFReporter-Studio    文件:SuggestionProviderLoader.java   
private static void executeExtension(final Object o) {
    ISafeRunnable runnable = new ISafeRunnable() {
        @Override
        public void handleException(Throwable e) {
            //TODO logging
            //              System.out.println("Exception in extension");
        }

        @Override
        public void run() throws Exception {
            ISuggestionProvider provider = ((ISuggestionProvider) o);
            SuggestionProviderUtils.addSuggestionProvider(provider);
        }
    };
    SafeRunner.run(runnable);
}
项目:PDFReporter-Studio    文件:MultiPageToolbarEditorPart.java   
/**
 * Disposes the given part and its site.
 * 
 * @param part
 *          The part to dispose; must not be <code>null</code>.
 */
private void disposePart(final IWorkbenchPart part) {
    SafeRunner.run(new ISafeRunnable() {
        public void run() {
            IWorkbenchPartSite partSite = part.getSite();
            part.dispose();
            if (partSite instanceof MultiPageToolbarEditorSite) {
                ((MultiPageToolbarEditorSite) partSite).dispose();
            }
        }

        public void handleException(Throwable e) {
            // Exception has already being logged by Core. Do nothing.
        }
    });
}
项目:APICloud-Studio    文件:StatusCollector.java   
/**
 * Notify a status change to the registered listeners.
 * 
 * @param oldStatus
 * @param newStatus
 */
private void notifyChange(final IStatus oldStatus, final IStatus newStatus)
{
    IStatusCollectorListener[] notifyTo = listeners.toArray(new IStatusCollectorListener[listeners.size()]);
    for (final IStatusCollectorListener listener : notifyTo)
    {
        SafeRunner.run(new ISafeRunnable()
        {

            public void run() throws Exception
            {
                listener.statusChanged(oldStatus, newStatus);
            }

            public void handleException(Throwable exception)
            {
                IdeLog.logError(CorePlugin.getDefault(),
                        "StatusCollector: Error while notifying a staus change event.", exception); //$NON-NLS-1$
            }
        });
    }
}
项目:APICloud-Studio    文件:ServerManager.java   
private void notifyListeners(Kind kind, IServer serverConfiguration)
{
    final ServerChangeEvent event = new ServerChangeEvent(kind, serverConfiguration);
    for (Object i : listeners.getListeners())
    {
        final IServerChangeListener listener = (IServerChangeListener) i;
        SafeRunner.run(new ISafeRunnable()
        {
            public void run()
            {
                listener.configurationChanged(event);
            }

            public void handleException(Throwable exception)
            {
                IdeLog.logError(WebServerCorePlugin.getDefault(), exception);
            }
        });
    }
}
项目:APICloud-Studio    文件:SVNProviderPlugin.java   
/**
 * 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);
    }
}
项目:APICloud-Studio    文件:SVNProviderPlugin.java   
/**
 * 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);
    }
}
项目:APICloud-Studio    文件:SVNProviderPlugin.java   
/**
 * 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);
    }
}
项目:APICloud-Studio    文件:SVNProviderPlugin.java   
/**
 * 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);
    }
}
项目:OpenSPIFe    文件:AbstractInPlaceDialog.java   
private void notifyButtonPressed(boolean isClosing) {
    final InPlaceDialogEvent event = new InPlaceDialogEvent(getReturnCode(), isClosing);
    for (final IInPlaceDialogListener listener : listeners) {
        SafeRunnable.run(new ISafeRunnable() {

            @Override
            public void run() throws Exception {
                listener.buttonPressed(event);
            }

            @Override
            public void handleException(Throwable exception) {
                LogUtil.error(new Status(IStatus.ERROR, "Multiselect Widget!", "Error while notifying IInPlaceCloseListener", exception));
            }
        });
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:DynamicValidationStateChange.java   
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);
            }
        });
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:ContributedCleanUpTabPage.java   
@Override
public void setWorkingValues(Map<String, String> workingValues) {
    super.setWorkingValues(workingValues);

    final CleanUpOptions options= new CleanUpOptions(workingValues) {
        /*
         * @see org.eclipse.jdt.internal.ui.fix.CleanUpOptions#setOption(java.lang.String, java.lang.String)
         */
        @Override
        public void setOption(String key, String value) {
            super.setOption(key, value);

            doUpdatePreview();
            notifyValuesModified();
        }
    };
    SafeRunner.run(new ISafeRunnable() {
        public void handleException(Throwable exception) {
            ContributedCleanUpTabPage.this.handleException(exception);
        }

        public void run() throws Exception {
            fContribution.setOptions(options);
        }
    });
}
项目:Eclipse-Postfix-Code-Completion    文件:ContributedCleanUpTabPage.java   
@Override
protected void doCreatePreferences(Composite composite, int numColumns) {
    final Composite parent= new Composite(composite, SWT.NONE);
    GridData layoutData= new GridData(SWT.FILL, SWT.FILL, true, true);
    layoutData.horizontalSpan= numColumns;
    parent.setLayoutData(layoutData);
    GridLayout layout= new GridLayout(1, false);
    layout.marginHeight= 0;
    layout.marginWidth= 0;
    parent.setLayout(layout);

    SafeRunner.run(new ISafeRunnable() {
        public void handleException(Throwable exception) {
            ContributedCleanUpTabPage.this.handleException(exception);

            Label label= new Label(parent, SWT.NONE);
            label.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
            label.setText(CleanUpMessages.ContributedCleanUpTabPage_ErrorPage_message);
        }

        public void run() throws Exception {
            fContribution.createContents(parent);
        }
    });
}
项目:Eclipse-Postfix-Code-Completion    文件:ContributedCleanUpTabPage.java   
@Override
public int getSelectedCleanUpCount() {
    final int[] result= new int[] { 0 };
    SafeRunner.run(new ISafeRunnable() {
        public void handleException(Throwable exception) {
            ContributedCleanUpTabPage.this.handleException(exception);
        }

        public void run() throws Exception {
            int count= fContribution.getSelectedCleanUpCount();
            Assert.isTrue(count >= 0 && count <= getCleanUpCount());
            result[0]= count;
        }
    });
    return result[0];
}
项目:Eclipse-Postfix-Code-Completion    文件:ClasspathAttributeConfigurationDescriptors.java   
public ClasspathAttributeConfiguration get(final String attributeKey) {
    final Descriptor desc= getDescriptors().get(attributeKey);
    if (desc == null) {
        return null;
    }
    final ClasspathAttributeConfiguration[] res= { null };
    SafeRunner.run(new ISafeRunnable() {

        public void handleException(Throwable exception) {
            JavaPlugin.log(exception);
            getDescriptors().remove(attributeKey); // remove from list
        }

        public void run() throws Exception {
            res[0]= desc.getInstance();
        }
    });
    return res[0];
}
项目:Eclipse-Postfix-Code-Completion    文件:FilterDescriptor.java   
/**
 * Creates a new <code>ViewerFilter</code>.
 * This method is only valid for viewer filters.
 * @return a new <code>ViewerFilter</code>
 */
public ViewerFilter createViewerFilter() {
    if (!isCustomFilter())
        return null;

    final ViewerFilter[] result= new ViewerFilter[1];
    String message= Messages.format(FilterMessages.FilterDescriptor_filterCreationError_message, getId());
    ISafeRunnable code= new SafeRunnable(message) {
        /*
         * @see org.eclipse.core.runtime.ISafeRunnable#run()
         */
        public void run() throws Exception {
            result[0]= (ViewerFilter)fElement.createExecutableExtension(CLASS_ATTRIBUTE);
        }

    };
    SafeRunner.run(code);
    return result[0];
}
项目:Eclipse-Postfix-Code-Completion    文件:TypeHierarchy.java   
/**
 * Notifies listeners that this hierarchy has changed and needs
 * refreshing. Note that listeners can be removed as we iterate
 * through the list.
 */
public void fireChange() {
    ArrayList listeners = getClonedChangeListeners(); // clone so that a listener cannot have a side-effect on this list when being notified
    if (listeners == null) {
        return;
    }
    if (DEBUG) {
        System.out.println("FIRING hierarchy change ["+Thread.currentThread()+"]"); //$NON-NLS-1$ //$NON-NLS-2$
        if (this.focusType != null) {
            System.out.println("    for hierarchy focused on " + ((JavaElement)this.focusType).toStringWithAncestors()); //$NON-NLS-1$
        }
    }

    for (int i= 0; i < listeners.size(); i++) {
        final ITypeHierarchyChangedListener listener= (ITypeHierarchyChangedListener)listeners.get(i);
        SafeRunner.run(new ISafeRunnable() {
            public void handleException(Throwable exception) {
                Util.log(exception, "Exception occurred in listener of Type hierarchy change notification"); //$NON-NLS-1$
            }
            public void run() throws Exception {
                listener.typeHierarchyChanged(TypeHierarchy.this);
            }
        });
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:ReconcileWorkingCopyOperation.java   
private void notifyParticipants(final CompilationUnit workingCopy) {
    IJavaProject javaProject = getWorkingCopy().getJavaProject();
    CompilationParticipant[] participants = JavaModelManager.getJavaModelManager().compilationParticipants.getCompilationParticipants(javaProject);
    if (participants == null) return;

    final ReconcileContext context = new ReconcileContext(this, workingCopy);
    for (int i = 0, length = participants.length; i < length; i++) {
        final CompilationParticipant participant = participants[i];
        SafeRunner.run(new ISafeRunnable() {
            public void handleException(Throwable exception) {
                if (exception instanceof Error) {
                    throw (Error) exception; // errors are not supposed to be caught
                } else if (exception instanceof OperationCanceledException)
                    throw (OperationCanceledException) exception;
                else if (exception instanceof UnsupportedOperationException) {
                    // might want to disable participant as it tried to modify the buffer of the working copy being reconciled
                    Util.log(exception, "Reconcile participant attempted to modify the buffer of the working copy being reconciled"); //$NON-NLS-1$
                } else
                    Util.log(exception, "Exception occurred in reconcile participant"); //$NON-NLS-1$
            }
            public void run() throws Exception {
                participant.reconcile(context);
            }
        });
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:Buffer.java   
/**
 * Notify the listeners that this buffer has changed.
 * To avoid deadlock, this should not be called in a synchronized block.
 */
protected void notifyChanged(final BufferChangedEvent event) {
    ArrayList listeners = this.changeListeners;
    if (listeners != null) {
        for (int i = 0, size = listeners.size(); i < size; ++i) {
            final IBufferChangedListener listener = (IBufferChangedListener) listeners.get(i);
            SafeRunner.run(new ISafeRunnable() {
                public void handleException(Throwable exception) {
                    Util.log(exception, "Exception occurred in listener of buffer change notification"); //$NON-NLS-1$
                }
                public void run() throws Exception {
                    listener.bufferChanged(event);
                }
            });

        }
    }
}
项目:translationstudio8    文件:SimpleMatcherFactory.java   
/**
 * 加载记忆库匹配实现 ;
 */
private void runExtension() {
    IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_ID);
    try {
        for (IConfigurationElement e : config) {
            final Object o = e.createExecutableExtension("class");
            if (o instanceof ISimpleMatcher) {
                ISafeRunnable runnable = new ISafeRunnable() {

                    public void handleException(Throwable exception) {
                        logger.error(Messages.getString("simpleMatch.SimpleMatcherFactory.logger1"), exception);
                    }

                    public void run() throws Exception {
                        ISimpleMatcher simpleMatcher = (ISimpleMatcher) o;                          
                        matchers.add(simpleMatcher);
                    }
                };
                SafeRunner.run(runnable);
            }
        }
    } catch (CoreException ex) {
        logger.error(Messages.getString("simpleMatch.SimpleMatcherFactory.logger1"), ex);
    }
}
项目:translationstudio8    文件:TmMatcher.java   
/**
 * 加哉记忆库匹配实现 ;
 */
private void runExtension() {
    IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(
            TMMATCH_EXTENSION_ID);
    try {
        for (IConfigurationElement e : config) {
            final Object o = e.createExecutableExtension("class");
            if (o instanceof ITmMatch) {
                ISafeRunnable runnable = new ISafeRunnable() {

                    public void handleException(Throwable exception) {
                        logger.error(Messages.getString("match.TmMatcher.logger1"), exception);
                    }

                    public void run() throws Exception {
                        tmTranslation = (ITmMatch) o;
                    }
                };
                SafeRunner.run(runnable);
            }
        }
    } catch (CoreException ex) {
        logger.error(Messages.getString("match.TmMatcher.logger1"), ex);
    }
}
项目:translationstudio8    文件:ComplexMatcherFactory.java   
/**
 * load implement of complex matcher
 */
private void runExtension() {
    IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_ID);
    try {
        for (IConfigurationElement e : config) {
            final Object o = e.createExecutableExtension("class");
            if (o instanceof IComplexMatch) {
                ISafeRunnable runnable = new ISafeRunnable() {

                    public void handleException(Throwable exception) {
                        logger.error(Messages.getString("complexMatch.ComplexMatcherFactory.logger1"), exception);
                    }

                    public void run() throws Exception {
                        IComplexMatch simpleMatcher = (IComplexMatch) o;                            
                        matchers.add(simpleMatcher);
                    }
                };
                SafeRunner.run(runnable);
            }
        }
    } catch (CoreException ex) {
        logger.error(Messages.getString("complexMatch.ComplexMatcherFactory.logger1"), ex);
    }
}