本文整理匯總了Java中org.eclipse.core.resources.IWorkspaceRoot.findMember方法的典型用法代碼示例。如果您正苦於以下問題:Java IWorkspaceRoot.findMember方法的具體用法?Java IWorkspaceRoot.findMember怎麽用?Java IWorkspaceRoot.findMember使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.core.resources.IWorkspaceRoot
的用法示例。
在下文中一共展示了IWorkspaceRoot.findMember方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getResourcesWithExtension
import org.eclipse.core.resources.IWorkspaceRoot; //導入方法依賴的package包/類
public ArrayList<String> getResourcesWithExtension(String ext, String containerName) {
ArrayList<String> ret = new ArrayList<String>();
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 prjLoc = new File(loc.toString());
Collection<File> res = FileUtils.listFiles(prjLoc, FileFilterUtils.suffixFileFilter(ext, IOCase.INSENSITIVE), TrueFileFilter.INSTANCE);
for (File file : res)
ret.add(file.getAbsolutePath());
}
return ret;
}
示例2: getFinalAssemblyDefinition
import org.eclipse.core.resources.IWorkspaceRoot; //導入方法依賴的package包/類
public CompositeNode getFinalAssemblyDefinition(String name, String containerName) {
CompositeNode 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 + ".fassmbl");
try {
ret = ParseUtil.getFinalAssemblyNodeFromText(FileUtils.readFileToString(file));
} catch (IOException e) {
EclipseUtil.writeStactTraceToConsole(e);
}
}
return ret;
}
示例3: getLogicalSystemDefinition
import org.eclipse.core.resources.IWorkspaceRoot; //導入方法依賴的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;
}
示例4: getComponentImplementationDefinition
import org.eclipse.core.resources.IWorkspaceRoot; //導入方法依賴的package包/類
public ComponentImplementationNode getComponentImplementationDefinition(String name, String containerName) {
ComponentImplementationNode 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 + ".cimpl");
try {
ret = ParseUtil.getComponentImplementationNodeFromText(FileUtils.readFileToString(file));
} catch (IOException e) {
EclipseUtil.writeStactTraceToConsole(e);
}
}
return ret;
}
示例5: createFileDeleteIfExists
import org.eclipse.core.resources.IWorkspaceRoot; //導入方法依賴的package包/類
/**
* Create a file in a folder with the specified name and content
*
* @param fullpath
* @param filename
* @param content
* @throws CoreException
* @throws InterruptedException
*/
public static IFile createFileDeleteIfExists(String fullpath, String filename, String content,
IProgressMonitor monitor) throws CoreException, InterruptedException {
SubMonitor subMonitor = SubMonitor.convert(monitor, 100);
subMonitor.setTaskName("Create file delete if it exists " + fullpath);
IFile newFile;
try {
IWorkspaceRoot wroot = ResourcesPlugin.getWorkspace().getRoot();
IContainer container = (IContainer) wroot.findMember(new Path(fullpath));
newFile = container.getFile(new Path(filename));
if (newFile.exists()) {
JDTManager.rename(newFile, new NullProgressMonitor());
newFile.delete(true, new NullProgressMonitor());
}
subMonitor.split(30);
byte[] source = content.getBytes(Charset.forName("UTF-8"));
newFile.create(new ByteArrayInputStream(source), true, new NullProgressMonitor());
subMonitor.split(70);
} finally {
subMonitor.done();
}
return newFile;
}
示例6: doFinish
import org.eclipse.core.resources.IWorkspaceRoot; //導入方法依賴的package包/類
private void doFinish(IPath containerPath, String[] path, IProgressMonitor monitor) throws CoreException {
monitor.beginTask("Creating package " + String.join(".", path), path.length);
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IResource resource = root.findMember(containerPath);
if (!resource.exists() || !(resource instanceof IContainer)) {
throwCoreException("Container \"" + containerPath + "\" does not exist.");
}
IContainer container = (IContainer) resource;
for(int i = 0; i < path.length; i++) {
Path p = new Path(path[i]);
final IFolder folder = container.getFolder(p);
if(!folder.exists())
folder.create(true, false, monitor);
container = container.getFolder(p);
monitor.worked(1);
}
}
示例7: isSourcePath
import org.eclipse.core.resources.IWorkspaceRoot; //導入方法依賴的package包/類
private boolean isSourcePath(String path) throws JavaModelException, BackingStoreException {
Path pp = new File(instance.getWorkspaceRoot().toString() + File.separator + path).toPath();
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
for (IClasspathEntry entry : project.getRawClasspath()) {
if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
IResource res = root.findMember(entry.getPath());
if (res != null) {
String file = res.getLocation().toOSString();
if (!file.isEmpty() && pp.startsWith(file)) {
IPath[] inclusionPatterns = entry.getInclusionPatterns();
if (!matchPatterns(pp, entry.getExclusionPatterns()) && (inclusionPatterns == null
|| inclusionPatterns.length == 0 || matchPatterns(pp, inclusionPatterns))) {
return true;
}
}
}
}
}
return false;
}
示例8: getLayoutFile
import org.eclipse.core.resources.IWorkspaceRoot; //導入方法依賴的package包/類
/**
* Returns the file object of the feature model
* @param featureModel
* @return
*/
private static File getLayoutFile(DwFeatureModelWrapped featureModel){
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot workspaceRoot = workspace.getRoot();
IFile file = workspaceRoot.getFile(new Path(featureModel.getModel().eResource().getURI().toPlatformString(true)));
IPath path = ((IPath)file.getFullPath().clone()).removeFileExtension().addFileExtension("hylayout");
IResource resourceInRuntimeWorkspace = workspaceRoot.findMember(path.toString());
if(resourceInRuntimeWorkspace != null){
return new File(resourceInRuntimeWorkspace.getLocationURI());
}else{
return null;
}
}
示例9: isValid
import org.eclipse.core.resources.IWorkspaceRoot; //導入方法依賴的package包/類
/**
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#isValid(org.eclipse.debug.core.ILaunchConfiguration)
*/
@Override
public boolean isValid(ILaunchConfiguration launchConfig) {
setMessage(null);
setErrorMessage(null);
final String uriStr;
try {
uriStr = launchConfig.getAttribute(getResourceRunConfigKey(), "");
} catch (CoreException e1) {
setErrorMessage("cannot read resource URI from launch configuration");
return false;
}
if (uriStr.trim().isEmpty()) {
setErrorMessage("launch configuration must specify a " + getResourceLabel().toLowerCase());
return false;
}
final URI resourceUri = URI.createURI(uriStr, true);
final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
final IResource resource = root.findMember(resourceUri.toPlatformString(true));
if (resource == null) {
setErrorMessage("unable to locate resource in workspace: " + resourceUri.toPlatformString(true));
return false;
}
if (!checkResourceIsInAvailableProject(resourceUri)) {
return false;
}
if (!checkResourceIsOfAcceptedType(resource)) {
return false;
}
if (!checkSubclassSpecificConstraints(launchConfig, resource, resourceUri)) {
return false;
}
return true;
}
示例10: doFinish
import org.eclipse.core.resources.IWorkspaceRoot; //導入方法依賴的package包/類
private void doFinish(
String targetProjectPath,
String analysisProjectName,
IProgressMonitor monitor)
throws CoreException, IOException {
monitor.beginTask("Creating " +analysisProjectName, 2);
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
ProjectGenerator projectGen = new ProjectGenerator();
IJavaProject sourceProject = projectGen.createProject(wizardInput);
IResource resourceTarget = root.findMember(new Path(targetProjectPath));
IJavaProject targetProject = JavaCore.create(resourceTarget.getProject());
GlobalSettings.put("Target_Path",resourceTarget.getLocation().toOSString()+ File.separator + targetProject.getOutputLocation().lastSegment());
GlobalSettings.put("AnalysisProject", sourceProject.getProject().getName());
GlobalSettings.put("TargetProject", targetProject.getProject().getName());
ProjectPreferences projPref = new ProjectPreferences();
projPref.createPreferences();
AddRemoveVisuFlowNatureHandler addNature = new AddRemoveVisuFlowNatureHandler();
try {
if(!sourceProject.getProject().isNatureEnabled("JimpleBuilder.VisuFlowNature"))
addNature.toggleNature(sourceProject.getProject());
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ServiceUtil.getService(DataModel.class).triggerProjectRebuild();
monitor.worked(1);
monitor.setTaskName("Opening file for editing...");
getShell().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
}
});
monitor.worked(1);
}
示例11: run
import org.eclipse.core.resources.IWorkspaceRoot; //導入方法依賴的package包/類
public void run(IMarker marker) {
try {
String location = (String) marker.getAttribute("file");
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IFile file = (IFile) root.findMember(location.substring(1));
if (DiffUtils.applyDiffToFile(file, diff)) {
marker.delete();
}
} catch (CoreException ex) {
System.out.println("Marker resolution failed.");
ex.printStackTrace();
}
}
示例12: getProjectView
import org.eclipse.core.resources.IWorkspaceRoot; //導入方法依賴的package包/類
/**
* Convert an Eclipse JDT project into an IntelliJ project view
*/
public static ProjectView getProjectView(IProject project)
throws BackingStoreException, JavaModelException {
com.google.devtools.bazel.e4b.projectviews.Builder builder = ProjectView.builder();
IScopeContext projectScope = new ProjectScope(project);
Preferences projectNode = projectScope.getNode(Activator.PLUGIN_ID);
for (String s : projectNode.keys()) {
if (s.startsWith("buildArgs")) {
builder.addBuildFlag(projectNode.get(s, ""));
} else if (s.startsWith("target")) {
builder.addTarget(projectNode.get(s, ""));
}
}
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
for (IClasspathEntry entry : ((IJavaProject) project).getRawClasspath()) {
switch (entry.getEntryKind()) {
case IClasspathEntry.CPE_SOURCE:
IResource res = root.findMember(entry.getPath());
if (res != null) {
builder.addDirectory(res.getProjectRelativePath().removeFirstSegments(1).toOSString());
}
break;
case IClasspathEntry.CPE_CONTAINER:
String path = entry.getPath().toOSString();
if (path.startsWith(STANDARD_VM_CONTAINER_PREFIX)) {
builder.setJavaLanguageLevel(
Integer.parseInt(path.substring(STANDARD_VM_CONTAINER_PREFIX.length())));
}
break;
}
}
return builder.build();
}
示例13: getFile
import org.eclipse.core.resources.IWorkspaceRoot; //導入方法依賴的package包/類
protected IFile getFile(String fileName, String containerName) throws CoreException {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IResource resource = root.findMember(new Path(containerName));
if (!resource.exists() || !(resource instanceof IContainer)) {
throwCoreException("Container \"" + containerName + "\" does not exist.");
}
IContainer container = (IContainer) resource;
final IFile file = container.getFile(new Path(fileName));
return file;
}
示例14: getWorkspaceResource
import org.eclipse.core.resources.IWorkspaceRoot; //導入方法依賴的package包/類
private static IResource getWorkspaceResource(Map<String, String> bookmarkProperties) {
String workspacePath = bookmarkProperties.get(PROP_WORKSPACE_PATH);
if (workspacePath == null) {
return null;
}
Path path = new Path(workspacePath);
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
IResource resource = workspaceRoot.findMember(path);
return resource;
}
示例15: getWorkspaceMember
import org.eclipse.core.resources.IWorkspaceRoot; //導入方法依賴的package包/類
/**
* Gets the workspace member.
*
* @param name
* the name
* @return the workspace member
*/
private IResource getWorkspaceMember(final String name) {
IWorkspaceRoot workspaceRoot = EcorePlugin.getWorkspaceRoot();
if (workspaceRoot == null) {
return null;
}
return workspaceRoot.findMember(new Path(name));
}