當前位置: 首頁>>代碼示例>>Java>>正文


Java IFile類代碼示例

本文整理匯總了Java中org.eclipse.core.resources.IFile的典型用法代碼示例。如果您正苦於以下問題:Java IFile類的具體用法?Java IFile怎麽用?Java IFile使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


IFile類屬於org.eclipse.core.resources包,在下文中一共展示了IFile類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: fix

import org.eclipse.core.resources.IFile; //導入依賴的package包/類
private void fix(IMarker marker, IProgressMonitor monitor) {
	MarkerResolutionGenerator.printAttributes (marker);
	try {
		String filepath  = (String) marker.getAttribute(BuildPolicyConfigurationException.JAVAFILENAME);
		int start = (int) marker.getAttribute(IMarker.CHAR_START);
		int end =  (int) marker.getAttribute(IMarker.CHAR_END);
		IFile ifile = (IFile) ResourceManager.toResource(new Path(filepath));
		ICompilationUnit cu = JavaCore.createCompilationUnitFrom(ifile);
		String source = cu.getBuffer().getContents();
		String part1 =  source.substring(0,start);
		String part2 =  source.substring(end);
		source = part1 + "value=\"" + resolutionMarkerDescription.getGenerator() + "\"" + part2;
		final Document document = new Document(source);
		cu.getBuffer().setContents(document.get());
	    cu.save(monitor, false);
	} catch (Exception e) {
		ResourceManager.logException(e);
	}
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:20,代碼來源:InvalidAnnotationPathGeneratorMarkerResolution.java

示例2: copyBuildFile

import org.eclipse.core.resources.IFile; //導入依賴的package包/類
private void copyBuildFile(String source, IProject project) throws CoreException {
	File sourceFileLocation = new File(source);
	File[] listFiles = sourceFileLocation.listFiles();
	if(listFiles != null){
		for(File sourceFile : listFiles){
			IFile destinationFile = project.getFile(sourceFile.getName());
			try(InputStream fileInputStream = new FileInputStream(sourceFile)) {
				if(!destinationFile.exists()){ //used while importing a project
					destinationFile.create(fileInputStream, true, null);
				}
			} catch (IOException | CoreException exception) {
				logger.debug("Copy build file operation failed");
				throw new CoreException(new MultiStatus(Activator.PLUGIN_ID, 100, "Copy build file operation failed", exception));
			}
		}
	}
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:18,代碼來源:ProjectStructureCreator.java

示例3: launchFile

import org.eclipse.core.resources.IFile; //導入依賴的package包/類
/**
 * Launch a file, using the file information, which means using default launch configurations.
 */
protected void launchFile(IFile originalFileToRun, String mode) {
	final String runnerId = getRunnerId();
	final String path = originalFileToRun.getFullPath().toOSString();
	final URI moduleToRun = URI.createPlatformResourceURI(path, true);

	final String implementationId = chooseImplHelper.chooseImplementationIfRequired(runnerId, moduleToRun);
	if (implementationId == ChooseImplementationHelper.CANCEL)
		return;

	RunConfiguration runConfig = runnerFrontEnd.createConfiguration(runnerId, implementationId, moduleToRun);

	ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
	ILaunchConfigurationType type = launchManager.getLaunchConfigurationType(getLaunchConfigTypeID());
	DebugUITools.launch(runConfigConverter.toLaunchConfiguration(type, runConfig), mode);
	// execution dispatched to proper delegate LaunchConfigurationDelegate
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:20,代碼來源:AbstractRunnerLaunchShortcut.java

示例4: deleteCorrospondingJobAndPropertyFileifUserDeleteXmlFile

import org.eclipse.core.resources.IFile; //導入依賴的package包/類
private boolean deleteCorrospondingJobAndPropertyFileifUserDeleteXmlFile(IProject iProject) {
	if (modifiedResource.getProjectRelativePath()!=null && StringUtils.equalsIgnoreCase(modifiedResource.getProjectRelativePath().segment(0),
			CustomMessages.ProjectSupport_JOBS)) {
		IFile propertyFileName = null;
		IFolder jobsFolder = iProject.getFolder(CustomMessages.ProjectSupport_JOBS);
		IFolder propertiesFolder = iProject.getFolder(Messages.PARAM);

		if (jobsFolder != null) {
			jobIFile=jobsFolder.getFile(modifiedResource.getFullPath().removeFirstSegments(2).removeFileExtension().addFileExtension(Constants.JOB_EXTENSION_FOR_IPATH));
		}
		if (propertiesFolder != null) {
			propertyFileName = propertiesFolder.getFile(modifiedResource.getFullPath().removeFileExtension()
					.addFileExtension(Constants.PROPERTIES).toFile().getName());
		}
		String message = getErrorMessageIfUserDeleteXmlRelatedFiles(jobIFile, propertyFileName);
		showErrorMessage(jobIFile, propertyFileName, Messages.bind(message, modifiedResource.getName()));
	} else {
		flag = true;
	}
	return flag;
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:22,代碼來源:JobDeleteParticipant.java

示例5: showMessageForGeneratingUniqueJobId

import org.eclipse.core.resources.IFile; //導入依賴的package包/類
/**
 * Create a Message Box displays a currentJob UniqueId and a message to
 * generate new Unique Id.
 * @param container
 * @param jobFile
 * @param isSubjob
 * @return {@link Integer}
 */
private int showMessageForGeneratingUniqueJobId(Container container, IFile jobFile, boolean isSubJob) {
	int buttonId = SWT.NO;
	if(StringUtils.isBlank(container.getUniqueJobId())){
		return SWT.YES;
	}
	MessageBox messageBox = new MessageBox(Display.getCurrent().getActiveShell(),
			SWT.ICON_QUESTION | SWT.YES | SWT.NO);
	messageBox.setText("Question");
	String previousUniqueJobId = container.getUniqueJobId();
	if (isSubJob) {
		messageBox.setMessage(Messages.bind(Messages.GENERATE_NEW_UNIQUE_JOB_ID_FOR_SUB_JOB, jobFile.getName(),
				previousUniqueJobId));
	} else {
		messageBox.setMessage(
				Messages.bind(Messages.GENERATE_NEW_UNIQUE_JOB_ID_FOR_JOB, jobFile.getName(), previousUniqueJobId));
	}
	buttonId = messageBox.open();
	return buttonId;
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:28,代碼來源:UiConverterUtil.java

示例6: openPossibleFileWithExtensionInProject

import org.eclipse.core.resources.IFile; //導入依賴的package包/類
/**
 * Open the only solution if only one file has the correct extension
 * Otherwise invite to select the file to open
 * @param project
 * @param fileExtension
 */
public static void openPossibleFileWithExtensionInProject(IProject project, String fileExtension) {
	FileFinderVisitor finder = new FileFinderVisitor(fileExtension);
	try {
		project.accept(finder);
		List<IFile> list =finder.getFiles();
		if(list.size() == 1) {
			openIFile(list.get(0));
		}
		else{
			openPossibleFileInProject(project,"*."+fileExtension);
		}
	} catch (CoreException e1) {
		// TODO Auto-generated catch block
		e1.printStackTrace();
	}
}
 
開發者ID:eclipse,項目名稱:gemoc-studio,代碼行數:23,代碼來源:OpenEditor.java

示例7: getActiveFile

import org.eclipse.core.resources.IFile; //導入依賴的package包/類
@Override
public IFile getActiveFile() {
	IProject projectWithGenmodel = this.getProject(this.gemocLanguageProject);
	FileFinderVisitor genmodelFinder = new FileFinderVisitor("genmodel");
	
	try {

		projectWithGenmodel.accept(genmodelFinder);
	} catch (CoreException e) {
		Activator.error(e.getMessage(), e);
	}

	if(genmodelFinder.getFiles().size() > 0){
		return genmodelFinder.getFiles().get(0);
	} else {
		return null;
	}
}
 
開發者ID:eclipse,項目名稱:gemoc-studio-modeldebugging,代碼行數:19,代碼來源:ActiveFileGenmodel.java

示例8: testCloseEditor

import org.eclipse.core.resources.IFile; //導入依賴的package包/類
@Test
public void testCloseEditor() throws Exception {
	
	IJavaProject project = ProjectHelper.getOrCreateSimpleGW4EProject(PROJECT_NAME, true, true);
	IFile impl = (IFile) ResourceManager
			.getResource(project.getProject().getFullPath().append("src/test/java/SimpleImpl.java").toString());
	Display.getDefault().syncExec(() -> {
		try {
			IWorkbenchWindow iww = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
			ResourceManager.closeEditor(impl, iww);
		} catch (PartInitException e) {
			ResourceManager.logException(e);
		}});
	 
	Waiter.waitUntil(new EditorClosedCondition("SimpleImpl.java"));
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:17,代碼來源:ResourceManagerTest.java

示例9: buildIncrement

import org.eclipse.core.resources.IFile; //導入依賴的package包/類
private void buildIncrement(IResourceDelta delta, PgDbParser parser, IProgressMonitor monitor)
        throws CoreException, InterruptedException, IOException {
    List<IFile> files = new ArrayList<>();
    delta.accept(d -> {
        if (PgUIDumpLoader.isInProject(d)) {
            IResource res = d.getResource();
            if (res.getType() == IResource.FILE) {
                switch (d.getKind()) {
                case IResourceDelta.REMOVED:
                case IResourceDelta.REMOVED_PHANTOM:
                    parser.removePathFromRefs(res.getLocation().toOSString());
                    break;
                default:
                    files.add((IFile) res);
                    break;
                }
            }
        }
        return true;
    });
    parser.getObjFromProjFiles(files, monitor);
}
 
開發者ID:pgcodekeeper,項目名稱:pgcodekeeper,代碼行數:23,代碼來源:ProjectBuilder.java

示例10: activateEditor

import org.eclipse.core.resources.IFile; //導入依賴的package包/類
@Override
public void activateEditor(final IWorkbenchPage page, final IStructuredSelection selection) {
	if (null != selection && !selection.isEmpty()) {
		final Object firstElement = selection.getFirstElement();
		if (firstElement instanceof ResourceNode) {
			final File fileResource = ((ResourceNode) firstElement).getResource();
			if (fileResource.exists() && fileResource.isFile()) {
				final URI uri = URI.createFileURI(fileResource.getAbsolutePath());
				final IResource resource = externalLibraryWorkspace.getResource(uri);
				if (resource instanceof IFile) {
					final IEditorInput editorInput = EditorUtils.createEditorInput(new URIBasedStorage(uri));
					final IEditorPart editor = page.findEditor(editorInput);
					if (null != editor) {
						page.bringToTop(editor);
						return;
					}
				}
			}
		}
	}
	super.activateEditor(page, selection);
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:23,代碼來源:N4JSResourceLinkHelper.java

示例11: testWorkspaceProjectAndExternalProject

import org.eclipse.core.resources.IFile; //導入依賴的package包/類
/**
 * Check if index is populated with external project content and workspace project content when the external
 * location with single project is registered and workspace contains project with different name.
 */
@Test
public void testWorkspaceProjectAndExternalProject() throws Exception {

	IProject createJSProject = ProjectUtils.createJSProject("LibFoo2");
	IFolder src = configureProjectWithXtext(createJSProject);
	IFile manifest = createJSProject.getProject().getFile("manifest.n4mf");
	assertMarkers("manifest of first project should have no errors", manifest, 0);
	createTestFile(src, "Foo", "console.log('hi')");

	copyProjectsToLocation(externalLibrariesRoot);
	waitForAutoBuild();
	setExternalLibrariesPreferenceStoreLocations(externalLibraryPreferenceStore, externalLibrariesRoot);

	Collection<String> expectedExternal = collectIndexableFiles(externalLibrariesRoot);
	Collection<String> expectedWorkspace = collectIndexableFiles(ResourcesPlugin.getWorkspace());
	Collection<String> expected = new HashSet<>();
	expected.addAll(expectedExternal);
	expected.addAll(expectedWorkspace);

	assertResourceDescriptions(expected, BuilderUtil.getAllResourceDescriptions());

	removeExternalLibrariesPreferenceStoreLocations(externalLibraryPreferenceStore, externalLibrariesRoot);

}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:29,代碼來源:ExternalPackagesPluginTest.java

示例12: isFilteredByParent

import org.eclipse.core.resources.IFile; //導入依賴的package包/類
private boolean isFilteredByParent() {
	if ((linkedResourceGroup == null) || linkedResourceGroup.isEnabled())
		return false;
	IPath containerPath = resourceGroup.getContainerFullPath();
	if (containerPath == null)
		return false;
	String resourceName = resourceGroup.getResource();
	if (resourceName == null)
		return false;
	if (resourceName.length() > 0) {
		IPath newFolderPath = containerPath.append(resourceName);
		IFile newFileHandle = createFileHandle(newFolderPath);
		IWorkspace workspace = newFileHandle.getWorkspace();
		return !workspace.validateFiltered(newFileHandle).isOK();
	}
	return false;
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:18,代碼來源:WizardNewFileCreationPage.java

示例13: loadClassesFromSettingsFolder

import org.eclipse.core.resources.IFile; //導入依賴的package包/類
private void loadClassesFromSettingsFolder() {
	Properties properties = new Properties();
	IFolder folder=getCurrentProject().getFolder(PathConstant.PROJECT_RESOURCES_FOLDER);
	IFile file = folder.getFile(PathConstant.EXPRESSION_EDITOR_EXTERNAL_JARS_PROPERTIES_FILES);
	try {
		LOGGER.debug("Loading property file");
		if (file.getLocation().toFile().exists()) {
			FileInputStream inStream = new FileInputStream(file.getLocation().toString());
			properties.load(inStream);
			
			for(Object key:properties.keySet()){
				String packageName=StringUtils.remove((String)key,Constants.DOT+Constants.ASTERISK);
				if(StringUtils.isNotBlank(properties.getProperty((String)key)) && StringUtils.isNotBlank(packageName)){
					loadUserDefinedClassesInClassRepo(properties.getProperty((String)key),packageName);
				}
			}
		}
	} catch (IOException |RuntimeException exception) {
		LOGGER.error("Exception occurred while loading jar files from projects setting folder",exception);
	}
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:22,代碼來源:BuildExpressionEditorDataSturcture.java

示例14: doSaveAs

import org.eclipse.core.resources.IFile; //導入依賴的package包/類
/**
 * This also changes the editor's input.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void doSaveAs ()
{
    SaveAsDialog saveAsDialog = new SaveAsDialog ( getSite ().getShell () );
    saveAsDialog.open ();
    IPath path = saveAsDialog.getResult ();
    if ( path != null )
    {
        IFile file = ResourcesPlugin.getWorkspace ().getRoot ().getFile ( path );
        if ( file != null )
        {
            doSaveAs ( URI.createPlatformResourceURI ( file.getFullPath ().toString (), true ), new FileEditorInput ( file ) );
        }
    }
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:22,代碼來源:DeploymentEditor.java

示例15: testOfflineAppendMode

import org.eclipse.core.resources.IFile; //導入依賴的package包/類
@Test
public void testOfflineAppendMode() throws Exception {
	GW4EProject project = new GW4EProject(bot, gwproject);
	FileParameters fp = project.createSimpleProject ();
	fp.setTargetFilename("SimpleOffLineImpl");
	OfflineTestUIPageTest page = walkToToOfflinePage(gwproject,fp); 
	page.selectAppendMode("com.company.SimpleImpl.java - gwproject/src/main/java");
	page.selectGenerators(new String [] {"random(edge_coverage(100))"});
	page.finish();
														  
	ICondition condition = new DefaultCondition () {
		@Override
		public boolean test() throws Exception {
			IFile resource = (IFile) ResourceManager.getResource("gwproject/src/main/java/com/company/SimpleImpl.java");
			boolean methodAppended = IOHelper.findInFile(resource, "Generated with : random(edge_coverage(100))");
			return methodAppended;
		}

		@Override
		public String getFailureMessage() {
			return "method not generated ";
		}
	};
	bot.waitUntil(condition, 3 * 6 * SWTBotPreferences.TIMEOUT); //3mn
	closeWizard ();
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:27,代碼來源:GW4EProjectTestCase.java


注:本文中的org.eclipse.core.resources.IFile類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。