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

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

本文整理了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

  1. protected List getFiles(List refResources) {
  2. List files = new ArrayList(refResources.size());
  3. IFile file = null;
  4. ReferencedResource refRes = null;
  5. for (int i = 0; i < refResources.size(); i++) {
  6. refRes = (ReferencedResource) refResources.get(i);
  7. file = WorkbenchResourceHelper.getFile(refRes);
  8. if (file != null)
  9. files.add(file);
  10. }
  11. return files;
  12. }

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

  1. public void modelDirtyStateChanged(IStructuredModel model, boolean isDirty) {
  2. if (!isDirty && resource.isModified()) { // The XMLModel was saved
  3. resource.setModified(false);
  4. long stamp = WorkbenchResourceHelper.computeModificationStamp(resource);
  5. WorkbenchResourceHelper.setSynhronizationStamp(resource, stamp);
  6. IProject proj = WorkbenchResourceHelper.getProject(resource);
  7. ResourceSetWorkbenchEditSynchronizer synchronizer = (ResourceSetWorkbenchEditSynchronizer) ((ProjectResourceSet) WorkbenchResourceHelperBase.getResourceSet(proj)).getSynchronizer();
  8. IFile aFile = WorkbenchResourceHelper.getFile(resource);
  9. synchronizer.preSave(aFile);
  10. }
  11. if (isDirty)
  12. resource.setModified(true);
  13. }

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

  1. public static IFile getFile(IProject project, URI uri) {
  2. ResourceSet set = getResourceSet(project);
  3. return getFile(set, uri);
  4. }

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

  1. /**
  2. * Return the IFile that currently corresponds to <code>aResource</code>.
  3. */
  4. public static IFile getFile(Resource aResource) {
  5. if (aResource != null) {
  6. if (isReferencedResource(aResource))
  7. return getFile((ReferencedResource) aResource);
  8. return internalGetFile(aResource);
  9. }
  10. return null;
  11. }

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

  1. /**
  2. * Delete
  3. *
  4. * @aResource in the Workbench.
  5. */
  6. public static void deleteResource(Resource aResource) throws CoreException {
  7. if (aResource != null)
  8. deleteFile(getFile(aResource));
  9. }

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

  1. public static IProject getProject(Resource res) {
  2. IProject proj = getProject(res.getResourceSet());
  3. if (proj == null) {
  4. IFile file = getFile(res);
  5. if (file != null)
  6. proj = file.getProject();
  7. }
  8. return proj;
  9. }

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

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

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

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

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

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

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

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

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

  1. /**
  2. * Method cacheValidateState.
  3. *
  4. * @param result
  5. */
  6. private void cacheValidateState(IStatus aStatus, List readOnlyResources, List roNonResourceFiles) {
  7. if (aStatus.isOK()) {
  8. if (readOnlyResources != null && !readOnlyResources.isEmpty()) {
  9. ReferencedResource res = null;
  10. for (int i = 0; i < readOnlyResources.size(); i++) {
  11. res = (ReferencedResource) readOnlyResources.get(i);
  12. WorkbenchResourceHelper.setSynhronizationStamp(res, computeModificationStamp(res));
  13. }
  14. }
  15. provider.cacheNonResourceValidateState(roNonResourceFiles);
  16. }
  17. }

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

  1. /**
  2. * Notify all editModels of the change.
  3. */
  4. private static void removedResources(List removedResources) {
  5. Resource firstRes = (Resource)removedResources.get(0);
  6. IProject proj = WorkbenchResourceHelper.getProject(firstRes);
  7. IModelProviderEvent event = new ModelProviderEvent(IModelProviderEvent.REMOVED_RESOURCE, null,proj);
  8. event.addResources(removedResources);
  9. notifyModelProviders(event);
  10. }

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

  1. /**
  2. * Cache the modification stamp of the <code>file</code>.
  3. *
  4. * @param file
  5. */
  6. private void cacheIgnored(IFile file) {
  7. long stamp = WorkbenchResourceHelper.computeModificationStamp(file);
  8. ignoredFilesCache.put(file, new Long(stamp));
  9. }

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

  1. /**
  2. * Method cacheSynchronizationStamp.
  3. *
  4. * @param r
  5. */
  6. public static void cacheSynchronizationStamp(ReferencedResource refResource) {
  7. if (refResource != null) {
  8. FileAdapter adapter = getFileAdapter(refResource);
  9. if (adapter != null && adapter.getSynchronizationStamp() <= FileAdapter.FILE_NOT_LOADED)
  10. adapter.setSynchronizationStamp(computeModificationStamp(refResource));
  11. }
  12. }

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

  1. private void cacheSynchronizationStamp() {
  2. IFile file = WorkbenchResourceHelper.getFile(resource);
  3. if (file != null) {
  4. if (xmlModel != null)
  5. xmlModel.resetSynchronizationStamp(file);
  6. }
  7. }

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

  1. public static String prependProjectName(EObject object, String label) {
  2. String projectName = null;
  3. if (object.eResource() != null) {
  4. IProject proj = WorkbenchResourceHelper.getProject(object.eResource());
  5. if (proj != null)
  6. projectName = proj.getName();
  7. }
  8. if (projectName == null || projectName.equals(label))
  9. return label;
  10. else if (label == null || label.length() == 0)
  11. return projectName;
  12. else
  13. return projectName + ": " + label; //$NON-NLS-1$
  14. }

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

  1. /**
  2. * Return true if we have already ignored this <code>file</code> and that its modification
  3. * stamp is the same as when we processed it.
  4. *
  5. * @param file
  6. * @return
  7. */
  8. private boolean hasIgnored(IFile file) {
  9. Long cachedStamp = (Long) ignoredFilesCache.get(file);
  10. if (cachedStamp == null)
  11. return false;
  12. long stamp = WorkbenchResourceHelper.computeModificationStamp(file);
  13. return cachedStamp.longValue() == stamp;
  14. }

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

  1. public IResource getResource(Object object) {
  2. Resource resource = null;
  3. if (object != null && object instanceof EObject)
  4. resource = ((EObject) object).eResource();
  5. if (resource != null)
  6. return WorkbenchResourceHelper.getFile(resource);
  7. return null;
  8. }

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

  1. /**
  2. * Notify all editModels of the change.
  3. */
  4. private static void removedResource(Resource removedResource) {
  5. IProject proj = WorkbenchResourceHelper.getProject(removedResource);
  6. IModelProviderEvent event = new ModelProviderEvent(IModelProviderEvent.REMOVED_RESOURCE, null,proj);
  7. event.addResource(removedResource);
  8. notifyModelProviders(event);
  9. }

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

  1. /**
  2. * Method cacheLastNonRefreshFileStamps.
  3. *
  4. * @param inconsistentFiles
  5. */
  6. private void cacheLastNonRefreshFileStamps(List inconsistentFiles) {
  7. if (inconsistentFiles != null && !inconsistentFiles.isEmpty()) {
  8. Map map = getLastNonRefreshStateMap();
  9. IFile file = null;
  10. long stamp = 0;
  11. for (int i = 0; i < inconsistentFiles.size(); i++) {
  12. file = (IFile) inconsistentFiles.get(i);
  13. stamp = WorkbenchResourceHelper.computeModificationStamp(file);
  14. map.put(file, new Long(stamp));
  15. }
  16. }
  17. }

相关文章