本文整理汇总了Java中org.eclipse.core.runtime.IPath.isPrefixOf方法的典型用法代码示例。如果您正苦于以下问题:Java IPath.isPrefixOf方法的具体用法?Java IPath.isPrefixOf怎么用?Java IPath.isPrefixOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.core.runtime.IPath
的用法示例。
在下文中一共展示了IPath.isPrefixOf方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: childrenExistInClasspath
import org.eclipse.core.runtime.IPath; //导入方法依赖的package包/类
/**
* Return whether folderPath has children in the classpath
*
* @param project
* @param folderPath
* @param monitor
* @return
* @throws JavaModelException
*/
public static IResource childrenExistInClasspath(IProject project, String folderPath, IProgressMonitor monitor)
throws JavaModelException {
IJavaProject javaProject = JavaCore.create(project);
IClasspathEntry[] entries = javaProject.getRawClasspath();
IPath folder = project.getFolder(folderPath).getFullPath();
for (int i = 0; i < entries.length; i++) {
if (folder.isPrefixOf(entries[i].getPath())) {
IPath path = entries[i].getPath();
IResource resource = ResourceManager.getResource(path.toString());
return resource;
}
}
return null;
}
示例2: acceptFile
import org.eclipse.core.runtime.IPath; //导入方法依赖的package包/类
private boolean acceptFile(IFile in) {
if (!PreferenceManager.isGraphModelFile(in))
return false;
IProject project = in.getProject();
String[] folders = PreferenceManager.getAuthorizedFolderForGraphDefinition();
for (int i = 0; i < folders.length; i++) {
IPath base = project.getFullPath().append(folders[i]);
if (base.isPrefixOf(in.getFullPath())) {
return true;
}
}
return false;
}
示例3: acceptDestination
import org.eclipse.core.runtime.IPath; //导入方法依赖的package包/类
private boolean acceptDestination(IProject project,IPath target) {
String[] folders = PreferenceManager.getAuthorizedFolderForGraphDefinition();
for (int i = 0; i < folders.length; i++) {
IPath base = project.getFullPath().append(folders[i]);
if (base.isPrefixOf(target)) {
return true;
}
}
return false;
}
示例4: buildGeneratedAnnotationValue
import org.eclipse.core.runtime.IPath; //导入方法依赖的package包/类
public static IPath buildGeneratedAnnotationValue(IFile in) {
IPath ret = null;
if (!PreferenceManager.isGraphModelFile(in))
return null;
IProject project = in.getProject();
String[] folders = PreferenceManager.getAuthorizedFolderForGraphDefinition();
for (int i = 0; i < folders.length; i++) {
IPath base = project.getFullPath().append(folders[i]);
if (base.isPrefixOf(in.getFullPath())) {
ret = in.getFullPath().makeRelativeTo(project.getFullPath());
break;
}
}
return ret;
}
示例5: buildModelAnnotationValue
import org.eclipse.core.runtime.IPath; //导入方法依赖的package包/类
public static IPath buildModelAnnotationValue (IFile in) {
IPath ret = null;
if (!PreferenceManager.isGraphModelFile(in)) return null;
IProject project = in.getProject();
String[] folders = PreferenceManager.getAuthorizedFolderForGraphDefinition();
for (int i = 0; i < folders.length; i++) {
IPath base = project.getFullPath().append(folders[i]);
if (base.isPrefixOf(in.getFullPath())) {
ret = in.getFullPath().makeRelativeTo(base);
break;
}
}
return ret;
}
示例6: validatePage
import org.eclipse.core.runtime.IPath; //导入方法依赖的package包/类
public boolean validatePage() {
setErrorMessage(null);
if (!displayProjects)
return true;
if (createPackageButton != null)
createPackageButton.setEnabled(false);
if (fDestinationField != null) {
ITreeSelection sl = fDestinationField.getStructuredSelection();
if (sl.isEmpty()) {
setErrorMessage(MessageUtil.getString("choose_a_target_folder_for_the_graph"));
return false;
}
if (!(sl.getFirstElement() instanceof IFolder)) {
setErrorMessage(MessageUtil.getString("choose_a_target_folder_for_the_graph"));
return false;
}
if (sl.getFirstElement() instanceof IFolder) {
IFolder folder = (IFolder) sl.getFirstElement();
String[] folders = PreferenceManager.getDefaultAuthorizedFolderForGraphDefinition();
boolean found = false;
for (String f : folders) {
IFolder tmp = (IFolder) folder;
if (tmp == null)
return false;
IProject project = tmp.getProject();
IPath p = new Path(project.getFullPath().toString()).append(f);
IPath tmpPath = tmp.getFullPath();
if (p.isPrefixOf(tmpPath)) {
createPackageButton.setEnabled(true);
found = true;
}
}
if (!found) {
setErrorMessage(MessageUtil.getString("choose_a_target_folder_for_the_graph"));
return false;
}
}
}
if (this.provider != null) {
if (this.provider.getDefaultFileName() != null
&& ((nameField.getText() == null) || (nameField.getText().trim().length() == 0))) {
setErrorMessage(MessageUtil.getString("choose_a_valid_filename"));
return false;
}
String value = nameField.getText();
if (this.provider.getDefaultFileName() != null && !isValidFilename(value)) {
setErrorMessage(MessageUtil.getString("choose_a_valid_filename"));
return false;
}
}
return true;
}
示例7: isFolderMainResources
import org.eclipse.core.runtime.IPath; //导入方法依赖的package包/类
public static boolean isFolderMainResources(IProject project, IPath path) {
IPath sourcemainPath = project.getFullPath().append(Constant.SOURCE_MAIN_RESOURCES);
return sourcemainPath.isPrefixOf(path);
}
示例8: buildFiles
import org.eclipse.core.runtime.IPath; //导入方法依赖的package包/类
public static PgDatabase buildFiles(Collection<IFile> files, IProgressMonitor monitor,
List<FunctionBodyContainer> funcBodies) throws InterruptedException, IOException, CoreException {
SubMonitor mon = SubMonitor.convert(monitor, files.size());
Set<String> schemaDirnamesLoaded = new HashSet<>();
IPath schemasPath = new Path(WORK_DIR_NAMES.SCHEMA.name());
PgDatabase db = new PgDatabase(false);
db.setArguments(new PgDiffArguments());
for (IFile file : files) {
IPath filePath = file.getProjectRelativePath();
if (!"sql".equals(file.getFileExtension()) || !isInProject(filePath)) { //$NON-NLS-1$
// skip non-sql or non-project files
// still report work
mon.worked(1);
continue;
}
if (schemasPath.isPrefixOf(filePath)) {
IPath relSchemasPath = filePath.makeRelativeTo(schemasPath);
String schemaDirname;
boolean schemaDefSql = relSchemasPath.segmentCount() == 1;
if (schemaDefSql) {
// schema definition SQL-file
schemaDirname = relSchemasPath.removeFileExtension().lastSegment();
} else {
// schema-contained object
// preload its schema so that search_path parses normally
schemaDirname = relSchemasPath.segment(0);
}
if (!schemaDirnamesLoaded.add(schemaDirname)) {
// schema already loaded, skip
if (schemaDefSql) {
// report schema pre-built if the same schema was to be built normally as well
mon.worked(1);
}
continue;
} else if (!schemaDefSql) {
// pre-load schema for object's search path
// otherwise we're dealing with the schema file itself, allow it to load normally
// don't pass progress monitor since this file isn't in the original load-set
loadFile(file.getProject().getFile(schemasPath.append(schemaDirname + ".sql")), //$NON-NLS-1$
null, db, funcBodies, null);
}
}
loadFile(file, mon, db, funcBodies, null);
}
return db;
}
示例9: packageChanged
import org.eclipse.core.runtime.IPath; //导入方法依赖的package包/类
protected IStatus packageChanged() {
StatusInfo status = new StatusInfo();
IPackageFragmentRoot root = getPackageFragmentRoot();
IJavaProject project = root != null ? root.getJavaProject() : null;
String packName = getPackageText().getText();
if (packName.length() > 0) {
IStatus val = validatePackageName(packName, project);
if (val.getSeverity() == IStatus.ERROR) {
status.setError(Messages.format(NewWizardMessages.NewTypeWizardPage_error_InvalidPackageName, val.getMessage()));
return status;
} else if (val.getSeverity() == IStatus.WARNING) {
status.setWarning(Messages.format(NewWizardMessages.NewTypeWizardPage_warning_DiscouragedPackageName, val.getMessage()));
// continue
}
} else {
status.setWarning(NewWizardMessages.NewTypeWizardPage_warning_DefaultPackageDiscouraged);
}
if (project != null) {
if (project.exists() && packName.length() > 0) {
try {
IPath rootPath = root.getPath();
IPath outputPath = project.getOutputLocation();
if (rootPath.isPrefixOf(outputPath) && !rootPath.equals(outputPath)) {
// if the bin folder is inside of our root, don't allow
// to name a package
// like the bin folder
IPath packagePath = rootPath.append(packName.replace('.', '/'));
if (outputPath.isPrefixOf(packagePath)) {
status.setError(NewWizardMessages.NewTypeWizardPage_error_ClashOutputLocation);
return status;
}
}
} catch (JavaModelException e) {
JavaPlugin.log(e);
// let pass
}
}
fCurrPackage = root.getPackageFragment(packName);
IResource resource = fCurrPackage.getResource();
if (resource != null) {
if (resource.isVirtual()) {
status.setError(NewWizardMessages.NewTypeWizardPage_error_PackageIsVirtual);
return status;
}
if (!ResourcesPlugin.getWorkspace().validateFiltered(resource).isOK()) {
status.setError(NewWizardMessages.NewTypeWizardPage_error_PackageNameFiltered);
return status;
}
}
} else {
status.setError("");
}
return status;
}
示例10: isInFolder
import org.eclipse.core.runtime.IPath; //导入方法依赖的package包/类
/**
* Return whether the candidate child is on the parent folder
*
* @param parent
* @param candidateChild
* @return
*/
public static boolean isInFolder(IPath parent, IPath candidateChild) {
return parent.isPrefixOf(candidateChild);
}