本文整理汇总了Java中org.eclipse.core.runtime.IPath类的典型用法代码示例。如果您正苦于以下问题:Java IPath类的具体用法?Java IPath怎么用?Java IPath使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IPath类属于org.eclipse.core.runtime包,在下文中一共展示了IPath类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validate
import org.eclipse.core.runtime.IPath; //导入依赖的package包/类
public static boolean validate(String container) {
if (container != null) {
String[] names = StringUtils.split(container, "/");
IResource resource = wsRoot.findMember(new Path("/" + names[0]));
IPath loc = resource.getLocation();
File prjLoc = new File(loc.toString());
File[] res = prjLoc.listFiles();
HashMap<String, ArrayList<File>> fileGroups = new HashMap<String, ArrayList<File>>();
HashMap<String, Integer> groupCnt = new HashMap<String, Integer>();
for (File file : res) {
String extension = FilenameUtils.getExtension(file.getName());
ArrayList<File> list = fileGroups.get(extension);
int cnt = (groupCnt.get(extension) == null) ? 0 : groupCnt.get(extension).intValue();
if (list == null)
list = new ArrayList<File>();
list.add(file);
cnt++;
groupCnt.put(extension, new Integer(cnt));
fileGroups.put(extension, list);
}
return !validate(groupCnt);
}
return false;
}
示例2: validateLinkedResource
import org.eclipse.core.runtime.IPath; //导入依赖的package包/类
/**
* Checks whether the linked resource target is valid. Sets the error
* message accordingly and returns the status.
*
* @return IStatus validation result from the CreateLinkedResourceGroup
*/
protected IStatus validateLinkedResource() {
IPath containerPath = resourceGroup.getContainerFullPath();
IPath newFilePath = containerPath.append(resourceGroup.getResource());
IFile newFileHandle = createFileHandle(newFilePath);
IStatus status = linkedResourceGroup
.validateLinkLocation(newFileHandle);
if (status.getSeverity() == IStatus.ERROR) {
if (firstLinkCheck) {
setMessage(status.getMessage());
setErrorMessage(null);
} else {
setErrorMessage(status.getMessage());
}
} else if (status.getSeverity() == IStatus.WARNING) {
setMessage(status.getMessage(), WARNING);
setErrorMessage(null);
}
return status;
}
示例3: loadSchemaFromExternalFile
import org.eclipse.core.runtime.IPath; //导入依赖的package包/类
/**
**
* This methods loads schema from external schema file
*
* @param externalSchemaFilePath
* @param schemaType
* @return
*/
public List<GridRow> loadSchemaFromExternalFile(String externalSchemaFilePath,String schemaType) {
IPath filePath=new Path(externalSchemaFilePath);
IPath copyOfFilePath=filePath;
if (!filePath.isAbsolute()) {
filePath = ResourcesPlugin.getWorkspace().getRoot().getFile(filePath).getRawLocation();
}
if(filePath!=null && filePath.toFile().exists()){
GridRowLoader gridRowLoader=new GridRowLoader(schemaType, filePath.toFile());
return gridRowLoader.importGridRowsFromXML();
}else{
MessageBox messageBox=new MessageBox(Display.getCurrent().getActiveShell(), SWT.ICON_ERROR);
messageBox.setMessage(Messages.FAILED_TO_IMPORT_SCHEMA_FILE+"\n"+copyOfFilePath.toString());
messageBox.setText(Messages.ERROR);
messageBox.open();
}
return null;
}
示例4: generateTestImplementation
import org.eclipse.core.runtime.IPath; //导入依赖的package包/类
/**
* Generate a test implementation if it does not exist
*
* @param implementationFolder
* @param implementationFragmentRoot
* @param targetPkg
* @param interfaceCompUnit
* @param monitor
* @throws CoreException
*/
public static IFile generateTestImplementation(TestResourceGeneration provider, IProgressMonitor monitor)
throws Exception {
IFile ifile = provider.toIFile();
if (ifile.exists()) {
JDTManager.rename(ifile, monitor);
ifile.delete(true, monitor);
}
if (ifile.exists())
return null;
NewExecutionContextClassWizardPageRunner execRunner = new NewExecutionContextClassWizardPageRunner(provider,
monitor);
Display.getDefault().syncExec(execRunner);
IPath path = execRunner.getType().getPath();
IFile createdFile = (IFile) ResourceManager.getResource(path.toString());
return createdFile;
}
示例5: createFromPath
import org.eclipse.core.runtime.IPath; //导入依赖的package包/类
/**
* Creates a module specifier proposal from a given path and type
*
* @param path
* The path of the proposal
* @param moduleType
* The type of the proposal
* @return The proposal
*/
static ModuleSpecifierProposal createFromPath(IPath path, ModuleProposalType moduleType) {
String content, label;
if (moduleType == ModuleProposalType.FOLDER) {
content = path.removeFileExtension().addTrailingSeparator().toString();
} else {
content = path.removeFileExtension().toString();
}
if (moduleType == ModuleProposalType.FOLDER) {
label = path.addTrailingSeparator().toString();
} else {
label = path.toString();
}
return new ModuleSpecifierProposal(content, label, moduleType);
}
示例6: findPathInGeneratedAnnotation
import org.eclipse.core.runtime.IPath; //导入依赖的package包/类
/**
* @param project
* @param itype
* @return
* @throws JavaModelException
*/
private static IPath findPathInGeneratedAnnotation(IProject project, IType itype) throws JavaModelException {
ICompilationUnit cu = itype.getCompilationUnit();
List<IAnnotationBinding> annotations = resolveAnnotation(cu, Generated.class).getAnnotations();
if ((annotations != null) && (annotations.size() > 0)) {
IAnnotationBinding ab = annotations.get(0);
IMemberValuePairBinding[] attributes = ab.getAllMemberValuePairs();
for (int i = 0; i < attributes.length; i++) {
IMemberValuePairBinding attribut = attributes[i];
if (attribut.getName().equalsIgnoreCase("value")) {
Object[] o = (Object[]) attribut.getValue();
if (o != null && o.length > 0 && String.valueOf(o[0]).trim().length() > 0) {
try {
IPath p = ResourceManager.find(project, String.valueOf(o[0]).trim());
return p;
} catch (Exception e) {
ResourceManager.logException(e);
return null;
}
}
}
}
}
return null;
}
示例7: openModuleSpecifierDialog
import org.eclipse.core.runtime.IPath; //导入依赖的package包/类
/**
* Open the dialog to select a module specifier
*
* @param shell
* The Shell to open the dialog in
*/
public void openModuleSpecifierDialog(Shell shell) {
ModuleSpecifierSelectionDialog dialog = new ModuleSpecifierSelectionDialog(shell,
model.getProject().append(model.getSourceFolder()));
if (!model.getModuleSpecifier().isEmpty()) {
String initialSelectionSpecifier = model.getModuleSpecifier();
dialog.setInitialSelection(initialSelectionSpecifier);
}
dialog.open();
Object result = dialog.getFirstResult();
if (result instanceof String) {
IPath specifierPath = new Path((String) result);
model.setModuleSpecifier(specifierPath.removeFileExtension().toString());
}
}
示例8: get
import org.eclipse.core.runtime.IPath; //导入依赖的package包/类
public static TestResourceGeneration get (IFile file) throws CoreException, FileNotFoundException {
String targetFolder = GraphWalkerContextManager.getTargetFolderForTestImplementation(file);
IPath pkgFragmentRootPath = file.getProject().getFullPath().append(new Path(targetFolder));
IPackageFragmentRoot implementationFragmentRoot = JDTManager.getPackageFragmentRoot(file.getProject(), pkgFragmentRootPath);
String classname = file.getName().split("\\.")[0];
classname = classname + PreferenceManager.suffixForTestImplementation(implementationFragmentRoot.getJavaProject().getProject().getName()) + ".java";
ClassExtension ce = PreferenceManager.getDefaultClassExtension(file);
IPath p = ResourceManager.getPathWithinPackageFragment(file).removeLastSegments(1);
p = implementationFragmentRoot.getPath().append(p);
ResourceContext context = new ResourceContext(p, classname, file, true, false, false, ce);
TestResourceGeneration trg = new TestResourceGeneration(context);
return trg;
}
示例9: getConflictingContainerNameFor
import org.eclipse.core.runtime.IPath; //导入依赖的package包/类
/**
* Returns the name of a container with a location that encompasses targetDirectory. Returns null if there is no
* conflict.
*
* @param targetDirectory
* the path of the directory to check.
* @return the conflicting container name or <code>null</code>
*/
private String getConflictingContainerNameFor(String targetDirectory) {
IPath rootPath = ResourcesPlugin.getWorkspace().getRoot().getLocation();
IPath testPath = new Path(targetDirectory);
// cannot export into workspace root
if (testPath.equals(rootPath))
return rootPath.lastSegment();
// Are they the same?
if (testPath.matchingFirstSegments(rootPath) == rootPath.segmentCount()) {
String firstSegment = testPath.removeFirstSegments(rootPath.segmentCount()).segment(0);
if (!Character.isLetterOrDigit(firstSegment.charAt(0)))
return firstSegment;
}
return null;
}
示例10: getLogicalSystemDefinition
import org.eclipse.core.runtime.IPath; //导入依赖的package包/类
public LogicalSystemNode getLogicalSystemDefinition(String name, String containerName) {
LogicalSystemNode ret = null;
if (containerName != null) {
String[] names = StringUtils.split(containerName, "/");
IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
IResource resource = wsRoot.findMember(new Path("/" + names[0]));
IPath loc = resource.getLocation();
File file = new File(loc.toOSString() + File.separator + name + ".lsys");
try {
ret = ParseUtil.getLogicalSystemNodeFromText(FileUtils.readFileToString(file));
} catch (IOException e) {
EclipseUtil.writeStactTraceToConsole(e);
}
}
return ret;
}
示例11: handleSyntaxException
import org.eclipse.core.runtime.IPath; //导入依赖的package包/类
private void handleSyntaxException(IFile in) {
ParserContextProperties props = new ParserContextProperties();
IPath buildPoliciesPath=null;
try {
buildPoliciesPath = ResourceManager.getBuildPoliciesPathForGraphModel(in);
} catch (FileNotFoundException e) {
ResourceManager.logException(e);
}
props.setProperty(PathGeneratorConfigurationException.GRAPHMODELPATH,in.getFullPath().toString());
props.setProperty(PathGeneratorConfigurationException.BUILDPOLICIESPATH,buildPoliciesPath.toString());
Location location = Location.NULL_LOCATION;
MarkerManager.addMarker(in, this,
new ParserException(
location,
new GraphModelSyntaxException(location, "Syntax Error in graph model", props)),
IMarker.SEVERITY_ERROR);
}
示例12: isMarkerChangeForThisEditor
import org.eclipse.core.runtime.IPath; //导入依赖的package包/类
private boolean isMarkerChangeForThisEditor(IResourceChangeEvent event) {
IResource resource = ResourceUtil.getResource(getEditorInput());
if (resource == null) {
return false;
}
IPath path = resource.getFullPath();
if (path == null) {
return false;
}
IResourceDelta eventDelta = event.getDelta();
if (eventDelta == null) {
return false;
}
IResourceDelta delta = eventDelta.findMember(path);
if (delta == null) {
return false;
}
boolean isMarkerChangeForThisResource = (delta.getFlags() & IResourceDelta.MARKERS) != 0;
return isMarkerChangeForThisResource;
}
示例13: validatePage
import org.eclipse.core.runtime.IPath; //导入依赖的package包/类
protected boolean validatePage() {
boolean returnCode= super.validatePage() && validateFilename();
if(returnCode){
IPath iPath=new Path(getContainerFullPath()+JOBS_FOLDER_NAME);
IFolder folder=ResourcesPlugin.getWorkspace().getRoot().getFolder(iPath);
if(!StringUtils.endsWithIgnoreCase(getFileName(), Constants.JOB_EXTENSION)){
IFile newFile= folder.getFile(getFileName()+Constants.JOB_EXTENSION);
if(newFile.exists()){
setErrorMessage("'"+newFile.getName()+"'"+Constants.ALREADY_EXISTS);
return false;
}
}
}
return returnCode;
}
示例14: save
import org.eclipse.core.runtime.IPath; //导入依赖的package包/类
/**
* Save the AST int he Compilation Unit
*
* @param testInterface
* @param rewrite
* @throws CoreException
*/
public static void save(CompilationUnit unit, ASTRewrite rewrite) throws CoreException {
ITextFileBufferManager bufferManager = FileBuffers.getTextFileBufferManager();
IPath path = unit.getJavaElement().getPath();
try {
bufferManager.connect(path, null);
ITextFileBuffer textFileBuffer = bufferManager.getTextFileBuffer(path);
IDocument document = textFileBuffer.getDocument();
TextEdit edit = rewrite.rewriteAST(document, null);
edit.apply(document);
textFileBuffer.commit(null /* ProgressMonitor */, true /* Overwrite */);
} catch (Exception e) {
ResourceManager.logException(e);
} finally {
// disconnect the path
bufferManager.disconnect(path, null);
}
}
示例15: createClasspathEntries
import org.eclipse.core.runtime.IPath; //导入依赖的package包/类
@Override
public List<IClasspathEntry> createClasspathEntries()
{
IPath srcJar = null;
if( underlyingResource.getFileExtension().equals("jar") )
{
String name = underlyingResource.getName();
IFile srcJarFile = underlyingResource.getProject().getFile(
"lib-src/" + name.substring(0, name.length() - 4) + "-sources.jar");
if( srcJarFile.exists() )
{
srcJar = srcJarFile.getFullPath();
}
}
return Arrays.asList(JavaCore.newLibraryEntry(underlyingResource.getFullPath(), srcJar, null));
}