Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » refresh a project
refresh a project [message #292444] Thu, 06 October 2005 11:45 Go to next message
Eclipse UserFriend
Originally posted by: pbeagan.yahoo_dontspamme_.com

What is the code snippet to refresh a project? I have an IPath to a file
in the project.

I have code that creates a new IFile in a project, saves to the root of that
project. I then immediately want to display the contents of this file in
an editor using IDE.openEditor(..). Problem is : Eclipse thinks the file
does not exist even though it is in the file system. Maybe there is
something I can do besides programmatically refresh the project. Any
ideas? Thanks.

sorry if this has been asked before.
Re: refresh a project [message #292996 is a reply to message #292444] Fri, 14 October 2005 11:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: john.eclipsefaq.org

If you created the IFile using IFile.create(...) then no refresh is
required. If you created the file some other way, such as with
java.io.File, then a refresh is required. Here is a snippet, given an
IProject, and an IPath to the file in that project:

IPath pathToFile = ...;//your path to the file
IFile file = project.getFile(pathToFile);
file.refreshLocal(IResource.DEPTH_ZERO, null);
--

Patrick wrote:
> What is the code snippet to refresh a project? I have an IPath to a file
> in the project.
>
> I have code that creates a new IFile in a project, saves to the root of that
> project. I then immediately want to display the contents of this file in
> an editor using IDE.openEditor(..). Problem is : Eclipse thinks the file
> does not exist even though it is in the file system. Maybe there is
> something I can do besides programmatically refresh the project. Any
> ideas? Thanks.
>
> sorry if this has been asked before.
Re: refresh a project [message #293002 is a reply to message #292996] Fri, 14 October 2005 14:00 Go to previous messageGo to next message
Eclipse UserFriend
I have similar problem. But the refreshLocal() did not help me.

Please see below for details of my problem

----------------------------------------------

HI,

I have implemented an action that creates a new file under a project and
tries to open it in an UMLEditor. This action is throwing a "Wrapped
exception"

What I have done is -

1) In the action, I am creating a new file under a project
IFile file = project.getFile( fileName );
file.create( null, false, null );
2) Open the new file in an UMLEditor
IEditorPart editorPart = IDE.openEditor( page, file, true );
3) The control comes back to MyEditor.setInput(). In this method I am
getting ResourceSet of the project and then trying to get the resource for
the file

IFile file = ( (IFileEditorInput) input ).getFile();
URI uri = URI.createPlatformResourceURI( file.getFullPath().toString() );
resourceSet.getResource( uri, true );

4) The getResource() method throws Wrapped Exception complaining that the
file that I created is not local. See the error trace below.

Is there anything that I am missing? How do I get rid of this problem?

Brahma



Wrapped exception
org.eclipse.core.internal.resources.ResourceException: Resource
/Ford/Appearance.uml is not local.
at
org.eclipse.core.internal.resources.Resource.checkLocal(Reso urce.java:316)
at org.eclipse.core.internal.resources.File.getContents(File.ja va:293)
at org.eclipse.core.internal.resources.File.getContents(File.ja va:283)
at
org.eclipse.emf.ecore.resource.impl.URIConverterImpl$Workben chHelper.createPlatformResourceInputStream(URIConverterImpl. java:195)
at
org.eclipse.emf.ecore.resource.impl.URIConverterImpl.createP latformResourceInputStream(URIConverterImpl.java:533)
at
org.eclipse.emf.ecore.resource.impl.URIConverterImpl.createI nputStream(URIConverterImpl.java:442)
at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:829)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:249)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:264)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:349)
at
com.bmide.model.util.TcResourceSetImpl.getResource(TcResourc eSetImpl.java:66)
at com.bmide.uml.ui.editor.UMLEditor.testLoad(UMLEditor.java:41 3)
at com.bmide.uml.ui.editor.UMLEditor.setInput(UMLEditor.java:34 5)
at org.eclipse.gef.ui.parts.GraphicalEditor.init(GraphicalEdito r.java:292)
at
org.eclipse.ui.internal.EditorManager.createSite(EditorManag er.java:773)
at
org.eclipse.ui.internal.EditorReference.createPartHelper(Edi torReference.java:572)
at
org.eclipse.ui.internal.EditorReference.createPart(EditorRef erence.java:365)
at
org.eclipse.ui.internal.WorkbenchPartReference.getPart(Workb enchPartReference.java:552)
at
org.eclipse.ui.internal.EditorAreaHelper.setVisibleEditor(Ed itorAreaHelper.java:258)
at
org.eclipse.ui.internal.EditorManager.setVisibleEditor(Edito rManager.java:1216)
at org.eclipse.ui.internal.EditorManager$5.run(EditorManager.ja va:944)
at
org.eclipse.core.internal.runtime.InternalPlatform.run(Inter nalPlatform.java:1044)
at org.eclipse.core.runtime.Platform.run(Platform.java:783)
at
org.eclipse.ui.internal.EditorManager.restoreState(EditorMan ager.java:939)
at
org.eclipse.ui.internal.WorkbenchPage.restoreState(Workbench Page.java:2535)
at
org.eclipse.ui.internal.WorkbenchWindow.restoreState(Workben chWindow.java:1819)
at org.eclipse.ui.internal.Workbench.doRestoreState(Workbench.j ava:2566)
at org.eclipse.ui.internal.Workbench.access$14(Workbench.java:2 515)
at org.eclipse.ui.internal.Workbench$19.run(Workbench.java:1514 )
at org.eclipse.ui.internal.Workbench$16.run(Workbench.java:1263 )
at
org.eclipse.jface.operation.ModalContext.runInCurrentThread( ModalContext.java:346)
at org.eclipse.jface.operation.ModalContext.run(ModalContext.ja va:291)
at
org.eclipse.jface.dialogs.ProgressMonitorDialog.run(Progress MonitorDialog.java:447)
at
org.eclipse.ui.internal.Workbench.runStartupWithProgress(Wor kbench.java:1258)
at org.eclipse.ui.internal.Workbench.restoreState(Workbench.jav a:1512)
at org.eclipse.ui.internal.Workbench.access$12(Workbench.java:1 491)
at org.eclipse.ui.internal.Workbench$17.run(Workbench.java:1374 )
at
org.eclipse.core.internal.runtime.InternalPlatform.run(Inter nalPlatform.java:1044)
at org.eclipse.core.runtime.Platform.run(Platform.java:783)
at org.eclipse.ui.internal.Workbench.restoreState(Workbench.jav a:1318)
at
org.eclipse.ui.internal.WorkbenchConfigurer.restoreState(Wor kbenchConfigurer.java:183)
at
org.eclipse.ui.application.WorkbenchAdvisor.openWindows(Work benchAdvisor.java:700)
at org.eclipse.ui.internal.Workbench.init(Workbench.java:1034)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1636)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:367)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:143)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplicatio n.java:103)
at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:226)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:376)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:163)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334 )
at org.eclipse.core.launcher.Main.basicRun(Main.java:278)
at org.eclipse.core.launcher.Main.run(Main.java:973)
at org.eclipse.core.launcher.Main.main(Main.java:948)
Re: refresh a project [message #293003 is a reply to message #293002] Fri, 14 October 2005 14:07 Go to previous message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

The documentation for file.create says if you pass "null" in for the
input stream then the file will not be local.

Null for input stream does not mean create an empty file!

You need to supply an InputStream that immediately returns end of input
so that you can create an empty file.

Brahma Somanchi wrote:
> I have implemented an action that creates a new file under a project and
> tries to open it in an UMLEditor. This action is throwing a "Wrapped
> exception"
>
> What I have done is -
>
> 1) In the action, I am creating a new file under a project
> IFile file = project.getFile( fileName );
> file.create( null, false, null );
> 2) Open the new file in an UMLEditor
>
> 4) The getResource() method throws Wrapped Exception complaining that
> the file that I created is not local. See the error trace below.
>
> Is there anything that I am missing? How do I get rid of this problem?

--
Thanks,
Rich Kulp
Previous Topic:popup menu in eclipse plugin
Next Topic:Plugin ClassLoader issue
Goto Forum:
  


Current Time: Mon Jul 14 21:10:25 EDT 2025

Powered by FUDForum. Page generated in 0.04225 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top