/**
* Create the actions.
*/
private void createActions() {
// New policy
ODOMActionCommand command = new ODOMActionCommand() {
public boolean enable(ODOMActionDetails details) {
Element selectedCategory = categoriesComposite.
getSelectedCategoryElement();
boolean enabled = selectedCategory != null;
if (enabled) {
// New policy is always enabled in admin mode when there
// is a selection.
enabled = context.isAdminProject();
if (!enabled) {
String categoryName = selectedCategory.
getAttributeValue(DeviceRepositorySchemaConstants.
CATEGORY_NAME_ATTRIBUTE);
enabled = categoryName.equals(
DeviceRepositorySchemaConstants.CUSTOM_CATEGORY_NAME);
}
}
return enabled;
}
public void run(ODOMActionDetails details) {
NewDevicePolicyWizard wizard =
new NewDevicePolicyWizard(getShell(),
context.getDeviceRepositoryAccessorManager());
wizard.open();
String policyName = wizard.getPolicyName();
// If the custom category is selected then prefix the policy
// name with the custom prefix to enable it to be identified
// as a custom policy.
if (categoriesComposite.
getSelectedCategoryElement().
getAttributeValue(DeviceRepositorySchemaConstants.
CATEGORY_NAME_ATTRIBUTE).
equals(DeviceRepositorySchemaConstants.
CUSTOM_CATEGORY_NAME)) {
StringBuffer buffer =
new StringBuffer(EclipseDeviceRepository.
getCustomPolicyNamePrefix());
buffer.append(policyName);
policyName = buffer.toString();
}
PolicyTypeComposition composition =
wizard.getPolicyTypeComposition();
PolicyType type = wizard.getPolicyType();
if (policyName != null && composition != null && type != null) {
// we don't allow policy creation to
// be undoable
try {
context.getUndoRedoManager().enable(false);
addNewPolicyToRepository(policyName, composition, type);
} finally {
context.getUndoRedoManager().enable(true);
}
selectNewPolicy(policyName);
}
}
};
newPolicyAction = new ODOMAction(command,
context,
null,
DevicesMessages.getResourceBundle(),
RESOURCE_PREFIX + "newPolicy.");
// Delete policy
command = new ODOMActionCommand() {
public boolean enable(ODOMActionDetails details) {
boolean enabled = categoriesComposite.getSelectedPolicyElement()
!= null;
if (enabled) {