本文整理汇总了Java中org.eclipse.core.resources.IWorkspaceRoot类的典型用法代码示例。如果您正苦于以下问题:Java IWorkspaceRoot类的具体用法?Java IWorkspaceRoot怎么用?Java IWorkspaceRoot使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IWorkspaceRoot类属于org.eclipse.core.resources包,在下文中一共展示了IWorkspaceRoot类的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: getChildren
import org.eclipse.core.resources.IWorkspaceRoot; //导入依赖的package包/类
@Override
public Object[] getChildren(final Object element) {
if (workingSetManagerBroker.isWorkingSetTopLevel()) {
if (element instanceof IWorkspaceRoot) {
final WorkingSetManager manager = workingSetManagerBroker.getActiveManager();
if (manager != null) {
return manager.getWorkingSets();
}
} else if (element instanceof WorkingSet) {
return ((WorkingSet) element).getElements();
}
}
final Object[] children = super.getChildren(element);
if (element instanceof IProject && ((IProject) element).isAccessible()) {
return Arrays2.add(children, getVirtualNodes((IProject) element));
}
return children;
}
示例3: initProjectLocation
import org.eclipse.core.resources.IWorkspaceRoot; //导入依赖的package包/类
private Multimap<String, IProject> initProjectLocation() {
final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
final IProject[] projects = root.getProjects();
final Multimap<String, IProject> locations = HashMultimap.create();
// initialize the repository paths
repositoryPaths = repositoriesProvider.getWorkspaceRepositories().stream()
.map(r -> r.getDirectory().getParentFile().toPath()).collect(Collectors.toSet());
for (final IProject project : projects) {
if (isRemoteEditNature(project)) {
continue;
}
final String pair = getWorkingSetId(project);
locations.put(pair, project);
}
return locations;
}
示例4: createProjectPluginResource
import org.eclipse.core.resources.IWorkspaceRoot; //导入依赖的package包/类
public IProject createProjectPluginResource(String projectName, IProgressMonitor monitor) throws CoreException {
IWorkspace myWorkspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot myWorkspaceRoot = myWorkspace.getRoot();
IProject resourceProject = myWorkspaceRoot.getProject(projectName);
if (!resourceProject.exists()) {
if(myWorkspaceRoot.getLocation().toFile().equals(new Path(Engine.PROJECTS_PATH).toFile())){
logDebug("createProjectPluginResource : project is in the workspace folder");
resourceProject.create(monitor);
}else{
logDebug("createProjectPluginResource: project isn't in the workspace folder");
IPath projectPath = new Path(Engine.PROJECTS_PATH + "/" + projectName).makeAbsolute();
IProjectDescription description = myWorkspace.newProjectDescription(projectName);
description.setLocation(projectPath);
resourceProject.create(description, monitor);
}
}
return resourceProject;
}
示例5: collectAllWorkspaceFiles
import org.eclipse.core.resources.IWorkspaceRoot; //导入依赖的package包/类
public static List<ResourceItem> collectAllWorkspaceFiles(IWorkspaceRoot workspace) {
List<ResourceItem> files = new ArrayList<>();
IResourceProxyVisitor visitor = new IResourceProxyVisitor() {
public boolean visit(IResourceProxy proxy) throws CoreException {
if (proxy.getType() != IResource.FILE) return true;
if (proxy.isDerived()) return false;
if (proxy.isPhantom()) return false;
if (proxy.isHidden()) return false;
IFile file = (IFile) proxy.requestResource();
files.add(makeResourceItem(file));
return false;
}
};
try {
IResource[] resources = workspace.members();
for(IResource resource : resources) {
if (!resource.getProject().isOpen()) continue;
resource.accept(visitor, 0);
}
} catch (CoreException e) {
throw new RuntimeException(e);
}
return files;
}
示例6: 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;
}
示例7: 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;
}
示例8: 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;
}
示例9: resourceChanged
import org.eclipse.core.resources.IWorkspaceRoot; //导入依赖的package包/类
@Override
public void resourceChanged(IResourceChangeEvent event)
{
if( event.getType() == IResourceChangeEvent.PRE_BUILD )
{
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
if( fTouchWorkspace )
{
IProject[] projects = root.getProjects();
for( int i = 0; i < projects.length; i++ )
{
touchProject(projects[i]);
}
}
else
{
Iterator<String> iter = fProjectNames.iterator();
while( iter.hasNext() )
{
touchProject(root.getProject(iter.next()));
}
}
fTouchWorkspace = false;
fProjectNames.clear();
}
}
示例10: 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;
}
示例11: createChange
import org.eclipse.core.resources.IWorkspaceRoot; //导入依赖的package包/类
@Override
public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
copyToPath=getArguments().getDestination().toString();
IWorkspaceRoot workSpaceRoot = ResourcesPlugin.getWorkspace().getRoot();
IProject project = workSpaceRoot.getProject(copyToPath.split("/")[1]);
IFolder jobFolder = project.getFolder(copyToPath.substring(copyToPath.indexOf('/', 2)));
previousJobFiles=new ArrayList<>();
for (IResource iResource : jobFolder.members()) {
if (!(iResource instanceof IFolder)) {
IFile iFile = (IFile) iResource;
if (iFile.getFileExtension().equalsIgnoreCase(Messages.JOB_EXT)) {
previousJobFiles.add(iFile);
}
}
}
copiedFileList.add(modifiedResource);
return null;
}
示例12: doSaveAs
import org.eclipse.core.resources.IWorkspaceRoot; //导入依赖的package包/类
@Override
public void doSaveAs() {
String jobId = getActiveProject() + "." + getJobName();
DataViewerUtility.INSTANCE.closeDataViewerWindows(JobManager.INSTANCE.getPreviouslyExecutedJobs().get(jobId));
deleteDebugFiles(jobId);
Map<String, String> currentParameterMap = getCurrentParameterMap();
IFile file=opeSaveAsDialog();
saveJob(file,true);
IWorkspaceRoot workSpaceRoot = ResourcesPlugin.getWorkspace().getRoot();
IProject project = workSpaceRoot.getProject(getActiveProject());
IFolder paramFolder = project.getFolder(Messages.PARAM);
IFile filename=paramFolder.getFile(oldFileName.replace(Messages.JOBEXTENSION,Messages.PROPERTIES_EXTENSION));
copyParameterFile(currentParameterMap,filename);
}
示例13: getProjectMap
import org.eclipse.core.resources.IWorkspaceRoot; //导入依赖的package包/类
/**
* Obtient la map Project vers Projet Java du workspace courant.
*
* @return Map des projets.
*/
public static JavaProjectMap getProjectMap() {
JavaProjectMap projects = new JavaProjectMap();
/* Racine du workspace courant. */
IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
/* Parcourt les projets de la racine. */
for (IProject project : wsRoot.getProjects()) {
/* Vérication que le projet est un projet Java accessible. */
if (!project.isAccessible() || !JdtUtils.isJavaProject(project)) {
continue;
}
/* Obtient l'AST du projet. */
IJavaProject javaProject = JavaCore.create(project);
projects.put(project, javaProject);
}
return projects;
}
示例14: getEditorInput
import org.eclipse.core.resources.IWorkspaceRoot; //导入依赖的package包/类
@Override
public IEditorInput getEditorInput(Object element) {
if (element instanceof ILineBreakpoint) {
return new FileEditorInput((IFile) ((ILineBreakpoint) element).getMarker().getResource());
}
IFileStore fileStore = EFS.getLocalFileSystem().getStore(new Path(element.toString()));
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IFile[] files = root.findFilesForLocationURI(fileStore.toURI());
if (files != null) {
for (IFile file : files) {
if (file.exists()) {
return new FileEditorInput(file);
}
}
}
return new FileStoreEditorInput(fileStore);
}
示例15: linkPressed
import org.eclipse.core.resources.IWorkspaceRoot; //导入依赖的package包/类
@Override
protected void linkPressed(final HyperlinkEvent event, final EObject project_p, final Session session) {
if (project_p instanceof Project) {
TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(project_p);
domain.getCommandStack().execute(new RecordingCommand(domain) {
@Override
protected void doExecute() {
final Project prj = ((Project) project_p);
final Mapping mapping = ToPeriodicDerivation.getOrApply(prj);
final DesignModel toBeAnalysedModel = (DesignModel) mapping.getSubLinks().get(0).getUniqueTargetValue("copy");
final URI uri = prj.eResource().getURI();
IPath path = new Path(uri.toPlatformString(true));
final String filename = path.lastSegment().replaceAll(".time4sys", "-report.asciidoc");
path = path.removeLastSegments(1);
path = path.append(filename);
IWorkspaceRoot wrkspc = ResourcesPlugin.getWorkspace().getRoot();
final IFile output = wrkspc.getFile(path);
generateReport(toBeAnalysedModel, output, null);
}
});
}
}