001: /*
002: * Enhydra Java Application Server Project
003: *
004: * The contents of this file are subject to the Enhydra Public License
005: * Version 1.1 (the "License"); you may not use this file except in
006: * compliance with the License. You may obtain a copy of the License on
007: * the Enhydra web site ( http://www.enhydra.org/ ).
008: *
009: * Software distributed under the License is distributed on an "AS IS"
010: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
011: * the License for the specific terms governing rights and limitations
012: * under the License.
013: *
014: * The Initial Developer of the Enhydra Application Server is Lutris
015: * Technologies, Inc. The Enhydra Application Server and portions created
016: * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
017: * All Rights Reserved.
018: *
019: * Contributor(s):
020: * Paul Mahar
021: *
022: */
023: package org.enhydra.kelp.common.deployer;
024:
025: // ToolBox imports
026: import org.enhydra.tool.ToolBoxInfo;
027: import org.enhydra.tool.common.IconSet;
028: import org.enhydra.tool.common.ToolException;
029: import org.enhydra.tool.configure.ConfigTool;
030:
031: // Kelp imports
032: import org.enhydra.kelp.common.Backward;
033: import org.enhydra.kelp.common.PathUtil;
034: import org.enhydra.kelp.common.event.SwingTableSelectionEvent;
035: import org.enhydra.kelp.common.event.SwingTableSelectionListener;
036: import org.enhydra.kelp.common.node.OtterTemplateNode;
037: import org.enhydra.kelp.common.node.OtterNode;
038: import org.enhydra.kelp.common.node.OtterProject;
039:
040: // Standard imports
041: import java.awt.*;
042: import java.awt.event.ActionEvent;
043: import java.awt.event.ActionListener;
044: import java.beans.*;
045: import java.util.ResourceBundle;
046: import java.util.ArrayList;
047: import java.util.Arrays;
048: import java.util.Vector;
049: import javax.swing.*;
050: import javax.swing.event.ListSelectionEvent;
051: import javax.swing.event.ListSelectionListener;
052: import javax.swing.table.AbstractTableModel;
053: import javax.swing.table.DefaultTableModel;
054:
055: //
056: public class ReplacementTablePanel extends JPanel implements
057: ListSelectionListener, SwingTableSelectionListener {
058: static ResourceBundle res = ResourceBundle
059: .getBundle("org.enhydra.kelp.common.Res"); // nores
060: private OtterNode node = null;
061: private GridBagLayout layoutMain;
062: private JTable table;
063: private JScrollPane scrollTable;
064: private JButton buttonAdd;
065: private JButton buttonEdit;
066: private JButton buttonRemove;
067: private JButton buttonReset;
068: private JButton buttonUp;
069: private JButton buttonDown;
070: private LocalButtonListener buttonListener;
071: private LocalTableModel tableModel = new LocalTableModel();
072: private int currentSelectionIndex = -1;
073: private SwingTableSelectionListener[] swingTableSelectionListeners = new SwingTableSelectionListener[0];
074:
075: public ReplacementTablePanel() {
076: try {
077: jbInit();
078: pmInit();
079: } catch (Exception e) {
080: e.printStackTrace();
081: }
082: }
083:
084: public void clearAll() {
085: buttonAdd.removeActionListener(buttonListener);
086: buttonEdit.removeActionListener(buttonListener);
087: buttonReset.removeActionListener(buttonListener);
088: buttonRemove.removeActionListener(buttonListener);
089: buttonUp.removeActionListener(buttonListener);
090: buttonDown.removeActionListener(buttonListener);
091: removeSwingTableSelectionListener(this );
092: table.getSelectionModel().removeListSelectionListener(this );
093: tableModel.removeTableModelListener(table);
094: tableModel.removeAllRows();
095: table.setModel(new DefaultTableModel());
096: removeAll();
097: tableModel = null;
098: buttonListener = null;
099: node = null;
100: swingTableSelectionListeners = null;
101: }
102:
103: /**
104: * ListSelectionListener event
105: */
106: public void valueChanged(ListSelectionEvent e) {
107: ListSelectionModel lsm = (ListSelectionModel) e.getSource();
108:
109: if (lsm.isSelectionEmpty()) {
110: currentSelectionIndex = -1;
111: } else {
112: currentSelectionIndex = lsm.getMinSelectionIndex();
113: }
114: fireSwingTableSelectionEvent();
115: }
116:
117: private void fireSwingTableSelectionEvent() {
118: for (int i = 0; i < swingTableSelectionListeners.length; i++) {
119: swingTableSelectionListeners[i]
120: .onSwingTableSelection(new SwingTableSelectionEvent(
121: this , currentSelectionIndex));
122: }
123: }
124:
125: public synchronized void addSwingTableSelectionListener(
126: SwingTableSelectionListener l) {
127: ArrayList list = null;
128:
129: list = new ArrayList(Arrays
130: .asList(swingTableSelectionListeners));
131: if (!list.contains(l)) {
132: list.add(l);
133: list.trimToSize();
134: swingTableSelectionListeners = new SwingTableSelectionListener[list
135: .size()];
136: swingTableSelectionListeners = (SwingTableSelectionListener[]) list
137: .toArray(swingTableSelectionListeners);
138: }
139: list.clear();
140: }
141:
142: public synchronized void removeSwingTableSelectionListener(
143: SwingTableSelectionListener l) {
144: ArrayList list = null;
145:
146: list = new ArrayList(Arrays
147: .asList(swingTableSelectionListeners));
148: if (list.contains(l)) {
149: list.remove(l);
150: list.trimToSize();
151: swingTableSelectionListeners = new SwingTableSelectionListener[list
152: .size()];
153: swingTableSelectionListeners = (SwingTableSelectionListener[]) list
154: .toArray(swingTableSelectionListeners);
155: }
156: list.clear();
157: }
158:
159: public void onSwingTableSelection(SwingTableSelectionEvent event) {
160: boolean selection = (!event.isSelectionNull());
161:
162: buttonEdit.setEnabled(selection);
163: buttonRemove.setEnabled(selection);
164: if (selection) {
165: int index = event.getSelectionIndex();
166: boolean down = (index < tableModel.getRowCount() - 1);
167: boolean up = (index > 0);
168:
169: buttonUp.setEnabled(up);
170: buttonDown.setEnabled(down);
171: } else {
172: buttonUp.setEnabled(false);
173: buttonDown.setEnabled(false);
174: }
175: }
176:
177: public OtterNode getNode() {
178: return node;
179: }
180:
181: public void setNode(OtterNode n) {
182: node = n;
183: }
184:
185: public void setIconView(boolean b) {
186: if (b) {
187: buttonAdd.setIcon(IconSet.getNewRowIcon());
188: buttonAdd.setText(new String());
189: buttonDown.setIcon(IconSet.getDownIcon());
190: buttonDown.setText(new String());
191: buttonEdit.setIcon(IconSet.getRowIcon());
192: buttonEdit.setText(new String());
193: buttonUp.setIcon(IconSet.getUpIcon());
194: buttonUp.setText(new String());
195: buttonRemove.setIcon(IconSet.getDeleteRowIcon());
196: buttonRemove.setText(new String());
197: buttonReset.setIcon(IconSet.getUndoIcon());
198: buttonReset.setText(new String());
199: } else {
200: buttonAdd.setIcon(null);
201: buttonAdd.setText(res.getString("buttonAdd_Text"));
202: buttonDown.setIcon(null);
203: buttonDown.setText(res.getString("buttonDown_Text"));
204: buttonEdit.setIcon(null);
205: buttonEdit.setText(res.getString("Edit"));
206: buttonUp.setIcon(null);
207: buttonUp.setText(res.getString("buttonUp_Text"));
208: buttonRemove.setIcon(null);
209: buttonRemove.setText(res.getString("Remove"));
210: buttonReset.setIcon(null);
211: buttonReset.setText(res.getString("buttonReset_Text"));
212: }
213: }
214:
215: public boolean isIconView() {
216: return (buttonAdd.getIcon() == null);
217: }
218:
219: public void readProperties() {
220: OtterProject project = null;
221:
222: if (node == null) {
223: System.err
224: .println("ReplacementTablePanel.readProperties(): node is null");
225: } else {
226: project = node.getProject();
227: if (node instanceof OtterTemplateNode) {
228: } else {
229: enableUI(true);
230: }
231: if (project.isDefaultProject()) {
232: buttonAdd.setEnabled(false);
233: buttonDown.setEnabled(false);
234: buttonUp.setEnabled(false);
235: buttonReset.setEnabled(false);
236: } else {
237: setReplacementTable(project.getReplacementTable());
238: }
239: }
240: invalidate();
241: }
242:
243: public void writeProperties() {
244: OtterProject project = null;
245:
246: if (node == null) {
247: System.err
248: .println("ReplacementTablePanel.writeProperties() - node null");
249: return;
250: } else {
251: project = node.getProject();
252: }
253: if (project.isDefaultProject()) {
254:
255: // done
256: } else {
257: project.setReplacementTable(getReplacementTable());
258: }
259: }
260:
261: public boolean isDataEqual() {
262: String[][] projReps = new String[0][0];
263: String[][] memReps = new String[0][0];
264: boolean equal = false;
265: OtterProject project = null;
266:
267: if (node == null) {
268: System.err
269: .println("ReplacementTablePanel.isDataEqual(): node is null");
270: } else {
271: project = node.getProject();
272: projReps = project.getReplacementTable();
273: memReps = getReplacementTable();
274: if (projReps.length == memReps.length) {
275: equal = true;
276: for (int i = 0; i < memReps.length; i++) {
277: if (equal
278: && (projReps[i].length == memReps[i].length)) {
279: for (int j = 0; j < memReps[i].length; j++) {
280: if (projReps[i][j].equals(memReps[i][j])) {
281: } else {
282: equal = false;
283: break;
284: }
285: }
286: } else {
287: equal = false;
288: break;
289: }
290: }
291: }
292: }
293: return equal;
294: }
295:
296: public void enableUI(boolean enable) {
297: table.setEnabled(enable);
298: buttonAdd.setEnabled(enable);
299: buttonEdit.setEnabled(currentSelectionIndex > -1);
300: buttonRemove.setEnabled(currentSelectionIndex > -1);
301: buttonReset.setEnabled(enable);
302: }
303:
304: //
305: //
306: private String[][] getReplacementTable() {
307: String[][] repTable = null;
308: LocalRow row = null;
309: int length = tableModel.getRowCount();
310:
311: repTable = new String[length][2];
312: for (int i = 0; i < length; i++) {
313: row = tableModel.getRow(i);
314: repTable[i][0] = row.getFind();
315: repTable[i][1] = row.getReplaceWith();
316: }
317: return repTable;
318: }
319:
320: private void setReplacementTable(String[][] repTable) {
321: tableModel.removeAllRows();
322: for (int i = 0; i < repTable.length; i++) {
323: tableModel.addRow(repTable[i][0], repTable[i][1]);
324: }
325: removeTableSelections();
326: }
327:
328: private void removeTableSelections() {
329: if (table.getSelectedRow() > -1) {
330: table.removeRowSelectionInterval(table.getSelectedRow(),
331: table.getSelectedRow());
332: }
333: currentSelectionIndex = -1;
334: fireSwingTableSelectionEvent();
335: table.updateUI();
336: }
337:
338: private void defaultTable() {
339: int result = JOptionPane.YES_OPTION;
340:
341: if (tableModel.getRowCount() > 0) {
342: result = JOptionPane.showConfirmDialog(this , res
343: .getString("Replace_current_set"), res
344: .getString("Switch_to_Default"),
345: JOptionPane.YES_NO_OPTION);
346: }
347: if (result == JOptionPane.YES_OPTION) {
348: OtterProject project = node.getProject();
349: String[][] def = new String[0][0];
350:
351: try {
352: def = ConfigTool.createReplacementStringArray(project
353: .getRootPath(), project.getDeployRootPath(),
354: ToolBoxInfo.getJavaPath());
355: def = Backward.createReplacementTable(def, PathUtil
356: .getInputTemplates(project));
357: } catch (ToolException e) {
358: def = new String[0][0];
359: e.printStackTrace();
360: }
361: setReplacementTable(def);
362: }
363: }
364:
365: private void addRow() {
366: ReplaceEditorDialog d = null;
367:
368: if (getTopLevelAncestor() instanceof JDialog) {
369: JDialog parentDialog = (JDialog) this .getTopLevelAncestor();
370:
371: d = new ReplaceEditorDialog(parentDialog, res
372: .getString("Add_Replace_Text"), true);
373: d.setFind(new String());
374: d.setReplaceWith(new String());
375: d.show();
376: if (d.getOption() == ReplaceEditorDialog.ACTION_OK) {
377: if (d.getFind().trim().length() > 0) {
378: tableModel.addRow(d.getFind(), d.getReplaceWith());
379: removeTableSelections();
380: }
381: }
382: }
383: }
384:
385: private void removeCurrent() {
386: int result = 0;
387:
388: if (currentSelectionIndex > -1
389: && currentSelectionIndex < tableModel.getRowCount()) {
390: result = JOptionPane.showConfirmDialog(this , res
391: .getString("Remove_current"), res
392: .getString("Confirm_Remove"),
393: JOptionPane.YES_NO_OPTION);
394: if (result == JOptionPane.YES_OPTION) {
395: tableModel.removeRow(currentSelectionIndex);
396: removeTableSelections();
397: }
398: }
399: }
400:
401: private void editCurrent() {
402: ReplaceEditorDialog d = null;
403: LocalRow row = tableModel.getRow(currentSelectionIndex);
404:
405: if (getTopLevelAncestor() instanceof JDialog) {
406: JDialog parentDialog = (JDialog) this .getTopLevelAncestor();
407:
408: d = new ReplaceEditorDialog(parentDialog, res
409: .getString("Edit_Replace_Text"), true);
410: d.setFind(row.getFind());
411: d.setReplaceWith(row.getReplaceWith());
412: d.show();
413: if (d.getOption() == ReplaceEditorDialog.ACTION_OK) {
414: if (d.getFind().trim().length() > 0) {
415: row.setFind(d.getFind());
416: row.setReplaceWith(d.getReplaceWith());
417: table.updateUI();
418: }
419: }
420: }
421: }
422:
423: private void moveRowUp() {
424: tableModel.moveUp(currentSelectionIndex);
425: table.updateUI();
426: }
427:
428: private void moveRowDown() {
429: tableModel.moveDown(currentSelectionIndex);
430: table.updateUI();
431: }
432:
433: private void pmInit() throws Exception {
434: buttonEdit.setEnabled(false);
435: buttonEdit.setToolTipText(res
436: .getString("buttonEdit_ToolTipText"));
437: buttonRemove.setEnabled(false);
438: buttonRemove.setToolTipText(res
439: .getString("buttonRemove_ToolTipText"));
440: buttonListener = new LocalButtonListener();
441: buttonAdd.addActionListener(buttonListener);
442: buttonAdd
443: .setToolTipText(res.getString("buttonAdd_ToolTipText"));
444: buttonEdit.addActionListener(buttonListener);
445: buttonReset.addActionListener(buttonListener);
446: buttonReset.setToolTipText(res
447: .getString("buttonReset_ToolTipText"));
448: buttonRemove.addActionListener(buttonListener);
449: buttonUp.addActionListener(buttonListener);
450: buttonUp.setToolTipText(res.getString("buttonUp_ToolTipText"));
451: buttonDown.addActionListener(buttonListener);
452: buttonDown.setToolTipText(res
453: .getString("buttonDown_ToolTipText"));
454: tableModel = new LocalTableModel();
455: table.setModel(tableModel);
456:
457: // table.setDefaultRenderer(String.class, new CellRendererWithToolTip());
458: tableModel.addTableModelListener(table);
459: table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
460: table.getTableHeader().setUpdateTableInRealTime(false);
461: table.getTableHeader().setReorderingAllowed(false);
462: ListSelectionModel rowSM = table.getSelectionModel();
463:
464: rowSM.addListSelectionListener(this );
465: addSwingTableSelectionListener(this );
466: setIconView(false);
467: }
468:
469: private void jbInit() throws Exception {
470: layoutMain = (GridBagLayout) Beans.instantiate(getClass()
471: .getClassLoader(), GridBagLayout.class.getName());
472: table = (JTable) Beans.instantiate(getClass().getClassLoader(),
473: JTable.class.getName());
474: buttonAdd = (JButton) Beans.instantiate(getClass()
475: .getClassLoader(), JButton.class.getName());
476: buttonEdit = (JButton) Beans.instantiate(getClass()
477: .getClassLoader(), JButton.class.getName());
478: buttonRemove = (JButton) Beans.instantiate(getClass()
479: .getClassLoader(), JButton.class.getName());
480: buttonReset = (JButton) Beans.instantiate(getClass()
481: .getClassLoader(), JButton.class.getName());
482: buttonUp = (JButton) Beans.instantiate(getClass()
483: .getClassLoader(), JButton.class.getName());
484: buttonDown = (JButton) Beans.instantiate(getClass()
485: .getClassLoader(), JButton.class.getName());
486: scrollTable = new JScrollPane(table);
487: table.setToolTipText(new String());
488: table.sizeColumnsToFit(JTable.AUTO_RESIZE_ALL_COLUMNS);
489: table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
490: table.setColumnSelectionAllowed(false);
491: scrollTable.setMinimumSize(new Dimension(300, 100));
492: scrollTable.setPreferredSize(new Dimension(300, 100));
493: scrollTable.getViewport().add(table, BorderLayout.CENTER);
494:
495: //
496: this .setLayout(layoutMain);
497: this .add(scrollTable, new GridBagConstraints(3, 0, 6, 1, 0.8,
498: 0.2, GridBagConstraints.CENTER,
499: GridBagConstraints.BOTH, new Insets(0, 0, 5, 0), 0, 0));
500: this .add(buttonAdd, new GridBagConstraints(3, 1, 1, 1, 0.1,
501: 0.0, GridBagConstraints.CENTER,
502: GridBagConstraints.NONE, new Insets(2, 1, 5, 1), 0, 0));
503: this .add(buttonEdit, new GridBagConstraints(4, 1, 1, 1, 0.1,
504: 0.0, GridBagConstraints.CENTER,
505: GridBagConstraints.NONE, new Insets(2, 1, 5, 1), 0, 0));
506: this .add(buttonRemove, new GridBagConstraints(5, 1, 1, 1, 0.1,
507: 0.0, GridBagConstraints.CENTER,
508: GridBagConstraints.NONE, new Insets(2, 1, 5, 1), 0, 0));
509: this .add(buttonReset, new GridBagConstraints(8, 1, 1, 1, 0.1,
510: 0.0, GridBagConstraints.CENTER,
511: GridBagConstraints.NONE, new Insets(2, 1, 5, 1), 0, 0));
512: this .add(buttonUp, new GridBagConstraints(6, 1, 1, 1, 0.1, 0.0,
513: GridBagConstraints.CENTER, GridBagConstraints.NONE,
514: new Insets(2, 1, 5, 1), 0, 0));
515: this .add(buttonDown, new GridBagConstraints(7, 1, 1, 1, 0.1,
516: 0.0, GridBagConstraints.CENTER,
517: GridBagConstraints.NONE, new Insets(2, 1, 5, 1), 0, 0));
518: }
519:
520: //
521: private class LocalButtonListener implements ActionListener {
522: public void actionPerformed(ActionEvent e) {
523: Object source = e.getSource();
524:
525: if (source == buttonReset) {
526: defaultTable();
527: } else if (source == buttonRemove) {
528: removeCurrent();
529: } else if (source == buttonAdd) {
530: addRow();
531: } else if (source == buttonEdit) {
532: editCurrent();
533: } else if (source == buttonUp) {
534: moveRowUp();
535: } else if (source == buttonDown) {
536: moveRowDown();
537: }
538: }
539:
540: }
541:
542: //
543: private class LocalTableModel extends AbstractTableModel {
544: private Vector rowVector = new Vector();
545:
546: public LocalTableModel() {
547: }
548:
549: public int getRowCount() {
550: int count = 0;
551:
552: if (rowVector != null) {
553: count = rowVector.size();
554: }
555: return count;
556: }
557:
558: public int getColumnCount() {
559: return 2;
560: }
561:
562: public String getColumnName(int columnIndex) {
563: String name = new String();
564:
565: switch (columnIndex) {
566: case 0:
567: name = res.getString("Text_to_find");
568: break;
569: case 1:
570: name = res.getString("Replace_with");
571: break;
572: }
573: return name;
574: }
575:
576: public Class getColumnClass(int columnIndex) {
577: Class columnClass = null;
578: Object value = getValueAt(0, columnIndex);
579:
580: if (value != null) {
581: columnClass = value.getClass();
582: }
583: return columnClass;
584: }
585:
586: public boolean isCellEditable(int rowIndex, int columnIndex) {
587: return false;
588: }
589:
590: public Object getValueAt(int rowIndex, int columnIndex) {
591: Object value = null;
592:
593: if (!isTableEmpty()) {
594: LocalRow row = (LocalRow) rowVector.elementAt(rowIndex);
595: LocalCell cell = new LocalCell(columnIndex, row);
596:
597: value = cell.getValue();
598: }
599: return value;
600: }
601:
602: public void setValueAt(Object aValue, int rowIndex,
603: int columnIndex) {
604: if (!isTableEmpty()) {
605: LocalRow row = (LocalRow) rowVector.elementAt(rowIndex);
606: LocalCell cell = new LocalCell(columnIndex, row);
607:
608: cell.setValue(aValue);
609: fireTableCellUpdated(columnIndex, rowIndex);
610: }
611: }
612:
613: protected LocalRow getRow(int rowIndex) {
614: LocalRow row = null;
615:
616: if (!isTableEmpty()) {
617: if (rowVector.size() > rowIndex) {
618: row = (LocalRow) rowVector.elementAt(rowIndex);
619: }
620: }
621: return row;
622: }
623:
624: protected void saveMap() {
625: OtterProject project = node.getProject();
626: int rowCount = rowVector.size();
627: String[][] map = new String[rowCount][2];
628: LocalRow row = null;
629:
630: for (int i = 0; i < rowCount; i++) {
631: row = (LocalRow) rowVector.elementAt(i);
632: map[i][0] = row.getFind();
633: map[i][1] = row.getReplaceWith();
634: }
635: project.setPackageMap(map);
636: }
637:
638: protected void populateModel() {
639: OtterProject project = node.getProject();
640: String[][] map = project.getPackageMap();
641:
642: if (map != null) {
643: int rowCount = map.length;
644:
645: for (int i = 0; i < rowCount; i++) {
646: addRow(map[i][0], map[i][1]);
647: }
648: }
649: }
650:
651: // /
652: // /
653: private boolean isTableEmpty() {
654: boolean empty = true;
655:
656: if (rowVector != null) {
657: if (rowVector.size() > 0) {
658: empty = false;
659: }
660: }
661: return empty;
662: }
663:
664: private void addRow(String f, String p) {
665: LocalRow newRow = null;
666:
667: newRow = new LocalRow(f, p);
668: rowVector.addElement(newRow);
669: fireTableDataChanged();
670: }
671:
672: private void removeRow(int index) {
673: if (index < rowVector.size()) {
674: rowVector.removeElementAt(index);
675: fireTableDataChanged();
676: }
677: }
678:
679: private void moveUp(int index) {
680: if (index > 0 && index < rowVector.size()) {
681: Object current = rowVector.elementAt(index);
682: Object previous = rowVector.elementAt(index - 1);
683:
684: rowVector.setElementAt(current, index - 1);
685: rowVector.setElementAt(previous, index);
686: fireTableDataChanged();
687: }
688: }
689:
690: private void moveDown(int index) {
691: if (index < (rowVector.size() - 1)) {
692: Object current = rowVector.elementAt(index);
693: Object next = rowVector.elementAt(index + 1);
694:
695: rowVector.setElementAt(current, index + 1);
696: rowVector.setElementAt(next, index);
697: fireTableDataChanged();
698: }
699: }
700:
701: private void removeAllRows() {
702: rowVector.removeAllElements();
703: fireTableDataChanged();
704: }
705:
706: }
707:
708: //
709: private class LocalRow {
710: private String find = new String();
711: private String replaceWith = new String();
712:
713: public LocalRow(String f, String rw) {
714: find = f;
715: replaceWith = rw;
716: }
717:
718: public String getFind() {
719: return find;
720: }
721:
722: public void setFind(String f) {
723: find = f;
724: saveToProject();
725: }
726:
727: public String getReplaceWith() {
728: return replaceWith;
729: }
730:
731: public void setReplaceWith(String rw) {
732: replaceWith = rw;
733: saveToProject();
734: }
735:
736: private void saveToProject() {
737: }
738:
739: }
740:
741: //
742: private class LocalCell {
743: private LocalRow row;
744: private int column;
745:
746: public LocalCell(int c, LocalRow r) {
747: column = c;
748: row = r;
749: }
750:
751: public boolean setValue(Object value) {
752: boolean set = true;
753:
754: switch (column) {
755: case 0:
756: row.setFind((String) value);
757: break;
758: case 1:
759: row.setReplaceWith((String) value);
760: break;
761: default:
762: set = false;
763: break;
764: }
765: return set;
766: }
767:
768: public Object getValue() {
769: Object value = null;
770:
771: switch (column) {
772: case 0:
773: value = row.getFind();
774: break;
775: case 1:
776: value = row.getReplaceWith();
777: break;
778: }
779: return value;
780: }
781:
782: //
783: //
784: protected LocalRow getRow() {
785: return row;
786: }
787:
788: }
789: }
|