mirror of
https://github.com/moparisthebest/FireTray
synced 2024-12-22 22:08:49 -05:00
tree in option panel: SOMETHING WORKING ! but stil WORK IN PROGRESS
This commit is contained in:
parent
69746ffc86
commit
1357e3a817
@ -27,7 +27,8 @@ firetray.UIOptions = {
|
||||
}
|
||||
|
||||
// setView();
|
||||
populateTree();
|
||||
// initView();
|
||||
populateTreeServerTypes();
|
||||
},
|
||||
|
||||
hideElement: function(parentId) {
|
||||
@ -172,22 +173,47 @@ function saveList(){
|
||||
// window.addEventListener('unload', saveList, false);
|
||||
*/
|
||||
|
||||
/*
|
||||
function initView() {
|
||||
let tree = document.getElementById("optTree");
|
||||
|
||||
var oldView = tree.view;
|
||||
var newView = {
|
||||
__proto__: oldView,
|
||||
setCellText: function(row, col, value) {
|
||||
oldView.setCellText(row, col, value);
|
||||
LOG("Text changed for a tree cell!");
|
||||
document.getElementById("pane1").userChangedValue(tree);
|
||||
}
|
||||
};
|
||||
tree.view = newView;
|
||||
LOG("initView");
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
* Save the Schedules List to the "extensions.hpsched.schedules" preference.
|
||||
* This is called by the pref's system when the GUI element is altered.
|
||||
*/
|
||||
function saveTree() {
|
||||
let tree = document.getElementById("optTree");
|
||||
let items = document.getElementById("rows").childNodes;
|
||||
function saveTreeServerTypes() {
|
||||
let tree = document.getElementById("ui_tree_server_types");
|
||||
let items = document.getElementById("ui_server_types").childNodes;
|
||||
|
||||
LOG("VIEW="+ tree.view);
|
||||
let prefObj = {};
|
||||
for (let i=0; i < items.length; i++) {
|
||||
for (let i=0; i < tree.view.rowCount; i++) {
|
||||
let cells = items[i].getElementsByTagName("treecell");
|
||||
LOG("CELLS:"+ tree.view.getCellText(i,
|
||||
tree.columns["name"]));
|
||||
// tree.columns.getColumnAt(0)));
|
||||
// tree.columns.getNamedColumn("name")));
|
||||
prefObj[cells[0].label] = {regex: cells[1].label, subs: cells[2].label};
|
||||
let serverTypeExcluded = (
|
||||
tree.view.getCellValue(
|
||||
i, tree.columns.getNamedColumn("server_type_excluded"))
|
||||
=== 'true');
|
||||
let serverTypeName = tree.view.getCellText(
|
||||
i, tree.columns.getNamedColumn("server_type_name"));
|
||||
let serverTypeOrder = parseInt(tree.view.getCellText(
|
||||
i, tree.columns.getNamedColumn("server_type_order")));
|
||||
LOG("SUPER: "+serverTypeName+", "+serverTypeExcluded);
|
||||
prefObj[serverTypeName] =
|
||||
{ order: serverTypeOrder, excluded: serverTypeExcluded };
|
||||
}
|
||||
|
||||
let prefStr = JSON.stringify(prefObj);
|
||||
@ -199,7 +225,7 @@ function saveTree() {
|
||||
}
|
||||
|
||||
function addItem() {
|
||||
let targetTree = document.getElementById("rows");
|
||||
let targetTree = document.getElementById("ui_server_types");
|
||||
|
||||
let item = document.createElement('treeitem');
|
||||
let row = document.createElement('treerow');
|
||||
@ -215,38 +241,49 @@ function addItem() {
|
||||
targetTree.appendChild(item);
|
||||
}
|
||||
|
||||
function populateTree() {
|
||||
function populateTreeServerTypes() {
|
||||
let prefPane = document.getElementById("pane1");
|
||||
|
||||
let prefStr = firetray.Utils.prefService.getCharPref("jsondata");
|
||||
let prefStr = firetray.Utils.prefService.getCharPref("server_types");
|
||||
let prefObj = JSON.parse(prefStr);
|
||||
|
||||
let targetTree = document.getElementById("rows");
|
||||
for (r in prefObj) {
|
||||
let name = prefObj[r];
|
||||
let targetTree = document.getElementById("ui_server_types");
|
||||
for (serverTypeName in prefObj) {
|
||||
let name = prefObj[serverTypeName];
|
||||
|
||||
let item = document.createElement('treeitem');
|
||||
let row = document.createElement('treerow');
|
||||
item.appendChild(row);
|
||||
|
||||
// server_type_excluded => checkbox
|
||||
let cell = document.createElement('treecell');
|
||||
cell.setAttribute('label',r);
|
||||
cell.addEventListener
|
||||
('change', function() {
|
||||
LOG("CHANGE: "+ firetray.Utils.prefService.getCharPref("jsondata"));
|
||||
document.getElementById("pane1")
|
||||
.userChangedValue(document.getElementById("optTree"));
|
||||
cell.setAttribute('value',prefObj[serverTypeName].excluded);
|
||||
// FIXME: we need to removeEventListener() !!! onunload ?
|
||||
cell.addEventListener(
|
||||
'DOMAttrModified', function(event) {
|
||||
if (event.attrName == "label") LOG("label changed!");
|
||||
if (event.attrName == "value") LOG("value changed!");
|
||||
document.getElementById("pane1")
|
||||
.userChangedValue(document.getElementById("ui_tree_server_types"));
|
||||
});
|
||||
cell.addEventListener('input', LOG("INPUT"));
|
||||
// cell.oninput = 'document.getElementById("pane1").userChangedValue(document.getElementById("optTree"));';
|
||||
row.appendChild(cell);
|
||||
|
||||
// server_type_name
|
||||
cell = document.createElement('treecell');
|
||||
cell.setAttribute('label',name.regex);
|
||||
cell.setAttribute('label',serverTypeName);
|
||||
// FIXME: refactor !!
|
||||
cell.addEventListener(
|
||||
'DOMAttrModified', function(event) {
|
||||
if (event.attrName == "label") LOG("label changed!");
|
||||
if (event.attrName == "value") LOG("value changed!");
|
||||
document.getElementById("pane1")
|
||||
.userChangedValue(document.getElementById("ui_tree_server_types"));
|
||||
});
|
||||
row.appendChild(cell);
|
||||
|
||||
// server_type_order
|
||||
cell = document.createElement('treecell');
|
||||
cell.setAttribute('label',name.subs);
|
||||
cell.setAttribute('label',prefObj[serverTypeName].order);
|
||||
row.appendChild(cell);
|
||||
|
||||
targetTree.appendChild(item);
|
||||
|
@ -14,8 +14,8 @@
|
||||
<preferences>
|
||||
<preference id="pref_bool_close_hides"
|
||||
name="extensions.firetray.close_hides" type="bool"/>
|
||||
<preference id="pref_string_jsondata"
|
||||
name="extensions.firetray.jsondata" type="string"/>
|
||||
<preference id="pref_string_server_types"
|
||||
name="extensions.firetray.server_types" type="string"/>
|
||||
</preferences>
|
||||
|
||||
|
||||
@ -33,18 +33,24 @@
|
||||
<button label="Add" oncommand="addItem();"/>
|
||||
<button label="Delete" oncommand="deleteSelection();"/>
|
||||
<separator class="thin" />
|
||||
<tree id="optTree" height="200" width="500" flex="1"
|
||||
<tree id="ui_tree_server_types" height="200" width="500" flex="1"
|
||||
seltype="single" editable="true"
|
||||
preference-editable="true"
|
||||
preference="pref_string_jsondata"
|
||||
onsynctopreference="return saveTree();">
|
||||
preference="pref_string_server_types"
|
||||
onsynctopreference="return saveTreeServerTypes();">
|
||||
<treecols>
|
||||
<treecol id="name" label="Name" primary="true" flex="1"
|
||||
persist="width ordinal hidden" width="50"/>
|
||||
<treecol id="regex" label="Regex" width="100" flex="1"/>
|
||||
<treecol id="subs" label="Subs" width="300" flex="1"/>
|
||||
<treecol id="server_type_excluded" type="checkbox" editable="true"
|
||||
label="Excluded" primary="true" flex="1" />
|
||||
<treecol id="server_type_name" label="Type" flex="1"
|
||||
primary="true" tooltiptext="HI"/>
|
||||
<treecol id="server_type_order" label="Order" editable="true"
|
||||
flex="1" hidden= "true" />
|
||||
<!-- <treecol id="name" label="Name" primary="true" flex="1" -->
|
||||
<!-- persist="width ordinal hidden" width="50"/> -->
|
||||
<!-- <treecol id="regex" label="Regex" width="100" flex="1"/> -->
|
||||
<!-- <treecol id="subs" label="Subs" width="300" flex="1"/> -->
|
||||
</treecols>
|
||||
<treechildren id="rows" />
|
||||
<treechildren id="ui_server_types" />
|
||||
</tree>
|
||||
<separator class="thin" />
|
||||
<label value="To edit a item doubleclick on it" />
|
||||
|
@ -5,7 +5,7 @@
|
||||
<em:unpack>true</em:unpack> <!-- needed for embedded icons -->
|
||||
<em:type>2</em:type>
|
||||
<em:name>FireTray</em:name>
|
||||
<em:version>0.4.0a2</em:version>
|
||||
<em:version>0.4.0a3</em:version>
|
||||
<em:creator>Hua Luo, Francesco Solero, Foudil BRÉTEL</em:creator>
|
||||
<em:contributor>Hua Luo, Francesco Solero (Firetray original authors)</em:contributor>
|
||||
<em:homepageURL>https://github.com/foudfou/firetray</em:homepageURL>
|
||||
|
Loading…
Reference in New Issue
Block a user