mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-03 23:25:26 +02:00
[170909] [plan] Contribute User Actions and Import/Export from RSE7. Add model for user action contexts and user actions, and a registry to manage them.
This commit is contained in:
parent
ff6fc2fce7
commit
3cacc032a0
5 changed files with 604 additions and 0 deletions
|
@ -0,0 +1,45 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.rse.internal.useractions;
|
||||
|
||||
import org.eclipse.rse.core.model.IRSEModelObject;
|
||||
import org.eclipse.rse.core.model.ISystemProfile;
|
||||
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
|
||||
|
||||
/**
|
||||
* The interface for user action contexts. Clients can implement this interface.
|
||||
*/
|
||||
public interface IUserActionContext extends IRSEModelObject {
|
||||
|
||||
/**
|
||||
* Returns the profile that the user action context belongs to.
|
||||
* @return the profile that the user action context belongs to.
|
||||
*/
|
||||
public ISystemProfile getParentProfile();
|
||||
|
||||
/**
|
||||
* Returns the subsystem configuration that the user action context is applicable for.
|
||||
* @return the subsystem configuration that the user action context is applicable for.
|
||||
*/
|
||||
public ISubSystemConfiguration getParentConfiguration();
|
||||
|
||||
/**
|
||||
* Returns the supplier of the user action context.
|
||||
* @return the supplier of the user action context.
|
||||
*/
|
||||
public String getSupplier();
|
||||
|
||||
/**
|
||||
* Returns whether the user action context is modifiable.
|
||||
* @return <code>true<code> if the user action context is modifiable, <code>false</code> otherwise.
|
||||
*/
|
||||
public boolean isModifiable();
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.rse.internal.useractions;
|
||||
|
||||
import org.eclipse.rse.core.model.IRSEModelObject;
|
||||
import org.eclipse.rse.core.model.ISystemProfile;
|
||||
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
|
||||
|
||||
/**
|
||||
* The interface for user action model. Clients can implement this interface.
|
||||
*/
|
||||
public interface IUserActionModel extends IRSEModelObject {
|
||||
|
||||
public static final String USER_ACTION_TYPE = "USER_ACTION_GENERIC"; //$NON-NLS-1$
|
||||
public static final String USER_ACTION_COMPILE = "USER_ACTION_COMPILE"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Returns the profile that the user action belongs to.
|
||||
* @return the profile that the user action belongs to.
|
||||
*/
|
||||
public ISystemProfile getParentProfile();
|
||||
|
||||
/**
|
||||
* Returns the subsystem configuration that the user action is applicable for.
|
||||
* @return the subsystem configuration that the user action is applicable for.
|
||||
*/
|
||||
public ISubSystemConfiguration getParentConfiguration();
|
||||
|
||||
/**
|
||||
* The type of the user action.
|
||||
* @return the type of the user action.
|
||||
*/
|
||||
public String getType();
|
||||
|
||||
/**
|
||||
* Returns the supplier of the user action.
|
||||
* @return the supplier of the user action.
|
||||
*/
|
||||
public String getSupplier();
|
||||
|
||||
/**
|
||||
* Returns whether the user action is modifiable.
|
||||
* @return <code>true<code> if the user action is modifiable, <code>false</code> otherwise.
|
||||
*/
|
||||
public boolean isModifiable();
|
||||
}
|
|
@ -0,0 +1,172 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.rse.internal.useractions;
|
||||
|
||||
import org.eclipse.rse.core.model.IPropertySet;
|
||||
import org.eclipse.rse.core.model.IRSEPersistableContainer;
|
||||
import org.eclipse.rse.core.model.ISystemProfile;
|
||||
import org.eclipse.rse.core.model.RSEModelObject;
|
||||
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
|
||||
|
||||
/**
|
||||
* The model object for a user action context. A user action context is what a user action can apply to.
|
||||
* An example of a user action context is a named list of file types for which a certain user action applies.
|
||||
* Since the context can consist of different properties (file types, process names, etc.), the properties that make up the
|
||||
* context can be specified through property sets of the context.
|
||||
*/
|
||||
public class UserActionContext extends RSEModelObject implements IUserActionContext {
|
||||
|
||||
// persistent properties
|
||||
private ISystemProfile profile;
|
||||
private ISubSystemConfiguration subsysConfig;
|
||||
private String name;
|
||||
private String description;
|
||||
private String supplier;
|
||||
private boolean isModifiable;
|
||||
|
||||
/**
|
||||
* Creates a modifiable user action context.
|
||||
* @param profile the parent profile for which the user action context applies.
|
||||
* @param subsysConfig the subsystem configuration for which the user action context applies.
|
||||
* @param name the name of the user action context.
|
||||
*/
|
||||
public UserActionContext(ISystemProfile profile, ISubSystemConfiguration subsysConfig, String name) {
|
||||
super();
|
||||
this.profile = profile;
|
||||
this.subsysConfig = subsysConfig;
|
||||
this.name = name;
|
||||
this.isModifiable = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a user action context.
|
||||
* @param profile the parent profile for which the user action context applies.
|
||||
* @param subsysConfig the subsystem configuration for which the user action context applies.
|
||||
* @param name the name of the user action context.
|
||||
* @param description the description of the user action context.
|
||||
* @param supplier the supplier of the user action context.
|
||||
* @param sets the property sets associated with the user action context. The actual list of object types - for example, file types - that the context
|
||||
* represents can be specified through this parameter.
|
||||
* @param isModifiable <code>true</code> if the user action context is modifiable, <code>false</code> otherwise.
|
||||
*/
|
||||
public UserActionContext(ISystemProfile profile, ISubSystemConfiguration subsysConfig, String name, String description, String supplier, IPropertySet[] sets, boolean isModifiable) {
|
||||
super();
|
||||
this.profile = profile;
|
||||
this.subsysConfig = subsysConfig;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.supplier = supplier;
|
||||
addPropertySets(sets);
|
||||
this.isModifiable = isModifiable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the profile that the user action context belongs to.
|
||||
* @return the profile that the user action context belongs to.
|
||||
*/
|
||||
public ISystemProfile getParentProfile() {
|
||||
return profile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the subsystem configuration that the user action context is applicable for.
|
||||
* @return the subsystem configuration that the user action context is applicable for.
|
||||
*/
|
||||
public ISubSystemConfiguration getParentConfiguration() {
|
||||
return subsysConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name of the user action context. It has no effect if the user action context is not modifiable.
|
||||
* @param name the name of the user action context.
|
||||
*/
|
||||
public void setName(String name) {
|
||||
|
||||
if (isModifiable()) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the user action context.
|
||||
* @return the name of the user action context.
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the description of the user action context. It has no effect if the user action context is not modifiable.
|
||||
* @param description the description of the user action context.
|
||||
*/
|
||||
public void setDescription(String description) {
|
||||
|
||||
if (isModifiable()) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the description of the user action context.
|
||||
* @return the description of the user action context.
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the supplier of the user action context.
|
||||
* @param supplier the supplier of the user action context.
|
||||
*/
|
||||
public void setSupplier(String supplier) {
|
||||
|
||||
if (isModifiable()) {
|
||||
this.supplier = supplier;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the supplier of the user action context.
|
||||
* @return the supplier of the user action context.
|
||||
*/
|
||||
public String getSupplier() {
|
||||
return supplier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the user action context is modifiable.
|
||||
* @return <code>true</code> if the user action context is modifiable, <code>false</code> otherwise.
|
||||
*/
|
||||
public boolean isModifiable() {
|
||||
return isModifiable;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.core.model.IRSEPersistableContainer#commit()
|
||||
*/
|
||||
public boolean commit() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.core.model.IRSEPersistableContainer#getPersistableChildren()
|
||||
*/
|
||||
public IRSEPersistableContainer[] getPersistableChildren() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.core.model.IRSEPersistableContainer#getPersistableParent()
|
||||
*/
|
||||
public IRSEPersistableContainer getPersistableParent() {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,176 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.rse.internal.useractions;
|
||||
|
||||
import org.eclipse.rse.core.model.IPropertySet;
|
||||
import org.eclipse.rse.core.model.IRSEPersistableContainer;
|
||||
import org.eclipse.rse.core.model.ISystemProfile;
|
||||
import org.eclipse.rse.core.model.RSEModelObject;
|
||||
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
|
||||
|
||||
/**
|
||||
* The model object for a user action. A user action applies to objects in subsystems belonging to a subsystem configuration in a user profile.
|
||||
*/
|
||||
public class UserActionModel extends RSEModelObject implements IUserActionModel {
|
||||
|
||||
// persistent properties
|
||||
private ISystemProfile profile;
|
||||
private ISubSystemConfiguration subsysConfig;
|
||||
private String type;
|
||||
private String name;
|
||||
private String description;
|
||||
private String supplier;
|
||||
private boolean isModifiable;
|
||||
|
||||
/**
|
||||
* Creates a user action model object.
|
||||
* @param profile the parent profile for which the user action applies.
|
||||
* @param subsysConfig the subsystem configuration for which the user action applies.
|
||||
* @param type the type of the user action.
|
||||
* @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 sets the property sets associated with the user action.
|
||||
* @param isModifiable <code>true</code> if the user action is modifiable, <code>false</code> otherwise.
|
||||
*/
|
||||
public UserActionModel(ISystemProfile profile, ISubSystemConfiguration subsysConfig, String type, String name, String description, String supplier, IPropertySet[] sets, boolean isModifiable) {
|
||||
super();
|
||||
this.profile = profile;
|
||||
this.subsysConfig = subsysConfig;
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.supplier = supplier;
|
||||
addPropertySets(sets);
|
||||
this.isModifiable = isModifiable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the profile that the user action belongs to.
|
||||
* @return the profile that the user action belongs to.
|
||||
*/
|
||||
public ISystemProfile getParentProfile() {
|
||||
return profile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the subsystem configuration that the user action is applicable for.
|
||||
* @return the subsystem configuration that the user action is applicable for.
|
||||
*/
|
||||
public ISubSystemConfiguration getParentConfiguration() {
|
||||
return subsysConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the type of the user action.
|
||||
* @param type the type of the user action.
|
||||
*/
|
||||
public void setType(String type) {
|
||||
|
||||
if (isModifiable()) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of the user action.
|
||||
* @return the type of the user action.
|
||||
*/
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name of the user action. It has no effect if the user action is not modifiable.
|
||||
* @param name the name of the user action.
|
||||
*/
|
||||
public void setName(String name) {
|
||||
|
||||
if (isModifiable()) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the user action.
|
||||
* @return the name of the user action.
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the description of the user action. It has no effect if the user action is not modifiable.
|
||||
* @param description the description of the user action.
|
||||
*/
|
||||
public void setDescription(String description) {
|
||||
|
||||
if (isModifiable()) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the description of the user action.
|
||||
* @return the description of the user action.
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the supplier of the user action.
|
||||
* @param supplier the supplier of the user action.
|
||||
*/
|
||||
public void setSupplier(String supplier) {
|
||||
|
||||
if (isModifiable()) {
|
||||
this.supplier = supplier;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the supplier of the user action.
|
||||
* @return the supplier of the user action.
|
||||
*/
|
||||
public String getSupplier() {
|
||||
return supplier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the user action is modifiable.
|
||||
* @return <code>true</code> if the user action is modifiable, <code>false</code> otherwise.
|
||||
*/
|
||||
public boolean isModifiable() {
|
||||
return isModifiable;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.core.model.IRSEPersistableContainer#commit()
|
||||
*/
|
||||
public boolean commit() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.core.model.IRSEPersistableContainer#getPersistableChildren()
|
||||
*/
|
||||
public IRSEPersistableContainer[] getPersistableChildren() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.core.model.IRSEPersistableContainer#getPersistableParent()
|
||||
*/
|
||||
public IRSEPersistableContainer getPersistableParent() {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,157 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.rse.internal.useractions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.rse.core.model.ISystemProfile;
|
||||
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
|
||||
|
||||
/**
|
||||
* The registry for user actions and user action contexts. Use this class to add, remove, copy and query user actions and contexts.
|
||||
*/
|
||||
public class UserActionRegistry {
|
||||
|
||||
private static UserActionRegistry registry;
|
||||
|
||||
private Map userActionContextMap;
|
||||
private Map userActionModelMap;
|
||||
|
||||
/**
|
||||
* Constructor to create the registry.
|
||||
*/
|
||||
private UserActionRegistry() {
|
||||
userActionContextMap = new HashMap();
|
||||
userActionModelMap = new HashMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the singleton instance of the registry.
|
||||
* @return the singleton instance of the registry.
|
||||
*/
|
||||
public static UserActionRegistry getInstance() {
|
||||
|
||||
if (registry == null) {
|
||||
registry = new UserActionRegistry();
|
||||
}
|
||||
|
||||
return registry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the map associating subsystem configurations to list of user action contexts.
|
||||
* @return the map associating subsystem configurations to list of user action contexts.
|
||||
*/
|
||||
private Map getUserActionContextMap(ISystemProfile profile) {
|
||||
|
||||
if (!userActionContextMap.containsKey(profile)) {
|
||||
userActionContextMap.put(profile, new HashMap());
|
||||
}
|
||||
|
||||
return (Map)(userActionContextMap.get(profile));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the map associating subsystem configurations to list of user actions.
|
||||
* @return the map associating subsystem configurations to list of user actions.
|
||||
*/
|
||||
private Map getUserActionModelMap(ISystemProfile profile) {
|
||||
|
||||
if (!userActionModelMap.containsKey(profile)) {
|
||||
userActionModelMap.put(profile, new HashMap());
|
||||
}
|
||||
|
||||
return (Map)(userActionModelMap.get(profile));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of user action contexts from a map associating subsystem configurations with lists of user action contexts.
|
||||
* @param map the map.
|
||||
* @param configuration the subsystem configuration.
|
||||
* @return the list of user action contexts for the given configuration.
|
||||
*/
|
||||
private List getUserActionContexts(Map map, ISubSystemConfiguration configuration) {
|
||||
|
||||
if (!map.containsKey(configuration)) {
|
||||
map.put(configuration, new ArrayList());
|
||||
}
|
||||
|
||||
return (List)(map.get(configuration));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of user actions from a map associating subsystem configurations with lists of user actions.
|
||||
* @param map the map.
|
||||
* @param configuration the subsystem configuration.
|
||||
* @return the list of user actions for the given configuration.
|
||||
*/
|
||||
private List getUserActionModels(Map map, ISubSystemConfiguration configuration) {
|
||||
|
||||
if (!map.containsKey(configuration)) {
|
||||
map.put(configuration, new ArrayList());
|
||||
}
|
||||
|
||||
return (List)(map.get(configuration));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a user action context for the given profile and subsystem configuration.
|
||||
* @param profile the system profile.
|
||||
* @param configuration the subsystem configuration.
|
||||
* @param context the user action context.
|
||||
*/
|
||||
public void addUserActionContext(ISystemProfile profile, ISubSystemConfiguration configuration, IUserActionContext context) {
|
||||
|
||||
Map map = getUserActionContextMap(profile);
|
||||
List list = getUserActionContexts(map, configuration);
|
||||
list.add(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a user action for the given profile and subsystem configuration.
|
||||
* @param profile the system profile.
|
||||
* @param configuration the subsystem configuration.
|
||||
*/
|
||||
public void addUserActionModel(ISystemProfile profile, ISubSystemConfiguration configuration, IUserActionModel model) {
|
||||
|
||||
Map map = getUserActionModelMap(profile);
|
||||
List list = getUserActionModels(map, configuration);
|
||||
list.add(model);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a user action context for the given profile and subsystem configuration.
|
||||
* @param profile the system profile.
|
||||
* @param configuration the subsystem configuration.
|
||||
* @param context the user action context.
|
||||
*/
|
||||
public void removeUserActionContext(ISystemProfile profile, ISubSystemConfiguration configuration, IUserActionContext context) {
|
||||
|
||||
Map map = getUserActionContextMap(profile);
|
||||
List list = getUserActionContexts(map, configuration);
|
||||
list.remove(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a user action for the given profile and subsystem configuration.
|
||||
* @param profile the system profile.
|
||||
* @param configuration the subsystem configuration.
|
||||
*/
|
||||
public void removeUserActionModel(ISystemProfile profile, ISubSystemConfiguration configuration, IUserActionModel model) {
|
||||
|
||||
Map map = getUserActionModelMap(profile);
|
||||
List list = getUserActionModels(map, configuration);
|
||||
list.remove(model);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue