Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Technology Project and PMC » Problem about User Feedback for Finished Jobs
Problem about User Feedback for Finished Jobs [message #601016] Wed, 16 August 2006 09:47
Cagatay is currently offline Cagatay
Messages: 17
Registered: July 2009
Junior Member
Hello,
I have used the code given in an Eclipse article to give feedback to the
user for finished jobs. But I have a problem.
http://www.eclipse.org/articles/Article-Concurrency/jobs-api .html

When the build job finishes, MessageDialog is shown to give "Your build
process completed" message to the user but it disappears quickly. So,user
can not notice that window. It is shown using asynchExec method but it can
not appear until user presses OK button. I want to show it until the user
presses OK button. So, user will understand from that window that build
completed.
When the window is shown to the user (within milisecs), the thread goes
out from run() method and that window is disposed I think.

Do you have any suggestion to fix this error?

Thank you,
Best wishes
Cagatay

public class BuildJob extends Job {

public BuildJob(String aName) {
super(aName);
}

public IStatus run(IProgressMonitor monitor)
{
try {
String as[] = new String[3];
as[0] = "make";
as[1] = "-f";
as[2] = "Makefile";

ProcessBuilder pb = new ProcessBuilder(as);
Map<String,String> env = pb.environment();
env.put("PATH",env.get("PATH")+":"+/opt/ed";

long start = new Date().getTime();
monitor.beginTask("Building projectnow...",350000);

long current;
int workedTotal = 0;
final Process p = pb.start();
boolean isExited = false;

while(!isExited){
//update the progess bar
current = new Date().getTime();
int workQuant = (int) (current-start-workedTotal);
workedTotal += workQuant;
monitor.subTask("Total: "+workedTotal+" seconds");
monitor.worked(workQuant);

try{
p.exitValue();
isExited = true;
}
catch( IllegalThreadStateException IE){
Thread.sleep(2000);
}
finally
{
if(monitor.isCanceled()){
System.out.println("canceled!!!");
p.destroy();
return Status.CANCEL_STATUS;
}

}

}
monitor.done();
System.out.println("Build finished!!!");
}
catch (Exception e) {
IsyaPlugin.logError("Error ");
}

//inform user about the finish of Project
setProperty(IProgressConstants.ICON_PROPERTY,getName());
if (isModal(this)) {
// if it is modal, it was not run in background.
// The progress dialog is still open so just open the message
showResults();
}
else {
setProperty(IProgressConstants.KEEP_PROPERTY,Boolean.TRUE);

setProperty(IProgressConstants.ACTION_PROPERTY,getBuildCompl etedAction());
}
return Status.OK_STATUS;
}


public boolean isModal(BuildJob job) {
Boolean isModal =
(Boolean)job.getProperty(IProgressConstants.PROPERTY_IN_DIAL OG);
if(isModal == null)
return false;
return isModal.booleanValue();
}

protected static void showResults() {
int i=0;
Display.getDefault().asyncExec(new Runnable() {
public void run() {
getBuildCompletedAction().run();
}
});
}

protected static Action getBuildCompletedAction() {
return new Action("View build status") {
public void run() {
MessageDialog.openInformation(Display.getDefault().getActive Shell(),
"Build Complete",
"Your build process completed!");
}
};
}

}
Previous Topic:CVS merge problem
Next Topic:Problem about User Feedback for Finished Jobs
Goto Forum:
  


Current Time: Fri Aug 01 18:46:06 EDT 2014

Powered by FUDForum. Page generated in 0.01753 seconds