本文整理匯總了Java中org.eclipse.core.resources.IProject類的典型用法代碼示例。如果您正苦於以下問題:Java IProject類的具體用法?Java IProject怎麽用?Java IProject使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
IProject類屬於org.eclipse.core.resources包,在下文中一共展示了IProject類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createSchema
import org.eclipse.core.resources.IProject; //導入依賴的package包/類
static IFolder createSchema(String name, boolean open, IProject project) throws CoreException {
IFolder projectFolder = project.getFolder(DbObjType.SCHEMA.name());
if (!projectFolder.exists()) {
projectFolder.create(false, true, null);
}
IFolder schemaFolder = projectFolder.getFolder(name);
if (!schemaFolder.exists()) {
schemaFolder.create(false, true, null);
}
IFile file = projectFolder.getFile(name + POSTFIX);
if (!file.exists()) {
StringBuilder sb = new StringBuilder();
sb.append(MessageFormat.format(PATTERN, DbObjType.SCHEMA, name));
sb.append(MessageFormat.format(OWNER_TO, DbObjType.SCHEMA, name));
file.create(new ByteArrayInputStream(sb.toString().getBytes()), false, null);
}
if (open) {
openFileInEditor(file);
}
return schemaFolder;
}
示例2: performOk
import org.eclipse.core.resources.IProject; //導入依賴的package包/類
/**
* @see PreferencePage#performOk
*/
@Override
public boolean performOk()
{
if( !modified )
{
return true;
}
IPath path = Path.EMPTY;
Object[] checked = listViewer.getCheckedElements();
for( Object elements : checked )
{
path = path.append(((IProject) elements).getName());
}
IPreferenceStore prefs = getPreferenceStore();
prefs.setValue(JPFClasspathPlugin.PREF_PARENT_REGISTRIES, path.toString());
try
{
((IPersistentPreferenceStore) prefs).save();
}
catch( IOException e )
{
JPFClasspathLog.logError(e);
}
return true;
}
示例3: hasNature
import org.eclipse.core.resources.IProject; //導入依賴的package包/類
/**
* Test whether the project has the passed nature
*
* @param receiver
* @param nature
* @return
*/
public static boolean hasNature(Object receiver, String nature) {
IProject project = JDTManager.toJavaProject(receiver);
if (project == null || !project.isOpen())
return false;
IProjectDescription description;
try {
description = project.getDescription();
} catch (CoreException e) {
ResourceManager.logException(e);
return false;
}
String[] natures = description.getNatureIds();
for (int i = 0; i < natures.length; i++) {
if (nature.equalsIgnoreCase(natures[i]))
return true;
}
return false;
}
示例4: executeForSelectedLanguage
import org.eclipse.core.resources.IProject; //導入依賴的package包/類
@Override
public Object executeForSelectedLanguage(ExecutionEvent event,
IProject updatedGemocLanguageProject, Language language)
throws ExecutionException {
CreateDomainModelWizardContextAction action = new CreateDomainModelWizardContextAction(
updatedGemocLanguageProject);
action.actionToExecute = CreateDomainModelAction.CREATE_NEW_EMF_PROJECT;
action.execute();
if(action.getCreatedEcoreUri() != null){
waitForAutoBuild();
updateMelange(event,language,action.getCreatedEcoreUri());
}
return null;
}
示例5: testNoErrorMarkersWhenReferencedFileIsCreatedBeforeReferencingFile
import org.eclipse.core.resources.IProject; //導入依賴的package包/類
/**
* <ol>
* <li>create Class1 file with having Class1.field0 -> should have no errors</li>
* <li>create Class0 file with referencing Class1.field0 -> should have no errors as Class1 already created</li>
* </ol>
*/
//@formatter:on
@Test
public void testNoErrorMarkersWhenReferencedFileIsCreatedBeforeReferencingFile() throws Exception {
// create project and test files
final IProject project = createJSProject("testNoErrorMarkersWhenReferencedFileIsCreatedBeforeReferencingFile");
IFolder folder = configureProjectWithXtext(project);
IFolder moduleFolder = createFolder(folder, TestFiles.moduleFolder());
IFile file2 = createTestFile(moduleFolder, "Class1", TestFiles.class1());
assertMarkers("File2 should have no errors", file2, 0);
IFile file1 = createTestFile(moduleFolder, "Class0", TestFiles.class0());
// The value of the local variable dummy is not used
assertMarkers("File1 should have no errors", file1, 1);
}
示例6: getPathWithinPackageFragment
import org.eclipse.core.resources.IProject; //導入依賴的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;
}
示例7: createModel
import org.eclipse.core.resources.IProject; //導入依賴的package包/類
@Override
protected void createModel(IProject project, boolean notify)
{
IPluginModel model = null;
if( isPluginProject(project) )
{
model = new ProjectPluginModelImpl(this, project);
}
if( model != null )
{
fModels.put(project, model);
if( notify )
{
addChange(model, IModelProviderEvent.MODELS_ADDED);
}
}
}
示例8: mkdirs
import org.eclipse.core.resources.IProject; //導入依賴的package包/類
private static void mkdirs(IFolder destPath) {
IContainer parent = destPath.getParent();
if (! parent.exists()) {
if (parent instanceof IFolder) {
mkdirs((IFolder) parent);
}
else if (parent instanceof IProject) {
mkdirs( ((IProject)parent).getFolder(".") );
}
}
try {
destPath.create(/*force*/true, /*local*/true, Constants.NULL_PROGRESS_MONITOR);
} catch (CoreException e) {
e.printStackTrace();
}
}
示例9: collectAllCompilationUnits
import org.eclipse.core.resources.IProject; //導入依賴的package包/類
/**
* Collects all compilation units within the project.
* @return the collection of the compilation units
*/
public static List<ICompilationUnit> collectAllCompilationUnits() {
List<ICompilationUnit> units = new ArrayList<ICompilationUnit>();
try {
IProject[] projects = getWorkspace().getRoot().getProjects();
for (int i = 0; i < projects.length; i++) {
IJavaProject project = (IJavaProject)JavaCore.create((IProject)projects[i]);
IPackageFragment[] packages = project.getPackageFragments();
for (int j = 0; j < packages.length; j++) {
ICompilationUnit[] cus = packages[j].getCompilationUnits();
for (int k = 0; k < cus.length; k++) {
IResource res = cus[k].getResource();
if (res.getType() == IResource.FILE) {
String name = cus[k].getPath().toString();
if (name.endsWith(".java")) {
units.add(cus[k]);
}
}
}
}
}
} catch (JavaModelException e) {
e.printStackTrace();
}
return units;
}
示例10: openXMLTransactionStepEditor
import org.eclipse.core.resources.IProject; //導入依賴的package包/類
public void openXMLTransactionStepEditor(IProject project)
{
TransactionStep transactionStep = (TransactionStep)this.getObject();
IFile file = project.getFile("_private/"+transactionStep.getName()+".xml");
IWorkbenchPage activePage = PlatformUI
.getWorkbench()
.getActiveWorkbenchWindow()
.getActivePage();
if (activePage != null) {
try {
activePage.openEditor(new XMLTransactionStepEditorInput(file,transactionStep),
"com.twinsoft.convertigo.eclipse.editors.xml.XMLTransactionStepEditor");
}
catch(PartInitException e) {
ConvertigoPlugin.logException(e, "Error while loading the step editor '" + transactionStep.getName() + "'");
}
}
}
示例11: getFileSystemAccess
import org.eclipse.core.resources.IProject; //導入依賴的package包/類
protected IFileSystemAccess2 getFileSystemAccess(final IProject project, final IProgressMonitor monitor) {
EclipseResourceFileSystemAccess2 access = fileSystemAccessProvider.get();
access.setContext(project);
access.setMonitor(monitor);
OutputConfiguration defaultOutput = new OutputConfiguration(IFileSystemAccess.DEFAULT_OUTPUT);
defaultOutput.setDescription("Output Folder");
defaultOutput.setOutputDirectory("./");
defaultOutput.setOverrideExistingResources(true);
defaultOutput.setCreateOutputDirectory(true);
defaultOutput.setCleanUpDerivedResources(false);
defaultOutput.setSetDerivedProperty(false);
defaultOutput.setKeepLocalHistory(false);
HashMap<String, OutputConfiguration> outputConfigurations = new HashMap<String, OutputConfiguration>();
outputConfigurations.put(IFileSystemAccess.DEFAULT_OUTPUT, defaultOutput);
access.setOutputConfigurations(outputConfigurations);
return access;
}
示例12: testModuleWithIgnoredMethod
import org.eclipse.core.resources.IProject; //導入依賴的package包/類
/**
* Runs a test module with one single class that has method with {@code Ignore} annotation.
*/
@Ignore("IDE-2270")
@Test
public void testModuleWithIgnoredMethod() {
final IProject project = getProjectByName(PROJECT_NAME);
assertTrue("Project is not accessible.", project.isAccessible());
final IFile module = project.getFile("test/X1.n4js");
assertTrue("Module is not accessible.", module.isAccessible());
runTestWaitResult(module);
final String[] expected = { "X1#x12Test" };
final String[] actual = getConsoleContentLines();
assertArrayEquals(expected, actual);
}
示例13: testModuleWithoutSuperClass
import org.eclipse.core.resources.IProject; //導入依賴的package包/類
/**
* Runs a test module with one single class that has neither super class nor {@code @Ignore} annotation.
*/
@Ignore("IDE-2270")
@Test
public void testModuleWithoutSuperClass() {
final IProject project = getProjectByName(PROJECT_NAME);
assertTrue("Project is not accessible.", project.isAccessible());
final IFile module = project.getFile("test/A.n4js");
assertTrue("Module is not accessible.", module.isAccessible());
runTestWaitResult(module);
final String[] expected = { "A#aTest" };
final String[] actual = getConsoleContentLines();
assertArrayEquals(expected, actual);
}
示例14: getElements
import org.eclipse.core.resources.IProject; //導入依賴的package包/類
@Override
public IAdaptable[] getElements() {
final IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
final IProject[] elements = new IProject[projects.length];
int elementCount = 0;
for (int i = 0, size = projects.length; i < size; i++) {
final IProject project = projects[i];
final IN4JSProject n4Project = core.findProject(toUri(project)).orNull();
if (type == null) { // Other Projects
if (n4Project == null || !n4Project.exists()) {
elements[elementCount++] = project;
}
} else {
if (n4Project != null && n4Project.exists() && type.equals(n4Project.getProjectType())) {
elements[elementCount++] = project;
}
}
}
return Arrays.copyOfRange(elements, 0, elementCount);
}
示例15: getStorages
import org.eclipse.core.resources.IProject; //導入依賴的package包/類
@Override
public Iterable<Pair<IStorage, IProject>> getStorages(URI uri) {
if (uri.isArchive()) {
URIBasedStorage storage = new URIBasedStorage(uri);
String authority = uri.authority();
URI archiveFileURI = URI.createURI(authority.substring(0, authority.length() - 1));
Optional<? extends IN4JSEclipseProject> optionalProject = eclipseCore.findProject(archiveFileURI);
if (optionalProject.isPresent()) {
return Collections.singletonList(Tuples.<IStorage, IProject> create(storage, optionalProject.get()
.getProject()));
} else {
return Collections.singletonList(Tuples.create(storage, null));
}
} else {
return Collections.emptyList();
}
}