Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Customizing the Menutext in the Command Context Menu
ManoloMadrid
Hi:
I'm a "learning" programmer with the Mailsite API and I'm having the next problem:
I'd like to change the text in the Menutext in the Command Context Menu attending the name of the database of the selected document. The problem I'm having is that when I ask in the Update Method for the Item "SelectedNRTDocuments" the string property Menutext has already fixed and I can't change it (I can, but it's not refreshed).
The strange thing is that in the same place I can change the status property without any problem.
Any ideas ???
Thanks in advance
Manolo Madrid
Find more posts tagged with
Comments
jny
Would you send in your ICommand project in a zip file? I'll take a look at it.
ManoloMadrid
Thanks:
Perhaps it's enough only sending this part of the code (if you need the whole code please ank it). Exactly what I'd like to do is in the lines below the commentary "HERE - I'd like ..." to be able of changing the Menutext text
using System;
using System.Text;
using System.Collections;
using System.Drawing;
using System.Windows.Forms;
using System.Data;
using Microsoft.Win32;
using IMANEXTLib;
using IManage;
using General;
namespace WSPublish
{
///
/// Summary description for DeleteDocument.
///
///
public class publishDocument : IMANEXTLib.ICommand
{
// TEMPORARY ACCELERATOR CONSTANTS
// NOTE: These constants are temporary; they are used to specify accelerator
// keys and will later be replaced. The constants to be specified later will
// most likely have the same values, but different names.
private const int tempVirtKey = 65536;
private const int tempNoInvert = 131072;
private const int tempShift = 262144;
private const int tempControl = 524288;
private const int tempAlt = 1048576;
//END TEMPORARY ACCELERATOR CONSTANTS
private int mAccelerator;
// The accelerator used to invoke this command, encoded as follows: add the
// ASCII value of the letter used to invoke this command, one of the
// constants in the "TEMPORARY ACCELERATOR CONSTANTS" section above to
// indicate if shift, control, and/or alt is pressed, and the value of
// tempVirtKey together
private object mBitmap;
// The handle to a bitmap used to represent this command in a toolbar.
// Handle may be acquired using the LoadBitmap Win32 API call
private ContextItems mContext;
// An interface to the context items object used to hold parameters for this command
private string mHelpFile;
// The full path and file name of the help file with user documentation for this command
private int mHelpID;
// The help ID for the documentation for this command in the help file
// specified in the HelpFile property
private string mHelpText;
// The ToolTip and status bar text for this command in the format "status bar text\nToolTip text"
private string mMenuText;
// The text used to represent the command in a menu
private string mName;
// The progID of this class in "projectName.className" format
private int mOptions;
// This property is reserved for future use; it must be set to zero
private int mStatus;
// Private CommandStatus mStatus;
// the status of the command (i.e. whether or not it's active, disabled, etc.)
private Commands mSubCommands;
// Reserved; for now, it should be set to Null
private string mTitle;
// A brief (few word) semantic description of this command
private IMANEXTLib.CommandType mType;
// The type of this command
public publishDocument()
{
try
{
// The Name is the progID of this command, consisting of the name
// property of the project and the name property of the class module in
// "projectName.className" form.
Name = "TikitContextMenu.PublishDocument";
// The Title should be assigned a brief description of what the command does.
Title = "Publish a document in the designed library";
// The Accelerator should be assigned a value that consists of the
// sum of the constant tempVirtKey, a constant representing the control, alt,
// and/or shift keys, and the ascii value of the letter key to be used as an
// accelerator. See the section "TEMPORARY ACCELERATOR CONSTANTS" for a set
// of possible constants.
Byte[] encodedBytes = Encoding.ASCII.GetBytes("C");
Accelerator = encodedBytes[0] + tempVirtKey + tempControl;
// The Type describes the type of command implemented. The
// different possible types are members of the Imanext.CommandType enumerated type.
Type = IMANEXTLib.CommandType.nrStandardCommand;
// Until it is verified by the Update method that the command should be
// active, the status should be set so that it is grayed out.
Status = (int)CommandStatus.nrGrayedCommand;
// The MenuText identifies the command in a menu. If an accelerator
// is assigned to this menu, it should be indicated after a tab.
//MenuText is decided by the program and it depends of the DB name
MenuText = Config.getValue("Publish");
// Add bitmap to the project as embedded resource (changed it from the properties pane)
//Bitmap bm = new Bitmap(this.GetType(), Application.StartupPath + "\\cancelación.bmp");
//System.IntPtr bp = bm.GetHbitmap();
//mBitmap = bp;
// The HelpText should contain a status bar description of the command
HelpText = "Delete a document.";
}
catch(Exception ex)
{
// Error handling code could go here. The error handling code should not
// explicitly raise any errors.
MessageBox.Show("An error occured when initializing TikitContextMenu.DeleteDocument\n" + ex.Message,"Error",MessageBoxButtons.OK);
}
}
/// ****************** Method Implementation for ICommand ***********************
///
/// To implement an iManage Extension Library command, only the three methods in
/// this section, Initialize, Update, and Execute need to be implemented.
/// Example code is contained within each method to demonstrate, as well as a
/// general description of the type of code that should be implemented there.
/// Initialize is used to pass a ContextItems object containing parameters for the
/// command object to the command object.
///
/// the ContextItems object containing parameters for the command object
public void Initialize(IMANEXTLib.ContextItems Context)
{
mContext = Context;
}
///
/// Update is used to evaluate the status of a command. It stores the results of
/// the evaluation in the Status property.
///
public void Update()
{
// INSERT CODE HERE - UPDATE
//This method should check the following things:
/*
* 1. Whether or not all the necessary parameters have been set in the Context property.
* 2. Whether or not the parameters contain data on which the command could operate.
* 3. Any other information needed to make an evaluation of the status of the command's availability to be executed.
*/
// Based on the results of the check, this method will populate the Status property
// with one of the following values in the CommandStatus enumerated type:
// nrActiveCommand: The command may be executed.
// nrGrayedCommand: The command is "grayed out" in the GUI.
// This method, as well as any of the command's methods, should not raise any
// errors, and should handle all errors raised by the methods within it.
// END INSERT CODE HERE - UPDATE
// Only active the context menu entry if one document is selected
//MessageBox.Show("Dentro del update");
try
{
Status = (int)CommandStatus.nrGrayedCommand;
// Get selected items ...
foreach (IMANEXTLib.IContextItem item in mContext)
{
if (item.Name == "SelectedNRTDocuments")
// ... Only for documents
{
System.Object[] docs = (System.Object[])item.Value;
// ... and only 1 document
//if (docs.Length == 1)
for (int j = 0; j < docs.Length; j++)
{
IManDocument doc = (IManDocument)docs;
// Check if this document was not previously marked as DELETED
// And active the menu entry only if it's not
doc.Refresh();
string database = (string)doc.GetAttributeValueByID(imProfileAttributeID.imProfileDatabase);
//// ********************************************************************************
////HERE -I'd liike to change the MenutextProperty attending the name of the database
//// ********************************************************************************
if (database != "Legal")
MenuText = "Publish";
else
MenuText = "PostPublish";
//// Insted the next change works
if (database != "Legal")
status = (int)CommandStatus.nrActiveCommand;
}
}
}
}
catch (Exception ex)
{
MessageBox.Show("An error occured when updating status of TikitContextMenu.DeleteDocument\n" + ex.Message,"Error",MessageBoxButtons.OK);
}
}
}
}
Thanks in advance
jny
The ICommand_MenuText Property is used to get and set values on the server side. It is then up to the client-side code to read it in for use. The WorkSite Desktop Client only reads in the menu text when it's loaded and not everytime the menu is refreshed thus the subsequent menu text changes are not acknowledged by the client.
The Status Property, however, is checked by the client everytime the menus are updated so to know whether or not to launch the command. The client will not read the MenuText Property because this requires a re-build of the entire menu.