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

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