added high-level "macro" classes for modules to use to install menu entries
This commit is contained in:
parent
5ef3ea1681
commit
386f2a1fb6
|
@ -1465,6 +1465,17 @@ INSERT INTO menuitems (menuid, sequence, itemtype, text, linktype, link, perm_ns
|
|||
(9, 65000, 'MARKER', 'end-module-sysadmin', NULL, NULL, NULL,
|
||||
NULL );
|
||||
|
||||
# Create the community service admin menu. (ID #10)
|
||||
INSERT INTO menus (menuid, menu_nsid, menu_name, title, subtitle)
|
||||
VALUES (10, 16, 'community.admin.service', 'Manage Community Services:', '${name}');
|
||||
INSERT INTO menuvars (menuid, var_name, default_val) VALUES
|
||||
(10, 'name', NULL),
|
||||
(10, 'cid', NULL);
|
||||
INSERT INTO menuitems (menuid, sequence, itemtype, text, linktype, link, perm_nsid, perm_name) VALUES
|
||||
(10, 0, 'TEXT', 'Return to Previous Menu', 'SERVLET', 'comm/admin/main.js?cc=${cid}', NULL, NULL),
|
||||
(10, 100, 'MARKER', 'begin-service-admin', NULL, NULL, NULL, NULL),
|
||||
(10, 65000, 'MARKER', 'end-service-admin', NULL, NULL, NULL, NULL);
|
||||
|
||||
# Create the sideboxes tables.
|
||||
INSERT INTO sbox_master (sbid, sb_nsid, sb_name, type_nsid, type_name, descr) VALUES
|
||||
(1, 19, 'community.list', 19, 'community.list', 'Community Membership List'),
|
||||
|
|
|
@ -48,6 +48,8 @@ public interface MenuEditObject
|
|||
|
||||
public MenuEditItemObject getItemByTypeText(String type, String text);
|
||||
|
||||
public MenuEditItemObject getItemContainingLinkText(String text);
|
||||
|
||||
public MenuEditItemObject getNextItem(MenuEditItemObject obj);
|
||||
|
||||
public MenuEditItemObject getPreviousItem(MenuEditItemObject obj);
|
||||
|
|
|
@ -164,6 +164,15 @@ class MenuEditImpl implements MenuEditObject
|
|||
|
||||
} // end getItemByTypeText
|
||||
|
||||
public MenuEditItemObject getItemContainingLinkText(String text)
|
||||
{
|
||||
if (m_mdef==null)
|
||||
return null;
|
||||
int ndx = m_mdef.getItemContainingLinkText(text);
|
||||
return (ndx<0) ? null : this.getItem(ndx);
|
||||
|
||||
} // end getItemContainingLinkText
|
||||
|
||||
public MenuEditItemObject getNextItem(MenuEditItemObject obj)
|
||||
{
|
||||
return this.getItem(obj.getIndexOfItem() + 1);
|
||||
|
|
|
@ -91,6 +91,8 @@ class MenuEditItemImpl implements MenuEditItemObject
|
|||
public void setSequence(int seq) throws DatabaseException
|
||||
{
|
||||
baleeted();
|
||||
if (m_item.getSequence()==seq)
|
||||
return;
|
||||
m_ops.setItemSequence(m_mdef.getID(),m_item.getSequence(),seq);
|
||||
m_item.setSequence(seq);
|
||||
m_mdef.resequence();
|
||||
|
@ -106,6 +108,8 @@ class MenuEditItemImpl implements MenuEditItemObject
|
|||
public void setEnabled(boolean flag) throws DatabaseException
|
||||
{
|
||||
baleeted();
|
||||
if (m_item.isEnabled()==flag)
|
||||
return;
|
||||
m_ops.setItemEnable(m_mdef.getID(),m_item.getSequence(),flag);
|
||||
m_item.setEnabled(flag);
|
||||
|
||||
|
@ -122,6 +126,8 @@ class MenuEditItemImpl implements MenuEditItemObject
|
|||
baleeted();
|
||||
if (indent<0)
|
||||
throw new IllegalArgumentException("indent must be >= 0");
|
||||
if (indent==m_item.getIndentLevel())
|
||||
return;
|
||||
m_ops.setItemIndent(m_mdef.getID(),m_item.getSequence(),indent);
|
||||
m_item.setIndentLevel(indent);
|
||||
|
||||
|
|
|
@ -0,0 +1,137 @@
|
|||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.util;
|
||||
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
import com.silverwrist.venice.VeniceNamespaces;
|
||||
import com.silverwrist.venice.iface.*;
|
||||
|
||||
public class CommunityMenuInstaller
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static final int STD_GAP = 100;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private MenuProvider m_provider;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
CommunityMenuInstaller(ServiceProvider services)
|
||||
{
|
||||
m_provider = (MenuProvider)(services.queryService(MenuProvider.class));
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void installCommunityServiceEntry(DynamoUser caller, String text, String linktype, String link,
|
||||
String shortvar) throws DatabaseException, DynamoSecurityException
|
||||
{
|
||||
MenuEditObject menu = m_provider.getEditMenu(caller,VeniceNamespaces.COMMUNITY_GLOBALS_NAMESPACE,"community.menu");
|
||||
MenuEditItemObject end_marker = menu.getItemByTypeText("MARKER","end-services");
|
||||
MenuEditItemObject insert_after = menu.getPreviousItem(end_marker);
|
||||
int new_sequence = insert_after.getSequence() + STD_GAP;
|
||||
if (new_sequence>=end_marker.getSequence())
|
||||
{ // need to renumber the menu items
|
||||
MenuEditItemObject item = menu.getItemByTypeText("MARKER","begin-services");
|
||||
new_sequence = item.getSequence();
|
||||
item = menu.getNextItem(item);
|
||||
new_sequence += STD_GAP;
|
||||
while (!(item.getItemType().equals("MARKER")))
|
||||
{ // reset the numbers for the sequence
|
||||
item.setSequence(new_sequence);
|
||||
item = menu.getNextItem(item);
|
||||
new_sequence += STD_GAP;
|
||||
|
||||
} // end while
|
||||
|
||||
} // end if
|
||||
|
||||
MenuEditItemObject new_object = menu.addItem("TEXT",new_sequence,text,linktype,link);
|
||||
new_object.setIfDefVar(shortvar);
|
||||
|
||||
} // end installCommunityServiceEntry
|
||||
|
||||
public void removeCommunityServiceEntry(DynamoUser caller, String link_text)
|
||||
throws DatabaseException, DynamoSecurityException
|
||||
{
|
||||
MenuEditObject menu = m_provider.getEditMenu(caller,VeniceNamespaces.COMMUNITY_GLOBALS_NAMESPACE,"community.menu");
|
||||
MenuEditItemObject item = menu.getItemContainingLinkText(link_text);
|
||||
if (item!=null)
|
||||
item.delete();
|
||||
|
||||
} // end removeCommunityServiceEntry
|
||||
|
||||
public void installCommunityServiceAdminEntry(DynamoUser caller, String text, String linktype, String link,
|
||||
String perm_nsid, String perm_name, String shortvar)
|
||||
throws DatabaseException, DynamoSecurityException
|
||||
{
|
||||
MenuEditObject menu = m_provider.getEditMenu(caller,VeniceNamespaces.COMMUNITY_GLOBALS_NAMESPACE,
|
||||
"community.admin.service");
|
||||
MenuEditItemObject end_marker = menu.getItemByTypeText("MARKER","end-service-admin");
|
||||
MenuEditItemObject insert_after = menu.getPreviousItem(end_marker);
|
||||
int new_sequence = insert_after.getSequence() + STD_GAP;
|
||||
if (new_sequence>=end_marker.getSequence())
|
||||
{ // need to renumber the menu items
|
||||
MenuEditItemObject item = menu.getItemByTypeText("MARKER","begin-service-admin");
|
||||
new_sequence = item.getSequence();
|
||||
item = menu.getNextItem(item);
|
||||
new_sequence += STD_GAP;
|
||||
while (!(item.getItemType().equals("MARKER")))
|
||||
{ // reset the numbers for the sequence
|
||||
item.setSequence(new_sequence);
|
||||
item = menu.getNextItem(item);
|
||||
new_sequence += STD_GAP;
|
||||
|
||||
} // end while
|
||||
|
||||
} // end if
|
||||
|
||||
MenuEditItemObject new_object = menu.addItem("TEXT",new_sequence,text,linktype,link);
|
||||
new_object.setPermission(perm_nsid,perm_name);
|
||||
new_object.setIfDefVar(shortvar);
|
||||
|
||||
} // end installCommunityServiceAdminEntry
|
||||
|
||||
public void removeCommunityServiceAdminEntry(DynamoUser caller, String link_text)
|
||||
throws DatabaseException, DynamoSecurityException
|
||||
{
|
||||
MenuEditObject menu = m_provider.getEditMenu(caller,VeniceNamespaces.COMMUNITY_GLOBALS_NAMESPACE,
|
||||
"community.admin.service");
|
||||
MenuEditItemObject item = menu.getItemContainingLinkText(link_text);
|
||||
if (item!=null)
|
||||
item.delete();
|
||||
|
||||
} // end removeCommunityServiceAdminEntry
|
||||
|
||||
} // end class CommunityMenuInstaller
|
|
@ -0,0 +1,97 @@
|
|||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.util;
|
||||
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
import com.silverwrist.venice.VeniceNamespaces;
|
||||
import com.silverwrist.venice.iface.*;
|
||||
|
||||
public class SystemAdminMenuInstaller
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static final int STD_GAP = 100;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private MenuProvider m_provider;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SystemAdminMenuInstaller(ServiceProvider services)
|
||||
{
|
||||
m_provider = (MenuProvider)(services.queryService(MenuProvider.class));
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void installSystemAdminEntry(DynamoUser caller, String text, String linktype, String link, String perm_nsid,
|
||||
String perm_name) throws DatabaseException, DynamoSecurityException
|
||||
{
|
||||
MenuEditObject menu = m_provider.getEditMenu(caller,VeniceNamespaces.SYSTEM_PERMS_NAMESPACE,
|
||||
"system.admin.module");
|
||||
MenuEditItemObject end_marker = menu.getItemByTypeText("MARKER","end-module-sysadmin");
|
||||
MenuEditItemObject insert_after = menu.getPreviousItem(end_marker);
|
||||
int new_sequence = insert_after.getSequence() + STD_GAP;
|
||||
if (new_sequence>=end_marker.getSequence())
|
||||
{ // need to renumber the menu items
|
||||
MenuEditItemObject item = menu.getItemByTypeText("MARKER","begin-module-sysadmin");
|
||||
new_sequence = item.getSequence();
|
||||
item = menu.getNextItem(item);
|
||||
new_sequence += STD_GAP;
|
||||
while (!(item.getItemType().equals("MARKER")))
|
||||
{ // reset the numbers for the sequence
|
||||
item.setSequence(new_sequence);
|
||||
item = menu.getNextItem(item);
|
||||
new_sequence += STD_GAP;
|
||||
|
||||
} // end while
|
||||
|
||||
} // end if
|
||||
|
||||
MenuEditItemObject new_object = menu.addItem("TEXT",new_sequence,text,linktype,link);
|
||||
new_object.setPermission(perm_nsid,perm_name);
|
||||
|
||||
} // end installSystemAdminEntry
|
||||
|
||||
public void removeSystemAdminEntry(DynamoUser caller, String link_text)
|
||||
throws DatabaseException, DynamoSecurityException
|
||||
{
|
||||
MenuEditObject menu = m_provider.getEditMenu(caller,VeniceNamespaces.SYSTEM_PERMS_NAMESPACE,
|
||||
"system.admin.module");
|
||||
MenuEditItemObject item = menu.getItemContainingLinkText(link_text);
|
||||
if (item!=null)
|
||||
item.delete();
|
||||
|
||||
} // end removeSystemAdminEntry
|
||||
|
||||
} // end class SystemAdminMenuInstaller
|
Loading…
Reference in New Issue
Block a user