001: /*
002: * Copyright (C) 2001, 2002 Robert MacGrogan
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2.1 of the License, or (at your option) any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: *
018: *
019: * $Archive: SourceJammer$
020: * $FileName: UndoCheckOutAction.java$
021: * $FileID: 4066$
022: *
023: * Last change:
024: * $AuthorName: Rob MacGrogan$
025: * $Date: 6/24/03 12:56 AM$
026: * $Comment: Moved message box/error dialog methods to MessageBoxUtil.$
027: */
028:
029: package org.sourcejammer.client.gui.action;
030:
031: import org.sourcejammer.client.DisplayTextLibrary;
032: import org.sourcejammer.client.SourceJammerClient;
033:
034: import java.awt.event.ActionEvent;
035: import java.awt.Cursor;
036: import javax.swing.*;
037: import org.sourcejammer.client.gui.dialog.UndoCheckOutDialog;
038: import org.sourcejammer.client.gui.CommandCentral;
039: import org.sourcejammer.client.gui.MessageBoxUtil;
040: import org.sourcejammer.client.gui.dialog.ClickValues;
041: import org.sourcejammer.client.gui.ProjectTreeNode;
042: import org.sourcejammer.project.view.NodeName;
043: import org.sourcejammer.project.view.SJRequest;
044: import org.sourcejammer.client.gui.GuiUtil;
045: import org.sourcejammer.client.gui.icons.IconBank;
046: import org.sourcejammer.client.plugin.EventTimingType;
047:
048: /**
049: * Title: $FileName: UndoCheckOutAction.java$
050: * @version $VerNum: 5$
051: * @author $AuthorName: Rob MacGrogan$<br><br>
052: *
053: * $Description: $<br>
054: * $KeyWordsOff: $<br>
055: */
056: public class UndoCheckOutAction extends AbstractAction implements
057: ClickValues {
058:
059: public UndoCheckOutAction() {
060: super (DisplayTextLibrary.getInstance().getDisplayText(
061: DisplayTextLibrary.ACT_UNDO_CHECKOUT), IconBank
062: .getInstance().getIcon(IconBank.BLANK_TOOL));
063: }
064:
065: public void actionPerformed(ActionEvent ev) {
066: try {
067: CommandCentral oCommand = CommandCentral.getInstance();
068: SJRequest request = oCommand.getBaseRequest();
069:
070: SourceJammerClient.getInstance().getFileListeners()
071: .notifyFileCheckeOutUndone(request, ev,
072: EventTimingType.BEFORE_EVENT, null);
073:
074: String[] saSelectedFiles = oCommand.getSelectedFileNames();
075:
076: int iNumFiles = saSelectedFiles.length;
077: if (iNumFiles > 0) {
078: int iClick = UndoCheckOutDialog.showDialog(
079: saSelectedFiles, oCommand.getRootAppFrame());
080: if (iClick == OK_BUTTON_CLICKED) {
081:
082: ProjectTreeNode ndSelected = oCommand
083: .getCurrentTreeNode();
084: NodeName ndName = ndSelected.getNodeName();
085: java.io.File flDefaultDirectory = oCommand
086: .getGuiConf().getDefaultWorkingDirectory(
087: ndName);
088: oCommand
089: .getRootAppFrame()
090: .setCursor(
091: Cursor
092: .getPredefinedCursor(Cursor.WAIT_CURSOR));
093: for (int i = 0; i < iNumFiles; i++) {
094: long lFileID = ndSelected
095: .getFileUniqueIDFromName(saSelectedFiles[i]);
096: oCommand.undoCheckOut(lFileID,
097: saSelectedFiles[i], flDefaultDirectory,
098: request);
099: }
100: ActionCentral.getInstance().fireAction(
101: ActionCentral.act_REFRESH_PROJECT);
102: }//end if clicked OK
103: }//end if files are selected
104: else {
105: MessageBoxUtil
106: .displayWarningMessage("Please select the file or files you want to check out.");
107: }
108: SourceJammerClient.getInstance().getFileListeners()
109: .notifyFileCheckeOutUndone(request, null,
110: EventTimingType.AFTER_EVENT, null);
111: } catch (Exception ex) {
112: MessageBoxUtil.displayErrorMessage(ex.getMessage(), true);
113: } finally {
114: CommandCentral.getInstance().getRootAppFrame().setCursor(
115: Cursor.getDefaultCursor());
116: }
117: }
118: }
|