当前位置: 首页>>代码示例>>Java>>正文


Java IElementChangedListener类代码示例

本文整理汇总了Java中org.eclipse.jdt.core.IElementChangedListener的典型用法代码示例。如果您正苦于以下问题:Java IElementChangedListener类的具体用法?Java IElementChangedListener怎么用?Java IElementChangedListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IElementChangedListener类属于org.eclipse.jdt.core包,在下文中一共展示了IElementChangedListener类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: firePostChangeDelta

import org.eclipse.jdt.core.IElementChangedListener; //导入依赖的package包/类
private void firePostChangeDelta(
    IJavaElementDelta deltaToNotify,
    IElementChangedListener[] listeners,
    int[] listenerMask,
    int listenerCount) {

  // post change deltas
  if (DEBUG) {
    System.out.println(
        "FIRING POST_CHANGE Delta [" + Thread.currentThread() + "]:"); // $NON-NLS-1$//$NON-NLS-2$
    System.out.println(
        deltaToNotify == null ? "<NONE>" : deltaToNotify.toString()); // $NON-NLS-1$
  }
  if (deltaToNotify != null) {
    // flush now so as to keep listener reactions to post their own deltas for subsequent
    // iteration
    flush();

    //			// mark the operation stack has not modifying resources since resource deltas are being
    // fired
    //			JavaModelOperation.setAttribute(JavaModelOperation.HAS_MODIFIED_RESOURCE_ATTR, null);

    notifyListeners(
        deltaToNotify, ElementChangedEvent.POST_CHANGE, listeners, listenerMask, listenerCount);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:27,代码来源:DeltaProcessor.java

示例2: fireReconcileDelta

import org.eclipse.jdt.core.IElementChangedListener; //导入依赖的package包/类
private void fireReconcileDelta(
    IElementChangedListener[] listeners, int[] listenerMask, int listenerCount) {

  IJavaElementDelta deltaToNotify = mergeDeltas(this.reconcileDeltas.values());
  if (DEBUG) {
    System.out.println(
        "FIRING POST_RECONCILE Delta ["
            + Thread.currentThread()
            + "]:"); // $NON-NLS-1$//$NON-NLS-2$
    System.out.println(
        deltaToNotify == null ? "<NONE>" : deltaToNotify.toString()); // $NON-NLS-1$
  }
  if (deltaToNotify != null) {
    // flush now so as to keep listener reactions to post their own deltas for subsequent
    // iteration
    this.reconcileDeltas = new HashMap();

    notifyListeners(
        deltaToNotify,
        ElementChangedEvent.POST_RECONCILE,
        listeners,
        listenerMask,
        listenerCount);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:26,代码来源:DeltaProcessor.java

示例3: notifyTypeHierarchies

import org.eclipse.jdt.core.IElementChangedListener; //导入依赖的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();
            }
          }
        });
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:27,代码来源:DeltaProcessor.java

示例4: init

import org.eclipse.jdt.core.IElementChangedListener; //导入依赖的package包/类
protected void init(IJavaProject project) {
	if (project == null || !project.exists() || !project.getResource().isAccessible())
		throw new IllegalArgumentException("Invalid javaProject");
	this.javaProject = project;
	getURLClassloader();
	listener = new IElementChangedListener() {

		public void elementChanged(final ElementChangedEvent event) {
			if (ignoreClasspathChanges(event))
				return;
			System.out.println("CLASSPATH CHANGED:" + event);
			// FIXME should release this classloader
			// what happend with current objects? we have 1 loader per
			// project, maybe se can filter some events? to have less
			// updates
			curlLoader = null;
			getURLClassloader();
			if (events != null)
				events.firePropertyChange("classpath", false, true);
		}
	};
	JavaCore.addElementChangedListener(listener, ElementChangedEvent.POST_CHANGE);
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:24,代码来源:JavaProjectClassLoader.java

示例5: fire

import org.eclipse.jdt.core.IElementChangedListener; //导入依赖的package包/类
public static void fire(final ElementChangedEvent extraEvent) {
    for (int i = 0; i < elementChangedListenerCount; i++) {
        if ((elementChangedListenerMasks[i] & extraEvent.getType()) != 0) {
            final IElementChangedListener listener = elementChangedListeners[i];

            // wrap callbacks with Safe runnable for subsequent listeners to
            // be called when some are causing grief
            SafeRunner.run(new ISafeRunnable() {
                @Override
                public void handleException(Throwable exception) {
                // Util.log(exception, "Exception occurred in listener
                // of Java element change notification"); //$NON-NLS-1$
                }

                @Override
                public void run() throws Exception {
                    listener.elementChanged(extraEvent);
                }
            });

        }
    }
}
 
开发者ID:forcedotcom,项目名称:idecore,代码行数:24,代码来源:ForceIdeEditorsPlugin.java

示例6: removeElementChangedListener

import org.eclipse.jdt.core.IElementChangedListener; //导入依赖的package包/类
public synchronized void removeElementChangedListener(IElementChangedListener listener) {

    for (int i = 0; i < this.elementChangedListenerCount; i++) {

      if (this.elementChangedListeners[i] == listener) {

        // need to clone defensively since we might be in the middle of listener notifications
        // (#fire)
        int length = this.elementChangedListeners.length;
        IElementChangedListener[] newListeners = new IElementChangedListener[length];
        System.arraycopy(this.elementChangedListeners, 0, newListeners, 0, i);
        int[] newMasks = new int[length];
        System.arraycopy(this.elementChangedListenerMasks, 0, newMasks, 0, i);

        // copy trailing listeners
        int trailingLength = this.elementChangedListenerCount - i - 1;
        if (trailingLength > 0) {
          System.arraycopy(this.elementChangedListeners, i + 1, newListeners, i, trailingLength);
          System.arraycopy(this.elementChangedListenerMasks, i + 1, newMasks, i, trailingLength);
        }

        // update manager listener state (#fire need to iterate over original listeners through a
        // local variable to hold onto
        // the original ones)
        this.elementChangedListeners = newListeners;
        this.elementChangedListenerMasks = newMasks;
        this.elementChangedListenerCount--;
        return;
      }
    }
  }
 
开发者ID:eclipse,项目名称:che,代码行数:32,代码来源:DeltaProcessingState.java

示例7: removeElementChangedListener

import org.eclipse.jdt.core.IElementChangedListener; //导入依赖的package包/类
/**
 * Removes the given element changed listener. Has no affect if an identical listener is not registered.
 * 
 * @param listener
 *            the listener
 */
public static void removeElementChangedListener(IElementChangedListener listener) {
    for (int i = 0; i < elementChangedListenerCount; i++) {

        if (elementChangedListeners[i] == listener) {

            // need to clone defensively since we might be in the middle of
            // listener notifications (#fire)
            int length = elementChangedListeners.length;
            IElementChangedListener[] newListeners = new IElementChangedListener[length];
            System.arraycopy(elementChangedListeners, 0, newListeners, 0, i);
            int[] newMasks = new int[length];
            System.arraycopy(elementChangedListenerMasks, 0, newMasks, 0, i);

            // copy trailing listeners
            int trailingLength = elementChangedListenerCount - i - 1;
            if (trailingLength > 0) {
                System.arraycopy(elementChangedListeners, i + 1, newListeners, i, trailingLength);
                System.arraycopy(elementChangedListenerMasks, i + 1, newMasks, i, trailingLength);
            }

            // update manager listener state (#fire need to iterate over
            // original listeners through a local variable to hold onto
            // the original ones)
            elementChangedListeners = newListeners;
            elementChangedListenerMasks = newMasks;
            elementChangedListenerCount--;
            return;
        }
    }
}
 
开发者ID:forcedotcom,项目名称:idecore,代码行数:37,代码来源:ForceIdeEditorsPlugin.java

示例8: fire

import org.eclipse.jdt.core.IElementChangedListener; //导入依赖的package包/类
public void fire(IJavaElementDelta customDelta, int eventType) {
  if (!this.isFiring) return;

  if (DEBUG) {
    System.out.println(
        "-----------------------------------------------------------------------------------------------------------------------"); // $NON-NLS-1$
  }

  IJavaElementDelta deltaToNotify;
  if (customDelta == null) {
    deltaToNotify = mergeDeltas(this.javaModelDeltas);
  } else {
    deltaToNotify = customDelta;
  }

  // Refresh internal scopes
  if (deltaToNotify != null) {
    Iterator scopes = this.manager.searchScopes.keySet().iterator();
    while (scopes.hasNext()) {
      AbstractSearchScope scope = (AbstractSearchScope) scopes.next();
      scope.processDelta(deltaToNotify, eventType);
    }
    JavaWorkspaceScope workspaceScope = this.manager.workspaceScope;
    if (workspaceScope != null) workspaceScope.processDelta(deltaToNotify, eventType);
  }

  // Notification

  // Important: if any listener reacts to notification by updating the listeners list or mask,
  // these lists will
  // be duplicated, so it is necessary to remember original lists in a variable (since field
  // values may change under us)
  IElementChangedListener[] listeners;
  int[] listenerMask;
  int listenerCount;
  synchronized (this.state) {
    listeners = this.state.elementChangedListeners;
    listenerMask = this.state.elementChangedListenerMasks;
    listenerCount = this.state.elementChangedListenerCount;
  }

  switch (eventType) {
    case DEFAULT_CHANGE_EVENT:
    case ElementChangedEvent.POST_CHANGE:
      firePostChangeDelta(deltaToNotify, listeners, listenerMask, listenerCount);
      fireReconcileDelta(listeners, listenerMask, listenerCount);
      break;
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:50,代码来源:DeltaProcessor.java

示例9: notifyListeners

import org.eclipse.jdt.core.IElementChangedListener; //导入依赖的package包/类
private void notifyListeners(
    IJavaElementDelta deltaToNotify,
    int eventType,
    IElementChangedListener[] listeners,
    int[] listenerMask,
    int listenerCount) {
  final ElementChangedEvent extraEvent = new ElementChangedEvent(deltaToNotify, eventType);
  for (int i = 0; i < listenerCount; i++) {
    if ((listenerMask[i] & eventType) != 0) {
      final IElementChangedListener listener = listeners[i];
      long start = -1;
      if (VERBOSE) {
        System.out.print(
            "Listener #" + (i + 1) + "=" + listener.toString()); // $NON-NLS-1$//$NON-NLS-2$
        start = System.currentTimeMillis();
      }
      // 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 {
              PerformanceStats stats = null;
              if (PERF) {
                //							stats = PerformanceStats.getStats(JavaModelManager.DELTA_LISTENER_PERF,
                // listener);
                //							stats.startRun();
              }
              listener.elementChanged(extraEvent);
              if (PERF) {
                stats.endRun();
              }
            }
          });
      if (VERBOSE) {
        System.out.println(
            " -> " + (System.currentTimeMillis() - start) + "ms"); // $NON-NLS-1$ //$NON-NLS-2$
      }
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:47,代码来源:DeltaProcessor.java

示例10: addElementChangedListener

import org.eclipse.jdt.core.IElementChangedListener; //导入依赖的package包/类
/**
 * Adds the given listener for changes to Java elements. Has no effect if an identical listener is already
 * registered.
 * 
 * This listener will only be notified during the POST_CHANGE resource change notification and any reconcile
 * operation (POST_RECONCILE). For finer control of the notification, use
 * <code>addElementChangedListener(IElementChangedListener,int)</code>, which allows to specify a different
 * eventMask.
 * 
 * @param listener
 *            the listener
 * @see ElementChangedEvent
 */
public static void addElementChangedListener(IElementChangedListener listener) {
    addElementChangedListener(listener, ElementChangedEvent.POST_CHANGE | ElementChangedEvent.POST_RECONCILE);
}
 
开发者ID:forcedotcom,项目名称:idecore,代码行数:17,代码来源:ForceIdeEditorsPlugin.java


注:本文中的org.eclipse.jdt.core.IElementChangedListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。