Source Code Cross Referenced for RDPropertyWindow.java in  » Portal » Open-Portal » components » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » Open Portal » components 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF
003:         *  NETSCAPE COMMUNICATIONS CORPORATION
004:         *
005:         *  Copyright (c) 1996 Netscape Communications Corporation.
006:         *  All Rights Reserved.
007:         *  Use of this Source Code is subject to the terms of the applicable
008:         *  license agreement from Netscape Communications Corporation.
009:         *
010:         *                                      ==> MCW 07/97 <==
011:         */
012:
013:        package components;
014:
015:        import applications.NoSortSimpleGrid;
016:
017:        import netscape.application.Alert;
018:        import netscape.application.BezelBorder;
019:        import netscape.application.Button;
020:        import netscape.application.Bitmap;
021:        import netscape.application.Color;
022:        import netscape.application.Font;
023:        import netscape.application.FontMetrics;
024:        import netscape.application.Image;
025:        import netscape.application.InternalWindow;
026:        import netscape.application.Menu;
027:        import netscape.application.MenuItem;
028:        import netscape.application.MenuView;
029:        import netscape.application.Popup;
030:        import netscape.application.Rect;
031:        import netscape.application.ScrollGroup;
032:        import netscape.application.Size;
033:        import netscape.application.Target;
034:        import netscape.application.TextField;
035:        import netscape.application.View;
036:        import netscape.application.Window;
037:
038:        import soif.AVPairs;
039:        import soif.CSID;
040:        import soif.Schema;
041:        import soif.Search;
042:        import soif.SOIF;
043:        import soif.Taxonomy;
044:
045:        import com.indius.base.IntVector;
046:        import com.indius.base.IBorderView;
047:        import com.indius.grid.IGridEditView;
048:
049:        import communications.PostConnection;
050:
051:        import graphical.IconInternalWindow;
052:        import graphical.Minimize;
053:        import graphical.WindowTiler;
054:
055:        public class RDPropertyWindow extends IconInternalWindow implements 
056:                Target {
057:            private IBorderView m_propertyBorder;
058:
059:            private NoSortSimpleGrid editGrid;
060:            private RDPropertyGridView editView;
061:
062:            private Popup targetPopup;
063:            private int targetPopupSelected; // Selected item index, used for reset
064:
065:            private Schema m_schema;
066:            private Taxonomy m_taxonomy;
067:            private CSID m_csidIn;
068:            private CSID m_csidOut;
069:            private String m_CGILocationIn;
070:            private String m_CGILocationOut;
071:
072:            private String m_url; // Selected URL
073:            private String m_classification; // Classification from RD Editor Window
074:
075:            private boolean m_updated = false;
076:
077:            private StringBuffer m_origValues = new StringBuffer();;
078:            private StringBuffer m_currValues = new StringBuffer();
079:
080:            private int m_urlRow = -1;
081:
082:            private Target m_updateTarget; // DB Update target
083:            private String m_updateCommand; // DB Update command
084:
085:            public RDPropertyWindow(int x, int y, int w, int h, String url,
086:                    String classification, boolean editableWindow,
087:                    Schema schema, Taxonomy taxonomy, CSID csidIn,
088:                    CSID csidOut, String CGILocationIn, String CGILocationOut,
089:                    WindowTiler windowTiler) {
090:                super (x, y, w, h, null);
091:
092:                m_schema = schema;
093:                m_taxonomy = taxonomy;
094:                m_csidIn = csidIn;
095:                m_csidOut = csidOut;
096:                m_url = url;
097:                m_classification = classification;
098:                m_CGILocationIn = CGILocationIn;
099:                m_CGILocationOut = CGILocationOut;
100:
101:                // Set up window title and attributes
102:                setTitle(Messages.TITLE_PROP_WINDOW + " - " + m_url);
103:                setCloseable(true);
104:                setResizable(true);
105:                setCloseCommand(Messages.CMD_CLOSE);
106:                setCloseTarget(this );
107:                Size windowContentSize = contentSize();
108:                setWindowTiler(windowTiler);
109:
110:                // Add menu bar to window
111:                Menu menuBar = new Menu(true);
112:                MenuItem fileMenu = menuBar
113:                        .addItemWithSubmenu(Messages.MENU_FILE);
114:                MenuItem saveItem = fileMenu.submenu().addItem(
115:                        Messages.CMD_SAVE, Messages.SCUT_SAVE,
116:                        Messages.CMD_SAVE, this );
117:                saveItem.setEnabled(editableWindow);
118:                fileMenu.submenu().addSeparator();
119:                MenuItem closeItem = fileMenu.submenu().addItem(
120:                        Messages.CMD_CLOSE, Messages.SCUT_CLOSE,
121:                        Messages.CMD_CLOSE, this );
122:                /* No edit menu in beta 2
123:                 MenuItem editMenu = menuBar.addItemWithSubmenu(Messages.MENU_EDIT);
124:                 MenuItem cutItem = editMenu.submenu().addItem(Messages.CMD_EDIT_CUT,
125:                 Messages.CMD_EDIT_CUT,
126:                 this);
127:                 cutItem.setEnabled(editableWindow);
128:                 editMenu.submenu().addItem(Messages.CMD_EDIT_COPY,
129:                 Messages.CMD_EDIT_COPY,
130:                 this);
131:                 MenuItem pasteItem = editMenu.submenu().addItem(Messages.CMD_EDIT_PASTE,
132:                 Messages.CMD_EDIT_PASTE,
133:                 this);
134:                 pasteItem.setEnabled(editableWindow);
135:                 editMenu.submenu().addSeparator();
136:                 MenuItem undoItem = editMenu.submenu().addItem(Messages.CMD_EDIT_UNDO,
137:                 Messages.CMD_EDIT_UNDO,
138:                 this);
139:                 undoItem.setEnabled(editableWindow);
140:                 */
141:
142:                MenuItem valueMenu = menuBar
143:                        .addItemWithSubmenu(Messages.MENU_VALUE);
144:                MenuItem insertItem = valueMenu.submenu().addItem(
145:                        Messages.CMD_VALUE_INSERT, Messages.SCUT_VALUE_INSERT,
146:                        Messages.CMD_VALUE_INSERT, this );
147:                insertItem.setEnabled(editableWindow);
148:                MenuItem deleteItem = valueMenu.submenu().addItem(
149:                        Messages.CMD_VALUE_DELETE, Messages.SCUT_VALUE_DELETE,
150:                        Messages.CMD_VALUE_DELETE, this );
151:                deleteItem.setEnabled(editableWindow);
152:                valueMenu.submenu().addSeparator();
153:                /* Taking out select all, with Indius you can only select one row at a time
154:                 and it scrolls the selected row into view resulting in the all entries
155:                 being scrolled. It is probably not really useful anyway.
156:                 valueMenu.submenu().addItem(Messages.CMD_VALUE_SELECTALL,
157:                 Messages.SCUT_VALUE_SELECTALL,
158:                 Messages.CMD_VALUE_SELECTALL,
159:                 this);
160:                 */
161:                valueMenu.submenu().addItem(Messages.CMD_VALUE_UNSELECTALL,
162:                        Messages.SCUT_VALUE_UNSELECTALL,
163:                        Messages.CMD_VALUE_UNSELECTALL, this );
164:                MenuView menuView = new MenuView(menuBar);
165:                menuView.sizeToMinSize();
166:                setMenuView(menuView);
167:
168:                TextField displayLabel = TextField
169:                        .createLabel(Messages.LBL_DISPLAY);
170:                displayLabel.setBounds(graphical.Header.WIDGETHGAP,
171:                        graphical.Header.WIDGETVGAP
172:                                + graphical.Header.LABELBORDERGAP, displayLabel
173:                                .minSize().width,
174:                        (int) (displayLabel.minSize().height * 1.5));
175:
176:                targetPopup = new Popup(displayLabel.x() + displayLabel.width()
177:                        + graphical.Header.WIDGETHGAP, displayLabel.y(), 0, 0);
178:                targetPopup.addItem(Messages.OPT_ALL, Messages.OPT_ALL);
179:                targetPopup.addItem(Messages.OPT_EDITABLE,
180:                        Messages.OPT_EDITABLE);
181:                targetPopup.addItem(Messages.OPT_NONEDITABLE,
182:                        Messages.OPT_NONEDITABLE);
183:                targetPopup.sizeTo(targetPopup.popupList().minItemWidth() * 2,
184:                        (int) (targetPopup.popupList().minItemHeight() * 1.5));
185:                targetPopup.setTarget(this );
186:                targetPopupSelected = targetPopup.selectedIndex(); // Save initial selection
187:
188:                // Create edit view
189:                editView = new RDPropertyGridView(graphical.Header.WIDGETVGAP,
190:                        graphical.Header.WIDGETVGAP, windowContentSize.width
191:                                - graphical.Header.WIDGETVGAP,
192:                        windowContentSize.height - graphical.Header.WIDGETVGAP,
193:                        m_taxonomy);
194:                editView.setEditableFields(m_schema.getEditableString());
195:                editView.setEditableView(editableWindow);
196:                editView.setHasRowLabels(false);
197:                editView.setHasHorizGridLines(true);
198:                editView.setHasVertGridLines(true);
199:                editView.setHorizResizeInstruction(View.WIDTH_CAN_CHANGE);
200:                editView.setVertResizeInstruction(View.HEIGHT_CAN_CHANGE);
201:                editView.setHasHorizScrollBar(false);
202:                editView.setHasVertScrollBar(true);
203:                editView.setBuffered(true);
204:                editView
205:                        .setSelectBackgroundColor(graphical.Header.SELECTEDCOLOR);
206:                editView.setSelectTextColor(editView.textColor());
207:                editView.setMultiSelect(true);
208:                editView.setPopupAlways(false); // Tooltip only when too small
209:                editView.setElasticLastColumn(true);
210:
211:                populateGrid(); // Load in RD's
212:
213:                Rect r = displayLabel.bounds();
214:                editView
215:                        .moveBy(0, r.y + r.height + graphical.Header.WIDGETVGAP);
216:                editView.sizeBy(0, (0 - (r.y + r.height
217:                        + graphical.Header.WIDGETVGAP + menuView.height())));
218:
219:                // Create edit border
220:                m_propertyBorder = new IBorderView(editView.bounds());
221:                m_propertyBorder.setBorder(BezelBorder.loweredBezel());
222:                m_propertyBorder
223:                        .setHorizResizeInstruction(View.WIDTH_CAN_CHANGE);
224:                m_propertyBorder
225:                        .setVertResizeInstruction(View.HEIGHT_CAN_CHANGE);
226:
227:                // Add view to window
228:                addSubview(displayLabel);
229:                addSubview(targetPopup);
230:                m_propertyBorder.addSubview(editView);
231:                addSubview(m_propertyBorder);
232:            }
233:
234:            /**
235:             * setNewRD - redisplay window with new resource description. (MCW)
236:             **/
237:            public void setNewRD(String url, String classification) {
238:                editView.deleteGridCellEditor(true); // Destroy cell editor, save changes
239:                // Make sure we don't overwrite RD changes
240:                int answer = checkForUnsavedChanges();
241:
242:                if (answer == Header.SAVE_SAVE) { // Save
243:                    saveCommand();
244:                } else if (answer == Header.SAVE_CANCEL) { // Cancel?
245:                    return;
246:                }
247:
248:                // Save new RD attributes
249:                m_url = url;
250:                m_classification = classification;
251:
252:                // Set up window title
253:                setTitle(Messages.TITLE_PROP_WINDOW + " - " + m_url);
254:
255:                populateGrid(); // Load in RD's
256:            }
257:
258:            /**
259:             * setNewClass - RD Editor has changed the classification, this notifies the RD
260:             * the RD PropertyWindow
261:             **/
262:            public void setNewClass(String classification) {
263:                // Save new RD attributes
264:                m_classification = classification;
265:            }
266:
267:            /**
268:             * performCommand - handle menu events. (MCW)
269:             **/
270:            public void performCommand(String command, Object arg) {
271:                if (Messages.CMD_SAVE.equals(command)) {
272:                    String saveResult = saveCommand();
273:                    //            System.out.println("saveResult=======\n" + saveResult + "\n=======");
274:                    return;
275:                } else if (Messages.CMD_CLOSE.equals(command)) {
276:                    int answer = checkForUnsavedChanges();
277:
278:                    if (answer == Header.SAVE_SAVE) { // Save
279:                        saveCommand();
280:                    } else if (answer == Header.SAVE_CANCEL) { // Cancel?
281:                        return;
282:                    }
283:
284:                    hide();
285:                    return;
286:                } else if (Messages.CMD_VALUE_INSERT.equals(command)) {
287:                    insertRow();
288:                    m_updated = true;
289:                    return;
290:                } else if (Messages.CMD_VALUE_DELETE.equals(command)) {
291:                    deleteRow();
292:                    m_updated = true;
293:                    return;
294:                } else if (Messages.CMD_VALUE_SELECTALL.equals(command)) {
295:                    selectAll(true);
296:                    return;
297:                } else if (Messages.CMD_VALUE_UNSELECTALL.equals(command)) {
298:                    selectAll(false);
299:                    return;
300:                } else if ((Messages.OPT_ALL.equals(command))
301:                        || // Target popup selection
302:                        (Messages.OPT_EDITABLE.equals(command))
303:                        || (Messages.OPT_NONEDITABLE.equals(command))) {
304:                    editView.deleteGridCellEditor(true); // Destroy cell editor, save changes
305:                    // Make sure we don't overwrite RD changes
306:                    int answer = checkForUnsavedChanges();
307:
308:                    if (answer == Header.SAVE_SAVE) { // Save
309:                        saveCommand();
310:                    } else if (answer == Header.SAVE_CANCEL) { // Cancel?
311:                        targetPopup.selectItemAt(targetPopupSelected); // Restore popup selection
312:                        return;
313:                    }
314:
315:                    // Changes saved or discarded
316:                    targetPopupSelected = targetPopup.selectedIndex(); // Save new popup selection
317:                    populateGrid(); // Refresh properties window
318:                    return;
319:                }
320:
321:                super .performCommand(command, arg);
322:            }
323:
324:            /**
325:             * saveCommand - Save RD. (MCW)
326:             **/
327:            public String saveCommand() {
328:                m_origValues = new StringBuffer();
329:                StringBuffer sbReq = new StringBuffer();
330:                StringBuffer sbDoc = new StringBuffer();
331:                StringBuffer viewPairs = new StringBuffer();
332:                String label = null;
333:
334:                editView.deleteGridCellEditor(true); // Destroy cell editor, save changes
335:
336:                int rowCount = editGrid.rows();
337:
338:                rootView().setOverrideCursor(View.WAIT_CURSOR);
339:                sbReq.append("@Request { -\n"
340:                        + AVPairs.toSOIF("submit-csid", m_csidIn.toString())
341:                        + AVPairs.toSOIF("submit-type", "persistent")
342:                        + AVPairs.toSOIF("submit-operation", "merge"));
343:                sbDoc.append("\n" + "@DOCUMENT { " + m_url + "\n");
344:
345:                int multiValue = 0;
346:
347:                for (int i = 0; i < rowCount; i++) {
348:                    //            if (editView.editable(i, 2) == true) {  // Editable field?
349:                    // I only display the field name on the first or only value
350:                    // for a field. The field name column on the 2nd thru nth multiple
351:                    // values are blank. Therefore if there is a label for this field
352:                    // I have hit a new field, which may be a single or multiple value
353:                    // field.
354:
355:                    if (editGrid.getValue(i, 1).toString().length() != 0) {
356:                        label = editGrid.getValue(i, 1).toString()
357:                                .toLowerCase();
358:
359:                        // I need to format the SOIF attribute based on whether this
360:                        // is a single or multiple value field, i.e. title or
361:                        // title-1 title-2 etc.
362:                        multiValue = 0; // Reset to single value
363:
364:                        if (editView.isEditable(i) == false) {
365:                            continue;
366:                        }
367:
368:                        if (editGrid.getValue(i + 1, 1).toString().length() == 0) {
369:                            multiValue = 1; // Next entry is blank, multiple value!
370:                        }
371:
372:                        if (i > 0) { // 2nd thru nth field
373:                            viewPairs.append(","); // Add field separator
374:                        }
375:
376:                        viewPairs.append(label);
377:                    }
378:
379:                    if (editView.isEditable(i) == false) {
380:                        continue;
381:                    }
382:
383:                    m_origValues.append(editGrid.getValue(i, 2).toString());
384:
385:                    if (multiValue != 0) { // Multiple value field?
386:                        sbDoc.append(AVPairs.toSOIF(label + "-" + multiValue,
387:                                editGrid.getValue(i, 2).toString()));
388:                        multiValue++;
389:                    } else {
390:                        sbDoc.append(AVPairs.toSOIF(label, editGrid.getValue(i,
391:                                2).toString()));
392:                    }
393:                    //            }
394:                }
395:
396:                sbReq.append(AVPairs
397:                        .toSOIF("submit-view", viewPairs.toString()));
398:                sbReq.append("}\n");
399:                sbDoc.append("}\n");
400:
401:                sbReq.append(sbDoc);
402:
403:                //      System.out.println( "-----" );
404:                //      System.out.println( m_CGILocationOut + "bin/rdsubmit" );
405:                //      System.out.println( "-----" );
406:                //      System.out.println( sbReq.toString() );
407:                //      System.out.println( "-----" );
408:
409:                String result = PostConnection.doWrite(m_CGILocationOut
410:                        + "bin/rdsubmit", sbReq.toString(), true);
411:                //      System.out.println("Result=" + result);
412:                m_updateTarget.performCommand(m_updateCommand, null);
413:                editView.setUpdatedView(false); // Reset changed indicators
414:                m_updated = false;
415:                rootView().removeOverrideCursor();
416:                Alert.runAlertExternally(Alert.notificationImage(),
417:                        Messages.SAVED_RDP, "", Messages.CMD_OK, null, null);
418:                graphical.Header.showStatus(Messages.SAVED);
419:                return result;
420:            }
421:
422:            /**
423:             * insertCommand - Insert a new row after selected entries. (MCW)
424:             **/
425:            public void insertRow() {
426:                int sc = editView.selectedRowCount();
427:
428:                if (sc == 0) {
429:                    return;
430:                }
431:
432:                IntVector sr = editView.selectedRows();
433:                int firstNewRow = 0;
434:
435:                for (int i = 0; i < sc; i++) {
436:                    if (editView.isEditable(sr.elementAt(i) + i) == true) {
437:                        editGrid.insertRow(sr.elementAt(i) + 1 + i);
438:                        firstNewRow = sr.elementAt(i) + 1 + i;
439:                    }
440:                }
441:
442:                if (firstNewRow != 0) { // New row(s) added?
443:                    editView.unselectAll();
444:                    editView.adviseRowsAdded();
445:                    editView.setDirty(true);
446:                    editView.createGridCellEditor(firstNewRow, 2);
447:                }
448:            }
449:
450:            /**
451:             * deleteCommand - Delete selected entries. If it is a multiple value,
452:             * the row is deleted. If it is the first entry, the value is deleted
453:             * but the row remains. (MCW)
454:             **/
455:            public void deleteRow() {
456:                editView.deleteGridCellEditor(false); // Destroy cell editor, junk changes
457:                int sc = editView.selectedRowCount();
458:
459:                if (sc == 0) {
460:                    return;
461:                }
462:
463:                IntVector sr = editView.selectedRows();
464:                int dr = 0;
465:
466:                for (int i = 0; i < sc; i++) {
467:                    if (editView.isEditable(sr.elementAt(i) - dr) == true) {
468:                        Object valueObject = editGrid.getValue(sr.elementAt(i)
469:                                - dr, 1);
470:
471:                        if (valueObject.toString().length() == 0) {
472:                            editGrid.deleteRow(sr.elementAt(i) - dr);
473:                            dr++;
474:                        } else {
475:                            editGrid.setValue(sr.elementAt(i) - dr, 2, "");
476:                        }
477:                    }
478:                }
479:
480:                editView.unselectAll();
481:                editView.adviseRowsAdded();
482:                editView.setDirty(true);
483:            }
484:
485:            /**
486:             * selectAll - Select/Unselect all entries. (MCW)
487:             **/
488:            public void selectAll(boolean select) {
489:                if (select == false) {
490:                    editView.unselectAll();
491:                    return;
492:                }
493:
494:                disableDrawing();
495:
496:                int i = 0;
497:                int t = editGrid.rows();
498:
499:                for (; i < t; i++) {
500:                    editView.select(i, true);
501:                }
502:
503:                reenableDrawing();
504:                editView.setDirty(true);
505:            }
506:
507:            /**
508:             * populateGrid - Get current display option and refresh grid. (MCW)
509:             **/
510:            public void populateGrid() {
511:                // Get field names, display them and calculate column width
512:                // required to hold longest field name.
513:                // Create edit grid
514:
515:                String[] editableFields = null; // Editable field names
516:                String[] noneditableFields = null; // Non-Editable field names
517:
518:                editView.unselectAll(); // Remove any current selection
519:                editView.deleteGridCellEditor(true); // Destroy cell editor, save changes
520:
521:                editGrid = new NoSortSimpleGrid();
522:                editGrid.setColumnLabel(0, "");
523:                editGrid.setColumnLabel(1, Messages.LBL_FIELD);
524:                editGrid.setColumnLabel(2, Messages.LBL_VALUE);
525:
526:                int d = targetPopup.selectedIndex();
527:
528:                switch (d) {
529:                case 0:
530:                    editableFields = m_schema.getEditable();
531:                    noneditableFields = m_schema.getNonEditable();
532:                    break;
533:
534:                case 1:
535:                    editableFields = m_schema.getEditable();
536:                    break;
537:
538:                case 2:
539:                    noneditableFields = m_schema.getNonEditable();
540:                    break;
541:
542:                default:
543:                    editableFields = m_schema.getEditable();
544:                    noneditableFields = m_schema.getNonEditable();
545:                    break;
546:                }
547:
548:                // Attach new grid now so that view class has access to it.
549:                editView.setGrid(editGrid);
550:
551:                Font fieldFont = editView.font();
552:                FontMetrics fieldFontMetrics = fieldFont.fontMetrics();
553:                int fieldWidth = 0;
554:                int dispIndex = 0;
555:                m_urlRow = -1; // Def: URL not displayed
556:
557:                if (editableFields != null) {
558:                    for (int fi = 0; fi < editableFields.length; fi++, dispIndex++) {
559:                        editView.setEditableRow(dispIndex, true);
560:                        editGrid.setValue(dispIndex, 1, editableFields[fi]);
561:                        fieldWidth = Math.max(fieldWidth, fieldFontMetrics
562:                                .stringWidth(editableFields[fi]));
563:
564:                        if (editableFields[fi].equalsIgnoreCase("url") == true) {
565:                            m_urlRow = dispIndex;
566:                        }
567:                    }
568:                }
569:
570:                if (noneditableFields != null) {
571:                    for (int fi = 0; fi < noneditableFields.length; fi++, dispIndex++) {
572:                        editView.setEditableRow(dispIndex, false);
573:                        editGrid.setValue(dispIndex, 1, noneditableFields[fi]);
574:                        fieldWidth = Math.max(fieldWidth, fieldFontMetrics
575:                                .stringWidth(noneditableFields[fi]));
576:
577:                        if (noneditableFields[fi].equalsIgnoreCase("url") == true) {
578:                            m_urlRow = dispIndex;
579:                        }
580:                    }
581:                }
582:
583:                if (m_urlRow != -1) {
584:                    editView.setUrlRowColumn(m_urlRow, 2); // Set URL link cell
585:                }
586:
587:                // Set up new grid
588:                editView.adviseSetGrid();
589:
590:                // Load in values and set value column width.
591:                getAllRD(m_url);
592:
593:                // Set column width
594:                editView.setColumnWidth(0, 20);
595:                editView.setColumnWidth(1, fieldWidth + 10);
596:
597:                // These are needed to get the view to refresh properely. I thought
598:                // adviseSetGrid would be enough but it isnt. didSizeBy forces the
599:                // elastic last column to be resized and setDirty forces a repaint.
600:                editView.didSizeBy(0, 0);
601:                editView.setDirty(true);
602:            }
603:
604:            /**
605:             * getAllRD - Get all the RD fields for a specific URL and load
606:             * into the properties grid. (MCW)
607:             **/
608:            public void getAllRD(String url) {
609:                m_origValues = new StringBuffer();
610:
611:                Search search = new Search(url, "", "", 10, "url", m_csidIn,
612:                        m_CGILocationIn);
613:
614:                //        System.out.println("Query=======\n" + search.getQuery() + "\n=======");
615:
616:                search.doQuery();
617:                SOIF soif = search.getSOIFResult();
618:
619:                if (soif == null) {
620:                    // This is happening in some of the testsuite databases,
621:                    // not sure if this is an error in the test suites or not,
622:                    // but I will allow for a not found condition.
623:                    if (m_urlRow != -1) {
624:                        editGrid.setValue(m_urlRow, 2, url); // Just display URL
625:                    }
626:
627:                    Alert.runAlertExternally(Alert.notificationImage(),
628:                            Messages.TITLE_DB_EMPTY, "", Messages.CMD_OK, null,
629:                            null);
630:                    return;
631:                }
632:
633:                //        System.out.println("SOIF=======\n" + soif.toString() + "\n=======");
634:
635:                int rowCount = editGrid.rows();
636:                String soifAttr;
637:                String soifValue;
638:                int attrCount;
639:                boolean rowsAdded = false;
640:
641:                for (; soif != null; soif = soif.next) {
642:                    for (int i = 0; i < rowCount; i++) {
643:                        soifAttr = editGrid.getValue(i, 1).toString();
644:
645:                        if (soifAttr.equalsIgnoreCase("classification") == true) {
646:                            // I am displaying the classification. However the user may have changed
647:                            // the classification using the RD Editor Window drag and drop. So I
648:                            // must check the RD Editor Window classification and use that. Note
649:                            // multiple values need special handling as the RD Editor Window only
650:                            // displays the first value. I will simply ignore multiple values
651:                            // for now as the drag and drop interface in the RD Editor window
652:                            // does not support multiple values.
653:
654:                            if (m_classification
655:                                    .startsWith(Messages.TAG_MULTIVALUE) == false) {
656:                                editGrid.setValue(i, 2, m_classification);
657:                                m_origValues.append(m_classification); // For unsaved test
658:                                continue;
659:                            }
660:                        }
661:
662:                        attrCount = soif.attributeValueCount(editGrid.getValue(
663:                                i, 1).toString());
664:
665:                        if (attrCount == 1) { // Single value?
666:                            // Note: Cannot get single value with multivalue methods,
667:                            // maybe I should change that to simplfy this method.
668:                            soifValue = soif.getValue(editGrid.getValue(i, 1)
669:                                    .toString());
670:
671:                            if (soifValue != null) { // Just in case
672:                                editGrid.setValue(i, 2, soifValue);
673:
674:                                if (editView.isEditable(i) == true) { // Editable field?
675:                                    m_origValues.append(soifValue);
676:                                }
677:                            }
678:                        } else if (attrCount > 1) { // Multiple values?
679:                            for (int j = 0; j < attrCount; j++) {
680:                                soifValue = soif.getValue(soifAttr, j + 1);
681:
682:                                if (j > 0) { // Rows 2 thru n
683:                                    i++;
684:                                    rowCount++;
685:                                    rowsAdded = true;
686:                                    editGrid.insertRow(i);
687:
688:                                    if (i <= m_urlRow) { // Need to move URL row?
689:                                        m_urlRow++;
690:                                        editView.setUrlRow(m_urlRow);
691:                                    }
692:                                }
693:
694:                                if (soifValue != null) { // Just in case
695:                                    editGrid.setValue(i, 2, soifValue);
696:
697:                                    if (editView.isEditable(i) == true) { // Editable field?
698:                                        m_origValues.append(soifValue);
699:                                    }
700:                                }
701:                            }
702:                        }
703:                    }
704:                }
705:
706:                if (rowsAdded == true) {
707:                    editView.adviseRowsAdded();
708:                }
709:            }
710:
711:            /**
712:             * Will determine whether or not the RD has been changed.
713:             **/
714:            public int checkForUnsavedChanges() {
715:                int rowCount = editGrid.rows();
716:                int result = Header.SAVE_CONTINUE; // Default = continue
717:
718:                editView.deleteGridCellEditor(true); // Destroy cell editor, save changes
719:                m_currValues = new StringBuffer(); // Reset buffer
720:
721:                for (int i = 0; i < rowCount; i++) {
722:                    if (editView.isEditable(i) == true) { // Editable field?
723:                        m_currValues.append(editGrid.getValue(i, 2).toString());
724:                    }
725:                }
726:
727:                //      System.out.println("m_currValues=======\n" + m_currValues.toString() + "\n=======");
728:                //      System.out.println("m_origValues=======\n" + m_origValues.toString() + "\n=======");
729:
730:                if ((m_updated == true)
731:                        || (editView.updatedView() == true)
732:                        || (m_origValues.toString().equals(
733:                                m_currValues.toString()) == false)) {
734:                    result = Alert.runAlertExternally(
735:                            Alert.notificationImage(),
736:                            Messages.TITLE_RDP_UNSAVED, "", Messages.CMD_SAVE,
737:                            Messages.CMD_DISCARD, Messages.CMD_CANCEL);
738:                }
739:
740:                if (result == Header.SAVE_CONTINUE) { // (Continue (Discard)?
741:                    editView.setUpdatedView(false); // Reset changed indicators
742:                    m_updated = false;
743:                }
744:
745:                return result;
746:            }
747:
748:            /**
749:             * setUpdateTarget - set DB Update target.
750:             **/
751:            public void setUpdateTarget(Target target) {
752:                m_updateTarget = target;
753:            }
754:
755:            /**
756:             * setUpdateCommand - set DB Update command.
757:             **/
758:            public void setUpdateCommand(String updateCommand) {
759:                m_updateCommand = updateCommand;
760:            }
761:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.