Commit a2d616d19c2c45fc31d9ff685f92fbfa626ec561

Authored by Elena.Budnik
1 parent b2c4f9ed

Anomalie 4830; right click : select + context menu

Showing 2 changed files with 167 additions and 153 deletions   Show diff stats
js/app/views/ExplorerUI.js
... ... @@ -53,9 +53,9 @@ Ext.define('amdaUI.TreeToolColumn', {
53 53 {
54 54 if(type === "click" && e.target.tagName === "IMG")
55 55 {
56   - var tooltype = e.target.getAttribute("tooltype");
57   - if(tooltype)
58   - return this.fireEvent("toolclick", view, cell, recordIndex, cellIndex, e);
  56 + var tooltype = e.target.getAttribute("tooltype");
  57 + if(tooltype)
  58 + return this.fireEvent("toolclick", view, cell, recordIndex, cellIndex, e);
59 59 }
60 60 return this.fireEvent.apply(this, arguments);
61 61 },
... ... @@ -287,11 +287,9 @@ Ext.define('amdaUI.ExplorerUI', {
287 287 store: store,
288 288 rootVisible: false,
289 289 animate: false,
290   - hideHeaders : true,
291   - //TODO deprecated
292   - //multiSelect: true,
  290 + hideHeaders : true,
293 291 selModel: Ext.create('Ext.selection.TreeModel', {
294   - ignoreRightMouseSelection: true,
  292 + // ignoreRightMouseSelection: true,
295 293 mode: 'MULTI'
296 294 }),
297 295  
... ... @@ -496,153 +494,149 @@ Ext.define('amdaUI.ExplorerUI', {
496 494 }
497 495 },
498 496 },
499   - listeners: {
  497 + listeners: {
500 498  
501   - itemmouseenter: function(view, record, item){
502   - if(record.get('isParameter')){
503   - var el = Ext.get(item),
504   - td = el.down('td > div');
505   - td.setStyle('cursor', 'crosshair');
506   - }
507   - else
508   - {
509   - var el = Ext.get(item),
510   - td = el.down('td > div');
511   - td.setStyle('cursor', 'pointer');
512   - }
  499 + itemmouseenter: function(view, record, item){
  500 + if(record.get('isParameter')){
  501 + var el = Ext.get(item),
  502 + td = el.down('td > div');
  503 + td.setStyle('cursor', 'crosshair');
  504 + }
  505 + else
  506 + {
  507 + var el = Ext.get(item),
  508 + td = el.down('td > div');
  509 + td.setStyle('cursor', 'pointer');
  510 + }
513 511 },
514   - itemcontextmenu: function(view, rec, item, index, e){
515   - // block other events
516   - e.stopEvent();
517   -
518   - // unlock selection
519   - view.ownerCt.getSelectionModel().setLocked(false);
520   -
521   - view.ownerCt.getSelectionModel().select(rec,true);
522   -
523   - // clear menu items
524   - menu.removeAll();
525   - var menuItems;
  512 +
  513 + itemcontextmenu: function(view, rec, item, index, e){
  514 + // block other events
  515 + e.stopEvent();
  516 +
  517 + // unlock selection
  518 + view.ownerCt.getSelectionModel().setLocked(false);
  519 + // already selected by default by right click
  520 + // view.ownerCt.getSelectionModel().select(rec,true);
  521 +
  522 + // clear menu items
  523 + menu.removeAll();
  524 + var menuItems;
526 525  
527   - // if it's a single selection
528   - if (view.ownerCt.getSelectionModel().selected.length === 1) {
529   - // get items menu corresponding to right clicked record
530   - menuItems = rec.getContextMenuItems(this);
531   -
532   - } else if (view.ownerCt.getSelectionModel().selected.length > 1) {
533   - // get items menu corresponding to right clicked record
534   - menuItems = rec.getContextMenuMultiItems(this);
535   -
536   - }
  526 + // if it's a single selection
  527 + if (view.ownerCt.getSelectionModel().selected.length === 1) {
  528 + // get items menu corresponding to right clicked record
  529 + menuItems = rec.getContextMenuItems(this);
  530 +
  531 + } else if (view.ownerCt.getSelectionModel().selected.length > 1) {
  532 + // get items menu corresponding to right clicked record
  533 + menuItems = rec.getContextMenuMultiItems(this);
  534 + }
537 535  
538 536 // if there's at least one item menu
539   - if (menuItems && menuItems.length){
540   - // add the items
541   - menu.add(menuItems);
542   - // add listener on right clicked record
543   - var onRecordClick = function (menu, item, e, eOpts)
544   - {
545   - //Dispatch click event to the record
546   - this.onMenuItemClick(menu,item,e);
547   - //Remove old click listener
548   - menu.removeListener('click',onRecordClick,this);
549   - };
550   - menu.addListener('click',onRecordClick,rec);
551   -
552   - // then show menu
553   - menu.showAt(e.getXY());
554   - }
555   - },
  537 + if (menuItems && menuItems.length){
  538 + // add the items
  539 + menu.add(menuItems);
  540 + // add listener on right clicked record
  541 + var onRecordClick = function (menu, item, e, eOpts)
  542 + {
  543 + //Dispatch click event to the record
  544 + this.onMenuItemClick(menu,item,e);
  545 + //Remove old click listener
  546 + menu.removeListener('click',onRecordClick,this);
  547 + };
  548 + menu.addListener('click',onRecordClick,rec);
  549 + // then show menu
  550 + menu.showAt(e.getXY());
  551 + }
  552 + },
556 553  
557   - itemdblclick: function(view, record, item, index, event){
558   - event.stopEvent();
559   -
560   - // first check if it is for SAVE-START-STOP plugin...
561   - if (Ext.PluginManager.getCount() > 0 &&
562   - record.get('nodeType') == amdaModel.TimeTableNode.nodeType && record.isLeaf()) {
563   - var zmgr = myDesktopApp.desktop.getDesktopZIndexManager();
564   - var winActive = zmgr.getActive();
565   - var winId = winActive.getId();
566   - if (winId == 'explorer-win') {
567   - zmgr.eachTopDown(function(win) {
568   - var id = win.getId();
569   - if (id !== 'explorer-win') {
570   - winId = id;
571   - return false;
572   - }
573   - });
574   - }
575   - }
  554 + itemdblclick: function(view, record, item, index, event){
  555 + event.stopEvent();
  556 +
  557 + // first check if it is for SAVE-START-STOP plugin...
  558 + if (Ext.PluginManager.getCount() > 0 &&
  559 + record.get('nodeType') == amdaModel.TimeTableNode.nodeType && record.isLeaf()) {
  560 + var zmgr = myDesktopApp.desktop.getDesktopZIndexManager();
  561 + var winActive = zmgr.getActive();
  562 + var winId = winActive.getId();
  563 + if (winId == 'explorer-win') {
  564 + zmgr.eachTopDown(function(win) {
  565 + var id = win.getId();
  566 + if (id !== 'explorer-win') {
  567 + winId = id;
  568 + return false;
  569 + }
  570 + });
  571 + }
  572 + }
576 573  
577   -// var targetModuleName = myDesktopApp.getModule('explorer-win').getPinedModule();
578   - if (record.get('nodeType') == 'remoteParam' && !record.isLeaf()
579   - && !record.get('isParameter')) {
580   - myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.interop.id, true, function (module) {
581   - module.createWindow(record.getBaseId());
582   - });
583   -
584   - }
  574 + if (record.get('nodeType') == 'remoteParam' && !record.isLeaf()
  575 + && !record.get('isParameter')) {
  576 + myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.interop.id, true, function (module) {
  577 + module.createWindow(record.getBaseId());
  578 + });
  579 + }
585 580  
586   - if (record.isLeaf() || record.data.isParameter)
587   - switch (record.get('nodeType'))
588   - {
589   - case 'myData' :
590   - case 'myDataParam' :
591   - case 'derivedParam' :
592   - case 'timeTable' :
593   - case 'sharedtimeTable' :
594   - case 'sharedcatalog' :
595   - case 'catalog' :
596   - case 'request' :
597   - case 'condition' :
598   - record.editLeaf();
599   - break;
600   - case 'localParam' :
601   - case 'remoteParam':
602   - case 'remoteSimuParam':
603   - record.createAlias(record);
604   - break;
605   - case 'bkgWorks' :
606   - if (!record.get('object')) {
607   - AmdaAction.getObject(record.get('id'), record.get('nodeType'), record.getObjectCallback, record);
608   - }
609   - else {
610   - if (record.get('status') == 'done') {
611   - var isInteractive = false;
612   - var isNewTab = true;
613   - record.editNode(isNewTab, isInteractive);
614   - }
615   - else {
616   - myDesktopApp.infoMsg('Job Status: ' + record.get('status'));
617   - }
618   - }
619   - break;
620   - }
621   -
622   - },
623   - beforeselect: function(view,node,index,options){
624   - // if there's at least one node already selected
625   - if(view.selected.length
626   - //AND (the node which is beeing selected has a different nodeType than the first selected node OR the first selected node isn't a leaf
627   - && ( node.get('nodeType')!== view.selected.items[0].get('nodeType') || !view.selected.items[0].isLeaf())
628   - // OR the node which is beeing selected has no nodeType OR it isn't a leaf OR
629   - || !node.get('nodeType') || !node.isLeaf()
630   - ){
631   - // clear old selection
632   - view.deselectAll();
633   - }
634   - },
635   - itemmousedown: function(tree,rec,item,index,event,options){
636   - if(event.button===2){
637   - // if the right clicked item is already selected
638   - if (tree.getSelectionModel().isSelected(rec)) {
639   - // lock selection to prevent the selection modification by the right click
640   - tree.getSelectionModel().setLocked(true);
641   - }
642   - }
643   - },
  581 + if (record.isLeaf() || record.data.isParameter)
  582 + switch (record.get('nodeType'))
  583 + {
  584 + case 'myData' :
  585 + case 'myDataParam' :
  586 + case 'derivedParam' :
  587 + case 'timeTable' :
  588 + case 'sharedtimeTable' :
  589 + case 'sharedcatalog' :
  590 + case 'catalog' :
  591 + case 'request' :
  592 + case 'condition' :
  593 + record.editLeaf();
  594 + break;
  595 + case 'localParam' :
  596 + case 'remoteParam':
  597 + case 'remoteSimuParam':
  598 + record.createAlias(record);
  599 + break;
  600 + case 'bkgWorks' :
  601 + if (!record.get('object')) {
  602 + AmdaAction.getObject(record.get('id'), record.get('nodeType'), record.getObjectCallback, record);
  603 + }
  604 + else {
  605 + if (record.get('status') == 'done') {
  606 + var isInteractive = false;
  607 + var isNewTab = true;
  608 + record.editNode(isNewTab, isInteractive);
  609 + }
  610 + else {
  611 + myDesktopApp.infoMsg('Job Status: ' + record.get('status'));
  612 + }
  613 + }
  614 + break;
  615 + }
  616 + },
  617 + beforeselect: function(view,node,index,options){
  618 + // if there's at least one node already selected
  619 + if(view.selected.length
  620 + //AND (the node which is beeing selected has a different nodeType than the first selected node OR the first selected node isn't a leaf
  621 + && ( node.get('nodeType')!== view.selected.items[0].get('nodeType') || !view.selected.items[0].isLeaf())
  622 + // OR the node which is beeing selected has no nodeType OR it isn't a leaf OR
  623 + || !node.get('nodeType') || !node.isLeaf()
  624 + ){
  625 + // clear old selection
  626 + view.deselectAll();
  627 + }
  628 + },
  629 + itemmousedown: function(tree,rec,item,index,event,options){
  630 + if(event.button===2){
  631 + // if the right clicked item is already selected
  632 + if (tree.getSelectionModel().isSelected(rec)) {
  633 + // lock selection to prevent the selection modification by the right click
  634 + tree.getSelectionModel().setLocked(true);
  635 + }
  636 + }
  637 + },
644 638 afterrender: function(comp){
645   - var view = comp.getView();
  639 + var view = comp.getView();
646 640 view.tip = Ext.create('Ext.tip.ToolTip', {
647 641 // The overall target element.
648 642 target: view.el,
... ... @@ -673,14 +667,15 @@ Ext.define('amdaUI.ExplorerUI', {
673 667 },
674 668 // if remote base is empty - open interoperability module
675 669 itemexpand: function(node) {
676   - if ( node.get('nodeType') == amdaModel.RemoteParamNode.nodeType
677   - && node.getDepth() == 3 && !node.hasChildNodes()) {
678   - node.addData();
679   - }
  670 + if ( node.get('nodeType') == amdaModel.RemoteParamNode.nodeType
  671 + && node.getDepth() == 3 && !node.hasChildNodes()) {
  672 + node.addData();
  673 + }
680 674 },
681   - scope: this
682   - },
683   - hideHeaders: true,
  675 + scope: this
  676 + },
  677 +
  678 + hideHeaders: true,
684 679 // must define a column with a field to enable editor
685 680 columns: [{
686 681 xtype : 'treetoolcolumn',
... ...
js/lib/ext-override.js
... ... @@ -96,7 +96,26 @@ Ext.onReady(function () {
96 96 }
97 97 }
98 98 });*/
99   -
  99 +
  100 +
  101 + Ext.override(Ext.selection.TreeModel, {
  102 +
  103 + onRowClick: function (view, record, item, index, e) {
  104 + // Record index will be -1 if the clicked record is a metadata record and not selectable
  105 + if (index !== -1) {
  106 + if (!this.allowRightMouseSelection(e)) {
  107 + return ;
  108 + }
  109 +
  110 + //Don't process if it's a right-click over a previously selected record.
  111 + // if (!(e.type === 'contextmenu' && this.isSelected(record))) {
  112 + this.processSelection(view, record, item, index, e);
  113 + // }
  114 + }
  115 + }
  116 + });
  117 +
  118 +
100 119 /*Ext.override(Ext.selection.Model, {
101 120 storeHasSelected: function(record) {
102 121 var store = this.store,
... ...