001: /**
002: * Caption: Zaval Java Resource Editor
003: * $Revision: 0.37 $
004: * $Date: 2002/03/28 9:24:42 $
005: *
006: * @author: Victor Krapivin
007: * @version: 2.0
008: *
009: * Zaval JRC Editor is a visual editor which allows you to manipulate
010: * localization strings for all Java based software with appropriate
011: * support embedded.
012: *
013: * For more info on this product read Zaval Java Resource Editor User's Guide
014: * (It comes within this package).
015: * The latest product version is always available from the product's homepage:
016: * http://www.zaval.org/products/jrc-editor/
017: * and from the SourceForge:
018: * http://sourceforge.net/projects/zaval0002/
019: *
020: * Contacts:
021: * Support : support@zaval.org
022: * Change Requests : change-request@zaval.org
023: * Feedback : feedback@zaval.org
024: * Other : info@zaval.org
025: *
026: * Copyright (C) 2001-2004 Zaval Creative Engineering Group (http://www.zaval.org)
027: *
028: * This program is free software; you can redistribute it and/or
029: * modify it under the terms of the GNU General Public License
030: * (version 2) as published by the Free Software Foundation.
031: *
032: * This program is distributed in the hope that it will be useful,
033: * but WITHOUT ANY WARRANTY; without even the implied warranty of
034: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
035: * GNU General Public License for more details.
036: *
037: * You should have received a copy of the GNU General Public License
038: * along with this program; if not, write to the Free Software
039: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
040: *
041: */package org.zaval.tools.i18n.translator;
042:
043: import org.zaval.awt.*;
044: import org.zaval.awt.dialog.*;
045:
046: import java.io.File;
047: import java.awt.*;
048: import java.util.*;
049:
050: public class ReplaceDialog extends EditDialog {
051: IERadioButton regex;
052: IERadioButton exact;
053: IERadioButton cg2[];
054:
055: IECheckbox cases;
056: IECheckbox prompt;
057: IECheckbox all;
058: EmulatedTextField replaceTo;
059: IELabel label;
060:
061: public void setReplaceLabel(String s) {
062: label.setText(s);
063: }
064:
065: public void setRMGroupLabels(String s1, String s3) {
066: regex.setLabel(s1);
067: exact.setLabel(s3);
068: }
069:
070: public void setCPALabels(String s1, String s2, String s3) {
071: cases.setLabel(s1);
072: prompt.setLabel(s2);
073: all.setLabel(s3);
074: }
075:
076: public boolean isExactMatching() {
077: return exact.getState();
078: }
079:
080: public boolean isRegexMatching() {
081: return regex.getState();
082: }
083:
084: public boolean isCaseSensitive() {
085: return cases.getState();
086: }
087:
088: public boolean isPromptRequired() {
089: return prompt.getState();
090: }
091:
092: public boolean isReplaceAll() {
093: return all.getState();
094: }
095:
096: public String getReplaceTo() {
097: return replaceTo.getText();
098: }
099:
100: public ReplaceDialog(Frame f, String s, boolean b, Component l) {
101: super (f, s, b, l);
102:
103: cg2 = new IERadioButton[2];
104: cg2[0] = regex = new IERadioButton("", false);
105: cg2[1] = exact = new IERadioButton("", true);
106: cases = new IECheckbox("");
107: cases.setState(true);
108: prompt = new IECheckbox("");
109: prompt.setState(true);
110: all = new IECheckbox("");
111: all.setState(false);
112:
113: label = new IELabel("To:");
114: replaceTo = new EmulatedTextField(20);
115: constrain(this , label, 0, 1, 1, 1, GridBagConstraints.NONE,
116: GridBagConstraints.WEST, 0.0, 0.0, 0, 5, 5, 5);
117: constrain(this , replaceTo, 1, 1, 1, 1,
118: GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST,
119: 1.0, 0.0, 0, 5, 5, 0);
120:
121: Panel p = new Panel();
122: p.setLayout(new GridBagLayout());
123:
124: Panel p2 = new BorderedPanel();
125: p2.setLayout(new GridBagLayout());
126: constrain(p2, exact, 1, 0, 1, 1, GridBagConstraints.NONE,
127: GridBagConstraints.NORTHWEST, 0.0, 0.0, 0, 5, 5, 0);
128: constrain(p2, regex, 1, 1, 1, 1, GridBagConstraints.NONE,
129: GridBagConstraints.NORTHWEST, 0.0, 0.0, 0, 5, 5, 0);
130: constrain(p, p2, 0, 1, 2, 1, GridBagConstraints.BOTH,
131: GridBagConstraints.NORTHWEST, 1.0, 1.0, 5, 0, 0, 0);
132:
133: constrain(p, cases, 0, 2, 2, 1, GridBagConstraints.NONE,
134: GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 0);
135: constrain(p, prompt, 0, 3, 2, 1, GridBagConstraints.NONE,
136: GridBagConstraints.NORTHWEST, 0.0, 0.0, 0, 5, 5, 0);
137: constrain(p, all, 0, 4, 2, 1, GridBagConstraints.NONE,
138: GridBagConstraints.NORTHWEST, 0.0, 0.0, 0, 5, 5, 5);
139:
140: constrain(this , p, 0, 2, 2, 1, GridBagConstraints.BOTH,
141: GridBagConstraints.NORTHWEST, 1.0, 1.0, 5, 5, 5, 5);
142: }
143:
144: private void applyTo(IERadioButton[] group, IERadioButton b) {
145: int j;
146: for (j = 0; j < group.length; ++j)
147: if (group[j] == b)
148: break;
149: if (j >= group.length)
150: return;
151: for (j = 0; j < group.length; ++j)
152: if (group[j] != b)
153: group[j].setState(false);
154: }
155:
156: public boolean action(Event evt, Object what) {
157: if (evt.target instanceof IERadioButton) {
158: applyTo(cg2, (IERadioButton) evt.target);
159: return true;
160: }
161: return super.action(evt, what);
162: }
163: }
|