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