/plugins/P4Plugin/tags/p4_0_3_0/p4plugin/action/P4FileInfoAction.java

#
Java | 80 lines | 38 code | 14 blank | 28 comment | 3 complexity | 144948b4112e73f62c5f8e40ed5beff0 MD5 | raw file

✨ Summary
  1. /*
  2. * :tabSize=4:indentSize=4:noTabs=true:
  3. * :folding=explicit:collapseFolds=1:
  4. *
  5. * (c) 2005 Marcelo Vanzin
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  20. */
  21. package p4plugin.action;
  22. import java.awt.event.ActionEvent;
  23. import org.gjt.sp.jedit.jEdit;
  24. import projectviewer.vpt.VPTNode;
  25. import p4plugin.Perforce;
  26. import p4plugin.config.P4GlobalConfig;
  27. /**
  28. * Calls a customizable p4 command to show information about a file.
  29. *
  30. * @author Marcelo Vanzin
  31. * @version $Id: P4FileInfoAction.java 9143 2007-03-15 05:47:31Z vanza $
  32. * @since P4P 0.1
  33. */
  34. public class P4FileInfoAction extends AsyncP4Action {
  35. private String path;
  36. private String cmd;
  37. public P4FileInfoAction(String cmd) {
  38. super(getActionName(cmd, false), false);
  39. this.cmd = cmd;
  40. }
  41. protected String getCommand() {
  42. return cmd;
  43. }
  44. protected String[] getArgs(ActionEvent ae) {
  45. return new String[] { path };
  46. }
  47. public void actionPerformed(ActionEvent ae) {
  48. path = viewer.getSelectedNode().getNodePath();
  49. super.actionPerformed(ae);
  50. }
  51. public void prepareForNode(VPTNode node) {
  52. getMenuItem().setVisible(node != null && node.isFile());
  53. }
  54. /** Shows the output in a dialog. */
  55. protected void postProcess(Perforce p4) {
  56. if ("diff".equals(getCommand()) &&
  57. P4GlobalConfig.getInstance().getIgnoreDiffOutput())
  58. {
  59. return;
  60. }
  61. String title =
  62. jEdit.getProperty("p4plugin.action." + getCommand() + ".title",
  63. new String[] { path });
  64. showOutputDialog(p4, title);
  65. }
  66. }