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.Constants;
021: import gruntspud.GruntspudContext;
022: import gruntspud.ResourceUtil;
023: import gruntspud.ui.OptionDialog;
024: import gruntspud.ui.OutputOptionWrapperPanel;
025: import gruntspud.ui.UIUtil;
026: import gruntspud.ui.commandoptions.ImportOptionsPane;
027: import gruntspud.ui.report.FileInfoPane;
028: import gruntspud.ui.report.ImportFileInfoPane;
029:
030: import java.awt.Component;
031: import java.awt.event.ActionEvent;
032: import java.util.ResourceBundle;
033:
034: import org.netbeans.lib.cvsclient.command.Command;
035:
036: /**
037: * Action to import files from the local filing system to a remote CVS repository
038: *
039: * @author magicthize
040: */
041: public class ImportAction extends ColoredReportingGruntspudAction {
042: static ResourceBundle res = ResourceBundle
043: .getBundle("gruntspud.actions.ResourceBundle");
044:
045: /**
046: * Constructor for the ImportAction object
047: *
048: * @param host host
049: * @param context context
050: */
051: public ImportAction(GruntspudContext context) {
052: super (res, "importAction", context);
053: putValue(GruntspudAction.ICON, UIUtil
054: .getCachedIcon(Constants.ICON_TOOL_IMPORT));
055: putValue(DefaultGruntspudAction.SMALL_ICON, UIUtil
056: .getCachedIcon(Constants.ICON_TOOL_SMALL_IMPORT));
057: setUpdatesFiles(false);
058: }
059:
060: /*
061: * (non-Javadoc)
062: *
063: * @see gruntspud.actions.GruntspudAction#checkAvailable()
064: */
065: public boolean checkAvailable() {
066: return !CVSCommandHandler.getInstance().isCommandRunning();
067: }
068:
069: /*
070: * (non-Javadoc)
071: *
072: * @see gruntspud.actions.ReportingGruntspudAction#createFileInfoPane()
073: */
074: public FileInfoPane createFileInfoPane() {
075: return new ImportFileInfoPane(getContext());
076:
077: }
078:
079: /*
080: * (non-Javadoc)
081: *
082: * @see gruntspud.actions.ReportingGruntspudAction#getFileInfoName()
083: */
084: public String getFileInfoName() {
085: return "importFileInfo";
086: }
087:
088: /*
089: * (non-Javadoc)
090: *
091: * @see gruntspud.actions.ReportingGruntspudAction#getFileInfoText()
092: */
093: public String getFileInfoText() {
094: return res.getString("importAction.fileInfoText");
095: }
096:
097: /*
098: * (non-Javadoc)
099: *
100: * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
101: */
102: public void actionPerformed(final ActionEvent evt) {
103: Component parent = getParentComponentForEvent(evt);
104: final ImportOptionsPane pane = new ImportOptionsPane(
105: getContext());
106: pane.setControlButtonsAreShown(false);
107: final OptionDialog.Option ok = new OptionDialog.Option(
108: res
109: .getString("importAction.optionDialog.option.ok.text"),
110: res
111: .getString("importAction.optionDialog.option.ok.toolTipText"),
112: ResourceUtil.getResourceMnemonic(res,
113: "importAction.optionDialog.option.ok.mnemonic"));
114: final OptionDialog.Option cancel = new OptionDialog.Option(
115: res
116: .getString("importAction.optionDialog.option.cancel.text"),
117: res
118: .getString("importAction.optionDialog.option.cancel.toolTipText"),
119: ResourceUtil
120: .getResourceMnemonic(res,
121: "importAction.optionDialog.option.cancel.mnemonic"));
122:
123: OptionDialog.Option opt = OptionDialog.showOptionDialog(
124: "import", getContext(), parent,
125: new OptionDialog.Option[] { ok, cancel },
126: new OutputOptionWrapperPanel(getContext(), pane, this ,
127: "history"), res
128: .getString("importAction.optionDialog.title"),
129: ok, new OptionDialog.Callback() {
130: public boolean canClose(OptionDialog dialog,
131: OptionDialog.Option option) {
132: return (option == cancel)
133: || pane.validateOptions();
134: }
135: });
136:
137: if (opt != ok) {
138: return;
139: }
140:
141: pane.applyOptions();
142:
143: final Command[] cmd = pane.getCommandsForSettings();
144: CVSCommandHandler.getInstance().runCommandGroup(parent,
145: getContext(), pane.getSelectedFile(), cmd, null, null,
146: false, pane.getIgnoreFileFilter(), pane.getProfile(),
147: this, getEnabledOptionalListeners());
148: }
149: }
|