You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

BrowserBuildProgressMonitor.java 3.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /********************************************************************
  2. * Copyright (c) 2007 Contributors. All rights reserved.
  3. * This program and the accompanying materials are made available
  4. * under the terms of the Eclipse Public License v 2.0
  5. * which accompanies this distribution and is available at
  6. * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt
  7. *
  8. * Contributors: IBM Corporation - initial API and implementation
  9. * Helen Hawkins - initial version (bug 148190)
  10. *******************************************************************/
  11. package org.aspectj.tools.ajbrowser.core;
  12. import javax.swing.JDialog;
  13. import org.aspectj.ajde.Ajde;
  14. import org.aspectj.ajde.core.IBuildProgressMonitor;
  15. import org.aspectj.ajde.ui.swing.BuildProgressPanel;
  16. import org.aspectj.tools.ajbrowser.BrowserManager;
  17. import org.aspectj.tools.ajbrowser.ui.BrowserMessageHandler;
  18. import org.aspectj.tools.ajbrowser.ui.swing.TopFrame;
  19. /**
  20. * Build progress monitor that shows the progress in a dialog containing
  21. * a JProgressBar. Also updates the progress bar at the bottom of AjBrowser
  22. * with the build progress information.
  23. */
  24. public class BrowserBuildProgressMonitor extends Thread implements IBuildProgressMonitor {
  25. public static final String PROGRESS_HEADING = "AspectJ Build";
  26. private BuildProgressPanel progressDialog = null;
  27. private JDialog dialog = null;
  28. private TopFrame topFrame;
  29. private BrowserMessageHandler handler;
  30. public BrowserBuildProgressMonitor(BrowserMessageHandler handler) {
  31. this.handler = handler;
  32. topFrame = (TopFrame) BrowserManager.getDefault().getRootFrame();
  33. dialog = new JDialog(topFrame, PROGRESS_HEADING, false);
  34. progressDialog = new BuildProgressPanel();
  35. dialog.setContentPane(progressDialog);
  36. dialog.setSize(550, 120);
  37. try {
  38. dialog.setLocationRelativeTo(topFrame);
  39. } catch (NoSuchMethodError nsme) {
  40. // running on 1.3
  41. }
  42. }
  43. public void finish(boolean wasFullBuild) {
  44. Ajde.getDefault().getIdeUIAdapter().displayStatusInformation("build finished...");
  45. progressDialog.finish();
  46. dialog.dispose();
  47. if (handler.getMessages().isEmpty()) {
  48. topFrame.hideMessagesPanel(handler);
  49. } else {
  50. topFrame.showMessagesPanel(handler);
  51. }
  52. }
  53. public boolean isCancelRequested() {
  54. boolean isCancel = progressDialog.isCancelRequested();
  55. if (isCancel) {
  56. Ajde.getDefault().getIdeUIAdapter().displayStatusInformation("Compile aborted");
  57. }
  58. return isCancel;
  59. }
  60. public void setProgress(double percentDone) {
  61. progressDialog.setProgressBarVal((int) (percentDone*progressDialog.getProgressBarMax()));
  62. }
  63. public void setProgressText(String text) {
  64. Ajde.getDefault().getIdeUIAdapter().displayStatusInformation(text);
  65. progressDialog.setProgressText(text);
  66. }
  67. public void begin() {
  68. Ajde.getDefault().getIdeUIAdapter().displayStatusInformation("starting build...");
  69. handler.reset();
  70. progressDialog.setProgressBarVal(0);
  71. progressDialog.setProgressText("starting build...");
  72. dialog.setLocationRelativeTo(Ajde.getDefault().getRootFrame());
  73. dialog.setVisible(true);
  74. }
  75. }