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.DirectoryDetailsPane;
025: import gruntspud.ui.OptionDialog;
026: import gruntspud.ui.UIUtil;
027: import gruntspud.ui.report.FileDetailsPane;
028: import gruntspud.ui.view.ViewManager;
029:
030: import java.awt.event.ActionEvent;
031: import java.util.ResourceBundle;
032:
033: import javax.swing.JComponent;
034:
035: /**
036: * Action to show various details about the selection, such as file size, modification times, permissions and CVS related
037: * information (where applicable) such as tags, keyword substitution mode etc
038: *
039: * @author magicthize
040: */
041: public class DetailsAction extends DefaultGruntspudAction {
042: static ResourceBundle res = ResourceBundle
043: .getBundle("gruntspud.actions.ResourceBundle");
044:
045: /**
046: * Constructor for the DetailsAction object
047: */
048: public DetailsAction(GruntspudContext context) {
049: super (res, "detailsAction", context);
050: putValue(GruntspudAction.ICON, UIUtil
051: .getCachedIcon(Constants.ICON_TOOL_DETAILS));
052: putValue(DefaultGruntspudAction.SMALL_ICON, UIUtil
053: .getCachedIcon(Constants.ICON_TOOL_SMALL_DETAILS));
054: }
055:
056: /*
057: * (non-Javadoc)
058: *
059: * @see gruntspud.actions.GruntspudAction#checkAvailable()
060: */
061: public boolean checkAvailable() {
062: ViewManager mg = getContext().getViewManager();
063: CVSFileNode[] sel = mg.getSelectedNodes();
064:
065: return !CVSCommandHandler.getInstance().isCommandRunning()
066: && mg.isHomeExists()
067: && ((sel != null) && (sel.length == 1));
068: }
069:
070: /*
071: * (non-Javadoc)
072: *
073: * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
074: */
075: public void actionPerformed(final ActionEvent evt) {
076: final JComponent parent = getContext().getHost()
077: .getMainComponent();
078: final CVSFileNode sel = getContext().getViewManager()
079: .getSelectedNode();
080: JComponent c = sel.isLeaf() ? (JComponent) (new FileDetailsPane(
081: getContext(), sel))
082: : ((JComponent) new DirectoryDetailsPane(sel,
083: getContext()));
084: OptionDialog.Option close = new OptionDialog.Option(
085: res
086: .getString("detailsAction.optionDialog.option.close.text"),
087: res
088: .getString("detailsAction.optionDialog.option.close.toolTipText"),
089: ResourceUtil
090: .getResourceMnemonic(res,
091: "detailsAction.optionDialog.option.close.mnemonic"));
092: OptionDialog.Option opt = OptionDialog.showOptionDialog(
093: "details", getContext(), parent,
094: new OptionDialog.Option[] { close }, c, res
095: .getString("detailsAction.optionDialog.title"),
096: close, new OptionDialog.Callback() {
097: public boolean canClose(OptionDialog dialog,
098: OptionDialog.Option option) {
099: return true;
100: }
101: }
102:
103: , true, true);
104:
105: if (c instanceof DirectoryDetailsPane) {
106: ((DirectoryDetailsPane) c).cleanUp();
107: }
108: }
109: }
|