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.

DefaultBuildProgressMonitor.java 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* *******************************************************************
  2. * Copyright (c) 1999-2001 Xerox Corporation,
  3. * 2002 Palo Alto Research Center, Incorporated (PARC).
  4. * All rights reserved.
  5. * This program and the accompanying materials are made available
  6. * under the terms of the Eclipse Public License v 2.0
  7. * which accompanies this distribution and is available at
  8. * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt
  9. *
  10. * Contributors:
  11. * Xerox/PARC initial implementation
  12. * Helen Hawkins Converted to new interface (bug 148190)
  13. * ******************************************************************/
  14. package org.aspectj.ajde.ui.swing;
  15. import java.awt.Frame;
  16. import javax.swing.JDialog;
  17. import org.aspectj.ajde.Ajde;
  18. import org.aspectj.ajde.core.IBuildProgressMonitor;
  19. /**
  20. * This dialog box is open while ajc is compiling the system and displays
  21. * a corresponding progress bar.
  22. *
  23. * @author Mik Kersten
  24. */
  25. public class DefaultBuildProgressMonitor extends Thread implements IBuildProgressMonitor {
  26. public static final String PROGRESS_HEADING = "AspectJ Build";
  27. private BuildProgressPanel progressDialog = null;
  28. private JDialog dialog = null;
  29. public DefaultBuildProgressMonitor(Frame parent) {
  30. dialog = new JDialog(parent, PROGRESS_HEADING, false);
  31. progressDialog = new BuildProgressPanel();
  32. dialog.setContentPane(progressDialog);
  33. dialog.setSize(550, 120);
  34. try {
  35. dialog.setLocationRelativeTo(parent);
  36. } catch (NoSuchMethodError nsme) {
  37. // running on 1.3
  38. }
  39. }
  40. /**
  41. * Start the progress monitor.
  42. */
  43. public void begin() {
  44. progressDialog.setProgressBarVal(0);
  45. progressDialog.setProgressText("starting build...");
  46. dialog.setLocationRelativeTo(Ajde.getDefault().getRootFrame());
  47. dialog.setVisible(true);
  48. }
  49. /**
  50. * Sets the label describing the current progress phase.
  51. */
  52. public void setProgressText(String text) {
  53. progressDialog.setProgressText(text);
  54. }
  55. /**
  56. * Jump the progress bar to the end and finish progress monitoring.
  57. */
  58. public void finish(boolean wasFullBuild) {
  59. progressDialog.finish();
  60. dialog.dispose();
  61. }
  62. public boolean isCancelRequested() {
  63. return progressDialog.isCancelRequested();
  64. }
  65. public void setProgress(double percentDone) {
  66. progressDialog.setProgressBarVal((int) (percentDone*progressDialog.getProgressBarMax()));
  67. }
  68. }