From daa22eb6c7741fa3cee048e33ca05f3f5fd7a8ec Mon Sep 17 00:00:00 2001 From: Anna Gerber Date: Tue, 6 Jan 2009 06:29:48 +0000 Subject: [PATCH] #28 - Generic way of deleting metadata (could be improved by only populating the menu with properties that are in use, and preventing deletion of required properties such as dat and creator) Temporary fix to prevent properties with generated ids from appearing in the relationship menus #27 - added context menu entry for adding background images to resource maps directly --- oaiorebuilder/content/firefoxOverlay.xul | 2 + oaiorebuilder/content/graphs/uifunctions.js | 39 +++++++++++++------- oaiorebuilder/content/overlay.js | 24 +++++------- oaiorebuilder/locale/en-US/oaiorebuilder.dtd | 1 + 4 files changed, 39 insertions(+), 27 deletions(-) diff --git a/oaiorebuilder/content/firefoxOverlay.xul b/oaiorebuilder/content/firefoxOverlay.xul index a41098e2..4dbdc0ff 100644 --- a/oaiorebuilder/content/firefoxOverlay.xul +++ b/oaiorebuilder/content/firefoxOverlay.xul @@ -44,6 +44,8 @@ oncommand="oaiorebuilder.onMenuItemCommand(event)"/> + diff --git a/oaiorebuilder/content/graphs/uifunctions.js b/oaiorebuilder/content/graphs/uifunctions.js index 3b557a28..1a841c6a 100644 --- a/oaiorebuilder/content/graphs/uifunctions.js +++ b/oaiorebuilder/content/graphs/uifunctions.js @@ -288,7 +288,8 @@ function loadRelationshipsFromOntology(){ var relResult = ontRDF.Match(null, null, rdftype, owlobjprop); for (var i = 0; i < relResult.length; i++) { var relresult = _splitTerm(relResult[i].subject); - ontrelationships[relresult.term] = relresult.ns; + if (!relresult.term.match("genid:")) + ontrelationships[relresult.term] = relresult.ns; } relResult = ontRDF.Match(null,null,rdftype,owldataprop); var tmp_resource_metadata = new Array(relResult.length); @@ -353,35 +354,47 @@ function setrdfrepos(rdfrepos, rdfrepostype){ reposURL = rdfrepos; reposType = rdfrepostype; } -function _make_menu_entry(menu, gridname, propname){ -// helper function for setUpMetadataMenu - var funcstr = "var props = " + gridname + ".getSource();" - funcstr += "if (props && !props[\"" + propname + "\"]){"; - funcstr += "props[\"" + propname + "\"] = \"\";"; +function _make_menu_entry(menu, gridname, propname, op){ + // helper function for setUpMetadataMenu + var funcstr = ""; + funcstr += "var props = " + gridname + ".getSource();"; + if (op == "add"){ + funcstr += "if (props && !props[\"" + propname + "\"]){"; + funcstr += "props[\"" + propname + "\"] = \"\";"; + } else { + funcstr += "if (props && typeof props[\"" + propname + "\"] != \"undefined\"){"; + funcstr += "delete props[\"" + propname + "\"];"; + } funcstr += gridname + ".setSource(props);}"; menu.add( { - id: menu.id + "-add-" + propname, + id: menu.id + "-" + op + "-" + propname, text: propname, handler: new Function(funcstr) }); } function setUpMetadataMenu (the_grid, gridname){ - // create context menu to add additional metadata properties to property grid - var metadataMenu = new Ext.menu.Menu({id:gridname + "-metadata-menu"}); + // create context menu to add/remove additional metadata properties + var addMetadataMenu = new Ext.menu.Menu({id:gridname + "-add-metadata-menu"}); + var remMetadataMenu = new Ext.menu.Menu({id:gridname + "-rem-metadata-menu"}); if (gridname == "aggregrid"){ for (var i = 0; i < aggre_metadata_props.length; i++){ - _make_menu_entry(metadataMenu, gridname, aggre_metadata_props[i]); + _make_menu_entry(addMetadataMenu, gridname, aggre_metadata_props[i], "add"); + _make_menu_entry(remMetadataMenu, gridname, aggre_metadata_props[i], "rem"); } } for (var i = 0; i < metadata_props.length; i++){ - _make_menu_entry(metadataMenu, gridname, metadata_props[i]); + _make_menu_entry(addMetadataMenu, gridname, metadata_props[i], "add"); + _make_menu_entry(remMetadataMenu, gridname, metadata_props[i], "rem"); } if (gridname == "nodegrid"){ for (var i = 0; i < resource_metadata_props.length; i++){ - _make_menu_entry(metadataMenu, gridname, resource_metadata_props[i]); + _make_menu_entry(addMetadataMenu, gridname, resource_metadata_props[i], "add"); + _make_menu_entry(remMetadataMenu, gridname, resource_metadata_props[i], "rem"); } } the_grid.getView().hmenu.add({id: - gridname + "metadata", text: "Add metadata", menu: metadataMenu}); + gridname + "-add-metadata", text: "Add metadata", menu: addMetadataMenu}); + the_grid.getView().hmenu.add({id: + gridname + "-rem-metadata", text: "Remove metadata", menu: remMetadataMenu}); } diff --git a/oaiorebuilder/content/overlay.js b/oaiorebuilder/content/overlay.js index fffee4f5..9712a870 100644 --- a/oaiorebuilder/content/overlay.js +++ b/oaiorebuilder/content/overlay.js @@ -47,13 +47,14 @@ var oaiorebuilder = { }, onMenuItemCommand: function(e) { if (gContextMenu.onLink) - window.graphiframe.addFigure(gContextMenu.linkURL); + window.graphiframe.addFigure(gContextMenu.linkURL); }, onMenuPopup: function (e){ gContextMenu.showItem('addimage-oaiorebuilder',gContextMenu.onImage); gContextMenu.showItem('addlink-oaiorebuilder', gContextMenu.onLink); - gContextMenu.showItem('oaioresep', gContextMenu.onImage || gContextMenu.onLink); - + gContextMenu.showItem('addbgimg-oaiorebuilder',gContextMenu.hasBGImage); + gContextMenu.showItem('oaioresep', gContextMenu.onImage || gContextMenu.onLink || gContextMenu.hasBGImage); + }, onToolbarButtonCommand: function(e) { this.toggleBar(); @@ -62,6 +63,10 @@ var oaiorebuilder = { if (gContextMenu.onImage) window.graphiframe.addFigure(gContextMenu.imageURL); }, + addBGImageMenuItemCommand: function(e) { + if (gContextMenu.hasBGImage) + window.graphiframe.addFigure(gContextMenu.bgImageURL); + }, onToolbarButtonCommand: function(e) { this.toggleBar(); }, @@ -74,7 +79,7 @@ var oaiorebuilder = { } }, loadRDF: function() { - + window.graphiframe.loadRDF(); }, loadRDFFromRepos: function() { @@ -84,16 +89,7 @@ var oaiorebuilder = { window.graphiframe.saveRDFToRepository(); }, addGraphNode: function () { - /*var txt = window.getBrowser().contentDocument.getSelection(); - if (txt != null){ - - }*/ - /*if (window.arguments != null) { - window.graphiframe.addFigure(window.arguments[0].content.location.href) - } - else {*/ window.graphiframe.addFigure(window.content.location.href); - //} }, resetGraph: function () { window.graphiframe.location.reload(true); @@ -102,7 +98,7 @@ var oaiorebuilder = { window.open("chrome://oaiorebuilder/content/about.xul","", "chrome,centerscreen,modal"); }, openOptions: function () { - window.open("chrome://oaiorebuilder/content/options.xul", "", "chrome,centerscreen,modal"); + window.open("chrome://oaiorebuilder/content/options.xul", "", "chrome,centerscreen,modal"); }, loadPrefs: function (){ var prefservice = Components.classes["@mozilla.org/preferences-service;1"] diff --git a/oaiorebuilder/locale/en-US/oaiorebuilder.dtd b/oaiorebuilder/locale/en-US/oaiorebuilder.dtd index 31bbbe66..02e2c807 100644 --- a/oaiorebuilder/locale/en-US/oaiorebuilder.dtd +++ b/oaiorebuilder/locale/en-US/oaiorebuilder.dtd @@ -1,6 +1,7 @@ +