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.

BuildConfigPopupMenu.java 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 v1.0
  7. * which accompanies this distribution and is available at
  8. * http://www.eclipse.org/legal/epl-v10.html
  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.event.ActionEvent;
  16. import java.awt.event.ActionListener;
  17. import java.util.Iterator;
  18. import java.util.List;
  19. import javax.swing.AbstractAction;
  20. import javax.swing.Icon;
  21. import javax.swing.JMenuItem;
  22. import javax.swing.JPopupMenu;
  23. import org.aspectj.ajde.Ajde;
  24. import org.aspectj.asm.IProgramElement;
  25. /**
  26. * Creates a popup menu that displays all the available .lst files. When one
  27. * is selected it runs a full build of files within the selected .lst file
  28. * in a separate thread.
  29. */
  30. public class BuildConfigPopupMenu extends JPopupMenu {
  31. private static final long serialVersionUID = -6730132748667530482L;
  32. public BuildConfigPopupMenu(final AbstractAction action) {
  33. List configFiles = Ajde.getDefault().getBuildConfigManager().getAllBuildConfigFiles();
  34. for (Object configFile : configFiles) {
  35. final String buildConfig = (String) configFile;
  36. JMenuItem buildItem = new JMenuItem(buildConfig);
  37. buildItem.setFont(AjdeWidgetStyles.DEFAULT_LABEL_FONT);
  38. buildItem.addActionListener(
  39. new ActionListener() {
  40. public void actionPerformed(ActionEvent e) {
  41. Ajde.getDefault().getBuildConfigManager().setActiveConfigFile(buildConfig);
  42. // A separate thread is required here because the buildProgresssMonitor
  43. // that monitors the build needs to be in a different thread
  44. // to that which is doing the build (swing threading issues)
  45. Ajde.getDefault().runBuildInDifferentThread(buildConfig, true);
  46. action.actionPerformed(e);
  47. }
  48. });
  49. buildItem.setIcon((Icon) Ajde.getDefault().getIconRegistry().getIcon(IProgramElement.Kind.FILE_LST).getIconResource());
  50. this.add(buildItem);
  51. }
  52. }
  53. }