• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Resources类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: checkInitialConditions

import org.eclipse.jdt.internal.corext.util.Resources; //导入依赖的package包/类
@Override
public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException {
  pm.beginTask("", 1); // $NON-NLS-1$
  try {
    RefactoringStatus result = new RefactoringStatus();
    result.merge(
        RefactoringStatus.create(
            Resources.checkInSync(ReorgUtils.getNotNulls(fMovePolicy.getResources()))));
    IResource[] javaResources = ReorgUtils.getResources(fMovePolicy.getJavaElements());
    result.merge(
        RefactoringStatus.create(Resources.checkInSync(ReorgUtils.getNotNulls(javaResources))));
    return result;
  } finally {
    pm.done();
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:JavaMoveProcessor.java


示例2: applyEdit

import org.eclipse.jdt.internal.corext.util.Resources; //导入依赖的package包/类
private static void applyEdit(ICompilationUnit cu, TextEdit edit, boolean save, IProgressMonitor monitor)
    throws CoreException, ValidateEditException {
  IFile file = (IFile) cu.getResource();
  if (!save || !file.exists()) {
    cu.applyTextEdit(edit, monitor);
  } else {
    if (monitor == null) {
      monitor = new NullProgressMonitor();
    }
    monitor.beginTask(CorextMessages.JavaModelUtil_applyedit_operation, 2);
    try {
      IStatus status = Resources.makeCommittable(file, null);
      if (!status.isOK()) {
        throw new ValidateEditException(status);
      }

      cu.applyTextEdit(edit, SubMonitor.convert(monitor, 1));

      cu.save(SubMonitor.convert(monitor, 1), true);
    } finally {
      monitor.done();
    }
  }
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:25,代码来源:TypeCreator.java


示例3: validateEdit

import org.eclipse.jdt.internal.corext.util.Resources; //导入依赖的package包/类
public static RefactoringStatus validateEdit(ICompilationUnit unit, Object context) {
	IResource resource= unit.getPrimary().getResource();
	RefactoringStatus result= new RefactoringStatus();
	if (resource == null)
		return result;
	IStatus status= Resources.checkInSync(resource);
	if (!status.isOK())
		result.merge(RefactoringStatus.create(status));
	status= Resources.makeCommittable(resource, context);
	if (!status.isOK()) {
		result.merge(RefactoringStatus.create(status));
		if (!result.hasFatalError()) {
			result.addFatalError(RefactoringCoreMessages.Checks_validateEdit);
		}
	}
	return result;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:18,代码来源:Checks.java


示例4: checkInitialConditions

import org.eclipse.jdt.internal.corext.util.Resources; //导入依赖的package包/类
@Override
public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException {
	Assert.isNotNull(fDeleteQueries);//must be set before checking activation
	RefactoringStatus result= new RefactoringStatus();
	result.merge(RefactoringStatus.create(Resources.checkInSync(ReorgUtils.getNotLinked(fResources))));
	IResource[] javaResources= ReorgUtils.getResources(fJavaElements);
	result.merge(RefactoringStatus.create(Resources.checkInSync(ReorgUtils.getNotNulls(javaResources))));
	for (int i= 0; i < fJavaElements.length; i++) {
		IJavaElement element= fJavaElements[i];
		if (element instanceof IType && ((IType)element).isAnonymous()) {
			// work around for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=44450
			// result.addFatalError("Currently, there isn't any support to delete an anonymous type.");
		}
	}
	return result;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:17,代码来源:JavaDeleteProcessor.java


示例5: determineOperation

import org.eclipse.jdt.internal.corext.util.Resources; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected int determineOperation(Object target, int operation, TransferData transferType, int operations) {

	boolean isPackageFragment= target instanceof IPackageFragment;
	boolean isJavaProject= target instanceof IJavaProject;
	boolean isPackageFragmentRoot= target instanceof IPackageFragmentRoot;
	boolean isContainer= target instanceof IContainer;

	if (!(isPackageFragment || isJavaProject || isPackageFragmentRoot || isContainer))
		return DND.DROP_NONE;

	if (isContainer) {
		IContainer container= (IContainer)target;
		if (container.isAccessible() && !Resources.isReadOnly(container))
			return DND.DROP_COPY;
	} else {
		IJavaElement element= (IJavaElement)target;
		if (!element.isReadOnly())
			return DND.DROP_COPY;
	}

	return DND.DROP_NONE;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:27,代码来源:FileTransferDropAdapter.java


示例6: validateModifiesFiles

import org.eclipse.jdt.internal.corext.util.Resources; //导入依赖的package包/类
public static RefactoringStatus validateModifiesFiles(IFile[] filesToModify, Object context) {
  RefactoringStatus result = new RefactoringStatus();
  IStatus status = Resources.checkInSync(filesToModify);
  if (!status.isOK()) result.merge(RefactoringStatus.create(status));
  status = Resources.makeCommittable(filesToModify, context);
  if (!status.isOK()) {
    result.merge(RefactoringStatus.create(status));
    if (!result.hasFatalError()) {
      result.addFatalError(RefactoringCoreMessages.Checks_validateEdit);
    }
  }
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:14,代码来源:Checks.java


示例7: validateEdit

import org.eclipse.jdt.internal.corext.util.Resources; //导入依赖的package包/类
public static RefactoringStatus validateEdit(ICompilationUnit unit, Object context) {
  IResource resource = unit.getPrimary().getResource();
  RefactoringStatus result = new RefactoringStatus();
  if (resource == null) return result;
  IStatus status = Resources.checkInSync(resource);
  if (!status.isOK()) result.merge(RefactoringStatus.create(status));
  status = Resources.makeCommittable(resource, context);
  if (!status.isOK()) {
    result.merge(RefactoringStatus.create(status));
    if (!result.hasFatalError()) {
      result.addFatalError(RefactoringCoreMessages.Checks_validateEdit);
    }
  }
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:16,代码来源:Checks.java


示例8: hasReadOnlyResourcesAndSubResources

import org.eclipse.jdt.internal.corext.util.Resources; //导入依赖的package包/类
private static boolean hasReadOnlyResourcesAndSubResources(IResource resource)
    throws CoreException {
  if (resource.isLinked()) // we don't want to count these because we never actually delete linked
    // resources
    return false;
  if (Resources.isReadOnly(resource)) return true;
  if (resource instanceof IContainer)
    return hasReadOnlyResourcesAndSubResources(((IContainer) resource).members());
  return false;
}
 
开发者ID:eclipse,项目名称:che,代码行数:11,代码来源:ReadOnlyResourceFinder.java


示例9: validateModifiesFiles

import org.eclipse.jdt.internal.corext.util.Resources; //导入依赖的package包/类
public static RefactoringStatus validateModifiesFiles(IFile[] filesToModify, Object context) {
	RefactoringStatus result= new RefactoringStatus();
	IStatus status= Resources.checkInSync(filesToModify);
	if (!status.isOK())
		result.merge(RefactoringStatus.create(status));
	status= Resources.makeCommittable(filesToModify, context);
	if (!status.isOK()) {
		result.merge(RefactoringStatus.create(status));
		if (!result.hasFatalError()) {
			result.addFatalError(RefactoringCoreMessages.Checks_validateEdit);
		}
	}
	return result;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:15,代码来源:Checks.java


示例10: checkInitialConditions

import org.eclipse.jdt.internal.corext.util.Resources; //导入依赖的package包/类
@Override
public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException {
	RefactoringStatus result= new RefactoringStatus();
	result.merge(RefactoringStatus.create(Resources.checkInSync(ReorgUtils.getNotNulls(fCopyPolicy.getResources()))));
	IResource[] javaResources= ReorgUtils.getResources(fCopyPolicy.getJavaElements());
	result.merge(RefactoringStatus.create(Resources.checkInSync(ReorgUtils.getNotNulls(javaResources))));
	return result;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:9,代码来源:JavaCopyProcessor.java


示例11: checkInitialConditions

import org.eclipse.jdt.internal.corext.util.Resources; //导入依赖的package包/类
@Override
public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException {
	pm.beginTask("", 1); //$NON-NLS-1$
	try {
		RefactoringStatus result= new RefactoringStatus();
		result.merge(RefactoringStatus.create(Resources.checkInSync(ReorgUtils.getNotNulls(fMovePolicy.getResources()))));
		IResource[] javaResources= ReorgUtils.getResources(fMovePolicy.getJavaElements());
		result.merge(RefactoringStatus.create(Resources.checkInSync(ReorgUtils.getNotNulls(javaResources))));
		return result;
	} finally {
		pm.done();
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:14,代码来源:JavaMoveProcessor.java


示例12: hasReadOnlyResourcesAndSubResources

import org.eclipse.jdt.internal.corext.util.Resources; //导入依赖的package包/类
private static boolean hasReadOnlyResourcesAndSubResources(IResource resource) throws CoreException {
	if (resource.isLinked()) //we don't want to count these because we never actually delete linked resources
		return false;
	if (Resources.isReadOnly(resource))
		return true;
	if (resource instanceof IContainer)
		return hasReadOnlyResourcesAndSubResources(((IContainer)resource).members());
	return false;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:10,代码来源:ReadOnlyResourceFinder.java


示例13: performValidateEdit

import org.eclipse.jdt.internal.corext.util.Resources; //导入依赖的package包/类
private boolean performValidateEdit(ICompilationUnit unit) {
	IStatus status= Resources.makeCommittable(unit.getResource(), JavaPlugin.getActiveWorkbenchShell());
	if (!status.isOK()) {
		String label= CorrectionMessages.CUCorrectionProposal_error_title;
		String message= CorrectionMessages.CUCorrectionProposal_error_message;
		ErrorDialog.openError(JavaPlugin.getActiveWorkbenchShell(), label, message, status);
		return false;
	}
	return true;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:11,代码来源:CUCorrectionProposal.java


示例14: checkInSync

import org.eclipse.jdt.internal.corext.util.Resources; //导入依赖的package包/类
private static boolean checkInSync(IResource[] resources, Shell parent, String title) {
	IStatus status= Resources.checkInSync(resources);
	if (status.isOK())
		return true;
	ErrorDialog.openError(parent, title,
		JavaUIMessages.ElementValidator_cannotPerform,
		status);
	return false;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:10,代码来源:ElementValidator.java


示例15: checkValidateEdit

import org.eclipse.jdt.internal.corext.util.Resources; //导入依赖的package包/类
private static boolean checkValidateEdit(IResource[] resources, Shell parent, String title) {
	IStatus status= Resources.makeCommittable(resources, parent);
	if (!status.isOK()) {
		ErrorDialog.openError(parent, title,
			JavaUIMessages.ElementValidator_cannotPerform,
			status);
		return false;
	}
	return true;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:11,代码来源:ElementValidator.java


示例16: isReadOnly

import org.eclipse.jdt.internal.corext.util.Resources; //导入依赖的package包/类
private boolean isReadOnly() {
	return Resources.isReadOnly(fProject.getResource());
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:4,代码来源:RenameJavaProjectProcessor.java


示例17: buildJavaToClassMap

import org.eclipse.jdt.internal.corext.util.Resources; //导入依赖的package包/类
private Map<String, ArrayList<IResource>> buildJavaToClassMap(IContainer container, IProgressMonitor monitor) throws CoreException {
	if (container == null || !container.isAccessible())
		return new HashMap<String, ArrayList<IResource>>(0);
	/*
	 * XXX: Bug 6584: Need a way to get class files for a java file (or CU)
	 */
	IClassFileReader cfReader= null;
	IResource[] members= container.members();
	Map<String, ArrayList<IResource>> map= new HashMap<String, ArrayList<IResource>>(members.length);
	for (int i= 0;  i < members.length; i++) {
		if (isClassFile(members[i])) {
			IFile classFile= (IFile)members[i];
			URI location= classFile.getLocationURI();
			if (location != null) {
				InputStream contents= null;
				try {
					contents= EFS.getStore(location).openInputStream(EFS.NONE, monitor);
					cfReader= ToolFactory.createDefaultClassFileReader(contents, IClassFileReader.CLASSFILE_ATTRIBUTES);
				} finally {
					try {
						if (contents != null)
							contents.close();
					} catch (IOException e) {
						throw new CoreException(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.ERROR,
							Messages.format(JarPackagerMessages.JarFileExportOperation_errorCannotCloseConnection, BasicElementLabels.getURLPart(Resources.getLocationString(classFile))),
							e));
					}
				}
				if (cfReader != null) {
					ISourceAttribute sourceAttribute= cfReader.getSourceFileAttribute();
					if (sourceAttribute == null) {
						/*
						 * Can't fully build the map because one or more
						 * class file does not contain the name of its
						 * source file.
						 */
						addWarning(Messages.format(
							JarPackagerMessages.JarFileExportOperation_classFileWithoutSourceFileAttribute,
							BasicElementLabels.getURLPart(Resources.getLocationString(classFile))), null);
						return null;
					}
					String javaName= new String(sourceAttribute.getSourceFileName());
					ArrayList<IResource> classFiles= map.get(javaName);
					if (classFiles == null) {
						classFiles= new ArrayList<IResource>(3);
						map.put(javaName, classFiles);
					}
					classFiles.add(classFile);
				}
			}
		}
	}
	return map;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:55,代码来源:JarFileExportOperation.java


示例18: getResourceLocations

import org.eclipse.jdt.internal.corext.util.Resources; //导入依赖的package包/类
private static String[] getResourceLocations(List<IResource> resources) {
	return Resources.getLocationOSStrings(resources.toArray(new IResource[resources.size()]));
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:4,代码来源:FileTransferDragAdapter.java


示例19: run

import org.eclipse.jdt.internal.corext.util.Resources; //导入依赖的package包/类
@Override
public void run(ISelection selection) {

	Shell shell= getShell();

	final IMember input= getEditionElement(selection);
	if (input == null) {
		MessageDialog.openInformation(shell, CompareMessages.ReplaceFromHistory_title, CompareMessages.ReplaceFromHistory_invalidSelectionMessage);
		return;
	}

	final IFile file= getFile(input);
	if (file == null) {
		showError();
		return;
	}

	IStatus status= Resources.makeCommittable(file, shell);
	if (!status.isOK()) {
		return;
	}

	if (fPrevious) {
		String errorTitle= CompareMessages.ReplaceFromHistory_title;
		String errorMessage= CompareMessages.ReplaceFromHistory_internalErrorMessage;
		try {
			ITypedElement ti = ElementLocalHistoryPageSource.getPreviousEdition(file, input);
			if (ti == null) {
				MessageDialog.openInformation(shell, errorTitle, CompareMessages.ReplaceFromHistory_parsingErrorMessage);
				return;
			}
			replace(input, file, ti);
		} catch (TeamException e) {
			ExceptionHandler.handle(e, shell, errorTitle, errorMessage);
		}
	} else {
		JavaElementHistoryPageSource pageSource = JavaElementHistoryPageSource.getInstance();
		CompareConfiguration cc = new CompareConfiguration();
		cc.setLeftEditable(false);
		cc.setRightEditable(false);
		HistoryPageCompareEditorInput ci = new HistoryPageCompareEditorInput(cc, pageSource, input) {
			@Override
			protected void performReplace(Object selectedElement) {
				if (selectedElement instanceof ITypedElement) {
					JavaReplaceWithEditionActionImpl.this.replace(input, file, (ITypedElement)selectedElement);
				}
			}
		};
		ci.setReplace(true);
		ci.setTitle(CompareMessages.JavaReplaceWithEditionActionImpl_0);
		ci.setHelpContextId(IJavaHelpContextIds.REPLACE_ELEMENT_WITH_HISTORY_DIALOG);
		CompareUI.openCompareDialog(ci);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:55,代码来源:JavaReplaceWithEditionActionImpl.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DestinationMapEntry类代码示例发布时间:2022-05-22
下一篇:
Java JvmPauseMonitor类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap