Some new CSS placeholders once the designers start making this look good.

Scholar.TreeView is now Scholar.FolderTreeView (SourcesTreeView later? depends)
Some changes to the way FolderTreeView works.
New Scholar.ItemGroup -- used by FolderTreeView and ItemTreeView.
the root folder is not currently displayed -- doesn't really matter because we are changing the way it all works.
(note: the Scholar.Items.getAll() function does not seem to be working correctly -- try clicking on the library)
This commit is contained in:
David Norton 2006-05-31 20:29:46 +00:00
parent a1ae5c13c9
commit 22cd938ecc
8 changed files with 141 additions and 99 deletions

View file

@ -1,63 +1,48 @@
Scholar.TreeView = function(root) Scholar.FolderTreeView = function()
{ {
this._treebox = null; this._treebox = null;
this._dataItems = new Array(); this._dataItems = new Array();
this.rowCount = 0; this.rowCount = 0;
this._treeType; this._showItem(new Scholar.ItemGroup('library',null),0,1);
this._rootFolder = root;
} }
Scholar.TreeView.prototype.setTree = function(treebox) Scholar.FolderTreeView.prototype.setTree = function(treebox)
{ {
if(this._treebox) if(this._treebox)
return; return;
this._treebox = treebox; this._treebox = treebox;
this._treeType = treebox.element.getAttribute("treeviewtype");
var newRows = Scholar.Items.getTreeRows(this._rootFolder,this._treeType); var newRows = Scholar.Items.getTreeRows(0,'folders');
for(var i = 0; i < newRows.length; i++) for(var i = 0; i < newRows.length; i++)
this._showItem(newRows[i], 0, i+1); //item ref, isContainerOpen, level this._showItem(new Scholar.ItemGroup('folder',newRows[i]), 0, this._dataItems.length); //item ref, level, beforeRow
this._refreshHashMap(); this._refreshHashMap();
} }
Scholar.TreeView.prototype.getCellText = function(row, column) Scholar.FolderTreeView.prototype.getCellText = function(row, column)
{ {
var obj = this._getItemAtRow(row); var obj = this._getItemAtRow(row);
if(obj.isFolder()) if(column.id == "name_column")
{ return obj.getName();
if(column.id == "name_column")
return obj.getName();
else
return "";
}
else else
{ return "";
if(column.id == "title_column")
return obj.getField("title");
else if(column.id == "creator_column")
return obj.getField("firstCreator");
else if(column.id == "source_column")
return obj.getField("source");
else
return "";
}
} }
Scholar.TreeView.prototype.isContainer = function(row) { return this._getItemAtRow(row).isFolder(); } Scholar.FolderTreeView.prototype.isContainer = function(row) { return this._getItemAtRow(row).isFolder(); }
Scholar.TreeView.prototype.isContainerOpen = function(row) { return this._dataItems[row][1]; } Scholar.FolderTreeView.prototype.isContainerOpen = function(row) { return this._dataItems[row][1]; }
Scholar.TreeView.prototype.isContainerEmpty = function(row) Scholar.FolderTreeView.prototype.isContainerEmpty = function(row)
{ {
if(this._treeType == 'folders') var itemGroup = this._getItemAtRow(row);
return !this._getItemAtRow(row).hasChildFolders(); if(itemGroup.isFolder())
return !itemGroup.ref.hasChildFolders();
else else
return (this.isContainer(row) && this._getItemAtRow(row).isEmpty()); return true;
} }
Scholar.TreeView.prototype.getLevel = function(row) { return this._dataItems[row][2]; } Scholar.FolderTreeView.prototype.getLevel = function(row) { return this._dataItems[row][2]; }
Scholar.TreeView.prototype.getParentIndex = function(row) Scholar.FolderTreeView.prototype.getParentIndex = function(row)
{ {
var thisLevel = this.getLevel(row); var thisLevel = this.getLevel(row);
if(thisLevel == 0) return -1; if(thisLevel == 0) return -1;
@ -67,7 +52,7 @@ Scholar.TreeView.prototype.getParentIndex = function(row)
return -1; return -1;
} }
Scholar.TreeView.prototype.hasNextSibling = function(row, afterIndex) Scholar.FolderTreeView.prototype.hasNextSibling = function(row, afterIndex)
{ {
var thisLevel = this.getLevel(row); var thisLevel = this.getLevel(row);
for(var i = afterIndex + 1; i < this.rowCount; i++) for(var i = afterIndex + 1; i < this.rowCount; i++)
@ -78,7 +63,7 @@ Scholar.TreeView.prototype.hasNextSibling = function(row, afterIndex)
} }
} }
Scholar.TreeView.prototype.toggleOpenState = function(row) Scholar.FolderTreeView.prototype.toggleOpenState = function(row)
{ {
var count = 0; //used to tell the tree how many rows were added/removed var count = 0; //used to tell the tree how many rows were added/removed
var thisLevel = this.getLevel(row); var thisLevel = this.getLevel(row);
@ -94,12 +79,12 @@ Scholar.TreeView.prototype.toggleOpenState = function(row)
} }
else else
{ {
var newRows = Scholar.Items.getTreeRows(this._getItemAtRow(row).getID(),this._treeType); //Get children var newRows = Scholar.Items.getTreeRows(this._getItemAtRow(row).ref.getID(),'folders'); //Get children
for(var i = 0; i < newRows.length; i++) for(var i = 0; i < newRows.length; i++)
{ {
count++; count++;
this._showItem(newRows[i], thisLevel+1, row+i+1); //insert new row this._showItem(new Scholar.ItemGroup('folder',newRows[i]), thisLevel+1, row+i+1); //insert new row
} }
} }
this._dataItems[row][1] = !this._dataItems[row][1]; //toggle container open value this._dataItems[row][1] = !this._dataItems[row][1]; //toggle container open value
@ -110,24 +95,25 @@ Scholar.TreeView.prototype.toggleOpenState = function(row)
this._refreshHashMap(); this._refreshHashMap();
} }
Scholar.TreeView.prototype._showItem = function(item, level, beforeRow) { this._dataItems.splice(beforeRow, 0, [item, false, level]); this.rowCount++; } Scholar.FolderTreeView.prototype._showItem = function(item, level, beforeRow) { this._dataItems.splice(beforeRow, 0, [item, false, level]); this.rowCount++; }
Scholar.TreeView.prototype._hideItem = function(row) { this._dataItems.splice(row,1); this.rowCount--; } Scholar.FolderTreeView.prototype._hideItem = function(row) { this._dataItems.splice(row,1); this.rowCount--; }
Scholar.TreeView.prototype._getItemAtRow = function(row) { return this._dataItems[row][0]; } Scholar.FolderTreeView.prototype._getItemAtRow = function(row) { return this._dataItems[row][0]; }
Scholar.TreeView.prototype.isSorted = function() { return false; } Scholar.FolderTreeView.prototype.isSorted = function() { return false; }
Scholar.TreeView.prototype.isSeparator = function(row) { return false; } Scholar.FolderTreeView.prototype.isSeparator = function(row) { return false; }
Scholar.TreeView.prototype.isEditable = function(row, idx) { return false; } Scholar.FolderTreeView.prototype.isEditable = function(row, idx) { return false; }
Scholar.TreeView.prototype.getRowProperties = function(row, prop) { } Scholar.FolderTreeView.prototype.getRowProperties = function(row, prop) { }
Scholar.TreeView.prototype.getColumnProperties = function(col, prop) { } Scholar.FolderTreeView.prototype.getColumnProperties = function(col, prop) { }
Scholar.TreeView.prototype.getCellProperties = function(row, col, prop) { } Scholar.FolderTreeView.prototype.getCellProperties = function(row, col, prop) { }
Scholar.TreeView.prototype.getImageSrc = function(row, col) { } Scholar.FolderTreeView.prototype.getImageSrc = function(row, col) { }
Scholar.TreeView.prototype.performAction = function(action) { } Scholar.FolderTreeView.prototype.performAction = function(action) { }
Scholar.TreeView.prototype.performActionOnCell = function(action, row, col) { } Scholar.FolderTreeView.prototype.performActionOnCell = function(action, row, col) { }
Scholar.TreeView.prototype.getProgressMode = function(row, col) { } Scholar.FolderTreeView.prototype.getProgressMode = function(row, col) { }
Scholar.TreeView.prototype.deleteSelection = function() Scholar.FolderTreeView.prototype.deleteSelection = function()
{ {
/*
if(this.selection.count == 0) if(this.selection.count == 0)
return; return;
@ -161,23 +147,55 @@ Scholar.TreeView.prototype.deleteSelection = function()
this._treebox.endUpdateBatch(); this._treebox.endUpdateBatch();
this._refreshHashMap(); this._refreshHashMap();
*/
} }
Scholar.TreeView.prototype._refreshHashMap = function() Scholar.FolderTreeView.prototype._refreshHashMap = function()
{ {
// Create hash map of folder and object ids to row indexes // Create hash map of folder and object ids to row indexes
this._itemRowMap = new Array();
this._folderRowMap = new Array(); this._folderRowMap = new Array();
for(var i=0; i < this.rowCount; i++){ for(var i=0; i < this.rowCount; i++){
if (this.isContainer(i)){ if (this.isContainer(i)){
this._folderRowMap[this._getItemAtRow(i).getID()] = i; this._folderRowMap[this._getItemAtRow(i).ref.getID()] = i;
}
else {
this._itemRowMap[this._getItemAtRow(i).getID()] = i;
} }
} }
//Scholar.debug(Scholar.varDump(this.folderRowMap)); //Scholar.debug(Scholar.varDump(this.folderRowMap));
//Scholar.debug(Scholar.varDump(this.objectRowMap)); //Scholar.debug(Scholar.varDump(this.objectRowMap));
}
Scholar.ItemGroup = function(type, ref)
{
this.type = type;
this.ref = ref;
}
Scholar.ItemGroup.prototype.isLibrary = function()
{
return this.type == 'library';
}
Scholar.ItemGroup.prototype.isFolder = function()
{
return this.type == 'folder';
}
Scholar.ItemGroup.prototype.getName = function()
{
if(this.isFolder())
return this.ref.getName();
else if(this.isLibrary())
return "Library";
else
return "";
}
Scholar.ItemGroup.prototype.getChildItems = function()
{
if(this.isFolder())
return Scholar.Items.getTreeRows(this.ref.getID(),'items');
else if(this.isLibrary())
return Scholar.Items.getAll();
else
return null;
} }

View file

@ -1,9 +1,9 @@
Scholar.ItemTreeView = function(root) Scholar.ItemTreeView = function(itemGroup)
{ {
this._treebox = null; this._treebox = null;
this._dataItems = new Array(); this._dataItems = new Array();
this.rowCount = 0; this.rowCount = 0;
this._rootFolder = root; this._itemGroup = itemGroup;
} }
Scholar.ItemTreeView.prototype.setTree = function(treebox) Scholar.ItemTreeView.prototype.setTree = function(treebox)
@ -12,7 +12,7 @@ Scholar.ItemTreeView.prototype.setTree = function(treebox)
return; return;
this._treebox = treebox; this._treebox = treebox;
var newRows = Scholar.Items.getTreeRows(this._rootFolder,"items"); var newRows = this._itemGroup.getChildItems();
for(var i = 0; i < newRows.length; i++) for(var i = 0; i < newRows.length; i++)
this._showItem(newRows[i], i+1); //item ref, before row this._showItem(newRows[i], i+1); //item ref, before row

View file

@ -15,10 +15,9 @@ var ScholarPane = new function()
function init() function init()
{ {
foldersView = new Scholar.TreeView(0); //pass params here? foldersView = new Scholar.FolderTreeView(); //pass params here?
document.getElementById('folders-tree').view = foldersView; document.getElementById('folders-tree').view = foldersView;
itemsView = new Scholar.ItemTreeView(0); document.getElementById('items-tree').view = null;
document.getElementById('items-tree').view = itemsView;
var addMenu = document.getElementById('tb-add').firstChild; var addMenu = document.getElementById('tb-add').firstChild;
var itemTypes = Scholar.ItemTypes.getTypes(); var itemTypes = Scholar.ItemTypes.getTypes();
@ -45,13 +44,12 @@ var ScholarPane = new function()
{ {
if(foldersView.selection.count == 1 && foldersView.selection.currentIndex != -1) if(foldersView.selection.count == 1 && foldersView.selection.currentIndex != -1)
{ {
itemsView = new Scholar.ItemTreeView(foldersView._getItemAtRow(foldersView.selection.currentIndex).getID()); itemsView = new Scholar.ItemTreeView(foldersView._getItemAtRow(foldersView.selection.currentIndex));
document.getElementById('items-tree').view = itemsView; document.getElementById('items-tree').view = itemsView;
} }
else if(foldersView.selection.count == 0) else if(foldersView.selection.count == 0)
{ {
itemsView = new Scholar.ItemTreeView(0); document.getElementById('items-tree').view = null;
document.getElementById('items-tree').view = itemsView;
} }
else else
{ {

View file

@ -1,5 +1,6 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<?xml-stylesheet href="chrome://scholar/skin/scholar.css" type="text/css"?> <?xml-stylesheet href="chrome://scholar/skin/scholar.css" type="text/css"?>
<?xml-stylesheet href="chrome://scholar/skin/overlay.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://scholar/locale/scholar.dtd"> <!DOCTYPE window SYSTEM "chrome://scholar/locale/scholar.dtd">
<overlay id="scholar" <overlay id="scholar"
@ -20,7 +21,7 @@
<vbox id="scholar-pane" position="1" persist="height"> <vbox id="scholar-pane" position="1" persist="height">
<hbox flex="1"> <hbox flex="1">
<tree id="folders-tree" <tree id="folders-tree"
treeviewtype="folders" style="-moz-user-focus: ignore;" hidecolumnpicker="true" style="-moz-user-focus: ignore;" hidecolumnpicker="true"
onselect="ScholarPane.folderSelected();" onselect="ScholarPane.folderSelected();"
persist="width" flex="1"> persist="width" flex="1">
<treecols> <treecols>
@ -32,7 +33,7 @@
</treecols> </treecols>
<treechildren/> <treechildren/>
</tree> </tree>
<splitter resizebefore="closest" resizeafter="closest"/> <splitter id="scholar-tree-splitter" resizebefore="closest" resizeafter="closest"/>
<tree <tree
id="items-tree" id="items-tree"
enableColumnDrag="true" enableColumnDrag="true"
@ -73,7 +74,7 @@
<treechildren/> <treechildren/>
</tree> </tree>
</hbox> </hbox>
<toolbar> <toolbar id="scholar-toolbar">
<toolbarbutton label="&menuitem.newFolder.label;" command="cmd_scholar_newFolder"/> <toolbarbutton label="&menuitem.newFolder.label;" command="cmd_scholar_newFolder"/>
<toolbarbutton id="tb-add" label="&menuitem.newItem.label;" type="menu"> <toolbarbutton id="tb-add" label="&menuitem.newItem.label;" type="menu">
<menupopup> <menupopup>
@ -81,10 +82,10 @@
</toolbarbutton> </toolbarbutton>
<spacer flex="1"/> <spacer flex="1"/>
<label value="Search:" control="tb-search"/> <label value="Search:" control="tb-search"/>
<textbox id="tb-search" type="timed" timeout="500" width="150" command="cmd_scholar_search"/> <textbox id="tb-search" type="timed" timeout="500" command="cmd_scholar_search"/>
</toolbar> </toolbar>
</vbox> </vbox>
<splitter resizebefore="closest" resizeafter="closest" position="2"/> <splitter id="scholar-splitter" resizebefore="closest" resizeafter="closest" position="2"/>
</vbox> </vbox>
<statusbar id="status-bar"> <statusbar id="status-bar">

View file

@ -16,7 +16,6 @@
<browser id="view" flex="1"/> <browser id="view" flex="1"/>
<vbox> <vbox>
<stack id="metadata"> <stack id="metadata">
<box id="metadata-background"/>
<vbox id="metadata-pane"> <vbox id="metadata-pane">
<textbox value="Title"/> <textbox value="Title"/>
<textbox value="Rights"/> <textbox value="Rights"/>
@ -26,7 +25,6 @@
</vbox> </vbox>
</stack> </stack>
<stack id="notes"> <stack id="notes">
<box id="notes-background"/>
<vbox id="notes-pane"> <vbox id="notes-pane">
<textbox value="Notes.... lorem ispum delorum..." multiline="true" flex="1"/> <textbox value="Notes.... lorem ispum delorum..." multiline="true" flex="1"/>
</vbox> </vbox>

View file

@ -0,0 +1,45 @@
vbox #scholar-pane
{
background: #f5f5f5;
min-height: 150px;
}
tree #folders-tree
{
min-width: 100px;
max-width: 200px;
}
#scholar-tree-splitter
{
}
tree #items-tree
{
}
#scholar-toolbar
{
}
#scholar-toolbar toolbarbutton
{
}
#tb-search
{
width: 150px;
}
#scholar-splitter
{
border-top: none;
border-bottom: 1px solid #A3A3A3;
min-height: 4px;
max-height: 4px;
background: #f5f5f5 !important;
}

View file

@ -1,7 +0,0 @@
#scholar-sidebar-object-pane-dynamic-fields label {
font-weight: bold;
}
#editpane {
background-color: rgb(239, 248, 206);
}

View file

@ -5,18 +5,12 @@
#view-toolbar .toggler #view-toolbar .toggler
{ {
margin: 4px;
} }
#metadata-background #subs
{ {
position: relative;
margin-top: 10px;
left: 10px;
width: 400px; width: 400px;
height: 100px;
background-color: black;
opacity: 0.4;
} }
#metadata-pane #metadata-pane
@ -27,17 +21,9 @@
width: 400px; width: 400px;
height: 100px; height: 100px;
overflow: auto; overflow: auto;
} padding: 5px;
font-size: 11px;
#notes-background background: #f5f5f5;
{
position: relative;
margin-top: 10px;
left: 10px;
width: 400px;
height: 100px;
background-color: black;
opacity: 0.4;
} }
#notes-pane #notes-pane
@ -47,4 +33,7 @@
left: 10px; left: 10px;
width: 400px; width: 400px;
height: 100px; height: 100px;
padding: 5px;
font-size: 11px;
background: #f5f5f5;
} }