Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Commit

Permalink
#28 - Generic way of deleting metadata (could be improved by only pop…
Browse files Browse the repository at this point in the history
…ulating 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
  • Loading branch information
AnnaGerber committed Jan 6, 2009
1 parent 49a008a commit daa22eb
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 27 deletions.
2 changes: 2 additions & 0 deletions oaiorebuilder/content/firefoxOverlay.xul
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
oncommand="oaiorebuilder.onMenuItemCommand(event)"/>
<xul:menuitem id="addimage-oaiorebuilder" label="&oaiorebuilderContextImage.label;"
oncommand="oaiorebuilder.addImageMenuItemCommand(event)"/>
<xul:menuitem id="addbgimg-oaiorebuilder" label="&oaiorebuilderContextBGImage.label;"
oncommand="oaiorebuilder.addBGImageMenuItemCommand(event)"/>
</xul:popup>

<xul:toolbarpalette id="BrowserToolbarPalette">
Expand Down
39 changes: 26 additions & 13 deletions oaiorebuilder/content/graphs/uifunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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});
}

24 changes: 10 additions & 14 deletions oaiorebuilder/content/overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
},
Expand All @@ -74,7 +79,7 @@ var oaiorebuilder = {
}
},
loadRDF: function() {

window.graphiframe.loadRDF();
},
loadRDFFromRepos: function() {
Expand All @@ -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);
Expand All @@ -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"]
Expand Down
1 change: 1 addition & 0 deletions oaiorebuilder/locale/en-US/oaiorebuilder.dtd
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!ENTITY oaiorebuilder.label "oaiorebuilder">
<!ENTITY oaiorebuilderContextLink.label "Add linked resource to ORE map">
<!ENTITY oaiorebuilderContextImage.label "Add image to ORE map">
<!ENTITY oaiorebuilderContextBGImage.label "Add background image to ORE map">
<!ENTITY oaiorebuilderToolbar.label "OAI-ORE Builder">
<!ENTITY oaiorebuilderToolbar.tooltip "Toggle oaiorebuilder">
<!ENTITY oaiorebuilder.addNodeLabel "Add Resource">
Expand Down

0 comments on commit daa22eb

Please sign in to comment.