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: BranchFileAction.java$
021: * $FileID: 4578$
022: *
023: * Last change:
024: * $AuthorName: Rob MacGrogan$
025: * $Date: 8/1/03 1:24 PM$
026: * $Comment: Use new BranchFilesDialog.$
027: */
028:
029: package org.sourcejammer.client.gui.action;
030:
031: import java.awt.event.ActionEvent;
032:
033: import javax.swing.AbstractAction;
034:
035: import org.sourcejammer.client.DisplayTextLibrary;
036: import org.sourcejammer.client.SourceJammerClient;
037: import org.sourcejammer.client.gui.CommandCentral;
038: import org.sourcejammer.client.gui.MessageBoxUtil;
039: import org.sourcejammer.client.gui.ProjectTreeNode;
040: import org.sourcejammer.client.gui.dialog.BranchFilesDialog;
041: import org.sourcejammer.client.gui.dialog.CheckInFilesDialog;
042: import org.sourcejammer.client.gui.dialog.ClickValues;
043: import org.sourcejammer.client.gui.icons.IconBank;
044: import org.sourcejammer.client.plugin.EventTimingType;
045: import org.sourcejammer.project.view.NodeInfo;
046: import org.sourcejammer.project.view.SJRequest;
047:
048: /**
049: * Title: $FileName: BranchFileAction.java$
050: * @version $VerNum: 7$
051: * @author $AuthorName: Rob MacGrogan$<br><br>
052: *
053: * $Description: Action for branching files.$<br>
054: * $KeyWordsOff: $<br>
055: */
056: public class BranchFileAction extends AbstractAction {
057:
058: public BranchFileAction() {
059: super (DisplayTextLibrary
060: .displayText(DisplayTextLibrary.ACT_BRANCH_FILE),
061: IconBank.getInstance().getIcon(IconBank.BLANK_TOOL));
062: }
063:
064: /**
065: * @see java.awt.event.ActionListener#actionPerformed(ActionEvent)
066: */
067: public void actionPerformed(ActionEvent ev) {
068: try {
069: CommandCentral cmd = CommandCentral.getInstance();
070:
071: SJRequest request = cmd.getBaseRequest();
072: SourceJammerClient.getInstance().getFileListeners()
073: .notifyFileBranched(request, ev,
074: EventTimingType.BEFORE_EVENT, null);
075:
076: NodeInfo[] selectedFiles = cmd.getSelectedFilesNodeInfo();
077: String[] saSelectedFiles = cmd.getSelectedFileNames();
078: ProjectTreeNode parent = cmd.getCurrentTreeNode();
079:
080: System.out.println("About to create dialog.");
081: BranchFilesDialog dialog = new BranchFilesDialog(
082: cmd.getRootAppFrame(),
083: saSelectedFiles,
084: DisplayTextLibrary
085: .displayText(DisplayTextLibrary.ACT_BRANCH_FILE));
086:
087: System.out.println("About to show dialog.");
088: dialog.showDialog(cmd.getRootAppFrame());
089: if (dialog.getButtonClicked() == ClickValues.OK_BUTTON_CLICKED) {
090: for (int i = 0; i < selectedFiles.length; i++) {
091: if (selectedFiles[i].isShared()) {
092: cmd.branchFile(selectedFiles[i], parent
093: .getProject().getUniqueID(), dialog
094: .getComment(), dialog.getIdentifier(),
095: request);
096: }
097: }
098: //Update current tree node.
099: ActionCentral.getInstance().fireActionThisThread(
100: Actions.act_REFRESH_PROJECT);
101: }
102:
103: SourceJammerClient.getInstance().getFileListeners()
104: .notifyFileBranched(request, ev,
105: EventTimingType.AFTER_EVENT, null);
106:
107: } catch (Exception ex) {
108: MessageBoxUtil.displayErrorMessage(ex.getMessage(), true);
109: }
110: }
111:
112: }
|