Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Is there a way I can get Eclipse "build" the java file I just imported at when I want?
Is there a way I can get Eclipse "build" the java file I just imported at when I want? [message #33855] Thu, 15 May 2003 19:19 Go to next message
Eclipse UserFriend
Originally posted by: wgyun.hotmail.com

Hi there,
I'm writing a new import wizard to import a java file into my
project(basicly copy the file into Eclipse and refresh the parent folder). I
thought once I imported the java file, I should be able to get the compiled
class file as well, but it seemed to be not the case, the build process was
postponed somehow, and when I tried to get the class file, it couldn't be
found. So my question is if I can synchronize the build process before I
tried to access the compiled class file. Put in another way, can I start the
build process programmatically and wait for the build process to complete
before I do another dependent task? I appreciate your help a lot!
Thanks!
Re: Is there a way I can get Eclipse "build" the java file I just imported at when I want? [message #33890 is a reply to message #33855] Thu, 15 May 2003 19:09 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Olivier_Thomann.ca.ibm.comNOSPAM

On Thu, 15 May 2003 15:19:43 -0400, "Cindy Wen" <wgyun@hotmail.com>
wrote:
>I'm writing a new import wizard to import a java file into my
>project(basicly copy the file into Eclipse and refresh the parent folder). I
>thought once I imported the java file, I should be able to get the compiled
>class file as well, but it seemed to be not the case, the build process was
>postponed somehow, and when I tried to get the class file, it couldn't be
>found. So my question is if I can synchronize the build process before I
>tried to access the compiled class file. Put in another way, can I start the
>build process programmatically and wait for the build process to complete
>before I do another dependent task? I appreciate your help a lot!
>Thanks!
You should refresh your project. I guess the file you copied in your
project is out of sync. Then there is no delta sent for its addition
and therefore no build.
--
Olivier
Re: Is there a way I can get Eclipse "build" the java file I just imported at when I want? [message #34261 is a reply to message #33890] Thu, 15 May 2003 20:36 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wgyun.hotmail.com

Sorry, I may not stated it clearly, the project did get refreshed but before
I tried to
access the class file, the code is something like this:

public ImportJava implements IRunnableWithProgress
{
...
ProjectUtil.copyFile(javaf, destpath);

final IResource resource = project;
display.syncExec(new Runnable()
{
public void run()
{
try
{
resource.refreshLocal(IResource.DEPTH_ONE, null);
}
catch (CoreException e)
{
WebServicesPlugin.log(e);
}
}
});

// Problem is in here, try to access the binary of the import java file
but find nothing
...
// however, once this thread is run through, the binary file is there
}
my question is whether I can synchronize the build process(just like what I
did to synchronize the refresh process which didn't work for build process)
before I try to access the build result?
Thanks for your reply!

"Olivier Thomann" <Olivier_Thomann@ca.ibm.comNOSPAM> wrote in message
news:kep7cvgojhi42rk3eeviqcdfrftiqscg22@4ax.com...
> On Thu, 15 May 2003 15:19:43 -0400, "Cindy Wen" <wgyun@hotmail.com>
> wrote:
> >I'm writing a new import wizard to import a java file into my
> >project(basicly copy the file into Eclipse and refresh the parent
folder). I
> >thought once I imported the java file, I should be able to get the
compiled
> >class file as well, but it seemed to be not the case, the build process
was
> >postponed somehow, and when I tried to get the class file, it couldn't be
> >found. So my question is if I can synchronize the build process before I
> >tried to access the compiled class file. Put in another way, can I start
the
> >build process programmatically and wait for the build process to complete
> >before I do another dependent task? I appreciate your help a lot!
> >Thanks!
> You should refresh your project. I guess the file you copied in your
> project is out of sync. Then there is no delta sent for its addition
> and therefore no build.
> --
> Olivier
Re: Is there a way I can get Eclipse "build" the java file I just imported at when I want? [message #34398 is a reply to message #33855] Thu, 15 May 2003 20:46 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: knut_radloff.oti.com

"Cindy Wen" <wgyun@hotmail.com> wrote in message news:ba0oel$qdd$1@rogue.oti.com...
> found. So my question is if I can synchronize the build process before I
> tried to access the compiled class file. Put in another way, can I start the
> build process programmatically and wait for the build process to complete
> before I do another dependent task? I appreciate your help a lot!

Try doing the refresh in a WorkspaceModifyOperation. That should trigger a build.
Here's an example I stole from Workbench.enableAutoBuild:

WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
protected void execute(IProgressMonitor monitor) throws CoreException {
monitor.setTaskName("task name");
//do refresh local here
}
};
IWorkbenchWindow window = getActiveWorkbenchWindow();
if (window != null)
window.run(true, true, op);
else
new ProgressMonitorDialog(shell).run(true, true, op);

Knut
Re: Is there a way I can get Eclipse "build" the java file I just imported at when I want? [message #34565 is a reply to message #34398] Thu, 15 May 2003 21:18 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.nos.pam.us.ibm.com

but remember that the build won't kick off until AFTER the workspace
modify operation is returned from. That's part of the reason for the
operation, to allow changes to be batch together without doing a build
on each modification.

Rich
Re: Is there a way I can get Eclipse "build" the java file I just imported at when I want? [message #45953 is a reply to message #34261] Fri, 23 May 2003 14:43 Go to previous message
Eclipse UserFriend
Originally posted by: John_Arthorne.oti.com_

Jumping in the conversation a bit late, but I thought I'd point out that
the code snippet below is wrong. It is using syncExec to execute the
refresh in the UI thread. This is generally the exact opposite of what
you want to do. Long running work like refresh and build should NOT
happen in the UI thread, because this will freeze the UI and prevent paints.

To answer your original question, you can force a build using the
methods IWorkspace.build or IProject.build. I generally wouldn't
recommend doing this though, since if the user has chosen to turn off
builds, they will be pretty annoyed if you force a build on them.
--


Cindy Wen wrote:
> Sorry, I may not stated it clearly, the project did get refreshed but before
> I tried to
> access the class file, the code is something like this:
>
> public ImportJava implements IRunnableWithProgress
> {
> ...
> ProjectUtil.copyFile(javaf, destpath);
>
> final IResource resource = project;
> display.syncExec(new Runnable()
> {
> public void run()
> {
> try
> {
> resource.refreshLocal(IResource.DEPTH_ONE, null);
> }
> catch (CoreException e)
> {
> WebServicesPlugin.log(e);
> }
> }
> });
>
> // Problem is in here, try to access the binary of the import java file
> but find nothing
> ...
> // however, once this thread is run through, the binary file is there
> }
Previous Topic:Virtual Table
Next Topic:Get IResource of currently open file?
Goto Forum:
  


Current Time: Wed Feb 05 17:01:35 GMT 2025

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

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

Back to the top