本文整理匯總了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);
}