001: /*
002: * Gruntspud
003: *
004: * Copyright (C) 2002 Brett Smith.
005: *
006: * Written by: Brett Smith <t_magicthize@users.sourceforge.net>
007: *
008: * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public
009: * License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
010: * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details.
012: *
013: * You should have received a copy of the GNU Library General Public License along with this program; if not, write to the Free
014: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
015: */
016:
017: package gruntspud.actions;
018:
019: import gruntspud.CVSCommandHandler;
020: import gruntspud.CVSFileNode;
021: import gruntspud.Constants;
022: import gruntspud.GruntspudContext;
023: import gruntspud.ResourceUtil;
024: import gruntspud.ui.OptionDialog;
025: import gruntspud.ui.UIUtil;
026: import gruntspud.ui.ignore.IgnoreFilePane;
027:
028: import java.awt.event.ActionEvent;
029: import java.util.ResourceBundle;
030:
031: import javax.swing.JComponent;
032:
033: /**
034: * Action to show the ignore file editor.
035: *
036: * @author magicthize
037: */
038: public class IgnoreAction extends DefaultGruntspudAction {
039: static ResourceBundle res = ResourceBundle
040: .getBundle("gruntspud.actions.ResourceBundle");
041:
042: /**
043: * Constructor for the IgnoreAction object
044: *
045: * @param context context
046: */
047: public IgnoreAction(GruntspudContext context) {
048: super (res, "ignoreAction", context);
049: putValue(GruntspudAction.ICON, UIUtil
050: .getCachedIcon(Constants.ICON_TOOL_IGNORE));
051: putValue(DefaultGruntspudAction.SMALL_ICON, UIUtil
052: .getCachedIcon(Constants.ICON_TOOL_SMALL_IGNORE));
053: }
054:
055: /*
056: * (non-Javadoc)
057: *
058: * @see gruntspud.actions.GruntspudAction#checkAvailable()
059: */
060: public boolean checkAvailable() {
061: return !CVSCommandHandler.getInstance().isCommandRunning();
062: }
063:
064: /*
065: * (non-Javadoc)
066: *
067: * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
068: */
069: public void actionPerformed(final ActionEvent evt) {
070: CVSFileNode s = getContext().getViewManager().getSelectedNode();
071: if ((s != null) && s.isLeaf() && (s.getParent() != null)) {
072: s = (CVSFileNode) s.getParent();
073: }
074: OptionDialog.Option ok = new OptionDialog.Option(
075: res
076: .getString("ignoreAction.optionDialog.option.ok.text"),
077: res
078: .getString("ignoreAction.optionDialog.option.ok.toolTipText"),
079: ResourceUtil.getResourceMnemonic(res,
080: "ignoreAction.optionDialog.option.ok.mnemonic"));
081: OptionDialog.Option cancel = new OptionDialog.Option(
082: res
083: .getString("ignoreAction.optionDialog.option.cancel.text"),
084: res
085: .getString("ignoreAction.optionDialog.option.cancel.toolTipText"),
086: ResourceUtil
087: .getResourceMnemonic(res,
088: "ignoreAction.optionDialog.option.cancel.mnemonic"));
089: final JComponent parent = getContext().getHost()
090: .getMainComponent();
091: final IgnoreFilePane ignorePane = new IgnoreFilePane(
092: getContext(), (s == null) ? null : s.getFile());
093: OptionDialog.Option opt = OptionDialog.showOptionDialog(
094: "ignoreList", getContext(), parent,
095: new OptionDialog.Option[] { ok, cancel }, ignorePane,
096: res.getString("ignoreAction.optionDialog.title"), ok,
097: new OptionDialog.Callback() {
098: public boolean canClose(OptionDialog dialog,
099: OptionDialog.Option option) {
100: return ignorePane.validateTabs();
101: }
102: });
103:
104: if (opt != ok) {
105: return;
106: }
107: ignorePane.applyTabs();
108: getContext().getViewManager().reloadTree();
109: }
110: }
|