org.eclipse.wst.common.internal.emfworkbench.WorkbenchResourceHelper类的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(118)

本文整理了Java中org.eclipse.wst.common.internal.emfworkbench.WorkbenchResourceHelper类的一些代码示例,展示了WorkbenchResourceHelper类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WorkbenchResourceHelper类的具体详情如下:
包路径:org.eclipse.wst.common.internal.emfworkbench.WorkbenchResourceHelper
类名称:WorkbenchResourceHelper

WorkbenchResourceHelper介绍

暂无

代码示例

代码示例来源:origin: org.eclipse/org.eclipse.wst.common.emfworkbench.integration

protected List getFiles(List refResources) {
  List files = new ArrayList(refResources.size());
  IFile file = null;
  ReferencedResource refRes = null;
  for (int i = 0; i < refResources.size(); i++) {
    refRes = (ReferencedResource) refResources.get(i);
    file = WorkbenchResourceHelper.getFile(refRes);
    if (file != null)
      files.add(file);
  }
  return files;
}

代码示例来源:origin: org.eclipse/org.eclipse.wst.xml.core

public void modelDirtyStateChanged(IStructuredModel model, boolean isDirty) {
  if (!isDirty && resource.isModified()) { // The XMLModel was saved
    resource.setModified(false);
    long stamp = WorkbenchResourceHelper.computeModificationStamp(resource);
    WorkbenchResourceHelper.setSynhronizationStamp(resource, stamp);
    IProject proj = WorkbenchResourceHelper.getProject(resource);
    ResourceSetWorkbenchEditSynchronizer synchronizer = (ResourceSetWorkbenchEditSynchronizer) ((ProjectResourceSet) WorkbenchResourceHelperBase.getResourceSet(proj)).getSynchronizer();
    IFile aFile = WorkbenchResourceHelper.getFile(resource);
    synchronizer.preSave(aFile);
  }
  if (isDirty)
    resource.setModified(true);
}

代码示例来源:origin: org.eclipse/org.eclipse.wst.common.emfworkbench.integration

public static IFile getFile(IProject project, URI uri) {
  ResourceSet set = getResourceSet(project);
  return getFile(set, uri);
}

代码示例来源:origin: org.eclipse/org.eclipse.wst.common.emfworkbench.integration

/**
 * Return the IFile that currently corresponds to <code>aResource</code>.
 */
public static IFile getFile(Resource aResource) {
  if (aResource != null) {
    if (isReferencedResource(aResource))
      return getFile((ReferencedResource) aResource);
    return internalGetFile(aResource);
  }
  return null;
}

代码示例来源:origin: org.eclipse/org.eclipse.wst.common.emfworkbench.integration

/**
 * Delete
 * 
 * @aResource in the Workbench.
 */
public static void deleteResource(Resource aResource) throws CoreException {
  if (aResource != null)
    deleteFile(getFile(aResource));
}

代码示例来源:origin: org.eclipse/org.eclipse.wst.common.emfworkbench.integration

public static IProject getProject(Resource res) {
  IProject proj = getProject(res.getResourceSet());
  if (proj == null) {
    IFile file = getFile(res);
    if (file != null)
      proj = file.getProject();
  }
  return proj;
}

代码示例来源:origin: org.eclipse/org.eclipse.wst.common.emfworkbench.integration

protected static boolean isSameProject(Resource resourceA, Resource resourceB) {
  IProject pA, pB;
  pA = getProject(resourceA);
  pB = getProject(resourceB);
  if (pA != null && pB != null)
    return pA.equals(pB);
  //otherwise we do not have enough info to determine false so we must return true
  return true;
}

代码示例来源:origin: org.eclipse/org.eclipse.wst.common.emfworkbench.integration

protected long computeModificationStamp(ReferencedResource resource) {
  return WorkbenchResourceHelper.computeModificationStamp(resource);
}

代码示例来源:origin: org.eclipse/org.eclipse.wst.common.emfworkbench.integration

public static long computeModificationStamp(ReferencedResource resource) {
  FileAdapter adapter = getFileAdapter(resource);
  return adapter == null ? FileAdapter.FILE_NOT_LOADED : computeModificationStamp(adapter.getFile());
}

代码示例来源:origin: org.eclipse/org.eclipse.jst.j2ee

private static void startListeningToResourceSet(IProject project) {
  ResourceSet set = WorkbenchResourceHelper.getResourceSet(project);
  if (set != null)
    set.eAdapters().add(getResourceSetListener(project));
}
private static ModelProviderKey createProviderKey(IProjectFacetVersion fv, int priority) {

代码示例来源:origin: org.eclipse/org.eclipse.wst.common.emfworkbench.integration

/**
 * Method cacheValidateState.
 * 
 * @param result
 */
private void cacheValidateState(IStatus aStatus, List readOnlyResources, List roNonResourceFiles) {
  if (aStatus.isOK()) {
    if (readOnlyResources != null && !readOnlyResources.isEmpty()) {
      ReferencedResource res = null;
      for (int i = 0; i < readOnlyResources.size(); i++) {
        res = (ReferencedResource) readOnlyResources.get(i);
        WorkbenchResourceHelper.setSynhronizationStamp(res, computeModificationStamp(res));
      }
    }
    provider.cacheNonResourceValidateState(roNonResourceFiles);
  }
}

代码示例来源:origin: org.eclipse/org.eclipse.jst.j2ee

/**
 * Notify all editModels of the change.
 */
private static void removedResources(List removedResources) {
  Resource firstRes = (Resource)removedResources.get(0);
  IProject proj = WorkbenchResourceHelper.getProject(firstRes);
    IModelProviderEvent event = new ModelProviderEvent(IModelProviderEvent.REMOVED_RESOURCE, null,proj);
    event.addResources(removedResources);
    notifyModelProviders(event);
  
}

代码示例来源:origin: org.eclipse/org.eclipse.wst.common.emfworkbench.integration

/**
 * Cache the modification stamp of the <code>file</code>.
 * 
 * @param file
 */
private void cacheIgnored(IFile file) {
  long stamp = WorkbenchResourceHelper.computeModificationStamp(file);
  ignoredFilesCache.put(file, new Long(stamp));
}

代码示例来源:origin: org.eclipse/org.eclipse.wst.common.emfworkbench.integration

/**
 * Method cacheSynchronizationStamp.
 * 
 * @param r
 */
public static void cacheSynchronizationStamp(ReferencedResource refResource) {
  if (refResource != null) {
    FileAdapter adapter = getFileAdapter(refResource);
    if (adapter != null && adapter.getSynchronizationStamp() <= FileAdapter.FILE_NOT_LOADED)
      adapter.setSynchronizationStamp(computeModificationStamp(refResource));
  }
}

代码示例来源:origin: org.eclipse/org.eclipse.wst.xml.core

private void cacheSynchronizationStamp() {
  IFile file = WorkbenchResourceHelper.getFile(resource);
  if (file != null) {
    if (xmlModel != null)
      xmlModel.resetSynchronizationStamp(file);
  }
}

代码示例来源:origin: org.eclipse/org.eclipse.jst.j2ee.ui

public static String prependProjectName(EObject object, String label) {
  String projectName = null;
  if (object.eResource() != null) {
    IProject proj = WorkbenchResourceHelper.getProject(object.eResource());
    if (proj != null)
      projectName = proj.getName();
  }
  if (projectName == null || projectName.equals(label))
    return label;
  else if (label == null || label.length() == 0)
    return projectName;
  else
    return projectName + ": " + label; //$NON-NLS-1$
}

代码示例来源:origin: org.eclipse/org.eclipse.wst.common.emfworkbench.integration

/**
 * Return true if we have already ignored this <code>file</code> and that its modification
 * stamp is the same as when we processed it.
 * 
 * @param file
 * @return
 */
private boolean hasIgnored(IFile file) {
  Long cachedStamp = (Long) ignoredFilesCache.get(file);
  if (cachedStamp == null)
    return false;
  long stamp = WorkbenchResourceHelper.computeModificationStamp(file);
  return cachedStamp.longValue() == stamp;
}

代码示例来源:origin: org.eclipse/org.eclipse.jst.j2ee

public IResource getResource(Object object) {
  Resource resource = null;
  if (object != null && object instanceof EObject)
    resource = ((EObject) object).eResource();
  if (resource != null)
    return WorkbenchResourceHelper.getFile(resource);
  return null;
}

代码示例来源:origin: org.eclipse/org.eclipse.jst.j2ee

/**
 * Notify all editModels of the change.
 */
private static void removedResource(Resource removedResource) {
  IProject proj = WorkbenchResourceHelper.getProject(removedResource);
    IModelProviderEvent event = new ModelProviderEvent(IModelProviderEvent.REMOVED_RESOURCE, null,proj);
    event.addResource(removedResource);
    notifyModelProviders(event);
  
}

代码示例来源:origin: org.eclipse/org.eclipse.wst.common.emfworkbench.integration

/**
 * Method cacheLastNonRefreshFileStamps.
 * 
 * @param inconsistentFiles
 */
private void cacheLastNonRefreshFileStamps(List inconsistentFiles) {
  if (inconsistentFiles != null && !inconsistentFiles.isEmpty()) {
    Map map = getLastNonRefreshStateMap();
    IFile file = null;
    long stamp = 0;
    for (int i = 0; i < inconsistentFiles.size(); i++) {
      file = (IFile) inconsistentFiles.get(i);
      stamp = WorkbenchResourceHelper.computeModificationStamp(file);
      map.put(file, new Long(stamp));
    }
  }
}

相关文章