Source Code Cross Referenced for SchemaTreeView.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:
011:        package components;
012:
013:        import communications.PostConnection;
014:        import graphical.BTListItem;
015:        import graphical.HyperTextFilter;
016:        import graphical.TreeView;
017:        import soif.AVPairs;
018:        import soif.CSID;
019:        import soif.SOIF;
020:        import soif.SOIFParser;
021:        import soif.Schema;
022:        import soif.SchemaColNode;
023:        import soif.SchemaGetter;
024:        import util.BinaryTree;
025:        import util.BTreeNode;
026:        import util.ReportError;
027:
028:        import java.awt.Dimension;
029:
030:        import netscape.application.Alert;
031:        import netscape.application.Button;
032:        import netscape.application.ContainerView;
033:        import netscape.application.Font;
034:        import netscape.application.GridLayout;
035:        import netscape.application.ListItem;
036:        import netscape.application.Target;
037:        import netscape.application.TextField;
038:        import netscape.application.View;
039:
040:        public class SchemaTreeView extends TreeView {
041:            public Schema schema;
042:            private String schemaOriginalIndex;
043:
044:            public ContainerView detailView;
045:            public View detailViewView;
046:            public View undetailView;
047:            public TextField detailLabel;
048:            public TextField undetailLabel;
049:
050:            public TextField soifAttLabel;
051:            public Button editBtn;
052:            public Button indxBtn;
053:            public TextField dscrLabel;
054:            public TextField dscrTextField;
055:            public Button uniqBtn;
056:
057:            private String CGILocation;
058:            private String CGITarget;
059:            private String CGIRead;
060:            private String CGIWrite;
061:            private String CGIWriteReindex;
062:            private CSID csid;
063:
064:            public Target notifyOfChange;
065:
066:            /**
067:             * Construct instance of SchemaTreeView.
068:             * @param CGILocation cgi location
069:             * @param CGITarget cgi target
070:             * @param CGIRead cgi read argument
071:             * @param CGIWrite cgi write argument
072:             * @param csid csid
073:             * @param editable editable or not
074:             * @param x x
075:             * @param y y
076:             * @param w width
077:             * @param h height
078:             * @param dragSourcePolicy drag source policy
079:             * @param dragDestinationPolicy drag destination policy
080:             * @param sizeForWindow size for containment in a window or a view
081:             * @param nameSpace url for space image
082:             * @param nameDocumentSel url for selected document image
083:             * @param nameDocument url for document image
084:             * @param nameFolderSel url for selected folder image
085:             * @param nameFolder url for folder image
086:             * @param nameBranchOpenSel url for selected branch open image
087:             * @param nameBranchOpen url for branch open image
088:             * @param nameBranchClosedSel url for selected branch closed image
089:             * @param nameBranchClosed url for branch closed image
090:             * @param showInternal show the internal fields or not
091:             * @param showUnIndexed show the unindexed fields or not
092:             */
093:            public SchemaTreeView(String CGILocation, String CGITarget,
094:                    String CGIRead, String CGIWrite, CSID csid,
095:                    boolean editable, int x, int y, int w, int h,
096:                    int dragSourcePolicy, int dragDestinationPolicy,
097:                    boolean sizeForWindow, String nameSpace,
098:                    String nameDocumentSel, String nameDocument,
099:                    String nameFolderSel, String nameFolder,
100:                    String nameBranchOpenSel, String nameBranchOpen,
101:                    String nameBranchClosedSel, String nameBranchClosed,
102:                    boolean showInternal, boolean showUnIndexed) {
103:                super (null, editable, x, y, w, h, dragSourcePolicy,
104:                        dragDestinationPolicy, sizeForWindow, nameSpace,
105:                        nameDocumentSel, nameDocument, nameFolderSel,
106:                        nameFolder, nameBranchOpenSel, nameBranchOpen,
107:                        nameBranchClosedSel, nameBranchClosed);
108:
109:                this .CGILocation = CGILocation;
110:                this .CGITarget = CGITarget;
111:                this .CGIRead = CGIRead;
112:                this .CGIWrite = CGIWrite;
113:                this .csid = csid;
114:
115:                obtainSchema();
116:                commonConstruction(showInternal, showUnIndexed);
117:            }
118:
119:            /**
120:             * Construct instance of SchemaTreeView.
121:             * @param CGILocation cgi location
122:             * @param CGITarget cgi target
123:             * @param CGIRead cgi read argument
124:             * @param CGIWrite cgi write argument
125:             * @param csid csid
126:             * @param editable editable or not
127:             * @param x x
128:             * @param y y
129:             * @param w width
130:             * @param h height
131:             * @param dragSourcePolicy drag source policy
132:             * @param dragDestinationPolicy drag destination policy
133:             * @param sizeForWindow size for containment in a window or a view
134:             * @param arraySpace pixel array for space
135:             * @param arrayDocumentSel pixel array for selected document
136:             * @param arrayDocument pixel array for document
137:             * @param arrayFolderSel pixel array for selected folder
138:             * @param arrayFolder pixel array for folder
139:             * @param arrayBranchOpenSel pixel array for selected branch open
140:             * @param arrayBranchOpen pixel array for branch open
141:             * @param arrayBranchClosedSel pixel array for selected branch closed
142:             * @param arrayBranchClosed pixel array for branch closed
143:             * @param showInternal show the internal fields or not
144:             * @param showUnIndexed show the unindexed fields or not
145:             */
146:            public SchemaTreeView(String CGILocation, String CGITarget,
147:                    String CGIRead, String CGIWrite, CSID csid,
148:                    boolean editable, int x, int y, int w, int h,
149:                    int dragSourcePolicy, int dragDestinationPolicy,
150:                    boolean sizeForWindow, int arraySpace[],
151:                    int arrayDocumentSel[], int arrayDocument[],
152:                    int arrayFolderSel[], int arrayFolder[],
153:                    int arrayBranchOpenSel[], int arrayBranchOpen[],
154:                    int arrayBranchClosedSel[], int arrayBranchClosed[],
155:                    Dimension imageSize, int pixelCount, boolean showInternal,
156:                    boolean showUnIndexed) {
157:                super (null, editable, x, y, w, h, dragSourcePolicy,
158:                        dragDestinationPolicy, sizeForWindow, arraySpace,
159:                        arrayDocumentSel, arrayDocument, arrayFolderSel,
160:                        arrayFolder, arrayBranchOpenSel, arrayBranchOpen,
161:                        arrayBranchClosedSel, arrayBranchClosed, imageSize,
162:                        pixelCount);
163:
164:                this .CGILocation = CGILocation;
165:                this .CGITarget = CGITarget;
166:                this .CGIRead = CGIRead;
167:                this .CGIWrite = CGIWrite;
168:                this .csid = csid;
169:
170:                obtainSchema();
171:                commonConstruction(showInternal, showUnIndexed);
172:            }
173:
174:            /**
175:             * Construct instance of SchemaTreeView.
176:             * @param schema schema
177:             * @param editable editable or not
178:             * @param x x
179:             * @param y y
180:             * @param w width
181:             * @param h height
182:             * @param dragSourcePolicy drag source policy
183:             * @param dragDestinationPolicy drag destination policy
184:             * @param sizeForWindow size for containment in a window or a view
185:             * @param nameSpace url for space image
186:             * @param nameDocumentSel url for selected document image
187:             * @param nameDocument url for document image
188:             * @param nameFolderSel url for selected folder image
189:             * @param nameFolder url for folder image
190:             * @param nameBranchOpenSel url for selected branch open image
191:             * @param nameBranchOpen url for branch open image
192:             * @param nameBranchClosedSel url for selected branch closed image
193:             * @param nameBranchClosed url for branch closed image
194:             * @param showInternal show the internal fields or not
195:             * @param showUnIndexed show the unindexed fields or not
196:             */
197:            public SchemaTreeView(Schema schema, boolean editable, int x,
198:                    int y, int w, int h, int dragSourcePolicy,
199:                    int dragDestinationPolicy, boolean sizeForWindow,
200:                    String nameSpace, String nameDocumentSel,
201:                    String nameDocument, String nameFolderSel,
202:                    String nameFolder, String nameBranchOpenSel,
203:                    String nameBranchOpen, String nameBranchClosedSel,
204:                    String nameBranchClosed, boolean showInternal,
205:                    boolean showUnIndexed) {
206:                super (null, editable, x, y, w, h, dragSourcePolicy,
207:                        dragDestinationPolicy, sizeForWindow, nameSpace,
208:                        nameDocumentSel, nameDocument, nameFolderSel,
209:                        nameFolder, nameBranchOpenSel, nameBranchOpen,
210:                        nameBranchClosedSel, nameBranchClosed);
211:
212:                this .schema = schema;
213:                schemaOriginalIndex = schema.getIndexableString();
214:
215:                this .CGILocation = null;
216:                this .CGITarget = null;
217:                this .CGIRead = null;
218:                this .CGIWrite = null;
219:                this .csid = null;
220:
221:                commonConstruction(showInternal, showUnIndexed);
222:            }
223:
224:            /**
225:             * Construct instance of SchemaTreeView.
226:             * @param schema schema
227:             * @param editable editable or not
228:             * @param x x
229:             * @param y y
230:             * @param w width
231:             * @param h height
232:             * @param dragSourcePolicy drag source policy
233:             * @param dragDestinationPolicy drag destination policy
234:             * @param sizeForWindow size for containment in a window or a view
235:             * @param arraySpace pixel array for space
236:             * @param arrayDocumentSel pixel array for selected document
237:             * @param arrayDocument pixel array for document
238:             * @param arrayFolderSel pixel array for selected folder
239:             * @param arrayFolder pixel array for folder
240:             * @param arrayBranchOpenSel pixel array for selected branch open
241:             * @param arrayBranchOpen pixel array for branch open
242:             * @param arrayBranchClosedSel pixel array for selected branch closed
243:             * @param arrayBranchClosed pixel array for branch closed
244:             * @param showInternal show the internal fields or not
245:             * @param showUnIndexed show the unindexed fields or not
246:             */
247:            public SchemaTreeView(Schema schema, boolean editable, int x,
248:                    int y, int w, int h, int dragSourcePolicy,
249:                    int dragDestinationPolicy, boolean sizeForWindow,
250:                    int arraySpace[], int arrayDocumentSel[],
251:                    int arrayDocument[], int arrayFolderSel[],
252:                    int arrayFolder[], int arrayBranchOpenSel[],
253:                    int arrayBranchOpen[], int arrayBranchClosedSel[],
254:                    int arrayBranchClosed[], Dimension imageSize,
255:                    int pixelCount, boolean showInternal, boolean showUnIndexed) {
256:                super (null, editable, x, y, w, h, dragSourcePolicy,
257:                        dragDestinationPolicy, sizeForWindow, arraySpace,
258:                        arrayDocumentSel, arrayDocument, arrayFolderSel,
259:                        arrayFolder, arrayBranchOpenSel, arrayBranchOpen,
260:                        arrayBranchClosedSel, arrayBranchClosed, imageSize,
261:                        pixelCount);
262:
263:                this .schema = schema;
264:                schemaOriginalIndex = schema.getIndexableString();
265:
266:                this .CGILocation = null;
267:                this .CGITarget = null;
268:                this .CGIRead = null;
269:                this .CGIWrite = null;
270:                this .csid = null;
271:
272:                commonConstruction(showInternal, showUnIndexed);
273:            }
274:
275:            private void obtainSchema() {
276:                schema = null;
277:
278:                if ((CGILocation != null) && (CGITarget != null)
279:                        && (csid != null)) {
280:                    SchemaGetter sg = new SchemaGetter(CGILocation, CGITarget
281:                            + CGIRead, csid);
282:                    sg.start();
283:                    sg.waitFor();
284:                    schema = sg.getSchema();
285:                    schemaOriginalIndex = schema.getIndexableString();
286:                } else {
287:                    ReportError.reportError(ReportError.ADMIN,
288:                            "SchemaTreeView", "obtainSchema",
289:                            Messages.INSUFFICIENTSCHEMAOBTAINPARAMS);
290:                }
291:            }
292:
293:            private void commonConstruction(boolean showInternal,
294:                    boolean showUnIndexed) {
295:                setEditableRoot(false);
296:                notifyOfTFEvents(this );
297:
298:                notifyOfChange = null;
299:                CGIWriteReindex = null;
300:
301:                setDupePeerNamesAllowed(false);
302:
303:                if (schema != null) {
304:                    if ((!showInternal) && (!showUnIndexed)) {
305:                        schema.hideInternalOrUnIndexed();
306:                    } else if (!showInternal) {
307:                        schema.hideInternal();
308:                    } else if (!showUnIndexed) {
309:                        schema.hideUnIndexed();
310:                    }
311:
312:                    if ((!showInternal) || (!showUnIndexed)) {
313:                        schema.hideTablesWithAllHidden();
314:                    }
315:
316:                    // SGP: it is possible that this should
317:                    // be part of the Taxonomy (Schema) constructor.
318:                    schema.binaryTree
319:                            .setEnumerationType(BinaryTree.DEPTHFIRSTSORTED);
320:
321:                    setBinaryTree(schema.binaryTree);
322:                }
323:
324:                soifAttLabel = TextField.createLabel(Messages.LBL_SOIFATT);
325:
326:                dscrLabel = TextField.createLabel(Messages.LBL_DESCRIPTION);
327:                dscrTextField = new TextField();
328:                dscrTextField.setOwner(this );
329:
330:                detailView = new ContainerView();
331:                undetailView = new View();
332:                detailViewView = new View();
333:
334:                detailLabel = TextField.createLabel(Messages.LBL_ATTRIBUTES);
335:                undetailLabel = TextField.createLabel(Messages.LBL_SCHEMA);
336:
337:                Font f = detailLabel.font();
338:                f = new Font(f.name(), Font.BOLD, f.size());
339:                detailLabel.setFont(f);
340:                detailLabel.sizeTo(detailLabel.minSize().width, detailLabel
341:                        .minSize().height);
342:                undetailLabel.setFont(f);
343:                undetailLabel.sizeTo(undetailLabel.minSize().width,
344:                        undetailLabel.minSize().height);
345:
346:                if (editable()) {
347:                    HyperTextFilter htf = HyperTextFilter
348:                            .createI18NAlphaNumericFilter(
349:                                    util.Key.I18NALPHANUMERIC_COUNT + 10, true);
350:                    htf.put( // return, enter
351:                            new Integer(10), new Character(' '));
352:                    htf.put(new Integer(45), new Character('-'));
353:                    htf.put(new Integer(46), new Character('.'));
354:                    htf.put(new Integer(95), new Character('_'));
355:                    // SGP: push nav stuff into HyperTextFilter
356:                    htf.put(new Integer(8), new Character('\010') // bs
357:                            );
358:                    htf.put(new Integer(127), new Character('\177') // del
359:                            );
360:                    htf.put( // home
361:                            new Integer(1000), new Character(' '));
362:                    htf.put( // end
363:                            new Integer(1001), new Character(' '));
364:                    htf.put( // left arrow
365:                            new Integer(1006), new Character(' '));
366:                    htf.put( // right arrow
367:                            new Integer(1007), new Character(' '));
368:
369:                    textField.setFilter(htf);
370:
371:                    // SGP: some of the positioning in here
372:                    // works as much by accident as by design,
373:                    // some review might prove useful.
374:
375:                    View v1 = new View(newPeerBtn.x(), newPeerBtn.y(),
376:                            scrollGroup.width(), cancelBtn.y()
377:                                    + cancelBtn.height() - newPeerBtn.y());
378:
379:                    newChildBtn.moveTo(Integer.MIN_VALUE, newChildBtn.y());
380:                    saveBtn.moveTo(Integer.MIN_VALUE, saveBtn.y());
381:                    cancelBtn.moveTo(Integer.MIN_VALUE, cancelBtn.y());
382:
383:                    soifAttLabel.setBounds(graphical.Header.WIDGETHGAP,
384:                            graphical.Header.WIDGETVGAP,
385:                            soifAttLabel.minSize().width, soifAttLabel
386:                                    .minSize().height);
387:
388:                    editBtn = Button.createCheckButton(
389:                            graphical.Header.WIDGETHGAP, soifAttLabel.y()
390:                                    + soifAttLabel.height()
391:                                    + (graphical.Header.WIDGETVGAP * 2), 0, 0);
392:                    editBtn.setTarget(this );
393:                    editBtn.setCommand(Messages.CMD_EDITABLE);
394:                    editBtn.setTitle(Messages.CMD_EDITABLE);
395:                    editBtn.sizeTo(editBtn.minSize().width,
396:                            editBtn.minSize().height);
397:                    indxBtn = Button.createCheckButton(
398:                            graphical.Header.WIDGETHGAP, editBtn.y()
399:                                    + editBtn.height()
400:                                    + graphical.Header.WIDGETVGAP, 0, 0);
401:                    indxBtn.setTarget(this );
402:                    indxBtn.setCommand(Messages.CMD_INDEXABLE);
403:                    indxBtn.setTitle(Messages.CMD_INDEXABLE);
404:                    indxBtn.sizeTo(indxBtn.minSize().width,
405:                            indxBtn.minSize().height);
406:
407:                    uniqBtn = Button.createCheckButton(
408:                            graphical.Header.WIDGETHGAP, indxBtn.y()
409:                                    + indxBtn.height()
410:                                    + graphical.Header.WIDGETVGAP, 0, 0);
411:                    uniqBtn.setTarget(this );
412:                    uniqBtn.setCommand(Messages.CMD_UNIQUE);
413:                    uniqBtn.setTitle(Messages.CMD_UNIQUE);
414:                    uniqBtn.sizeTo(uniqBtn.minSize().width,
415:                            uniqBtn.minSize().height);
416:
417:                    /* uniqBtn deprecated...
418:                    dscrLabel.setBounds(
419:                        graphical.Header.WIDGETHGAP,
420:                        uniqBtn.y()
421:                            + uniqBtn.height()
422:                            + ( graphical.Header.WIDGETVGAP * 2 ),
423:                        dscrLabel.minSize().width,
424:                        dscrLabel.minSize().height
425:                    );
426:                     */
427:                    dscrLabel.setBounds(graphical.Header.WIDGETHGAP, indxBtn
428:                            .y()
429:                            + indxBtn.height()
430:                            + (graphical.Header.WIDGETVGAP * 2), dscrLabel
431:                            .minSize().width, dscrLabel.minSize().height);
432:                    dscrTextField.setBounds(dscrLabel.x(), dscrLabel.y()
433:                            + dscrLabel.height() + graphical.Header.WIDGETVGAP,
434:                            1, dscrTextField.minSize().height);
435:
436:                    detailView.addSubview(soifAttLabel);
437:                    detailView.addSubview(editBtn);
438:                    detailView.addSubview(indxBtn);
439:                    // detailView.addSubview( uniqBtn );
440:                    detailView.addSubview(dscrLabel);
441:                    detailView.addSubview(dscrTextField);
442:                    detailView.setBounds(scrollGroup.bounds());
443:                    detailView.moveTo(0, 0);
444:                    detailView.setVertResizeInstruction(View.HEIGHT_CAN_CHANGE);
445:                    detailView.setHorizResizeInstruction(View.WIDTH_CAN_CHANGE);
446:
447:                    detailViewView.setBounds(scrollGroup.bounds());
448:                    detailViewView.addSubview(detailView);
449:                    detailViewView
450:                            .setVertResizeInstruction(View.HEIGHT_CAN_CHANGE);
451:                    detailViewView
452:                            .setHorizResizeInstruction(View.WIDTH_CAN_CHANGE);
453:                    detailViewView.addSubview(detailLabel);
454:                    detailLabel.moveTo(detailLabel.x(), delBtn.y()
455:                            + delBtn.height());
456:                    detailView.moveTo(detailView.x(), detailLabel.y()
457:                            + detailLabel.height());
458:                    detailView.sizeTo(detailView.width(), detailView.height()
459:                            - (detailLabel.y() + detailLabel.height()));
460:
461:                    removeSubview(scrollGroup);
462:                    undetailView.setBounds(v1.bounds());
463:                    newPeerBtn.moveTo(0, 0);
464:                    delBtn
465:                            .moveTo(newPeerBtn.x() + newPeerBtn.width()
466:                                    + (graphical.Header.WIDGETHGAP * 3),
467:                                    newPeerBtn.y());
468:                    scrollGroup.moveTo(0, newPeerBtn.y() + newPeerBtn.height()
469:                            + graphical.Header.WIDGETVGAP);
470:                    scrollGroup.sizeTo(scrollGroup.width(), scrollGroup
471:                            .height()
472:                            + (detailView.y() - scrollGroup.y()) + 10 // SGP
473:                    );
474:                    undetailView.addSubview(scrollGroup);
475:
476:                    newPeerBtn.removeFromSuperview();
477:                    undetailView.addSubview(newPeerBtn);
478:                    delBtn.removeFromSuperview();
479:                    undetailView.addSubview(delBtn);
480:
481:                    GridLayout g = new GridLayout(1, 2);
482:                    g.setHorizGap(graphical.Header.WIDGETHGAP);
483:                    v1.setLayoutManager(g);
484:                    v1.addSubview(undetailView);
485:                    v1.addSubview(detailViewView);
486:                    v1.setVertResizeInstruction(View.HEIGHT_CAN_CHANGE);
487:                    v1.setHorizResizeInstruction(View.WIDTH_CAN_CHANGE);
488:                    v1.layoutView(0, 0);
489:                    addSubview(v1);
490:
491:                    soifAttLabel.sizeTo(detailView.width()
492:                            - (graphical.Header.WIDGETHGAP * 2), dscrTextField
493:                            .height());
494:                    dscrTextField.sizeTo(detailView.width()
495:                            - (graphical.Header.WIDGETHGAP * 2), dscrTextField
496:                            .height());
497:                    soifAttLabel
498:                            .setHorizResizeInstruction(View.WIDTH_CAN_CHANGE);
499:                    dscrTextField
500:                            .setHorizResizeInstruction(View.WIDTH_CAN_CHANGE);
501:                }
502:
503:                openAndClose((BTListItem) listView.itemAt(0));
504:                selectAndDraw((BTListItem) listView.itemAt(0));
505:            }
506:
507:            public void setWriteReindex(String CGIWriteReindex) {
508:                this .CGIWriteReindex = CGIWriteReindex;
509:            }
510:
511:            public String writeSchema() {
512:                if (CGIWriteReindex != null) {
513:                    String one = schema.getIndexableString();
514:
515:                    if (one.compareTo(schemaOriginalIndex) != 0) {
516:                        int answer = Alert.runAlertExternally(Alert
517:                                .notificationImage(),
518:                                applications.Messages.REINDEXWARN,
519:                                applications.Messages.REINDEXWARN2,
520:                                Messages.CMD_SAVE, Messages.CMD_CANCEL, null);
521:                        if (answer == 1) {
522:                            performCommand("DOTHESAVE", null);
523:                        } else {
524:                            performCommand("KICKBACKRELAX", null);
525:                        }
526:                        /*
527:                                Prompt riPrompt = new Prompt(
528:                                    applications.Messages.REINDEXWARN,
529:                                    this,
530:                                    "DOTHESAVE",
531:                                    "KICKBACKRELAX"
532:                                );
533:                         */
534:                        return "NODIALOG";
535:                    }
536:                }
537:
538:                return PostConnection.doWrite(CGILocation + CGITarget
539:                        + CGIWrite, schema.toSOIF());
540:            }
541:
542:            /**
543:             * Use data to set detail area.
544:             */
545:            public void setDetail() {
546:                Object o = null;
547:                ListItem li = getCurrentListItem();
548:
549:                if (li != null) {
550:                    o = ((BTreeNode) li.data()).getValue();
551:                }
552:
553:                if (o == null) { /* for metrowerks bug */
554:                } else if (o instanceof  SchemaColNode) {
555:                    SchemaColNode scn = (SchemaColNode) o;
556:
557:                    soifAttLabel.setStringValue(Messages.LBL_SOIFATT
558:                            + scn.getValue("SOIF-Attribute"));
559:
560:                    editBtn.setEnabled(true);
561:                    editBtn
562:                            .setState((scn.getValue("Edit-Attribute") == null) ? false
563:                                    : true);
564:
565:                    indxBtn.setEnabled(true);
566:                    indxBtn
567:                            .setState((scn.getValue("Index-Attribute") == null) ? false
568:                                    : true);
569:
570:                    uniqBtn.setEnabled(true);
571:                    uniqBtn
572:                            .setState((scn.getValue("Enforce-Uniqueness") == null) ? false
573:                                    : true);
574:
575:                    dscrTextField.setEditable(true);
576:                    dscrTextField.setStringValue(scn.getValue("Description"));
577:                    dscrTextField
578:                            .setBackgroundColor(graphical.Header.ACTIVECOLOR);
579:                } else {
580:                    setDetailDisabled();
581:                }
582:
583:                setDetailDirty();
584:            }
585:
586:            private void setDetailDisabled() {
587:                soifAttLabel.setStringValue(Messages.LBL_SOIFATT);
588:                editBtn.setState(false);
589:                editBtn.setEnabled(false);
590:                indxBtn.setState(false);
591:                indxBtn.setEnabled(false);
592:                uniqBtn.setState(false);
593:                uniqBtn.setEnabled(false);
594:                dscrTextField.setEditable(false);
595:                dscrTextField.setStringValue("");
596:                dscrTextField
597:                        .setBackgroundColor(graphical.Header.INACTIVECOLOR);
598:            }
599:
600:            private void setDetailDirty() {
601:                soifAttLabel.setDirty(true);
602:                editBtn.setDirty(true);
603:                indxBtn.setDirty(true);
604:                dscrTextField.setDirty(true);
605:                uniqBtn.setDirty(true);
606:            }
607:
608:            /**
609:             * Get information from detail area, set data.
610:             */
611:            public void getDetail() {
612:                ListItem li = getCurrentListItem();
613:
614:                if (li != null) {
615:                    Object o = ((BTreeNode) li.data()).getValue();
616:                    if (o instanceof  SchemaColNode) {
617:                        SchemaColNode scn = (SchemaColNode) o;
618:                        scn.setEditAttribute((String) ((editBtn.state()) ? "1"
619:                                : ""));
620:                        scn.setIndexAttribute((String) ((indxBtn.state()) ? "1"
621:                                : ""));
622:                        scn.setEnforceUniqueness(uniqBtn.state());
623:                        scn.update("Description", dscrTextField.stringValue());
624:                    }
625:                }
626:
627:            }
628:
629:            public boolean clickCommand() {
630:                if (editable()) {
631:                    getDetail();
632:                    super .clickCommand();
633:                    setDetail();
634:                } else {
635:                    super .clickCommand();
636:                }
637:
638:                return false;
639:            }
640:
641:            private void setName(String s) {
642:                ListItem li = getCurrentListItem();
643:
644:                if (li != null) {
645:                    Object o = ((BTreeNode) li.data()).getValue();
646:                    if (o instanceof  SchemaColNode) {
647:                        SchemaColNode scn = (SchemaColNode) o;
648:                        scn.setValue("SOIF-Attribute", s);
649:                        scn.setValue("Column-Name", s);
650:                        scn.setValue("System-Column-Name", s);
651:                    }
652:                }
653:            }
654:
655:            public void textEditingDidEnd(TextField textfield,
656:                    int endCondition, boolean contentsChanged) {
657:                super .textEditingDidEnd(textfield, endCondition,
658:                        contentsChanged);
659:                setName(textfield.stringValue());
660:                getDetail();
661:            }
662:
663:            public void textWasModified(TextField textfield) {
664:                changeNotify();
665:                if (textfield != textField) {
666:                    return;
667:                }
668:                super .textWasModified(textfield);
669:                soifAttLabel.setStringValue(Messages.LBL_SOIFATT
670:                        + textfield.stringValue());
671:                setName(textfield.stringValue());
672:            }
673:
674:            private void changeNotify() {
675:                if (notifyOfChange != null) {
676:                    notifyOfChange.performCommand(
677:                            graphical.Messages.MSG_CHANGED_DATA, null);
678:                }
679:            }
680:
681:            private SchemaColNode getCurrCol() {
682:                ListItem li = getCurrentListItem();
683:
684:                if (li != null) {
685:                    Object o = ((BTreeNode) li.data()).getValue();
686:                    if (o instanceof  SchemaColNode) {
687:                        return (SchemaColNode) o;
688:                    }
689:                }
690:
691:                return null;
692:            }
693:
694:            public void newPeerBtnPress() {
695:                getDetail();
696:
697:                // SGP: this ought to be pushed down to Schema.
698:                AVPairs avp = new AVPairs("SOIF-Attribute",
699:                        graphical.Messages.NEW);
700:                avp.insertAfter( // SGP
701:                        "In-Root-Table", "1");
702:                avp.insertAfter("Data-Type", "string" // SGP
703:                );
704:                avp.insertAfter("System-Column-Name", graphical.Messages.NEW);
705:                avp.insertAfter("Column-Name", graphical.Messages.NEW);
706:                avp.insertAfter("System-Table-Name", "doctbl" // SGP
707:                );
708:                avp.insertAfter("Table-Name", "Documents" // SGP
709:                );
710:                SchemaColNode scn = new SchemaColNode(avp);
711:                newPeer(new BTreeNode(graphical.Messages.NEW, scn));
712:
713:                setDetail();
714:                changeNotify();
715:            }
716:
717:            public void delBtnPress() {
718:                super .delBtnPress();
719:                setDetail();
720:                changeNotify();
721:            }
722:
723:            public void buttonEnablement() {
724:                super .buttonEnablement();
725:                if (listView.count() < 3) {
726:                    delBtn.setEnabled(false);
727:                }
728:            }
729:
730:            /**
731:             * Verify that no SOIF attribute name qualifies as
732:             * multi-value SOIF.
733:             * SGP: Checks the tree w/out taking the TextField into account.
734:             */
735:            public boolean valid() {
736:                StringBuffer sb = new StringBuffer();
737:
738:                schema.binaryTree.currentBackup();
739:                schema.binaryTree.resetEnumeration();
740:                while (schema.binaryTree.hasMoreElements(true)) {
741:                    schema.binaryTree.nextElement(true);
742:                    Object o = schema.binaryTree.getValue();
743:                    if (o instanceof  SchemaColNode) {
744:                        AVPairs avp = new AVPairs(((SchemaColNode) o)
745:                                .getLabel(), "dummy");
746:                        if (avp.getAttributeIndex() != AVPairs.NOMULTIVALUE) {
747:                            if (sb.length() != 0) {
748:                                sb.append(", ");
749:                            }
750:                            sb.append(avp.getAttribute());
751:                        }
752:                    }
753:                }
754:                schema.binaryTree.currentRestore();
755:
756:                if (sb.length() != 0) {
757:                    Alert.runAlertExternally(Alert.notificationImage(), sb
758:                            .toString()
759:                            + Messages.NOTRAILINGMV, "", Messages.CMD_OK, null,
760:                            null);
761:                    return false;
762:                }
763:
764:                return true;
765:            }
766:
767:            public void performCommand(String command, Object arg) {
768:                if (Messages.CMD_EDITABLE.equals(command)) {
769:                    SchemaColNode scn = getCurrCol();
770:                    if (scn != null) {
771:                        scn.setEditAttribute((String) ((editBtn.state()) ? "1"
772:                                : ""));
773:                    }
774:                    changeNotify();
775:                } else if ("KICKBACKRELAX".equals(command)) {
776:                } else if ("DOTHESAVE".equals(command)) {
777:                    String s = PostConnection.doWrite(CGILocation + CGITarget
778:                            + CGIWriteReindex, schema.toSOIF());
779:                    if (s.indexOf(Messages.ROBOTRUNNING) != -1) {
780:                        Alert.runAlertExternally(Alert.notificationImage(),
781:                                Messages.ROBOTISRUNNINGSAVEERR, "",
782:                                Messages.CMD_OK, null, null);
783:                    } else {
784:                        Alert.runAlertExternally(Alert.notificationImage(),
785:                                applications.Messages.SAVED_SCHEMA, "",
786:                                Messages.CMD_OK, null, null);
787:                        graphical.Header
788:                                .showStatus(applications.Messages.SAVED);
789:                    }
790:                } else if (Messages.CMD_INDEXABLE.equals(command)) {
791:                    SchemaColNode scn = getCurrCol();
792:                    if (scn != null) {
793:                        scn.setIndexAttribute((String) ((indxBtn.state()) ? "1"
794:                                : ""));
795:                    }
796:                    changeNotify();
797:                } else if (Messages.CMD_UNIQUE.equals(command)) {
798:                    SchemaColNode scn = getCurrCol();
799:                    if (scn != null) {
800:                        scn.setEnforceUniqueness(uniqBtn.state());
801:                    }
802:                    changeNotify();
803:                } else {
804:                    super.performCommand(command, arg);
805:                }
806:            }
807:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.