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