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: RebuildLabelAction.java$
021: * $FileID: 4056$
022: *
023: * Last change:
024: * $AuthorName: Rob MacGrogan$
025: * $Date: 9/1/03 9:26 PM$
026: * $Comment: Debug.$
027: */
028:
029: package org.sourcejammer.client.gui.action;
030:
031: import java.awt.event.ActionEvent;
032: import javax.swing.*;
033: import org.sourcejammer.client.DisplayTextLibrary;
034: import org.sourcejammer.client.gui.CommandCentral;
035: import org.sourcejammer.client.gui.dialog.InputBox;
036: import org.sourcejammer.client.gui.process.ProcessCentral;
037: import org.sourcejammer.client.gui.process.info.LabelProcessInfo;
038: import org.sourcejammer.project.view.NodeInfo;
039: import java.awt.Cursor;
040: import org.sourcejammer.util.BadMethodArgumentException;
041: import org.sourcejammer.util.AppConfig;
042: import org.sourcejammer.client.gui.MessageBoxUtil;
043: import org.sourcejammer.client.gui.ProjectTreeNode;
044: import org.sourcejammer.client.gui.GuiUtil;
045:
046: /**
047: * Title: $FileName: RebuildLabelAction.java$
048: * @author $AuthorName: Rob MacGrogan$
049: * @version $VerNum: 5$<br><br>
050: *
051: * $Description: $
052: * $KeyWordsOff: $<br><br>
053: */
054: public class RebuildLabelAction extends AbstractAction {
055:
056: public RebuildLabelAction() {
057: super (
058: DisplayTextLibrary
059: .displayText(DisplayTextLibrary.ACT_REBUILD_LABELED_VER));
060: }
061:
062: public void actionPerformed(ActionEvent parm1) {
063: try {
064: CommandCentral central = CommandCentral.getInstance();
065: NodeInfo[] labels = central.getSelectedFilesNodeInfo();
066: if (labels.length > 1) {
067: throw new BadMethodArgumentException(
068: DisplayTextLibrary
069: .displayText(DisplayTextLibrary.ERR_NO_SEL_LABEL));
070: } else if (labels.length == 0) {
071: throw new BadMethodArgumentException(
072: DisplayTextLibrary
073: .displayText(DisplayTextLibrary.ERR_SEL_ONE_FILE));
074: }
075: NodeInfo label = labels[0];
076: if (label.getFileType() != AppConfig.FileTypes.LABEL) {
077: throw new BadMethodArgumentException(DisplayTextLibrary
078: .displayText(DisplayTextLibrary.ERR_NOT_LABEL));
079: }
080: long labelID = label.getUniqueID();
081: ProjectTreeNode ndParent = central.getCurrentTreeNode();
082: long parentID = ndParent.getProject().getUniqueID();
083:
084: String[] saInputLabels = {
085: DisplayTextLibrary
086: .displayText(DisplayTextLibrary.LBL_DESCRIPTION),
087: DisplayTextLibrary
088: .displayText(DisplayTextLibrary.LBL_BUILD_CHANGELIST) };
089: InputBox.FieldType[] types = new InputBox.FieldType[2];
090: types[0] = InputBox.FieldType.TEXT;
091: types[1] = InputBox.FieldType.CHECKBOX;
092:
093: String[] saValues = MessageBoxUtil
094: .displayInputBox(
095: saInputLabels,
096: null,
097: types,
098: DisplayTextLibrary
099: .displayText(DisplayTextLibrary.LBL_REBUILD_LABEL),
100: true,
101: DisplayTextLibrary
102: .displayText(DisplayTextLibrary.BTN_MAKE));
103: if (saValues != null) {
104: String sDescription = saValues[0];
105:
106: LabelProcessInfo info = new LabelProcessInfo();
107: info.setLabelID(labelID);
108: info.setParentID(parentID);
109: info.setDescription(sDescription);
110:
111: String sBuildChangelist = saValues[1];
112: boolean buildChangeList = (Boolean
113: .valueOf(sBuildChangelist)).booleanValue();
114: info.setBuildChangeList(buildChangeList);
115:
116: ProcessCentral.getInstance().fireProcess(
117: ProcessCentral.prs_REBUILD_LABEL, info);
118: }
119: } catch (Exception ex) {
120: MessageBoxUtil.displayErrorMessage(ex.getMessage(), true);
121: }
122: }
123: }
|