From 782d2eb9945bb2a7ad43544e45c23a3ed30d3202 Mon Sep 17 00:00:00 2001 From: Kushal Munir < kmunir@ca.ibm.com> Date: Tue, 1 May 2007 19:52:18 +0000 Subject: [PATCH] [170909] [plan] Contribute User Actions and Import/Export from RSE7. Update model and registry for user actions. --- .../useractions/IUserActionModel.java | 14 ++++- .../internal/useractions/UserActionModel.java | 59 ++++++++++++++++++- .../useractions/UserActionRegistry.java | 4 +- 3 files changed, 72 insertions(+), 5 deletions(-) diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/IUserActionModel.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/IUserActionModel.java index ee81cf1e271..236a0bcec92 100644 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/IUserActionModel.java +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/IUserActionModel.java @@ -46,9 +46,21 @@ public interface IUserActionModel extends IRSEModelObject { */ public String getSupplier(); + /** + * Returns the command of the user action. + * @return the command of the user action. + */ + public String getCommand(); + + /** + * Returns the contexts to which the user action applies. + * @return array of user action contexts, or an empty array if there are no contexts to which the user action applies. + */ + public IUserActionContext[] getContexts(); + /** * Returns whether the user action is modifiable. * @return true if the user action is modifiable, false otherwise. */ public boolean isModifiable(); -} +} \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/UserActionModel.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/UserActionModel.java index 43586599f88..ea0350ef0db 100644 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/UserActionModel.java +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/UserActionModel.java @@ -10,6 +10,9 @@ *******************************************************************************/ package org.eclipse.rse.internal.useractions; +import java.util.ArrayList; +import java.util.List; + import org.eclipse.rse.core.model.IPropertySet; import org.eclipse.rse.core.model.IRSEPersistableContainer; import org.eclipse.rse.core.model.ISystemProfile; @@ -28,7 +31,23 @@ public class UserActionModel extends RSEModelObject implements IUserActionModel private String name; private String description; private String supplier; + private String command; + private List contextList; private boolean isModifiable; + + /** + * Creates a modifiable user action. + * @param profile the parent profile for which the user action applies. + * @param subsysConfig the subsystem configuration for which the user action applies. + * @param name the name of the user action. + */ + public UserActionModel(ISystemProfile profile, ISubSystemConfiguration subsysConfig, String name) { + super(); + this.profile = profile; + this.subsysConfig = subsysConfig; + this.name = name; + this.isModifiable = true; + } /** * Creates a user action model object. @@ -38,10 +57,12 @@ public class UserActionModel extends RSEModelObject implements IUserActionModel * @param name the name of the user action. * @param description the description of the user action. * @param supplier the supplier of the user action. + * @param command the command of the user action. + * @param contexts the array of user action contexts to which this user action applies, or an empty array if there are no contexts to which the user action applies. * @param sets the property sets associated with the user action. * @param isModifiable true if the user action is modifiable, false otherwise. */ - public UserActionModel(ISystemProfile profile, ISubSystemConfiguration subsysConfig, String type, String name, String description, String supplier, IPropertySet[] sets, boolean isModifiable) { + public UserActionModel(ISystemProfile profile, ISubSystemConfiguration subsysConfig, String type, String name, String description, String supplier, String command, IUserActionContext[] contexts, IPropertySet[] sets, boolean isModifiable) { super(); this.profile = profile; this.subsysConfig = subsysConfig; @@ -49,6 +70,13 @@ public class UserActionModel extends RSEModelObject implements IUserActionModel this.name = name; this.description = description; this.supplier = supplier; + this.command = command; + contextList = new ArrayList(); + + for (int i = 0; i < contexts.length; i++) { + contextList.add(contexts[i]); + } + addPropertySets(sets); this.isModifiable = isModifiable; } @@ -127,7 +155,7 @@ public class UserActionModel extends RSEModelObject implements IUserActionModel } /** - * Sets the supplier of the user action. + * Sets the supplier of the user action. It has no effect if the user action is not modifiable. * @param supplier the supplier of the user action. */ public void setSupplier(String supplier) { @@ -144,6 +172,33 @@ public class UserActionModel extends RSEModelObject implements IUserActionModel public String getSupplier() { return supplier; } + + /** + * Sets the command of the user action. It has no effect if the user action is not modifiable. + * @param command the command of the user action. + */ + public void setCommand(String command) { + + if (isModifiable()) { + this.command = command; + } + } + + /** + * Returns the command of the user action. + * @return the command of the user action. + */ + public String getCommand() { + return command; + } + + /** + * Returns the contexts to which the user action applies. + * @return array of user action contexts, or an empty array if there are no contexts to which the user action applies. + */ + public IUserActionContext[] getContexts() { + return (IUserActionContext[])(contextList.toArray()); + } /** * Returns whether the user action is modifiable. diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/UserActionRegistry.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/UserActionRegistry.java index 2d39554b097..7cadf6cd6a5 100644 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/UserActionRegistry.java +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/UserActionRegistry.java @@ -128,8 +128,8 @@ public class UserActionRegistry { */ public boolean containsUserActionModel(ISystemProfile profile, ISubSystemConfiguration configuration, IUserActionContext context) { - Map map = getUserActionContextMap(profile); - List list = getUserActionContexts(map, configuration); + Map map = getUserActionModelMap(profile); + List list = getUserActionModels(map, configuration); return list.contains(context); }