source: cats/ISOcat/trunk/mod-ISOcat-interface-gi/interface/JSXAPPS/ISOcat/js/org/isocat/gui/DCEditor.js @ 2612

Last change on this file since 2612 was 2612, checked in by mwindhouwer, 11 years ago

M mod-ISOcat-access-data/dbx/DCIF.xml

  • added @isocat:isa

M mod-ISOcat-interface-rest/representations/html/datacategory.xsl

  • visualize the is-a hierarchy

M mod-ISOcat-interface-rest/interface/help.html
M mod-ISOcat-interface-rest/interface/services.wadl
M mod-ISOcat-interface-rest/interface/dc.acc
M mod-ISOcat-interface-rest/interface/lock.acc
M mod-ISOcat-interface-rest/representations/dcs2/handle.acc
M mod-ISOcat-interface-rest/representations/dcs2/determine.acc
M mod-ISOcat-interface-rest/representations/dcs2/representations.xml

  • changed application/dcif+xml to application/x-dcif+xml
  • still accept application/dcif+xml in content negotiation
File size: 60.5 KB
Line 
1jsx3.util.Logger.getLogger("org.isocat").info("Loading class[org.isocat.gui.DCEditor]");
2
3/**
4 * The DC viewer
5 * @author Menzo.Windhouwer@mpi.nl
6 */
7jsx3.lang.Class.defineClass("org.isocat.gui.DCEditor", null, [], function(DCEditor, DCEditor_prototype) { 
8
9        /**
10         * The class logger
11         */
12        DCEditor.log = jsx3.util.Logger.getLogger("org.isocat.gui.DCEditor");
13       
14        /**
15         * The view block of the component
16         */
17        DCEditor_prototype.view;
18       
19        /**
20         * The window of the component
21         */
22        DCEditor_prototype.window;
23       
24        /**
25         * The editor CDF source
26         */
27        DCEditor_prototype.cdf;
28       
29        /**
30         * The DC
31         */
32        DCEditor_prototype.dc;
33       
34        /**
35         * The label
36         */
37        DCEditor_prototype.label;
38
39        /**
40         * The save buttons
41         */
42        DCEditor_prototype.saveButtonMenu;
43        DCEditor_prototype.saveButtonWizard;
44
45        /**
46         * The cancel button
47         */
48        DCEditor_prototype.cancelButtonWizard;
49
50        /**
51         * The check button
52         */
53        DCEditor_prototype.checkButton;
54
55        /**
56         * The window button
57         */
58        DCEditor_prototype.windowButton;
59
60        /**
61         * The view splitter
62         */
63        DCEditor_prototype.viewSplitter;
64
65       /**
66         * The check result view
67         */
68        DCEditor_prototype.checkView;
69       
70       /**
71         * The check result viewer
72         */
73        DCEditor_prototype.checkResult;
74       
75        /**
76         * The editor stack
77         */
78        DCEditor_prototype.stack;
79       
80        /**
81         * The adminstrative information
82         */
83        DCEditor_prototype.adminInfo;
84       
85        /**
86         * The descriptive information
87         */
88        DCEditor_prototype.descrInfo;
89       
90        /**
91         * The linguistic information
92         */
93        DCEditor_prototype.lingInfo;
94       
95        /**
96         * Some of the form fields
97         */
98        DCEditor_prototype.identifier;
99        DCEditor_prototype.version;
100        DCEditor_prototype.type;
101        DCEditor_prototype.origin;
102        DCEditor_prototype.administrationStatus;
103        DCEditor_prototype.registrationStatus;
104        DCEditor_prototype.effectiveDate;
105        DCEditor_prototype.untilDate;
106        DCEditor_prototype.explanations;
107        DCEditor_prototype.issues;
108        DCEditor_prototype.profiles;
109        DCEditor_prototype.dataElementNames;
110        DCEditor_prototype.languageMenuLeft;
111        DCEditor_prototype.languageMenuRight;
112        DCEditor_prototype.languageSectionsSplitter;
113        DCEditor_prototype.datatypes;
114        DCEditor_prototype.valueDomain;
115        DCEditor_prototype.ruleTypeMask;
116        DCEditor_prototype.constraints;
117        DCEditor_prototype.isA;
118        DCEditor_prototype.linguisticMenuLeft;
119        DCEditor_prototype.linguisticMenuRight;
120        DCEditor_prototype.linguisticSectionsSplitter;
121       
122        /**
123         * Tabs related to DC types
124         */
125        DCEditor_prototype.simpleComplexTabs;
126        DCEditor_prototype.closedConstrainedTabs;
127       
128        /**
129         * language documents
130         */
131        DCEditor_prototype.langsLeft;
132        DCEditor_prototype.langsRight;
133       
134        /**
135         * linguistic documents
136         */
137        DCEditor_prototype.lingsLeft;
138        DCEditor_prototype.lingsRight;
139        /**
140         * The change flag
141         */
142        DCEditor_prototype.change;
143       
144        /**
145         * Indentifier check results
146         */
147        DCEditor_prototype.identifierCheckInfo;
148       
149        /**
150         * Type change results
151         */
152        DCEditor_prototype.DCType;
153        DCEditor_prototype.typeChangeInfo;
154       
155        /**
156         * Consistency checks
157         */
158        DCEditor_prototype.checks;
159       
160        /**
161         * Add to basket flag
162         */
163        DCEditor_prototype.addToBasket;
164       
165        /**
166         * Constructor
167         */
168        DCEditor_prototype.init = function(view) {
169                org.isocat.gui.DCEditor.log.info("initialize DC editor["+this+"]");
170
171                this.view = view;
172                org.isocat.gui.DCEditor.log.info("- DC editor view["+this.view+"]");
173                this.window = null;
174                org.isocat.gui.DCEditor.log.info("- DC editor window["+this.window+"]");
175                this.label = this.view.getDescendantOfName("label");
176                org.isocat.gui.DCEditor.log.info("- DC editor label["+this.label+"]");
177                this.cancelButtonWizard = this.view.getDescendantOfName("cancelButtonWizard");
178                org.isocat.gui.DCEditor.log.info("- DC editor cancel button (wizard) ["+this.cancelButtonWizard+"]");
179                this.saveButtonMenu = this.view.getDescendantOfName("saveButtonMenu");
180                org.isocat.gui.DCEditor.log.info("- DC editor save button (menu) ["+this.saveButtonMenu+"]");
181                this.saveButtonWizard = this.view.getDescendantOfName("saveButtonWizard");
182                org.isocat.gui.DCEditor.log.info("- DC editor save button (wizard) ["+this.saveButtonWizard+"]");
183                this.windowButton = null;//this.view.getDescendantOfName("windowButton");
184                org.isocat.gui.DCEditor.log.info("- DC editor window button["+this.windowButton+"]");
185                this.window = null;
186                org.isocat.gui.DCEditor.log.info("- DC editor window["+this.window+"]");
187                this.cdf = this.view.getDescendantOfName("cdf");
188                org.isocat.gui.DCEditor.log.info("- DC editor cdf source["+this.cdf+"]");
189                this.stack = this.view.getDescendantOfName("stackgroup");
190                org.isocat.gui.DCEditor.log.info("- DC editor stack["+this.stack+"]");
191                this.adminInfo = this.view.getDescendantOfName("administrativeInformation");
192                org.isocat.gui.DCEditor.log.info("- DC editor administrative information["+this.adminInfo+"]");
193                this.descrInfo = this.view.getDescendantOfName("descriptiveInformation");
194                org.isocat.gui.DCEditor.log.info("- DC editor descriptive information["+this.descrInfo+"]");
195                this.lingInfo = this.view.getDescendantOfName("linguisticInformation");
196                org.isocat.gui.DCEditor.log.info("- DC editor linguistic information["+this.lingInfo+"]");
197                this.checkButton = this.view.getDescendantOfName("checkButton");
198                org.isocat.gui.DCEditor.log.info("- check button["+this.checkButton+"]");
199                this.viewSplitter = this.view.getDescendantOfName("viewSplitter");
200                org.isocat.gui.DCEditor.log.info("- view splitter"+this.viewSplitter+"]");
201                this.checkView = this.view.getDescendantOfName("CheckResultView");
202                org.isocat.gui.DCEditor.log.info("- check result view"+this.checkView+"]");
203                this.checkResult = this.view.getDescendantOfName("checkResult");
204                org.isocat.gui.DCEditor.log.info("- check result viewer"+this.checkResult+"]");
205               
206                // get some of the forms fields
207                this.identifier           = this.view.getDescendantOfName("identifier");
208                this.version              = this.view.getDescendantOfName("version");
209                this.type                 = this.view.getDescendantOfName("type");
210                this.origin               = this.view.getDescendantOfName("origin");
211                this.administrationStatus = this.view.getDescendantOfName("administrationStatus");
212                this.registrationStatus   = this.view.getDescendantOfName("registrationStatus");
213                this.effectiveDate        = this.view.getDescendantOfName("effectiveDate");
214                this.untilDate            = this.view.getDescendantOfName("untilDate");
215                this.explanations         = this.view.getDescendantOfName("explanations");
216                this.issues               = this.view.getDescendantOfName("issues");
217                this.profiles             = this.view.getDescendantOfName("ProfilesInput").controller;
218                org.isocat.gui.DCEditor.log.info("- DC editor profiles editor["+this.profiles+"]");
219                this.dataElementNames     = this.view.getDescendantOfName("dataElementNames");
220                this.languageMenuLeft     = this.view.getDescendantOfName("languageMenuLeft");
221                this.languageMenuRight    = this.view.getDescendantOfName("languageMenuRight");
222                this.languageSectionsSplitter = this.view.getDescendantOfName("languageSectionsSplitter");
223                org.isocat.gui.DCEditor.log.info("- DC editor language section splitter["+this.languageSectionsSplitter+"]");
224                this.languageSectionLeft  = this.languageSectionsSplitter.getChild("left").getChild("LanguageSection").controller;
225                this.languageSectionLeft.setEditor(this);
226                org.isocat.gui.DCEditor.log.info("- DC editor language section left["+this.languageSectionLeft+"]");
227                this.languageSectionRight = this.languageSectionsSplitter.getChild("right").getChild("LanguageSection").controller;
228                this.languageSectionRight.setEditor(this);
229                org.isocat.gui.DCEditor.log.info("- DC editor language section right["+this.languageSectionRight+"]");
230                this.datatypes            = this.view.getDescendantOfName("datatypes");
231                this.valueDomain    = this.view.getDescendantOfName("ProfileValueDomainEditor").controller;
232                this.ruleTypeMask         = this.view.getDescendantOfName("ruleTypeMask");
233                this.constraints          = this.view.getDescendantOfName("constraints");
234                this.isA                  = this.view.getDescendantOfName("isA");
235                this.linguisticMenuLeft   = this.view.getDescendantOfName("linguisticMenuLeft");
236                this.linguisticMenuRight  = this.view.getDescendantOfName("linguisticMenuRight");
237                this.linguisticSectionsSplitter = this.view.getDescendantOfName("linguisticSectionsSplitter");
238                this.linguisticSectionLeft  = this.linguisticSectionsSplitter.getChild("left").getChild("LinguisticSection").controller;
239                this.linguisticSectionLeft.setEditor(this);
240                org.isocat.gui.DCEditor.log.info("- DC editor linguistic section left["+this.linguisticSectionLeft+"]");
241                this.linguisticSectionRight = this.linguisticSectionsSplitter.getChild("right").getChild("LinguisticSection").controller;
242                this.linguisticSectionRight.setEditor(this);
243                org.isocat.gui.DCEditor.log.info("- DC editor linguistic section right["+this.linguisticSectionRight+"]");
244               
245                // get the DC type tabs
246                this.simpleComplexTabs = this.view.getDescendantOfName("simpleComplexTabs");
247                this.closedConstrainedTabs = this.view.getDescendantOfName("closedConstrainedTabs");
248               
249                // get the indentifier check info area
250                this.identifierCheckInfo  = this.view.getDescendantOfName("identifierCheckInfo");
251                this.identifierCheckInfo.setVisibility(jsx3.gui.Block.VISIBILITYHIDDEN,true);
252               
253                // get the type change info area
254                this.DCType = null;
255                this.typeChangeInfo = this.view.getDescendantOfName("typeChangeInfo");
256                this.typeChangeInfo.setVisibility(jsx3.gui.Block.VISIBILITYHIDDEN,true);
257               
258                // reset the active checks counter
259                this.checks = new Object();
260
261                // reset the change flag
262                this.change = false;
263               
264                // reset the add to basket flag
265                this.addToBasket = false;
266               
267                // by default the cancel button is invisible
268                this.cancelButtonWizard.setVisibility(jsx3.gui.Block.VISIBILITYHIDDEN,true);
269               
270                // reset some form fields
271                this.identifier.setValue("");
272                this.version.setValue("0.0.0");
273                this.origin.setValue("");
274                this.administrationStatus.setValue("candidate");
275                this.registrationStatus.setValue("private");
276                this.effectiveDate.setDate(null);
277                this.untilDate.setDate(null);
278                this.isA.setText("<i>none</i>");
279
280                // make the admin info active
281                this.stack.setSelectedIndex(0);
282               
283                // reset all text/select masks
284                var columns = this.view.getDescendantsOfType(jsx3.gui.Matrix.Column,false);
285                for (var c=0;c<columns.length;c++) {
286                        var column = columns[c];
287                        var masks = column.getDescendantsOfType(jsx3.gui.TextBox,true);
288                        for (var m=0;m<masks.length;m++) {
289                                var mask = masks[m];
290                                mask.setWidth("100%");
291                        }
292                        masks = column.getDescendantsOfType(jsx3.gui.Select,true);
293                        for (var m=0;m<masks.length;m++) {
294                                var mask = masks[m];
295                                mask.setWidth("100%");
296                        }
297                }
298               
299                // set the changed handler for the profiles editor
300                this.profiles.changedHandler(this,this.profilesChanged);
301               
302                // set the callbacks for the profile value domains editor
303                this.valueDomain.setDelCallback(this,this.delValue);
304                this.valueDomain.setChangedCallback(this,this.changed);
305
306                // intialize language/linguistic selectors
307                var langs = org.isocat.loadDynamicCDFDocument(new jsx3.net.URI("http://isocat:8080/isocat/rest/info/languages.xml"),"Languages2CDF_xsl");
308                var cacheId = "language-"+this.view.getId();
309
310                this.langsLeft = langs.cloneDocument();
311                this.langsLeft.insertRecord({jsxid:"none", jsxtext:"none", jsxdivider:"1"});
312                org.isocat.APP.getCache().setDocument(cacheId+"-left",this.langsLeft);
313                this.languageMenuLeft.setXMLId(cacheId+"-left");
314                this.languageMenuLeft.setText("Language");
315                this.languageMenuLeft.setImage("images/flag.png");
316                this.languageMenuLeft.repaint();
317               
318                this.langsRight = langs.cloneDocument();
319                this.langsRight.insertRecord({jsxid:"none", jsxtext:"none", jsxdivider:"1"});
320                org.isocat.APP.getCache().setDocument(cacheId+"-right",this.langsRight);
321                this.languageMenuRight.setXMLId(cacheId+"-right");
322                this.languageMenuRight.setText("Language");
323                this.languageMenuRight.setImage("images/flag.png");
324                this.languageMenuRight.repaint();
325               
326                //this.languageSectionsSplitter.setSubcontainer1Pct("100",true);
327
328                langs = org.isocat.loadDynamicCDFDocument(new jsx3.net.URI("http://isocat:8080/isocat/rest/info/languages.xml"),"LinguisticLanguages2CDF_xsl");
329                cacheId = "linguistic-"+this.view.getId();
330               
331                this.lingsLeft = langs.cloneDocument();
332                this.lingsLeft.insertRecord({jsxid:"none", jsxtext:"none", jsxdivider:"1"});
333                org.isocat.APP.getCache().setDocument(cacheId+"-left",this.lingsLeft);
334                this.linguisticMenuLeft.setXMLId(cacheId+"-left");
335                this.linguisticMenuLeft.setText("Language");
336                this.linguisticMenuLeft.setImage("images/flag.png");
337                this.linguisticMenuLeft.repaint();
338               
339                this.lingsRight = langs.cloneDocument();
340                this.lingsRight.insertRecord({jsxid:"none", jsxtext:"none", jsxdivider:"1"});
341                org.isocat.APP.getCache().setDocument(cacheId+"-right",this.lingsRight);
342                this.linguisticMenuRight.setXMLId(cacheId+"-right");
343                this.linguisticMenuRight.setText("Language");
344                this.linguisticMenuRight.setImage("images/flag.png");
345                this.linguisticMenuRight.repaint();
346
347                // initialize the datatypes
348                var cacheId = "datatypes-"+this.view.getId();
349                org.isocat.loadDynamicCDFDocument(new jsx3.net.URI("http://isocat:8080/isocat/rest/info/data-types.xml"),"Datatypes2CDF_xsl",null,cacheId);
350                this.datatypes.setXMLId(cacheId);
351
352                // initialize the rule types
353                var cacheId = "ruletypes-"+this.view.getId();
354                var ruleTypes = org.isocat.loadDynamicCDFDocument(new jsx3.net.URI("http://isocat:8080/isocat/rest/info/rule-types.xml"),"RuleTypes2CDF_xsl",null,cacheId);
355                this.ruleTypeMask.setXMLId(cacheId);
356               
357                // reset more of the form
358                //this.newDataCategory();
359
360                org.isocat.gui.DCEditor.log.info("initialized DC editor["+this+"]");
361               
362                this.view.controller = this;
363               
364                // publish the message using PageBus
365                org.isocat.publish("org.isocat.gui.DCEditor.init", this);
366        };
367       
368        DCEditor_prototype.dcId = function() {
369                var id = this.view.getId();
370                if (typeof(this.dc) != 'undefined')
371                        id = this.dc.id;
372                return "dc-"+id;
373        };
374       
375        DCEditor_prototype.cacheId = function() {
376                return "DC-"+this.dcId();
377        };
378       
379        DCEditor_prototype.newDataCategory = function(addToBasket) {
380            if (typeof(addToBasket) == 'undefined')
381                this.addToBasket = false;
382            else
383                this.addToBasket = addToBasket;
384                this.editDataCategory();
385        };
386       
387        DCEditor_prototype.editDataCategory = function(dc) {
388                org.isocat.gui.Loading.load(this.view,"Loading ...").show();
389
390                this.dc = dc;
391               
392                var src = null;
393               
394                if (typeof(dc) == 'undefined') {
395                        org.isocat.gui.DCEditor.log.info("editing new DC");
396                        src = "dc_xml";
397                        this.canCheck(false);
398                } else {
399                        org.isocat.gui.DCEditor.log.info("editing existing DC["+dc.id+"]");
400                       
401                        if (!this.lockDataCategory()) {
402                                //this.close();
403                                return false;
404                        }
405                       
406                        // set the title
407                        this.setTitle();
408                       
409                        // disable the type field
410                        //this.type.setEnabled(jsx3.gui.Form.STATEDISABLED,true);
411       
412                        // load the DC content
413                        src = jsx3.net.URI.valueOf("http://isocat:8080/isocat/rest/dc/"+this.dc.id+".dcif?dcif-cleanup=false&parse-xml-constraints=false");
414                       
415                        // we can check an existing DC
416                        this.checkIcon();
417                        this.canCheck(true);
418                }
419               
420                this.check(false);
421
422                this.checks = new Object();
423
424                if (src != null) {
425                        org.isocat.gui.DCEditor.log.info("load uri["+src+"].");
426                        org.isocat.loadDynamicCDFDocument(src,"DC2CDF_xsl",null,this.cacheId());
427               
428                        // update the rest of the interface
429                        this.update();
430                }
431               
432                return true;
433        };
434       
435        DCEditor_prototype.lockDataCategory = function() {
436                var locked = false;
437                // acquire a lock on the DC
438                var lock = org.isocat.profile.lockDC(this.dc.id);
439                if (lock == null) {
440                        // there was an error in getting this lock, probably you can't edit this DC
441                        org.isocat.APP.alert("Can't edit this DC","Sorry, you can't edit this data category because you can't lock it.",null,"OK");
442                        this.lock = null;
443                } else {
444                        var type = lock.selectSingleNode("/*").getNodeName();
445                        if (type == 'nolock') {
446                                // this DC is already locked
447                                var name = lock.selectSingleNode("/nolock/user").getValue();
448                                org.isocat.APP.alert("DC is already locked","Sorry, you can't edit this data category because it is locked by another user ("+name+").",null,"OK");
449                                this.lock = null;
450                        } else if (type == 'lock') {
451                                org.isocat.gui.DCEditor.log.info("acquired DC lock["+lock+"]");
452                                var id = lock.selectSingleNode("/lock/id").getValue();
453                                this.lock = {id:id};
454                                locked = true;
455                        } else {
456                                org.isocat.APP.alert("Can't edit this DC","An error occured and the data category couldn't be locked! Please contact the ISOcat system administrator.",null,"OK");
457                                this.lock = null;
458                        }
459                }
460                return locked;
461        };
462       
463        DCEditor_prototype.update = function() {
464                org.isocat.gui.DCEditor.log.info("update DC editor["+this+"] ...");
465               
466                // update the CDF data source
467                this.cdf.setXMLId(this.cacheId());
468                this.cdf.setCDFId(this.dcId());
469                this.cdf.read(true);
470               
471                org.isocat.gui.DCEditor.log.info("updated the DC editor CDF source with cache["+this.cacheId()+"].");
472                               
473                this.updateAdminInfo();
474                this.updateDescrInfo();
475                this.updateLingInfo();
476
477                // reset buttons
478                this.canSave(false);
479               
480                this.change = false;
481               
482                // reset the title
483                this.setTitle();
484               
485                org.isocat.gui.Loading.load(this.view,"Loading ...").hide();
486               
487                org.isocat.gui.DCEditor.log.info("... update DC editor["+this+"]");
488        };
489       
490        DCEditor_prototype.updateAdminInfo = function() {
491                org.isocat.gui.DCEditor.log.info("update DC editor["+this+"] administrative information ...");
492
493                var cdfDoc = this.cdf.getXML();
494               
495                // reset the DC type switch
496                this.DCType = null;
497                this.typeChangeInfo.setVisibility(jsx3.gui.Block.VISIBILITYHIDDEN,true);
498               
499                var cacheId = this.cacheId()+"-explanations";
500                org.isocat.APP.getCache().setDocument(cacheId,org.isocat.createSubCDFDocument(cdfDoc,"explanations",true));
501                this.explanations.setXMLId(cacheId);
502                this.explanations.repaintData();
503
504                cacheId = this.cacheId()+"-issues";
505                org.isocat.APP.getCache().setDocument(cacheId,org.isocat.createSubCDFDocument(cdfDoc,"issues",true));
506                this.issues.setXMLId(cacheId);
507                this.issues.repaintData();
508
509                org.isocat.gui.DCEditor.log.info("... update DC editor["+this+"] administrative information");
510        };
511       
512        DCEditor_prototype.updateDescrInfo = function() {
513                org.isocat.gui.DCEditor.log.info("update DC editor["+this+"] descriptive information ...");
514
515                var cdfDoc = this.cdf.getXML();
516               
517                this.profiles.loadProfiles(org.isocat.createSubCDFDocument(cdfDoc,"profiles",true));
518
519                var cacheId = this.cacheId()+"-datanames";
520                org.isocat.APP.getCache().setDocument(cacheId,org.isocat.createSubCDFDocument(cdfDoc,"datanames",true));
521                this.dataElementNames.setXMLId(cacheId);
522                this.dataElementNames.repaintData();
523               
524                this.languageSectionLeft.reset();
525                this.languageSectionRight.reset();
526               
527                // check the existing language sections
528                var langs = this.langsLeft.getRecordIds();
529                for(var i=0;i<langs.length;i++) {
530                        var lang = this.langsLeft.getRecordNode(langs[i]);
531                        var tag  = lang.getAttribute("tag");
532                        var lsec = cdfDoc.selectSingleNode("//record[@jsxid='languagesections']/record[@jsxtext='"+tag+"']");
533                        //org.isocat.gui.DCEditor.log.info("- language section["+tag+"]:"+(lsec!=null?"1":"0"));
534                        lang.setAttribute("jsxselected",(lsec!=null?"1":"0"))
535                        lang = this.langsRight.getRecordNode(langs[i]);
536                        lang.setAttribute("jsxselected",(lsec!=null?"1":"0"))
537                }
538
539                // select the english language section, if it exists
540                var english = this.langsLeft.selectSingleNode("//record[@tag='en']");
541                if (english!=null) {
542                        this.selectLanguageSection(this.languageMenuLeft,english);
543                } else {
544                        org.isocat.gui.DCEditor.log.info("... no english?");
545                        this.selectLanguageSection(this.languageMenuLeft,this.langsLeft.selectSingleNode("//record[@tag]"));
546                }
547               
548                this.selectLanguageSection(this.languageMenuRight,this.langsRight.selectSingleNode("//record[@jsxid='none']"));
549
550                org.isocat.gui.DCEditor.log.info("... update DC editor["+this+"] descriptive information");
551        };
552       
553        DCEditor_prototype.updateLingInfo = function() {
554                org.isocat.gui.DCEditor.log.info("update DC editor["+this+"] linguistic information ...");
555               
556                var cdfDoc = this.cdf.getXML();
557               
558                var dcType = this.cdf.getXML().getRecord("admin").type;
559                if (dcType === null)
560                        dcType = "complex";
561                var cdType = this.cdf.getXML().getRecord("conceptualdomain").type;
562                if (cdType === null)
563                        cdType = "open";
564               
565                // complex DC: data type
566                var datatype = cdfDoc.getRecordNode("conceptualdomain").getAttribute("datatype-id");
567                if (datatype === null)
568                        datatype = "datatype-1"; // the id of the default data type: string
569                this.datatypes.setValue(datatype);
570               
571                // when this.datatypes is a tree
572                //this.datatypes.selectRecord("datatype-1");
573                //var par = this.datatypes.getRecordNode("datatype-1").getParent();
574                //while (par.getNodeName()=='record') {
575                //      par.setAttribute("jsxopen","1");
576                //      par = par.getParent();
577                //}
578
579                // closed DC: value domain
580                var cacheId = this.cacheId()+"-valuedomain";
581                if (cdType == "closed") {
582                        org.isocat.APP.getCache().setDocument(cacheId,org.isocat.createSubCDFDocument(cdfDoc,"conceptualdomain",true));
583                } else {
584                        org.isocat.APP.getCache().setDocument(cacheId,new jsx3.xml.CDF.Document.newDocument()); // an empty CDF document
585                }
586                this.valueDomain.setProfiles(this.profiles.getProfiles());
587                this.valueDomain.setValues(cacheId);
588               
589                // constrained DC: constraints
590                var cacheId = this.cacheId()+"-constraints";
591                if (cdType == "constrained") {
592                        org.isocat.APP.getCache().setDocument(cacheId,org.isocat.createSubCDFDocument(cdfDoc,"conceptualdomain",true));
593                } else {
594                        org.isocat.APP.getCache().setDocument(cacheId,new jsx3.xml.CDF.Document.newDocument()); // an empty CDF document
595                }
596                this.constraints.setXMLId(cacheId);
597                this.constraints.repaintData();
598               
599                // simple DC
600                this.isARecord = null;
601                if (dcType == "simple") {
602                        this.isARecord = this.cdf.getXML().getRecord("is-a");
603                        this.updateIsA();
604                }
605               
606                this.linguisticSectionLeft.reset();
607                this.linguisticSectionRight.reset();
608               
609                // check the existing linguistic sections
610                var langs = this.lingsLeft.getRecordIds();
611                for(var i=0;i<langs.length;i++) {
612                        var lang = this.lingsLeft.getRecordNode(langs[i]);
613                        var tag  = lang.getAttribute("tag");
614                        var lsec = cdfDoc.selectSingleNode("//record[@jsxid='linguisticsections']/record[@jsxtext='"+tag+"']");
615                        //org.isocat.gui.DCEditor.log.info("- language section["+tag+"]:"+(lsec!=null?"1":"0"));
616                        lang.setAttribute("jsxselected",(lsec!=null?"1":"0"))
617                        lang = this.lingsRight.getRecordNode(langs[i]);
618                        lang.setAttribute("jsxselected",(lsec!=null?"1":"0"))
619                }
620
621                this.selectLinguisticSection(this.linguisticMenuLeft,this.lingsLeft.selectSingleNode("//record[@jsxid='none']"));
622                this.selectLinguisticSection(this.linguisticMenuRight,this.lingsRight.selectSingleNode("//record[@jsxid='none']"));
623               
624                org.isocat.gui.DCEditor.log.info("... update DC editor["+this+"] linguistic information");
625        };
626               
627        DCEditor_prototype.updateLanguageMenu = function(menu,lang,repaint) {
628                if (lang != "none") {
629                        var objRECORD = menu.getRecordNode(lang);
630                        menu.setText(objRECORD.getAttribute("jsxtext"));
631                        if (objRECORD.getAttribute("jsximg")!=null)
632                                menu.setImage(objRECORD.getAttribute("jsximg"));
633                        else
634                                menu.setImage("images/flag.png");
635                } else {
636                        menu.setText("Language");
637                        menu.setImage("images/flag.png");
638                }
639
640                if (repaint)
641                        menu.repaint();
642        }
643
644        DCEditor_prototype.syncLanguageSectionsMenus = function(src,lang,repaint) {
645                var dst = null;
646                if (src == this.languageMenuLeft)
647                        dst = this.languageMenuRight;
648                else
649                        dst = this.languageMenuLeft;
650               
651                org.isocat.gui.DCEditor.log.info("DCEditor.syncLanguageSectionsMenus:src["+src+"]dst["+dst+"]lang["+lang+"]");
652
653                var langs = dst.getRecordIds();
654                for(var i=0;i<langs.length;i++)
655                        if (langs[i] == lang)
656                                dst.getRecordNode(lang).setAttribute("jsxdisabled","1"); // disable the selected lang in the src menu in the dst menu
657                        else
658                                dst.getRecordNode(langs[i]).setAttribute("jsxdisabled","0");
659               
660                if (repaint)
661                        dst.repaint();
662        };
663
664        DCEditor_prototype.selectLanguageSection = function(menu,lang) {
665                var langid = lang.getAttribute("jsxid");
666                this.updateLanguageMenu(menu,langid,false);
667                this.syncLanguageSectionsMenus(menu,langid,false);
668               
669                // save the previously selected language section (if it has changed)
670                var saved = null;
671                if (menu == this.languageMenuRight) {
672                        if (this.languageSectionRight.save(false))
673                                saved = this.languageSectionRight.lang;
674                } else {
675                        if (this.languageSectionLeft.save(false))
676                                saved = this.languageSectionLeft.lang;
677                }
678
679                // check the saved language section in the menus
680                if (saved!=null) {
681                        this.langsLeft.getRecordNode(saved.getAttribute("jsxid")).setAttribute("jsxselected","1");
682                        this.langsRight.getRecordNode(saved.getAttribute("jsxid")).setAttribute("jsxselected","1");
683                }
684
685                this.languageMenuRight.repaint();
686                this.languageMenuLeft.repaint();
687               
688                if (langid!="none") {
689                        if (menu == this.languageMenuRight) {
690                                if (this.languageSectionsSplitter.getSubcontainer1Pct() == "100") {
691                                        this.languageSectionsSplitter.setSubcontainer1Pct("50",true);
692                                }
693                        } else {
694                                if (this.languageSectionsSplitter.getSubcontainer1Pct() == "0") {
695                                        this.languageSectionsSplitter.setSubcontainer1Pct("50",true);
696                                }
697                        }
698                       
699                        this.showLanguageSection(menu,lang);
700                } else {
701                        if (menu == this.languageMenuRight) {
702                                if (this.languageSectionsSplitter.getSubcontainer1Pct() != "100")
703                                        this.languageSectionsSplitter.setSubcontainer1Pct("100",true);
704                                this.languageSectionRight.reset();
705                                this.languageSectionRight.disable();
706                        } else {
707                                if (this.languageSectionsSplitter.getSubcontainer1Pct() != "0")
708                                        this.languageSectionsSplitter.setSubcontainer1Pct("0",true);
709                                this.languageSectionLeft.reset();
710                                this.languageSectionLeft.disable();
711                        }
712                }
713        };
714       
715        DCEditor_prototype.showLanguageSection = function(src,lang) {
716                var dst = null;
717                if (src == this.languageMenuLeft)
718                        dst = this.languageSectionLeft;
719                else
720                        dst = this.languageSectionRight;
721               
722                var lsec = this.cdf.getXML().selectSingleNode("//record[@jsxid='languagesections']/record[@language='"+lang.getAttribute("jsxid")+"']");
723                org.isocat.gui.DCEditor.log.info("DCEditor.showLanguageSection(src["+src+"]dst["+dst+"]lang["+lang+"]):lsec["+lsec+"]");
724               
725                dst.enable();
726                if (lsec!=null) {
727                        // use the existing one
728                        dst.editLanguageSection(lang,lsec,this.cdf.getXML());
729                } else {
730                        // check if a record with id 'languagesections' exists
731                        var ls = this.cdf.getXML().getRecordNode('languagesections');
732                        if (ls == null)
733                                this.cdf.getXML().insertRecord({jsxid:'languagesections'},this.dcId());
734                        // create a new one, and use that
735                        var id =  jsx3.xml.CDF.getKey();
736                        lsec = {jsxid:id, language:lang.getAttribute("jsxid"), jsxtext:lang.getAttribute("tag")};
737                        lsec = this.cdf.getXML().insertRecord(lsec,'languagesections',true);
738                        org.isocat.gui.DCEditor.log.info("DCEditor.showLanguageSection(...):added lsec["+id+"]["+lsec+"]");
739                        dst.editLanguageSection(lang,lsec,this.cdf.getXML());
740                }
741        };
742       
743        DCEditor_prototype.updateLinguisticMenu = function(menu,lang,repaint) {
744                if (lang != "none") {
745                        var objRECORD = menu.getRecordNode(lang);
746                        menu.setText(objRECORD.getAttribute("jsxtext"));
747                        if (objRECORD.getAttribute("jsximg")!=null)
748                                menu.setImage(objRECORD.getAttribute("jsximg"));
749                        else
750                                menu.setImage("images/flag.png");
751                } else {
752                        menu.setText("Language");
753                        menu.setImage("images/flag.png");
754                }
755
756                if (repaint)
757                        menu.repaint();
758        }
759
760        DCEditor_prototype.syncLinguisticSectionsMenus = function(src,lang,repaint) {
761                var dst = null;
762                if (src == this.linguisticMenuLeft)
763                        dst = this.linguisticMenuRight;
764                else
765                        dst = this.linguisticMenuLeft;
766               
767                org.isocat.gui.DCEditor.log.info("DCEditor.syncLinguisticSectionsMenus:src["+src+"]dst["+dst+"]lang["+lang+"]");
768
769                var langs = dst.getRecordIds();
770                for(var i=0;i<langs.length;i++)
771                        if (langs[i] == lang)
772                                dst.getRecordNode(lang).setAttribute("jsxdisabled","1"); // disable the selected lang in the src menu in the dst menu
773                        else
774                                dst.getRecordNode(langs[i]).setAttribute("jsxdisabled","0");
775               
776                if (repaint)
777                        dst.repaint();
778        };
779
780        DCEditor_prototype.selectLinguisticSection = function(menu,lang) {
781                var langid = lang.getAttribute("jsxid");
782                this.updateLinguisticMenu(menu,langid,false);
783                this.syncLinguisticSectionsMenus(menu,langid,false);
784               
785                // save the previously selected linguistic section (if it has changed)
786                var saved = null;
787                if (menu == this.linguisticMenuRight) {
788                        if (this.linguisticSectionRight.save(false))
789                                saved = this.linguisticSectionRight.lang;
790                } else {
791                        if (this.linguisticSectionLeft.save(false))
792                                saved = this.linguisticSectionLeft.lang;
793                }
794
795                // check the saved linguistic section in the menus
796                if (saved!=null) {
797                        this.lingsLeft.getRecordNode(saved.getAttribute("jsxid")).setAttribute("jsxselected","1");
798                        this.lingsRight.getRecordNode(saved.getAttribute("jsxid")).setAttribute("jsxselected","1");
799                }
800
801                this.linguisticMenuRight.repaint();
802                this.linguisticMenuLeft.repaint();
803               
804                if (langid!="none") {
805                        if (menu == this.linguisticMenuRight) {
806                                if (this.linguisticSectionsSplitter.getSubcontainer1Pct() == "100") {
807                                        this.linguisticSectionsSplitter.setSubcontainer1Pct("50",true);
808                                }
809                        } else {
810                                if (this.linguisticSectionsSplitter.getSubcontainer1Pct() == "0") {
811                                        this.linguisticSectionsSplitter.setSubcontainer1Pct("50",true);
812                                }
813                        }
814                       
815                        this.showLinguisticSection(menu,lang);
816                } else {
817                        if (menu == this.linguisticMenuRight) {
818                                if (this.linguisticSectionsSplitter.getSubcontainer1Pct() != "100")
819                                        this.linguisticSectionsSplitter.setSubcontainer1Pct("100",true);
820                                this.linguisticSectionRight.reset();
821                                this.linguisticSectionRight.disable();
822                        } else {
823                                if (this.linguisticSectionsSplitter.getSubcontainer1Pct() != "0")
824                                        this.linguisticSectionsSplitter.setSubcontainer1Pct("0",true);
825                                this.linguisticSectionLeft.reset();
826                                this.linguisticSectionLeft.disable();
827                        }
828                }
829        };
830       
831        DCEditor_prototype.showLinguisticSection = function(src,lang) {
832                var dst = null;
833                if (src == this.linguisticMenuLeft)
834                        dst = this.linguisticSectionLeft;
835                else
836                        dst = this.linguisticSectionRight;
837               
838                var lsec = this.cdf.getXML().selectSingleNode("//record[@jsxid='linguisticsections']/record[@language='"+lang.getAttribute("jsxid")+"']");
839                org.isocat.gui.DCEditor.log.info("DCEditor.showLinguisticSection(src["+src+"]dst["+dst+"]lang["+lang+"]):lsec["+lsec+"]");
840               
841                dst.enable();
842                if (lsec!=null) {
843                        // use the existing one
844                        dst.editLinguisticSection(lang,lsec,this.cdf.getXML());
845                } else {
846                        // check if a record with id 'linguisticsections' exists
847                        var ls = this.cdf.getXML().getRecordNode('linguisticsections');
848                        if (ls == null)
849                                this.cdf.getXML().insertRecord({jsxid:'linguisticsections'},this.dcId());
850                        // create a new one, and use that
851                        var id =  jsx3.xml.CDF.getKey();
852                        lsec = {jsxid:id, language:lang.getAttribute("jsxid"), jsxtext:lang.getAttribute("tag"), type:dst.domainType };
853                        lsec = this.cdf.getXML().insertRecord(lsec,'linguisticsections',true);
854                        org.isocat.gui.DCEditor.log.info("DCEditor.showLinguisticSection(...):added lsec["+id+"]["+lsec+"]");
855                        dst.editLinguisticSection(lang,lsec,this.cdf.getXML());
856                }
857        };
858       
859        DCEditor_prototype.addExplanation = function() {
860                var id =  jsx3.xml.CDF.getKey();
861                var rec = this.explanations.insertRecord({jsxid:id,jsxtext:''});
862                jsx3.sleep(function() { this.explanations.focusCellById(id,"jsxtext"); },"focusCell",this,true);
863                this.changed();
864        };
865       
866        DCEditor_prototype.addIssue = function() {
867                var id =  jsx3.xml.CDF.getKey();
868                var rec = this.issues.insertRecord({jsxid:id,jsxtext:''});
869                jsx3.sleep(function() { this.issues.focusCellById(id,"jsxtext"); },"focusCell",this,true);
870                this.changed();
871        };
872       
873        DCEditor_prototype.addDataElementName = function() {
874                var id =  jsx3.xml.CDF.getKey();
875                var rec = this.dataElementNames.insertRecord({jsxid:id,jsxtext:'',source:''});
876                jsx3.sleep(function() { this.dataElementNames.focusCellById(id,"jsxtext"); },"focusCell",this,true);
877                this.changed();
878        };
879       
880        DCEditor_prototype.addConstraint = function() {
881                var id =  jsx3.xml.CDF.getKey();
882                var rec = this.constraints.insertRecord({jsxid:id,jsxtext:''});
883                jsx3.sleep(function() { this.constraints.focusCellById(id,"jsxtext"); },"focusCell",this,true);
884                this.changed();
885        };
886       
887        DCEditor_prototype.profilesChanged = function() {
888                // callback from the ProfilesInput
889                // propagate changes to the ProfileValueDomainEditor
890                this.valueDomain.setProfiles(this.profiles.getProfiles(),this.valueDomain.hasValues());
891                // trigger changed
892                this.changed();
893        };
894               
895        DCEditor_prototype.delValue = function(id) {
896                // signal the linguistic sections
897                var vid = id.replace(/.*-/,'');
898                for (var langs = this.cdf.getXML().selectNodeIterator("//record[@jsxid='linguisticsections']/record/@jsxtext");langs.hasNext();) {
899                        var lang = langs.next().getValue();
900                        var val  = "lingsec-conceptualdomain-"+lang+"-value-"+vid;
901                        var rec  = this.cdf.deleteRecord(val,false);
902                        if (rec != null)
903                                org.isocat.gui.DCEditor.log.info("value["+val+"] deleted from LS["+lang+"]");
904                }
905                this.linguisticSectionLeft.delValue(vid);
906                this.linguisticSectionRight.delValue(vid);
907        };
908       
909        DCEditor_prototype.getValues = function() {
910                return this.valueDomain.getValues();
911        };
912       
913        DCEditor_prototype.editIsA = function() {
914                 var list = org.isocat.APP.getRootBlock().loadAndCache("components/DCList.xml",true).controller;
915                 list.setSingleSelect();
916                 if (this.isARecord != null) {
917                         var values = new Array(1);
918                         values[0] = this.isARecord.id;
919                         list.preselectValues(new jsx3.util.List(values));
920                 }
921                 
922                 //check if the DC is member of the private profile
923                 var q = null;
924                 if ((this.profiles.getProfiles().getRecord("profile-0")!=null)) {
925                         // any simple DC can be linked
926                         q = new org.isocat.data.Query(org.isocat.profile.user(),"simple",new Array());
927                         org.isocat.gui.DCEditor.log.info("DCEditor.editIsA():query for any simple DC");
928                 } else {
929                         // only simple DCs from the selected profiles can be linked
930                         q = new org.isocat.data.Query(org.isocat.profile.user(),"simple",this.profiles.getProfiles().getRecordIds());
931                         org.isocat.gui.DCEditor.log.info("EDEditor.editIsA():query for simple DCs belonging to selected profiles");
932                 }
933                 
934                 list.callback(this,this.setIsA);
935                 list.load(q);
936        };
937
938        DCEditor_prototype.setIsA = function(values) {
939                var dc = values.get(0);
940                if (dc != null) {
941                        // need the following CDF record: @jsxid='is-a' @id=<id> @jsxtext=<name> @name=<name> identifier=<identifier>
942                        if (dc.getAttribute("id")!="0") {
943                                this.isARecord = {jsxid:"is-a",id:dc.getAttribute("id"),jsxtext:dc.getAttribute("name"),name:dc.getAttribute("name"),identifier:dc.getAttribute("identifier")};
944                                this.updateIsA();
945                                org.isocat.gui.DCEditor.log.info("simple DC ["+this+"] is a is ["+this.isARecord.id+","+this.isARecord.jsxtext+"]");
946                        } else {
947                                this.deleteIsA();
948                        }
949                }
950                return true;
951        };
952       
953        DCEditor_prototype.deleteIsA = function() {
954                this.isARecord = null;
955                this.updateIsA();
956                org.isocat.gui.DCEditor.log.info("simple DC ["+this+"] is a set to none");
957                this.changed();
958        };
959       
960        DCEditor_prototype.updateIsA = function() {
961                var text="<i>none</i>";
962                if (this.isARecord != null) {
963                        var text = "/"+this.isARecord.identifier+"/";
964                        if (this.isARecord.identifier != this.isARecord.name)
965                                text += " ("+this.isARecord.name+")";
966                }
967                this.isA.setText(text,true);
968        this.changed();
969        };
970       
971        DCEditor_prototype.changed = function() {
972                this.change = true;
973                this.setTitle();
974                this.canSave(true);
975                this.canCheck(false);
976        };
977       
978        DCEditor_prototype.changedType = function() {
979                var type = this.type.getValue();
980                this.changed();
981                this.setDCType(type);
982               
983                org.isocat.gui.DCEditor.log.info("DCEditor: old type["+this.DCType+"] new type["+type+"]");
984               
985                var icon = this.typeChangeInfo.getChild("image");
986                var text = this.typeChangeInfo.getChild("label");
987                if (this.DCType != type) {
988                        if (this.DCType=='closed') {
989                                this.typeChangeInfo.setVisibility(jsx3.gui.Block.VISIBILITYVISIBLE,true);
990                                icon.setSrc("http://isocat:8080/Tango/16x16/status/dialog-warning.png");
991                                icon.repaint();
992                                text.setText("value domains will be deleted",true);
993                        } else if (this.DCType=='constrained') {
994                                this.typeChangeInfo.setVisibility(jsx3.gui.Block.VISIBILITYVISIBLE,true);
995                                icon.setSrc("http://isocat:8080/Tango/16x16/status/dialog-warning.png");
996                                icon.repaint();
997                                text.setText("constraints will be deleted",true);
998                        } else if (this.DCType=='simple') {
999                                this.typeChangeInfo.setVisibility(jsx3.gui.Block.VISIBILITYVISIBLE,true);
1000                                icon.setSrc("http://isocat:8080/Tango/16x16/status/dialog-warning.png");
1001                                icon.repaint();
1002                                text.setText("value domain relationships will be deleted",true);
1003                        } else {
1004                                this.typeChangeInfo.setVisibility(jsx3.gui.Block.VISIBILITYHIDDEN,true);
1005                        }
1006                } else {
1007                        this.typeChangeInfo.setVisibility(jsx3.gui.Block.VISIBILITYHIDDEN,true);
1008                }
1009        };
1010       
1011        DCEditor_prototype.setDCType = function(type) {
1012                if (this.DCType == null)
1013                        this.DCType = type;
1014                if (type == 'container') {
1015                        org.isocat.gui.DCEditor.log.info("container DC");
1016                        this.simpleComplexTabs.setSelectedIndex(2,true);
1017                } else if (type == 'simple') {
1018                        org.isocat.gui.DCEditor.log.info("simple DC");
1019                        this.simpleComplexTabs.setSelectedIndex(0,true);
1020                } else {
1021                        this.simpleComplexTabs.setSelectedIndex(1,true);
1022                        org.isocat.gui.DCEditor.log.info("complex DC");
1023                        if (type == 'open') {
1024                                this.closedConstrainedTabs.setVisibility(jsx3.gui.Block.VISIBILITYHIDDEN,true);
1025                                org.isocat.gui.DCEditor.log.info("open complex DC");
1026                        } else {
1027                                this.closedConstrainedTabs.setVisibility(jsx3.gui.Block.VISIBILITYVISIBLE,true);
1028                                if (type == 'closed') {
1029                                        this.closedConstrainedTabs.setSelectedIndex(0,true);
1030                                        org.isocat.gui.DCEditor.log.info("closed complex DC");
1031                                } else {
1032                                        this.closedConstrainedTabs.setSelectedIndex(1,true);
1033                                        org.isocat.gui.DCEditor.log.info("constrained complex DC");
1034                                }
1035                        }
1036                }
1037                this.linguisticSectionLeft.setDCType(type);
1038                this.linguisticSectionRight.setDCType(type);
1039        };
1040       
1041        DCEditor_prototype.canSave = function(enable) {
1042                org.isocat.gui.DCEditor.log.info("DCEditor.canSave("+enable+")");
1043                if (enable) {
1044                    if (this.identifier.getValue()=='') {
1045                        org.isocat.gui.DCEditor.log.info("DCEditor.canSave(...):empty identifier");
1046                        enable = false;
1047                    }
1048                    if (this.type.getValue()=='') {
1049                        org.isocat.gui.DCEditor.log.info("DCEditor.canSave(...):empty type");
1050                        enable = false;
1051                    }
1052                    if (this.anyError()) {
1053                        org.isocat.gui.DCEditor.log.info("DCEditor.canSave(...):some error");
1054                        enable = false;
1055                    }
1056                }
1057                org.isocat.gui.DCEditor.log.info("DCEditor.canSave(...):enable["+enable+"]");
1058               
1059                if (enable) {
1060                        this.saveButtonMenu.setEnabled(jsx3.gui.Form.STATEENABLED,true);
1061                        this.saveButtonWizard.setEnabled(jsx3.gui.Form.STATEENABLED,true);
1062                } else {
1063                        this.saveButtonMenu.setEnabled(jsx3.gui.Form.STATEDISABLED,true);
1064                        this.saveButtonWizard.setEnabled(jsx3.gui.Form.STATEDISABLED,true);
1065                }
1066        };
1067       
1068        DCEditor_prototype.canCheck = function(enable) {
1069                if (enable) {
1070                        this.checkButton.setEnabled(jsx3.gui.Form.STATEENABLED,true);
1071                } else {
1072                        this.checkButton.setEnabled(jsx3.gui.Form.STATEDISABLED,true);
1073                }
1074        };
1075       
1076        DCEditor_prototype.checkIdentifier = function() {
1077                var icon = this.identifierCheckInfo.getChild("image");
1078                var text = this.identifierCheckInfo.getChild("label");
1079                icon.setSrc("http://isocat:8080/famfamfam/silk/icons/hourglass.png");
1080                icon.repaint();
1081                text.setText("checking ...",true);
1082                this.identifierCheckInfo.setVisibility(jsx3.gui.Block.VISIBILITYVISIBLE,true);
1083                this.identifier.setEnabled(jsx3.gui.Form.STATEDISABLED,true);
1084                this.canSave(false);
1085                if (org.isocat.trim(this.identifier.getValue())!='') {
1086                        var url = "http://isocat:8080/isocat/rest/user/"+escape(org.isocat.profile.user())+"/search.xml?fields=identifier&scope=both&keywords="+escape(this.identifier.getValue());
1087                        org.isocat.asyncLoadDocument(url,null,this,this.checkedIdentifier);
1088                        this.setCheck("identifier","checking");
1089                } else {
1090                        org.isocat.gui.DCEditor.log.info("identifier is empty");
1091                        icon.setSrc("http://isocat:8080/Tango/16x16/status/dialog-error.png");
1092                        icon.repaint();
1093                        text.setText("identifier is empty",true);
1094                        this.setCheck("identifier","empty");
1095                }
1096        };
1097       
1098        DCEditor_prototype.checkedIdentifier = function(doc,req) {
1099                this.identifier.setEnabled(jsx3.gui.Form.STATEENABLED,true);
1100                var icon = this.identifierCheckInfo.getChild("image");
1101                var text = this.identifierCheckInfo.getChild("label");
1102                if (doc != null) {
1103                        org.isocat.gui.DCEditor.log.info("checked identifier["+doc+"].");
1104                        var cid = 0;
1105                        if (typeof(this.dc)!='undefined')
1106                                cid = this.dc.id;
1107                        var uid = org.isocat.profile.id();
1108                        if (typeof(this.dc)!='undefined')
1109                                uid = this.dc.owner_id;
1110                        // find DCs with the same name (owned by the logged in user)
1111                        var xp = "//dc[identifier='"+this.identifier.getValue()+"'][owner/@id="+uid+"]";
1112                        var ids = doc.selectNodes(xp);
1113                        org.isocat.gui.DCEditor.log.info("found ids["+ids.size()+"].");
1114                        if (ids.size()==0) {
1115                                // doesn't exist yet
1116                                org.isocat.gui.DCEditor.log.info("owner/identifier combo doesn't exist yet");
1117                                icon.setSrc("http://isocat:8080/famfamfam/silk/icons/tick.png");
1118                                icon.repaint();
1119                                text.setText("",true);
1120                                this.setCheck("identifier","ok");
1121                                this.canSave(true);
1122                                // if there are public (TODO: shared) matches suggest those
1123                                xp = "//dc[identifier='"+this.identifier.getValue()+"'][scope='public']";
1124                                ids = doc.selectNodes(xp);
1125                                if (ids.size()==1) {
1126                                        var dup = doc.selectSingleNode(xp);
1127                                        var msg = "Maybe this data category already exists. Can it be this public one?";
1128                                        msg += "<p>";
1129                                        msg += '<a href="#" onclick="javascript:org.isocat.showDataCategoryInWindow(\''+dup.selectSingleNode("id").getValue()+'\')">'+dup.selectSingleNode("name").getValue()+'</a>';
1130                                        msg += "</p>";
1131                                        org.isocat.APP.alert("Data Category suggestion",msg,null,"Close",{nonModal:true});
1132                                } else if (ids.size()>1) {
1133                                        var msg = "Maybe this data category already exists. Can it be one of those, which are public available?";
1134                                        msg += "<ol>";
1135                                        for (var iter = ids.iterator();iter.hasNext();) {
1136                                                var dup = iter.next();
1137                                                msg += '<li><a href="#" onclick="javascript:org.isocat.showDataCategoryInWindow(\''+dup.selectSingleNode("id").getValue()+'\')">'+dup.selectSingleNode("name").getValue()+'</a></li>';
1138                                        }
1139                                        msg += "</ol>";
1140                                        org.isocat.APP.alert("Data Category suggestions",msg,null,"Close",{nonModal:true});
1141                                } else if (ids.size()==0) {
1142                                        // check if the identifier is a valid local QName
1143                                        var xml = "<"+this.identifier.getValue()+"/>";
1144                                        var xdoc = new jsx3.xml.Document();
1145                                        xdoc.loadXML(xml);
1146                                        var err =  xdoc.getError();
1147                                        if (err.code != 0) {
1148                                                org.isocat.gui.DCEditor.log.info("XML check failed for identifier: "+err.description);
1149                                                icon.setSrc("http://isocat:8080/Tango/16x16/status/dialog-error.png");
1150                                                icon.repaint();
1151                                                text.setText("identifier is invalid",true);
1152                                                this.setCheck("identifier","invalid XML");
1153                                                this.canSave(false);
1154                                                org.isocat.APP.alert("This identifier is invalid","An identifier should be a valid local part of a qualified name as specified in the XML standard! This means, for example, that it isn't allowed to start with a number or to contain any spaces. You won't be able to save this (new) data category.",null,"OK");
1155                                        }
1156                                }
1157                        } else {
1158                                // check if this DC is in the set
1159                                var member = false;
1160                                for (var iter = ids.iterator();iter.hasNext();) {
1161                                        if (iter.next().selectSingleNode("id").getValue() == cid) {
1162                                                member = true;
1163                                                break;
1164                                        }
1165                                }
1166                                if (!member) {
1167                                        org.isocat.gui.DCEditor.log.info("owner/identifier combo does exist already");
1168                                        icon.setSrc("http://isocat:8080/Tango/16x16/status/dialog-warning.png");
1169                                        icon.repaint();
1170                                        text.setText("identifier already in use",true);
1171                                        var msg = "The registry already contains " + (ids.size()==1?"a data category":"data categories") +" with this identifier and owned by you:";
1172                                        msg += "<ol>";
1173                                        for (var iter = ids.iterator();iter.hasNext();) {
1174                                                var dup = iter.next();
1175                                                msg += '<li><a href="#" onclick="javascript:org.isocat.showDataCategoryInWindow(\''+dup.selectSingleNode("id").getValue()+'\')">'+dup.selectSingleNode("name").getValue()+'</a></li>';
1176                                        }
1177                                        msg += "</ol>";
1178                                        org.isocat.APP.alert("Data Category is known",msg,null,"OK",{nonModal:true});
1179                                        this.setCheck("identifier","ok");
1180                                        this.canSave(true);
1181                                } else {
1182                                        org.isocat.gui.DCEditor.log.info("found dc.id["+cid+"]");
1183                                        icon.setSrc("http://isocat:8080/famfamfam/silk/icons/tick.png");
1184                                        icon.repaint();
1185                                        text.setText("",true);
1186                                        this.setCheck("identifier","ok");
1187                                        this.canSave(true);
1188                                }
1189                        }
1190                } else {
1191                        org.isocat.gui.DCEditor.log.info("failed to check identifier");
1192                        icon.setSrc("http://isocat:8080/Tango/16x16/status/dialog-error.png");
1193                        icon.repaint();
1194                        text.setText("couldn't validate the indentifier",true);
1195                        this.setCheck("identifier","failed");
1196                        this.canSave(false);
1197                        org.isocat.APP.alert("Error validating identifier","An error occurred while validating the identifier! You won't be able to save this new data category. Please contact the system administrator.",null,"OK");
1198                }
1199        };
1200       
1201        DCEditor_prototype.checkConstraint = function(matrix,id,col,value) {
1202                var res = true;
1203               
1204                var attr = col.getPath();
1205                org.isocat.gui.DCEditor.log.info("column["+attr+"]");
1206
1207                var session = null;
1208                if (id=="jsxautorow") {
1209                        session = matrix.getAutoRowSession();
1210                        org.isocat.gui.DCEditor.log.info("autorow["+session+"]");
1211                } else {
1212                        session = matrix.getRecord(id);
1213                        org.isocat.gui.DCEditor.log.info("rec["+session+"]");
1214                }
1215
1216                var rtype = session["rule-type"];
1217                var rule  = session["jsxtext"];
1218                if (attr == "rule-type")
1219                        rtype = value;
1220                if (attr == "jsxtext")
1221                        rule = value;
1222                org.isocat.gui.DCEditor.log.info("rule-type["+rtype+"] rule["+rule+"]");
1223               
1224                if ((attr == "jsxtext") || (attr == "rule-type")) { // only check when the rule type or the rule changed
1225                        if ((typeof(rtype)!='undefined') && (typeof(rule)!='undefined')) {
1226                                var rid = this.ruleTypeMask.getXML().selectSingleNode("//record[@jsxtext='"+rtype+"']/@jsxid").getValue();
1227                                var rec = this.ruleTypeMask.getRecord(rid);
1228                                org.isocat.gui.DCEditor.log.info("rule-type["+rtype+"] needs XML["+(rec.xml=='true')+"]");
1229                               
1230                                if (rec.xml=='true') {
1231                                        var xdoc = new jsx3.xml.Document();
1232                                        xdoc.loadXML(rule);
1233                                        var err =  xdoc.getError();
1234                                        if (err.code != 0) {
1235                                                res = false;
1236                                                org.isocat.gui.DCEditor.log.info("XML check failed for rule["+rule+"]: "+err.description);
1237                                                org.isocat.APP.alert("This rule is invalid","A rule of type '"+rtype+"' needs to be wellformed XML! The XML parser reported the following error: <p>"+err.description+"</p> Due to this error you won't be able to save this (new) data category.",null,"OK");
1238                                                this.setCheck("constraint-"+session["jsxid"],"invalid-XML");
1239                                        } else {
1240                                                org.isocat.gui.DCEditor.log.info("XML check succeeded for rule["+rule+"]");
1241                                                this.setCheck("constraint-"+session["jsxid"],"ok");
1242                                        }
1243                                } else
1244                                        this.setCheck("constraint-"+session["jsxid"],"ok"); // free text constraints are always ok
1245                        }
1246                }
1247               
1248                this.canSave(res);
1249                return res;
1250        };
1251
1252        DCEditor_prototype.setCheck = function(id,status) {
1253                this.checks[id] = status;
1254                org.isocat.gui.DCEditor.log.info("check["+id+"]:"+this.checks[id]);
1255        };
1256
1257        DCEditor_prototype.anyError = function() {
1258                var res = false;
1259                for (check in this.checks) {
1260                        if (this.checks[check] != "ok") {
1261                                org.isocat.gui.DCEditor.log.info("check error["+check+"]:"+this.checks[check]);
1262                                res = true;
1263                                //break;
1264                        }
1265                }
1266                return res;
1267        };
1268       
1269        DCEditor_prototype.save = function() {
1270                var saveDC = org.isocat.APP.getRootBlock().loadAndCache("components/SaveDC.xml",true);
1271                if (typeof(this.dc) == 'undefined')
1272                        saveDC.controller.setType("CREATE");
1273                saveDC.controller.callback(this,this._save);
1274                saveDC.repaint();
1275                saveDC.controller.focus();
1276        };
1277       
1278        DCEditor_prototype._save = function(change) {
1279                this.cdf.write();
1280                org.isocat.gui.DCEditor.log.info("Synced CDF source with cache["+this.cacheId()+"].");
1281               
1282                //assemble the complete CDF document again
1283                var cdfDoc = this.cdf.getXML();
1284                org.isocat.replaceSubCDFDocument(cdfDoc,"admin","explanations",this.explanations.getXML(),true);
1285                org.isocat.replaceSubCDFDocument(cdfDoc,"admin","issues",this.issues.getXML(),true);
1286                org.isocat.replaceSubCDFDocument(cdfDoc,"descr","profiles",this.profiles.getProfiles(),true);
1287                org.isocat.replaceSubCDFDocument(cdfDoc,"descr","datanames",this.dataElementNames.getXML(),true);
1288               
1289                // save active language sections
1290                this.languageSectionLeft.save(false);
1291                this.languageSectionRight.save(false);
1292               
1293                // save conceptual domain
1294                var type = this.type.getValue()
1295                if (type != 'simple') {
1296                        if (type == 'closed') {
1297                                org.isocat.replaceSubCDFDocument(cdfDoc,"dc-"+(typeof(this.dc) == 'undefined'?0:this.dc.id),"conceptualdomain",this.valueDomain.getValues(),true);
1298                        }  else if (type == 'constrained') {
1299                                org.isocat.replaceSubCDFDocument(cdfDoc,"dc-"+(typeof(this.dc) == 'undefined'?0:this.dc.id),"conceptualdomain",this.constraints.getXML(),true);
1300                        }
1301                        var cd = cdfDoc.getRecordNode("conceptualdomain");
1302                        cd.setAttribute("type",type);
1303                        cd.setAttribute("datatype",this.datatypes.getRecord(this.datatypes.getValue()).jsxtext);
1304                        cd.setAttribute("datatype-id",this.datatypes.getValue());
1305                }
1306               
1307                // save the simple DC isA relation
1308                if (this.isARecord != null) {
1309                        cdfDoc.insertRecord(this.isARecord,"dc-"+(typeof(this.dc) == 'undefined'?0:this.dc.id));
1310                } else {
1311                        // remove any existing isA record in the CDF doc
1312                        cdfDoc.deleteRecord("is-a");
1313                }
1314               
1315                // save active language sections
1316                this.linguisticSectionLeft.save(false);
1317                this.linguisticSectionRight.save(false);
1318               
1319                // get the change document
1320                var changes = org.isocat.createSubCDFDocument(cdfDoc,"changes",true);
1321                changes.insertRecord({jsxid:jsx3.xml.CDF.getKey(), jsxtext:change});
1322                org.isocat.replaceSubCDFDocument(cdfDoc,"admin","changes",changes,true);
1323               
1324                // remove all autorow records
1325                var autorow = null;
1326                do {
1327                        autorow = cdfDoc.deleteRecord("jsxautorow");
1328                } while (autorow != null);
1329               
1330                // convert the CDF document to DCIF
1331                var dcifDoc = org.isocat.transformXML(cdfDoc,"CDF2DC_xsl");
1332                if (dcifDoc == null) {
1333                        org.isocat.gui.DCEditor.log.info("org.isocat.gui.DCEditor.save("+this.cacheId()+"):failed to transform!");
1334                        org.isocat.APP.alert("Saving the Data Category failed","The DC couldn't be saved! Contact the ISOcat system administrator.",null,"OK");
1335                        this.canSave(false);
1336                        return;
1337                }
1338
1339                var uri = "http://isocat:8080/isocat/rest";
1340                if (typeof(this.dc) == 'undefined') {
1341                        uri += "/dc";
1342                } else {
1343                        uri += "/user/"+escape(org.isocat.profile.user());
1344                        uri += "/session/"+escape(org.isocat.profile.session().id);
1345                        uri += "/lock/"+escape(this.lock.id);
1346                        uri += "/dc/"+escape(this.dc.id);
1347                }
1348                               
1349                var method = "POST";
1350                if (typeof(this.dc) == 'undefined')
1351                        method = "PUT";
1352                               
1353                org.isocat.gui.DCEditor.log.info("accessing service uri["+uri+"]["+method+"]["+dcifDoc+"]");
1354               
1355                //var req = new jsx3.net.Request().open(method,uri,false,org.isocat.profile.user(),org.isocat.profile.pass());
1356                var req = new jsx3.net.Request().open(method,uri,false);
1357                req.setRequestHeader("Content-Type","application/xml");// IE doesn't set this automagically (FF does), and otherwise NK won't pass it on to the ISOcat accessors
1358                req.setRequestHeader("Accept","application/x-dcif+xml");// we want the DCIF of the updated/new DC
1359                req.send(dcifDoc.toString());
1360               
1361                var status = req.getStatus();
1362                org.isocat.gui.DCEditor.log.info("service uri["+uri+"]["+method+"] returned HTTP status["+status+"]");
1363                               
1364                if ((status==200) || (status==201)) {
1365                        org.isocat.gui.DCEditor.log.info("service uri["+uri+"]["+method+"]["+status+"] response["+req.getResponseText()+"]");
1366                        var dcifDoc = new jsx3.xml.Document();
1367                        dcifDoc.loadXML(req.getResponseText());
1368                        //org.isocat.gui.DCEditor.log.info("DC["+dcifDoc+"]");
1369                        //var id = dcifDoc.selectSingleNode("/dcif:dataCategorySelection/dcif:dataCategory/@isocat:id",{dcif:'http://www.isocat.org/ns/dcif', isocat:'http://www.isocat.org/'}).getValue(); ... results in 'Multiple colons are not allowed in a name' error in IE
1370                        var id = null;
1371                        for (var iter = dcifDoc.getChildIterator();iter.hasNext();) {
1372                            var node = iter.next();
1373                            if (node.getBaseName() == 'dataCategory') {
1374                                id = node.getAttribute("isocat:id");
1375                            }
1376                        }
1377                        if (id==null)
1378                            org.isocat.APP.alert("Error","Sorry, the identity of this DC can't be determined! Please contact the ISOcat system administrator.",null,"OK")
1379                       
1380                        org.isocat.gui.DCEditor.log.info("DC["+dcifDoc+"]["+id+"]");
1381                       
1382                        if (typeof(this.dc) == 'undefined') {
1383                            // the DC now exists and has an id
1384                            this.dc = {id:id};
1385                            // and we now need a lock on it
1386                            if (!this.lockDataCategory())
1387                                    this.close(); // this should be almost impossible ... the owner would have to quickly lock it in another browser window
1388                            // also rename the window
1389                            if (this.window != null)
1390                                    this.window.setName("window-edit-DC-"+this.dc.id);
1391                            // ask if we need to add it to the basket
1392                            var view = this.view;
1393                            if (this.addToBasket) {
1394                                this.basket();
1395                            } else {
1396                                org.isocat.APP.confirm("Add to basket","Add this new Data Category to the basket?",
1397                                            function(dialog) {
1398                                                    jsx3.GO(view.getId()).controller.basket(dialog);
1399                                            },
1400                                            null,"Yes","No",1);
1401                            }
1402                        }
1403                       
1404                        // disable the type field, it can't be changed anymore
1405                        //this.type.setEnabled(jsx3.gui.Form.STATEDISABLED,true);
1406                       
1407                        // convert the DCIF document to CDF
1408                        var cdfDoc = org.isocat.transformXML(dcifDoc,"DC2CDF_xsl");
1409                        cdfDoc = jsx3.xml.CDF.Document.wrap(cdfDoc);
1410                        cdfDoc.convertProperties(org.isocat.APP.getProperties());
1411                       
1412                        // update the cached doc
1413                        org.isocat.APP.getCache().setDocument(this.cacheId(),cdfDoc);
1414
1415                        // reload the form with the DCIF so we get all ids at the right places ... TODO: prevent that this resets all kind of UI elements ...
1416                        this.update();
1417                       
1418                        // now we can check the DC
1419                        this.canCheck(true);
1420                        if (this.checkButton.getState()==jsx3.gui.ToolbarButton.STATEON) {
1421                            this.check(true);
1422                            org.isocat.gui.DCEditor.log.info("rechecked the DC");
1423                        } else {
1424                            org.isocat.gui.DCEditor.log.info("skipped rechecking the DC");
1425                        }
1426                       
1427                        // tell all listeners this DC is updated
1428                        org.isocat.publish("org.isocat.DC.reload",this.dc.id);
1429                } else if (status==403) {
1430                        org.isocat.APP.alert("Failed to save the DC","Sorry, you lost your edit lock on this DC.",null,"OK")
1431                        org.isocat.gui.DCEditor.log.info("failed to save the DC["+org.isocat.profile.user()+"]["+this.identifier.getValue()+"]:status["+status+"]");
1432                } else if (status==409) {
1433                        org.isocat.APP.alert("Failed to save the DC","Sorry, this DC already exists so the save failed.",null,"OK")
1434                        org.isocat.gui.DCEditor.log.info("failed to save the DC["+org.isocat.profile.user()+"]["+this.identifier.getValue()+"]:status["+status+"]");
1435                } else {
1436                        org.isocat.APP.alert("Failed to save the DC","Sorry, an error occurred on the server and the DC couldn't be saved.",null,"OK")
1437                        org.isocat.gui.DCEditor.log.info("failed to save the DC["+org.isocat.profile.user()+"]["+this.identifier.getValue()+"]:status["+status+"]");
1438                }
1439               
1440                this.canSave(false);
1441                this.setTitle();
1442                return true;
1443        };
1444       
1445        DCEditor_prototype.basket = function(dialog) {
1446                var dc = org.isocat.data.DC.load(this.dc.id);
1447                org.isocat.addToBasket(dc);
1448                if (typeof(dialog)!='undefined') {
1449                        dialog.doClose();
1450                }
1451        }
1452
1453        DCEditor_prototype.cancel = function() {
1454                if (this.window != null) {
1455                        var close = true;
1456                        var view = this.view;
1457                        if (this.change) {
1458                                org.isocat.APP.confirm("Close this DC Editor","There are unsaved changes! Do you really want to close this editor?",
1459                                        function(dialog) {
1460                                                jsx3.GO(view.getId()).controller.close(dialog);
1461                                        },
1462                                        null,"Yes","No",2);
1463                                close=false;
1464                        }
1465                        if (close)
1466                                this.close();
1467                }
1468                return close;
1469        };
1470       
1471        DCEditor_prototype.close = function(dialog) {
1472                if (this.lock != null) {
1473                        org.isocat.profile.unlockDC(this.lock.id);
1474                }
1475                if (this.window != null) {
1476                        org.isocat.gui.DCEditor.log.info("this.window["+this.window+"].doClose() ...");
1477                        this.window.doClose();
1478                        org.isocat.gui.DCEditor.log.info("... done");
1479                }
1480                if (typeof(dialog)!='undefined') {
1481                        dialog.doClose();
1482                }
1483        }
1484
1485        DCEditor_prototype.check = function(show) {
1486                if (show) {
1487                        // show the check result view
1488                        if (this.viewSplitter.getSubcontainer1Pct() == "100") {
1489                                this.viewSplitter.setSubcontainer1Pct("80",true);
1490                        }
1491               
1492                        // load the loading overlay
1493                        org.isocat.gui.Loading.load(this.checkView,"Checking ...").show();
1494
1495                        // request the check
1496                        var uri = "http://isocat:8080/isocat/rest/dc/"+this.dc.id+"/check"; 
1497                        org.isocat.asyncLoadDynamicCDFDocument(new jsx3.net.URI(uri),"Check2CDF_xsl",null,"check-dc-"+this.dc.id,this,this.checked);
1498                } else {
1499                        // hide the check result view
1500                        if (this.viewSplitter.getSubcontainer1Pct() != "100") {
1501                                this.viewSplitter.setSubcontainer1Pct("100",true);
1502                        }
1503                }
1504        };
1505       
1506        DCEditor_prototype.checked = function(doc,req) {
1507                org.isocat.gui.Loading.load(this.checkView).hide();
1508                if (doc!=null) {
1509                        this.checkResult.setXMLId("check-dc-"+this.dc.id);
1510                        this.checkResult.repaintData();
1511                   
1512                        // determine the check result
1513                        this.dc.check = req.getResponseXML().selectSingleNode('/check/@result').getValue();
1514                   
1515                        // update the check icon
1516                        this.checkIcon();
1517                } else {
1518                        // hide the check result view
1519                        if (this.viewSplitter.getSubcontainer1Pct() != "100") {
1520                                this.viewSplitter.setSubcontainer1Pct("100",true);
1521                        }
1522                        org.isocat.gui.DCViewer.log.info("The DC check call failed. The HTTP Status code is: " + req.getStatus());
1523                        org.isocat.APP.alert("DC checking failed","The DC couldn't be checked! Contact the ISOcat system administrator.",null,"OK");
1524                }
1525        };
1526       
1527        DCEditor_prototype.checkIcon = function() {
1528                        // set the correct check icon
1529                        if (typeof(this.dc.check)!='undefined') {
1530                            var prop = "icon: check "+this.dc.check;
1531                            if (org.isocat.APP.getProperties().containsKey(prop)) {
1532                                this.checkButton.setDynamicProperty("jsximage",prop,true)
1533                                this.checkButton.repaint();
1534                                 }
1535                        }
1536        }
1537       
1538        DCEditor_prototype.setTitle =  function() {
1539                var title = "New Data Category";
1540                if (typeof(this.dc) != 'undefined')
1541                        title = this.dc.name + " - " + this.dc.version;
1542                if (this.identifier.getValue() != '')
1543                        title = this.identifier.getValue() + " - " + this.version.getValue();
1544               
1545                if (this.change)
1546                        title += " *";
1547               
1548                org.isocat.gui.DCEditor.log.info("set DC editor title["+title+"].");
1549               
1550                if (this.window != null) {
1551                        this.label.setText("",true);
1552                        this.window.getCaptionBar().setText(title,true);
1553                        //this.windowButton.setEnabled(jsx3.gui.Form.STATEDISABLED,true);;
1554                } else {
1555                        this.label.setText(title,true);
1556                        //this.windowButton.setEnabled(jsx3.gui.Form.STATEENABLED,true);;
1557                }
1558        };
1559       
1560        DCEditor_prototype.setWindow = function(window) {
1561                this.window = window;
1562                this.setTitle();
1563                this.cancelButtonWizard.setVisibility(jsx3.gui.Block.VISIBILITYVISIBLE,true);
1564                var close = this.window.getDescendantOfName("btnClose");
1565                // remove existing close button listeners
1566                close.unsubscribeAll(jsx3.gui.Interactive.EXECUTE);
1567                close.setEvent("",jsx3.gui.Interactive.EXECUTE);
1568                // register our own listener
1569                close.subscribe(jsx3.gui.Interactive.EXECUTE,this,this.cancel);
1570        };
1571       
1572        DCEditor_prototype.focus = function() {
1573                this.view.focus();
1574
1575                jsx3.sleep(function() { this.identifier.focus(); },"focusDCEditor",this,true);
1576                org.isocat.gui.DCEditor.log.info("set DC editor focus to identifier field.");
1577
1578                // delayed till everything is painted ...
1579                this.setDCType(this.cdf.getXML().getRecord("admin").type);
1580        };
1581});
Note: See TracBrowser for help on using the repository browser.