本文整理汇总了Java中org.eclipse.core.resources.IResource.getProject方法的典型用法代码示例。如果您正苦于以下问题:Java IResource.getProject方法的具体用法?Java IResource.getProject怎么用?Java IResource.getProject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.core.resources.IResource
的用法示例。
在下文中一共展示了IResource.getProject方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getReplacementText
import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
@Override
public String getReplacementText() {
SelectEcoreIFileDialog dialog = new SelectEcoreIFileDialog();
if (dialog.open() == Dialog.OK) {
Object[] selections = dialog.getResult();
if(selections != null
&& selections.length != 0
&& selections[0] instanceof IResource
){
IResource ecoreFile = (IResource) selections[0];
ecoreProject = ecoreFile.getProject();
String path = "/"+ecoreFile.getProject().getName() +"/"+ecoreFile.getProjectRelativePath();
URI uri = URI.createPlatformResourceURI(path,true);
String replacementText = "\""+uri.toString()+"\"";
return replacementText;
}
}
return "";
}
示例2: visit
import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
@Override
public boolean visit(IResourceDelta delta) throws CoreException
{
IResource resource = delta.getResource();
if( resource.isDerived() )
{
return false;
}
if( resource.getType() == IResource.FILE )
{
IFile file = (IFile) resource;
IProject project = resource.getProject();
if( file.equals(JPFProject.getManifest(project)) )
{
manifestChanged = true;
return false;
}
}
return true;
}
示例3: getTargetFolderForGeneratedTests
import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
/**
* Return the allowed folder where test can be generated in depending on the
* user selection if the selected graph is in src/main/resource then
* src/main/java if the selected graph is in src/test/resource then
* src/test/java
*
* @return
*/
public static IPath getTargetFolderForGeneratedTests(IResource selectedGraphFile) {
IProject project = selectedGraphFile.getProject();
IPath pathResourceTestFolder = project.getFullPath().append(getTestResourceFolder());
if (ResourceManager.isInFolder(pathResourceTestFolder,
selectedGraphFile.getParent().getFullPath()))
return project.getFullPath().append(getTestSourceFolder());
IPath pathResourceMainFolder = project.getFullPath().append(getMainResourceFolder());
if (ResourceManager.isInFolder(pathResourceMainFolder,
selectedGraphFile.getParent().getFullPath()))
return project.getFullPath().append(getMainSourceFolder());
return null;
}
示例4: getPathWithinPackageFragment
import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
/**
* Return a path relative to its package fragment root
*
* @param project
* @param path
* @return
* @throws JavaModelException
*/
public static IPath getPathWithinPackageFragment(IResource ifile) throws JavaModelException {
IProject project = ifile.getProject();
IPath path = ifile.getFullPath();
String[] segments = path.segments();
IJavaProject jproject = JavaCore.create(project);
IPackageFragment[] pkgs = jproject.getPackageFragments();
IPath p = new Path("/");
for (int i = 0; i < segments.length; i++) {
for (int j = 0; j < pkgs.length; j++) {
if (pkgs[j].getPath().equals(p)) {
IPath ret = path.makeRelativeTo(pkgs[j].getPath());
return ret;
}
}
p = p.append(segments[i]);
}
return null;
}
示例5: decorate
import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
@Override
public void decorate(Object element, IDecoration decoration) {
if (element instanceof IResource) {
IResource res = (IResource) element;
IProject proj = res.getProject();
try {
if (proj != null && proj.isAccessible() && proj.hasNature(NATURE.ID)) {
IMarker[] markers = res.findMarkers(MARKER.ERROR, false,
IResource.DEPTH_INFINITE);
if (markers.length > 0) {
decoration.addOverlay(PlatformUI.getWorkbench().getSharedImages()
.getImageDescriptor(ISharedImages.IMG_DEC_FIELD_ERROR));
}
}
} catch (CoreException e) {
Log.log(e);
}
}
}
示例6: setTargetFolderForTestInterface
import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
/**
* @param path
*/
public static void setTargetFolderForTestInterface(IResource resource,boolean main) {
IProject project = resource.getProject();
String path = resource.getFullPath().removeFirstSegments(1).toString();
String key = GW4E_MAIN_SOURCE_GENERATED_INTERFACE;
if (!main) {
key = GW4E_TEST_SOURCE_GENERATED_INTERFACE;
}
boolean projectScoped = isProjectScoped(key);
SettingsManager.putValues(project, key,
new String[] { path }, projectScoped);
}
示例7: preferences
import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
/**
* Returns the plugin's project scoped preferences using the given
* resource to identify the project.
*
* @param resource a resource from the project
* @return the preferences
*/
public static Preferences preferences(IResource resource) {
ProjectScope projectScope = new ProjectScope(resource.getProject());
return projectScope.getNode(MinifyBuilder.BUILDER_ID);
}