source: DASISH/t5.6/client/chrome/markingcollection/content/markingcollection/treedate.js @ 2709

Last change on this file since 2709 was 2709, checked in by sroth, 11 years ago

Wired-Marker initial source code with minor adjustments.

  • Property svn:executable set to *
File size: 25.6 KB
Line 
1var bitsTreeDate = {
2        _init        : false,
3        _xmlfilename : 'treedate.xml',
4        _xmlfolder   : null,
5        _xmlfile     : null,
6        _xmldoc      : null,
7        _namespace   : 'http://www.bits.cc/Wired-Marker/',
8        _ns_alias    : 'WM',
9
10        _refresh_timer : null,
11
12        get APPCONT()  { return document.getElementById("appcontent"); },
13        get TREE()     { return document.getElementById("bitsTreeDate"); },
14
15        get idTREE_IDATE()     { return "bitsTreeDateTreecolDate"; },
16        get idTREE_TAB()       { return "mcTreeTabDate"; },
17        get idTREE_TABS()      { return "mcTreeTabs"; },
18
19        get TREE_IDATE()       { return document.getElementById(this.idTREE_IDATE); },
20        get TREE_TABS()        { return document.getElementById(this.idTREE_TABS); },
21
22        get POPUP()            { return document.getElementById("mcPopupDateFolder"); },
23
24        get SIDEBAR_BOX()      { return document.getElementById("bitsSidebarBox"); },
25        get SIDEBAR_TREEVBOX(){ return document.getElementById("mcTreeVBox"); },
26        get SIDEBAR_TREETBOX(){ return document.getElementById("mcTreeTabbox"); },
27        get SIDEBAR_TREE()     { return document.getElementById("mcTree"); },
28
29        get SIDEBAR()     { return window.top.document.getElementById("sidebar"); },
30        get SIDEBAR_DOC(){try{return this.SIDEBAR.contentDocument;}catch(e){return undefined;}},
31
32        get BROADCASTER(){ return window.top.document.getElementById("viewMarkingCollection"); },
33
34        get STRING()     { return window.top.document.getElementById("MarkingCollectionOverlayString"); },
35        get DataSource(){ return window.top.bitsObjectMng.DataSource; },
36        get Common()     { return window.top.bitsObjectMng.Common;     },
37        get XPath()      { return window.top.bitsObjectMng.XPath;      },
38        get Database()   { return window.top.bitsObjectMng.Database;   },
39        get XML()        { return window.top.bitsObjectMng.XML;   },
40        get gBrowser()   { return window.top.bitsObjectMng.getBrowser();},
41        get dbinfo()     { return window.top.bitsMarkingCollection.dbinfo; },
42        get localfolder(){ return window.top.bitsMarkingCollection.localfolder; },
43
44        get object(){return (this.TREE.currentIndex>=0 ? this.getRowObject(this.TREE.currentIndex) : undefined);},
45
46        get xmldoc()   { return this._xmldoc; },
47        get xmlfile()  { return this._xmlfile; },
48        get namespace(){ return this._namespace; },
49        get ns_alias(){ return this._ns_alias; },
50
51        get isChecked(){ return (this.SIDEBAR_TREETBOX.hidden == false && this.TREE_TABS.selectedItem.id == this.idTREE_TAB)?true:false; },
52
53/////////////////////////////////////////////////////////////////////
54        progressListener : {
55                QueryInterface : function(aIID){
56                        if(aIID.equals(Components.interfaces.nsIWebProgressListener) || aIID.equals(Components.interfaces.nsISupportsWeakReference) || aIID.equals(Components.interfaces.nsISupports)) return this;
57                        throw Components.results.NS_NOINTERFACE;
58                },
59                onLocationChange : function(webProgress, aRequest, aURI){
60                        if(webProgress.isLoadingDocument) return;
61                        bitsTreeDate.pageshow(webProgress.DOMWindow.document);
62                },
63                onStateChange : function(webProgress, request, stateFlags, status){
64                        if(webProgress.isLoadingDocument) return;
65                        bitsTreeDate.pageshow(webProgress.DOMWindow.document);
66                },
67                onProgressChange : function(){},
68                onStatusChange : function(){},
69                onSecurityChange : function(){},
70                onLinkIconAvailable : function(){}
71        },
72
73/////////////////////////////////////////////////////////////////////
74        loadxml : function(){
75                try{
76                        var extensionDir = this.Common.getExtensionDir().clone();
77                        if(extensionDir){
78                                this._xmlfolder = extensionDir;
79                                this._xmlfile = extensionDir.clone();
80                                this._xmlfile.append(this._xmlfilename);
81                                if(!this._xmlfile.exists()){
82                                        var aContent = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n';
83                                        aContent += '<!DOCTYPE TREEDATES>\n';
84                                        aContent += '<TREEDATES xmlns:WM="'+this.namespace+'"/>\n';
85                                        this.Common.writeFile(this._xmlfile,aContent,"UTF-8");
86                                }
87                                if(this._xmlfile.exists()){
88                                        function _loadXMLDocument(pUri){
89                                                if(pUri == undefined) return undefined;
90                                                var xmlDocument = window.top.bitsMarkingCollection.loadXMLDocument(pUri);
91                                                if(xmlDocument){
92                                                        return xmlDocument.documentElement;
93                                                }else{
94                                                        return undefined;
95                                                }
96                                        }
97                                        function _createXMLDocument(aXMLFile){
98                                                if(!aXMLFile) return undefined;
99                                                try{
100                                                        return _loadXMLDocument(bitsTreeDate.Common.IO.newFileURI(aXMLFile).spec);
101                                                }catch(ex){
102                                                        bitsTreeDate._dump("bitsTreeDate._createXMLDocument():"+ ex);
103                                                        return undefined;
104                                                }
105                                        }
106                                        this._xmldoc = _createXMLDocument(this._xmlfile);
107                                        if(this._xmldoc){
108                                                var nodes =  this.evaluateArray('//TREEDATE[@dbtype]');
109                                                for(var i=nodes.length-1;i>=0;i--){
110                                                        nodes[i].parentNode.removeChild(nodes[i]);
111                                                }
112                                        }
113                                }
114                        }
115                }catch(e){
116                        this._dump("bitsTreeDate.loadxml():"+e);
117                }
118        },
119
120/////////////////////////////////////////////////////////////////////
121        xmlflash : function(aTimeout){
122                try{
123                        if(!aTimeout) aTimeout = 0;
124                        var self = this;
125                        setTimeout(function(){ self._xmlflash(); },aTimeout);
126                }catch(e){
127                        this._dump("bitsTreeDate.xmlflash():"+e);
128                }
129        },
130
131/////////////////////////////////////////////////////////////////////
132        _xmlflash : function(aTimeout){
133                try{
134                        if(!this.xmldoc || !this.xmlfile) return;
135                        var s = new XMLSerializer();
136                        var xml = s.serializeToString(this.xmldoc);
137                        this.Common.writeFile(this.xmlfile, xml+"\n","UTF-8");
138                }catch(e){
139                        this._dump("bitsTreeDate._xmlflash():"+e);
140                }
141        },
142
143/////////////////////////////////////////////////////////////////////
144        evaluateArray : function(aExpr){
145                return this.XPath.evaluateArray(aExpr,this.xmldoc);
146        },
147
148/////////////////////////////////////////////////////////////////////
149        init : function(aEvent){
150                try{
151                        if(!this._init){
152                                var itemview_disp = nsPreferences.getBoolPref("wiredmarker.itemview.disp");
153                                if(itemview_disp == undefined) itemview_disp = true;
154                                if(!itemview_disp){
155                                        this.SIDEBAR_TREETBOX.hidden = true;
156                                        this.SIDEBAR_TREEVBOX.appendChild(this.SIDEBAR_TREE);
157                                }
158                                if(this.SIDEBAR_TREE.builderView) this.SIDEBAR_TREE.builderView.addObserver(mcTreeDNDHandler.builderObserver);
159                                this.loadxml();
160                                this._init = true;
161                                this.rebuild();
162                        }
163                }catch(e){
164                        alert(e);
165                }
166        },
167
168/////////////////////////////////////////////////////////////////////
169        disp : function(aEvent){},
170
171/////////////////////////////////////////////////////////////////////
172        done : function(aEvent){
173                if(this.SIDEBAR_TREE.builderView) this.SIDEBAR_TREE.builderView.removeObserver(mcTreeDNDHandler.builderObserver);
174                this._init = false;
175        },
176
177/////////////////////////////////////////////////////////////////////
178        treeDispChange : function(){},
179
180/////////////////////////////////////////////////////////////////////
181        onChangeListStyle : function(aEvent){},
182
183/////////////////////////////////////////////////////////////////////
184        onViewTypePopupCommand : function(aEvent){},
185
186/////////////////////////////////////////////////////////////////////
187        onSearchButtonCommand : function(aEvent){},
188
189/////////////////////////////////////////////////////////////////////
190// TREE 衚瀺制埡関連
191/////////////////////////////////////////////////////////////////////
192        get rowCount(){
193                return (this.itemObjects?this.itemObjects.length:0);
194        },
195        getRowObject : function(row){
196                return (row>=0 && this.itemObjects && this.itemObjects.length>row ? this.itemObjects[row] : undefined);
197        },
198        getCellText : function(row,column){
199                if(!this.itemObjects || !this.itemObjects[row]) return null;
200                return this.itemObjects[row].text;
201        },
202        setTree: function(treebox){ this.treebox = treebox; },
203        isContainer: function(row){
204                try{
205                        return this.itemObjects[row].container;
206                }catch(e){
207                        return false;
208                }
209        },
210        isContainerOpen: function(row){
211                return this.itemObjects[row].open;
212        },
213        isContainerEmpty: function(row){
214                return this.itemObjects[row].empty;
215        },
216        toggleOpenState: function(row){
217                this.itemObjects[row].open = !this.itemObjects[row].open;
218                var elems =  this.evaluateArray('//TREEDATE[@id="'+this.itemObjects[row].id+'"]');
219                if(elems && elems.length){
220                        elems[0].setAttribute('open',this.itemObjects[row].open);
221                        this.xmlflash();
222                }
223                if(this.itemObjects[row].open){
224                        var splice_pos = row;
225                        var len = this.itemObjects[row].childlen.length;
226                        for(var i=0;i<len;i++){
227                                splice_pos++;
228                                this.itemObjects.splice(splice_pos,0,this.itemObjects[row].childlen[i]);
229                                if(this.itemObjects[row].childlen[i].open){
230                                        for(var j=0;j<this.itemObjects[row].childlen[i].childlen.length;j++){
231                                                splice_pos++
232                                                this.itemObjects.splice(splice_pos,0,this.itemObjects[row].childlen[i].childlen[j]);
233                                                if(this.itemObjects[row].childlen[i].childlen[j].open){
234                                                        for(var k=0;k<this.itemObjects[row].childlen[i].childlen[j].childlen.length;k++){
235                                                                splice_pos++
236                                                                this.itemObjects.splice(splice_pos,0,this.itemObjects[row].childlen[i].childlen[j].childlen[k]);
237                                                        }
238                                                }
239                                        }
240                                }
241                        }
242                }else{
243                        var len = 0;
244                        for(var i=row+1;i<this.itemObjects.length;i++){
245                                if(this.itemObjects[row].level >= this.itemObjects[i].level) break;
246                                len++;
247                        }
248                        var remove_arr = this.itemObjects.splice(row+1, len);
249                }
250                this.TREE.view = this;
251        },
252  getParentIndex: function(row){
253                try{
254                        return this.itemObjects[row].parentIndex;
255                }catch(e){
256                        return -1;
257                }
258        },
259        hasNextSibling: function(row,afterRow){
260this._dump("hasNextSibling("+row+","+afterRow+")");
261                return this.itemObjects[row].hasNext;
262        },
263        isSeparator: function(row){ return false; },
264        isSorted: function(){ return true; },
265        getLevel: function(row){
266                try{
267                        return this.itemObjects[row].level;
268                }catch(e){
269                        return -1;
270                }
271        },
272        getImageSrc: function(row,column){
273                if(!this.itemObjects) return undefined;
274                if(!this.itemObjects[row]) return undefined;
275                return this.itemObjects[row].icon;
276        },
277        getRowProperties: function(row,prop){},
278        getCellProperties: function(row, column, prop){
279                if(row<this.itemObjects.length){
280                        var aserv=Components.classes["@mozilla.org/atom-service;1"].getService(Components.interfaces.nsIAtomService);
281                        prop.AppendElement(aserv.getAtom("folder"));
282                }
283        },
284        getColumnProperties: function(column, element, prop){},
285        cycleHeader : function(col){},
286        isEditable : function(row,column){ return column.editable; },
287        setCellText : function(row,column,text){},
288        setCellValue : function(row,column,text){},
289        canDrop : function(index, orient){ return false; },
290        onDrop : function(row, orient){},
291        drop : function(row, orient){},
292
293/////////////////////////////////////////////////////////////////////
294// Drag & Drop Old Callback functions
295/////////////////////////////////////////////////////////////////////
296        onOldDraggesture: function(aEvent){
297                aEvent.stopPropagation();
298        },
299        onOldDragover: function(aEvent){
300                aEvent.stopPropagation();
301        },
302        onOldDragdrop: function(aEvent){
303                aEvent.stopPropagation();
304        },
305        onOldDragexit: function(aEvent){
306                aEvent.stopPropagation();
307        },
308
309/////////////////////////////////////////////////////////////////////
310// Drag & Drop New Callback functions
311/////////////////////////////////////////////////////////////////////
312        onDragEvents: function(aEvent){},
313
314        onDragStart : function(event){},
315
316        onDropEvents: function(aEvent){},
317
318/////////////////////////////////////////////////////////////////////
319        onBrowserMousedown : function(aEvent){},
320
321/////////////////////////////////////////////////////////////////////
322        capture : function(aXferString, aRow, aOrient){},
323
324/////////////////////////////////////////////////////////////////////
325        getObjectFromID : function(aID){
326                if(this.itemObjects){
327                        var objects = this.itemObjects.filter(
328                                function(element, index, array) {
329                                        return element.id == (aID=='0'?'all':aID);
330                                }
331                        );
332                        if(objects && objects.length>0) return objects[0];
333                }
334                return undefined;
335        },
336
337/////////////////////////////////////////////////////////////////////
338        refresh : function(){
339                if(this._refresh_timer) clearTimeout(this._refresh_timer);
340                this._refresh_timer = setTimeout(function(){ bitsTreeDate._refresh(); },100);
341        },
342
343        _refresh : function(){
344                var idx = this.TREE.currentIndex;
345                var rows = this.getSelection();
346                this.rebuild();
347                try{this.TREE.currentIndex=idx;}catch(e){}
348                if(!this.itemObjects) return;
349                try{
350                        var i;
351                        for(i=0;i<rows.length;i++){
352                                if(!this.TREE.view.selection.isSelected(rows[i])) this.TREE.view.selection.select(rows[i]);
353                        }
354                }catch(e){}
355                bitsItemView.refresh();
356        },
357
358        rebuild : function(){
359                if(!this._init) return;
360                try{this.TREE.currentIndex = -1;}catch(e){}
361                try{this.TREE.view.selection.clearSelection();}catch(e){}
362                if(this.itemObjects){
363                        this.itemObjects.length = 0;
364                }else{
365                        this.itemObjects = [];
366                }
367                var flash_flag = false;
368                var elem_id = 'all';
369                var obj_db = {
370                        id : elem_id,
371                        text : 'All',
372                        container : true,
373                        open : true,
374                        empty : false,
375                        level : 0,
376                        parentIndex : -1,
377                        hasNext : false,
378                        childlen : []
379                };
380                var elems =  this.evaluateArray('//TREEDATE[@id="'+elem_id+'"]');
381                if(elems && elems.length){
382                        obj_db.open = (elems[0].getAttribute("open")==="true");
383                }else{
384                        var elem = this.xmldoc.ownerDocument.createElement('TREEDATE');
385                        elem.setAttribute('id',elem_id);
386                        elem.setAttribute('open',true);
387                        this.xmldoc.appendChild(elem);
388                        flash_flag = true;
389                }
390                this.itemObjects.push(obj_db);
391                var dbtype_pos = this.itemObjects.length-1;
392                var objects_year = this.Database.getObjectYear();
393                if(objects_year){
394                        for(var i=0;i<objects_year.length;i++){
395                                var objects_month = this.Database.getObjectMonthFromYear(objects_year[i]);
396                                var elem_id = objects_year[i];
397                                var obj_year = {
398                                        id : elem_id,
399                                        text : objects_year[i],
400                                        date : {
401                                                year : objects_year[i]
402                                        },
403                                        container : true,
404                                        open : false,
405                                        empty : false,
406                                        level : 1,
407                                        parentIndex : dbtype_pos,
408                                        hasNext : (i<objects_year.length-1)?true:false,
409                                        childlen : []
410                                };
411                                var elems =  this.evaluateArray('//TREEDATE[@id="'+elem_id+'"]');
412                                if(elems && elems.length){
413                                        obj_year.open = (elems[0].getAttribute("open")==="true");
414                                }else{
415                                        var elem = this.xmldoc.ownerDocument.createElement('TREEDATE');
416                                        elem.setAttribute('id',elem_id);
417                                        elem.setAttribute('open',false);
418                                        this.xmldoc.appendChild(elem);
419                                        flash_flag = true;
420                                }
421                                if(obj_db.open) this.itemObjects.push(obj_year);
422                                var len = this.itemObjects.length-1;
423                                for(var j=0;j<objects_month.length;j++){
424                                        var month_text = (new Date(objects_year[i],objects_month[j]-1,1)).toDateString().replace(/^\w+\s+(\w+)\s+\d+\s+\d+$/,"$1").toUpperCase();
425                                        var elem_id = objects_year[i]+objects_month[j];
426                                        var obj_month = {
427                                                id : elem_id,
428                                                text : month_text,
429                                                date : {
430                                                        year  : objects_year[i],
431                                                        month : objects_month[j]
432                                                },
433                                                container : true,
434                                                open : false,
435                                                empty : false,
436                                                level : 2,
437                                                parentIndex : i,
438                                                hasNext : (j<objects_month.length-1)?true:false,
439                                                childlen : []
440                                        };
441                                        var elems =  this.evaluateArray('//TREEDATE[@id="'+elem_id+'"]');
442                                        if(elems && elems.length){
443                                                obj_month.open = (elems[0].getAttribute("open")==="true");
444                                        }else{
445                                                var elem = this.xmldoc.ownerDocument.createElement('TREEDATE');
446                                                elem.setAttribute('id',elem_id);
447                                                elem.setAttribute('open',false);
448                                                this.xmldoc.appendChild(elem);
449                                                flash_flag = true;
450                                        }
451                                if(obj_db.open && obj_year.open) this.itemObjects.push(obj_month);
452                                        var objects_day = this.Database.getObjectDayFromYearMonth(objects_year[i],objects_month[j]);
453                                        if(objects_day){
454                                                for(var k=0;k<objects_day.length;k++){
455                                                        var dat_text = objects_day[k];
456                                                        var elem_id = objects_year[i]+objects_month[j]+objects_day[k];
457                                                        var obj_day = {
458                                                                id : elem_id,
459                                                                text : dat_text,
460                                                                date : {
461                                                                        year  : objects_year[i],
462                                                                        month : objects_month[j],
463                                                                        day   : objects_day[k]
464                                                                },
465                                                                container : true,
466                                                                open : false,
467                                                                empty : true,
468                                                                level : 3,
469                                                                parentIndex : j,
470                                                                hasNext : (k<objects_day.length-1)?true:false,
471                                                                childlen : []
472                                                        };
473                                                        var elems =  this.evaluateArray('//TREEDATE[@id="'+elem_id+'"]');
474                                                        if(elems && elems.length){
475                                                                obj_day.open = (elems[0].getAttribute("open")==="true");
476                                                        }else{
477                                                                var elem = this.xmldoc.ownerDocument.createElement('TREEDATE');
478                                                                elem.setAttribute('id',elem_id);
479                                                                elem.setAttribute('open',false);
480                                                                this.xmldoc.appendChild(elem);
481                                                                flash_flag = true;
482                                                        }
483                                                        obj_month.childlen.push(obj_day);
484                                                        if(obj_db.open && obj_year.open && obj_month.open) this.itemObjects.push(obj_day);
485                                                }
486                                        }
487                                        obj_year.childlen.push(obj_month);
488                                }
489                                this.itemObjects[dbtype_pos].childlen.push(obj_year);
490                        }
491                }
492                if(flash_flag) this.xmlflash();
493                this.TREE.view = this;
494        },
495
496/////////////////////////////////////////////////////////////////////
497// TREE むベント関連
498/////////////////////////////////////////////////////////////////////
499        onMousedown : function(aEvent){
500                this.TREE.removeAttribute("contextmenu");
501                if(aEvent.button == 2){ //右クリック
502                        var row = {};
503                        var col = {};
504                        var obj = {};
505                        this.TREE.treeBoxObject.getCellAt(aEvent.clientX, aEvent.clientY, row, col, obj);
506                        if(row.value>=0) this.TREE.setAttribute("contextmenu",this.POPUP.id);
507                }
508        },
509
510        onMousemove : function(aEvent){},
511
512        onMouseout : function(aEvent){},
513
514        onClick : function(aEvent){
515                var row = {};
516                var col = {};
517                var obj = {};
518                this.TREE.treeBoxObject.getCellAt(aEvent.clientX, aEvent.clientY, row, col, obj);
519                if(row.value<0){
520                        this.TREE.view.selection.clearSelection();
521                        return;
522                }
523                if(this.itemObjects && this.itemObjects[row.value]){
524                        var viewmode = mcTreeViewModeService.viewmode;
525                        var param = {
526                                viewmode : viewmode,
527                                dbtype : this.itemObjects[row.value].dbtype,
528                                where    : []
529                        };
530                        if(window.top.bitsMarkingCollection._uncategorized.use){
531                                param.res = this.Common.RDF.GetResource(this.DataSource.getID2About("0",undefined,window.top.bitsMarkingCollection._uncategorized.dbtype));
532                        }
533                        if(this.itemObjects[row.value].date){
534                                param.where.push({
535                                        key : "substr(om_object.oid_date,7,4)",
536                                        val : this.itemObjects[row.value].date.year
537                                });
538                                if(this.itemObjects[row.value].date.month){
539                                        param.where.push({
540                                                key : "substr(om_object.oid_date,1,2)",
541                                                val : this.itemObjects[row.value].date.month
542                                        });
543                                        if(this.itemObjects[row.value].date.day){
544                                                param.where.push({
545                                                        key : "substr(om_object.oid_date,4,2)",
546                                                        val : this.itemObjects[row.value].date.day
547                                                });
548                                        }
549                                }
550                        }
551                        bitsItemView.onTreeDateClick(param);
552                        bitsItemView.TREE.currentIndex = 0;
553                        try{
554                                if(!bitsItemView.TREE.view.selection.isSelected(bitsItemView.TREE.currentIndex)) bitsItemView.TREE.view.selection.select(bitsItemView.TREE.currentIndex);
555                                if(bitsItemView.itemObjects && bitsItemView.itemObjects[bitsItemView.TREE.currentIndex]){
556                                        var objs = bitsItemView.Database.getObject({oid:bitsItemView.itemObjects[bitsItemView.TREE.currentIndex].oid}, bitsItemView.itemObjects[bitsItemView.TREE.currentIndex].dbtype);
557                                        if(objs && objs.length>0) mcPropertyView.dispProperty(objs[0]);
558                                }
559                        }catch(e){
560                                this._dump("bitsTreeDate.onClick():"+e);
561                                setTimeout(function(){
562                                        if(bitsItemView.TREE.view && !bitsItemView.TREE.view.selection.isSelected(bitsItemView.TREE.currentIndex)) bitsItemView.TREE.view.selection.select(bitsItemView.TREE.currentIndex);
563                                        if(bitsItemView.itemObjects && bitsItemView.itemObjects[bitsItemView.TREE.currentIndex]){
564                                                var objs = bitsItemView.Database.getObject({oid:bitsItemView.itemObjects[bitsItemView.TREE.currentIndex].oid}, bitsItemView.itemObjects[bitsItemView.TREE.currentIndex].dbtype);
565                                                if(objs && objs.length>0) mcPropertyView.dispProperty(objs[0]);
566                                        }
567                                },1000);
568                        }
569                }
570
571                //おたじない
572                this.TREE.blur();
573                this.TREE.focus();
574        },
575
576        onDblClick : function(aEvent){},
577
578        onKeyPress : function(aEvent){},
579
580        onKeyDown : function(aEvent){},
581
582        onSelectTab : function(aObject){
583                if(!this._init) return;
584                if(bitsItemView.TREE_IFOLDER.hidden) bitsItemView.TREE_IFOLDER.hidden = false;
585                if(bitsItemView.TREE_IFOLDERSTYLE.hidden) bitsItemView.TREE_IFOLDERSTYLE.hidden = false;
586                var dbtype = undefined;
587                if(this.itemObjects && aObject){
588                        dbtype = aObject.dbtype;
589                        delete aObject.dbtype;
590                        var objects = this.Database.getObject(aObject, dbtype);
591                        if(objects && objects.length>0){
592                                var year = objects[0].oid_date.substr(6,4);
593                                var month = objects[0].oid_date.substr(0,2);
594                                var day = objects[0].oid_date.substr(3,2);
595                                var len = this.itemObjects.length;
596                                var exists = false;
597                                var target_id = year+month+day;
598                                var id = year+month+day;
599                                var selectIdx = -1;
600                                for(var i=0;i<len;i++){
601                                        if(this.itemObjects[i].id != id) continue;
602                                        exists = true;
603                                        selectIdx = i;
604                                        break;
605                                }
606                                if(!exists){
607                                        id = year+month;
608                                        for(var i=0;i<len;i++){
609                                                if(this.itemObjects[i].id != id) continue;
610                                                exists = true;
611                                                selectIdx = i;
612                                                break;
613                                        }
614                                }
615                                if(!exists){
616                                        id = year;
617                                        for(var i=0;i<len;i++){
618                                                if(this.itemObjects[i].id != id) continue;
619                                                exists = true;
620                                                selectIdx = i;
621                                                break;
622                                        }
623                                }
624                                if(selectIdx>=0){
625                                        if(this.isContainer(selectIdx) && !this.isContainerOpen(selectIdx)) this.toggleOpenState(selectIdx);
626                                        if(target_id != id){
627                                                aObject.dbtype = dbtype;
628                                                setTimeout(function(){ bitsTreeDate.onSelectTab(aObject); },100);
629                                                return;
630                                        }else{
631                                                this.TREE.currentIndex = selectIdx;
632                                                if(!this.TREE.view.selection.isSelected(this.TREE.currentIndex)) this.TREE.view.selection.select(this.TREE.currentIndex);
633                                        }
634                                }
635                        }
636                }
637                var idx = this.TREE.currentIndex;
638                var rows = this.getSelection();
639                if(rows && rows.length && rows[0]<this.rowCount){
640                        var row = {value:rows[0]};
641                        var viewmode = mcTreeViewModeService.viewmode;
642                        var param = {
643                                viewmode : viewmode,
644                                dbtype   : this.itemObjects[row.value].dbtype,
645                                where    : [],
646                        };
647                        if(window.top.bitsMarkingCollection._uncategorized.use){
648                                param.res = this.Common.RDF.GetResource(this.DataSource.getID2About("0",undefined,window.top.bitsMarkingCollection._uncategorized.dbtype));
649                        }
650                        if(this.itemObjects && this.itemObjects[row.value]){
651                                if(this.itemObjects[row.value].date){
652                                        param.where.push({
653                                                key : "substr(om_object.oid_date,7,4)",
654                                                val : this.itemObjects[row.value].date.year
655                                        });
656                                        if(this.itemObjects[row.value].date.month){
657                                                param.where.push({
658                                                        key : "substr(om_object.oid_date,1,2)",
659                                                        val : this.itemObjects[row.value].date.month
660                                                });
661                                                if(this.itemObjects[row.value].date.day){
662                                                        param.where.push({
663                                                                key : "substr(om_object.oid_date,4,2)",
664                                                                val : this.itemObjects[row.value].date.day
665                                                        });
666                                                }
667                                        }
668                                }
669                        }
670                        bitsItemView.onTreeDateClick(param);
671                }else{
672                        bitsItemView.onTreeDateClick();
673                }
674                if(aObject && aObject.oid){
675                        setTimeout(function(){ mcItemView.setSelection(aObject.oid,dbtype); },0);
676                }else{
677                        setTimeout(function(){
678                                if(!bitsItemView.TREE.view) return;
679                                bitsItemView.TREE.currentIndex = 0;
680                                if(!bitsItemView.TREE.view.selection.isSelected(bitsItemView.TREE.currentIndex)) bitsItemView.TREE.view.selection.select(bitsItemView.TREE.currentIndex);
681                                if(bitsItemView.itemObjects && bitsItemView.itemObjects[bitsItemView.TREE.currentIndex]){
682                                        var objs = bitsItemView.Database.getObject({oid:bitsItemView.itemObjects[bitsItemView.TREE.currentIndex].oid}, bitsItemView.itemObjects[bitsItemView.TREE.currentIndex].dbtype);
683                                        if(objs && objs.length>0) mcPropertyView.dispProperty(objs[0]);
684                                }
685                        },0);
686                }
687        },
688
689        onSelectTabs : function(aEvent){
690                if(!this._init) return;
691                mcPropertyView.dispProperty();
692                if(aEvent.target.selectedItem.id == this.idTREE_TAB){
693                        this.onSelectTab();
694                }else{
695                        mcItemView.onTreeClick();
696                        mcPropertyView.dispProperty(mcTreeHandler.object);
697                }
698        },
699
700/////////////////////////////////////////////////////////////////////
701// TREE 関連
702/////////////////////////////////////////////////////////////////////
703        copy : function(aMode){},
704
705        open : function(tabbed){},
706
707        confirmRemovingFor : function(){},
708
709        setSelection : function(aOID,aDBTYPE){},
710
711        getSelection : function(){
712                if(!this.TREE || !this.TREE.view) return undefined;
713                var ret = [];
714                var rc;
715                var i;
716                for(rc=0;rc<this.TREE.view.selection.getRangeCount();rc++){
717                        var start = {}, end = {};
718                        this.TREE.view.selection.getRangeAt(rc, start, end);
719                        for(i=start.value;i<= end.value;i++){
720                                if(!this.TREE.view.selection.isSelected(i)) continue;
721                                ret.push(i);
722                        }
723                }
724                return ret;
725        },
726
727        validateMultipleSelection : function(aIdxList){},
728
729        mergeObject : function(aFolder){},
730
731        copyObject : function(aFolder){},
732
733        moveObject : function(aFolder,aModShift){},
734
735        remove : function(aEvent){},
736
737        pageshow : function(aDoc){},
738
739        getElemOffsetHeight : function(elem,height){},
740
741        getElementById : function(pElemId){},
742
743        doTopElement : function(pElemId,aStyle,aID,aDBType){},
744
745        doTopElementIMG : function(aID,aDBType){},
746
747        changeNodeStyleFromID : function(aID,aStyle,pPfid){},
748
749        property : function(){},
750
751////////////////////////////////////////////////////////////////////
752// TREE ドラッグむベント関連
753/////////////////////////////////////////////////////////////////////
754        getModifiers : function(aEvent){},
755
756        dragDropObserver : {
757                onDragStart : function(event, transferData, action){},
758                getSupportedFlavours : function(){},
759                onDragOver : function(event, flavour, session){},
760                onDragExit : function(event, session){},
761                onDrop     : function(event, transferData, session){}
762        },
763
764/////////////////////////////////////////////////////////////////////
765// Popup むベント関連
766/////////////////////////////////////////////////////////////////////
767        onPopupShowing : function(aEvent){},
768
769        onPopupHiding : function(aEvent){},
770
771        onPopupCommand : function(aEvent){},
772
773/////////////////////////////////////////////////////////////////////
774        onSearchKeyPress : function(aEvent){},
775
776
777/////////////////////////////////////////////////////////////////////
778        _dump : function(aString){
779                window.top.bitsMarkingCollection._dump(aString);
780        },
781};
Note: See TracBrowser for help on using the repository browser.