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