diff options
Diffstat (limited to 'rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse')
129 files changed, 0 insertions, 24146 deletions
diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/Activator.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/Activator.java deleted file mode 100644 index a4bdd2f7d..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/Activator.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - * David Dykstal (IBM) - [186589] move user actions API out of org.eclipse.rse.ui - * Kevin Doyle (IBM) - [222828] Icons for some Actions Missing - *******************************************************************************/ -package org.eclipse.rse.internal.useractions; - -import java.net.URL; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.rse.ui.SystemBasePlugin; -import org.osgi.framework.BundleContext; - -/** - * The main plugin class to be used in the desktop. - */ -public class Activator extends SystemBasePlugin { - //The shared instance. - private static Activator plugin; - public static final String PLUGIN_ID = "org.eclipse.rse.useractions"; //$NON-NLS-1$ - /** - * The constructor. - */ - public Activator() { - plugin = this; - } - - /** - * This method is called upon plug-in activation - */ - public void start(BundleContext context) throws Exception { - super.start(context); - } - - /** - * This method is called when the plug-in is stopped - */ - public void stop(BundleContext context) throws Exception { - super.stop(context); - plugin = null; - } - - /** - * Returns the shared instance. - */ - public static Activator getDefault() { - return plugin; - } - - /* - * (non-Javadoc) - * @see org.eclipse.rse.ui.SystemBasePlugin#initializeImageRegistry() - */ - protected void initializeImageRegistry() - { - putImageInRegistry(IUserActionsImageIds.COMPILE_0, "icons/full/dlcl16/compile.gif"); //$NON-NLS-1$ - putImageInRegistry(IUserActionsImageIds.COMPILE_1, "icons/full/elcl16/compile.gif"); //$NON-NLS-1$ - putImageInRegistry(IUserActionsImageIds.WORK_WITH_COMPILE_COMMANDS_0, "icons/full/dlcl16/workwithcompilecmds.gif"); //$NON-NLS-1$ - putImageInRegistry(IUserActionsImageIds.WORK_WITH_COMPILE_COMMANDS_1, "icons/full/elcl16/workwithcompilecmds.gif"); //$NON-NLS-1$ - putImageInRegistry(IUserActionsImageIds.WORK_WITH_NAMED_TYPES_0, "icons/full/dlcl16/workwithnamedtypes.gif"); //$NON-NLS-1$ - putImageInRegistry(IUserActionsImageIds.WORK_WITH_NAMED_TYPES_1, "icons/full/elcl16/workwithnamedtypes.gif"); //$NON-NLS-1$ - putImageInRegistry(IUserActionsImageIds.WORK_WITH_USER_ACTIONS_0, "icons/full/dlcl16/workwithuseractions.gif"); //$NON-NLS-1$ - putImageInRegistry(IUserActionsImageIds.WORK_WITH_USER_ACTIONS_1, "icons/full/elcl16/workwithuseractions.gif"); //$NON-NLS-1$ - - putImageInRegistry(IUserActionsImageIds.USERACTION_NEW, "icons/full/obj16/user_action_new_obj.gif"); //$NON-NLS-1$ - putImageInRegistry(IUserActionsImageIds.USERACTION_USR, "icons/full/obj16/user_action_obj.gif"); //$NON-NLS-1$ - putImageInRegistry(IUserActionsImageIds.USERACTION_IBM, "icons/full/obj16/user_action_ibm_obj.gif"); //$NON-NLS-1$ - putImageInRegistry(IUserActionsImageIds.USERACTION_IBMUSR, "icons/full/obj16/user_action_ibm_user_obj.gif"); //$NON-NLS-1$ - putImageInRegistry(IUserActionsImageIds.USERTYPE_NEW, "icons/full/obj16/user_type_new_obj.gif"); //$NON-NLS-1$ - putImageInRegistry(IUserActionsImageIds.USERTYPE_USR, "icons/full/obj16/user_type_obj.gif"); //$NON-NLS-1$ - putImageInRegistry(IUserActionsImageIds.USERTYPE_IBM, "icons/full/obj16/user_type_ibm_obj.gif"); //$NON-NLS-1$ - putImageInRegistry(IUserActionsImageIds.USERTYPE_IBMUSR, "icons/full/obj16/user_type_ibm_user_obj.gif"); //$NON-NLS-1$ - putImageInRegistry(IUserActionsImageIds.COMPILE_NEW, "icons/full/obj16/compcmd_new_obj.gif"); //$NON-NLS-1$ - putImageInRegistry(IUserActionsImageIds.COMPILE_USR, "icons/full/obj16/compcmd_user_obj.gif"); //$NON-NLS-1$ - putImageInRegistry(IUserActionsImageIds.COMPILE_IBM, "icons/full/obj16/compcmd_ibm_obj.gif"); //$NON-NLS-1$ - putImageInRegistry(IUserActionsImageIds.COMPILE_IBMUSR, "icons/full/obj16/compcmd_ibmuser_obj.gif"); //$NON-NLS-1$ - } - -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/IUserActionContext.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/IUserActionContext.java deleted file mode 100644 index 991b595cd..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/IUserActionContext.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * 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(); -} 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 deleted file mode 100644 index 236a0bcec..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/IUserActionModel.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * 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 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 <code>true<code> if the user action is modifiable, <code>false</code> 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/IUserActionsImageIds.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/IUserActionsImageIds.java deleted file mode 100644 index 9b46a6460..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/IUserActionsImageIds.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * 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: - * David Dykstal (IBM) - [186589] move user types, user actions, and compile commands - * API to the user actions plugin - * Kevin Doyle (IBM) - [222828] Icons for some Actions Missing - *******************************************************************************/ -package org.eclipse.rse.internal.useractions; - -public interface IUserActionsImageIds { - - public static final String COMPILE_0 = "COMPILE_0"; //$NON-NLS-1$ - public static final String COMPILE_1 = "COMPILE_1"; //$NON-NLS-1$ - public static final String WORK_WITH_USER_ACTIONS_0 = "WORK_WITH_USER_ACTIONS_0"; //$NON-NLS-1$ - public static final String WORK_WITH_USER_ACTIONS_1 = "WORK_WITH_USER_ACTIONS_1"; //$NON-NLS-1$ - public static final String WORK_WITH_NAMED_TYPES_0 = "WORK_WITH_NAMED_TYPES_0"; //$NON-NLS-1$ - public static final String WORK_WITH_NAMED_TYPES_1 = "WORK_WITH_NAMED_TYPES_1"; //$NON-NLS-1$ - public static final String WORK_WITH_COMPILE_COMMANDS_0 = "WORK_WITH_COMPILE_COMMANDS_0"; //$NON-NLS-1$ - public static final String WORK_WITH_COMPILE_COMMANDS_1 = "WORK_WITH_COMPILE_COMMANDS_1"; //$NON-NLS-1$ - - // Specific Compile Commands and User Action Icons - public static final String USERACTION_NEW = "USERACTION_NEW"; //$NON-NLS-1$ - public static final String USERACTION_USR = "USERACTION_USR"; //$NON-NLS-1$ - public static final String USERACTION_IBM = "USERACTION_IBM"; //$NON-NLS-1$ - public static final String USERACTION_IBMUSR = "USERACTION_IBMUSR"; //$NON-NLS-1$ - public static final String USERTYPE_NEW = "USERTYPE_NEW"; //$NON-NLS-1$ - public static final String USERTYPE_USR = "USERTYPE_USR"; //$NON-NLS-1$ - public static final String USERTYPE_IBM = "USERTYPE_IBM"; //$NON-NLS-1$ - public static final String USERTYPE_IBMUSR = "USERTYPE_IBMUSR"; //$NON-NLS-1$ - public static final String COMPILE_NEW = "COMPILE_NEW"; //$NON-NLS-1$ - public static final String COMPILE_USR = "COMPILE_USR"; //$NON-NLS-1$ - public static final String COMPILE_IBM = "COMPILE_IBM"; //$NON-NLS-1$ - public static final String COMPILE_IBMUSR = "COMPILE_IBMUSR"; //$NON-NLS-1$ -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/IUserActionsMessageIds.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/IUserActionsMessageIds.java deleted file mode 100644 index 70d5b3325..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/IUserActionsMessageIds.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 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: - * David Dykstal (IBM) - [186589] move user types, user actions, and compile commands - * API to the user actions plugin - * David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared - *******************************************************************************/ -package org.eclipse.rse.internal.useractions; - -public interface IUserActionsMessageIds { - - public static final String MSG_VALIDATE_UDANAME_EMPTY = "RSEG1180"; //$NON-NLS-1$ - public static final String MSG_VALIDATE_UDANAME_NOTUNIQUE= "RSEG1181"; //$NON-NLS-1$ - public static final String MSG_VALIDATE_UDANAME_NOTVALID = "RSEG1182"; //$NON-NLS-1$ - public static final String MSG_VALIDATE_UDACMT_EMPTY = "RSEG1183"; //$NON-NLS-1$ - public static final String MSG_VALIDATE_UDACMT_NOTVALID = "RSEG1184"; //$NON-NLS-1$ - public static final String MSG_VALIDATE_UDACMD_EMPTY = "RSEG1185"; //$NON-NLS-1$ - public static final String MSG_VALIDATE_UDACMD_NOTVALID = "RSEG1186"; //$NON-NLS-1$ - public static final String MSG_VALIDATE_UDTNAME_EMPTY = "RSEG1187"; //$NON-NLS-1$ - public static final String MSG_VALIDATE_UDTNAME_NOTUNIQUE= "RSEG1188"; //$NON-NLS-1$ - public static final String MSG_VALIDATE_UDTNAME_NOTVALID = "RSEG1189"; //$NON-NLS-1$ - public static final String MSG_VALIDATE_UDTTYPES_EMPTY = "RSEG1190"; //$NON-NLS-1$ - public static final String MSG_VALIDATE_UDTTYPES_NOTVALID = "RSEG1191"; //$NON-NLS-1$ - public static final String MSG_VALIDATE_COMPILELABEL_EMPTY = "RSEG1195"; //$NON-NLS-1$ - public static final String MSG_VALIDATE_COMPILELABEL_NOTUNIQUE= "RSEG1196"; //$NON-NLS-1$ - public static final String MSG_VALIDATE_COMPILELABEL_NOTVALID = "RSEG1197"; //$NON-NLS-1$ - public static final String MSG_VALIDATE_COMPILESTRING_EMPTY = "RSEG1198"; //$NON-NLS-1$ - public static final String MSG_VALIDATE_COMPILESTRING_NOTVALID = "RSEG1199"; //$NON-NLS-1$ - public static final String MSG_UDA_LOAD_ERROR = "RSEG1140"; //$NON-NLS-1$ - public static final String MSG_UDA_ROOTTAG_ERROR = "RSEG1141"; //$NON-NLS-1$ - public static final String MSG_CONFIRM_DELETE_USERACTION = "RSEG1230"; //$NON-NLS-1$ - public static final String MSG_CONFIRM_DELETE_USERTYPE = "RSEG1231"; //$NON-NLS-1$ - -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/IUserActionsModelChangeEvents.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/IUserActionsModelChangeEvents.java deleted file mode 100644 index eaf46a26a..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/IUserActionsModelChangeEvents.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * 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: - * David Dykstal (IBM) - [186589] move user types, user actions, and compile commands - * API to the user actions plugin - *******************************************************************************/ -package org.eclipse.rse.internal.useractions; - -/* - * These constants for model change events were taken from ISystemModelChangeEvents. - */ -public interface IUserActionsModelChangeEvents { - - /** - * Resource Type: user action - */ - public static final int SYSTEM_RESOURCETYPE_USERACTION = 128; - /** - * Resource Type: named type, which are used in user actions - */ - public static final int SYSTEM_RESOURCETYPE_NAMEDTYPE = 256; - /** - * Resource Type: compile command - */ - public static final int SYSTEM_RESOURCETYPE_COMPILECMD = 512; - -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/UserActionContext.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/UserActionContext.java deleted file mode 100644 index 54b970035..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/UserActionContext.java +++ /dev/null @@ -1,172 +0,0 @@ -/******************************************************************************* - * 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 IRSEPersistableContainer.NO_CHILDREN; - } - - /* (non-Javadoc) - * @see org.eclipse.rse.core.model.IRSEPersistableContainer#getPersistableParent() - */ - public IRSEPersistableContainer getPersistableParent() { - return null; - } -}
\ 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 deleted file mode 100644 index 4811a94db..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/UserActionModel.java +++ /dev/null @@ -1,231 +0,0 @@ -/******************************************************************************* - * 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.List; - -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 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. - * @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 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 <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, String command, IUserActionContext[] contexts, IPropertySet[] sets, boolean isModifiable) { - super(); - this.profile = profile; - this.subsysConfig = subsysConfig; - this.type = type; - 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; - } - - /** - * 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. It has no effect if the user action is not modifiable. - * @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; - } - - /** - * 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. - * @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 IRSEPersistableContainer.NO_CHILDREN; - } - - /* (non-Javadoc) - * @see org.eclipse.rse.core.model.IRSEPersistableContainer#getPersistableParent() - */ - public IRSEPersistableContainer getPersistableParent() { - return null; - } -}
\ No newline at end of file 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 deleted file mode 100644 index 631cd5144..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/UserActionRegistry.java +++ /dev/null @@ -1,205 +0,0 @@ -/******************************************************************************* - * 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)); - } - - /** - * Returns whether a user action context for the given profile and subsystem configuration exists. - * @param profile the system profile. - * @param configuration the subsystem configuration. - * @param context the user action context. - * @return <code>true</code> if the user action context exists, <code>false</code> otherwise. - */ - public boolean containsUserActionContext(ISystemProfile profile, ISubSystemConfiguration configuration, IUserActionContext context) { - Map map = getUserActionContextMap(profile); - List list = getUserActionContexts(map, configuration); - return list.contains(context); - } - - /** - * Returns whether a user action for the given profile and subsystem configuration exists. - * @param profile the system profile. - * @param configuration the subsystem configuration. - * @param context the user action. - * @return <code>true</code> if the user action context exists, <code>false</code> otherwise. - */ - public boolean containsUserActionModel(ISystemProfile profile, ISubSystemConfiguration configuration, IUserActionContext context) { - Map map = getUserActionModelMap(profile); - List list = getUserActionModels(map, configuration); - return list.contains(context); - } - - /** - * 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. - * @param model the user action model. - */ - 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. - * @param model the user action model. - */ - public void removeUserActionModel(ISystemProfile profile, ISubSystemConfiguration configuration, IUserActionModel model) { - Map map = getUserActionModelMap(profile); - List list = getUserActionModels(map, configuration); - list.remove(model); - } - - /** - * Returns an array of user action contexts for the given profile and subsystem configuration. - * @param profile the system profile. - * @param configuration the subsystem configuration. - * @return the array of user action contexts, or an empty array if none. - */ - public IUserActionContext[] getUserActionContexts(ISystemProfile profile, ISubSystemConfiguration configuration) { - Map map = getUserActionContextMap(profile); - List list = getUserActionContexts(map, configuration); - return (IUserActionContext[])(list.toArray()); - } - - /** - * Returns an array of user actions for the given profile and subsystem configuration. - * @param profile the system profile. - * @param configuration the subsystem configuration. - * @return the array of user action models, or an empty array if none. - */ - public IUserActionModel[] getUserActionModels(ISystemProfile profile, ISubSystemConfiguration configuration) { - Map map = getUserActionModelMap(profile); - List list = getUserActionModels(map, configuration); - return (IUserActionModel[])(list.toArray()); - } -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/UserActionsIcon.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/UserActionsIcon.java deleted file mode 100644 index c6ec9a54b..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/UserActionsIcon.java +++ /dev/null @@ -1,110 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 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 - * David Dykstal (IBM) - [186589] move user types, user actions, and compile commands - * API to the user actions plugin - * Kevin Doyle (IBM) - [222828] Icons for some Actions Missing - *******************************************************************************/ -package org.eclipse.rse.internal.useractions; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.swt.graphics.Image; - -/** - * Defines the standard icons for user actions, user types, and compile commands. - * Images and image descriptions may be extracted from these. - * There is no public constructor. Use the predefined instances of this class - * to access the images and descriptors. - */ -public class UserActionsIcon { - - /** - * A new user defined action. - */ - public static final UserActionsIcon USERACTION_NEW = new UserActionsIcon(IUserActionsImageIds.USERACTION_NEW); - - /** - * An existing user defined user action. - */ - public static final UserActionsIcon USERACTION_USR = new UserActionsIcon(IUserActionsImageIds.USERACTION_USR); - - /** - * A predefined user defined action. - */ - public static final UserActionsIcon USERACTION_IBM = new UserActionsIcon(IUserActionsImageIds.USERACTION_IBM); - - /** - * A predefined user defined action that has been modified. - */ - public static final UserActionsIcon USERACTION_IBMUSR = new UserActionsIcon(IUserActionsImageIds.USERACTION_IBMUSR); - - /** - * A new user defined type. - */ - public static final UserActionsIcon USERTYPE_NEW = new UserActionsIcon(IUserActionsImageIds.USERTYPE_NEW); - - /** - * An existing user defined type. - */ - public static final UserActionsIcon USERTYPE_USR = new UserActionsIcon(IUserActionsImageIds.USERTYPE_USR); - - /** - * A predefined user defined type. - */ - public static final UserActionsIcon USERTYPE_IBM = new UserActionsIcon(IUserActionsImageIds.USERTYPE_IBM); - - /** - * A predefined user defined type that has been modified. - */ - public static final UserActionsIcon USERTYPE_IBMUSR = new UserActionsIcon(IUserActionsImageIds.USERTYPE_IBMUSR); - - /** - * A new user defined compile command. - */ - public static final UserActionsIcon COMPILE_NEW = new UserActionsIcon(IUserActionsImageIds.COMPILE_NEW); - - /** - * An existing user defined compile command. - */ - public static final UserActionsIcon COMPILE_USR = new UserActionsIcon(IUserActionsImageIds.COMPILE_USR); - - /** - * A predefined user defined compile command. - */ - public static final UserActionsIcon COMPILE_IBM = new UserActionsIcon(IUserActionsImageIds.COMPILE_IBM); - - /** - * A predefined user defined compile command that has been edited. - */ - public static final UserActionsIcon COMPILE_IBMUSR = new UserActionsIcon(IUserActionsImageIds.COMPILE_IBMUSR); - - private String imageID; - - private UserActionsIcon(String imageID) { - this.imageID = imageID; - } - - /** - * Gets the image associated with this icon. This image is stored in the image registry of the - * user actions plugin and therefore the image must not be disposed when its use is completed. - * @return the image - */ - public Image getImage() { - return Activator.getDefault().getImage(imageID); - } - - /** - * Gets the image descriptor associated with this icon. - * @return the image descriptor - */ - public ImageDescriptor getImageDescriptor() { - return Activator.getDefault().getImageDescriptor(imageID); - } - -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/UserActionsPersistenceUtil.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/UserActionsPersistenceUtil.java deleted file mode 100644 index b5ac28fcf..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/UserActionsPersistenceUtil.java +++ /dev/null @@ -1,212 +0,0 @@ -/******************************************************************************* - * 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 - * David Dykstal (IBM) - [186589] move user types, user actions, and compile commands - * API to the user actions plugin - *******************************************************************************/ -package org.eclipse.rse.internal.useractions; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.rse.core.model.ISystemProfile; -import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; - -/** - * This class is a placeholder documenting the old persistence API and structure for - * user actions, user type filters, and compile commands. - * The class is not functional. - * TODO: (dwd) this needs to be replaced with the new persistence provider scheme. - */ -public class UserActionsPersistenceUtil { - - - /* - * Bogus infrastructure to make this compile - */ - - private static class ResourceHelpers { - IFolder getOrCreateFolder(IFolder parent, String folderName) { - return null; - } - IFolder getFolder(IContainer parent, String folderName) { - return null; - } - } - - private static ResourceHelpers getResourceHelpers() { - return new ResourceHelpers(); - } - - private static IFolder getProfileFolder(String profileName) { - return null; - } - - private static String getFolderName(ISubSystemConfiguration subystemConfiguration) { - return null; - } - - private static IProject getRemoteSystemsProject() { - return null; - } - - private static final String RESOURCE_USERACTIONS_FOLDER_NAME = null; - private static final String RESOURCE_COMPILECOMMANDS_FOLDER_NAME = null; - private static final String RESOURCE_TYPE_FILTERS_FOLDER_NAME = null; - - /* - * -------------------------------------------------------------------------------------------------------------------------------- - * USER ACTIONS SUBTREE FOLDER METHODS... - * ====================================== - * .--- Team (folder) - getProfileFolder(SystemProfile/"team") - * | | - * | | - * | .--- UserActions (folder) - getUserActionsFolder(SystemProfile/"team") - * | | - * | .--- SubSystemConfigurationID1 (folder) - getUserActionsFolder(SystemProfile/"team", SubSystemConfiguration) - * | | .--- actions.xml (file) - * | .--- SubSystemConfigurationID2 (folder) - * | .--- actions.xml (file) - * -------------------------------------------------------------------------------------------------------------------------------- - */ - // --------------------------------------------------- - // GET USER DEFINED ACTIONS ROOT FOLDER PER PROFILE... - // --------------------------------------------------- - /** - * Get user defined actions root folder given a system profile name - */ - protected static IFolder getUserActionsFolder(String profileName) - { - return getResourceHelpers().getOrCreateFolder(getProfileFolder(profileName),RESOURCE_USERACTIONS_FOLDER_NAME); - } - /** - * Get user defined actions root folder given a system profile object and subsystem factory - */ - public static IFolder getUserActionsFolder(ISystemProfile profile, ISubSystemConfiguration ssFactory) - { - return getUserActionsFolder(profile.getName(),ssFactory); - } - /** - * Get user defined actions root folder given a system profile name and subsystem factory - */ - public static IFolder getUserActionsFolder(String profileName, ISubSystemConfiguration ssFactory) - { - IFolder parentFolder = getUserActionsFolder(profileName); - String folderName = getFolderName(ssFactory); - return getResourceHelpers().getOrCreateFolder(parentFolder, folderName); // Do create it. - } - /** - * Test for existence of user defined actions root folder given a system profile name and subsystem factory - */ - public static boolean testUserActionsFolder(String profileName, ISubSystemConfiguration ssFactory) - { - IFolder parentFolder = getUserActionsFolder(profileName); - String folderName = getFolderName(ssFactory); - return (getResourceHelpers().getFolder(parentFolder, folderName).exists()); // Do NOT create it. - } - - /** - * Get user defined actions root folder given a system profile name and subsystem factory Id. - * This is a special-needs method provided for the Import action processing, - * when a subsystem instance is not available. - */ - public static IFolder getUserActionsFolder( String profileName, String factoryId) - { - IFolder parentFolder = getUserActionsFolder(profileName); - return getResourceHelpers().getOrCreateFolder(parentFolder, factoryId); // Do create it. - } - - /* - * -------------------------------------------------------------------------------------------------------------------------------- - * COMPILE COMMAND SUBTREE FOLDER METHODS... - * ====================================== - * .--- Team (folder) - getProfileFolder(SystemProfile/"team") - * | | - * | | - * | .--- CompileCommands (folder) - getCompileCommandsFolder(SystemProfile/"team") - * | | - * | .--- SubSystemConfigurationID1 (folder) - getCompileCommandsFolder(SystemProfile/"team", SubSystemConfiguration) - * | | .--- compileCommands.xml (file) - * | .--- SubSystemConfigurationID2 (folder) - * | .--- compileCommands.xml (file) - * -------------------------------------------------------------------------------------------------------------------------------- - */ - // --------------------------------------------------- - // GET COMPILE COMMANDS ROOT FOLDER PER PROFILE... - // --------------------------------------------------- - /** - * Get compile commands root folder given a system profile name - */ - protected static IFolder getCompileCommandsFolder(String profileName) - { - return getResourceHelpers().getOrCreateFolder(getProfileFolder(profileName),RESOURCE_COMPILECOMMANDS_FOLDER_NAME); - } - /** - * Get compile commands root folder given a system profile object and subsystem factory - */ - public static IFolder getCompileCommandsFolder(ISystemProfile profile, ISubSystemConfiguration ssFactory) - { - return getCompileCommandsFolder(profile.getName(),ssFactory); - } - /** - * Get compile commands root folder given a system profile name and subsystem factory - */ - public static IFolder getCompileCommandsFolder(String profileName, ISubSystemConfiguration ssFactory) - { - IFolder parentFolder = getCompileCommandsFolder(profileName); - String folderName = getFolderName(ssFactory); - return getResourceHelpers().getOrCreateFolder(parentFolder, folderName); // Do create it. - } - - /** - * Get compile commands root folder given a system profile name and subsystem factory Id. - * This is a special-needs method provided for the Import action processing, - * when a subsystem instance is not available. - */ - public static IFolder getCompileCommandsFolder( String profileName, String factoryId) - { - IFolder parentFolder = getCompileCommandsFolder(profileName); - return getResourceHelpers().getOrCreateFolder(parentFolder, factoryId); // Do create it. - } - - /* - * -------------------------------------------------------------------------------------------------------------------------------- - * TYPE FILTERS SUBTREE FOLDER METHODS... - * ====================================== - * .--- TypeFilters (folder) - getTypeFiltersFolder() - * .--- SubSystemConfigurationID1 (folder) - getTypeFiltersFolder(SubSystemConfiguration) - * | .--- typefilters.xmi (file) - * -------------------------------------------------------------------------------------------------------------------------------- - */ - - /** - * Get the typeFilters root folder - */ - public static IFolder getTypeFiltersFolder() - { - return getResourceHelpers().getFolder(getRemoteSystemsProject(),RESOURCE_TYPE_FILTERS_FOLDER_NAME); - } - /** - * Get the typeFilters sub-folder per subsystem factory object - */ - public static IFolder getTypeFiltersFolder(ISubSystemConfiguration ssFactory) - { - IFolder parentFolder = getTypeFiltersFolder(); - String folderName = getFolderName(ssFactory); - return getResourceHelpers().getOrCreateFolder(parentFolder, folderName); // DO create it. - } - /** - * Get the typeFilters sub-folder per subsystem factory id - */ - public static IFolder getTypeFiltersFolder(String ssFactoryId) - { - IFolder parentFolder = getTypeFiltersFolder(); - return getResourceHelpers().getOrCreateFolder(parentFolder, ssFactoryId); // DO create it. - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/UserActionsResources.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/UserActionsResources.java deleted file mode 100644 index eb6ec4d3e..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/UserActionsResources.java +++ /dev/null @@ -1,124 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - * David McKnight (IBM) - [216252] [nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible - *******************************************************************************/ -package org.eclipse.rse.internal.useractions; - -import org.eclipse.osgi.util.NLS; - -public class UserActionsResources extends NLS { - private static String BUNDLE_NAME = "org.eclipse.rse.internal.useractions.UserActionsResources"; //$NON-NLS-1$ - // Property sheet values: Categories in Team view - public static String RESID_PROPERTY_TEAM_USERACTION_TYPE_VALUE; - public static String RESID_PROPERTY_TEAM_COMPILETYPE_TYPE_VALUE; - public static String RESID_PROPERTY_TEAM_COMPILECMD_TYPE_VALUE; - // USER ACTION PROPERTIES PAGE... - public static String RESID_PP_USERACTION_TITLE; - public static String RESID_PP_USERACTION_TYPE_VALUE; - public static String RESID_PP_USERACTION_PROFILE_LABEL; - public static String RESID_PP_USERACTION_PROFILE_TOOLTIP; - public static String RESID_PP_USERACTION_ORIGIN_LABEL; - public static String RESID_PP_USERACTION_ORIGIN_TOOLTIP; - public static String RESID_PP_USERACTION_DOMAIN_LABEL; - public static String RESID_PP_USERACTION_DOMAIN_TOOLTIP; - // COMPILE TYPE PROPERTIES PAGE... - public static String RESID_PP_COMPILETYPE_TITLE; - public static String RESID_PP_COMPILETYPE_TYPE_VALUE; - public static String RESID_PP_COMPILETYPE_TYPE_TOOLTIP; - public static String RESID_PP_COMPILETYPE_PROFILE_LABEL; - public static String RESID_PP_COMPILETYPE_PROFILE_TOOLTIP; - public static String RESID_PP_COMPILETYPE_FILETYPE_LABEL; - public static String RESID_PP_COMPILETYPE_FILETYPE_TOOLTIP; - // COMPILE COMMAND PROPERTIES PAGE... - public static String RESID_PP_COMPILECMD_TITLE; - public static String RESID_PP_COMPILECMD_TYPE_VALUE; - public static String RESID_PP_COMPILECMD_PROFILE_LABEL; - public static String RESID_PP_COMPILECMD_PROFILE_TOOLTIP; - public static String RESID_PP_COMPILECMD_ORIGIN_LABEL; - public static String RESID_PP_COMPILECMD_ORIGIN_TOOLTIP; - // USER ACTIONS - public static String ACTION_COMPILE_NOPROMPT_LABEL; - public static String ACTION_COMPILE_NOPROMPT_TOOLTIP; - public static String ACTION_COMPILE_PROMPT_LABEL; - public static String ACTION_COMPILE_PROMPT_TOOLTIP; - // Property sheet values: User actions - public static String RESID_PROPERTY_ORIGIN_IBM_VALUE; - public static String RESID_PROPERTY_ORIGIN_IBMUSER_VALUE; - public static String RESID_PROPERTY_ORIGIN_USER_VALUE; - public static String RESID_PROPERTY_ORIGIN_ISV_VALUE; - public static String RESID_PROPERTY_ORIGIN_ISVUSER_VALUE; - public static String RESID_PROPERTY_USERACTION_VENDOR_LABEL; - public static String RESID_PROPERTY_USERACTION_VENDOR_TOOLTIP; - public static String RESID_PROPERTY_USERACTION_DOMAIN_LABEL; - public static String RESID_PROPERTY_USERACTION_DOMAIN_TOOLTIP; - public static String RESID_PROPERTY_USERACTION_DOMAIN_ALL_VALUE; - // Property sheet values: Compile types - public static String RESID_PROPERTY_COMPILETYPE_TYPES_LABEL; - public static String RESID_PROPERTY_COMPILETYPE_TYPES_DESCRIPTION; - // TEAM VIEW - public static String RESID_TEAMVIEW_USERACTION_VALUE; - - - public static String RESID_PROPERTY_ORIGIN_LABEL; - public static String RESID_PROPERTY_ORIGIN_TOOLTIP; - public static String RESID_PROPERTY_COMMAND_LABEL; - public static String RESID_PROPERTY_COMMAND_TOOLTIP; - public static String RESID_PROPERTY_COMMENT_LABEL; - public static String RESID_PROPERTY_COMMENT_TOOLTIP; - - public static String MSG_VALIDATE_UDANAME_EMPTY; - public static String MSG_VALIDATE_UDANAME_NOTUNIQUE; - public static String MSG_VALIDATE_UDANAME_NOTVALID; - public static String MSG_VALIDATE_UDACMT_EMPTY; - public static String MSG_VALIDATE_UDACMT_NOTVALID; - public static String MSG_VALIDATE_UDACMD_EMPTY; - public static String MSG_VALIDATE_UDACMD_NOTVALID; - public static String MSG_VALIDATE_UDTNAME_EMPTY; - public static String MSG_VALIDATE_UDTNAME_NOTUNIQUE; - public static String MSG_VALIDATE_UDTNAME_NOTVALID; - public static String MSG_VALIDATE_UDTTYPES_EMPTY; - public static String MSG_VALIDATE_UDTTYPES_NOTVALID; - public static String MSG_VALIDATE_COMPILELABEL_EMPTY; - public static String MSG_VALIDATE_COMPILELABEL_NOTUNIQUE; - public static String MSG_VALIDATE_COMPILELABEL_NOTVALID; - public static String MSG_VALIDATE_COMPILESTRING_EMPTY; - public static String MSG_VALIDATE_COMPILESTRING_NOTVALID; - public static String MSG_UDA_LOAD_ERROR; - public static String MSG_UDA_ROOTTAG_ERROR; - public static String MSG_CONFIRM_DELETE_USERACTION; - public static String MSG_CONFIRM_DELETE_USERTYPE; - - public static String MSG_VALIDATE_UDANAME_EMPTY_DETAILS; - public static String MSG_VALIDATE_UDANAME_NOTUNIQUE_DETAILS; - public static String MSG_VALIDATE_UDANAME_NOTVALID_DETAILS; - public static String MSG_VALIDATE_UDACMT_EMPTY_DETAILS; - public static String MSG_VALIDATE_UDACMT_NOTVALID_DETAILS; - public static String MSG_VALIDATE_UDACMD_EMPTY_DETAILS; - public static String MSG_VALIDATE_UDACMD_NOTVALID_DETAILS; - public static String MSG_VALIDATE_UDTNAME_EMPTY_DETAILS; - public static String MSG_VALIDATE_UDTNAME_NOTUNIQUE_DETAILS; - public static String MSG_VALIDATE_UDTNAME_NOTVALID_DETAILS; - public static String MSG_VALIDATE_UDTTYPES_EMPTY_DETAILS; - public static String MSG_VALIDATE_UDTTYPES_NOTVALID_DETAILS; - public static String MSG_VALIDATE_COMPILELABEL_EMPTY_DETAILS; - public static String MSG_VALIDATE_COMPILELABEL_NOTUNIQUE_DETAILS; - public static String MSG_VALIDATE_COMPILELABEL_NOTVALID_DETAILS; - public static String MSG_VALIDATE_COMPILESTRING_EMPTY_DETAILS; - public static String MSG_VALIDATE_COMPILESTRING_NOTVALID_DETAILS; - - public static String MSG_UDA_ROOTTAG_ERROR_DETAILS; - public static String MSG_CONFIRM_DELETE_USERACTION_DETAILS; - public static String MSG_CONFIRM_DELETE_USERTYPE_DETAILS; - - static { - // load message values from bundle file - NLS.initializeMessages(BUNDLE_NAME, UserActionsResources.class); - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/UserActionsResources.properties b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/UserActionsResources.properties deleted file mode 100644 index 24c82c799..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/UserActionsResources.properties +++ /dev/null @@ -1,158 +0,0 @@ -############################################################################### -# Copyright (c) 2002, 2008 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 -# David McKnight (IBM) - [216252] [nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible -############################################################################### - -# NLS_MESSAGEFORMAT_VAR -# NLS_ENCODING=UTF-8 - -#TEAM VIEW PROPERTIES -RESID_PROPERTY_TEAM_USERACTION_TYPE_VALUE=User action -RESID_PROPERTY_TEAM_COMPILETYPE_TYPE_VALUE=Compilable source type -RESID_PROPERTY_TEAM_COMPILECMD_TYPE_VALUE=Compile command - -#============================================================= -# USER ACTION PROPERTIES PAGE... -#============================================================= -RESID_PP_USERACTION_TITLE=Properties for User Action -RESID_PP_USERACTION_TYPE_VALUE=User action -RESID_PP_USERACTION_PROFILE_LABEL=Parent profile -RESID_PP_USERACTION_PROFILE_TOOLTIP=Profile that contains this user action -RESID_PP_USERACTION_ORIGIN_LABEL=Origin -RESID_PP_USERACTION_ORIGIN_TOOLTIP=Who supplied this user action? -RESID_PP_USERACTION_DOMAIN_LABEL=Domain -RESID_PP_USERACTION_DOMAIN_TOOLTIP=What domain is this action scoped to? - -#============================================================= -# COMPILE TYPE PROPERTIES PAGE... -#============================================================= -RESID_PP_COMPILETYPE_TITLE=Properties for Compilable Source Type -RESID_PP_COMPILETYPE_TYPE_VALUE=Compilable source type -RESID_PP_COMPILETYPE_TYPE_TOOLTIP=What type of artifact is this? -RESID_PP_COMPILETYPE_PROFILE_LABEL=Parent profile -RESID_PP_COMPILETYPE_PROFILE_TOOLTIP=Profile that contains this compile type and its compile commands -RESID_PP_COMPILETYPE_FILETYPE_LABEL=Source type -RESID_PP_COMPILETYPE_FILETYPE_TOOLTIP=The type of source that this type's compile commands apply to - -#============================================================= -# COMPILE COMMAND PROPERTIES PAGE... -#============================================================= -RESID_PP_COMPILECMD_TITLE=Properties for Compilable Command -RESID_PP_COMPILECMD_TYPE_VALUE=Compile command -RESID_PP_COMPILECMD_PROFILE_LABEL=Parent profile -RESID_PP_COMPILECMD_PROFILE_TOOLTIP=Profile that contains this compile command -RESID_PP_COMPILECMD_ORIGIN_LABEL=Origin -RESID_PP_COMPILECMD_ORIGIN_TOOLTIP=Who supplied this compile command? - -#============================================================= -# USER ACTIONS... -#============================================================= -ACTION_COMPILE_NOPROMPT_LABEL=Compile -ACTION_COMPILE_NOPROMPT_TOOLTIP=Run compile commands without prompting them -ACTION_COMPILE_PROMPT_LABEL=Compile (Prompt) -ACTION_COMPILE_PROMPT_TOOLTIP=Prompt and then run compile commands - -#============================================================= -#USER ACTION PROPERTIES - PROPERTY SHEET -#============================================================= -RESID_PROPERTY_ORIGIN_IBM_VALUE=IBM supplied -RESID_PROPERTY_ORIGIN_IBMUSER_VALUE=IBM supplied, user edited -RESID_PROPERTY_ORIGIN_ISV_VALUE=ISV supplied -RESID_PROPERTY_ORIGIN_ISVUSER_VALUE=ISV supplied, user edited -RESID_PROPERTY_ORIGIN_USER_VALUE=User defined -RESID_PROPERTY_USERACTION_DOMAIN_ALL_VALUE=All -RESID_PROPERTY_USERACTION_VENDOR_LABEL=Vendor -RESID_PROPERTY_USERACTION_VENDOR_TOOLTIP=Vendor that supplied this command -RESID_PROPERTY_USERACTION_DOMAIN_LABEL=Domain -RESID_PROPERTY_USERACTION_DOMAIN_TOOLTIP=Object domain this applies to - -#============================================================= -#COMPILE TYPE PROPERTIES - PROPERTY SHEET -#============================================================= -RESID_PROPERTY_COMPILETYPE_TYPES_LABEL=File type -RESID_PROPERTY_COMPILETYPE_TYPES_DESCRIPTION=File type this refers to - -#============================================================= -# Team View -#============================================================= -RESID_TEAMVIEW_USERACTION_VALUE=User action - -RESID_PROPERTY_ORIGIN_LABEL=Origin -RESID_PROPERTY_ORIGIN_TOOLTIP=Where this originated from -RESID_PROPERTY_COMMAND_LABEL=Command -RESID_PROPERTY_COMMAND_TOOLTIP=The command that will be executed -RESID_PROPERTY_COMMENT_LABEL=Comment -RESID_PROPERTY_COMMENT_TOOLTIP=A description - - -MSG_VALIDATE_UDANAME_EMPTY = Enter action name -MSG_VALIDATE_UDANAME_EMPTY_DETAILS = You must enter a name for this action - -MSG_VALIDATE_UDANAME_NOTUNIQUE= Action name is not unique -MSG_VALIDATE_UDANAME_NOTUNIQUE_DETAILS = There is already an action with the given name in the selected profile. Specify a name that is not already in use - -MSG_VALIDATE_UDANAME_NOTVALID =Action name is not valid -MSG_VALIDATE_UDANAME_NOTVALID_DETAILS =The given name is not a valid action name - -MSG_VALIDATE_UDACMT_EMPTY = Enter comment -MSG_VALIDATE_UDACMT_EMPTY_DETAILS = You must enter a comment for this action - -MSG_VALIDATE_UDACMT_NOTVALID = Action comment is not valid -MSG_VALIDATE_UDACMT_NOTVALID_DETAILS =The given comment has syntactical errors - -MSG_VALIDATE_UDACMD_EMPTY = Enter command -MSG_VALIDATE_UDACMD_EMPTY_DETAILS = You must enter a command for this action - -MSG_VALIDATE_UDACMD_NOTVALID = Action command is not valid -MSG_VALIDATE_UDACMD_NOTVALID_DETAILS = The given command has syntactical errors - -MSG_VALIDATE_UDTNAME_EMPTY = Enter type name -MSG_VALIDATE_UDTNAME_EMPTY_DETAILS = You must enter a name for this collection of resource types - -MSG_VALIDATE_UDTNAME_NOTUNIQUE= Type name {0} in use -MSG_VALIDATE_UDTNAME_NOTUNIQUE_DETAILS = There is already a named type with the given name. Specify a name that is not already in use - -MSG_VALIDATE_UDTNAME_NOTVALID = Type name {0} is not valid -MSG_VALIDATE_UDTNAME_NOTVALID_DETAILS =The given name is not valid for a named type. It must not contain blanks - -MSG_VALIDATE_UDTTYPES_EMPTY = Specify one or more resource types -MSG_VALIDATE_UDTTYPES_EMPTY_DETAILS = You must specify one or more simple or generic resource types to constitute this named type - -MSG_VALIDATE_UDTTYPES_NOTVALID = Types not valid -MSG_VALIDATE_UDTTYPES_NOTVALID_DETAILS = Syntactical errors were found in the list of resource types - -MSG_VALIDATE_COMPILELABEL_EMPTY = Enter a label for this compile command -MSG_VALIDATE_COMPILELABEL_EMPTY_DETAILS = You must enter a label for this compile command, that will be shown in menus and lists - -MSG_VALIDATE_COMPILELABEL_NOTUNIQUE= Compile command label "{0}" is in use -MSG_VALIDATE_COMPILELABEL_NOTUNIQUE_DETAILS =There is already a compile command with the given label. Specify a label that is not already in use - -MSG_VALIDATE_COMPILELABEL_NOTVALID = Compile command label "{0}" is not valid -MSG_VALIDATE_COMPILELABEL_NOTVALID_DETAILS =The given label is not a valid compile label - -MSG_VALIDATE_COMPILESTRING_EMPTY = Enter command string for this compile command -MSG_VALIDATE_COMPILESTRING_EMPTY_DETAILS = You must enter a command string for this compile command. This is what is run when this compile command is selected. - -MSG_VALIDATE_COMPILESTRING_NOTVALID = Compile command string "{0}" is not valid -MSG_VALIDATE_COMPILESTRING_NOTVALID_DETAILS = The given string is not a valid command. - -MSG_UDA_LOAD_ERROR = Error occurred while loading the user-defined action information from file: {0} - -MSG_UDA_ROOTTAG_ERROR = The xml file ''{0}'' appears to be corrupted. It has been replaced -MSG_UDA_ROOTTAG_ERROR_DETAILS=Expected root tag to be named ''{0}''. The corrupted file has been renamed to ''{1}'' and a new file created for you - -MSG_CONFIRM_DELETE_USERACTION = Delete selected user actions? -MSG_CONFIRM_DELETE_USERACTION_DETAILS=This is a permanent deletion of the selected actions and cannot be undone.Select Yes to delete and No to cancel the delete action - -MSG_CONFIRM_DELETE_USERTYPE = Delete selected types? -MSG_CONFIRM_DELETE_USERTYPE_DETAILS =This is a permanent deletion of the selected types and cannot be undone.Select Yes to delete and No to cancel the delete action - - -
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/api/files/compile/ISystemCompileManagerAdapter.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/api/files/compile/ISystemCompileManagerAdapter.java deleted file mode 100644 index c67f6a270..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/api/files/compile/ISystemCompileManagerAdapter.java +++ /dev/null @@ -1,28 +0,0 @@ -/********************************************************************************* - * Copyright (c) 2008 IBM Corporation. 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: - * Xuan Chen (IBM) - [222470] initial contribution. - *********************************************************************************/ -package org.eclipse.rse.internal.useractions.api.files.compile; - -import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; -import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileManager; - -/** - * Compile Manager Adapter Interface. - * <p> - * <strong>EXPERIMENTAL</strong>. This class or interface has been added as part - * of a work in progress. There is no guarantee that this API will work or that - * it will remain the same. Please do not use this API without consulting with - * the <a href="http://www.eclipse.org/dsdp/tm/">Target Management</a> team. - * </p> - */ -public interface ISystemCompileManagerAdapter { - - public SystemCompileManager getSystemCompileManager(ISubSystemConfiguration ssc); - -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/api/files/compile/UniversalCompileManagerAdapter.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/api/files/compile/UniversalCompileManagerAdapter.java deleted file mode 100644 index b99e453ba..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/api/files/compile/UniversalCompileManagerAdapter.java +++ /dev/null @@ -1,45 +0,0 @@ -/********************************************************************************* - * Copyright (c) 2008 IBM Corporation. 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: - * Xuan Chen (IBM) - [222470] initial contribution. - *********************************************************************************/ -package org.eclipse.rse.internal.useractions.api.files.compile; - -import java.util.HashMap; - -import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; -import org.eclipse.rse.internal.useractions.files.compile.UniversalCompileManager; -import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileManager; - -/** - * Universal Compile Manager Adapter. - * <p> - * <strong>EXPERIMENTAL</strong>. This class or interface has been added as part - * of a work in progress. There is no guarantee that this API will work or that - * it will remain the same. Please do not use this API without consulting with - * the <a href="http://www.eclipse.org/dsdp/tm/">Target Management</a> team. - * </p> - */ -public class UniversalCompileManagerAdapter implements - ISystemCompileManagerAdapter { - private HashMap compileManagers = new HashMap(); - - public SystemCompileManager getSystemCompileManager(ISubSystemConfiguration ssc) { - String configID = ssc.getId(); - - SystemCompileManager thisCompileManager = (SystemCompileManager)compileManagers.get(configID); - if (thisCompileManager == null) - { - thisCompileManager = new UniversalCompileManager(); - thisCompileManager.setSubSystemFactory(ssc); - compileManagers.put(configID, thisCompileManager); - } - - return thisCompileManager; - } - -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/api/files/uda/ISystemUDActionSubsystemAdapter.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/api/files/uda/ISystemUDActionSubsystemAdapter.java deleted file mode 100644 index 9cc1d36ca..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/api/files/uda/ISystemUDActionSubsystemAdapter.java +++ /dev/null @@ -1,29 +0,0 @@ -/********************************************************************************* - * Copyright (c) 2008 IBM Corporation. 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: - * Xuan Chen (IBM) - [222470] initial contribution. - *********************************************************************************/ -package org.eclipse.rse.internal.useractions.api.files.uda; - -import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDActionSubsystem; - - -/** - * User-defined Action Subsystem Adapter Interface. - * <p> - * <strong>EXPERIMENTAL</strong>. This class or interface has been added as part - * of a work in progress. There is no guarantee that this API will work or that - * it will remain the same. Please do not use this API without consulting with - * the <a href="http://www.eclipse.org/dsdp/tm/">Target Management</a> team. - * </p> - */ -public interface ISystemUDActionSubsystemAdapter { - - public SystemUDActionSubsystem getSystemUDActionSubsystem(ISubSystemConfiguration ssc); - -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/api/files/uda/UniversalSystemUDActionSubsystemAdapter.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/api/files/uda/UniversalSystemUDActionSubsystemAdapter.java deleted file mode 100644 index 12247ee1a..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/api/files/uda/UniversalSystemUDActionSubsystemAdapter.java +++ /dev/null @@ -1,44 +0,0 @@ -/********************************************************************************* - * Copyright (c) 2008 IBM Corporation. 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: - * Xuan Chen (IBM) - [222470] initial contribution. - *********************************************************************************/ -package org.eclipse.rse.internal.useractions.api.files.uda; - -import java.util.HashMap; - -import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; -import org.eclipse.rse.internal.useractions.files.uda.UDActionSubsystemUniversalFiles; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDActionSubsystem; - -/** - * Universal User-defined Action Subsystem Adapter. - * <p> - * <strong>EXPERIMENTAL</strong>. This class or interface has been added as part - * of a work in progress. There is no guarantee that this API will work or that - * it will remain the same. Please do not use this API without consulting with - * the <a href="http://www.eclipse.org/dsdp/tm/">Target Management</a> team. - * </p> - */ -public class UniversalSystemUDActionSubsystemAdapter implements ISystemUDActionSubsystemAdapter { - private HashMap uDActionSubsystems = new HashMap(); - - public SystemUDActionSubsystem getSystemUDActionSubsystem(ISubSystemConfiguration ssc) { - String configID = ssc.getId(); - - SystemUDActionSubsystem thisuDActionSubsystem = (SystemUDActionSubsystem)uDActionSubsystems.get(configID); - if (thisuDActionSubsystem == null) - { - thisuDActionSubsystem = new UDActionSubsystemUniversalFiles(); - thisuDActionSubsystem.setSubSystemFactory(ssc); - uDActionSubsystems.put(configID, thisuDActionSubsystem); - } - - return thisuDActionSubsystem; - } - -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/api/ui/compile/SystemCascadingCompileAction.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/api/ui/compile/SystemCascadingCompileAction.java deleted file mode 100644 index 5503bde0d..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/api/ui/compile/SystemCascadingCompileAction.java +++ /dev/null @@ -1,100 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry - *******************************************************************************/ -package org.eclipse.rse.internal.useractions.api.ui.compile; - -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.rse.core.RSECorePlugin; -import org.eclipse.rse.core.model.ISystemProfile; -import org.eclipse.rse.internal.useractions.UserActionsResources; -import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileCascadeByProfileAction; -import org.eclipse.rse.ui.ISystemContextMenuConstants; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.SystemPreferencesManager; -import org.eclipse.rse.ui.actions.SystemBaseAction; -import org.eclipse.rse.ui.actions.SystemBaseSubMenuAction; -import org.eclipse.swt.widgets.Shell; - -/** - * Cascading Compile-> menu for remote compilable resources. - * <p> - * <strong>EXPERIMENTAL</strong>. This class or interface has been added as part - * of a work in progress. There is no guarantee that this API will work or that - * it will remain the same. Please do not use this API without consulting with - * the <a href="http://www.eclipse.org/dsdp/tm/">Target Management</a> team. - * </p> - */ -public class SystemCascadingCompileAction extends SystemBaseSubMenuAction implements IMenuListener { - private boolean isPrompt; - - /** - * Constructor for SystemCascadingCompileAction - */ - public SystemCascadingCompileAction(Shell shell, boolean isPrompt) { - super(isPrompt ? UserActionsResources.ACTION_COMPILE_PROMPT_LABEL : UserActionsResources.ACTION_COMPILE_NOPROMPT_LABEL, isPrompt ? UserActionsResources.ACTION_COMPILE_PROMPT_TOOLTIP - : UserActionsResources.ACTION_COMPILE_NOPROMPT_TOOLTIP, (ImageDescriptor) null, shell); - this.isPrompt = isPrompt; - allowOnMultipleSelection(false); - setMenuID(ISystemContextMenuConstants.MENU_COMPILE); - setCreateMenuEachTime(false); - setPopulateMenuEachTime(true); - //setTest(true); - if (isPrompt) - setHelp(RSEUIPlugin.HELPPREFIX + "ccpa0000"); //$NON-NLS-1$ - else - setHelp(RSEUIPlugin.HELPPREFIX + "ccna0000"); //$NON-NLS-1$ - } - - /** - * @see SystemBaseSubMenuAction#getSubMenu() - */ - public IMenuManager populateSubMenu(IMenuManager ourSubMenu) { - ourSubMenu.addMenuListener(this); - ourSubMenu.setRemoveAllWhenShown(true); - //menu.setEnabled(true); - ourSubMenu.add(new SystemBaseAction("dummy", null)); //$NON-NLS-1$ - return ourSubMenu; - } - - /** - * Called when submenu is about to show - */ - public void menuAboutToShow(IMenuManager ourSubMenu) { - //System.out.println("Inside menuAboutToShow for SystemCascadingCompileAction"); - Object firstSelection = getFirstSelection(); - if (firstSelection == null) { - System.out.println("Hmm, selection is null! "); //$NON-NLS-1$ - ourSubMenu.add(new SystemBaseAction("Programming error. Selection is null! ", null)); //$NON-NLS-1$ - return; - } - // is cascading-by-profile preference turned on? - if (SystemPreferencesManager.getCascadeUserActions()) { - ISystemProfile[] activeProfiles = RSECorePlugin.getTheSystemRegistry().getActiveSystemProfiles(); - for (int idx = 0; idx < activeProfiles.length; idx++) { - SystemBaseSubMenuAction profileAction = new SystemCompileCascadeByProfileAction(getShell(), firstSelection, activeProfiles[idx], isPrompt); - ourSubMenu.add(profileAction.getSubMenu()); - } - } - // else concatenate all the compile commands from all the active profiles... - else { - ISystemProfile[] activeProfiles = RSECorePlugin.getTheSystemRegistry().getActiveSystemProfiles(); - for (int idx = 0; idx < activeProfiles.length; idx++) - SystemCompileCascadeByProfileAction.populateMenuWithCompileActions(ourSubMenu, getShell(), activeProfiles[idx], firstSelection, isPrompt); - } - // add a separator before Work With Compile Commands... menu item - ourSubMenu.add(new Separator()); - // add Work With Commands... action - ourSubMenu.add(new SystemWorkWithCompileCommandsAction(getShell(), true)); - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/api/ui/compile/SystemCompileAction.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/api/ui/compile/SystemCompileAction.java deleted file mode 100644 index 35c5b82df..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/api/ui/compile/SystemCompileAction.java +++ /dev/null @@ -1,205 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - * Martin Oberhuber (Wind River) - [168870] refactor org.eclipse.rse.core package of the UI plugin - * David Dykstal (IBM) - [186589] move user actions API out of org.eclipse.rse.ui - * David McKnight (IBM) - [225506] [api][breaking] RSE UI leaks non-API types - * Kevin Doyle (IBM) - [252707] Everytime a Compile command is selected a saving profile job is performed - *******************************************************************************/ -package org.eclipse.rse.internal.useractions.api.ui.compile; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.rse.internal.useractions.Activator; -import org.eclipse.rse.internal.useractions.IUserActionsImageIds; -import org.eclipse.rse.internal.useractions.ui.compile.SystemCompilableSource; -import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileCommand; -import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileManager; -import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileType; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.actions.SystemBaseAction; -import org.eclipse.rse.ui.view.ISystemEditableRemoteObject; -import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter; -import org.eclipse.rse.ui.view.SystemAdapterHelpers; -import org.eclipse.rse.ui.view.SystemTableViewProvider; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.dialogs.ListSelectionDialog; -import org.eclipse.ui.model.AdaptableList; -import org.eclipse.ui.model.WorkbenchContentProvider; - -/** - * This is the action for an individual compile command, either prompted or not - * prompted. The label for the action is simply the compile command's label. If - * promptable, then "..." is appended. - * <p> - * <strong>EXPERIMENTAL</strong>. This class or interface has been added as part - * of a work in progress. There is no guarantee that this API will work or that - * it will remain the same. Please do not use this API without consulting with - * the <a href="http://www.eclipse.org/dsdp/tm/">Target Management</a> team. - * </p> - */ -public class SystemCompileAction extends SystemBaseAction { - private SystemCompileCommand compileCmd; - private boolean isPrompt; - - /** - * Constructor - */ - public SystemCompileAction(Shell shell, SystemCompileCommand compileCommand, boolean isPrompt) { - super( - isPrompt ? compileCommand.getLabel() + "..." : compileCommand.getLabel(), compileCommand.getLabel(), Activator.getDefault().getImageDescriptor(IUserActionsImageIds.COMPILE_1), shell); // null == image //$NON-NLS-1$ - this.compileCmd = compileCommand; - this.isPrompt = isPrompt; - SystemCompileManager mgr = compileCommand.getParentType().getParentProfile().getParentManager(); - allowOnMultipleSelection(mgr.isMultiSelectSupported(compileCommand)); - if (isPrompt) - setHelp(RSEUIPlugin.HELPPREFIX + "scpa0000"); //$NON-NLS-1$ - else - setHelp(RSEUIPlugin.HELPPREFIX + "scna0000"); //$NON-NLS-1$ - SystemCompileCommand lucc = compileCmd.getParentType().getLastUsedCompileCommand(); - if ((lucc != null) && lucc.getLabel().equals(compileCmd.getLabel())) { - setChecked(true); - // if (!isPrompt) - // setAccelerator(SWT.CTRL | SWT.SHIFT | 'c'); - } else - setChecked(false); - } - - /** - * Intercept of parent method that is our first opportunity to enable/disable this action, typically - * by interrogating the current selection, retrievable via getSelection. - * <p> - * For this compile action, we disable if we are not currently connected. - */ - public boolean updateSelection(IStructuredSelection selection) { - boolean enable = true; - Object selected = getFirstSelection(); - if (selected == null) return false; - ISystemRemoteElementAdapter rmtAdapter = SystemAdapterHelpers.getRemoteAdapter(selected); - if (rmtAdapter == null) enable = false; - // yantzi:artemis6.0, we need to allow the menu item to show up even if disconnected in order - // to allow customers to restore the tree view from cache on startup and still have all actions - // available. It is up to the subsystme to make sure to connect if required when the compile - // command is run - //else - // enable = rmtAdapter.getSubSystem(selected).isConnected(); - if (!enable) return false; - SystemCompileManager mgr = compileCmd.getParentType().getParentProfile().getParentManager(); - while (enable && (selected != null)) { - enable = mgr.isCompilable(selected); - selected = getNextSelection(); - } - return enable; - } - - /** - * Intercept of parent method that is our opportunity to enable/disable this action, typically - * by interrogating the current selection, retrievable via getSelection. - * <p> - * For this compile action, we disable if we are not currently connected. - */ - public boolean checkObjectType(Object selectedObject) { - ISystemRemoteElementAdapter rmtAdapter = SystemAdapterHelpers.getRemoteAdapter(selectedObject); - if (rmtAdapter == null) - return false; - else - return rmtAdapter.getSubSystem(selectedObject).isConnected(); - } - - /** - * Called by eclipse when the user selects this action. Does the actual running of the action. - */ - public void run() { - if (checkDirtyEditors()) { - Object element = getFirstSelection(); - boolean ok = true; - while (ok && (element != null)) { - SystemCompileType compType = compileCmd.getParentType(); - if (!compileCmd.equals(compType.getLastUsedCompileCommand())) { - compType.setLastUsedCompileCommand(compileCmd); - compType.getParentProfile().writeToDisk(); - } - SystemCompilableSource compilableSrc = compType.getParentProfile().getCompilableSourceObject(getShell(), element, compileCmd, isPrompt, viewer); - ok = compilableSrc.runCompileCommand(); - if (ok) element = getNextSelection(); - } - } - } - - protected List getDirtyEditors() { - IStructuredSelection sel = getSelection(); - List selection = sel.toList(); - List dirtyEditors = new ArrayList(); - for (int i = 0; i < selection.size(); i++) { - Object selected = selection.get(i); - if (selected instanceof IAdaptable) { - ISystemEditableRemoteObject editable = getEditableFor((IAdaptable) selected); - if (editable != null) { - try { - // is the file being edited? - if (editable.checkOpenInEditor() == 0) { - // reference the editing editor - editable.openEditor(); - // file is open in editor - prompt for save - if (editable.isDirty()) { - dirtyEditors.add(editable); - } - } - } catch (Exception e) { - } - } - } - } - return dirtyEditors; - } - - protected ISystemEditableRemoteObject getEditableFor(IAdaptable selected) { - ISystemRemoteElementAdapter adapter = (ISystemRemoteElementAdapter) selected.getAdapter(ISystemRemoteElementAdapter.class); - if (adapter.canEdit(selected)) { - ISystemEditableRemoteObject editable = adapter.getEditableRemoteObject(selected); - try { - editable.setLocalResourceProperties(); - } catch (Exception e) { - } - return editable; - } - return null; - } - - protected boolean checkDirtyEditors() { - List dirtyEditors = getDirtyEditors(); - if (dirtyEditors.size() > 0) { - AdaptableList input = new AdaptableList(); - for (int i = 0; i < dirtyEditors.size(); i++) { - ISystemEditableRemoteObject rmtObj = (ISystemEditableRemoteObject) dirtyEditors.get(i); - input.add(rmtObj.getRemoteObject()); - } - WorkbenchContentProvider cprovider = new WorkbenchContentProvider(); - SystemTableViewProvider lprovider = new SystemTableViewProvider(null); - ListSelectionDialog dlg = new ListSelectionDialog(getShell(), input, cprovider, lprovider, SystemUDAResources.EditorManager_saveResourcesMessage); - dlg.setInitialSelections(input.getChildren()); - dlg.setTitle(SystemUDAResources.EditorManager_saveResourcesTitle); - int result = dlg.open(); - //Just return false to prevent the operation continuing - if (result == IDialogConstants.CANCEL_ID) return false; - Object[] filesToSave = dlg.getResult(); - for (int s = 0; s < filesToSave.length; s++) { - IAdaptable rmtObj = (IAdaptable) filesToSave[s]; - ISystemEditableRemoteObject editable = getEditableFor(rmtObj); - editable.doImmediateSaveAndUpload(); - } - } - return true; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/api/ui/compile/SystemDynamicCompileMenu.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/api/ui/compile/SystemDynamicCompileMenu.java deleted file mode 100644 index ae4e5582f..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/api/ui/compile/SystemDynamicCompileMenu.java +++ /dev/null @@ -1,155 +0,0 @@ -/********************************************************************************* - * Copyright (c) 2008 IBM Corporation. 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: - * Xuan Chen (IBM) - [222470] initial contribution. - * Kevin Doyle (IBM) - [239805] User Action/Compile menu's shouldn't be tied to IRemoteFile - *********************************************************************************/ -package org.eclipse.rse.internal.useractions.api.ui.compile; - -import java.util.ArrayList; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.ActionContributionItem; -import org.eclipse.jface.action.IContributionItem; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.rse.core.RSECorePlugin; -import org.eclipse.rse.core.model.ISystemProfile; -import org.eclipse.rse.core.subsystems.ISubSystem; -import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; -import org.eclipse.rse.internal.useractions.api.files.compile.ISystemCompileManagerAdapter; -import org.eclipse.rse.internal.useractions.files.compile.UniversalCompileManager; -import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileCommand; -import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileManager; -import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileProfile; -import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileType; -import org.eclipse.rse.ui.SystemBasePlugin; -import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter; -import org.eclipse.rse.ui.view.SystemAdapterHelpers; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.CompoundContributionItem; - -/** - * Dynamic Compile Menu. - * <p> - * <strong>EXPERIMENTAL</strong>. This class or interface has been added as part - * of a work in progress. There is no guarantee that this API will work or that - * it will remain the same. Please do not use this API without consulting with - * the <a href="http://www.eclipse.org/dsdp/tm/">Target Management</a> team. - * </p> - */ -public class SystemDynamicCompileMenu extends CompoundContributionItem -{ - private class TestContribution extends ActionContributionItem { - - public TestContribution(Action action) - { - super(action); - } - - /* - public void fill(Menu menu, int index) - { - - MenuItem menuItem = new MenuItem(menu, SWT.RADIO); - menuItem.setText("My First Contribution"); - } - */ - } - - protected IContributionItem[] getContributionItems() { - - ArrayList returnedItemList = new ArrayList(); - - ISystemProfile[] activeProfiles = RSECorePlugin.getTheSystemRegistry().getActiveSystemProfiles(); - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - ISelection selection = window.getSelectionService().getSelection(); - Object firstSelection = ((IStructuredSelection) selection).getFirstElement(); - if (firstSelection == null) - { - return new IContributionItem[0]; - } - Shell shell = SystemBasePlugin.getActiveWorkbenchShell(); - - ISystemRemoteElementAdapter rmtAdapter = SystemAdapterHelpers.getRemoteAdapter(firstSelection); - ISubSystem subsystem = rmtAdapter.getSubSystem(firstSelection); - ISubSystemConfiguration ssc = subsystem.getSubSystemConfiguration(); - - SystemCompileManager compileManager = null; - - if (firstSelection instanceof IAdaptable) { - ISystemCompileManagerAdapter adapter = (ISystemCompileManagerAdapter)((IAdaptable)firstSelection).getAdapter(ISystemCompileManagerAdapter.class); - if (null != adapter) - { - compileManager = adapter.getSystemCompileManager(ssc); - } - } - - if (null == compileManager) - { - compileManager = new UniversalCompileManager(); - compileManager.setSubSystemFactory(ssc); - } - - for (int idx = 0; idx < activeProfiles.length; idx++) - { - String srcType = null; - if (rmtAdapter != null) { - srcType = rmtAdapter.getRemoteSourceType(firstSelection); - if (srcType == null) - srcType = "null"; //$NON-NLS-1$ - else if (srcType.equals("")) //$NON-NLS-1$ - srcType = "blank"; //$NON-NLS-1$ - } - - if (null != compileManager) - { - SystemCompileManager thisCompileManager = compileManager; - SystemCompileProfile compileProfile = thisCompileManager.getCompileProfile(activeProfiles[idx]); - // compileProfile.addContributions(firstSelection); - SystemCompileType compileType = compileProfile.getCompileType(srcType); - - if (compileType != null) - { - SystemCompileCommand[] cmds = compileType.getCompileCommandsArray(); - for (int idx2=0; idx2<cmds.length; idx2++) - { - SystemCompileAction action = new SystemCompileAction(shell, cmds[idx2], true); - action.setSelection(selection); - TestContribution testContribution = new TestContribution(action); - returnedItemList.add(testContribution); - //ourSubMenu.add(action); - } - } - } - - } - - // add a separator before Work With Compile Commands... menu item - //ourSubMenu.add(new Separator()); - // add Work With Commands... action - if (returnedItemList.size() > 0) - returnedItemList.add(new Separator()); - - // Here's where you would dynamically generate your list - SystemWorkWithCompileCommandsAction workWithCompileCommandAction = new SystemWorkWithCompileCommandsAction(shell, true, subsystem, compileManager); - workWithCompileCommandAction.setSelection(selection); - TestContribution testContribution = new TestContribution(workWithCompileCommandAction); - returnedItemList.add(testContribution); - IContributionItem[] list = (IContributionItem[])returnedItemList.toArray(new IContributionItem[]{}); - //String[] array = (String[])arrayList.toArray(new String[]{}); - //SystemCascadingCompileAction promptAction = new SystemCascadingCompileAction(null, true); - //list[0] = new TestContribution(/*promptAction*/); - - return list; - } - -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/api/ui/compile/SystemWorkWithCompileCommandsAction.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/api/ui/compile/SystemWorkWithCompileCommandsAction.java deleted file mode 100644 index c8b7c1996..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/api/ui/compile/SystemWorkWithCompileCommandsAction.java +++ /dev/null @@ -1,195 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - * Martin Oberhuber (Wind River) - [168870] refactor org.eclipse.rse.core package of the UI plugin - * David Dykstal (IBM) - [186589] move user types, user actions, and compile commands - * API to the user actions plugin - * Xuan Chen (IBM) - [225617] [useraction][api] Remove Team view support inside user action. - * Kevin Doyle (IBM) - [222828] Icons for some Actions Missing - * Kevin Doyle (IBM) - [239908] Need to set the connection in compile manager for Work with Compile Commands Action - *******************************************************************************/ -package org.eclipse.rse.internal.useractions.api.ui.compile; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.rse.core.model.ISystemProfile; -import org.eclipse.rse.core.subsystems.ISubSystem; -import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; -import org.eclipse.rse.internal.useractions.Activator; -import org.eclipse.rse.internal.useractions.IUserActionsImageIds; -import org.eclipse.rse.internal.useractions.api.files.compile.ISystemCompileManagerAdapter; -import org.eclipse.rse.internal.useractions.files.compile.UniversalCompileManager; -import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileManager; -import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileProfile; -import org.eclipse.rse.internal.useractions.ui.compile.SystemWorkWithCompileCommandsDialog; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources; -import org.eclipse.rse.ui.ISystemContextMenuConstants; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.actions.SystemBaseDialogAction; -import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter; -import org.eclipse.rse.ui.view.SystemAdapterHelpers; -import org.eclipse.swt.widgets.Shell; - -/** - * The action that displays the Work With -> Compile Commands menu item - * <p> - * <strong>EXPERIMENTAL</strong>. This class or interface has been added as part - * of a work in progress. There is no guarantee that this API will work or that - * it will remain the same. Please do not use this API without consulting with - * the <a href="http://www.eclipse.org/dsdp/tm/">Target Management</a> team. - * </p> - */ -public class SystemWorkWithCompileCommandsAction extends SystemBaseDialogAction { - - private ISubSystem subsystem = null; - private ISubSystemConfiguration subsystemFactory = null; - private ISystemProfile profile = null; - private SystemCompileManager compileManager = null; - - /** - * Constructor - * @param shell The Shell of the parent UI for this dialog - * @param fromCascadingCompileAction true to get "Work with Compile Commands" label, false to get "Compile Commands" label. - */ - public SystemWorkWithCompileCommandsAction(Shell shell, boolean fromCascadingCompileAction) { - super(fromCascadingCompileAction ? SystemUDAResources.ACTION_WORKWITH_WWCOMPILE_CMDS_LABEL : SystemUDAResources.ACTION_WORKWITH_COMPILE_CMDS_LABEL, - fromCascadingCompileAction ? SystemUDAResources.ACTION_WORKWITH_WWCOMPILE_CMDS_TOOLTIP : SystemUDAResources.ACTION_WORKWITH_COMPILE_CMDS_TOOLTIP, Activator.getDefault() - .getImageDescriptor(IUserActionsImageIds.WORK_WITH_COMPILE_COMMANDS_1), shell); - allowOnMultipleSelection(false); - if (!fromCascadingCompileAction) - setContextMenuGroup(ISystemContextMenuConstants.GROUP_WORKWITH); - else - setContextMenuGroup(ISystemContextMenuConstants.GROUP_REORGANIZE); - setHelp(RSEUIPlugin.HELPPREFIX + "actnwwcc"); //$NON-NLS-1$ - setAvailableOffline(true); - } - - public SystemWorkWithCompileCommandsAction(Shell shell, boolean fromCascadingCompileAction, ISubSystem subSystem, SystemCompileManager compileManager) - { - this(shell, fromCascadingCompileAction); - this.subsystem = subSystem; - this.compileManager = compileManager; - if (null != subSystem) - { - subsystemFactory = subsystem.getSubSystemConfiguration(); - profile = subSystem.getSystemProfile(); - } - - } - - /** - * Reset between runs - */ - public void reset() { - // nothing to do as we have no instance vars. - } - - /** - * Called by SystemBaseAction when selection is set. - * Our opportunity to verify we are allowed for this selected type. - */ - public boolean updateSelection(IStructuredSelection selection) { - return true; - } - - /** - * If you decide to use the supplied run method as is, - * then you must override this method to create and return - * the dialog that is displayed by the default run method - * implementation. - * <p> - * If you override run with your own, then - * simply implement this to return null as it won't be used. - * @see #run() - */ - protected Dialog createDialog(Shell shell) { - Object inputObject = getFirstSelection(); - boolean caseSensitive = false; - if (null == subsystem) - { - if (inputObject instanceof ISubSystem) - subsystem = (ISubSystem) inputObject; - //Don't think we need to support invoking this diaglog from Team view. - /* - else if (inputObject instanceof SystemTeamViewCompileTypeNode) { - SystemTeamViewCompileTypeNode typeNode = ((SystemTeamViewCompileTypeNode) inputObject); - subsystemFactory = typeNode.getParentSubSystemFactory().getSubSystemConfiguration(); - profile = typeNode.getProfile(); - } else if (inputObject instanceof SystemTeamViewSubSystemConfigurationNode) { - subsystemFactory = ((SystemTeamViewSubSystemConfigurationNode) inputObject).getSubSystemConfiguration(); - profile = ((SystemTeamViewSubSystemConfigurationNode) inputObject).getProfile(); - } - */ - else { - ISystemRemoteElementAdapter rmtAdapter = SystemAdapterHelpers.getRemoteAdapter(inputObject); - if (rmtAdapter != null) subsystem = rmtAdapter.getSubSystem(inputObject); - } - } - SystemCompileProfile currProfile = null; - SystemCompileProfile[] currProfiles = null; - - if (subsystem != null) { - if (subsystemFactory == null) subsystemFactory = subsystem.getSubSystemConfiguration(); - if (profile == null) profile = subsystem.getSystemProfile(); - } - - if (null == compileManager) - { - if (inputObject instanceof IAdaptable) { - ISystemCompileManagerAdapter adapter = (ISystemCompileManagerAdapter)((IAdaptable)inputObject).getAdapter(ISystemCompileManagerAdapter.class); - if (null != adapter) - { - compileManager = adapter.getSystemCompileManager(subsystemFactory); - } - } - } - - if (null == compileManager) - { - compileManager = new UniversalCompileManager(); - compileManager.setSubSystemFactory(subsystemFactory); - } - - if (null != compileManager) - { - if (profile != null) - { - currProfile = compileManager.getCompileProfile(profile); - currProfiles = compileManager.getAllCompileProfiles(); - } - - if (subsystem != null) { - compileManager.setSystemConnection(subsystem.getHost()); - } - - caseSensitive = subsystemFactory.isCaseSensitive(); - - SystemWorkWithCompileCommandsDialog dlg = new SystemWorkWithCompileCommandsDialog(shell, compileManager, currProfile); - /* FIXME - currProfiles cannot be null since above stuff was commented out - if (currProfiles != null) { - dlg.setProfiles(currProfiles); - } - */ - dlg.setProfiles(currProfiles); - dlg.setCaseSensitive(caseSensitive); - - return dlg; - } - return null; - } - - /** - * Required by parent. We use it to return the new name. - * In our case, we don't need it, so we return null. - */ - protected Object getDialogValue(Dialog dlg) { - return null; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/api/ui/uda/SystemDynamicUserActionMenu.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/api/ui/uda/SystemDynamicUserActionMenu.java deleted file mode 100644 index 4d801352b..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/api/ui/uda/SystemDynamicUserActionMenu.java +++ /dev/null @@ -1,141 +0,0 @@ -/********************************************************************************* - * Copyright (c) 2008 IBM Corporation. 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: - * Xuan Chen (IBM) - [222470] initial contribution. - * Kevin Doyle (IBM) - [239805] User Action/Compile menu's shouldn't be tied to IRemoteFile - * Kevin Doyle (IBM) - [253037] ClassCastException in SystemDynamicUserActionMenu - *********************************************************************************/ -package org.eclipse.rse.internal.useractions.api.ui.uda; - -import java.util.ArrayList; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.ActionContributionItem; -import org.eclipse.jface.action.IContributionItem; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.rse.core.RSECorePlugin; -import org.eclipse.rse.core.model.ISystemProfile; -import org.eclipse.rse.core.subsystems.ISubSystem; -import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; -import org.eclipse.rse.internal.useractions.api.files.uda.ISystemUDActionSubsystemAdapter; -import org.eclipse.rse.internal.useractions.files.uda.UDActionSubsystemUniversalFiles; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDActionSubsystem; -import org.eclipse.rse.internal.useractions.ui.uda.actions.SystemWorkWithUDAsAction; -import org.eclipse.rse.ui.SystemBasePlugin; -import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter; -import org.eclipse.rse.ui.view.SystemAdapterHelpers; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.CompoundContributionItem; - -/** - * Dynamic User-defined Action Menu. - * <p> - * <strong>EXPERIMENTAL</strong>. This class or interface has been added as part - * of a work in progress. There is no guarantee that this API will work or that - * it will remain the same. Please do not use this API without consulting with - * the <a href="http://www.eclipse.org/dsdp/tm/">Target Management</a> team. - * </p> - */ -public class SystemDynamicUserActionMenu extends CompoundContributionItem -{ - private class UserActionContribution extends ActionContributionItem { - - public UserActionContribution(Action action) - { - super(action); - } - - /* - public void fill(Menu menu, int index) - { - - MenuItem menuItem = new MenuItem(menu, SWT.RADIO); - menuItem.setText("My First Contribution"); - } - */ - } - - protected IContributionItem[] getContributionItems() { - - ArrayList returnedItemList = new ArrayList(); - - ISystemProfile[] activeProfiles = RSECorePlugin.getTheSystemRegistry().getActiveSystemProfiles(); - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - ISelection selection = window.getSelectionService().getSelection(); - Object firstSelection = null; - if (selection instanceof IStructuredSelection) - firstSelection = ((IStructuredSelection) selection).getFirstElement(); - if (firstSelection == null) - { - return new IContributionItem[0]; - } - ISystemRemoteElementAdapter rmtAdapter = SystemAdapterHelpers.getRemoteAdapter(firstSelection); - - ISubSystem subsystem = rmtAdapter.getSubSystem(firstSelection); - ISubSystemConfiguration ssc = subsystem.getSubSystemConfiguration(); - - SystemUDActionSubsystem systemUDActionSubsystem = null; - - if (firstSelection instanceof IAdaptable) { - ISystemUDActionSubsystemAdapter adapter = (ISystemUDActionSubsystemAdapter)((IAdaptable)firstSelection).getAdapter(ISystemUDActionSubsystemAdapter.class); - if (null != adapter) - { - systemUDActionSubsystem = adapter.getSystemUDActionSubsystem(ssc); - systemUDActionSubsystem.setSubsystem(subsystem); - } - } - - if (null == systemUDActionSubsystem) - { - systemUDActionSubsystem = new UDActionSubsystemUniversalFiles(); - systemUDActionSubsystem.setSubSystemFactory(ssc); - systemUDActionSubsystem.setSubsystem(subsystem); - } - - Shell shell = SystemBasePlugin.getActiveWorkbenchShell(); - for (int idx = 0; idx < activeProfiles.length; idx++) - { - //Xuan: the code for systemUDActionSubsystem#addUserActions go here... - // systemUDActionSubsystem.addUserActions(menu, (IStructuredSelection)selection, profi, shell); - if (null != systemUDActionSubsystem) - { - Action[] list = systemUDActionSubsystem.addUserActions(null, (IStructuredSelection)selection, activeProfiles[idx], shell); - - for (int i = 0; i < list.length; i++) - { - UserActionContribution testContribution = new UserActionContribution(list[i]); - returnedItemList.add(testContribution); - } - } - } - - // add a separator before Work With Compile Commands... menu item - //ourSubMenu.add(new Separator()); - // add Work With Commands... action - if (returnedItemList.size() > 0) - returnedItemList.add(new Separator()); - - SystemWorkWithUDAsAction wwAction; - wwAction = new SystemWorkWithUDAsAction(shell, systemUDActionSubsystem.getSubsystem(), systemUDActionSubsystem); - wwAction.setText(SystemUDAResources.RESID_WORKWITH_UDAS_ACTION_LABEL); - wwAction.setToolTipText(SystemUDAResources.RESID_WORKWITH_UDAS_ACTION_TOOLTIP); - wwAction.allowOnMultipleSelection(true); - wwAction.setSelection(selection); - UserActionContribution userActionContribution = new UserActionContribution(wwAction); - returnedItemList.add(userActionContribution); - - IContributionItem[] list = (IContributionItem[])returnedItemList.toArray(new IContributionItem[]{}); - return list; - } - -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/LocalCompileManager.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/LocalCompileManager.java deleted file mode 100644 index 3017d0dda..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/LocalCompileManager.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 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.files.compile; - -import org.eclipse.rse.core.model.ISystemProfile; -import org.eclipse.rse.internal.useractions.ui.SystemCmdSubstVarList; -import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileProfile; - -/** - * Specialization of the compile manager for universal files, for local files. - */ -public class LocalCompileManager extends UniversalCompileManager { - /** - * Constructor for LocalCompileManager. - */ - public LocalCompileManager() { - super(); - } - - /** - * Overridable method to instantiate the SystemCompileProfile for the - * given system profile. - * <p> - * We return an instance of LocalCompileProfile - */ - protected SystemCompileProfile createCompileProfile(ISystemProfile profile) { - return new LocalCompileProfile(this, profile.getName()); - } - - /** - * For support of the Work With Compile Commands dialog. - * <p> - * Return the substitution variables supported by compile commands managed by this manager. - */ - public SystemCmdSubstVarList getSubstitutionVariableList() { - return UniversalCompileSubstList.getInstance(); - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/LocalCompileProfile.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/LocalCompileProfile.java deleted file mode 100644 index 4d4ed838a..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/LocalCompileProfile.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2008 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.files.compile; - -import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileManager; - -/** - * Specialization of the compile profile class, uniquely for the compile support of files from - * the local file subsystem. - */ -public class LocalCompileProfile extends UniversalCompileProfile { - /** - * Constructor - * @param manager SystemCompileManager of this compile file - * @param profileName System profile name - */ - public LocalCompileProfile(SystemCompileManager manager, String profileName) { - super(manager, profileName); - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/UniversalCompilableSource.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/UniversalCompilableSource.java deleted file mode 100644 index 73cd4d583..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/UniversalCompilableSource.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2008 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.files.compile; - -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.rse.internal.useractions.ui.compile.SystemCompilableSource; -import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileCommand; -import org.eclipse.rse.shells.ui.RemoteCommandHelpers; -import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; -import org.eclipse.swt.widgets.Shell; - -/** - * This encapsulates a file in a universal file system, which is to be compiled. - */ -public class UniversalCompilableSource extends SystemCompilableSource { - /** - * Constructor for UniversalCompilableSource. - * @param shell - the shell to use if need to prompt - * @param firstSelection - the selected compilable source member - * @param compileCmd - the Compile Command that is to be run against the selected compilable source member - * @param isPrompt - true if the user choose the flavor of the action to prompt the compile command - * @param viewer - the viewer that originated the compile action - */ - public UniversalCompilableSource(Shell shell, Object firstSelection, SystemCompileCommand compileCmd, boolean isPrompt, Viewer viewer) { - super(shell, firstSelection, compileCmd, isPrompt, viewer); - } - - /** - * After the substituting and the prompting, it is now time to the remote running of the - * fully resolved compile command. Do that here. - * <p> - * We use the RemoteCommandHelpers class to run it. - */ - protected boolean internalRunCompileCommand(String compileCmd) { - String path = RemoteCommandHelpers.getWorkingDirectory((IRemoteFile) firstSelection); - boolean ok = RemoteCommandHelpers.runUniversalCommand(shell, compileCmd, path, getCommandSubSystem(), true); - return ok; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/UniversalCompileManager.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/UniversalCompileManager.java deleted file mode 100644 index 08574788f..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/UniversalCompileManager.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 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.files.compile; - -import org.eclipse.rse.core.model.IHost; -import org.eclipse.rse.core.model.ISystemProfile; -import org.eclipse.rse.internal.useractions.ui.SystemCmdSubstVarList; -import org.eclipse.rse.internal.useractions.ui.compile.ISystemCompileCommandSubstitutor; -import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileManager; -import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileProfile; -import org.eclipse.rse.internal.useractions.ui.compile.SystemDefaultCompileCommands; - -/** - * Specializatio of compile support for universal file subsystems. - */ -public class UniversalCompileManager extends SystemCompileManager { - /** - * Constructor for UniversalCompileManager. - */ - public UniversalCompileManager() { - super(); - } - - /** - * Overridable method to instantiate the SystemCompileProfile for the - * given system profile. - * <p> - * We return an instance of UniversalCompileProfile - */ - protected SystemCompileProfile createCompileProfile(ISystemProfile profile) { - return new UniversalCompileProfile(this, profile.getName()); - } - - /** - * Return the default list of compile commands to prime new documents with. - */ - public SystemDefaultCompileCommands getDefaultCompileCommands() { - return UniversalIBMCompileCommands.getIBMCompileCommands(); - } - - /** - * For support of the Work With Compile Commands dialog. - * <p> - * Return the substitution variables supported by compile commands managed by this manager. - */ - public SystemCmdSubstVarList getSubstitutionVariableList() { - return UniversalCompileSubstList.getInstance(); - } - - /** - * @see org.eclipse.rse.internal.useractions.ui.compile.SystemCompileManager#createSubstitutor(IHost) - */ - protected ISystemCompileCommandSubstitutor createSubstitutor(IHost connection) { - return new UniversalCompileSubstitutor(connection); - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/UniversalCompileProfile.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/UniversalCompileProfile.java deleted file mode 100644 index 08380ec43..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/UniversalCompileProfile.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2008 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.files.compile; - -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.rse.internal.useractions.ui.compile.SystemCompilableSource; -import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileCommand; -import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileManager; -import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileProfile; -import org.eclipse.swt.widgets.Shell; - -/** - * Specialization of the compile profile class, uniquely for the compile support of files from - * a universal file subsystem. - */ -public class UniversalCompileProfile extends SystemCompileProfile { - /** - * Constructor for UniversalCompileProfile. - * @param manager SystemCompileManager of this compile file - * @param profileName System profile name - */ - public UniversalCompileProfile(SystemCompileManager manager, String profileName) { - super(manager, profileName); - } - - /** - * When the time comes to actually run a compile command against a selected source object, - * this method is called to return the instance of SystemCompilableSource to do that. - * <p> - * This method must be implemented to return an instance of your subclass of SystemCompilableSource. - */ - public SystemCompilableSource getCompilableSourceObject(Shell shell, Object selectedObject, SystemCompileCommand compileCmd, boolean isPrompt, Viewer viewer) { - UniversalCompilableSource compilableSrc = new UniversalCompilableSource(shell, selectedObject, compileCmd, isPrompt, viewer); - return compilableSrc; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/UniversalCompileSubstList.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/UniversalCompileSubstList.java deleted file mode 100644 index 6cf8786e3..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/UniversalCompileSubstList.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 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 - * Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods - *******************************************************************************/ -package org.eclipse.rse.internal.useractions.files.compile; - -import org.eclipse.rse.internal.useractions.ui.SystemCmdSubstVarList; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources; - -/** - * Encapsulation of the compile command substitution variables for universal files. - */ -public class UniversalCompileSubstList extends SystemCmdSubstVarList { - private static final String[] UNIVERSAL_FILES_VARNAMES = { "system_filesep", //$NON-NLS-1$ - "system_homedir", //$NON-NLS-1$ - "system_pathsep", //$NON-NLS-1$ - "system_tempdir", //$NON-NLS-1$ - "resource_name", //$NON-NLS-1$ - "resource_name_root", //$NON-NLS-1$ - "resource_path", //$NON-NLS-1$ - "resource_path_root", //$NON-NLS-1$ - "resource_path_drive", //$NON-NLS-1$ - "container_name", //$NON-NLS-1$ - "container_path" //$NON-NLS-1$ - }; - private static final String[] UNIVERSAL_FILES_DESCRIPTIONS = { SystemUDAResources.RESID_COMPILE_FILES_SUBVAR_SYSTEM_FILESEP, SystemUDAResources.RESID_COMPILE_FILES_SUBVAR_SYSTEM_HOMEDIR, - SystemUDAResources.RESID_COMPILE_FILES_SUBVAR_SYSTEM_PATHSEP, SystemUDAResources.RESID_COMPILE_FILES_SUBVAR_SYSTEM_TEMPDIR, SystemUDAResources.RESID_COMPILE_FILES_SUBVAR_RESOURCE_NAME, - SystemUDAResources.RESID_COMPILE_FILES_SUBVAR_RESOURCE_NAME_ROOT, SystemUDAResources.RESID_COMPILE_FILES_SUBVAR_RESOURCE_PATH, - SystemUDAResources.RESID_COMPILE_FILES_SUBVAR_RESOURCE_PATH_ROOT, SystemUDAResources.RESID_COMPILE_FILES_SUBVAR_RESOURCE_PATH_DRIVE, - SystemUDAResources.RESID_COMPILE_FILES_SUBVAR_CONTAINER_NAME, SystemUDAResources.RESID_COMPILE_FILES_SUBVAR_CONTAINER_PATH }; - private static UniversalCompileSubstList inst = null; - - /** - * Constructor . - * Not to be used directly. Rather, use {@link #getInstance()}. - */ - UniversalCompileSubstList() { - super(UNIVERSAL_FILES_VARNAMES, UNIVERSAL_FILES_DESCRIPTIONS); - } - - /** - * Return the singleton of this object. No need ever for more than one instance - */ - public static UniversalCompileSubstList getInstance() { - if (inst == null) inst = new UniversalCompileSubstList(); - return inst; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/UniversalCompileSubstitutor.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/UniversalCompileSubstitutor.java deleted file mode 100644 index 368761748..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/UniversalCompileSubstitutor.java +++ /dev/null @@ -1,219 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 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 - * Martin Oberhuber (Wind River) - [168870] refactor org.eclipse.rse.core package of the UI plugin - *******************************************************************************/ -package org.eclipse.rse.internal.useractions.files.compile; - -import org.eclipse.rse.core.model.IHost; -import org.eclipse.rse.internal.useractions.ui.compile.ISystemCompileCommandSubstitutor; -import org.eclipse.rse.shells.ui.RemoteCommandHelpers; -import org.eclipse.rse.subsystems.files.core.model.RemoteFileUtility; -import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; -import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem; -import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystemConfiguration; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCmdSubSystem; -import org.eclipse.rse.ui.view.SystemAdapterHelpers; - -/** - * This class is responsible for doing variable substitution for iSeries compile - * commands - */ -public class UniversalCompileSubstitutor implements ISystemCompileCommandSubstitutor { - private IHost connection; - - /** - * Constructor for UniversalCompileSubstitutor. - */ - public UniversalCompileSubstitutor(IHost connection) { - super(); - this.connection = connection; - } - - /** - * Reset the connection so one instance can be re-used - */ - public void setConnection(IHost connection) { - this.connection = connection; - } - - /** - * @see org.eclipse.rse.internal.useractions.ui.ISystemSubstitutor#getSubstitutionValue(String, Object) - */ - public String getSubstitutionValue(String substitutionVariable, Object context) { - //private static final String[] UNIVERSAL_FILES_VARNAMES = - //{"system_filesep", "system_homedir", "system_pathsep", "system_tempdir", - // "user_id", "resource_name", "resource_path", "resource_path_root", "resource_path_drive", "container_name", "container_path"}; - if (substitutionVariable.equals("${system_filesep}")) //$NON-NLS-1$ - return getFileSeparator(); - else if (substitutionVariable.equals("${system_homedir}")) //$NON-NLS-1$ - return getHomeDirectory(); - else if (substitutionVariable.equals("${system_pathsep}")) //$NON-NLS-1$ - return getPathSeparator(); - else if (substitutionVariable.equals("${system_tempdir}")) //$NON-NLS-1$ - return getTempDirectory(); - else if (substitutionVariable.equals("${user_id}")) //$NON-NLS-1$ - return getUserId(); - else if (substitutionVariable.equals("${resource_name}")) //$NON-NLS-1$ - return getResourceName(context); - else if (substitutionVariable.equals("${resource_name_root}")) //$NON-NLS-1$ - return getResourceNameRoot(context); - else if (substitutionVariable.equals("${resource_path}")) //$NON-NLS-1$ - return getResourcePath(context); - else if (substitutionVariable.equals("${resource_path_root}")) //$NON-NLS-1$ - return getPathRoot(context); - else if (substitutionVariable.equals("${resource_path_drive}")) //$NON-NLS-1$ - return getPathDrive(context); - else if (substitutionVariable.equals("${container_name}")) //$NON-NLS-1$ - return getContainerName(context); - else if (substitutionVariable.equals("${container_path}")) //$NON-NLS-1$ - return getContainerPath(context); - return null; - } - - /** - * Get the command subsystem - */ - protected IRemoteCmdSubSystem getCmdsSubSystem() { - return RemoteCommandHelpers.getCmdSubSystem(connection); - } - - /** - * Get the files subsystem - */ - protected IRemoteFileSubSystem getFilesSubSystem() { - return RemoteFileUtility.getFileSubSystem(connection); - } - - /** - * Get the files subsystem factory - */ - protected IRemoteFileSubSystemConfiguration getFilesSubSystemFactory() { - return RemoteFileUtility.getFileSubSystem(connection).getParentRemoteFileSubSystemConfiguration(); - } - - /** - * Return the file separator for the ${system_filesep} variable - */ - protected String getFileSeparator() { - return getFilesSubSystemFactory().getSeparator(); - } - - /** - * Return the path separator for the ${system_pathsep} variable - */ - protected String getPathSeparator() { - return getFilesSubSystemFactory().getPathSeparator(); - } - - /** - * Return the user's home directory on the remote system, for the ${system_homedir} variable - */ - protected String getHomeDirectory() { - return getCmdsSubSystem().getConnectorService().getHomeDirectory(); - } - - /** - * Return the temporary directory on the remote system, for the ${system_tempdir} variable - */ - protected String getTempDirectory() { - return getCmdsSubSystem().getConnectorService().getTempDirectory(); - } - - /** - * Return the user ID used to connect with the remote system, for the ${user_id} variable - */ - protected String getUserId() { - return getCmdsSubSystem().getConnectorService().getUserId(); - } - - /** - * Return the name of the currently selected resource, for the ${resource_name} variable - */ - protected String getResourceName(Object context) { - return SystemAdapterHelpers.getRemoteAdapter(context).getName(context); - } - - /** - * Return the root part of the name of the currently selected resource, for the ${resource_name_root} variable - */ - protected String getResourceNameRoot(Object context) { - IRemoteFile selectedFile = (IRemoteFile) context; - String name = selectedFile.getName(); - int dotIdx = name.lastIndexOf('.'); - if (dotIdx == 0) - return ""; //$NON-NLS-1$ - else if (dotIdx > 0) - return name.substring(0, dotIdx); - else - return name; - } - - /** - * Return the path of the currently selected resource, for the ${resource_path} variable - */ - protected String getResourcePath(Object context) { - return SystemAdapterHelpers.getRemoteAdapter(context).getAbsoluteName(context); - } - - /** - * Return the root part of the path, for the ${resource_path_root} variable - */ - protected String getPathRoot(Object context) { - IRemoteFile selectedFile = (IRemoteFile) context; - String name = selectedFile.getAbsolutePath(); - if (name != null) { - if (name.startsWith("/") || name.startsWith("\\")) //$NON-NLS-1$ //$NON-NLS-2$ - return name.substring(0, 1); - else { - int idx = name.indexOf(":\\"); //$NON-NLS-1$ - if (idx > 0) return name.substring(0, idx + 2); - } - } - return ""; //$NON-NLS-1$ - } - - /** - * Return the drive part of the path, for the ${resource_path_drive} variable - */ - protected String getPathDrive(Object context) { - IRemoteFile selectedFile = (IRemoteFile) context; - String name = selectedFile.getAbsolutePath(); - if ((name != null) && (name.length() > 1)) { - int idx = name.indexOf(':'); - if (idx > 0) return name.substring(0, idx); - } - return ""; //$NON-NLS-1$ - } - - /** - * Return the name of the parent folder, for the ${container_name} variable - */ - protected String getContainerName(Object context) { - IRemoteFile selectedFile = (IRemoteFile) context; - String fn = selectedFile.getParentName(); - if (fn != null) - return fn; - else - return ""; //$NON-NLS-1$ - } - - /** - * Return the path of the parent folder, for the ${container_path} variable - */ - protected String getContainerPath(Object context) { - IRemoteFile selectedFile = (IRemoteFile) context; - String name = selectedFile.getAbsolutePath(); - if ((name != null) && (name.length() > 1)) { - int idx = name.indexOf(':'); - if (idx > 0) return name.substring(0, idx); - } - return ""; //$NON-NLS-1$ - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/UniversalIBMCompileCommand.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/UniversalIBMCompileCommand.java deleted file mode 100644 index 1974d8581..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/UniversalIBMCompileCommand.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.eclipse.rse.internal.useractions.files.compile; - -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - *******************************************************************************/ -import org.eclipse.rse.internal.useractions.ui.compile.SystemDefaultCompileCommand; - -/** - * Specialization of the the SystemDefaultCompileCommand for an IBM-supplied - * compile command for universal files. - */ -public class UniversalIBMCompileCommand extends SystemDefaultCompileCommand { - /** - * Constructor for UniversalCompileIBMCommand. - * @param commandLabel label of the command - * @param commandName name of the command - */ - public UniversalIBMCompileCommand(String commandLabel, String commandName) { - super(commandLabel, commandName); - } - - /** - * Constructor for UniversalCompileIBMCommand. - * @param commandName name of the command - */ - public UniversalIBMCompileCommand(String commandName) { - super(commandName); - } - - /** - * Constructor that takes a command name and label and the parameters. - * This avoids you having to call setAdditionalCommandParameters. - */ - public UniversalIBMCompileCommand(String commandLabel, String commandName, String parameters) { - super(commandLabel, commandName, parameters); - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/UniversalIBMCompileCommands.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/UniversalIBMCompileCommands.java deleted file mode 100644 index 58ec333b9..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/UniversalIBMCompileCommands.java +++ /dev/null @@ -1,65 +0,0 @@ -package org.eclipse.rse.internal.useractions.files.compile; - -/******************************************************************************* - * Copyright (c) 2002, 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 - *******************************************************************************/ -import org.eclipse.rse.internal.useractions.ui.compile.SystemDefaultCompileCommands; - -/** - * Specialization of the SystemDefaultCompileCommands for the IBM-supplied compile commands - * for universal files - */ -public class UniversalIBMCompileCommands extends SystemDefaultCompileCommands { - private static UniversalIBMCompileCommands ibmCompileCommands; - // Source types supported - public static final String TYPE_C = "c"; //$NON-NLS-1$ - public static final String TYPE_CC = "cc"; //$NON-NLS-1$ - public static final String TYPE_CXX = "cxx"; //$NON-NLS-1$ - public static final String TYPE_CPP = "cpp"; //$NON-NLS-1$ - public static final String TYPE_CPP_C = "C"; //$NON-NLS-1$ - public static final String TYPE_CPP_CC = "CC"; //$NON-NLS-1$ - public static final String TYPE_CPP_CXX = "CXX"; //$NON-NLS-1$ - public static final String TYPE_JAVA = "java"; //$NON-NLS-1$ - public static final String[] ALL_IBM_SRC_TYPES = { TYPE_C, TYPE_CPP, TYPE_CC, TYPE_CPP_CC, TYPE_CXX, TYPE_CPP_CXX, TYPE_JAVA }; - - /** - * Constructor - */ - public UniversalIBMCompileCommands() { - super(); - } - - /** - * Get all IBM supplied compilable source types. - */ - public String[] getAllDefaultSuppliedSourceTypes() { - return ALL_IBM_SRC_TYPES; - } - - /** - * Return the singleton instance of the list of commands IBM recognizes by default - */ - public static UniversalIBMCompileCommands getIBMCompileCommands() { - if (ibmCompileCommands == null) { - ibmCompileCommands = new UniversalIBMCompileCommands(); - UniversalIBMCompileCommand cmd = null; - cmd = new UniversalIBMCompileCommand("JAVAC", "javac", "-deprecation -classpath . ${resource_name}"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - cmd.setSourceTypes(new String[] { TYPE_JAVA }); - ibmCompileCommands.addCommand(cmd); - cmd = new UniversalIBMCompileCommand("GCC", "gcc", "-c ${resource_name} -o ${resource_name_root}.o"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - cmd.setSourceTypes(new String[] { TYPE_C, TYPE_CC, TYPE_CPP, TYPE_CPP_CC, TYPE_CPP_CXX, TYPE_CXX }); - ibmCompileCommands.addCommand(cmd); - cmd = new UniversalIBMCompileCommand("CC", "cc", "-c ${resource_name} -o ${resource_name_root}.o"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - cmd.setSourceTypes(new String[] { TYPE_C, TYPE_CC, TYPE_CPP, TYPE_CPP_CC, TYPE_CPP_CXX, TYPE_CXX }); - ibmCompileCommands.addCommand(cmd); - } - return ibmCompileCommands; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/uda/UDActionSubsystemFiles.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/uda/UDActionSubsystemFiles.java deleted file mode 100644 index f96f61358..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/uda/UDActionSubsystemFiles.java +++ /dev/null @@ -1,799 +0,0 @@ -package org.eclipse.rse.internal.useractions.files.uda; - -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - * Xuan Chen (IBM) - [222263] Need to provide a PropertySet Adapter for System Team View (cleanup some use action stuff) - * Kevin Doyle (IBM) - [222830] ArrayIndexOutOfBoundsException on Restore Defaults on Folder User Actions - * Xuan Chen (IBM) - [246807] [useractions] - Command Command property set from different os and subsystem are all shown as "Compile Commands" in Team view - *******************************************************************************/ -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Iterator; -import java.util.StringTokenizer; -import java.util.Vector; - -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.rse.core.model.IPropertySet; -import org.eclipse.rse.core.model.ISystemProfile; -import org.eclipse.rse.internal.useractions.UserActionsIcon; -import org.eclipse.rse.internal.useractions.ui.SystemCmdSubstVarList; -import org.eclipse.rse.internal.useractions.ui.uda.ISystemUDAConstants; -import org.eclipse.rse.internal.useractions.ui.uda.ISystemUDAEditPaneHoster; -import org.eclipse.rse.internal.useractions.ui.uda.ISystemUDTreeView; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDActionElement; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDActionManager; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDActionSubsystem; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDBaseManager; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDTypeEditPane; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDTypeElement; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDTypeManager; -import org.eclipse.rse.services.clientserver.FileTypeMatcher; -import org.eclipse.rse.shells.ui.RemoteCommandHelpers; -import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; -import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCmdSubSystem; -import org.eclipse.rse.ui.ISystemIconConstants; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; - -/** - * User action subsystem for universal files - */ -public class UDActionSubsystemFiles extends SystemUDActionSubsystem { - public static final String NO_EXTENSION_PLACEHOLDER = ".null"; //$NON-NLS-1$ - private static DateFormat dateFormatter; - // INSTANCE VARIABLES... - private FileTypeMatcher fileTypeMatcher; - // CONSTANTS... - private static final String DOMAINS[] = { "Folder", "File" }; //$NON-NLS-1$ //$NON-NLS-2$ - // Matching name string in the plugin resources (translated) - //private String DOMAIN_NEWTYPENAME_STRING[] = { RESID_UDT_FILES_DOMAIN_NEWFOLDER, RESID_UDT_FILES_DOMAIN_NEWFILE }; - // index values must match above 2 variables - public static final int DOMAIN_FOLDER = 0; - public static final int DOMAIN_FILE = 1; - protected static final String FILE_ACTIONS[][] = // todo! - // name, refresh, singleSel, collect, types, cmd - { { "java", "false", "true", "false", "CLASS", "java ${resource_name_root}" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ - { "javac", "true", "false", "true", "JAVA", "javac -deprecation -classpath . ${resource_name}" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ - { "jar", "true", "false", "true", "ALL", "jar -cvf classes.jar ${resource_name}" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ - { "unjar", "false", "true", "false", "JAR ZIP", "jar -xf ${resource_name}" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ - { "gmake", "true", "false", "false", "GNU_MAKEFILE", "gmake -f ${resource_name}" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ - { "make", "true", "false", "false", "MAKEFILE", "make -f ${resource_name}" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ - // I have decided against the following in favor of allowing these to be expanded in the tree view. Phil - //{"list", "false", "true", "false", "JAR ZIP", "jar tf ${resource_name}"}, - }; - protected static final String FOLDER_ACTIONS[][] = - // name, refresh, singleSel, collect, cmd - { { "javac", "true", "false", "true", "javac -deprecation -classpath . *.java" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ - { "jar", "true", "false", "true", "jar cvf classes.jar *.class" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ - }; - protected static final String IBM_DEFAULT_FOLDERTYPES[][] = { // name, types - { "ALL", "*" }, //$NON-NLS-1$ //$NON-NLS-2$ - }; - protected static final String IBM_DEFAULT_FILETYPES[][] = { // name, types - { "ALL", "*" }, //$NON-NLS-1$ //$NON-NLS-2$ - { "C", "c,h,i" }, //$NON-NLS-1$ //$NON-NLS-2$ - { "C_COMPILABLE", "c" }, //$NON-NLS-1$ //$NON-NLS-2$ - { "CPP", "cpp,cxx,hpp,ipp" }, //$NON-NLS-1$ //$NON-NLS-2$ - { "CPP_COMPILABLE", "cpp,cxx" }, //$NON-NLS-1$ //$NON-NLS-2$ - { "CLASS", "class" }, //$NON-NLS-1$ //$NON-NLS-2$ - { "CSS", "css" }, //$NON-NLS-1$ //$NON-NLS-2$ - { "EAR", "ear" }, //$NON-NLS-1$ //$NON-NLS-2$ - { "EXE", "exe,bat,cmd" }, //$NON-NLS-1$ //$NON-NLS-2$ - { "GRAPHIC", "bmp,gif,jpg" }, //$NON-NLS-1$ //$NON-NLS-2$ - { "GNU_MAKEFILE", "GNUMakefile" + NO_EXTENSION_PLACEHOLDER }, //$NON-NLS-1$ //$NON-NLS-2$ - { "HTML", "htm, html" }, //$NON-NLS-1$ //$NON-NLS-2$ - { "JAVA", "java" }, //$NON-NLS-1$ //$NON-NLS-2$ - { "JAVASCRIPT", "js" }, //$NON-NLS-1$ //$NON-NLS-2$ - { "JAR", "jar" }, //$NON-NLS-1$ //$NON-NLS-2$ - { "JARZIP", "jar,zip" }, //$NON-NLS-1$ //$NON-NLS-2$ - { "JSP", "jsp" }, //$NON-NLS-1$ //$NON-NLS-2$ - { "MAKEFILE", "makefile" + NO_EXTENSION_PLACEHOLDER + ", mak" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - { "NONE", "null" }, // our own invention! //$NON-NLS-1$ //$NON-NLS-2$ - { "PERL", "pl" }, //$NON-NLS-1$ //$NON-NLS-2$ - { "PROFILE", "profile" }, //$NON-NLS-1$ //$NON-NLS-2$ - { "PYTHON", "py" }, //$NON-NLS-1$ //$NON-NLS-2$ - { "SHELL ", "csh, ksh, sh" }, //$NON-NLS-1$ //$NON-NLS-2$ - { "SQLJ", "sqlj" }, //$NON-NLS-1$ //$NON-NLS-2$ - { "WAR", "war" }, //$NON-NLS-1$ //$NON-NLS-2$ - { "WEB", "css, htm, html, js, jsp" }, //$NON-NLS-1$ //$NON-NLS-2$ - { "TAR", "tar" }, //$NON-NLS-1$ //$NON-NLS-2$ - { "ZIP", "zip" }, //$NON-NLS-1$ //$NON-NLS-2$ - }; - protected String[] DOMAIN_NAME_STRING = new String[2]; - protected String[] DOMAIN_NEWNAME_STRING = new String[2]; - - /** - * Constructor - */ - public UDActionSubsystemFiles() { - super(); - DOMAIN_NAME_STRING[0] = SystemUDAResources.RESID_UDA_FILES_DOMAIN_FOLDER; - DOMAIN_NAME_STRING[1] = SystemUDAResources.RESID_UDA_FILES_DOMAIN_FILE; - DOMAIN_NEWNAME_STRING[0] = SystemUDAResources.RESID_UDA_FILES_DOMAIN_NEWFOLDER; - DOMAIN_NEWNAME_STRING[1] = SystemUDAResources.RESID_UDA_FILES_DOMAIN_NEWFILE; - } - - /** - * Overridable extension point for child classes to do migration of their actions. - * This is called on first load of a document, which has a release stamp other than - * the current release - * @return true if any migration was done... we return false - */ - protected boolean doActionsMigration(ISystemProfile profile, String oldRelease) { - return false; - } - - /** - * Overridable extension point for child classes to do migration of their types. - * This is called on first load of a document, which has a release stamp other than - * the current release - * @return true if any migration was done... we return false - */ - protected boolean doTypesMigration(ISystemProfile profile, String oldRelease) { - return false; - } - - /** - * Required override of parent for doing substitutions for our unique variables. - */ - public String internalGetSubstitutionValue(SystemUDActionElement currentAction, String subvar, Object selectedObject) { - return getUniversalSubstitutionValue(currentAction, subvar, selectedObject); - } - - /** - * Required override of parent for doing substitutions for our unique variables. - */ - public static String getUniversalSubstitutionValue(SystemUDActionElement currentAction, String subvar, Object selectedObject) { - /* from resource property file... - Common to files and folders: - ...uda.files.subvar.resource_date = Last modified date of selected resource - ...uda.files.subvar.resource_name = Name of selected resource, unqualified - ...uda.files.subvar.resource_path = Path of selected resource, including name - ...uda.files.subvar.resource_path_root=Root of selected file's path. "c:\\" on Windows, or "/" on others - ...uda.files.subvar.resource_path_drive=Drive letter on Windows, empty string on others - ...uda.files.subvar.container_name=Name of folder containing selected resource, unqualified - ...uda.files.subvar.container_path=Path of folder containing selected resource, including name - // note: resource_name and resource_path handled for us in parent class! - File specific: - ...uda.files.subvar.resource_name_root=Name of selected resource without the extension - ...uda.files.subvar.resource_name_ext=Extension part of the name of the selected resource - */ - IRemoteFile selectedFile = (IRemoteFile) selectedObject; - if (subvar.equals("${resource_date}")) //$NON-NLS-1$ - { - if (dateFormatter == null) dateFormatter = new SimpleDateFormat("yyyy.MM.dd hh:mm:ss z"); //new SimpleDateFormat(); //$NON-NLS-1$ - Date lmd = selectedFile.getLastModifiedDate(); - if (lmd != null) - return dateFormatter.format(lmd); - else - return "not available"; //$NON-NLS-1$ - } else if (subvar.equals("${resource_name_root}")) //$NON-NLS-1$ - { - String name = selectedFile.getName(); - int dotIdx = name.lastIndexOf('.'); - if (dotIdx == 0) - return ""; //$NON-NLS-1$ - else if (dotIdx > 0) - return name.substring(0, dotIdx); - else - return name; - } else if (subvar.equals("${resource_name_ext}")) //$NON-NLS-1$ - { - String name = selectedFile.getName(); - int dotIdx = name.lastIndexOf('.'); - if (dotIdx == 0) { - if (name.length() == 1) - return ""; //$NON-NLS-1$ - else - return name.substring(1); - } else if (dotIdx > 0) - return name.substring(dotIdx + 1); - else - return ""; //$NON-NLS-1$ - } - /* - else if (subvar.equals("${path}")) - { - String p = selectedFile.getParentNoRoot(); - if (p != null) - return p; - else - return ""; - } - */ - else if (subvar.equals("${container_name}")) //$NON-NLS-1$ - { - // another example where the info can't be trusted! - /* - String fn = selectedFile.getParentName(); - if (fn != null) - return fn; - else - return ""; - */ - String fullpath = selectedFile.getParentPath(); - if ((fullpath == null) || (fullpath.length() == 0)) return ""; //$NON-NLS-1$ - IRemoteFileSubSystem rfss = getFileSubSystem(selectedObject); - if (rfss == null) return ""; //$NON-NLS-1$ - char sep = rfss.getParentRemoteFileSubSystemConfiguration().getSeparatorChar(); - int idx = fullpath.lastIndexOf(sep); - if (idx >= 0) - return fullpath.substring(idx + 1); - else - return ""; //$NON-NLS-1$ - } else if (subvar.equals("${container_path}")) //$NON-NLS-1$ - return selectedFile.getParentPath(); - else if (subvar.equals("${resource_path_root}")) //$NON-NLS-1$ - { - String name = selectedFile.getAbsolutePath(); - if (name != null) { - if (name.startsWith("/") || name.startsWith("\\")) //$NON-NLS-1$ //$NON-NLS-2$ - return name.substring(0, 1); - else { - int idx = name.indexOf(":\\"); //$NON-NLS-1$ - if (idx > 0) return name.substring(0, idx + 2); - } - } - return ""; //$NON-NLS-1$ - } else if (subvar.equals("${resource_path_drive}")) //$NON-NLS-1$ - { - //String root = selectedFile.getRoot(); - String name = selectedFile.getAbsolutePath(); - if ((name != null) && (name.length() > 1)) { - int idx = name.indexOf(':'); - if (idx > 0) return name.substring(0, idx); - } - return ""; //$NON-NLS-1$ - } - /* now handled in common base class - else if (subvar.equals("${system_pathsep}")) - return selectedFile.getSeparator(); - */ - return null; // return null to tell parent we didn't do any substitutions! - } - - /** - * Get the delimiter used to delimiter the types in a type string. - * Default is " " - */ - protected String getTypesDelimiter() { - return ","; //$NON-NLS-1$ - } - - /** - * After an action's command has been resolved (vars substituted) this method - * is called to actually do the remote command execution - * <p> - * Run the user action's command in the default shell, and - * log result in the command view. - * - * @param shell - the shell to use if need to prompt for password or show msg dialog - * @param action - the action being processed, in case attributes of it need to be queried - * @param cmdString - the resolved command - * @param cmdSubSystem - this connection's command subsystem, which will run the command - * @param context - the selected IRemoteFile object - * @param viewer the viewer that originated the compile action - * @return true if we should continue, false if something went wrong - */ - protected boolean runCommand(Shell shell, SystemUDActionElement action, String cmdString, IRemoteCmdSubSystem cmdSubSystem, Object context, Viewer viewer) { - return runUniversalCommand(shell, cmdString, cmdSubSystem, context); - } - - /** - * Encapsulation of code needed to run a universal subsystem command. - * - * @param shell - the shell to use if need to prompt for password or show msg dialog - * @param cmdString - the resolved command - * @param cmdSubSystem - this connection's command subsystem, which will run the command - * @param context - the selected IRemoteFile object - * @return true if we should continue, false if something went wrong - */ - public static boolean runUniversalCommand(Shell shell, String cmdString, IRemoteCmdSubSystem cmdSubSystem, Object context) { - String path = RemoteCommandHelpers.getWorkingDirectory((IRemoteFile) context); - boolean ok = RemoteCommandHelpers.runUniversalCommand(shell, cmdString, path, cmdSubSystem); - return ok; - } // end method - - // ----------------------------------------------- - // OVERRIDDEN METHODS FOR CAPABILITY DEFINITION - // ----------------------------------------------- - /** - * Return true if actions can be scoped by file types - * The iSeries native file system does support types - */ - public boolean supportsTypes() { - return true; - } - - /** - * Return true if actions can be scoped by file types for the given domain. - * Default is supportsTypes() - */ - public boolean supportsTypes(int domain) { - if (domain == DOMAIN_FOLDER) - return false; - else - return true; - } - - /** - * Return true if the action/type manager supports domains. - * The iSeries native file system does support domains - */ - public boolean supportsDomains() { - return true; - } - - /** - * In some cases, we supports domains in general, but only want to expose - * one of those domains to the user. For example, for file subsystems, - * we support folder and file domains, but for named types we really only - * support the file domain. - * <p> - * We return DOMAIN_FILE if the docManager is the type manager - */ - public int getSingleDomain(SystemUDBaseManager docManager) { - if (docManager != getUDTypeManager()) - return -1; - else - return DOMAIN_FILE; - } - - // -------------------- - // VARIOUS OVERRIDES... - // -------------------- - /** - * Subclasses may override to provide a custom type edit pane subclass - */ - public SystemUDTypeEditPane getCustomUDTypeEditPane(ISystemUDAEditPaneHoster parent, ISystemUDTreeView tv) { - return new UDTypesEditPaneFiles(this, parent, tv); - } - - /** - * Prime new document with default types. This adds all the types that common across all system types, - * but also allows unique types to be added per system by calling primeAdditionalDefaultUniversalTypes, - * which is a method that subclasses can override. - * <p> - * Do no override this method, but instead override primeAdditionalDefaultUniversalTypes. - */ - public SystemUDTypeElement[] primeDefaultTypes(SystemUDTypeManager typeMgr) { - Vector v = new Vector(); - primeDefaultUniversalTypes(typeMgr, v); - // give subclasses a chance... - primeAdditionalDefaultUniversalTypes(typeMgr, v); - // convert vector to array - SystemUDTypeElement[] typesArray = new SystemUDTypeElement[v.size()]; - for (int idx = 0; idx < typesArray.length; idx++) - typesArray[idx] = (SystemUDTypeElement) v.elementAt(idx); - return typesArray; - } - - /** - * Static version of primeDefaultTypes that is called by the iSeries IFS action subsystem. - * @param typeMgr - the manager of the types document to be primed - * @param vectorOfTypes - the vector to populate with types. Can be null, in which case the results are returned as an array - * @return null if given a vector (it is populated), else the array of default types - */ - public static SystemUDTypeElement[] primeDefaultUniversalTypes(SystemUDTypeManager typeMgr, Vector vectorOfTypes) { - Vector v = vectorOfTypes; - if (v == null) v = new Vector(); - for (int i = 0; i < IBM_DEFAULT_FOLDERTYPES.length; i++) { - SystemUDTypeElement ft = typeMgr.addType(DOMAIN_FOLDER, IBM_DEFAULT_FOLDERTYPES[i][0]); - if (null == ft) continue; - v.addElement(ft); - ft.setTypes(IBM_DEFAULT_FOLDERTYPES[i][1]); - } - for (int i = 0; i < IBM_DEFAULT_FILETYPES.length; i++) { - SystemUDTypeElement ft = typeMgr.addType(DOMAIN_FILE, IBM_DEFAULT_FILETYPES[i][0]); - if (null == ft) continue; - v.addElement(ft); - ft.setTypes(IBM_DEFAULT_FILETYPES[i][1]); - } - if (vectorOfTypes != null) return null; - // convert vector to array - SystemUDTypeElement[] typesArray = new SystemUDTypeElement[v.size()]; - for (int idx = 0; idx < typesArray.length; idx++) - typesArray[idx] = (SystemUDTypeElement) v.elementAt(idx); - return typesArray; - } - - /** - * This is an override point for subclasses to add system-specify default types. - * <p> - * To simplify processing, subclasses should add their additional SystemUDTypeElement - * objects to the given vector. - */ - protected void primeAdditionalDefaultUniversalTypes(SystemUDTypeManager typeMgr, Vector vectorOfTypes) { - } - - /** - * Prime new document with default action. This adds all the actions that common across all system types, - * but also allows unique actions to be added per system by calling primeAdditionalDefaultUniversalActions, - * which is a method that subclasses can override. - * <p> - * Do no override this method, but instead override primeAdditionalDefaultUniversalActions. - */ - public SystemUDActionElement[] primeDefaultActions(SystemUDActionManager actionMgr, ISystemProfile profile) { - Vector v = new Vector(); - primeDefaultUniversalActions(actionMgr, profile, v); - // give subclasses a chance... - primeAdditionalDefaultUniversalActions(actionMgr, profile, v); - // convert vector to array - SystemUDActionElement[] actionArray = new SystemUDActionElement[v.size()]; - for (int idx = 0; idx < actionArray.length; idx++) - actionArray[idx] = (SystemUDActionElement) v.elementAt(idx); - return actionArray; - } - - /** - * Static version of primeDefaultActions that is called by the iSeries IFS action subsystem. - * @param actionMgr - the manager of the actions document to be primed - * @param vectorOfActions - the vector to populate with actions. Can be null, in which case the results are returned as an array - * @return null if given a vector (it is populated), else the array of default actions - */ - public static SystemUDActionElement[] primeDefaultUniversalActions(SystemUDActionManager actionMgr, ISystemProfile profile, Vector vectorOfActions) { - Vector v = vectorOfActions; - if (v == null) v = new Vector(); - String osType = actionMgr.getActionSubSystem().getOSType(); - String userDefinedActionPropertySetName = ISystemUDAConstants.USER_DEFINED_ACTION_PROPRERTY_SET_PREFIX + osType + "." + actionMgr.getDocumentRootTagName(); //$NON-NLS-1$ - IPropertySet userDefinedActionPropertySet = profile.getPropertySet(userDefinedActionPropertySetName); - if (null == userDefinedActionPropertySet) - { - userDefinedActionPropertySet = profile.createPropertySet(userDefinedActionPropertySetName); - userDefinedActionPropertySet.addProperty(ISystemUDAConstants.NAME_ATTR, ISystemUDAConstants.USER_DEFINED_ACTION_PROPRERTY_SET_Name + " - " + osType); //$NON-NLS-1$ - userDefinedActionPropertySet.addProperty(ISystemUDAConstants.RELEASE_ATTR, ISystemUDAConstants.RELEASE_VALUE); - userDefinedActionPropertySet.addProperty(ISystemUDAConstants.UDA_ROOT_ATTR, actionMgr.getDocumentRootTagName()); - } - // add file actions - int domain = DOMAIN_FILE; - SystemUDActionElement newAction; - //IPropertySet domainFilePropertySet = userDefinedActionPropertySet.createPropertySet(DOMAINS[1]); - for (int idx = 0; idx < FILE_ACTIONS.length; idx++) { - newAction = actionMgr.addAction(profile, FILE_ACTIONS[idx][0], domain); - v.addElement(newAction); - newAction.setCommand(FILE_ACTIONS[idx][5]); - newAction.setPrompt(true); // may as well always allow users chance to change command as its submitted - newAction.setRefresh(FILE_ACTIONS[idx][1].equals("true")); //$NON-NLS-1$ - newAction.setShow(true); - newAction.setSingleSelection(FILE_ACTIONS[idx][2].equals("true")); //$NON-NLS-1$ - newAction.setCollect(FILE_ACTIONS[idx][3].equals("true")); //$NON-NLS-1$ - newAction.setFileTypes(convertStringToArray(FILE_ACTIONS[idx][4])); - } - // add folder actions - domain = DOMAIN_FOLDER; - for (int idx = 0; idx < FOLDER_ACTIONS.length; idx++) { - newAction = actionMgr.addAction(profile, FOLDER_ACTIONS[idx][0], domain); - v.addElement(newAction); - newAction.setCommand(FOLDER_ACTIONS[idx][4]); - newAction.setPrompt(true); // may as well always allow users chance to change command as its submitted - newAction.setRefresh(FOLDER_ACTIONS[idx][1].equals("true")); //$NON-NLS-1$ - newAction.setShow(true); - newAction.setSingleSelection(FOLDER_ACTIONS[idx][2].equals("true")); //$NON-NLS-1$ - newAction.setCollect(FOLDER_ACTIONS[idx][3].equals("true")); //$NON-NLS-1$ - newAction.setFileTypes(new String[] { "ALL" }); //$NON-NLS-1$ - } - if (vectorOfActions != null) return null; - // convert vector to array... - SystemUDActionElement[] actionArray = new SystemUDActionElement[v.size()]; - for (int idx = 0; idx < actionArray.length; idx++) - actionArray[idx] = (SystemUDActionElement) v.elementAt(idx); - return actionArray; - } - - /** - * This is an override point for subclasses to add system-specify default actions. - * <p> - * To simplify processing, subclasses should add their additional SystemUDActionElement - * objects to the given vector. - */ - protected void primeAdditionalDefaultUniversalActions(SystemUDActionManager actionMgr, ISystemProfile profile, Vector vectorOfActions) { - } - - /** - * Given this IBM-supplied named type, restore it to its IBM-supplied state - * @return true if all went well, false if it wasn't restore for some reason - */ - public boolean restoreDefaultType(SystemUDTypeElement element, int domain, String typeName) { - boolean ok = restoreUniversalDefaultType(element, domain, typeName); - if (!ok) ok = restoreAdditionalDefaultType(element, domain, typeName); - return ok; - } - - /** - * Given this IBM-supplied named type, restore it to its IBM-supplied state. - * This concrete method tests the commonly supplied universal types. - * @return true if all went well, false if it wasn't restore for some reason - */ - public static boolean restoreUniversalDefaultType(SystemUDTypeElement element, int domain, String typeName) { - boolean ok = false; - String[][] typesArray = IBM_DEFAULT_FILETYPES; - if (domain == DOMAIN_FOLDER) // no IBM types for folder. - typesArray = IBM_DEFAULT_FOLDERTYPES; - // first test the universal types... - int match = -1; - for (int idx = 0; (match == -1) && (idx < typesArray.length); idx++) { - if (typeName.equals(typesArray[idx][0])) match = idx; - } - if (match != -1) { - element.setName(typesArray[match][0]); - element.setTypes(typesArray[match][1]); - ok = true; - } - return ok; - } - - /** - * Given this IBM-supplied named type, restore it to its IBM-supplied state. - * This abstract method is for the subclasses. - * @return true if all went well, false if it wasn't restore for some reason - */ - protected boolean restoreAdditionalDefaultType(SystemUDTypeElement element, int domain, String typeName) { - return false; - } - - /** - * Given this IBM-supplied named action, restore it to its IBM-supplied state - * @return true if all went well, false if it wasn't restore for some reason - */ - public boolean restoreDefaultAction(SystemUDActionElement element, int domain, String typeName) { - boolean ok = restoreUniversalDefaultAction(element, domain, typeName); - if (!ok) ok = restoreAdditionalDefaultAction(element, domain, typeName); - return ok; - } - - /** - * Given this IBM-supplied named action, restore it to its IBM-supplied state. - * This concrete method tests the commonly supplied universal actions. - * @return true if all went well, false if it wasn't restore for some reason - */ - public static boolean restoreUniversalDefaultAction(SystemUDActionElement element, int domain, String actionName) { - boolean ok = false; - String[][] actionsArray = FILE_ACTIONS; - if (domain == DOMAIN_FOLDER) // no IBM types for folder. - actionsArray = FOLDER_ACTIONS; - // first test the universal types... - int match = -1; - for (int idx = 0; (match == -1) && (idx < actionsArray.length); idx++) { - if (actionName.equals(actionsArray[idx][0])) match = idx; - } - if (match != -1) { - element.setName(actionsArray[match][0]); - element.setPrompt(true); // may as well always allow users chance to change command as its submitted - element.setRefresh(actionsArray[match][1].equals("true")); //$NON-NLS-1$ - element.setShow(true); - element.setSingleSelection(actionsArray[match][2].equals("true")); //$NON-NLS-1$ - element.setCollect(actionsArray[match][3].equals("true")); //$NON-NLS-1$ - if (domain == DOMAIN_FOLDER) { - element.setFileTypes(new String[] { "ALL" }); //$NON-NLS-1$ - element.setCommand(actionsArray[match][4]); - } else { - element.setFileTypes(convertStringToArray(actionsArray[match][4])); - element.setCommand(actionsArray[match][5]); - } - ok = true; - } - return ok; - } - - /** - * Given this IBM-supplied named action, restore it to its IBM-supplied state. - * This abstract method is for the subclasses. - * @return true if all went well, false if it wasn't restore for some reason - */ - protected boolean restoreAdditionalDefaultAction(SystemUDActionElement element, int domain, String actionName) { - return false; - } - - /** - * Convert space-delimited string into array of strings - */ - protected static String[] convertStringToArray(String string) { - StringTokenizer tokens = new StringTokenizer(string); - Vector v = new Vector(); - while (tokens.hasMoreTokens()) { - v.addElement(tokens.nextToken()); - } - String[] strings = new String[v.size()]; - for (int idx = 0; idx < strings.length; idx++) - strings[idx] = (String) v.elementAt(idx); - return strings; - } - - /** - * We disable user defined actions if we are in work-offline mode. - * Currently, how we determine this is dependent on the subsystem factory. - */ - public boolean getWorkingOfflineMode() { - return false; // todo: change this when offline mode is supported for universal! - } - - /** - * Return the list of substitution variables for the given domain type. - * Called from edit pane in work with dialog. - * This must be overridden! - */ - public SystemCmdSubstVarList getActionSubstVarList(int actionDomainType) { - if (actionDomainType == DOMAIN_FOLDER) - return UDSubstListFolders.getInstance(); - else if (actionDomainType == DOMAIN_FILE) - return UDSubstListFiles.getInstance(); - else - return null; - } - - /** - * Given an action, and the currently selected remote objects, and the domain of those, - * return true if ALL of the selected remote objects matches any of the type criteria - * for this action - * <p> - * Override of parent - */ - protected boolean meetsSelection(SystemUDActionElement action, IStructuredSelection selection, int domainType) { - if (domainType == DOMAIN_FOLDER) return true; // no point in further testing because our getDomainFromSelection method already did this - String unresolvedActionTypes[] = action.getFileTypes(); - // fastpath for "ALL"! - if ((unresolvedActionTypes == null) || (unresolvedActionTypes.length == 0)) - return true; // what else to do? - else if (unresolvedActionTypes[0].equals("ALL")) //$NON-NLS-1$ - return true; - // flatten types - String[] actionTypes = resolveTypes(unresolvedActionTypes, domainType); - // create file type matcher - fileTypeMatcher = null; - if (domainType == DOMAIN_FILE) { - if (fileTypeMatcher == null) fileTypeMatcher = new FileTypeMatcher(null, getSubsystem().getSubSystemConfiguration().isCaseSensitive()); - fileTypeMatcher.setTypesAndNames(actionTypes); - } - Iterator elements = selection.iterator(); - Object element = null; - while (elements.hasNext()) { - element = elements.next(); - IRemoteFile file = (IRemoteFile) element; - // OK if matches any one of the file types for an action - boolean foundMatch = false; - if (domainType == DOMAIN_FOLDER) { - if (file.isDirectory()) foundMatch = true; - } else { - if (fileTypeMatcher.matches(file.getName())) foundMatch = true; - } - if (!foundMatch) return false; - } - return true; - } - - /** - * Parent override. - * <p> - * Compares a particular file type (not named, but actual scalar/generic type) - * to a specific user-selected remote object. - * Returns true if the object's information matches that of the given type - * <p> - * BECAUSE WE OVERRRIDE meetsSelection, THIS METHOD IS NEVER CALLED FOR US! - * - * @param actionType - an unnamed file type, as in "*.cpp" - * @param selectedObject - one of the currently selected remote objects - * @param domainType - integer representation of current domain - */ - protected boolean isMatch(Object actionType, Object selectedObject, int domainType) { - return true; - } - - // ----------------------------------------------- - // OVERRIDDEN METHODS RELATED TO DOMAIN SUPPORT... - // ----------------------------------------------- - /** - * Parent override. - * Determine domain, given the selection. - * Eg subsystem that supports domains has to do this via overriding this method. - * If domains not supported, return -1. - */ - protected int getDomainFromSelection(IStructuredSelection selection) { - int domain = -1; - Iterator elements = selection.iterator(); - if (elements.hasNext()) { - IRemoteFile currFile = (IRemoteFile) elements.next(); - if (currFile.isDirectory()) - domain = DOMAIN_FOLDER; - else - domain = DOMAIN_FILE; - } - return domain; - } - - /** - * Parent override. - * For efficiency reasons, internally we use an integer to represent a domain. - * However, that has to be mapped to a name which is actually what is stored as the - * "type" attribute for the xml domain node. - * This returns the maximum integer number supported by this action/type manager. - * Returns 1 for us. - */ - public int getMaximumDomain() { - return 1; - } - - /** - * Get the list of untranslated domain names - */ - public String[] getDomainNames() { - return DOMAINS; - } - - /** - * Get the list of translated domain names - */ - public String[] getXlatedDomainNames() { - return DOMAIN_NAME_STRING; - } - - /** - * Get the list of translated domain names for the tree view's "New" nodes - */ - public String[] getXlatedDomainNewNames() { - return DOMAIN_NEWNAME_STRING; - } - - /** - * Get the list of translated domain names for "new" nodes in tree view, for the WW Named Types dialog - */ - public String[] getXlatedDomainNewTypeNames() { - return DOMAIN_NEWNAME_STRING; - //return DOMAIN_NEWTYPENAME_STRING; // SHOULD NEVER BE CALLED - } - - /** - * Get the domain icon to show in the tree views - */ - public Image getDomainImage(int domain) { - if (domain == DOMAIN_FOLDER) - return RSEUIPlugin.getDefault().getImage(ISystemIconConstants.ICON_SYSTEM_FOLDER_ID); - //return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER); - else if (domain == DOMAIN_FILE) - //return RSEUIPlugin.getDefault().getImage(ISystemConstants.ICON_SYSTEM_FILE_ID); - return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FILE); - return null; - } - - /** - * Get the domain icon to show in the tree views, for the new item for this domain - */ - public Image getDomainNewImage(int domain) { - if (domain == DOMAIN_FOLDER) - return RSEUIPlugin.getDefault().getImage(ISystemIconConstants.ICON_SYSTEM_NEWFOLDER_ID); - //return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER); - else if (domain == DOMAIN_FILE) return RSEUIPlugin.getDefault().getImage(ISystemIconConstants.ICON_SYSTEM_NEWFILE_ID); - //return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FILE); - return null; - } - - /** - * Get the domain icon to show in the named type tree view, for the new item for this domain - */ - public Image getDomainNewTypeImage(int domain) { - return UserActionsIcon.USERTYPE_NEW.getImage(); - } - - /** - * Overridable method for child classes to supply the label to display in the - * "New" node for types. Typically only overriden if domains are not supported, as otherwise - * the child nodes of "New" have the specific labels. - * @return translated label for "New named type..." - */ - protected String getNewNodeTypeLabel() { - return SystemUDAResources.RESID_UDA_FILES_NEWNODE_LABEL; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/uda/UDActionSubsystemLocalFiles.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/uda/UDActionSubsystemLocalFiles.java deleted file mode 100644 index b10ef5be4..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/uda/UDActionSubsystemLocalFiles.java +++ /dev/null @@ -1,114 +0,0 @@ -package org.eclipse.rse.internal.useractions.files.uda; - -/******************************************************************************* - * Copyright (c) 2002, 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 - *******************************************************************************/ -import java.util.Vector; - -import org.eclipse.rse.core.model.ISystemProfile; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDActionElement; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDActionManager; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDTypeElement; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDTypeManager; - -/** - * This is a specialization of the universal files user action support, for - * stuff unique to Local files. - */ -public class UDActionSubsystemLocalFiles extends UDActionSubsystemFiles { - /** - * Constructor for UDActionSubsystemLocalFiles. - */ - public UDActionSubsystemLocalFiles() { - super(); - } - - /** - * Parent intercept for adding default pre-defined types that are unique to us. - */ - protected void primeAdditionalDefaultUniversalTypes(SystemUDTypeManager typeMgr, Vector vectorOfTypes) { - // I have decided not to include the iSeries unique types as there are user actions I can imagine for them, - // and they clutter up the namespace for non-iSeries users... - /* - // the following contains ONLY those types that are unique to local. - // for now these are only local copies of remote iSeries members - final String fileTypes[][] = - { - {"CBL_400", "cbl,cblle,lbl,sqlcblle" }, - {"CL_400", "clp,clle,cmd400,icl" }, - {"DDS_400", "dds,dspf,prtf,pf,lf,icff" }, - {"RPG_400", "rpg,rpgle,rpt" }, - }; - - for (int i = 0; i < fileTypes.length; i++) - { - SystemUDTypeElement ft = typeMgr.addType(DOMAIN_FILE, fileTypes[i][0]); - if (null == ft) - continue; - vectorOfTypes.addElement(ft); - ft.setTypes(fileTypes[i][1]); - } - */ - } - - /** - * Parent intercept for adding default pre-defined actions that are unique to us. - */ - protected void primeAdditionalDefaultUniversalActions(SystemUDActionManager actionMgr, ISystemProfile profile, Vector vectorOfActions) { - // duplicate the non-iseries types... - int domain = DOMAIN_FILE; - SystemUDActionElement newAction; - for (int idx = 0; idx < UDActionSubsystemUniversalFiles.UNIVERSAL_FILE_ACTIONS.length; idx++) { - newAction = actionMgr.addAction(profile, UDActionSubsystemUniversalFiles.UNIVERSAL_FILE_ACTIONS[idx][0], domain); - vectorOfActions.addElement(newAction); - newAction.setCommand(UDActionSubsystemUniversalFiles.UNIVERSAL_FILE_ACTIONS[idx][5]); - newAction.setPrompt(true); // may as well always allow users chance to change command as its submitted - newAction.setRefresh(UDActionSubsystemUniversalFiles.UNIVERSAL_FILE_ACTIONS[idx][1].equals("true")); //$NON-NLS-1$ - newAction.setShow(true); - newAction.setSingleSelection(UDActionSubsystemUniversalFiles.UNIVERSAL_FILE_ACTIONS[idx][2].equals("true")); //$NON-NLS-1$ - newAction.setCollect(UDActionSubsystemUniversalFiles.UNIVERSAL_FILE_ACTIONS[idx][3].equals("true")); //$NON-NLS-1$ - newAction.setFileTypes(convertStringToArray(UDActionSubsystemUniversalFiles.UNIVERSAL_FILE_ACTIONS[idx][4])); - } - // add actions unique to local... - } - - /** - * Parent intercept for restoring one of our unique IBM-supplied actions to its original state. - * @return true if all went well, false if it wasn't restore for some reason - */ - protected boolean restoreAdditionalDefaultAction(SystemUDActionElement element, int domain, String actionName) { - boolean ok = false; - if (domain == DOMAIN_FOLDER) return ok; - int match = -1; - for (int idx = 0; (match == -1) && (idx < UDActionSubsystemUniversalFiles.UNIVERSAL_FILE_ACTIONS.length); idx++) { - if (UDActionSubsystemUniversalFiles.UNIVERSAL_FILE_ACTIONS[idx][0].equals(actionName)) match = idx; - } - if (match != -1) { - element.setName(UDActionSubsystemUniversalFiles.UNIVERSAL_FILE_ACTIONS[match][0]); - element.setPrompt(true); // may as well always allow users chance to change command as its submitted - element.setRefresh(UDActionSubsystemUniversalFiles.UNIVERSAL_FILE_ACTIONS[match][1].equals("true")); //$NON-NLS-1$ - element.setShow(true); - element.setSingleSelection(UDActionSubsystemUniversalFiles.UNIVERSAL_FILE_ACTIONS[match][2].equals("true")); //$NON-NLS-1$ - element.setCollect(UDActionSubsystemUniversalFiles.UNIVERSAL_FILE_ACTIONS[match][3].equals("true")); //$NON-NLS-1$ - element.setFileTypes(convertStringToArray(UDActionSubsystemUniversalFiles.UNIVERSAL_FILE_ACTIONS[match][4])); - element.setCommand(UDActionSubsystemUniversalFiles.UNIVERSAL_FILE_ACTIONS[match][5]); - ok = true; - } - return ok; - } - - /** - * Override of parent method to restore unique type supplied by us, to its original state. - * @return true if all went well, false if it wasn't restore for some reason - */ - protected boolean restoreAdditionalDefaultType(SystemUDTypeElement element, int domain, String typeName) { - return false; // nothing unique - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/uda/UDActionSubsystemUniversalFiles.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/uda/UDActionSubsystemUniversalFiles.java deleted file mode 100644 index dbf085797..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/uda/UDActionSubsystemUniversalFiles.java +++ /dev/null @@ -1,113 +0,0 @@ -package org.eclipse.rse.internal.useractions.files.uda; - -/******************************************************************************* - * Copyright (c) 2002, 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 - *******************************************************************************/ -import java.util.Vector; - -import org.eclipse.rse.core.model.ISystemProfile; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDActionElement; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDActionManager; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDTypeElement; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDTypeManager; - -/** - * This is a specialization of the universal files user action support, for - * stuff unique to non-Local, non-IFS files. - */ -public class UDActionSubsystemUniversalFiles extends UDActionSubsystemFiles { - /** - * Universal non-iseries actions - */ - protected static final String UNIVERSAL_FILE_ACTIONS[][] = - // name, refresh, singleSel, collect, types, cmd - { - // these probably should be deleted, as these are more appropriate as compile commands - // {"gcc", "true", "false", "false", "CPP_COMPILABLE C_COMPILABLE","gcc -c ${resource_name} -o ${resource_name_root}.o"}, - // {"cc", "true", "false", "false", "CPP_COMPILABLE C_COMPILABLE","cc -c ${resource_name} -o ${resource_name_root}.o"}, - //{"IBM C", "true", "false", "false", "C_COMPILABLE", "xlc -c -qinfo=all ${resource_name} -o ${resource_name_root}.o"}, - //{"IBM C++","true", "false", "false", "CPP_COMPILABLE", "xlC -c -qinfo=all ${resource_name} -o ${resource_name_root}.o"}, - }; - - /** - * Constructor - */ - public UDActionSubsystemUniversalFiles() { - super(); - } - - /** - * Parent intercept for adding default pre-defined types that are unique to us. - */ - protected void primeAdditionalDefaultUniversalTypes(SystemUDTypeManager typeMgr, Vector vectorOfTypes) { - return; // nothing unique - } - - /** - * Parent intercept for adding default pre-defined actions that are unique to us. - */ - protected void primeAdditionalDefaultUniversalActions(SystemUDActionManager actionMgr, ISystemProfile profile, Vector vectorOfActions) { - // add file actions - int domain = DOMAIN_FILE; - SystemUDActionElement newAction; - for (int idx = 0; idx < UNIVERSAL_FILE_ACTIONS.length; idx++) { - newAction = actionMgr.addAction(profile, UNIVERSAL_FILE_ACTIONS[idx][0], domain); - vectorOfActions.addElement(newAction); - newAction.setCommand(UNIVERSAL_FILE_ACTIONS[idx][5]); - newAction.setPrompt(true); // may as well always allow users chance to change command as its submitted - newAction.setRefresh(UNIVERSAL_FILE_ACTIONS[idx][1].equals("true")); //$NON-NLS-1$ - newAction.setShow(true); - newAction.setSingleSelection(UNIVERSAL_FILE_ACTIONS[idx][2].equals("true")); //$NON-NLS-1$ - newAction.setCollect(UNIVERSAL_FILE_ACTIONS[idx][3].equals("true")); //$NON-NLS-1$ - newAction.setFileTypes(convertStringToArray(UNIVERSAL_FILE_ACTIONS[idx][4])); - } - } - - /** - * We disable user defined actions if we are in work-offline mode. - * Currently, how we determine this is dependent on the subsystem factory. - */ - public boolean getWorkingOfflineMode() { - return false; // todo... set to preferences setting when offline mode supported for universal - } - - /** - * Parent intercept for restoring one of our unique IBM-supplied actions to its original state. - * @return true if all went well, false if it wasn't restore for some reason - */ - protected boolean restoreAdditionalDefaultAction(SystemUDActionElement element, int domain, String actionName) { - boolean ok = false; - if (domain == DOMAIN_FOLDER) return ok; - int match = -1; - for (int idx = 0; (match == -1) && (idx < UNIVERSAL_FILE_ACTIONS.length); idx++) { - if (UNIVERSAL_FILE_ACTIONS[idx][0].equals(actionName)) match = idx; - } - if (match != -1) { - element.setName(UNIVERSAL_FILE_ACTIONS[match][0]); - element.setPrompt(true); // may as well always allow users chance to change command as its submitted - element.setRefresh(UNIVERSAL_FILE_ACTIONS[match][1].equals("true")); //$NON-NLS-1$ - element.setShow(true); - element.setSingleSelection(UNIVERSAL_FILE_ACTIONS[match][2].equals("true")); //$NON-NLS-1$ - element.setCollect(UNIVERSAL_FILE_ACTIONS[match][3].equals("true")); //$NON-NLS-1$ - element.setFileTypes(convertStringToArray(UNIVERSAL_FILE_ACTIONS[match][4])); - element.setCommand(UNIVERSAL_FILE_ACTIONS[match][5]); - ok = true; - } - return ok; - } - - /** - * Override of parent method to restore unique type supplied by us, to its original state. - * @return true if all went well, false if it wasn't restore for some reason - */ - protected boolean restoreAdditionalDefaultType(SystemUDTypeElement element, int domain, String typeName) { - return false; // nothing unique - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/uda/UDSubstListCommonFiles.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/uda/UDSubstListCommonFiles.java deleted file mode 100644 index 3e0da128c..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/uda/UDSubstListCommonFiles.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 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 - * Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods - *******************************************************************************/ -package org.eclipse.rse.internal.useractions.files.uda; - -import org.eclipse.rse.internal.useractions.ui.SystemCmdSubstVarList; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDASubstVarListCommon; - -/** - * Encapsulation of the common substitution variables for both folders and files. - * Superset of overall system common variables. - */ -public class UDSubstListCommonFiles extends SystemCmdSubstVarList { - /* from resource property file... - ...uda.files.subvar.resource_date = Last modified date of selected resource - ...uda.files.subvar.resource_name = Name of selected resource, unqualified - ...uda.files.subvar.resource_path = Path of selected resource, including name - ...uda.files.subvar.resource_path_root=Root of selected file's path. "c:\\" on Windows, or "/" on others - ...uda.files.subvar.resource_path_drive=Drive letter on Windows, empty string on others - ...uda.files.subvar.container_name=Name of folder containing selected resource, unqualified - ...uda.files.subvar.container_path=Path of folder containing selected resource, including name - */ - private static final String[] COMMON_VARNAMES = { "resource_date", //$NON-NLS-1$ - "resource_name", //$NON-NLS-1$ - "resource_path", //$NON-NLS-1$ - "resource_path_root", //$NON-NLS-1$ - "resource_path_drive", //$NON-NLS-1$ - "container_name", //$NON-NLS-1$ - "container_path" //$NON-NLS-1$ - }; - private static final String[] COMMON_DESCRIPTIONS = { SystemUDAResources.RESID_UDA_FILES_SUBVAR_RESOURCE_DATE, SystemUDAResources.RESID_UDA_FILES_SUBVAR_RESOURCE_NAME, - SystemUDAResources.RESID_UDA_FILES_SUBVAR_RESOURCE_PATH, SystemUDAResources.RESID_UDA_FILES_SUBVAR_RESOURCE_PATH_ROOT, SystemUDAResources.RESID_UDA_FILES_SUBVAR_RESOURCE_PATH_DRIVE, - SystemUDAResources.RESID_UDA_FILES_SUBVAR_CONTAINER_NAME, SystemUDAResources.RESID_UDA_FILES_SUBVAR_CONTAINER_PATH }; - private static UDSubstListCommonFiles inst = null; - - /** - * Constructor . - * Not to be used directly. Rather, use {@link #getInstance()}. - */ - UDSubstListCommonFiles() { - super(SystemUDASubstVarListCommon.getInstance(), COMMON_VARNAMES, COMMON_DESCRIPTIONS); - } - - /** - * Return the singleton of this object. No need ever for more than one instance - */ - public static UDSubstListCommonFiles getInstance() { - if (inst == null) inst = new UDSubstListCommonFiles(); - return inst; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/uda/UDSubstListFiles.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/uda/UDSubstListFiles.java deleted file mode 100644 index a05af1959..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/uda/UDSubstListFiles.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 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 - * Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods - *******************************************************************************/ -package org.eclipse.rse.internal.useractions.files.uda; - -import org.eclipse.rse.internal.useractions.ui.SystemCmdSubstVarList; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources; - -/** - * @author coulthar - * - * Substitution variables for folders. Superset of common list - */ -public class UDSubstListFiles extends SystemCmdSubstVarList { - /* from resource property file... - ...uda.files.subvar.resource_name_root=Name of selected resource without the extension - ...uda.files.subvar.resource_name_ext=Extension part of the name of the selected resource - */ - private static final String[] FILE_VARNAMES = { "resource_name_ext", //$NON-NLS-1$ - "resource_name_root" //$NON-NLS-1$ - }; - private static final String[] DESCRIPTIONS = { SystemUDAResources.RESID_UDA_FILES_SUBVAR_RESOURCE_NAME_EXT, SystemUDAResources.RESID_UDA_FILES_SUBVAR_RESOURCE_NAME_ROOT }; - private static UDSubstListFiles inst = null; - - /** - * Constructor . - * Not to be used directly. Rather, use {@link #getInstance()}. - */ - UDSubstListFiles() { - super(UDSubstListCommonFiles.getInstance(), FILE_VARNAMES, DESCRIPTIONS); - testForDuplicates(); - } - - /** - * Return the singleton of this object. No need ever for more than one instance - */ - public static UDSubstListFiles getInstance() { - if (inst == null) inst = new UDSubstListFiles(); - return inst; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/uda/UDSubstListFolders.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/uda/UDSubstListFolders.java deleted file mode 100644 index 8c05fd0fc..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/uda/UDSubstListFolders.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 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 - * Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods - *******************************************************************************/ -package org.eclipse.rse.internal.useractions.files.uda; - -import org.eclipse.rse.internal.useractions.ui.SystemCmdSubstVarList; - -/** - * @author coulthar - * - * Substitution variables for folders. Superset of common list - */ -public class UDSubstListFolders extends SystemCmdSubstVarList { - private static final String[] FOLDER_VARNAMES = {}; - private static final String[] DESCRIPTIONS = {}; - private static UDSubstListFolders inst = null; - - /** - * Constructor . - * Not to be used directly. Rather, use {@link #getInstance()}. - */ - UDSubstListFolders() { - super(UDSubstListCommonFiles.getInstance(), FOLDER_VARNAMES, DESCRIPTIONS); - testForDuplicates(); - } - - /** - * Return the singleton of this object. No need ever for more than one instance - */ - public static UDSubstListFolders getInstance() { - if (inst == null) inst = new UDSubstListFolders(); - return inst; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/uda/UDTypesEditPaneFiles.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/uda/UDTypesEditPaneFiles.java deleted file mode 100644 index 7166171b4..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/uda/UDTypesEditPaneFiles.java +++ /dev/null @@ -1,69 +0,0 @@ -package org.eclipse.rse.internal.useractions.files.uda; - -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - *******************************************************************************/ -import org.eclipse.rse.internal.useractions.ui.uda.ISystemUDAEditPaneHoster; -import org.eclipse.rse.internal.useractions.ui.uda.ISystemUDTreeView; -import org.eclipse.rse.internal.useractions.ui.uda.ISystemUDTypeEditPaneTypesSelector; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDActionSubsystem; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDTypeEditPane; -import org.eclipse.swt.widgets.Composite; - -/** - * @author coulthar - * - * This is a refinement of the generic edit pane for defining - * new named file types, specifialized for universal files. - * Specifically, it overrides the editor used to select/specify - * the individual types that constitute the named type. - */ -public class UDTypesEditPaneFiles extends SystemUDTypeEditPane { - /** - * Constructor for UDTypesEditPaneFiles. - * @param udaActionSubsys User Defined Action subsystem - * @param parent any dialog or property page that wants to host a user action edit pane. - * @param tv User Defined Action tree view - */ - public UDTypesEditPaneFiles(SystemUDActionSubsystem udaActionSubsys, ISystemUDAEditPaneHoster parent, ISystemUDTreeView tv) { - super(udaActionSubsys, parent, tv); - } - - /** - * Overridable exit point. - * Return true if the types are to be auto-uppercased. - * We return false - */ - protected boolean getAutoUpperCaseTypes() { - return false; - } - - /** - * Overridable exit point from parent. - * Create the edit widgets that will allow the user to see and - * edit the list of file types that constitute this named type. - * <p> - * To better facilitate this, the only requirement is that this - * "editor" meet the minimal interface - * {@link org.eclipse.rse.internal.useractions.ui.uda.ISystemUDTypeEditPaneTypesSelector} - * <p> - * Our implementation is to return an instance of our custom UDDTypesEditorFiles class. - * - * @param parent - the parent composite where the widgets are to go - * @param nbrColumns - the number of columns in the parent composite, which these - * widgets should span - * @return a class implementing the required interface - */ - protected ISystemUDTypeEditPaneTypesSelector createTypesListEditor(Composite parent, int nbrColumns) { - UDTypesEditorFiles ourEditor = new UDTypesEditorFiles(parent, nbrColumns); - //ourEditor.setAutoUpperCase(getAutoUpperCaseTypes()); - return ourEditor; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/uda/UDTypesEditorFiles.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/uda/UDTypesEditorFiles.java deleted file mode 100644 index 9e09517a7..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/uda/UDTypesEditorFiles.java +++ /dev/null @@ -1,591 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - * David Dykstal (IBM) - [186589] move user types, user actions, and compile commands - * API to the user actions plugin - * David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared - *******************************************************************************/ -package org.eclipse.rse.internal.useractions.files.uda; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.StringTokenizer; -import java.util.Vector; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.viewers.CheckStateChangedEvent; -import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.jface.viewers.ICheckStateListener; -import org.eclipse.rse.internal.useractions.Activator; -import org.eclipse.rse.internal.useractions.IUserActionsMessageIds; -import org.eclipse.rse.internal.useractions.UserActionsResources; -import org.eclipse.rse.internal.useractions.ui.uda.ISystemUDTypeEditPaneTypesSelector; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources; -import org.eclipse.rse.services.clientserver.messages.SimpleSystemMessage; -import org.eclipse.rse.services.clientserver.messages.SystemMessage; -import org.eclipse.rse.subsystems.files.core.model.RemoteFileFilterString; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.SystemWidgetHelpers; -import org.eclipse.rse.ui.messages.ISystemMessageLine; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.IFileEditorMapping; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.dialogs.FileEditorMappingContentProvider; -import org.eclipse.ui.dialogs.FileEditorMappingLabelProvider; - -/** - * This class implements the interface needed to supply - * custom widgets allowing the user to specify the file types - * for a named file type, in the Work With File Types dialog - */ -public class UDTypesEditorFiles implements ISystemUDTypeEditPaneTypesSelector, ICheckStateListener { - public static final String NO_EXTENSION_PLACEHOLDER = UDActionSubsystemFiles.NO_EXTENSION_PLACEHOLDER; - // gui widgets - private CheckboxTableViewer typesSelectionList; - //private Label typesSelectionListVerbage; - //private Button addTypesButton; - //private Text definedTypesText; - private Label definedTypesLabel; - private Text userDefinedText; - private Label nonEditableVerbage; - private Composite typesComposite; - // state - private java.util.List inpTypes; - private IFileEditorMapping[] currentInput; - private int currentDomain; - private boolean ignoreModifyEvents = false; - // constants - private static final int LIST_HEIGHT = 150; - private static final int LIST_WIDTH = 50; - private static final String TYPE_DELIMITER = ","; //GenericMessages.getString("TypesFiltering.typeDelimiter"); //$NON-NLS-1$ - // registered listeners - private Vector listeners = new Vector(); - - /** - * Constructor for UDTypesEditorFiles. - */ - public UDTypesEditorFiles(Composite comp, int nbrColumns) //, SystemPromptDialog parentDialog) - { - super(); - // List of currently selected types if given parent composite has 2 columns - if (nbrColumns == 2) { - //definedTypesText = - // SystemWidgetHelpers.createLabeledTextField(comp, null, rb, RESID_UDT_FILES_DEFINEDTYPES_ROOT); - definedTypesLabel = SystemWidgetHelpers.createLabeledLabel(comp, SystemUDAResources.RESID_UDT_FILES_DEFINEDTYPES_LABEL, SystemUDAResources.RESID_UDT_FILES_DEFINEDTYPES_TOOLTIP, true); - } - nonEditableVerbage = SystemWidgetHelpers.createVerbiage(comp, "", nbrColumns, false, 350); //$NON-NLS-1$ - nonEditableVerbage.setVisible(false); - //typesComposite = SystemWidgetHelpers.createGroupComposite(comp, 1, rb.getString(RESID_UDT_FILES_TYPESGROUP_ROOT_LABEL); - typesComposite = SystemWidgetHelpers.createTightComposite(comp, 1); - typesComposite.setToolTipText(SystemUDAResources.RESID_UDT_FILES_TYPESGROUP_TOOLTIP); - ((GridData) typesComposite.getLayoutData()).horizontalSpan = nbrColumns; - nbrColumns = 1; - // List of currently selected types if given parent composite did not have 2 columns - if (definedTypesLabel == null) - //definedTypesText = - // SystemWidgetHelpers.createLabeledTextField(typesComposite, null, rb, RESID_UDT_FILES_DEFINEDTYPES_ROOT); - definedTypesLabel = SystemWidgetHelpers.createLabeledLabel(typesComposite, SystemUDAResources.RESID_UDT_FILES_DEFINEDTYPES_LABEL, SystemUDAResources.RESID_UDT_FILES_DEFINEDTYPES_TOOLTIP, - true); - //definedTypesLabel.setEnabled(false); - definedTypesLabel.setForeground(definedTypesLabel.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY)); - //definedTypesText = - // SystemWidgetHelpers.createReadonlyTextField(typesComposite, rb, RESID_UDT_FILES_DEFINEDTYPES_ROOT); - //definedTypesText.setToolTipText(""); - //definedTypesText.setVisible(false); - // types selection label - //typesSelectionListVerbage = - // SystemWidgetHelpers.createLabel(typesComposite, rb, RESID_UDT_TYPESLIST_LABEL_ROOT, nbrColumns, false); - // types selection list - //typesSelectionList = CheckboxTableViewer.newCheckList(comp, SWT.BORDER); - Table table = new Table(typesComposite, SWT.CHECK | SWT.BORDER); - table.setToolTipText(SystemUDAResources.RESID_UDT_FILES_TYPESGROUP_TOOLTIP); - typesSelectionList = new CheckboxTableViewer(table); - GridData data = new GridData(GridData.FILL_BOTH); - data.horizontalSpan = nbrColumns; - data.heightHint = LIST_HEIGHT; - data.widthHint = LIST_WIDTH; - //data.grabExcessHorizontalSpace = false; - //data.grabExcessVerticalSpace = false; - typesSelectionList.getTable().setLayoutData(data); - typesSelectionList.setLabelProvider(FileEditorMappingLabelProvider.INSTANCE); - typesSelectionList.setContentProvider(FileEditorMappingContentProvider.INSTANCE); - addSelectionButtons(typesComposite); - Composite userComp = createUserEntryGroup(typesComposite); - ((GridData) userComp.getLayoutData()).horizontalSpan = nbrColumns; - // configure widgets... - initializeViewer(); - //if ((this.initialSelections != null) && !this.initialSelections.isEmpty()) - // checkInitialSelections(); - typesSelectionList.addCheckStateListener(this); - } - - /** - * Set domain. - * The edit pane may possibly appear differently, depending on the domain. - * When the domain changes (either in "new" or "edit" mode) this method is called. - */ - public void setDomain(int domain) { - this.currentDomain = domain; - } - - /** - * Set the message line for issuing msgs to - */ - public void setMessageLine(ISystemMessageLine msgLine) { - } - - /** - * Return the domain of the currently selected existing named type, or "new" node - */ - public int getDomain() { - return currentDomain; - } - - /** - * @see org.eclipse.rse.internal.useractions.ui.uda.ISystemUDTypeEditPaneTypesSelector#setTypes(String) - */ - public void setTypes(String types) { - //this.inpTypes = types; - if (types == null) { - setTypes((String[]) null); - } else { - setTypes(RemoteFileFilterString.parseTypes(types)); - setDefinedTypesText(types); - } - } - - /** - * Set defined types text - */ - private void setDefinedTypesText(String types) { - definedTypesLabel.setText(" " + types); //$NON-NLS-1$ - definedTypesLabel.setToolTipText(types); - //definedTypesText.setText(types); - } - - /** - * Clear defined types text - */ - private void clearDefinedTypesText() { - definedTypesLabel.setText(""); //$NON-NLS-1$ - definedTypesLabel.setToolTipText(""); //$NON-NLS-1$ - //definedTypesText.setText(""); - } - - /** - * Set the types via an array - */ - private void setTypes(String[] types) { - clearTypes(); - if (types != null) { - this.inpTypes = Arrays.asList(types); - ignoreModifyEvents = true; - checkInitialSelections(); - ignoreModifyEvents = false; - } - } - - /** - * @see org.eclipse.rse.internal.useractions.ui.uda.ISystemUDTypeEditPaneTypesSelector#clearTypes() - */ - public void clearTypes() { - ignoreModifyEvents = true; - this.inpTypes = null; - typesSelectionList.setAllChecked(false); - clearDefinedTypesText(); - userDefinedText.setText(""); //$NON-NLS-1$ - ignoreModifyEvents = false; - } - - /** - * @see org.eclipse.rse.internal.useractions.ui.uda.ISystemUDTypeEditPaneTypesSelector#getTypes() - */ - public String getTypes() { - return RemoteFileFilterString.getTypesString(getTypesAsArray()); - } - - /** - * @see org.eclipse.rse.internal.useractions.ui.uda.ISystemUDTypeEditPaneTypesSelector#getTypes() - */ - public String[] getTypesAsArray() { - java.util.List selectedEntries = getSelectedTypes(); - String[] seldArray = new String[selectedEntries.size()]; - for (int idx = 0; idx < seldArray.length; idx++) - seldArray[idx] = (String) selectedEntries.get(idx); - return seldArray; - } - - /** - * @see org.eclipse.rse.internal.useractions.ui.uda.ISystemUDTypeEditPaneTypesSelector#addModifyListener(ModifyListener) - */ - public void addModifyListener(ModifyListener listener) { - listeners.add(listener); - } - - /** - * @see org.eclipse.rse.internal.useractions.ui.uda.ISystemUDTypeEditPaneTypesSelector#removeModifyListener(ModifyListener) - */ - public void removeModifyListener(ModifyListener listener) { - listeners.remove(listener); - } - - /** - * @see org.eclipse.rse.internal.useractions.ui.uda.ISystemUDTypeEditPaneTypesSelector#validate() - */ - public SystemMessage validate() { - if (typesSelectionList == null) return null; - - - - if (!areTypesSelected()) { - return new SimpleSystemMessage(Activator.PLUGIN_ID, - IUserActionsMessageIds.MSG_VALIDATE_UDTTYPES_EMPTY, - IStatus.ERROR, - UserActionsResources.MSG_VALIDATE_UDTTYPES_EMPTY, - UserActionsResources.MSG_VALIDATE_UDTTYPES_EMPTY_DETAILS); - } - // validate that user-defined entry field! - return validateUserDefinedTypes(); - } - - /** - * Validate the contents of the user-defined types entry field - */ - public SystemMessage validateUserDefinedTypes() { - String filename = userDefinedText.getText().trim(); - // copied from SystemSelectFileTypes... - // check for empty name and extension - if (filename.length() == 0) return null; - // check for empty extension if there is no name - int index = filename.indexOf('.'); - if (index == filename.length() - 1) { - if (index == 0 || (index == 1 && filename.charAt(0) == '*')) { - return new SimpleSystemMessage(Activator.PLUGIN_ID, - IUserActionsMessageIds.MSG_VALIDATE_UDTTYPES_NOTVALID, - IStatus.ERROR, - UserActionsResources.MSG_VALIDATE_UDTTYPES_NOTVALID, - UserActionsResources.MSG_VALIDATE_UDTTYPES_NOTVALID_DETAILS); - } - } - int startScan = 0; - if (filename.startsWith("*.")) //$NON-NLS-1$ - startScan = 2; - // check for characters before * - // or no other characters - // or next character not '.' - index = filename.indexOf('*', startScan); - if (index > -1) { - if (filename.length() == 1) { - return new SimpleSystemMessage(Activator.PLUGIN_ID, - IUserActionsMessageIds.MSG_VALIDATE_UDTTYPES_NOTVALID, - IStatus.ERROR, - UserActionsResources.MSG_VALIDATE_UDTTYPES_NOTVALID, - UserActionsResources.MSG_VALIDATE_UDTTYPES_NOTVALID_DETAILS); - } - if (index != 0 || filename.charAt(1) != '.') { - return new SimpleSystemMessage(Activator.PLUGIN_ID, - IUserActionsMessageIds.MSG_VALIDATE_UDTTYPES_NOTVALID, - IStatus.ERROR, - UserActionsResources.MSG_VALIDATE_UDTTYPES_NOTVALID, - UserActionsResources.MSG_VALIDATE_UDTTYPES_NOTVALID_DETAILS); - } - } - return null; - } - - /** - * @see org.eclipse.rse.internal.useractions.ui.uda.ISystemUDTypeEditPaneTypesSelector#getControl() - */ - public Control getControl() { - return typesSelectionList.getControl(); - } - - /** - * Enable or disable the input-capability of the constituent controls - */ - public void setEnabled(boolean enable) { - typesSelectionList.getControl().setEnabled(enable); - userDefinedText.setEnabled(enable); - } - - /** - * We want to disable editing of IBM or vendor-supplied - * types, so when one of these is selected, this method is - * called to enter non-editable mode. - * @param editable Whether to disable editing of this type or not - * @param vendor When disabling, it contains the name of the vendor for substitution purposes - */ - public void setEditable(boolean editable, String vendor) { - //setEnabled(editable); - typesComposite.setVisible(editable); - if (editable) - nonEditableVerbage.setVisible(false); - else { - nonEditableVerbage.setVisible(true); - if (vendor.equals("IBM")) //$NON-NLS-1$ - nonEditableVerbage.setText(SystemUDAResources.RESID_UDT_IBM_VERBAGE); - else { - String verbage = SystemUDAResources.RESID_UDT_VENDOR_VERBAGE; - verbage = SystemMessage.sub(verbage, "%1", vendor); //$NON-NLS-1$ - nonEditableVerbage.setText(verbage); - } - } - } - - // private methods... - /** - * Fire event to all listeners... - */ - private void fireModifiedEvent() { - Event event = new Event(); - event.widget = getControl(); - event.type = SWT.Modify; - event.data = this; - ModifyEvent mEvent = new ModifyEvent(event); - for (int idx = 0; idx < listeners.size(); idx++) { - ModifyListener l = (ModifyListener) listeners.elementAt(idx); - //System.out.println("...firing modify event"); - l.modifyText(mEvent); - } - setDefinedTypesText(getTypes()); - } - - /** - * From ICheckStateListener interface. - * Called when user checks/unchecks an item - */ - public void checkStateChanged(CheckStateChangedEvent event) { - //System.out.println("inside checkStateChanged"); - if (!ignoreModifyEvents) fireModifiedEvent(); - ignoreModifyEvents = false; // non-sticky - } - - // -------------------------------------------- - // Similar to org.eclipse.ui.dialogs.TypeFilteringDialog - // -------------------------------------------- - /** - * Add the selection and deselection buttons to the dialog. - * @param composite org.eclipse.swt.widgets.Composite - */ - private void addSelectionButtons(Composite composite) { - /* - Composite buttonComposite = new Composite(composite, SWT.RIGHT); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - buttonComposite.setLayout(layout); - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.GRAB_HORIZONTAL); - data.grabExcessHorizontalSpace = true; - composite.setData(data); - - Button selectButton = createButton(buttonComposite, IDialogConstants.SELECT_ALL_ID, GenericMessages.getString("WizardTransferPage.selectAll"), false); //$NON-NLS-1$ - - SelectionListener listener = new SelectionAdapter() - { - public void widgetSelected(SelectionEvent e) { - typesSelectionList.setAllChecked(true); - } - }; - selectButton.addSelectionListener(listener); - - Button deselectButton = createButton(buttonComposite, IDialogConstants.DESELECT_ALL_ID, GenericMessages.getString("WizardTransferPage.deselectAll"), false); //$NON-NLS-1$ - - listener = new SelectionAdapter() - { - public void widgetSelected(SelectionEvent e) { - typesSelectionList.setAllChecked(false); - - } - }; - deselectButton.addSelectionListener(listener); - */ - } - - protected static Button createPushButton(Composite group, String label, String tooltip) { - Button button = createPushButton(group, label); - button.setToolTipText(tooltip); - return button; - } - - public static Button createPushButton(Composite group, String label) { - Button button = new Button(group, SWT.PUSH); - button.setText(label); - //button.setText("THIS IS A LONG LABEL. I MEAN, IT IS JUST HUGE!"); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - button.setLayoutData(data); - return button; - } - - /** - * Add the currently-specified extensions. - */ - private void addUserDefinedEntries(java.util.List result) { - StringTokenizer tokenizer = new StringTokenizer(userDefinedText.getText(), TYPE_DELIMITER); - //Allow the *. and . prefix and extract the extension - while (tokenizer.hasMoreTokens()) { - String currentExtension = tokenizer.nextToken().trim(); - if (!currentExtension.equals("")) //$NON-NLS-1$ - { - if (currentExtension.startsWith("*."))//$NON-NLS-1$ - result.add(currentExtension.substring(2)); - else { - if (currentExtension.startsWith("."))//$NON-NLS-1$ - result.add(currentExtension.substring(1)); - else - result.add(currentExtension); - } - } - } - } - - /** - * Visually checks the previously-specified elements in this dialog's list viewer. - */ - private void checkInitialSelections() { - if ((inpTypes == null) || (inpTypes.size() == 0)) return; - IFileEditorMapping editorMappings[] = PlatformUI.getWorkbench().getEditorRegistry().getFileEditorMappings(); - ArrayList selectedMappings = new ArrayList(); - for (int i = 0; i < editorMappings.length; i++) { - IFileEditorMapping mapping = editorMappings[i]; - if (inpTypes.contains(mapping.getLabel())) { - typesSelectionList.setChecked(mapping, true); - selectedMappings.add(mapping.getLabel()); - } else { - //System.out.println("name = '" + mapping.getName() + "', label = '" + mapping.getLabel() + "', ext = '" + mapping.getExtension() + "'"); - if (mapping.getName().equals("*")) //$NON-NLS-1$ - { - if (inpTypes.contains(mapping.getExtension())) { - typesSelectionList.setChecked(mapping, true); - selectedMappings.add(mapping.getExtension()); - } - } else if (mapping.getExtension().equals("")) // extension-less name like "makefile" //$NON-NLS-1$ - { - if (inpTypes.contains(mapping.getName() + NO_EXTENSION_PLACEHOLDER)) { - typesSelectionList.setChecked(mapping, true); - selectedMappings.add(mapping.getName() + NO_EXTENSION_PLACEHOLDER); - } - } - } - } - //Now add in the ones not selected to the user defined list - Iterator initialIterator = inpTypes.iterator(); - StringBuffer entries = new StringBuffer(); - while (initialIterator.hasNext()) { - String nextExtension = (String) initialIterator.next(); - if (!selectedMappings.contains(nextExtension)) { - entries.append(nextExtension); - entries.append(','); - } - } - this.userDefinedText.setText(entries.toString()); - } - - /** - * Create the group that shows the user defined entries for the dialog. - * @param parent the parent this is being created in. - */ - private Composite createUserEntryGroup(Composite parent) { - // destination specification group - int nbrColumns = 2; - Composite composite = SystemWidgetHelpers.createFlushComposite(parent, nbrColumns); - userDefinedText = SystemWidgetHelpers.createLabeledTextField(composite, null, SystemUDAResources.RESID_UDT_FILES_USERTYPES_LABEL, SystemUDAResources.RESID_UDT_FILES_USERTYPES_TOOLTIP); - userDefinedText.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - if (!ignoreModifyEvents) fireModifiedEvent(); - ignoreModifyEvents = false; // non-sticky flag - } - }); - SystemWidgetHelpers.setHelp(userDefinedText, RSEUIPlugin.HELPPREFIX + "wwnt0002"); //$NON-NLS-1$ - return composite; - } - - /** - * Return the input to the dialog. - */ - private IFileEditorMapping[] getInput() { - //Filter the mappings to be just those with a wildcard extension - // Hmm, why does Eclipse do this? Phil - if (currentInput == null) { - currentInput = - //IFileEditorMapping [] allMappings = - PlatformUI.getWorkbench().getEditorRegistry().getFileEditorMappings(); - //java.util.List wildcardEditors = new ArrayList(); - //for (int i = 0; i < allMappings.length; i++) - //{ - //if (allMappings[i].getName().equals("*"))//$NON-NLS-1$ - //wildcardEditors.add(allMappings[i]); - //} - //currentInput = new IFileEditorMapping[wildcardEditors.size()]; - //wildcardEditors.toArray(currentInput); - } - return currentInput; - } - - /** - * Initializes this dialog's viewer after it has been laid out. - */ - private void initializeViewer() { - typesSelectionList.setInput(getInput()); - } - - /** - * Return the currently selected items as a java.util.List of Strings - */ - protected java.util.List getSelectedTypes() { - // Get the input children. - IFileEditorMapping[] children = getInput(); - java.util.List list = new ArrayList(); - // Build a list of selected children. - for (int i = 0; i < children.length; ++i) { - IFileEditorMapping element = children[i]; - if (typesSelectionList.getChecked(element)) { - if (element.getName().equals("*")) //$NON-NLS-1$ - list.add(element.getExtension()); - else if (element.getExtension().equals("")) //$NON-NLS-1$ - list.add(element.getName() + NO_EXTENSION_PLACEHOLDER); - else - list.add(element.getLabel()); - } - } - addUserDefinedEntries(list); - //setResult(list); - return list; - } - - /** - * Return true if there are any types currently selected - */ - protected boolean areTypesSelected() { - // Get the input children. - IFileEditorMapping[] children = getInput(); - // Test list of selected children. - for (int i = 0; i < children.length; ++i) { - IFileEditorMapping element = children[i]; - if (typesSelectionList.getChecked(element)) { - return true; - } - } - String udtText = userDefinedText.getText().trim(); - if (udtText.length() == 0) return false; - //StringTokenizer tokenizer = - // new StringTokenizer(udtText, TYPE_DELIMITER); - //return tokenizer.hasMoreTokens(); - return true; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/ISystemCommandTextAdditionalGUIProvider.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/ISystemCommandTextAdditionalGUIProvider.java deleted file mode 100644 index d4be8029f..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/ISystemCommandTextAdditionalGUIProvider.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 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.ui; - -import org.eclipse.swt.widgets.Composite; - -/** - * Interface that is to be implemented by anyone interested in - * supplying additional gui, beyond the default, to the command text widget. - */ -public interface ISystemCommandTextAdditionalGUIProvider { - /** - * Overridable entry point for subclasses that wish to put something to the right of the "Command:" label - * @return true if something entered to take up the available columns, false otherwise (will be padded) - */ - public boolean createCommandLabelLineControls(Composite parent, int availableColumns); - - /** - * Create additional buttons, to go under command prompt. - * Overridable. - * @return true if something entered to take up the available columns, false otherwise (will be padded) - */ - public boolean createExtraButtons(Composite parent, int availableColumns); -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/ISystemSubstitutor.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/ISystemSubstitutor.java deleted file mode 100644 index 3e6633df7..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/ISystemSubstitutor.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui; - -/******************************************************************************* - * Copyright (c) 2002, 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 - *******************************************************************************/ -/** - * Objects implementing this interface are passed to - * {@link SystemCmdSubstVarList} parse a given command - * string for variables defined in the substitution list. - * For each match, this object is called back to retrieve - * the substition value, given the variable name (including - * its prefix). It will also pass back the context object - * given to it. Presumably this is a currently selected object. - */ -public interface ISystemSubstitutor { - /** - * Return the string to substitute for the given substitution - * variable, given the current context object. This object will - * be passed whatever was passed into the doSubstitution method. - * <p>It is VERY IMPORTANT to return null if you can't do the - * substitution for some reason! This is a clue to the algorithm - * that no change was made and increases performance. - */ - public String getSubstitutionValue(String substitutionVariable, Object context); -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/SystemCmdSubstVar.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/SystemCmdSubstVar.java deleted file mode 100644 index 2f186feba..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/SystemCmdSubstVar.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui; - -/******************************************************************************* - * Copyright (c) 2002, 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 - *******************************************************************************/ -/** - * @author coulthar - * - * This class encapsulates a single substitution variable. - * Such a variable has the following information: - * <ol> - * <li>The actual variable, as in "&L" - * <li>A translated description of the variable, as in "Library name" - * <li>A display string, which is typically a concatenation of the above two attributes - * </ol> - * Currently this class is not used at runtime to do the actual substitution, - * although that would be a natural next step. - */ -public class SystemCmdSubstVar implements Comparable { - private String var, desc; - - // public constants - /** - * Constructor - */ - public SystemCmdSubstVar(String variable, String description) { - super(); - this.var = variable; - this.desc = description; - } - - /** - * Return the substitution variable. Eg "&x" or "${xxxx}" - */ - public String getVariable() { - return var; - } - - /** - * Return the description. Eg "File name" - */ - public String getDescription() { - return desc; - } - - /** - * Return the display string. Eg var " - " description - */ - public String getDisplayString() { - return var + " - " + desc; //$NON-NLS-1$ - } - - // comparable interface method, to enable sorting - /** - * Compare ourself to another instance of this class - * @return -1 we are less than given object, 0 we are equal, 1 we are greater than - */ - public int compareTo(Object o) { - /* only re-use this when we want to bubble longer names to top... - SystemUDASubstVar other = (SystemUDASubstVar)o; - if (var.equals(other.getVariable())) - return 0; - else if (var.length() > other.getVariable().length()) - return -1; // we want longer names at the beginning of an ascending list! - else - return 1; - */ - return var.compareTo(((SystemCmdSubstVar) o).getVariable()); - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/SystemCmdSubstVarList.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/SystemCmdSubstVarList.java deleted file mode 100644 index 15a9e57b6..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/SystemCmdSubstVarList.java +++ /dev/null @@ -1,292 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui; - -/******************************************************************************* - * Copyright (c) 2002, 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 - *******************************************************************************/ -import java.io.PrintWriter; -import java.util.Arrays; - -/** - * @author coulthar - * - * This encapsulates a list of substitution variables. - * The input for the list is the variable prefix (eg "&"), an - * array of variable names (eg "A", "B", etc), plus the - * resource bundle and key-root for getting the variable - * descriptions (will append variable names to the key-root - * to get the resource bundle key). - * <p> - * This class is also used to help with the actual substitutions - * at runtime. The method doSubstitutions will walk the given - * string looking for matches on any of the variables in this - * list, taking care to look for the longer-named variables first, - * and when a match is found, will call back to the given - * implementor of ISystemSubstitutor, to get the substitution - * value. The substitutor will be given the variable name (eg, "N", - * not "&N") and whatever context object was passed into - * doSubstitutions, presumably one of the currently selected - * objects. - */ -public class SystemCmdSubstVarList { - private SystemCmdSubstVar[] list, sortedList; - private char prefix = ' '; - private boolean usingDelimiters = false; - // constants - /** - * Typical substitution variable prefix when using single prefix char: '&' - */ - public static final char SUBST_PREFIX_AMP = '&'; - /** - * Typical substitution variable char prefix when using delimiters: "$" - */ - public static final char SUBST_PREFIX_DOLLAR = '$'; - /** - * Typical substitution variable char prefix when using delimiters: "{" - */ - public static final char SUBST_PREFIX_BRACE = '}'; - /** - * Typical substitution variable string prefix when using delimiters: "{" - */ - public static final String SUBST_PREFIX = "${"; //$NON-NLS-1$ - /** - * Typical substitution variable char suffix when using delimiters: "}" - */ - public static final char SUBST_SUFFIX_BRACE = '}'; - - /** - * Constructor when using single prefix like '&' - */ - public SystemCmdSubstVarList(char prefix, String[] names, String[] descriptions) { - this(null, prefix, names, descriptions); - } - - /** - * Constructor when using single prefix like '&', and based on another list - * Sometimes a substitution variable list contains common variables, plus some unique variables. - * In this case, use this construction, and pass in the list object for the common variables. - */ - public SystemCmdSubstVarList(SystemCmdSubstVarList commonList, char prefix, String[] names, String[] descriptions) { - super(); - this.prefix = prefix; - init(commonList, names, descriptions); - } - - /** - * Constructor when using ${xxx} delimiting, and not based on another list - */ - public SystemCmdSubstVarList(String[] names, String[] descriptions) { - this(null, names, descriptions); - } - - /** - * Constructor when using ${xxx} delimiting, and we are based on another list - */ - public SystemCmdSubstVarList(SystemCmdSubstVarList commonList, String[] names, String[] descriptions) { - super(); - usingDelimiters = true; - prefix = SUBST_PREFIX_DOLLAR; - init(commonList, names, descriptions); - } - - /** - * Abstraction of common stuff done by all constructors. - */ - public void init(SystemCmdSubstVarList commonList, String[] names, String[] descriptions) { - SystemCmdSubstVar[] commonArray = null; - int idx = 0; - if (commonList == null) - list = new SystemCmdSubstVar[names.length]; - else { - commonArray = commonList.getListAsArray(); - list = new SystemCmdSubstVar[commonArray.length + names.length]; - for (; idx < commonArray.length; idx++) - list[idx] = commonArray[idx]; - } - String varName = null; - String description = null; - for (int jdx = 0; jdx < names.length; idx++, jdx++) { - if (!usingDelimiters) { - varName = prefix + names[jdx]; - } else { - varName = SUBST_PREFIX + names[jdx] + SUBST_SUFFIX_BRACE; - } - description = descriptions[jdx]; - list[idx] = new SystemCmdSubstVar(varName, description); - } - // sort list alphabetically... - Arrays.sort(list); - // for testing... - /* - System.out.println("Sorted list: "); - for (int jdx=0; jdx<list.length; jdx++) - System.out.println("..."+list[jdx].getVariable()); - System.out.println(); - */ - } - - /** - * Return the list of variables as an array of SystemCmdSubstVar objects - */ - public SystemCmdSubstVar[] getListAsArray() { - return list; - } - - /** - * Return the list as an array of display strings of the form xx - some text - */ - public String[] getDisplayStrings() { - String[] strings = new String[list.length]; - for (int idx = 0; idx < strings.length; idx++) - strings[idx] = list[idx].getDisplayString(); - return strings; - } - - /** - * For debugging purposes, writes the list of variables to standard out - */ - public void printDisplayStrings() { - System.out.println("Substitution Variables for " + getClass().getName()); //$NON-NLS-1$ - String[] strings = getDisplayStrings(); - for (int idx = 0; idx < strings.length; idx++) - System.out.println(strings[idx]); - System.out.println(); - } - - /** - * For whatever purpose, writes the list of variables to given stream - */ - public void printDisplayStrings(PrintWriter stream) { - stream.println("Substitution Variables for " + getClass().getName()); //$NON-NLS-1$ - String[] strings = getDisplayStrings(); - for (int idx = 0; idx < strings.length; idx++) - stream.println(strings[idx]); - stream.println(); - } - - /** - * Given a command string potentially containing substitution variables, - * and a context object that represents something currently selected (say), - * this will scan the command string for matches on any of the substitution - * variables defined in this list. For each match it calls the given - * implementor of {@link ISystemSubstitutor} to retrieve the value to - * replace the substitution variable with. The substitutor is also given - * the context object passed in here. - * <p> - * Currently this assume all variables use the prefix given in the constructor, - * as it optimizes performance. - * Another flavour would be needed if arbitrary prefixes were to supported! - * <p> - * Further, this also currently assumes a doubled up prefix is used for escaping, - * meaning the first prefix is to be removed, the next is to be left unsubstituted. - * - * @param commandString - the command from the user action, that contains vars to be substituted - * @param context - a selected object - * @param substitutor - an object that knows how to do substitutions. A callback. - */ - public String doSubstitutions(String commandString, Object context, ISystemSubstitutor substitutor) { - //System.out.println("Command before substitution: " + commandString); - // walk the command string, looking for variables... - String part1, part2; - int index = 0; - int lastindex = 0; - //int cmdLength = commandString.length(); - while ((index = commandString.indexOf(prefix, lastindex)) >= 0) { - lastindex = index + 1; // start next search at char after this '&' - // ampersand followed by at least one letter? - if (commandString.length() >= (index + 1)) { - char sc = commandString.charAt(index + 1); // char after this '&' - if (sc == prefix) // next char is also an '&'? - { - ++lastindex; // skip it. Note its ok to bump it past length of string - } else { - String var = findMatchingVar(commandString, index); - if (var != null) { - String replacement = substitutor.getSubstitutionValue(var, context); - if (replacement != null) { - if (index == 0) // substitution variable at front of command? - commandString = commandString.substring(index + var.length()); - else { - part1 = commandString.substring(0, index); - part2 = commandString.substring(index + var.length()); - commandString = part1 + replacement + part2; - } - lastindex = index + replacement.length(); // assume replacement has no '&' chars in it! - } - } - } - } - } // end while - //System.out.println("Command after substitution : " + commandString); - //System.out.println(); - return commandString; - } - - /** - * For testing purposes. - * Given the selected object, this returns an array of strings, one for each substitution - * variable, of the form "varname = substituted-value". - * @param context - a selected object - * @param substitutor - an object that knows how to do substitutions. A callback - */ - public String[] doAllSubstitutions(Object context, ISystemSubstitutor substitutor) { - String[] substitutedVariables = new String[list.length]; - String currVar = null; - for (int idx = 0; idx < list.length; idx++) { - currVar = list[idx].getVariable(); - substitutedVariables[idx] = currVar + " = " + //$NON-NLS-1$ - doSubstitutions("\"" + currVar + "\"", context, substitutor); //$NON-NLS-1$ //$NON-NLS-2$ - } - return substitutedVariables; - } - - /** - * Check our list of sub vars for a match on given string at given index - */ - private String findMatchingVar(String cmd, int indexOfPrefix) { - if (sortedList == null) { - sortedList = list; - /* - * At this point we don't need to sort names as we are careful not - * to define variables that are ambiguous. Eg, &A and &AB. - * - sortedList = new SystemUDASubstVar[list.length]; - for (int i = 0; i < sortedList.length; i++) - sortedList[i] = list[i]; - Arrays.sort(sortedList); - */ - } - int cmdlen = cmd.length(); - for (int idx = 0; idx < sortedList.length; idx++) { - String var = sortedList[idx].getVariable(); - int varlen = var.length(); - if (((indexOfPrefix + varlen) <= cmdlen) && var.equals(cmd.substring(indexOfPrefix, indexOfPrefix + varlen))) return var; - } - return null; - } - - /** - * Helper method to test for duplicate variables - */ - public void testForDuplicates() { - String currname = null; - for (int idx = 0; idx < list.length; idx++) { - currname = list[idx].getVariable(); - for (int i = 0; i < list.length; i++) - if (i != idx) if (list[i].equals(currname)) System.out.println("duplicate subs var " + currname + " in list " + this.getClass().getName()); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - /** - * This writes out the class name. - */ - public String toString() { - return getClass().getName(); - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/SystemCommandTextField.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/SystemCommandTextField.java deleted file mode 100644 index cb9bd8795..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/SystemCommandTextField.java +++ /dev/null @@ -1,319 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 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 - * Kevin Doyle (IBM) - [239704] No Validation for Command textbox in Work with Compile and User Action dialogs - * Kevin Doyle (IBM) - [242041] Bring back Undo/Content Assist for User Actions/Compile Commands Command Field - *******************************************************************************/ -package org.eclipse.rse.internal.useractions.ui; - -import org.eclipse.jface.text.ITextOperationTarget; -import org.eclipse.jface.text.source.ISourceViewer; -import org.eclipse.jface.text.source.SourceViewer; -import org.eclipse.jface.window.Window; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources; -import org.eclipse.rse.internal.useractions.ui.validators.ValidatorUserActionCommand; -import org.eclipse.rse.services.clientserver.messages.SystemMessage; -import org.eclipse.rse.shells.ui.view.ISystemCommandTextModifyListener; -import org.eclipse.rse.shells.ui.view.SystemCommandEditor; -import org.eclipse.rse.ui.ISystemMassager; -import org.eclipse.rse.ui.SystemWidgetHelpers; -import org.eclipse.rse.ui.validators.ISystemValidator; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.KeyAdapter; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; - -/** - * This class encapsulates a prompt for a remote command that supports - * substitution variables. It is used in both compile and user action dialogs. - */ -public class SystemCommandTextField implements SelectionListener { - protected SystemCommandEditor textCommand; - protected ISystemMassager cmdMassager; - protected Button insertVariableButton; - protected Button editButton; - protected boolean menuListenerAdded; - protected SystemCommandViewerConfiguration sourceViewerConfiguration; - //mri - private String cmdFieldLabel = SystemUDAResources.RESID_UDA_COMMAND_LABEL; - private String cmdFieldTooltip = SystemUDAResources.RESID_UDA_COMMAND_TOOLTIP; - private String insertVarButtonLabel = SystemUDAResources.RESID_UDA_INSERTVAR_BUTTON_LABEL; - private String insertVarButtonTooltip = SystemUDAResources.RESID_UDA_INSERTVAR_BUTTON_TOOLTIP; - private String editButtonLabel = SystemUDAResources.RESID_UDA_EDIT_BUTTON_LABEL; - private String editButtonTooltip = SystemUDAResources.RESID_UDA_EDIT_BUTTON_TOOLTIP; - /** - * Maximum text length for command field: 512 - */ - public static final int MAX_CMD_LENGTH = 512; - - /** - * Constructor . - * You must call setSubstitutionVariableList before - * calling createContents! - */ - public SystemCommandTextField(SystemCommandViewerConfiguration cmdAssistant) { - super(); - this.sourceViewerConfiguration = cmdAssistant; - } - - /** - * Reset what will be used to manage the content assist. A default is supplied. - */ - public void setCommandTextViewerConfiguration(SystemCommandViewerConfiguration cmdAssistant) { - // defect 46404... - if ((sourceViewerConfiguration != null) && (textCommand != null) && (sourceViewerConfiguration.getContentAssistant(textCommand) != null)) - sourceViewerConfiguration.getContentAssistant(textCommand).uninstall(); - this.sourceViewerConfiguration = cmdAssistant; - if (textCommand != null) { - textCommand.configure(sourceViewerConfiguration); - } - } - - /** - * Set the substitution variable list that Insert Variable will use. - */ - public void setSubstitutionVariableList(SystemCmdSubstVarList varList) { - sourceViewerConfiguration.setSubstVarList(varList); - } - - /** - * Set the action command massager. This is called to massage the contents - * when getCommandText is called. - */ - public void setCommandMassager(ISystemMassager massager) { - this.cmdMassager = massager; - } - - /** - * Return the command massager as set by setCommandMassager(...) - */ - public ISystemMassager getCommandMassager() { - return cmdMassager; - } - - /** - * Return the edit widget. Will be null until createEditor is called - */ - public SourceViewer getEditor() { - return textCommand; - } - - /** - * Return the control widget for the command prompt - */ - public Control getCommandWidget() { - return textCommand.getControl(); - } - - /** - * Return the text contents of the command widget - */ - public String getCommandText() { - return textCommand.getCommandText(); - } - - /** - * Return the text contents of the command widget, after applying the massager. - * If the massager is null, this is the same as calling getCommandText(). - */ - public String getMassagedCommandText() { - if (cmdMassager == null) - return getCommandText(); - else - return cmdMassager.massage(getCommandText()); - } - - /** - * Set the text contents of the command widget - */ - public void setCommandText(String text) { - textCommand.getDocument().set(text); - } - - /** - * Enable/disable command widget - */ - public void enableCommandWidget(boolean enable) { - if (textCommand != null) textCommand.getTextWidget().setEnabled(enable); - if (insertVariableButton != null) insertVariableButton.setEnabled(enable); - if (editButton != null) editButton.setEnabled(enable); - } - - /** - * Turn on or off event ignoring flag - */ - public void setIgnoreChanges(boolean ignore) { - if (textCommand != null) { - textCommand.setIgnoreChanges(ignore); - } - } - - /** - * Method createContents. - * @param comp - the parent composite into which to place the prompt, field and insert-variable buttons - * @return Control - */ - public Control createContents(Composite comp, int nbrColumns, ISystemCommandTextAdditionalGUIProvider guiProvider) { - Label labelCommand = SystemWidgetHelpers.createLabel(comp, cmdFieldLabel, cmdFieldTooltip); - String s = SystemWidgetHelpers.appendColon(labelCommand.getText()); - labelCommand.setText(s); - if ((guiProvider == null) || !guiProvider.createCommandLabelLineControls(comp, nbrColumns - 1)) ((GridData) labelCommand.getLayoutData()).horizontalSpan = nbrColumns; - int cmdSpan = nbrColumns; - textCommand = createEditor(comp, cmdSpan, sourceViewerConfiguration); - textCommand.getControl().setToolTipText(cmdFieldTooltip); - // Insert Variable... button - insertVariableButton = SystemWidgetHelpers.createPushButton(comp, null, insertVarButtonLabel, insertVarButtonTooltip); - // edit command button - editButton = SystemWidgetHelpers.createPushButton(comp, null, editButtonLabel, editButtonTooltip); - // SUBCLASS-SUPPLIED BUTTONS - if ((guiProvider == null) || !guiProvider.createExtraButtons(comp, nbrColumns - 1)) addFillerLine(comp, nbrColumns - 1); - insertVariableButton.addSelectionListener(this); - editButton.addSelectionListener(this); - textCommand.getTextWidget().addKeyListener(new KeyAdapter() - { - public void keyReleased(KeyEvent e) - { - - if (!e.doit) - return; - - if (e.stateMask == SWT.CTRL) - { - switch (e.character) - { - case ' ' : - textCommand.setInCodeAssist(true); - textCommand.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS); - break; - // CTRL-Z - case (int) 'z' - (int) 'a' + 1 : - textCommand.doOperation(ITextOperationTarget.UNDO); - //e.doit = false; - break; - } - } - - } - }); - return comp; - } - - /** - * Set the information needed to get the command field's mri - */ - public void setMRI(String cmdFieldLabel, String cmdFieldTooltip, String insertVarButtonLabel, String insertVarButtonTooltip) { - this.cmdFieldLabel = cmdFieldLabel; - this.cmdFieldTooltip = cmdFieldTooltip; - this.insertVarButtonLabel = insertVarButtonLabel; - this.insertVarButtonTooltip = insertVarButtonTooltip; - } - - /** - * SelectionListener Interface: - * For the checkboxes - */ - public void widgetDefaultSelected(SelectionEvent e) { - } - - /** - * SelectionListener Interface: - * For the checkboxes - */ - public void widgetSelected(SelectionEvent e) { - Object source = e.getSource(); - if (source == insertVariableButton) { - //sourceViewerConfiguration.getSubstVarList().printDisplayStrings(); - textCommand.getTextWidget().setFocus(); - textCommand.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS); - } else if (source == editButton) { - // bring up dialog - SystemCommandViewerConfiguration cfg = new SystemCommandViewerConfiguration(); - cfg.setSubstVarList(sourceViewerConfiguration.getSubstVarList()); - SystemEditCommandDialog dlg = new SystemEditCommandDialog(getCommandWidget().getShell(), getCommandText(), cfg, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL); - if (dlg.open() == Window.OK) { - String str = dlg.getCommand(); - textCommand.getDocument().set(str); - } - } - } - - /** - * Create the editor widget - */ - private SystemCommandEditor createEditor(Composite parent, int nbrColumns, SystemCommandViewerConfiguration sourceViewerConfiguration) { - textCommand = new SystemCommandEditor(null, parent, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, nbrColumns, sourceViewerConfiguration, - "", SystemUDAResources.RESID_UDA_INSERTVAR_BUTTON_LABEL); //$NON-NLS-1$ - textCommand.setCommandValidator(new ValidatorUserActionCommand()); - return textCommand; - } - - /** - * Set the command validator to validate contents per keystroke - */ - public void setCommandValidator(ISystemValidator cmdValidator) { - if (textCommand != null) textCommand.setCommandValidator(cmdValidator); - } - - /** - * Validate command input - */ - public SystemMessage validateCommand() { - if (textCommand != null) - return textCommand.validateCommand(); - else - return null; - } - - /** - * Add a modify listener - */ - public void addModifyListener(ISystemCommandTextModifyListener listener) { - if (textCommand != null) textCommand.addModifyListener(listener); - } - - /** - * Remove a modify listener - */ - public void removeModifyListener(ISystemCommandTextModifyListener listener) { - if (textCommand != null) textCommand.removeModifyListener(listener); - } - - // ----------------------------- - // Helper methods... - // ----------------------------- - /** - * Add a separator line. This is a physically visible line. - */ - protected Label addSeparatorLine(Composite parent, int nbrColumns) { - Label separator = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL); - GridData data = new GridData(); - data.horizontalSpan = nbrColumns; - data.horizontalAlignment = GridData.FILL; - separator.setLayoutData(data); - return separator; - } - - /** - * Add a spacer line - */ - protected Label addFillerLine(Composite parent, int nbrColumns) { - Label filler = new Label(parent, SWT.LEFT); - GridData data = new GridData(); - data.horizontalSpan = nbrColumns; - data.horizontalAlignment = GridData.FILL; - filler.setLayoutData(data); - return filler; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/SystemCommandViewerConfiguration.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/SystemCommandViewerConfiguration.java deleted file mode 100644 index 459379ae7..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/SystemCommandViewerConfiguration.java +++ /dev/null @@ -1,209 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui; - -/******************************************************************************* - * Copyright (c) 2002, 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 - *******************************************************************************/ -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.ITextViewer; -import org.eclipse.jface.text.contentassist.CompletionProposal; -import org.eclipse.jface.text.contentassist.ContentAssistant; -import org.eclipse.jface.text.contentassist.ICompletionProposal; -import org.eclipse.jface.text.contentassist.IContentAssistProcessor; -import org.eclipse.jface.text.contentassist.IContentAssistant; -import org.eclipse.jface.text.contentassist.IContextInformation; -import org.eclipse.jface.text.contentassist.IContextInformationValidator; -import org.eclipse.jface.text.hyperlink.IHyperlinkDetector; -import org.eclipse.jface.text.source.ISourceViewer; -import org.eclipse.jface.text.source.SourceViewerConfiguration; - -/** - * @author coulthar - * - * This is the class which enables the popup window shown when - * Insert Variable is pressed in the UDA dialog. - */ -public class SystemCommandViewerConfiguration extends SourceViewerConfiguration { - private SystemCommandContentAssistProcessor contentAssistantProcessor; - private ContentAssistant contentAssistant; - - /** - * Constructor - * You must call setSubstVarList. - */ - public SystemCommandViewerConfiguration() { - super(); - contentAssistantProcessor = new SystemCommandContentAssistProcessor(this); - } - - /** - * Reset the variable list - */ - public void setSubstVarList(SystemCmdSubstVarList variableList) { - contentAssistantProcessor.setSubstVarList(variableList); - } - - /** - * Return the current substitution variable list - */ - public SystemCmdSubstVarList getSubstVarList() { - return contentAssistantProcessor.getSubstVarList(); - } - - /** - * Parent override. - * Returns the content assistant ready to be used with the given source viewer. - * - * @param sourceViewer the source viewer to be configured by this configuration - * @return a content assistant or <code>null</code> if content assist should not be supported - */ - public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) { - if (contentAssistant == null) { - contentAssistant = new ContentAssistant(); - contentAssistant.setContentAssistProcessor(contentAssistantProcessor, IDocument.DEFAULT_CONTENT_TYPE); - contentAssistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY); - contentAssistant.enableAutoActivation(true); - } - return contentAssistant; - } - - /* - * Similar to org.eclipse.jdt.internal.ui.text.template.TemplateVariableProcessor#getStart(String,int). - */ - /** - * Guesses the start position of the completion. - * <p> - * Overridable by subclasses for cases when not using ${...} substitution variable patterns - */ - protected int getStart(String string, int end) { - int start = end; - if (start >= 1 && string.charAt(start - 1) == '$') return start - 1; - while ((start != 0) && Character.isUnicodeIdentifierPart(string.charAt(start - 1))) - start--; - if (start >= 2 && string.charAt(start - 1) == '{' && string.charAt(start - 2) == '$') return start - 2; - return end; - } - - /** - * Return the characters which trigger the auto-display of the list - * substitution variables. We return '$' by default, but this can be - * overridden. - */ - protected char[] getCompletionProposalAutoActivationCharacters() { - return new char[] { '$' }; - } - - /* - * (non-Javadoc) - * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getHyperlinkDetectors(org.eclipse.jface.text.source.ISourceViewer) - */ - public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) { - return null; - } - - /** - * Internal class that implements the content assist processor interface - */ - private class SystemCommandContentAssistProcessor implements IContentAssistProcessor { - private SystemCmdSubstVarList variableList; - private SystemCommandViewerConfiguration configurator; - - /** - * Constructor - */ - public SystemCommandContentAssistProcessor(SystemCommandViewerConfiguration configurator) { - this.configurator = configurator; - } - - /** - * Reset the variable list - */ - public void setSubstVarList(SystemCmdSubstVarList variableList) { - this.variableList = variableList; - } - - /** - * Return the variable list - */ - public SystemCmdSubstVarList getSubstVarList() { - return variableList; - } - - /** - * @see IContentAssistProcessor#computeCompletionProposals(ITextViewer, int) - */ - public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) { - if (variableList == null) { - System.out.println("Inside UDAContentAssistProcessor in SystemUDASourceViewerConfiguration. variableList is null!"); //$NON-NLS-1$ - return null; - } - SystemCmdSubstVar[] subVars = variableList.getListAsArray(); - ICompletionProposal[] proposalList = new ICompletionProposal[subVars.length]; - int replacementOffset = documentOffset; - int replacementLength = 0; - // this little algo comes from the Java template support example. - // I am not sure I like it... it seems to be designed to replace the - // contents of the text from the previous substitution-variable-start character - // (eg '&' or '$') to the current cursor position. - String text = viewer.getDocument().get(); - //System.out.println("docOffset = " + documentOffset + ", text = '" + text + "'"); - replacementOffset = configurator.getStart(text, documentOffset); - replacementLength = documentOffset - replacementOffset; - for (int idx = 0; idx < proposalList.length; idx++) { - SystemCmdSubstVar currVar = subVars[idx]; - // @param replacementString the actual string to be inserted into the document - // @param replacementOffset the offset of the text to be replaced - // @param replacementLength the length of the text to be replaced - // @param cursorPosition the position of the cursor following the insert relative to replacementOffset - // @param image the image to display for this proposal - // @param displayString the string to be displayed for the proposal - // @param contentInformation the context information associated with this proposal - // @param additionalProposalInfo the additional information associated with this proposal - proposalList[idx] = new CompletionProposal(currVar.getVariable(), replacementOffset, replacementLength, documentOffset + currVar.getVariable().length(), null, currVar - .getDisplayString(), null, null); - } - return proposalList; - } - - /* - * @see IContentAssistProcessor#computeContextInformation(ITextViewer, int) - */ - public IContextInformation[] computeContextInformation(ITextViewer viewer, int documentOffset) { - return null; - } - - /* - * @see IContentAssistProcessor#getCompletionProposalAutoActivationCharacters() - */ - public char[] getCompletionProposalAutoActivationCharacters() { - return configurator.getCompletionProposalAutoActivationCharacters(); - } - - /* - * @see IContentAssistProcessor#getContextInformationAutoActivationCharacters() - */ - public char[] getContextInformationAutoActivationCharacters() { - return null; - } - - /* - * @see IContentAssistProcessor#getErrorMessage() - */ - public String getErrorMessage() { - return null; - } - - /* - * @see IContentAssistProcessor#getContextInformationValidator() - */ - public IContextInformationValidator getContextInformationValidator() { - return null; - } - } // end inner class -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/SystemEditCommandDialog.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/SystemEditCommandDialog.java deleted file mode 100644 index b0d248222..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/SystemEditCommandDialog.java +++ /dev/null @@ -1,141 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui; - -/******************************************************************************* - * Copyright (c) 2002, 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 - * Kevin Doyle (IBM) - [239704] No Validation for Command textbox in Work with Compile and User Action dialogs - *******************************************************************************/ -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.text.source.ISourceViewer; -import org.eclipse.jface.text.source.SourceViewer; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources; -import org.eclipse.rse.internal.useractions.ui.validators.ValidatorUserActionCommand; -import org.eclipse.rse.shells.ui.view.SystemCommandEditor; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; - -/** - * Dialog used for editing command text in a resizable widget - */ -public class SystemEditCommandDialog extends Dialog { - // gui - protected Label newNamePrompt; - // input - protected String cmd; - // output - protected String newCmdString; - protected boolean ignoreChanges; - // state - protected SystemCommandViewerConfiguration sourceViewerConfiguration; - protected SystemCommandEditor textCommand; - protected Button insertVariableButton; - protected int style; - protected int INSERT_ID = 10; - - /** - * Constructor. - * @param shell The parent window hosting this dialog - * @param command The resolved command from the user action - * @param sourceViewerConfiguration configration for editor - * @param style for editor - */ - public SystemEditCommandDialog(Shell shell, String command, SystemCommandViewerConfiguration sourceViewerConfiguration, int style) { - this(shell, command, SystemUDAResources.RESID_UDA_PROMPTCMD_TITLE, sourceViewerConfiguration, style); - } - - /** - * Constructor when specifying your own title. - * @param shell The parent window hosting this dialog - * @param command The resolved command from the user action - * @param title title for the dialog - * @param sourceViewerConfiguration configration for editor - * @param style for editor - */ - public SystemEditCommandDialog(Shell shell, String command, String title, SystemCommandViewerConfiguration sourceViewerConfiguration, int style) { - super(shell); - setShellStyle(getShellStyle() | SWT.RESIZE | SWT.MAX); - this.style = style; - this.cmd = command; - this.sourceViewerConfiguration = sourceViewerConfiguration; - } - - /** - * Create GUI controls, populate into given composite. - */ - protected Control createDialogArea(Composite gparent) { - Composite parent = new Composite(gparent, SWT.NONE); - GridData data = new GridData(); - data.heightHint = 100; - data.widthHint = 400; - parent.setLayout(new GridLayout()); - parent.setLayoutData(data); - createEditor(parent, 5, sourceViewerConfiguration, cmd); - String title = SystemUDAResources.RESID_UDA_COMMAND_LABEL; - getShell().setText(title); - return parent; - } - - /** - * Create the editor widget - */ - private SourceViewer createEditor(Composite parent, int columnSpan, SystemCommandViewerConfiguration sourceViewerConfiguration, String cmd) { - textCommand = new SystemCommandEditor(null, parent, style, columnSpan, sourceViewerConfiguration, cmd, SystemUDAResources.RESID_UDA_INSERTVAR_BUTTON_LABEL); - textCommand.setCommandValidator(new ValidatorUserActionCommand()); - return textCommand; - } - - protected void createButtonsForButtonBar(Composite parent) { - String label = SystemUDAResources.RESID_UDA_INSERTVAR_BUTTON_LABEL; - createButton(parent, INSERT_ID, label, false); - super.createButtonsForButtonBar(parent); - } - - /** - * Return widget to set initial focus to - */ - protected Control getInitialFocusControl() { - return textCommand.getControl(); - } - - protected void buttonPressed(int buttonId) { - if (IDialogConstants.OK_ID == buttonId) { - processOK(); - textCommand.getTextWidget().dispose(); - } - if (buttonId == INSERT_ID) { - textCommand.getTextWidget().setFocus(); - textCommand.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS); - } - super.buttonPressed(buttonId); - } - - /** - * Called when user presses OK button. - * Return true to close dialog. - * Return false to not close dialog. - */ - protected boolean processOK() { - newCmdString = textCommand.getDocument().get().trim(); - return true; - } - - /** - * Returns the user-edited command - */ - public String getCommand() { - return newCmdString; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/SystemPromptCommandDialog.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/SystemPromptCommandDialog.java deleted file mode 100644 index b17be1fba..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/SystemPromptCommandDialog.java +++ /dev/null @@ -1,220 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui; - -/******************************************************************************* - * Copyright (c) 2002, 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 - *******************************************************************************/ -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources; -import org.eclipse.rse.services.clientserver.messages.SystemMessage; -import org.eclipse.rse.ui.SystemWidgetHelpers; -import org.eclipse.rse.ui.dialogs.SystemPromptDialog; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; - -/** - * Dialog used when to prompt the user with a command, with the intention that - * the user can change. - * <p> - * This default implementation merely puts the command into an entry field, which - * the user can edit. - * <p> - * Typically this is subclassed or configured to supply unique translated text. - */ -public class SystemPromptCommandDialog extends SystemPromptDialog { - // gui - protected Text cmdText; - protected Label newNamePrompt; - // input - protected String cmd; - // output - protected String newCmdString; - // state - protected SystemMessage errorMessage; - - /** - * Constructor. - * @param shell The parent window hosting this dialog - * @param command The resolved command from the user action - */ - public SystemPromptCommandDialog(Shell shell, String command) { - this(shell, command, SystemUDAResources.RESID_UDA_PROMPTCMD_TITLE); - } - - /** - * Constructor when specifying your own title. - * @param shell The parent window hosting this dialog - * @param command The resolved command from the user action - */ - public SystemPromptCommandDialog(Shell shell, String command, String title) { - super(shell, title); - this.cmd = command; - super.setOkButtonLabel(getOKButtonLabel()); - super.setOkButtonToolTipText(getOKButtonToolTipText()); - super.setCancelButtonToolTipText(getCancelButtonToolTipText()); - //setHelp(RSEUIPlugin.HELPPREFIX+"drnp0000"); - } - - // -------------- - // MRI METHODS... - // -------------- - /** - * Translated text configuration method. - * Override to return OK button label if you don't want the default - */ - protected String getOKButtonLabel() { - return SystemUDAResources.RESID_UDA_PROMPTCMD_OKBUTTON_LABEL; - } - - /** - * Translated text configuration method. - * Override to return OK button tooltip if you don't want the default - */ - protected String getOKButtonToolTipText() { - return SystemUDAResources.RESID_UDA_PROMPTCMD_OKBUTTON_TOOLTIP; - } - - /** - * Translated text configuration method. - * Override to return Cancel button tooltip if you don't want the default - */ - protected String getCancelButtonToolTipText() { - return SystemUDAResources.RESID_UDA_PROMPTCMD_CANCELBUTTON_TOOLTIP; - } - - /** - * Translated text configuration method. - * Override to return verbage message if you don't want the default - */ - protected String getVerbage() { - return SystemUDAResources.RESID_UDA_PROMPTCMD_VERBAGE_LABEL; - } - - /** - * Translated text configuration method. - * Override to return label for the command prompt, if you don't want the default - */ - protected String getPromptLabel() { - return SystemUDAResources.RESID_UDA_PROMPTCMD_PROMPT_LABEL; - } - - /** - * Translated text configuration method. - * Override to return tooltip text for the command prompt, if you don't want the default - */ - protected String getPromptToolTipText() { - return SystemUDAResources.RESID_UDA_PROMPTCMD_PROMPT_TOOLTIP; - } - - /** - * Create GUI controls, populate into given composite. - */ - protected Control createInner(Composite parent) { - // Inner composite - int nbrColumns = 1; - Composite composite_prompts = SystemWidgetHelpers.createComposite(parent, nbrColumns); - // VERBAGE - SystemWidgetHelpers.createVerbiage(composite_prompts, getVerbage(), nbrColumns, false, 250); - addFillerLine(composite_prompts, nbrColumns); - // ENTRY FIELD - SystemWidgetHelpers.createLabel(composite_prompts, getPromptLabel()); - cmdText = SystemWidgetHelpers.createMultiLineTextField(composite_prompts, null, 65); - ((GridData) cmdText.getLayoutData()).widthHint = 350; - cmdText.setToolTipText(getPromptToolTipText()); - cmdText.setTextLimit(2000); - cmdText.setText(cmd); - // add keystroke listeners... - cmdText.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - validateInput(); - } - }); - return composite_prompts; - } - - /** - * Return widget to set initial focus to - */ - protected Control getInitialFocusControl() { - return cmdText; - } - - /** - * Called when user presses OK button. - * Return true to close dialog. - * Return false to not close dialog. - */ - protected boolean processOK() { - newCmdString = cmdText.getText().trim(); - boolean closeDialog = verify(); - if (closeDialog) { - setOutputObject(newCmdString); - } - return closeDialog; - } - - /** - * Verifies all input. Currently, we do no verification! - * @return true if there are no errors in the user input - */ - public boolean verify() { - //clearErrorMessage(); - //errorMessage = null; - //if (errorMessage != null) - // cmdText.setFocus(); - return (errorMessage == null); - } - - /** - * This hook method is called whenever the text changes in the cmd input field. - * Currently not used. - */ - protected SystemMessage validateInput() { - //errorMessage = null; - //if (errorMessage != null) - // displayErrorMessage(errorMessage); - //else - // clearErrorMessage(); - setPageComplete(); - return errorMessage; - } - - /** - * This method can be called by the dialog or wizard page host, to decide whether to enable - * or disable the next, final or ok buttons. It returns true if the minimal information is - * available and is correct. - */ - public boolean isPageComplete() { - boolean pageComplete = false; - if (errorMessage == null) { - String theNewCmd = cmdText.getText().trim(); - pageComplete = (theNewCmd.length() > 0); - } - return pageComplete; - } - - /** - * Inform caller of page-complete status of this form - */ - public void setPageComplete() { - setPageComplete(isPageComplete()); - } - - /** - * Returns the user-edited command - */ - public String getCommand() { - return newCmdString; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/ISystemCompileCommandEditPaneHoster.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/ISystemCompileCommandEditPaneHoster.java deleted file mode 100644 index aaa6d057d..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/ISystemCompileCommandEditPaneHoster.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 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.ui.compile; - -//import org.eclipse.jface.viewers.ISelection; -//import org.eclipse.jface.viewers.IStructuredSelection; -//import org.eclipse.jface.viewers.StructuredSelection; -//import org.eclipse.jface.viewers.ISelection; -//import org.eclipse.swt.widgets.Control; -import org.eclipse.rse.ui.messages.ISystemMessageLine; -import org.eclipse.swt.widgets.Shell; - -/** - * The interface that must be implemented for any dialog or property page that wants to - * host a user action edit pane. - */ -public interface ISystemCompileCommandEditPaneHoster extends ISystemMessageLine { - /** - * Get the shell for this dialog or property page - */ - public Shell getShell(); -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/ISystemCompileCommandEditPaneListener.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/ISystemCompileCommandEditPaneListener.java deleted file mode 100644 index cb163598d..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/ISystemCompileCommandEditPaneListener.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.compile; - -/******************************************************************************* - * Copyright (c) 2002, 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 - *******************************************************************************/ -import org.eclipse.rse.services.clientserver.messages.SystemMessage; - -/** - * This listener interface is implemented by any code desired to be kept aware - * of all user changes to a compile command in the SystemCompileCommandEditPane. - */ -public interface ISystemCompileCommandEditPaneListener { - /** - * Callback method. The user has changed the compile command. It may or may not - * be valid. If not, the given message is non-null. If it is, and you want it, - * call getSystemCompileCommand() in the edit pane. - */ - public void compileCommandChanged(SystemMessage message); -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/ISystemCompileCommandSubstitutor.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/ISystemCompileCommandSubstitutor.java deleted file mode 100644 index 5f8fd3750..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/ISystemCompileCommandSubstitutor.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 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.ui.compile; - -import org.eclipse.rse.core.model.IHost; -import org.eclipse.rse.internal.useractions.ui.ISystemSubstitutor; - -/** - * This is the callback from SystemCmdSubstVarList that is used to substitute - * a particular substitution variable into the given compile command, for the - * given remote object. - */ -public interface ISystemCompileCommandSubstitutor extends ISystemSubstitutor { - /** - * Reset the connection so one instance can be re-used - */ - public void setConnection(IHost connection); -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/ISystemCompileXMLConstants.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/ISystemCompileXMLConstants.java deleted file mode 100644 index f6a175723..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/ISystemCompileXMLConstants.java +++ /dev/null @@ -1,153 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - * Xuan Chen (IBM) - [222263] Need to provide a PropertySet Adapter for System Team View (cleanup some use action stuff) - *******************************************************************************/ - -package org.eclipse.rse.internal.useractions.ui.compile; - -import org.eclipse.rse.core.RSECorePlugin; - -/** - * Constants used in the persistence of the compile commands, into an xml file - */ -public interface ISystemCompileXMLConstants { - - public static final String COMPILE_COMMAND_PROPRERTY_SET_PREFIX = "CompileCommand."; //$NON-NLS-1$ - public static final String COMPILE_COMMAND_NAME = "Compile Commands"; //$NON-NLS-1$ - - // root tag - /** - * The name of the root element (tag) for the compile types xml file. That element is named "types". - */ - public static final String ROOT_ELEMENT = "types"; //$NON-NLS-1$ - /** - * The name of the attribute holding the version number when this document was last written. - * The xml attribute is named "version". - */ - public static final String VERSION_ATTRIBUTE = "version"; //$NON-NLS-1$ - /** - * Current version number for the compile framework - */ - public static final String VERSION_VALUE = RSECorePlugin.CURRENT_RELEASE_NAME; // changed from "5.1.0" by Phil - /** - * The name of the copyright element (tag) holding the copyright value. That element is named "copyright". - */ - public static final String COPYRIGHT_ELEMENT = "copyright"; //$NON-NLS-1$ - /** - * The data of the copyright element (tag). - */ - public static final String COPYRIGHT_TEXT = "Copyright (c) IBM Corporation and others 2002, 2007"; //$NON-NLS-1$ - // type tag - /** - * The name of the element (tag) containing all the compile command sub-elements (tags) for - * a source type. - * <p> - * The xml element is named "compiletype". - */ - public static final String TYPE_ELEMENT = "compiletype"; //$NON-NLS-1$ - public static final String SOURCETYPE_ATTRIBUTE = "sourcetype"; //$NON-NLS-1$ - /** - * The name of the attribute holding the last-used compile command. This value identifies that - * command via its label value. - * <p> - * The xml attribute is named "lastcompilename", for historical reasons (when compile commands - * were called compile names). - */ - public static final String LASTUSED_ATTRIBUTE = "lastcompilename"; //$NON-NLS-1$ - // compile name tag - /** - * The name of the element (tag) containing all the compile command attributes. - * The xml element is named "compilename", for historical reasons (when compile commands - * were called compile names). - */ - public static final String COMPILECOMMAND_ELEMENT = "compilename"; //$NON-NLS-1$ - /** - * The name of the attribute holding the compile command label. This is the name the user sees for this - * compile command. The xml attribute is named "name" for historical reasons (when compile commands - * were called compile names). - */ - public static final String LABEL_ATTRIBUTE = "name"; //$NON-NLS-1$ - public static final String TYPE_ATTRIBUTE = "type"; //$NON-NLS-1$ - /** - * The name of the attribute holding the nature value. This tells the framework if this is - * an IBM-supplied or user-supplied compile command. The xml attribute is named "nature". - */ - public static final String NATURE_ATTRIBUTE = "nature"; //$NON-NLS-1$ - /** - * Value for the compile command nature attribute for IBM-supplied commands: "IBM defined" - */ - public static final String NATURE_IBM_VALUE = "IBM defined"; //$NON-NLS-1$ - /** - * Value for the compile command nature attribute for user-supplied commands: "User defined" - */ - public static final String NATURE_USER_VALUE = "User defined"; //$NON-NLS-1$ - /** - * Value for the compile command nature attribute for vendor-supplied commands: "ISV defined" - */ - public static final String NATURE_ISV_VALUE = "ISV defined"; //$NON-NLS-1$ - /** - * The name of the attribute holding the default string value. This is the IBM-supplied value for - * support of "Restore Defaults". The xml attribute is named "default". - */ - public static final String DEFAULT_ATTRIBUTE = "default"; //$NON-NLS-1$ - /** - * The name of the attribute holding the current string value. This is the potentially user-edited - * compile command including parameters. The xml attribute is named "current". - */ - public static final String CURRENT_ATTRIBUTE = "current"; //$NON-NLS-1$ - /** - * The name of the attribute holding the menu option value. This tells the compile framework if this - * user action is to displayed in the non-promptable cascading menu, the promptable cascading menu, - * or both cascading menus. These menus shown in the popup menu for a compilable remote source - * object. - * The xml attribute is named "menu". - */ - public static final String MENU_ATTRIBUTE = "menu"; //$NON-NLS-1$ - /** - * Value for the compile command menu attribute for prompt-only commands: "Prompt" - */ - public static final String MENU_PROMPTABLE_VALUE = "Prompt"; //$NON-NLS-1$ - /** - * Value for the compile command menu attribute for no-prompt-only commands: "NoPrompt" - */ - public static final String MENU_NON_PROMPTABLE_VALUE = "NoPrompt"; //$NON-NLS-1$ - /** - * Value for the compile command menu attribute for both prompt and no-prompt commands: "Both" - */ - public static final String MENU_BOTH_VALUE = "Both"; //$NON-NLS-1$ - /** - * Value for the compile command menu attribute for neither promptable nor non-promptable commands: "None". - * These compile commands do not appear in the menu. - */ - public static final String MENU_NONE_VALUE = "None"; //$NON-NLS-1$ - /** - * The name of the attribute holding the relative order the compile command is to appear in any - * list of compile commands: "order" - */ - public static final String ORDER_ATTRIBUTE = "order"; //$NON-NLS-1$ - /** - * The name of the attribute holding the job environment value. This is not used in all cases, but those - * that need it (such as for iSeries IFS which needs to prompt for QSYS vs QSHELL cmd), this is where to - * store it. The attribute name is "jobenv". - */ - public static final String JOBENV_ATTRIBUTE = "jobenv"; //$NON-NLS-1$ - /** - * The name of the attribute holding the id: "id" - */ - public static final String ID_ATTRIBUTE = "id"; //$NON-NLS-1$ - /** - * The name of the attribute holding whether the label is editable: "labeleditable" - */ - public static final String LABEL_EDITABLE_ATTRIBUTE = "labeleditable"; //$NON-NLS-1$ - /** - * The name of the attribute holding whether the command string is editable: "stringeditable" - */ - public static final String STRING_EDITABLE_ATTRIBUTE = "stringeditable"; //$NON-NLS-1$ -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompilableSource.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompilableSource.java deleted file mode 100644 index 62c44e64f..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompilableSource.java +++ /dev/null @@ -1,231 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 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 - * Martin Oberhuber (Wind River) - [168870] refactor org.eclipse.rse.core package of the UI plugin - *******************************************************************************/ -package org.eclipse.rse.internal.useractions.ui.compile; - -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.rse.core.model.IHost; -import org.eclipse.rse.core.subsystems.ISubSystem; -import org.eclipse.rse.internal.useractions.ui.SystemCmdSubstVarList; -import org.eclipse.rse.shells.ui.RemoteCommandHelpers; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCmdSubSystem; -import org.eclipse.rse.ui.SystemBasePlugin; -import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter; -import org.eclipse.rse.ui.view.SystemAdapterHelpers; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; - -/** - * When a user selects a remote compilable source member, and then one of the compile commands - * from the cascading compile popup menu action, an instance of this class is created to manage - * the actual running of the compile command against the selected source. - */ -public class SystemCompilableSource implements Runnable { - protected Object firstSelection; - protected boolean isPrompt; - protected SystemCompileCommand compileCmd; - protected ISystemRemoteElementAdapter rmtAdapter; - protected Shell shell; - protected Viewer viewer; - - /** - * Constructor for SystemCompilableSource. - * Instantiated by SystemCompileAction. - * @param shell - the current shell, in case we need it for the prompt dialog or error messages. - * @param firstSelection - the selected compilable source member - * @param compileCmd - the Compile Command that is to be run against the selected compilable source member - * @param isPrompt - true if the user choose the flavor of the action to prompt the compile command - * @param viewer - the viewer that originated the compile action - */ - public SystemCompilableSource(Shell shell, Object firstSelection, SystemCompileCommand compileCmd, boolean isPrompt, Viewer viewer) { - super(); - this.shell = shell; - this.firstSelection = firstSelection; - this.compileCmd = compileCmd; - this.isPrompt = isPrompt; - this.rmtAdapter = SystemAdapterHelpers.getRemoteAdapter(firstSelection); - this.viewer = viewer; - } - - /** - * Return the shell as set in the constructor. - * If this is null, we attempt to get the active shell - */ - public Shell getShell() { - if (shell != null) - return shell; - else { - shell = SystemBasePlugin.getActiveWorkbenchShell(); - if (shell == null) { - shell = Display.getCurrent().getActiveShell(); - if (shell == null) { - Shell[] shells = Display.getCurrent().getShells(); - for (int i = 0; (i < shells.length) && (shell == null); i++) - if (!shells[i].isDisposed() && shells[i].isEnabled()) shell = shells[i]; - } - } - return shell; - } - } - - /** - * Return the selected compilable remote source object we are to compile - */ - protected Object getSelectedObject() { - return firstSelection; - } - - /** - * Return the compile command to compile the selected source object with. - */ - protected SystemCompileCommand getCompileCommand() { - return compileCmd; - } - - /** - * Return if the compile command is to be prompted or not - */ - protected boolean isPrompt() { - return isPrompt; - } - - /** - * Return the remote adapter for the currently selected compilable remote source object - */ - protected ISystemRemoteElementAdapter getRemoteAdapter() { - return rmtAdapter; - } - - /** - * Return the source type of this remote object - */ - public String getSourceType() { - return rmtAdapter.getRemoteSourceType(firstSelection); - } - - /** - * Return the system connection from the which the selected object came from - */ - public IHost getSystemConnection() { - return getSubSystem().getHost(); - } - - /** - * Return the subsystem which is responsible for producing the remote object. - */ - protected ISubSystem getSubSystem() { - return rmtAdapter.getSubSystem(firstSelection); - } - - /** - * Return the command subsystem for the remote connection. Typically needed to actually run the - * compile command. - */ - protected IRemoteCmdSubSystem getCommandSubSystem() { - return RemoteCommandHelpers.getCmdSubSystem(getSubSystem().getHost()); - } - - /** - * Return the substitution variable list. Called by runCompileCommand default implementation. - * By default, returns it from the SystemCompileManager, but you can override if you have your - * own list. - */ - protected SystemCmdSubstVarList getSubstitutionVariableList() { - SystemCompileManager mgr = compileCmd.getParentType().getParentProfile().getParentManager(); - mgr.setCurrentCompileCommand(compileCmd); // defect 47808 - SystemCmdSubstVarList varlist = mgr.getSubstitutionVariableList(); - mgr.setCurrentCompileCommand(null); // defect 47808 - return varlist; - } - - /** - * Return the substitutor for doing variable substitution. Called by runCompileCommand default implementation. - * By default, returns it from the SystemCompileManager, but you can override if you have your - * own list. - */ - protected ISystemCompileCommandSubstitutor getSubstitutor() { - SystemCompileManager mgr = compileCmd.getParentType().getParentProfile().getParentManager(); - mgr.setCurrentCompileCommand(compileCmd); // defect 47808 - // if not called by the compile action, system connection is not set, so set it here - if (mgr.getSystemConnection() == null) mgr.setSystemConnection(getSystemConnection()); - ISystemCompileCommandSubstitutor substitutor = compileCmd.getParentType().getParentProfile().getParentManager().getSubstitutor(); - mgr.setCurrentCompileCommand(null); // defect 47808 - return substitutor; - } - - /** - * Run the compile command against the selected source. - * Do not override this directly, as it tries to handle the prompting first. - * Rather, override internalPromptCompileCommand(String) and internalRunCompileCommand(String) - */ - public boolean runCompileCommand() { - //String originalString = compileCmd.getCurrentString(); - String substitutedString = getSubstitutedString(compileCmd, firstSelection, getSubstitutor()); - if (isPrompt()) { - substitutedString = internalPromptCompileCommand(substitutedString); - if (substitutedString == null || substitutedString.trim().equals("")) //$NON-NLS-1$ - return false; - } - //System.out.println("Running compile command..."); - //System.out.println("...original cmd: '" + originalString + "'"); - //System.out.println("...final cmd...: '" + substitutedString + "'"); - return internalRunCompileCommand(substitutedString); - } - - /** - * Given the compile command, the selected source object, do the variable substitution. - * This can be overridden if needed. The default implementation here is: - * <pre><code> - * return compileCmd.doVariableSubstitution(firstSelection, substitutor); - * </code></pre> - */ - protected String getSubstitutedString(SystemCompileCommand compileCmd, Object firstSelection, ISystemCompileCommandSubstitutor substitutor) { - return compileCmd.doVariableSubstitution(firstSelection, substitutor); - } - - /** - * After the substituting and the prompting, it is now time to the remote running of the - * fully resolved compile command. Do that here. - * <p> - * Must be overridden. - * @return true if all is well, false if something went wrong. This prevents the next compile from running - */ - protected boolean internalRunCompileCommand(String compileCmd) { - return true; - } - - /** - * When running a compile command from the prompt menu, we prompt the command. This is the - * method that does this prompt. Override if appropriate, else a simple dialog is presented - * to the user showing the substituted compile command and allowing them to change it. - * <p> - * By default, this uses the SystemPromptCompileCommandDialog dialog to prompt the user to change - * the compile command. - */ - protected String internalPromptCompileCommand(String substitutedCompileCommand) { - String promptedCmd = substitutedCompileCommand; - SystemPromptCompileCommandDialog promptDlg = new SystemPromptCompileCommandDialog(shell, substitutedCompileCommand); - promptDlg.open(); - if (!promptDlg.wasCancelled()) - promptedCmd = promptDlg.getCommand(); - else - promptedCmd = null; - return promptedCmd; - } - - /** - * The run() method for running code in a thread. This is empty by default, but we include it - * for your convenience to save adding "implements Runnable" in your subclass. Override if - * using threads or asynchExec. - */ - public void run() { - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileCascadeByProfileAction.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileCascadeByProfileAction.java deleted file mode 100644 index a2742d387..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileCascadeByProfileAction.java +++ /dev/null @@ -1,134 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - * Martin Oberhuber (Wind River) - [168870] refactor org.eclipse.rse.core package of the UI plugin - * David Dykstal (IBM) - [186589] move user actions API out of org.eclipse.rse.ui - * David McKnight (IBM) - [225506] [api][breaking] RSE UI leaks non-API types - *******************************************************************************/ -package org.eclipse.rse.internal.useractions.ui.compile; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.rse.core.model.ISystemProfile; -import org.eclipse.rse.core.subsystems.ISubSystem; -import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; -import org.eclipse.rse.internal.ui.view.SystemViewMenuListener; -import org.eclipse.rse.internal.useractions.api.files.compile.ISystemCompileManagerAdapter; -import org.eclipse.rse.internal.useractions.api.ui.compile.SystemCompileAction; -import org.eclipse.rse.ui.ISystemIconConstants; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.actions.ISystemViewMenuListener; -import org.eclipse.rse.ui.actions.SystemBaseDummyAction; -import org.eclipse.rse.ui.actions.SystemBaseSubMenuAction; -import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter; -import org.eclipse.rse.ui.view.SystemAdapterHelpers; -import org.eclipse.swt.widgets.Shell; - -/** - * A cascading submenu action for "Compile->". - * This is after the first cascade, which lists profiles. - * Here, for that profile, we list actions - */ -public class SystemCompileCascadeByProfileAction extends SystemBaseSubMenuAction implements IMenuListener { - private ISystemProfile profile; - private Object firstSelection; - private boolean isPrompt; - - /** - * Constructor. - */ - public SystemCompileCascadeByProfileAction(Shell shell, Object firstSelection, ISystemProfile profile, boolean isPrompt) { - super(profile.getName(), RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_PROFILE_ID), shell); - this.profile = profile; - this.firstSelection = firstSelection; - this.isPrompt = isPrompt; - setCreateMenuEachTime(false); - setPopulateMenuEachTime(true); - //this.setTest(true); - } - - /** - * @see org.eclipse.rse.ui.actions.SystemBaseSubMenuAction#getSubMenu() - */ - public IMenuManager populateSubMenu(IMenuManager menu) { - //System.out.println("Inside populateSubMenu for SystemUDACascadeByProfileAction"); - menu.addMenuListener(this); - menu.setRemoveAllWhenShown(true); - //menu.setEnabled(true); - menu.add(new SystemBaseDummyAction()); - return menu; - } - - /** - * Called when submenu is about to show. Called because we - * implement IMenuListener, and registered ourself for this event. - */ - public void menuAboutToShow(IMenuManager ourSubMenu) { - //System.out.println("Inside menuAboutToShow for SystemUDACascadeByProfileAction"); - Shell shell = getShell(); - populateMenuWithCompileActions(ourSubMenu, shell, profile, firstSelection, isPrompt); - } - - /** - * Overridable method from parent that instantiates the menu listener who job is to add mnemonics. - * @param setMnemonicsOnlyOnce true if the menu is static and so mnemonics need only be set once. False if it is dynamic - */ - protected ISystemViewMenuListener createMnemonicsListener(boolean setMnemonicsOnlyOnce) { - return new SystemViewMenuListener(false); // our menu is re-built dynamically each time - } - - /** - * Re-usable method to populate a sub-menu with compile actions... - */ - public static IMenuManager populateMenuWithCompileActions(IMenuManager ourSubMenu, Shell shell, ISystemProfile profile, Object firstSelection, boolean isPrompt) { - String srcType = null; - ISystemRemoteElementAdapter rmtAdapter = SystemAdapterHelpers.getRemoteAdapter(firstSelection); - if (rmtAdapter != null) { - srcType = rmtAdapter.getRemoteSourceType(firstSelection); - if (srcType == null) - srcType = "null"; //$NON-NLS-1$ - else if (srcType.equals("")) //$NON-NLS-1$ - srcType = "blank"; //$NON-NLS-1$ - } else - return ourSubMenu; // should never happen - ISubSystem subsystem = rmtAdapter.getSubSystem(firstSelection); - ISubSystemConfiguration ssc = subsystem.getSubSystemConfiguration(); - - SystemCompileManager compileManager = null; - - if (firstSelection instanceof IAdaptable) { - ISystemCompileManagerAdapter adapter = (ISystemCompileManagerAdapter)((IAdaptable)firstSelection).getAdapter(ISystemCompileManagerAdapter.class); - if (null != adapter) - { - compileManager = adapter.getSystemCompileManager(ssc); - } - } - - if (null != compileManager) - { - SystemCompileManager thisCompileManager = compileManager; - SystemCompileProfile compileProfile = thisCompileManager.getCompileProfile(profile); - // compileProfile.addContributions(firstSelection); - SystemCompileType compileType = compileProfile.getCompileType(srcType); - - if (compileType != null) - { - SystemCompileCommand[] cmds = compileType.getCompileCommandsArray(); - for (int idx=0; idx<cmds.length; idx++) - { - SystemCompileAction action = new SystemCompileAction(shell, cmds[idx], isPrompt); - ourSubMenu.add(action); - } - } - } - - return ourSubMenu; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileCommand.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileCommand.java deleted file mode 100644 index c46881461..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileCommand.java +++ /dev/null @@ -1,440 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - * Martin Oberhuber (Wind River) - [180562][api] dont implement ISystemCompileXMLConstants - * Martin Oberhuber (Wind River) - [219975] Fix implementations of clone() - *******************************************************************************/ -package org.eclipse.rse.internal.useractions.ui.compile; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.Platform; -import org.eclipse.rse.internal.useractions.ui.SystemCmdSubstVarList; - -/** - * A compile command is represents a command that can be run on a remote system for the - * explicit purpose of compiling selected source members. - * <p> - * The attributes of a compile command include: - * <ul> - * <li>Nature. Either IBM-supplied or user defined. See {@link #setNature(String)} and {@link #getNature()} - * <li>Label. The visual name the user sees, representing this compile command. See {@link #setLabel(String)} and {@link #getLabel()} - * <li>DefaultString. The default IBM-supplied compile command (with parms) for support of restore defaults. See {@link #setDefaultString(String)} and {@link #getDefaultString()} - * <li>CurrentString. The current potentially user-edited compile command (with parms) for support of restore defaults. - * See {@link #setCurrentString(String)} and {@link #getCurrentString()} - * <li>MenuOption. Identifies what compile popup menu this command appears in, if any. - * See {@link #setMenuOption(String)} and {@link #getMenuOption()} and {@link #isPromptable()} and {@link #isNonPromptable()}. - * <li>Option. This compile commands position within the list of compile commands for a given compile type. - * See {@link #setOrder(int)} and {@link #getOrder()} - * <li>JobEnvironment. This is available for subsystems that need it, and they decide what to put in this attribute. - * </ul> - */ -public class SystemCompileCommand implements Cloneable, IAdaptable { - private SystemCompileType parentType; // reference to parent type - private String nature; - private String id; - private String label; - private String defaultString; - private String currentString; - private String menuOption; - private String jobEnv; - private int order; - private boolean isLabelEditable = true; - private static final String ID_IBM_PREFIX = "com.ibm"; //$NON-NLS-1$ - private static final String ID_USER_PREFIX = "user"; //$NON-NLS-1$ - - /** - * Constructor for SystemCompileCommand - */ - public SystemCompileCommand(SystemCompileType parentType) { - super(); - setParentType(parentType); - setMenuOptionBoth(); - } - - /** - * Constructor for SystemCompileCommand. Id and label must be a unique value. - */ - public SystemCompileCommand(SystemCompileType parentType, String id, String label, String nature, String defaultString, String currentString, String menuOption, int order) { - super(); - setParentType(parentType); - setId(id); - setLabel(label); - setNature(nature); - setDefaultString(defaultString); - setCurrentString(currentString); - setMenuOption(menuOption); - setOrder(order); - // if the given id is null, then try to configure it automatically. - // This is only good for IBM and user supplied commands. - // We assume ISV supplied commands have unique ids. - if (id == null) { - configureId(); - } - } - - /** - * Sets the parent type - * @param parentType the parent type - */ - public void setParentType(SystemCompileType parentType) { - this.parentType = parentType; - } - - /** - * Get the parent type - * @return the parent type - */ - public SystemCompileType getParentType() { - return parentType; - } - - /** - * Set the id. This is the unique id of the compile command. - * @param identifier the id - */ - public void setId(String identifier) { - this.id = identifier; - } - - /** - * Get the id. - * @return the unique id. - */ - public String getId() { - return id; - } - - /** - * Sets the id automatically. This only works for IBM supplied or user supplied commands. It does - * not work with ISV supplied commands. ISVs should set their own unique id. - */ - private void configureId() { - if (nature != null && label != null) { - if (isIBMSupplied()) { - setId(ID_IBM_PREFIX + "." + label); //$NON-NLS-1$ - } else if (isUserSupplied()) { - setId(ID_USER_PREFIX + "." + label); //$NON-NLS-1$ - } - } - } - - /** - * Set the label. This is the visual name the user sees in the compile command list. - * @param name the label - */ - public void setLabel(String name) { - this.label = name; - configureId(); // Id may change as a result - } - - /** - * Get the label. This is the visual name the user sees in the compile command list. - * @return the label - */ - public String getLabel() { - return label; - } - - /** - * Set the nature: either IBM-supplied or user defined. - * @param nature Typically one of {#link ISystemCompileXMLConstants#NATURE_IBM_VALUE} or {#link ISystemCompileXMLConstants#NATURE_USER_VALUE} - * @see #setIsIBMSupplied() - * @see #setIsUserSupplied() - * @see #setIsISVSupplied() - */ - public void setNature(String nature) { - this.nature = nature; - configureId(); // Id may change as a result - // For IBM and User supplied commands, we set editability parameters. We do this here because it's convenient. - // During a copy and paste of an IBM supplied command, nature of newly created command is user supplied, - // and so label becomes editable. - if (isIBMSupplied()) { - setLabelEditable(false); - setCommandStringEditable(true); - } else if (isUserSupplied()) { - setLabelEditable(true); - setCommandStringEditable(true); - } - } - - /** - * Indicate this is IBM supplied. This sets the nature to {#link ISystemCompileXMLConstants#NATURE_IBM_VALUE} - */ - public void setIsIBMSupplied() { - setNature(ISystemCompileXMLConstants.NATURE_IBM_VALUE); - } - - /** - * Indicate this is user supplied. This sets the nature to {#link ISystemCompileXMLConstants#NATURE_USER_VALUE} - */ - public void setIsUserSupplied() { - setNature(ISystemCompileXMLConstants.NATURE_USER_VALUE); - } - - /** - * Indicate this is ISV supplied. This sets the nature to {#link ISystemCompileXMLConstants#NATURE_ISV_VALUE} - */ - public void setIsISVSupplied() { - setNature(ISystemCompileXMLConstants.NATURE_ISV_VALUE); - } - - /** - * Get the nature: either IBM-supplied or user defined. - * @return the nature. One of {#link ISystemCompileXMLConstants#NATURE_IBM_VALUE} or {#link ISystemCompileXMLConstants#NATURE_USER_VALUE} - * @see #isIBMSupplied() - * @see #isUserSupplied() - */ - public String getNature() { - return nature; - } - - /** - * Return true if this is an IBM-supplied type. If false it is user or ISV supplied. - */ - public boolean isIBMSupplied() { - return nature.equals(ISystemCompileXMLConstants.NATURE_IBM_VALUE); - } - - /** - * Return true if this is an user-supplied type. If false it is IBM or ISV supplied. - */ - public boolean isUserSupplied() { - return nature.equals(ISystemCompileXMLConstants.NATURE_USER_VALUE); - } - - /** - * Return true if this is an ISV-supplied type. If false it is IBM or user supplied. - */ - public boolean isISVSupplied() { - return nature.equals(ISystemCompileXMLConstants.NATURE_ISV_VALUE); - } - - /** - * Set the default string. This is the IBM-supplied compile command (with parameters) that is restored when "Restore Defaults" is pressed. - * @param defaultString the default string - */ - public void setDefaultString(String defaultString) { - //this.defaultString = defaultString.toUpperCase(); // now leave it up to GUI to do massaging - this.defaultString = defaultString; - } - - /** - * Get the default string. This is the IBM-supplied compile command (with parameters) that is restored when "Restore Defaults" is pressed. - * @return the default string - */ - public String getDefaultString() { - return defaultString; - } - - /** - * Set the current string. This is the current value of the compile command (with parameters). - * @param currentString the current string - */ - public void setCurrentString(String currentString) { - //this.currentString = currentString.toUpperCase(); now leave it up to GUI to massage command string - this.currentString = currentString; - } - - /** - * Get the current string. This is the current value of the compile command (with parameters). - * @return the current string - */ - public String getCurrentString() { - return currentString; - } - - /** - * Set the menu option. Dictates in what popup menu, if any, this compile command appears in. - * @param menuOption the menu option. - * One of {#link ISystemCompileXMLConstants#MENU_PROMPTABLE_VALUE} - * or {#link ISystemCompileXMLConstants#MENU_NON_PROMPTABLE_VALUE} - * or {#link ISystemCompileXMLConstants#MENU_BOTH_VALUE} - * or {#link ISystemCompileXMLConstants#MENU_NONE_VALUE} - */ - public void setMenuOption(String menuOption) { - this.menuOption = menuOption; - } - - /** - * Fastpath to setting the menu option to both, which is the typical case - */ - public void setMenuOptionBoth() { - setMenuOption(ISystemCompileXMLConstants.MENU_BOTH_VALUE); - } - - /** - * Get the menu option. Dictates in what popup menu, if any, this compile command appears in. - * @return the menu option: - * One of {#link ISystemCompileXMLConstants#MENU_PROMPTABLE_VALUE} - * or {#link ISystemCompileXMLConstants#MENU_NON_PROMPTABLE_VALUE} - * or {#link ISystemCompileXMLConstants#MENU_BOTH_VALUE} - * or {#link ISystemCompileXMLConstants#MENU_NONE_VALUE} - */ - public String getMenuOption() { - return menuOption; - } - - /** - * Set the order. That is, this compile commands position within the list of compile commands for a given compile type. - * @returns the compile command's order or position. - */ - public void setOrder(int order) { - this.order = order; - } - - /** - * Get the order. That is, this compile commands position within the list of compile commands for a given compile type. - * @return the order or position. - */ - public int getOrder() { - return order; - } - - /** - * Returns if it is promptable. Queries the value of the menuOption attribute. - * - * @return true if promptable, false otherwise - */ - public boolean isPromptable() { - if (menuOption.equals(ISystemCompileXMLConstants.MENU_BOTH_VALUE) || menuOption.equals(ISystemCompileXMLConstants.MENU_PROMPTABLE_VALUE)) - return true; - else - return false; - } - - /** - * Returns if it is non-promptable. Queries the value of the menuOption attribute. - */ - public boolean isNonPromptable() { - if (menuOption.equals(ISystemCompileXMLConstants.MENU_BOTH_VALUE) || menuOption.equals(ISystemCompileXMLConstants.MENU_NON_PROMPTABLE_VALUE)) - return true; - else - return false; - } - - /** - * Set the job environment property. This is subsystem specific, and not used by all subsystems. - */ - public void setJobEnvironment(String jobenv) { - this.jobEnv = jobenv; - } - - /** - * Get the job environment property. - */ - public String getJobEnvironment() { - return jobEnv; - } - - /** - * Sets whether the label is editable in the Work With Compile Commands dialog. - */ - public void setLabelEditable(boolean editable) { - isLabelEditable = editable; - } - - /** - * Gets whether the label is editable in the Work With Compile Commands dialog. - */ - public boolean isLabelEditable() { - return isLabelEditable; - } - - /** - * Sets whether the command string is editable in the Work With Compile Commands dialog. - */ - public void setCommandStringEditable(boolean editable) { - } - - /** - * Gets whether the command string is editable in the Work With Compile Commands dialog. - */ - public boolean isCommandStringEditable() { - // return isCommandStringEditable; - return true; // for 5.1, all command strings are editable - // TODO: For V6, think about the scenario when it's false - // how do we handle that in the various dialogs? - } - - /** - * Clone the object: creates a new compile command and copies all its attributes. - * - * During the process of cloning, the Nature is always set to be - * User-supplied - so even if an IBM-Supplied compile command is cloned, - * the result will be treated as User-supplied. - * - * Subclasses must ensure that such a deep copy operation is always - * possible, so their state must always be cloneable. Which should - * always be possible to achieve, since this Object also needs to be - * serializable. If a subclass adds additional complex attributes, - * this method should be subclassed to clone those attributes. - */ - public Object clone() { - ////Old invalid method of cloning does not maintain runtime type - //SystemCompileCommand clone = new SystemCompileCommand(getParentType(), getId(), getLabel(), ISystemCompileXMLConstants.NATURE_USER_VALUE, null, getCurrentString(), getMenuOption(), getOrder()); - SystemCompileCommand clone = null; - try { - clone = (SystemCompileCommand)super.clone(); - } catch(CloneNotSupportedException e) { - //assert false; //can never happen - throw new RuntimeException(e); - } - clone.setNature(ISystemCompileXMLConstants.NATURE_USER_VALUE); - clone.setDefaultString(null); - clone.configureId(); - if (jobEnv != null) clone.setJobEnvironment(jobEnv); - return clone; - } - - /** - * Print the full command string to standard out, for debugging purposes - */ - public void printCommand(String indent) { - System.out.println(indent + "Label: '" + label + "', Cmd: '" + currentString + "'"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } - - /** - * Do substitution of any variables found in the compile command, using the given - * remote source object. It is the responsibility of the caller of this method to - * supply a "substitutor" that has knowledge of the supported substitution variables - * for these compile commands. Each implementation will override the substitutor - * interface to support the necessary getters for resolving their supported variables. - * <p> - * This method retrieves the substitution variable list from the compile manager, and - * then calls doSubstitutions in it. This in turn will call back to the supplied substitutor - * for each match it finds in compile string, of a variable in its list. - */ - public String doVariableSubstitution(Object remoteObject, ISystemCompileCommandSubstitutor substitutor) { - SystemCompileManager mgr = parentType.getParentProfile().getParentManager(); - mgr.setCurrentCompileCommand(this); // defect 47808 - SystemCmdSubstVarList substVarList = mgr.getSubstitutionVariableList(); - String substitutedString = substVarList.doSubstitutions(getCurrentString(), remoteObject, substitutor); - mgr.setCurrentCompileCommand(null); // defect 47808 - //System.out.println("mgr class = " + mgr.getClass().getName()); - //System.out.println("substVL class = " + substVarList.getClass().getName()); - //System.out.println("substitutor class = " + substitutor.getClass().getName()); - return substitutedString; - } - - /** - * Return this object as a string. - */ - public String toString() { - return getCurrentString(); - } - - /** - * This is the method required by the IAdaptable interface. - * Given an adapter class type, return an object castable to the type, or - * null if this is not possible. - */ - public Object getAdapter(Class adapterType) { - return Platform.getAdapterManager().getAdapter(this, adapterType); - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileCommandActionCopy.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileCommandActionCopy.java deleted file mode 100644 index e03bd8f43..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileCommandActionCopy.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.compile; - -/******************************************************************************* - * Copyright (c) 2002, 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 - *******************************************************************************/ -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources; -import org.eclipse.rse.ui.ISystemContextMenuConstants; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.actions.SystemBaseAction; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; - -/** - * The action is used within the Work With Compile Commands dialog, in the context menu of the selected compile command. - * It is used to copy the selected compile command to the clipboard for subsequent paste. - */ -public class SystemCompileCommandActionCopy extends SystemBaseAction { - private SystemWorkWithCompileCommandsDialog parentDialog; - - /** - * Constructor - */ - public SystemCompileCommandActionCopy(SystemWorkWithCompileCommandsDialog parentDialog) { - super(SystemUDAResources.RESID_WWCOMPCMDS_ACTION_COPY_LABEL, SystemUDAResources.RESID_WWCOMPCMDS_ACTION_COPY_TOOLTIP, PlatformUI.getWorkbench().getSharedImages().getImageDescriptor( - ISharedImages.IMG_TOOL_COPY), null); - allowOnMultipleSelection(false); - this.parentDialog = parentDialog; - setContextMenuGroup(ISystemContextMenuConstants.GROUP_REORGANIZE); - setHelp(RSEUIPlugin.HELPPREFIX + "wwcc2000"); //$NON-NLS-1$ - } - - /** - * We override from parent to do unique checking. - * We intercept to ensure this is isn't the "new" filter string - */ - public boolean updateSelection(IStructuredSelection selection) { - return parentDialog.canCopy(); - } - - /** - * This is the method called when the user selects this action. - */ - public void run() { - parentDialog.doCopy(); - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileCommandActionDelete.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileCommandActionDelete.java deleted file mode 100644 index c6d6a8fff..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileCommandActionDelete.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.compile; - -/******************************************************************************* - * Copyright (c) 2002, 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 - *******************************************************************************/ -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources; -import org.eclipse.rse.ui.ISystemContextMenuConstants; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.actions.SystemBaseAction; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; - -/** - * The action is used within the Work With Compile Commands dialog, in the context menu of the selected compile command. - * It is used to delete the selected compile command. - */ -public class SystemCompileCommandActionDelete extends SystemBaseAction { - private SystemWorkWithCompileCommandsDialog parentDialog; - - /** - * Constructor - */ - public SystemCompileCommandActionDelete(SystemWorkWithCompileCommandsDialog parentDialog) { - super(SystemUDAResources.RESID_WWCOMPCMDS_ACTION_DELETE_LABEL, SystemUDAResources.RESID_WWCOMPCMDS_ACTION_DELETE_TOOLTIP, PlatformUI.getWorkbench().getSharedImages().getImageDescriptor( - ISharedImages.IMG_TOOL_DELETE), null); - allowOnMultipleSelection(false); - this.parentDialog = parentDialog; - setContextMenuGroup(ISystemContextMenuConstants.GROUP_REORGANIZE); - setHelp(RSEUIPlugin.HELPPREFIX + "wwcc1000"); //$NON-NLS-1$ - } - - /** - * We override from parent to do unique checking. - * We intercept to ensure this is isn't the "new" filter string - */ - public boolean updateSelection(IStructuredSelection selection) { - return parentDialog.canDelete(); - } - - /** - * This is the method called when the user selects this action. - */ - public void run() { - parentDialog.doDelete(); - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileCommandActionMoveDown.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileCommandActionMoveDown.java deleted file mode 100644 index 148daf866..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileCommandActionMoveDown.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.compile; - -/******************************************************************************* - * Copyright (c) 2002, 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 - *******************************************************************************/ -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources; -import org.eclipse.rse.ui.ISystemContextMenuConstants; -import org.eclipse.rse.ui.ISystemIconConstants; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.actions.SystemBaseAction; - -/** - * The action is used within the Work With Compile Commands dialog, in the context menu of the selected compile command. - * It is used to move the selected compile command up by one in the list. - */ -public class SystemCompileCommandActionMoveDown extends SystemBaseAction { - private SystemWorkWithCompileCommandsDialog parentDialog; - - /** - * Constructor - */ - public SystemCompileCommandActionMoveDown(SystemWorkWithCompileCommandsDialog parentDialog) { - super(SystemUDAResources.RESID_WWCOMPCMDS_ACTION_MOVEDOWN_LABEL, SystemUDAResources.RESID_WWCOMPCMDS_ACTION_MOVEDOWN_TOOLTIP, RSEUIPlugin.getDefault().getImageDescriptor( - ISystemIconConstants.ICON_SYSTEM_MOVEDOWN_ID), null); - allowOnMultipleSelection(false); - this.parentDialog = parentDialog; - setContextMenuGroup(ISystemContextMenuConstants.GROUP_REORDER); - setHelp(RSEUIPlugin.HELPPREFIX + "wwcc5000"); //$NON-NLS-1$ - } - - /** - * We override from parent to do unique checking. - * We intercept to ensure this is isn't the last filter string in the list - */ - public boolean updateSelection(IStructuredSelection selection) { - return parentDialog.canMoveDown(); - } - - /** - * This is the method called when the user selects this action. - */ - public void run() { - parentDialog.doMoveDown(); - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileCommandActionMoveUp.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileCommandActionMoveUp.java deleted file mode 100644 index 098089310..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileCommandActionMoveUp.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.compile; - -/******************************************************************************* - * Copyright (c) 2002, 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 - *******************************************************************************/ -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources; -import org.eclipse.rse.ui.ISystemContextMenuConstants; -import org.eclipse.rse.ui.ISystemIconConstants; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.actions.SystemBaseAction; - -/** - * The action is used within the Work With Compile Commands dialog, in the context menu of the selected compile command. - * It is used to move the selected compile command down by one in the list - */ -public class SystemCompileCommandActionMoveUp extends SystemBaseAction { - private SystemWorkWithCompileCommandsDialog parentDialog; - - /** - * Constructor - */ - public SystemCompileCommandActionMoveUp(SystemWorkWithCompileCommandsDialog parentDialog) { - super(SystemUDAResources.RESID_WWCOMPCMDS_ACTION_MOVEUP_LABEL, SystemUDAResources.RESID_WWCOMPCMDS_ACTION_MOVEUP_TOOLTIP, RSEUIPlugin.getDefault().getImageDescriptor( - ISystemIconConstants.ICON_SYSTEM_MOVEUP_ID), null); - allowOnMultipleSelection(false); - this.parentDialog = parentDialog; - setContextMenuGroup(ISystemContextMenuConstants.GROUP_REORDER); - setHelp(RSEUIPlugin.HELPPREFIX + "wwcc4000"); //$NON-NLS-1$ - } - - /** - * We override from parent to do unique checking. - * We intercept to ensure this is isn't the fist filter string - */ - public boolean updateSelection(IStructuredSelection selection) { - return parentDialog.canMoveUp(); - } - - /** - * This is the method called when the user selects this action. - */ - public void run() { - parentDialog.doMoveUp(); - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileCommandActionPaste.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileCommandActionPaste.java deleted file mode 100644 index 27e9b96d2..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileCommandActionPaste.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.compile; - -/******************************************************************************* - * Copyright (c) 2002, 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 - *******************************************************************************/ -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources; -import org.eclipse.rse.ui.ISystemContextMenuConstants; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.actions.SystemBaseAction; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; - -/** - * The action is used within the Work With Compile Commands dialog, in the context menu of the selected compile command. - * It is used to paste the copied compile command from the clipboard to the list. - */ -public class SystemCompileCommandActionPaste extends SystemBaseAction { - private SystemWorkWithCompileCommandsDialog parentDialog; - - /** - * Constructor - */ - public SystemCompileCommandActionPaste(SystemWorkWithCompileCommandsDialog parentDialog) { - super(SystemUDAResources.RESID_WWCOMPCMDS_ACTION_PASTE_LABEL, SystemUDAResources.RESID_WWCOMPCMDS_ACTION_PASTE_TOOLTIP, PlatformUI.getWorkbench().getSharedImages().getImageDescriptor( - ISharedImages.IMG_TOOL_PASTE), null); - allowOnMultipleSelection(false); - this.parentDialog = parentDialog; - setContextMenuGroup(ISystemContextMenuConstants.GROUP_REORGANIZE); - setHelp(RSEUIPlugin.HELPPREFIX + "wwcc3000"); //$NON-NLS-1$ - } - - /** - * We override from parent to do unique checking. - * We intercept to ensure there is something in the clipboard to copy - */ - public boolean updateSelection(IStructuredSelection selection) { - return parentDialog.canPaste(); - } - - /** - * This is the method called when the user selects this action. - */ - public void run() { - parentDialog.doPaste(); - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileCommandActionRestoreDefaults.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileCommandActionRestoreDefaults.java deleted file mode 100644 index b5c047c94..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileCommandActionRestoreDefaults.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.compile; - -/******************************************************************************* - * Copyright (c) 2002, 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 - *******************************************************************************/ -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources; -import org.eclipse.rse.ui.ISystemContextMenuConstants; -import org.eclipse.rse.ui.ISystemIconConstants; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.actions.SystemBaseAction; - -/** - * The action is used within the Work With Compile Commands dialog, in the context menu - * of the selected compile command. - * It is used to restore shipped defaults of the selected IBM-supplied compile command. - */ -public class SystemCompileCommandActionRestoreDefaults extends SystemBaseAction { - private SystemWorkWithCompileCommandsDialog parentDialog; - - /** - * Constructor - */ - public SystemCompileCommandActionRestoreDefaults(SystemWorkWithCompileCommandsDialog parentDialog) { - super(SystemUDAResources.RESID_WWCOMPCMDS_ACTION_RESTORE_LABEL, SystemUDAResources.RESID_WWCOMPCMDS_ACTION_RESTORE_TOOLTIP, RSEUIPlugin.getDefault().getImageDescriptorFromIDE( - ISystemIconConstants.ICON_IDE_REFRESH_ID), null); - allowOnMultipleSelection(false); - this.parentDialog = parentDialog; - setContextMenuGroup(ISystemContextMenuConstants.GROUP_CHANGE); - setHelp(RSEUIPlugin.HELPPREFIX + "wwcc6000"); //$NON-NLS-1$ - } - - /** - * We override from parent to do unique checking. - * We intercept to ensure this is an IBM-supplied compile command - */ - public boolean updateSelection(IStructuredSelection selection) { - return parentDialog.canRestore(); - } - - /** - * This is the method called when the user selects this action. - */ - public void run() { - parentDialog.doRestore(); - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileCommandContentProvider.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileCommandContentProvider.java deleted file mode 100644 index fda07183a..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileCommandContentProvider.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.compile; - -/******************************************************************************* - * Copyright (c) 2002, 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 - *******************************************************************************/ -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.Viewer; - -/** - * Content provider for the list viewer in the Work With Compile Commands dialog. - */ -public class SystemCompileCommandContentProvider implements IStructuredContentProvider { - /** - * Constructor for SystemCompileCommandContentProvider. - */ - public SystemCompileCommandContentProvider() { - super(); - } - - /** - * @see org.eclipse.jface.viewers.IContentProvider#dispose() - */ - public void dispose() { - } - - /** - * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(Viewer, Object, Object) - */ - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - } - - /** - * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(Object) - */ - public Object[] getElements(Object inputElement) { - return null; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileCommandEditPane.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileCommandEditPane.java deleted file mode 100644 index 5365019a2..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileCommandEditPane.java +++ /dev/null @@ -1,677 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.compile; - -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - * David Dykstal (IBM) - [186589] move user types, user actions, and compile commands - * API to the user actions plugin - *******************************************************************************/ -import java.util.Vector; - -import org.eclipse.rse.core.model.IHost; -import org.eclipse.rse.internal.useractions.ui.ISystemCommandTextAdditionalGUIProvider; -import org.eclipse.rse.internal.useractions.ui.SystemCmdSubstVarList; -import org.eclipse.rse.internal.useractions.ui.SystemCommandTextField; -import org.eclipse.rse.internal.useractions.ui.SystemCommandViewerConfiguration; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources; -import org.eclipse.rse.internal.useractions.ui.validators.ValidatorCompileCommandLabel; -import org.eclipse.rse.services.clientserver.messages.SystemMessage; -import org.eclipse.rse.shells.ui.view.ISystemCommandTextModifyListener; -import org.eclipse.rse.ui.ISystemMassager; -import org.eclipse.rse.ui.SystemWidgetHelpers; -import org.eclipse.rse.ui.validators.ISystemValidator; -import org.eclipse.rse.ui.validators.ISystemValidatorUniqueString; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; - -/** - * This class prompts the user to create or edit the contents of a single - * compile command. This edit pane is used in the Work With Compile Commands dialog. - * <p> - * So what is the "contract" the edit pane has to fulfill? - * <ul> - * <li>work in "new" or "edit" mode. In the latter case it is given a SystemCompileCommand as input. - * This needs to be switchable on the fly. This is typically automated by use of a "state machine". - * <li>give as output a new or updated SystemCompileCommand - * <li>allow interested parties to know when the contents have been changed, as they change, - * and whether there are errors in those changes - * </ul> - * Contractually, here are the methods called by the main page of the new filter wizard: - * <ul> - * <li>addChangeListener ... no need to ever override - * <li>setSubSystem ... no need to ever override - * <li>setCompileCommandValidator ... no need to ever override - * <li>isComplete ... no need to ever override - * <li>createContents ... you will typically override - * <li>verify ... you will typically override - * <li>getInitialFocusControl ... you will typically override - * <li>getCompileCommand ... you will typically override - * <li>areFieldsComplete ... you will typically override - * </ul> - */ -public class SystemCompileCommandEditPane implements SelectionListener, ISystemCommandTextAdditionalGUIProvider, ISystemCommandTextModifyListener { - // inputs - protected Shell shell; - protected ISystemCompileCommandEditPaneHoster hoster; - protected SystemCompileManager compileManager; - protected SystemCompileCommand inputCompileCommand; - protected SystemCompileType parentCompileType; - protected Vector listeners = new Vector(); - protected SystemCmdSubstVarList varList; - protected boolean newMode = true; - protected boolean ignoreChanges; - // default GUI - protected Label labelLabel; - protected Text textLabel; - protected SystemCommandTextField commandField; - // state - protected SystemMessage errorMessage; - protected boolean skipEventFiring; - protected boolean fromVerify; - protected boolean caseSensitive; - protected Control controlInError = null; - // validators - protected ISystemValidator cmdLabelValidator; - - /** - * Constructor - * @param compileManager - the compile manager owner of this compile command - * @param shell - the shell of the wizard or dialog host this - * @param owner - the dialog or property page hosting this edit pane - * @param caseSensitive - whether the file system is case sensitive for where this compile command will run. Usually from isCaseSensitive() of a subsystem factory. - */ - public SystemCompileCommandEditPane(SystemCompileManager compileManager, Shell shell, ISystemCompileCommandEditPaneHoster owner, boolean caseSensitive) { - super(); - this.compileManager = compileManager; - this.shell = shell; - this.caseSensitive = caseSensitive; - this.commandField = new SystemCommandTextField(getCommandTextViewerConfiguration()); - this.commandField.setSubstitutionVariableList(compileManager.getSubstitutionVariableList()); - this.hoster = owner; - } - - // ------------------------------ - // HELPER METHODS... - // ------------------------------ - /** - * Return the shell given us in the ctor - */ - protected Shell getShell() { - return shell; - } - - /** - * Return the input compile command as given us in setCompileCommand - */ - protected SystemCompileCommand getInputCompileCommand() { - return inputCompileCommand; - } - - /** - * For subclasses: return the input compile manager - */ - protected SystemCompileManager getCompileManager() { - return compileManager; - } - - /** - * For subclasses within the subsystem factory framework: return the system connection - * within which this dialog was launched. - */ - protected IHost getSystemConnection() { - return compileManager.getSystemConnection(); - } - - // ------------------------------ - // CONFIGURATION/INPUT METHODS... - // ------------------------------ - /** - * Set the validator to use for the compile command. By default, ValidatorCompileCommandLabel is used. - */ - public void setCompileLabelValidator(ISystemValidator validator) { - this.cmdLabelValidator = validator; - } - - /** - * Turn on ignore changes mode. Subclasses typically can just query the inherited - * field ignoreChanges, unless they need to set the ignoreChanges mode in their - * own composite widgets, in which case they can override and intercept this. - */ - protected void setIgnoreChanges(boolean ignoreChanges) { - this.ignoreChanges = ignoreChanges; - commandField.setIgnoreChanges(ignoreChanges); - } - - /** - * Identify a listener interested in any changes made to the filter string, - * as they happen - */ - public void addChangeListener(ISystemCompileCommandEditPaneListener l) { - listeners.add(l); - } - - /** - * Remove a listener interested in any changes made to the filter string, - * as they happen - */ - public void removeChangeListener(ISystemCompileCommandEditPaneListener l) { - listeners.remove(l); - } - - /** - * Set the action command validator. This is called per keystroke as - * the user types the command. - */ - public void setCommandValidator(ISystemValidator validator) { - commandField.setCommandValidator(validator); - } - - /** - * Set the action command massager. This is called before saving the - * command to the persistent store, to allow for massaging what the - * user typed, such as doing intelligent uppercasing. - */ - public void setCommandMassager(ISystemMassager massager) { - commandField.setCommandMassager(massager); - } - - /** - * Set the substitution variable list that Insert Variable will use. - */ - public void setSubstitutionVariableList(SystemCmdSubstVarList varList) { - commandField.setSubstitutionVariableList(varList); - } - - /** - * For child classes to return their own subclasses of the default configurator - * used to enable proposal support in the command entry field. - */ - protected SystemCommandViewerConfiguration getCommandTextViewerConfiguration() { - return new SystemCommandViewerConfiguration(); - } - - /** - * For child classes (such as iSeries IFS) that need to dynamically change the command - * entry field configuration, on the fly. - */ - protected void setCommandTextViewerConfiguration(SystemCommandViewerConfiguration cmdAssistant) { - commandField.setCommandTextViewerConfiguration(cmdAssistant); - } - - // ------------------------------ - // LIFECYCLE METHODS... - // ------------------------------ - /** - * Set the input filter string, in edit mode. - * Or pass null if reseting to new mode. - */ - public void setCompileCommand(SystemCompileType parentCompileType, SystemCompileCommand compileCommand) { - this.inputCompileCommand = compileCommand; - //System.out.println("inside setCompileCommand: input null? " + (compileCommand==null)); - this.parentCompileType = parentCompileType; - if ((parentCompileType != null) && (cmdLabelValidator instanceof ISystemValidatorUniqueString)) { - Vector existingLabels = parentCompileType.getExistingLabels(); - if (compileCommand != null) existingLabels.removeElement(compileCommand.getLabel()); - ((ISystemValidatorUniqueString) cmdLabelValidator).setExistingNamesList(existingLabels); - } - newMode = (compileCommand == null); - setIgnoreChanges(true); - resetFields(); - if (compileCommand != null) doInitializeFields(); - enableExtraButtons(); - if (newMode) - resetExtraButtonsForNewMode(); - else - resetExtraButtons(compileCommand); - setIgnoreChanges(false); - } - - /** - * Save all pending changes. Called by dialog when user Presses Apply. - * @return new or updated compile command object. Caller must call writeToDisk() on the parent SystemCompileProfile object - */ - public SystemCompileCommand saveChanges() { - String cmdLabel = textLabel.getText().trim(); - if (cmdLabel.length() == 0) return null; - String cmdString = commandField.getMassagedCommandText(); - if (cmdString.length() == 0) return null; - cmdString = preSaveMassage(cmdString); - SystemCompileCommand currentCmd = inputCompileCommand; - if (currentCmd == null) // new mode? Must create the new compile command object - { - currentCmd = new SystemCompileCommand(parentCompileType); - currentCmd.setDefaultString(cmdString); - currentCmd.setIsUserSupplied(); - } else if (commandField.getCommandMassager() != null) { - setIgnoreChanges(true); // disable modify listeners - setCommandText(cmdString); - setIgnoreChanges(false); // re-enable modify listeners - } - if (!caseSensitive) { - //cmdLabel = cmdLabel.toUpperCase(); I0 decision not to do this anymore - //cmdString = cmdString.toUpperCase(); we use a massager now - } - currentCmd.setLabel(cmdLabel); - currentCmd.setCurrentString(cmdString); - processExtraButtonsChanges(currentCmd); // allow subclasses to save their extra data - /* - String option = null; - if (yesPromptButton.getSelection() && noPromptButton.getSelection()) - option = ISystemCompileXMLConstants.MENU_BOTH_VALUE; - else if (yesPromptButton.getSelection() && !noPromptButton.getSelection()) - option = ISystemCompileXMLConstants.MENU_PROMPTABLE_VALUE; - else if (!yesPromptButton.getSelection() && noPromptButton.getSelection()) - option = ISystemCompileXMLConstants.MENU_NON_PROMPTABLE_VALUE; - else - option = ISystemCompileXMLConstants.MENU_NONE_VALUE; - currentCmd.setMenuOption(option); - */ - return currentCmd; - } - - /** - * Opportunity for subclasses to perform any additional massaging of the - * user-entered command string, just prior to saving it. - */ - protected String preSaveMassage(String commandString) { - return commandString; - } - - /** - * In the Work With dialog, this edit pane is shown on the right side, beside - * the compile command selection list. Above it is a label, that shows something - * like "Selected Compile Command" in edit mode, or "New Compile Command" in new mode. - * <p> - * This method gives subclasses the opportunity to specify unique values for this label. - * In addition to setting the text, the tooltip text should also be set. - */ - public void configureHeadingLabel(Label label) { - if (!newMode) { - label.setText(SystemUDAResources.RESID_WWCOMPCMDS_EDITCMD_LABEL); - label.setToolTipText(SystemUDAResources.RESID_WWCOMPCMDS_EDITCMD_TOOLTIP); - } else { - label.setText(SystemUDAResources.RESID_WWCOMPCMDS_NEWCMD_LABEL); - label.setToolTipText(SystemUDAResources.RESID_WWCOMPCMDS_NEWCMD_TOOLTIP); - } - } - - /** - * Populate the pane with the GUI widgets - * @param parent of the pane - * @return Control - */ - public Control createContents(Composite parent) { - if (cmdLabelValidator == null) cmdLabelValidator = new ValidatorCompileCommandLabel(); - if (cmdLabelValidator instanceof ISystemValidatorUniqueString) ((ISystemValidatorUniqueString) cmdLabelValidator).setCaseSensitive(caseSensitive); - // Inner composite - int nbrColumns = 3; - Composite composite_prompts = SystemWidgetHelpers.createComposite(parent, nbrColumns); - ((GridLayout) composite_prompts.getLayout()).marginWidth = 0; - // COMPILE LABEL PROMPT - textLabel = SystemWidgetHelpers.createLabeledTextField(composite_prompts, null, getCompileCommandLabel(), getCompileCommandTooltip()); - labelLabel = SystemWidgetHelpers.getLastLabel(); - textLabel.setTextLimit(cmdLabelValidator.getMaximumNameLength()); - ((GridData) textLabel.getLayoutData()).horizontalSpan = nbrColumns - 1; - // COMPILE COMMAND PROMPT - /* - textString = SystemWidgetHelpers.createLabeledTextField(composite_prompts,null,rb, getCompileCommandPromptRBKey()); - labelString = SystemWidgetHelpers.getLastLabel(); - //textString.setTextLimit(1000); - ((GridData)textString.getLayoutData()).widthHint=300; - */ - commandField.createContents(composite_prompts, nbrColumns, this); - resetFields(); - doInitializeFields(); - // add keystroke listeners... - textLabel.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - validateLabelInput(); - } - }); - commandField.addModifyListener(this); - return composite_prompts; - } - - /** - * Return the control to recieve initial focus. Should be overridden if you override createContents - */ - public Control getInitialFocusControl() { - if (textLabel.isEnabled()) - return textLabel; - else - return commandField.getCommandWidget(); - } - - /** - * Overridable entry point for subclasses that wish to put something to the right of the "Command:" label - * From interface ISystemCommandTextAdditionalGUIProvider. - * @return true if something entered to take up the available columns, false otherwise (will be padded) - */ - public boolean createCommandLabelLineControls(Composite parent, int availableColumns) { - return false; - } - - /** - * Create additional buttons, to go under command prompt. - * Overridable. - * From interface ISystemCommandTextAdditionalGUIProvider. - * @return true if something entered to take up the available columns, false otherwise (will be padded) - */ - public boolean createExtraButtons(Composite parent, int availableColumns) { - return false; - } - - /** - * Enable/disable extra buttons added by subclass. - * Called when state changes - * Overridable - */ - protected void enableExtraButtons() { - } - - /** - * Overridable method for resetting GUI in subclass-supplied additional GUI, - * when in "new" mode - */ - protected void resetExtraButtonsForNewMode() { - } - - /** - * Overridable method for resetting GUI in subclass-supplied additional GUI, - * when in "edit" mode - */ - protected void resetExtraButtons(SystemCompileCommand originalCmd) { - } - - /** - * Overridable method for saving data in subclass-supplied additional GUI. - */ - protected void processExtraButtonsChanges(SystemCompileCommand currentCmd) { - } - - protected String getCompileCommandLabel() { - return SystemUDAResources.RESID_WWCOMPCMDS_CMDLABEL_LABEL; - } - - protected String getCompileCommandTooltip() { - return SystemUDAResources.RESID_WWCOMPCMDS_CMDLABEL_TOOLTIP; - } - - protected String getCompileCommandPromptLabel() { - return SystemUDAResources.RESID_WWCOMPCMDS_CMD_LABEL; - } - - protected String getCompileCommandPromptTooltip() { - return SystemUDAResources.RESID_WWCOMPCMDS_CMD_TOOLTIP; - } - - /** - * Initialize the input fields based on the inputCompileCommand, and perhaps subsystem. - * This can be called before createContents, so test for null widgets first! - * Prior to this being called, resetFields is called to set the initial default state prior to input - */ - protected void doInitializeFields() { - //System.out.println("inside doInitializeFields: textString null? " + (commandField==null) + " input null? " + (inputCompileCommand==null)); - if (commandField == null) return; // do nothing - if (inputCompileCommand != null) { - textLabel.setText(inputCompileCommand.getLabel()); - /* if (!inputCompileCommand.isLabelEditable()) { // ibm or vendor supplied? - textLabel.setEnabled(false); - } */ - textLabel.setEnabled(inputCompileCommand.isLabelEditable()); - commandField.setCommandText(inputCompileCommand.getCurrentString()); - /* if (!inputCompileCommand.isCommandStringEditable()) { - System.out.println("Compile command not editable"); - commandField.enableCommandWidget(false); - } */ - commandField.enableCommandWidget(inputCompileCommand.isCommandStringEditable()); - } - } - - /** - * This is called in the work with compile commands dialog when the user selects "new", or selects another command. - * You must override this if you override createContents. Be sure to test if the contents have even been created yet! - */ - protected void resetFields() { - textLabel.setEnabled(true); - textLabel.setText(""); //$NON-NLS-1$ - commandField.setCommandText(""); //$NON-NLS-1$ - errorMessage = null; - } - - /** - * Do not override. Instead, override areFieldsComplete(). - * <p> - * This is called by the dialog when first shown, to decide if the default information - * is complete enough to enable finish. It doesn't do validation, that will be done when - * finish is pressed. - */ - public boolean isComplete() { - boolean complete = true; - if (errorMessage != null) // pending errors? - complete = false; // clearly not complete. - else - complete = areFieldsComplete(); - return complete; - } - - /** - * Must be overridden if createContents is overridden. - * <p> - * This is called by the isComplete, to decide if the default information - * is complete enough to enable finish. It doesn't do validation, that will be done when - * finish is pressed. - */ - protected boolean areFieldsComplete() { - if (commandField == null) - return false; - else - return (textLabel.getText().trim().length() > 0) && (commandField.getCommandText().length() > 0); - } - - /** - * Are errors pending? Used in dialog to prevent changing the compile command selection - */ - public boolean areErrorsPending() { - return (errorMessage != null); - } - - /** - * Clear any pending errors. Called when Revert pressed. - */ - public void clearErrorMessage() { - errorMessage = null; - } - - /** - * Callback from SystemCommandTextField when the user modifies the command. - * @param cmdText - current contents of the field - * @param errorMessage - potential error detected by the default validator - */ - public void commandModified(String cmdText, SystemMessage errorMessage) { - this.errorMessage = errorMessage; - processCommandTextChange(cmdText, (errorMessage != null)); - if (!fromVerify) fireChangeEvent(errorMessage); - } - - /** - * Method called as user types into the command field - * Encapsulated out so that it can be called from various types of listeners. - * Further, it is easily overridden - */ - protected void processCommandTextChange(String newText, boolean hasError) { - } - - /** - * Set the command text - */ - protected void setCommandText(String text) { - commandField.setCommandText(text); - } - - /** - * Get the command text as is, no massaging done. - */ - protected String getCommandText() { - return commandField.getCommandText(); - } - - // ------------------------------ - // PRIVATE METHODS - // ------------------------------ - /** - * Fire an event to all registered listeners, that the user has changed the - * compile command. Include the error message, if in error, so it can be displayed to the user. - * <p> - * Because this is used to enable/disable the Next and Finish buttons it is important - * to call it when asked to do verification, even if nothing has changed. - * <p> - * It is more efficient, however, to defer the event firing during a full verification - * until after the last widget has been verified. To enable this, set the protected - * variable "skipEventFiring" to true at the top of your verify event, then to "false" - * at the end. Then do fireChangeEvent(errorMessage); - */ - protected void fireChangeEvent(SystemMessage error) { - if (skipEventFiring) return; - for (int idx = 0; idx < listeners.size(); idx++) { - ISystemCompileCommandEditPaneListener l = (ISystemCompileCommandEditPaneListener) listeners.elementAt(idx); - l.compileCommandChanged(error); - } - } - - // --------------------------------------------- - // METHODS FOR VERIFYING INPUT PER KEYSTROKE ... - // --------------------------------------------- - /** - * Validates compile command label as entered so far in the text field. - * Not called if you override createContents() and verify() - */ - protected SystemMessage validateLabelInput() { - if (ignoreChanges) return errorMessage; - errorMessage = cmdLabelValidator.validate(textLabel.getText().trim()); - //if ((errorMessage == null) && !fromVerify) - // errorMessage = validate(true, false); - if (!fromVerify) fireChangeEvent(errorMessage); - return errorMessage; - } - - /** - * Validates compile command string as entered so far in the text field. - * Not called if you override createContents() and verify() - */ - protected SystemMessage validateStringInput() { - if (ignoreChanges) return errorMessage; - errorMessage = commandField.validateCommand(); - if (!fromVerify) fireChangeEvent(errorMessage); - return errorMessage; - } - - /** - * Does complete verification of input fields. This has to handle being called - * from a particular validator method or from verify. - * - * @return error message if there is one, else null if ok - */ - public SystemMessage validate(boolean skipLabel, boolean skipString) { - errorMessage = null; - controlInError = null; - if (!skipLabel) { - errorMessage = validateLabelInput(); - if (errorMessage != null) controlInError = textLabel; - } - if ((errorMessage == null) && !skipString) { - errorMessage = validateStringInput(); - if (errorMessage != null) controlInError = commandField.getCommandWidget(); - } - return errorMessage; - } - - // --------------------------------- - // METHODS FOR VERIFICATION... - // --------------------------------- - /** - * Does complete verification of input fields. If this - * method returns null, there are no errors and the dialog or wizard can close; - * - * @return error message if there is one, else null if ok - */ - public SystemMessage verify() { - fromVerify = true; - errorMessage = validate(false, false); - if (errorMessage != null) { - if (controlInError != null) controlInError.setFocus(); - } - fromVerify = false; - fireChangeEvent(errorMessage); - return errorMessage; - } - - // ------------------ - // EVENT LISTENERS... - // ------------------ - /** - * User has selected something - */ - public void widgetSelected(SelectionEvent event) { - } - - /** - * User has selected something via enter/dbl-click - */ - public void widgetDefaultSelected(SelectionEvent event) { - } - - // --------------- - // HELPER METHODS - // --------------- - /** - * Add a separator line. This is a physically visible line. - */ - protected void addSeparatorLine(Composite parent, int nbrColumns) { - Label separator = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL); - GridData data = new GridData(); - data.horizontalSpan = nbrColumns; - data.horizontalAlignment = GridData.FILL; - separator.setLayoutData(data); - } - - /** - * Add a spacer line - */ - protected void addFillerLine(Composite parent, int nbrColumns) { - Label filler = new Label(parent, SWT.LEFT); - GridData data = new GridData(); - data.horizontalSpan = nbrColumns; - data.horizontalAlignment = GridData.FILL; - filler.setLayoutData(data); - } - - /** - * Add a spacer line that grows in height to absorb extra space - */ - protected void addGrowableFillerLine(Composite parent, int nbrColumns) { - Label filler = new Label(parent, SWT.LEFT); - GridData data = new GridData(); - data.horizontalSpan = nbrColumns; - data.horizontalAlignment = GridData.FILL; - data.verticalAlignment = GridData.FILL; - data.grabExcessVerticalSpace = true; - filler.setLayoutData(data); - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileCommandLabelProvider.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileCommandLabelProvider.java deleted file mode 100644 index e44b52c30..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileCommandLabelProvider.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.compile; - -/******************************************************************************* - * Copyright (c) 2002, 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 - * David Dykstal (IBM) - [186589] move user types, user actions, and compile commands - * API to the user actions plugin - *******************************************************************************/ -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.rse.internal.useractions.Activator; -import org.eclipse.rse.internal.useractions.IUserActionsImageIds; -import org.eclipse.swt.graphics.Image; - -/** - * Label provider for compile commands in the work with compile commands - * dialog. - */ -public class SystemCompileCommandLabelProvider extends LabelProvider { - - Image _compileCommandImage = null; - - /** - * Constructor - */ - public SystemCompileCommandLabelProvider() { - super(); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object) - */ - public String getText(Object element) { - if (element instanceof SystemCompileCommand) - return ((SystemCompileCommand) element).getLabel(); - else if (element != null) - return element.toString(); - else - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object) - */ - public Image getImage(Object element) { - Image result = null; - if (element instanceof SystemCompileCommand) { - if (_compileCommandImage == null || _compileCommandImage.isDisposed()) { - ImageDescriptor id = Activator.getDefault().getImageDescriptor(IUserActionsImageIds.COMPILE_1); - _compileCommandImage = id.createImage(); - } - result = _compileCommandImage; - } - return result; - } - -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileContributor.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileContributor.java deleted file mode 100644 index 4977519c2..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileContributor.java +++ /dev/null @@ -1,137 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 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 - * Martin Oberhuber (Wind River) - [180562][api] dont implement ISystemCompileXMLConstants - *******************************************************************************/ -package org.eclipse.rse.internal.useractions.ui.compile; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter; -import org.eclipse.rse.ui.view.SystemAdapterHelpers; - -public class SystemCompileContributor { - private IConfigurationElement config; - private SystemCompileRemoteObjectMatcher matcher; - - public SystemCompileContributor(IConfigurationElement element) { - this.config = element; - String ssfId = element.getAttribute("subsystemconfigurationid"); //$NON-NLS-1$ - String namefilter = element.getAttribute("namefilter"); //$NON-NLS-1$ - String typefilter = element.getAttribute("typefilter"); //$NON-NLS-1$ - matcher = new SystemCompileRemoteObjectMatcher(ssfId, namefilter, typefilter); - } - - /** - * Getter method. - * Return what was specified for the <samp>subsystemconfigurationid</samp> xml attribute. - */ - public String getSubSystemFactoryId() { - return matcher.getSubSystemFactoryId(); - } - - /** - * Getter method. - * Return what was specified for the <samp>namefilter</samp> xml attribute. - */ - public String getNameFilter() { - return matcher.getNameFilter(); - } - - /** - * Getter method. - * Return what was specified for the <samp>typefilter</samp> xml attribute. - */ - public String getTypeFilter() { - return matcher.getTypeFilter(); - } - - /** - * Returns true if the current selection matches all the given filtering criteria, false otherwise. - */ - public boolean isApplicableTo(Object element) { - return matcher.appliesTo(element); - } - - /** - * Contribute the compile command. - */ - public void contributeCompileCommand(SystemCompileProfile prf, Object element) { - ISystemRemoteElementAdapter rmtAdapter = SystemAdapterHelpers.getRemoteAdapter(element); - if (rmtAdapter != null) { - String srcType = rmtAdapter.getRemoteSourceType(element); - if (srcType == null) { - srcType = "null"; //$NON-NLS-1$ - } else if (srcType.equals("")) { //$NON-NLS-1$ - srcType = "blank"; //$NON-NLS-1$ - } - String id = config.getAttribute("id"); //$NON-NLS-1$ - String label = config.getAttribute("label"); //$NON-NLS-1$ - String commandString = config.getAttribute("commandstring"); //$NON-NLS-1$ - String labelEditable = config.getAttribute("labeleditable"); //$NON-NLS-1$ - String commandStringEditable = config.getAttribute("stringeditable"); //$NON-NLS-1$ - // label and command string are editable by default - // they are only false if indicated in extension point - boolean isLabelEditable = true; - boolean isCommandStringEditable = true; - if (labelEditable != null && labelEditable.equalsIgnoreCase("false")) { //$NON-NLS-1$ - isLabelEditable = false; - } - if (commandStringEditable != null && commandStringEditable.equalsIgnoreCase("false")) { //$NON-NLS-1$ - isCommandStringEditable = false; - } - // check all required attributes - if (id == null || label == null || commandString == null || id.equals("") || label.equals("") || commandString.equals("")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - return; - } - // obtain the compile type - SystemCompileType compileType = prf.getCompileType(srcType); - // if compile type exists, then get all the compile commands for this compile type - if (compileType != null) { - // search for a command with the id - boolean idExists = compileType.isIdExists(id); - // TODO: if compile commands with the id exist, we probably should update the default command string. - // Why update the default command string? Because a vendor might decide to update a - // compile command with a new release. We don't want to change the label, current string, etc. - // but at least change the default command string. On the other hand, changing the default - // command string is unnecessary most of the time, since idExists is true after the first time the - // the compile command is added. Hence we leave it for now. - if (!idExists) { - // now check if a command with the label exists; we want to avoid duplicate labels - // so only add the command if this label does not already exist. - boolean labelExists = compileType.isLabelExists(label); - if (!labelExists) { - int numOfCommands = compileType.getNumOfCommands(); - SystemCompileCommand command = new SystemCompileCommand(compileType, id, label, ISystemCompileXMLConstants.NATURE_ISV_VALUE, commandString, commandString, ISystemCompileXMLConstants.MENU_BOTH_VALUE, numOfCommands); - command.setLabelEditable(isLabelEditable); - command.setCommandStringEditable(isCommandStringEditable); - compileType.addCompileCommandInOrder(command); - // if the type had no existing commands at all, then make the compile command - // we have just added the last used compile command for the type - if (numOfCommands == 0) { - compileType.setLastUsedCompileCommand(command); - } - } - } - } - // compile type does not exist, so add a compile type, then add the compile command to it - else { - compileType = new SystemCompileType(prf, srcType); - SystemCompileCommand command = new SystemCompileCommand(compileType, id, label, ISystemCompileXMLConstants.NATURE_ISV_VALUE, commandString, commandString, ISystemCompileXMLConstants.MENU_BOTH_VALUE, 0); - command.setLabelEditable(isLabelEditable); - command.setCommandStringEditable(isCommandStringEditable); - compileType.addCompileCommandInOrder(command); - // since the compile command we have added is the first compile command for the newly created - // compile type, make it the last used compile command. - compileType.setLastUsedCompileCommand(command); - // add the compile type to the compile profile - prf.addCompileType(compileType); - } - } - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileContributorManager.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileContributorManager.java deleted file mode 100644 index 98baef77c..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileContributorManager.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.compile; - -/******************************************************************************* - * Copyright (c) 2002, 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 - *******************************************************************************/ -import java.util.Vector; - -/** - * This singleton class manages all compile contributions added through extension points. - */ -public class SystemCompileContributorManager { - private static SystemCompileContributorManager inst; - private Vector contributors = new Vector(); - - private SystemCompileContributorManager() { - loadContributors(); - } - - /** - * Returns the singleton instance of the manager. - * @return The singleton instance of this class - */ - public static SystemCompileContributorManager getInstance() { - if (inst == null) { - inst = new SystemCompileContributorManager(); - } - return inst; - } - - /** - * Loads the compile contributors from the workbench's registry. - */ - private void loadContributors() { - SystemCompileContributorReader reader = new SystemCompileContributorReader(); - reader.readCompileContributors(this); - } - - /** - * Register a contributor with the manager. - * @param contributor a contributor. - */ - public void registerContributor(SystemCompileContributor contributor) { - contributors.add(contributor); - } - - /** - * Adds all compile command contributions through extension point for the remote object. - * Returns true if there are any contributions, false otherwise. - */ - public boolean contributeCompileCommands(SystemCompileProfile prf, Object element) { - boolean isContributions = false; - // go through list of all contributors, find out which ones apply for the selected element - // and add/change a compile type to the given compile profile. - for (int idx = 0; idx < contributors.size(); idx++) { - SystemCompileContributor contributor = (SystemCompileContributor) contributors.elementAt(idx); - if (contributor.isApplicableTo(element)) { - contributor.contributeCompileCommand(prf, element); - isContributions = true; - } - } - return isContributions; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileContributorReader.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileContributorReader.java deleted file mode 100644 index f31ee553f..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileContributorReader.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.compile; - -/******************************************************************************* - * Copyright (c) 2002, 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 - *******************************************************************************/ -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IExtensionRegistry; -import org.eclipse.core.runtime.Platform; -import org.eclipse.rse.ui.RSEUIPlugin; - -/** - * This class reads configuration elements from the workbench's registry, creates contributors - * and registers them with the manager. - */ -public class SystemCompileContributorReader { - private SystemCompileContributorManager manager; - private static final String COMPILE_COMMAND_ELEMENT_NAME = "compilecommand"; //$NON-NLS-1$ - - public SystemCompileContributorReader() { - } - - public void readCompileContributors(SystemCompileContributorManager mgr) { - this.manager = mgr; - IExtensionRegistry registry = Platform.getExtensionRegistry(); - IExtensionPoint extensionPoint = registry.getExtensionPoint(RSEUIPlugin.PLUGIN_ID, "compile"); //$NON-NLS-1$ - if (extensionPoint != null) { - IExtension[] extensions = extensionPoint.getExtensions(); - for (int m = 0; m < extensions.length; m++) { - IExtension extension = extensions[m]; - IConfigurationElement[] elements = extension.getConfigurationElements(); - for (int n = 0; n < elements.length; n++) { - IConfigurationElement element = elements[n]; - // if the element is a compile command - // then create a contributor that represents the element - // and register the contributor with the contributor manager - if (element.getName().equals(COMPILE_COMMAND_ELEMENT_NAME)) { - SystemCompileContributor contributor = new SystemCompileContributor(element); - manager.registerContributor(contributor); - } - } - } - } - } -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileManager.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileManager.java deleted file mode 100644 index 3f81d6bb7..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileManager.java +++ /dev/null @@ -1,429 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core - * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry - * David Dykstal (IBM) - [186589] move user actions API out of org.eclipse.rse.ui - * Martin Oberhuber (Wind River) - [cleanup] Avoid using SystemStartHere in production code - * Xuan Chen (IBM) - [223126] [api][breaking] Remove API related to User Actions in RSE Core/UI - *******************************************************************************/ - -package org.eclipse.rse.internal.useractions.ui.compile; - -import java.util.Hashtable; - -import org.eclipse.core.resources.IFolder; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.rse.core.RSECorePlugin; -import org.eclipse.rse.core.model.IHost; -import org.eclipse.rse.core.model.ISystemProfile; -import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; -import org.eclipse.rse.internal.useractions.UserActionsPersistenceUtil; -import org.eclipse.rse.internal.useractions.api.ui.compile.SystemCascadingCompileAction; -import org.eclipse.rse.internal.useractions.ui.SystemCmdSubstVarList; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources; -import org.eclipse.rse.services.clientserver.messages.SystemMessage; -import org.eclipse.rse.subsystems.files.core.subsystems.IVirtualRemoteFile; -import org.eclipse.rse.ui.ISystemMessages; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.SystemBasePlugin; -import org.eclipse.rse.ui.SystemMenuManager; -import org.eclipse.rse.ui.messages.SystemMessageDialog; -import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter; -import org.eclipse.rse.ui.view.SystemAdapterHelpers; -import org.eclipse.swt.widgets.Shell; - -/** - * This class manages the compile framework for a particular instantiation. - * It is typically associated with a subsystem factory, but it is designed - * to be used in other contexts as well. - * <p> - * Here is the model for the compile framework: - * <ul> - * <li>This compile manager manages a list of SystemCompileProfiles. For subsystem - * factories, there will be one of these per system profile. In other contexts, - * there may well be only one SystemCompileProfile per manager. - * <li>A SystemCompileProfile manages a list of a SystemCompileTypes, which are persisted. - * There is one compile type per compilable source type, like ".cpp" for unix file - * systems. - * <li>Each SystemCompileType manages a list of SystemCompileCommands. Each command - * represents a remote command for compiling source objects of this type. Each - * command has a label shown in the Compile popup menu and a compile string that - * is the command. - * <li>There is a Work With Compile Commmands dialog that shows all existing types, - * and for each type the list of existing compile commands. Users can use this - * to define new compile commands per type, and new types. - * <li>The compile profile will optionally pre-fill its list if the persistent file is - * not found (ie, on first touch). That pre-filled list is what the user gets by - * default until they define their own compile commands. The pre-filled compile - * commands can be edited by the user (except the label) and can be restored to - * their shipped values. - * <li>When the user selects a compile command to run, an instance of SystemCompilableSource - * is created, containing a reference to the selected source object and the - * selected SystemCompileCommand. A method in that object is called to actually - * run the compile command. - * <li>Compile commands can have substitution variables. The list of supported substitution - * variables is supplied by this SystemCompileManager. The work-with dialog allows the - * user to easily insert these into his command string, and the SystemCompilableSource - * object is responsible for making the substitutions at runtime, given the compile - * command and selected source object. - * </ul> - * @see SystemCompileProfile - * @see SystemCompileType - * @see SystemCompileCommand - * @see SystemWorkWithCompileCommandsDialog - */ -public abstract class SystemCompileManager { - private Hashtable compileProfilesPerProfile = new Hashtable(); - private Hashtable compileSubstitutorsPerConnection = new Hashtable(); - protected IHost systemConnection; - protected String osType = "default"; //$NON-NLS-1$ - protected ISubSystemConfiguration subsystemFactory; - /** - * As last set by calling setCurrentCompileCommand. Sometimes needed by subclasses. - */ - protected SystemCompileCommand currentCompileCommand; - - /** - * Constructor for SystemCompileManager - */ - public SystemCompileManager() { - super(); - } - - /** - * Sets the subsystemconfiguration which instantiated this. Not called if using this - * framework outside of the world of subsystem factories. - */ - public void setSubSystemFactory(ISubSystemConfiguration ssFactory) { - this.subsystemFactory = ssFactory; - } - - /** - * Return the subsystem factory which instantiated this instance, or as set via {@link #setSubSystemFactory(ISubSystemConfiguration)}. - */ - public ISubSystemConfiguration getSubSystemFactory() { - return subsystemFactory; - } - - /** - * Set the current system connection. This is set in the work with dialog, and - * used by the edit pane and other downstream classes. - */ - public void setSystemConnection(IHost systemConnection) { - this.systemConnection = systemConnection; - } - - /** - * Return the system connection with which this manager instance is associated. - */ - public IHost getSystemConnection() { - return systemConnection; - } - - /** - * Sets the current compile command. Called by the framework when running a compile command, prior to calling - * commands that may be dependent on values in the compile command being processed. - */ - public void setCurrentCompileCommand(SystemCompileCommand compileCmd) { // defect 47808 - this.currentCompileCommand = compileCmd; - } - - /** - * Return the current compile cmd as set by {@link #setCurrentCompileCommand(SystemCompileCommand)}. - */ - public SystemCompileCommand getCurrentCompileCommand() { // defect 47808 - return currentCompileCommand; - } - - /** - * Return true (default) if multiple-select is supported for the compile action - */ - public boolean isMultiSelectSupported(SystemCompileCommand compileCmd) { - return true; - } - - /** - * Get the singleton compile profile given a SystemProfile. - * <p> - * Called in the Work With Compile Commands and the Compile cascading actions. - * <p> - * Do not override this, as the implementation is complete. However, - * you must override createCompileProfile. - * <p> - * If you are using this outside of the subsystem framework, this method will not be called. - * - * @see #createCompileProfile(ISystemProfile) - */ - public SystemCompileProfile getCompileProfile(ISystemProfile profile) { - if (compileProfilesPerProfile == null) compileProfilesPerProfile = new Hashtable(); - SystemCompileProfile cprofile = (SystemCompileProfile) compileProfilesPerProfile.get(profile); - if (cprofile == null) { - cprofile = createCompileProfile(profile); - if (cprofile != null) compileProfilesPerProfile.put(profile, cprofile); - } - return cprofile; - } - - /** - * Return a list of all SystemCompileProfile objects. - * By default, returns one per active system profile. If not using the subsystem framework, - * this must be overridden. - */ - public SystemCompileProfile[] getAllCompileProfiles() { - ISystemProfile[] systemProfiles = RSECorePlugin.getTheSystemProfileManager().getActiveSystemProfiles(); - SystemCompileProfile[] compProfiles = null; - if ((systemProfiles != null) && (systemProfiles.length > 0)) { - compProfiles = new SystemCompileProfile[systemProfiles.length]; - for (int idx = 0; idx < systemProfiles.length; idx++) - compProfiles[idx] = getCompileProfile(systemProfiles[idx]); - } - return compProfiles; - } - - /** - * Overridable method to instantiate your SystemCompileProfile subclass for the - * given system profile. - * <p>It is important you pass the SystemProfile's name to the ctor of SystemCompileProfile. - */ - protected abstract SystemCompileProfile createCompileProfile(ISystemProfile profile); - - /** - * Callback method from SystemCompileProfile to get the folder into which the - * xml file for this compile profile will be stored. By default uses the - * given subsystem factory. If you are using this framework outside of the - * subsystem factory world, then override this method. - */ - public IFolder getCompileProfileFolder(SystemCompileProfile compProfile) { - ISystemProfile systemProfile = getSystemProfile(compProfile); - if (systemProfile == null) { - SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_GENERIC_E); - msg.makeSubstitution(SystemUDAResources.SystemCompileManager_0); - SystemBasePlugin - .logError("In SystemCompileManager#getCompileProfileFolder, and we have gotten a null for the system profile named " + compProfile.getProfileName() + ". That should never happen!"); //$NON-NLS-1$ //$NON-NLS-2$ - SystemMessageDialog.displayErrorMessage(SystemBasePlugin.getActiveWorkbenchShell(), msg); - //return null; BETTER TO LET IT CRASH... BETTER RECOVERY - } - //System.out.println("systemProfile = " + systemProfile); - //System.out.println("subsystemFactory = " + subsystemFactory); - IFolder folder = UserActionsPersistenceUtil.getCompileCommandsFolder(systemProfile, subsystemFactory); - return folder; - } - - /** - * Callback from SystemProfile to decide, when no xml file is found, if we want - * to prime the new xml file with defaults. - * <p> - * By default, returns true if the SystemProfile the given compile profile is - * associated with is a user-private profile. If not using the compile framework, - * override this to use your own criteria. - */ - public boolean wantToPrimeWithDefaults(SystemCompileProfile profile) { - ISystemProfile systemProfile = getSystemProfile(profile); - //System.out.println("Inside wantToPrimeWithDefaults("+systemProfile.getName()+") and result is " + systemProfile.isDefaultPrivate()); - return systemProfile.isDefaultPrivate(); - } - - /** - * Return the default (supplied) compile commands to prime the compile commands with. - */ - public abstract SystemDefaultCompileCommands getDefaultCompileCommands(); - - /** - * If the command is an default supplied command, returns its SystemDefaultCompileCommand object. - * Returns null if not a default supplied command. - * @param commandName - the name of the command, minus the parameters. This is not the label! - */ - public SystemDefaultCompileCommand getDefaultSuppliedCommand(String commandName) { - SystemDefaultCompileCommands dftCmds = getDefaultCompileCommands(); - if (dftCmds == null) return null; - return dftCmds.getCommand(commandName); - } - - /** - * Given a SystemCompileProfile, return the SystemProfile it is associated with - */ - private ISystemProfile getSystemProfile(SystemCompileProfile compProfile) { - //return currentProfile; - //SystemProfile[] systemProfiles = RSECorePlugin.getTheSystemProfileManager().getActiveSystemProfiles(); THIS WAS THE BUG!! - ISystemProfile[] systemProfiles = RSECorePlugin.getTheSystemProfileManager().getSystemProfiles(); - String profileName = compProfile.getProfileName(); - ISystemProfile currentProfile = null; - for (int idx = 0; (currentProfile == null) && (idx < systemProfiles.length); idx++) { - if (systemProfiles[idx].getName().equals(profileName)) currentProfile = systemProfiles[idx]; - } - return currentProfile; - /* - System.out.println("Searching for match on = " + compProfile.getProfileName()); - Enumeration keys = compileProfilesPerProfile.keys(); - System.out.println(":Keys exist? " + keys.hasMoreElements()); - SystemProfile match = null; - while ((match==null) && keys.hasMoreElements()) - { - SystemProfile key = (SystemProfile)keys.nextElement(); - SystemCompileProfile value = (SystemCompileProfile)compileProfilesPerProfile.get(key); - System.out.println("...key = " + key.getName()); - System.out.println("...value = " + value.getProfileName()); - if (value == compProfile) - match = key; - } - return match; - */ - } - - /** - * The compile manager and related classes is impacted by a profile rename, as we have - * some in-memory places to be updated. This method is called by the subsystem factory - * on a profile rename operation so we can update ourselves. - */ - public void profileRenamed(ISystemProfile profile, String oldName) { - if (compileProfilesPerProfile == null) return; - SystemCompileProfile cprofile = (SystemCompileProfile) compileProfilesPerProfile.get(profile); - if (cprofile != null) cprofile.setProfileName(profile.getName()); - } - - /** - * Return true if the given remote object is potentially compilable. This decides - * the existence of the Compile menu item. It is possible to enable/disable this if - * there is no current compile command... this is a more course grained decision. - * <p> - * Our default implementation is to query the source type of the input object, - * and return true only if there is a source type defined for it in any of the - * currently active system profiles. - */ - public boolean isCompilable(Object selection) { - /* MJB: Hack to disable compilation on virtual files for now */ - if (selection instanceof IVirtualRemoteFile) return false; - ISystemRemoteElementAdapter rmtAdapter = SystemAdapterHelpers.getRemoteAdapter(selection); - if (rmtAdapter == null) return false; - String srcType = rmtAdapter.getRemoteSourceType(selection); - if (srcType == null) return false; - boolean compilable = false; - ISystemProfile[] activeProfiles = RSECorePlugin.getTheSystemRegistry().getActiveSystemProfiles(); - for (int idx = 0; !compilable && (idx < activeProfiles.length); idx++) { - SystemCompileProfile compProfile = getCompileProfile(activeProfiles[idx]); - compProfile.addContributions(selection); - compilable = (compProfile.getCompileType(srcType) != null); - } - return compilable; - } - - /** - * Populate main context menu with a menu item for compile. - * Allows subclasses the opportunity to add compile actions for single and multiple selections. - * <p> - * This is called by the addCommonRemoteObjectsActions method, if this subsystem - * supports compiles. - */ - public void addCompileActions(Shell shell, IStructuredSelection selection, SystemMenuManager menu, String menuGroup) { - if ((selection == null) || (selection.getFirstElement() == null)) { - return; - } - int size = selection.size(); - if (size == 1) { - addSingleSelectionCompileActions(shell, selection, menu, menuGroup); - } else if (size > 1) { - addMultipleSelectionCompileActions(shell, selection, menu, menuGroup); - } - } - - /** - * Adds compile actions for single selections. - * Populates main context menu with a "Compile->" submenu cascade, - * which will only be populated when the submenu is selected. - * <p> - * This is called by the addCompileActions method for single selections. - * Subclasses may override. - */ - public void addSingleSelectionCompileActions(Shell shell, IStructuredSelection selection, SystemMenuManager menu, String menuGroup) { - SystemCascadingCompileAction promptAction = new SystemCascadingCompileAction(shell, true); - SystemCascadingCompileAction noPromptAction = new SystemCascadingCompileAction(shell, false); - menu.add(menuGroup, noPromptAction); - menu.add(menuGroup, promptAction); - } - - /** - * Adds compile actions for multiple selections. - * By default, does nothing. - * This is called by the addCompileActions method for multiple selections. - * Subclasses may override. - */ - public void addMultipleSelectionCompileActions(Shell shell, IStructuredSelection selection, SystemMenuManager menu, String menuGroup) { - SystemCompileMultipleSelectAction multiAction = new SystemCompileMultipleSelectAction(shell); - menu.add(menuGroup, multiAction); - } - - /** - * For support of the Work With Compile Commands dialog. - * <p> - * Return the substitution variables supported by compile commands managed by this manager. - */ - public abstract SystemCmdSubstVarList getSubstitutionVariableList(); - - /** - * Return the substitutor for doing variable substitution. - * <p> - * Override to return a class that implements ISystemCompileCommandSubstitutor, that knows how to - * substitute the variables found in getSubstitutionVariableList(). - */ - protected ISystemCompileCommandSubstitutor getSubstitutor() { - ISystemCompileCommandSubstitutor substor = (ISystemCompileCommandSubstitutor) compileSubstitutorsPerConnection.get(systemConnection); - if (substor == null) { - substor = createSubstitutor(systemConnection); - compileSubstitutorsPerConnection.put(systemConnection, substor); - } - return substor; - } - - /** - * Return the substitutor for doing variable substitution. - * <p> - * Override to return a class that implements ISystemCompileCommandSubstitutor, that knows how to - * substitute the variables found in getSubstitutionVariableList(). - */ - protected abstract ISystemCompileCommandSubstitutor createSubstitutor(IHost connection); - - /** - * For support of the Work With Compile Commands dialog. - * <p> - * Return our edit pane. Overriding this is an alternative to calling setEditPane. - * This is called in createContents - */ - public SystemCompileCommandEditPane getCompileCommandEditPane(Shell shell, ISystemCompileCommandEditPaneHoster hoster, boolean caseSensitive) { - return new SystemCompileCommandEditPane(this, shell, hoster, caseSensitive); - } - - /** - * For support of the Work With Compile Commands dialog. - * <p> - * Return the dialog used to prompt for a new source type when "Add..." is pressed beside the - * source type combo. This returns an instance of the default SystemNewCompileSrcTypeDialog. - * <p> - * One strategy for subclasses is to call super on this method, then configure the results via - * the setters in the default dialog. Another is to subclass that dialog and return an instance - * of the subclass. - */ - protected SystemNewCompileSrcTypeDialog getNewSrcTypeDialog(Shell shell, boolean caseSensitive) { - //System.out.println("test 1" + caseSensitive); - return new SystemNewCompileSrcTypeDialog(shell, this, caseSensitive); - } - - public String getSourceTypePromptMRILabel() { - return SystemUDAResources.RESID_WWCOMPCMDS_TYPES_LABEL; - } - - public String getSourceTypePromptMRITooltip() { - return SystemUDAResources.RESID_WWCOMPCMDS_TYPES_TOOLTIP; - } - - public String getOSType() - { - return osType; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileMultipleSelectAction.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileMultipleSelectAction.java deleted file mode 100644 index cc1dffa97..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileMultipleSelectAction.java +++ /dev/null @@ -1,183 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - * Martin Oberhuber (Wind River) - [168870] refactor org.eclipse.rse.core package of the UI plugin - * David McKnight (IBM) - [225506] [api][breaking] RSE UI leaks non-API types - * Kevin Doyle (IBM) - [240069] Need to fix the markers FIXME in SystemCompileMultipleSelectAction - *******************************************************************************/ -package org.eclipse.rse.internal.useractions.ui.compile; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.rse.core.model.ISystemProfile; -import org.eclipse.rse.core.subsystems.ISubSystem; -import org.eclipse.rse.internal.useractions.UserActionsResources; -import org.eclipse.rse.internal.useractions.api.files.compile.ISystemCompileManagerAdapter; -import org.eclipse.rse.internal.useractions.files.compile.UniversalCompileManager; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources; -import org.eclipse.rse.ui.actions.SystemBaseAction; -import org.eclipse.rse.ui.view.ISystemEditableRemoteObject; -import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter; -import org.eclipse.rse.ui.view.SystemAdapterHelpers; -import org.eclipse.rse.ui.view.SystemTableViewProvider; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.dialogs.ListSelectionDialog; -import org.eclipse.ui.model.AdaptableList; -import org.eclipse.ui.model.WorkbenchContentProvider; - -public class SystemCompileMultipleSelectAction extends SystemBaseAction { - /** - * Constructor for multiple select compile action - */ - public SystemCompileMultipleSelectAction(Shell shell) { - super(UserActionsResources.ACTION_COMPILE_NOPROMPT_LABEL, UserActionsResources.ACTION_COMPILE_NOPROMPT_TOOLTIP, (ImageDescriptor) null, shell); - allowOnMultipleSelection(true); - setAccelerator(SWT.CTRL | SWT.SHIFT | 'c'); - } - - - /** - * The default implementation runs the last used compile command for each selected resource. - * @see org.eclipse.jface.action.IAction#run() - */ - public void run() { - if (checkDirtyEditors()) { - Object element = getFirstSelection(); - boolean ok = true; - while (ok && (element != null)) { - ISystemRemoteElementAdapter rmtAdapter = SystemAdapterHelpers.getRemoteAdapter(element); - - ISubSystem subsystem = rmtAdapter.getSubSystem(element); - - String srcType = null; - srcType = rmtAdapter.getRemoteSourceType(element); - if (srcType == null) { - srcType = "null"; //$NON-NLS-1$ - } else if (srcType.equals("")) { //$NON-NLS-1$ - srcType = "blank"; //$NON-NLS-1$ - } - - SystemCompileManager compileManager = null; - - if (element instanceof IAdaptable) { - ISystemCompileManagerAdapter adapter = (ISystemCompileManagerAdapter)((IAdaptable)element).getAdapter(ISystemCompileManagerAdapter.class); - if (null != adapter) - { - compileManager = adapter.getSystemCompileManager(subsystem.getSubSystemConfiguration()); - } - } - - if (null == compileManager) - { - compileManager = new UniversalCompileManager(); - compileManager.setSubSystemFactory(subsystem.getSubSystemConfiguration()); - } - - ISystemProfile profile = subsystem.getSystemProfile(); - - // get the compile profile - SystemCompileProfile compileProfile = compileManager.getCompileProfile(profile); - - compileManager.setSystemConnection(subsystem.getHost()); - - // add any contributions from compile extension points - // compileProfile.addContributions(element); - - // get the compile type for the current resource - SystemCompileType compType = (SystemCompileType)compileProfile.getCompileType(srcType); - - - // get the last used compile command for that type - SystemCompileCommand compileCmd = compType.getLastUsedCompileCommand(); - - SystemCompilableSource compilableSrc = compType.getParentProfile().getCompilableSourceObject(getShell(), element, compileCmd, false, viewer); - - ok = compilableSrc.runCompileCommand(); - - if (ok) { - element = getNextSelection(); - } - } - } - } - - protected List getDirtyEditors() { - IStructuredSelection sel = getSelection(); - List selection = sel.toList(); - List dirtyEditors = new ArrayList(); - for (int i = 0; i < selection.size(); i++) { - Object selected = selection.get(i); - if (selected instanceof IAdaptable) { - ISystemEditableRemoteObject editable = getEditableFor((IAdaptable) selected); - if (editable != null) { - try { - // is the file being edited? - if (editable.checkOpenInEditor() == 0) { - // reference the editing editor - editable.openEditor(); - // file is open in editor - prompt for save - if (editable.isDirty()) { - dirtyEditors.add(editable); - } - } - } catch (Exception e) { - } - } - } - } - return dirtyEditors; - } - - protected ISystemEditableRemoteObject getEditableFor(IAdaptable selected) { - ISystemRemoteElementAdapter adapter = (ISystemRemoteElementAdapter) selected.getAdapter(ISystemRemoteElementAdapter.class); - if (adapter.canEdit(selected)) { - ISystemEditableRemoteObject editable = adapter.getEditableRemoteObject(selected); - try { - editable.setLocalResourceProperties(); - } catch (Exception e) { - } - return editable; - } - return null; - } - - protected boolean checkDirtyEditors() { - List dirtyEditors = getDirtyEditors(); - if (dirtyEditors.size() > 0) { - AdaptableList input = new AdaptableList(); - for (int i = 0; i < dirtyEditors.size(); i++) { - ISystemEditableRemoteObject rmtObj = (ISystemEditableRemoteObject) dirtyEditors.get(i); - input.add(rmtObj.getRemoteObject()); - } - WorkbenchContentProvider cprovider = new WorkbenchContentProvider(); - SystemTableViewProvider lprovider = new SystemTableViewProvider(null); - // TODO: Cannot use WorkbenchMessages -- it's internal - ListSelectionDialog dlg = new ListSelectionDialog(getShell(), input, cprovider, lprovider, SystemUDAResources.EditorManager_saveResourcesMessage); - dlg.setInitialSelections(input.getChildren()); - // TODO: Cannot use WorkbenchMessages -- it's internal - dlg.setTitle(SystemUDAResources.EditorManager_saveResourcesTitle); - int result = dlg.open(); - //Just return false to prevent the operation continuing - if (result == IDialogConstants.CANCEL_ID) return false; - Object[] filesToSave = dlg.getResult(); - for (int s = 0; s < filesToSave.length; s++) { - IAdaptable rmtObj = (IAdaptable) filesToSave[s]; - ISystemEditableRemoteObject editable = getEditableFor(rmtObj); - editable.doImmediateSaveAndUpload(); - } - } - return true; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileProfile.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileProfile.java deleted file mode 100644 index b69bffa8f..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileProfile.java +++ /dev/null @@ -1,614 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - * Martin Oberhuber (Wind River) - [180562][api] dont implement ISystemCompileXMLConstants - * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry - * Xuan Chen (IBM) - [222263] Need to provide a PropertySet Adapter for System Team View (cleanup some use action stuff) - * Xuan Chen (IBM) - [225617] [useraction][api] Remove Team view support inside user action. - * Kevin Doyle (IBM) - [239701] [useractions] Compile types show up multiple times after adding a command - * Xuan Chen (IBM) - [246807] [useractions] - Command Command property set from different os and subsystem are all shown as "Compile Commands" in Team view - *******************************************************************************/ - -package org.eclipse.rse.internal.useractions.ui.compile; - -import java.util.Vector; - -import org.eclipse.core.resources.IFolder; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.rse.core.RSECorePlugin; -import org.eclipse.rse.core.model.IProperty; -import org.eclipse.rse.core.model.IPropertySet; -import org.eclipse.rse.core.model.ISystemProfile; -import org.eclipse.swt.widgets.Shell; - -/** - * A SystemCompileProfile has a one-to-one correspondence with a SystemProfile. There is one - * for each profile, for each subsystem factory that supports compiles. - * <p> - * The compile profile manages all aspects of the compile framework for this subsystem factory, - * for this system profile. Underneath, this basically means managing the xml file where the - * compile information is stored. - * <p> - * At a high level, a SystemCompileProfile manages a list of {@link SystemCompileType} objects, - * of which there is one per compilable source type. Given a raw source type like ".cpp" there - * is a method {@link #getCompileType(String)} to return the SystemCompileType object for it. - * From that, one can get a list of compile commands registered for that type, and the - * last-used compile command for that type. - */ -public abstract class SystemCompileProfile { - private SystemCompileManager parentManager; - //private SystemProfile systemProfile; - private String profileName; - private Vector compileTypes; - private String[] srcTypes; - private boolean isRead; - private Object associatedData; - - /** - * Constructor for SystemCompileProfile - * Will automatically read from disk. - * @param manager - the SystemCompileManager which instantiated this - * @param profileName - the name for this profile. - */ - public SystemCompileProfile(SystemCompileManager manager, String profileName) { - super(); - this.parentManager = manager; - this.profileName = profileName; - //this.systemProfile = profile; - doPreRead(); - readFromDisk(); - } - - // ----------------- - // PUBLIC METHODS... - // ----------------- - /** - * Reset the profile name, on a profile rename operation, say. - */ - public void setProfileName(String name) { - //System.out.println("Inside SystemCompileProfile#setProfileName. Old = " + profileName + ", New = " + name); - this.profileName = name; - } - - /** - * Set any data you want associated with this profile, while it is in memory - */ - public void setAssociatedData(Object data) { - this.associatedData = data; - } - - /** - * Get the associated data set via setAssociatedData - */ - public Object getAssociatedData() { - return associatedData; - } - - /** - * Return the name of this profile as given in the constructor - */ - public String getProfileName() { - return profileName; - } - - /** - * Return the system profile this is associated with - */ - public ISystemProfile getProfile() { - return RSECorePlugin.getTheSystemRegistry().getSystemProfile(profileName); - } - - /** - * Return the SystemCompileManager responsible for this profile - */ - public SystemCompileManager getParentManager() { - return parentManager; - } - - /** - * Add a compile type - */ - public void addCompileType(SystemCompileType type) { - compileTypes.add(type); - flushCache(); - } - - /** - * Remote a compile type. - * Should only be called if the type is empty of compile commands - */ - public void removeCompileType(SystemCompileType type) { - compileTypes.remove(type); - flushCache(); - } - - /** - * Get compile types. - * @return a Vector of SystemCompileType objects. - */ - public Vector getCompileTypes() { - return compileTypes; - } - - /** - * Get compile types as an array of strings. - */ - public String[] getCompileTypesArray() { - if ((srcTypes == null) || (srcTypes.length != compileTypes.size())) { - srcTypes = new String[compileTypes.size()]; - for (int idx = 0; idx < srcTypes.length; idx++) - srcTypes[idx] = ((SystemCompileType) compileTypes.elementAt(idx)).getType(); - } - return srcTypes; - } - - /** - * Get the compile type, given a type - */ - public SystemCompileType getCompileType(String typeString) { - SystemCompileType compileType; - for (int i = 0; i < compileTypes.size(); i++) { - compileType = (SystemCompileType) (compileTypes.get(i)); - if (compileType.getType().equalsIgnoreCase(typeString)) return compileType; - } - return null; - } - - /** - * Save this profile to disk. It is saved to an xml file that is scoped - * to a folder named after the subsystem factory, and that in turn is - * scoped to a folder named "CompileCommands" within this system profile's - * folder. - */ - public void writeToDisk() { - //We need to get the compile command information from the system profile now. - ISystemProfile systemProfile = RSECorePlugin.getTheSystemProfileManager().getSystemProfile(profileName); - write(compileTypes, systemProfile); - isRead = false; - } - - /** - * Should you require access to the IFolder containing the persisted xml - * file, call this method. Note, this folder is only created on first touch, - * so this call may have the side-effect of creating the folder. - * <p> - * This defers back to the owning SystemCompileManager. - */ - public IFolder getCompileFolder() { - return parentManager.getCompileProfileFolder(this); - } - - // ------------------- - // ABSTRACT METHODS... - // ------------------- - /** - * When the time comes to actually run a compile command against a selected source object, - * this method is called to return the instance of SystemCompilableSource to do that. - * <p> - * This method must be implemented to return an instance of your subclass of SystemCompilableSource. - */ - public abstract SystemCompilableSource getCompilableSourceObject(Shell shell, Object selectedObject, SystemCompileCommand compileCmd, boolean isPrompt, Viewer viewer); - - /** - * This method is called by the constructor, prior to reading the xml contents from disk. - * It is an exit point in case subclasses need to do anything before the read, such as rename - * or migrate legacy information. - */ - protected void doPreRead() { - } - - // ------------------- - // PRIVATE METHODS... - // ------------------- - /** - * Read all compile types associated with the profile from the disk - */ - private void readFromDisk() { - if (!isRead) { - compileTypes = read(); - isRead = true; - } - } - - /** - * Clear any cached info, as something has changed. - */ - private void flushCache() { - srcTypes = null; - } - - /** - * Read the XML file that holds all information about the - * types and associated compile names in this profile. - */ - private Vector read() { - Vector types = null; - - //We need to get the compile command information from the system profile now. - //Get the propertySet first - String osType = getParentManager().getOSType(); - String compileCommandPropertySetName = ISystemCompileXMLConstants.COMPILE_COMMAND_PROPRERTY_SET_PREFIX + osType; - ISystemProfile systemProfile = RSECorePlugin.getTheSystemProfileManager().getSystemProfile(profileName); - IPropertySet compileCommandPropertySet = systemProfile.getPropertySet(compileCommandPropertySetName); - if (null == compileCommandPropertySet) - { - if (parentManager.wantToPrimeWithDefaults(this)) // we only prime the user's private profile with default compile commands - { - types = writeDefaults(systemProfile); - } - else - { - return new Vector(); - } - } - else - { - types = getTypes(systemProfile); - } - /* - File file = getCompileProfileJavaFile(); - // If the file does not exist, then write all IBM supplied default - // types and compile names first before reading - if (file == null || !file.exists()) { - if (parentManager.wantToPrimeWithDefaults(this)) // we only prime the user's private profile with default compile commands - { - if (!writeDefaults()) return new Vector(); - } else { - return new Vector(); - } - } - */ - return types; - } - - /** - * Get all the compile types. - * @return a vector of SystemCompileType objects. - */ - private Vector getTypes(ISystemProfile systemProfile) { - Vector types = new Vector(); - //Get the propertySet first - String osType = getParentManager().getOSType(); - String compileCommandPropertySetName = ISystemCompileXMLConstants.COMPILE_COMMAND_PROPRERTY_SET_PREFIX + osType; - IPropertySet compileCommandPropertySet = systemProfile.getPropertySet(compileCommandPropertySetName); - if (null == compileCommandPropertySet) - { - return null; - } - IPropertySet[] list = compileCommandPropertySet.getPropertySets(); //This is for all the compile types - if (list == null) return types; - - for (int i = 0; i < list.length; i++) { - IPropertySet compileType = list[i]; //This is one compile type - IPropertySet[] compileNameList = compileType.getPropertySets(); - - IProperty typeProperty = compileType.getProperty(ISystemCompileXMLConstants.SOURCETYPE_ATTRIBUTE); - String type = typeProperty.getValue(); - IProperty lastUsedProperty = compileType.getProperty(ISystemCompileXMLConstants.LASTUSED_ATTRIBUTE); - String lastUsed = lastUsedProperty.getValue(); - - SystemCompileType newType = new SystemCompileType(this, type); - - for (int j = 0; j < compileNameList.length; j++) { - IPropertySet compileName = compileNameList[j]; //This is one compilename - // get the name of the compile name - IProperty labelProperty = compileName.getProperty(ISystemCompileXMLConstants.LABEL_ATTRIBUTE); - String name = labelProperty.getValue(); - // get the nature of the compile name - IProperty natureProperty = compileName.getProperty(ISystemCompileXMLConstants.NATURE_ATTRIBUTE); - String nature = natureProperty.getValue(); - // get the default command string - IProperty defaultProperty = compileName.getProperty(ISystemCompileXMLConstants.DEFAULT_ATTRIBUTE); - String defaultString = (defaultProperty != null) ? defaultProperty.getValue() : ""; //$NON-NLS-1$ - // get the current string - IProperty currentProperty = compileName.getProperty(ISystemCompileXMLConstants.CURRENT_ATTRIBUTE); - String currentString = currentProperty.getValue(); - // get the menu option - IProperty menuProperty = compileName.getProperty(ISystemCompileXMLConstants.MENU_ATTRIBUTE); - String menuOption = menuProperty.getValue(); - // get the jobenv option - IProperty jobenvProperty = compileName.getProperty(ISystemCompileXMLConstants.JOBENV_ATTRIBUTE); - String jobEnv = null; - if (null != jobenvProperty) - { - jobEnv = jobenvProperty.getValue(); - } - // get the ordering - IProperty orderProperty = compileName.getProperty(ISystemCompileXMLConstants.ORDER_ATTRIBUTE); - int order = j; - // to ensure previous beta customers do not have problems - if (null != orderProperty) - { - order = Integer.valueOf(orderProperty.getValue()).intValue(); - } - // get the id option - IProperty idProperty = compileName.getProperty(ISystemCompileXMLConstants.ID_ATTRIBUTE); - String id = null; - if (null != idProperty) - { - id = idProperty.getValue(); - } - // get the label editable option - IProperty labelEditableProperty = compileName.getProperty(ISystemCompileXMLConstants.LABEL_EDITABLE_ATTRIBUTE); - String labelEditable = null; - if (null != labelEditableProperty) - { - labelEditable = labelEditableProperty.getValue(); - } - // get the string editable option - IProperty stringEditableProperty = compileName.getProperty(ISystemCompileXMLConstants.STRING_EDITABLE_ATTRIBUTE); - String stringEditable = null; - if (null != stringEditableProperty) - { - stringEditable = stringEditableProperty.getValue(); - } - // id can be null, in which case the contructor will try to configure the id automatically - // so no need to check for id == null here - SystemCompileCommand newCmd = new SystemCompileCommand(newType, id, name, nature, defaultString, currentString, menuOption, order); - // if label editable is null, i.e. attribute did not exist, then don't do anything - // because the command is either IBM supplied or user supplied, and the constructor will take - // care of it. We only care if the attribute is not null. - if (labelEditable != null) { - boolean isLabelEditable = Boolean.valueOf(labelEditable).booleanValue(); - newCmd.setLabelEditable(isLabelEditable); - } - // if string editable is null, i.e. attribute did not exist, then don't do anything - // because the command is either IBM supplied or user supplied, and the constructor will take - // care of it. We only care if the attribute is not null. - if (stringEditable != null) { - boolean isStringEditable = Boolean.valueOf(stringEditable).booleanValue(); - newCmd.setCommandStringEditable(isStringEditable); - } - if (jobEnv != null) newCmd.setJobEnvironment(jobEnv); - if (name.equalsIgnoreCase(lastUsed)) newType.setLastUsedCompileCommand(newCmd); - //TODO - XUAN need to handling migration later on - /* - if (oldversion) newCmd = migrateCompileCommand(newCmd, oldvrm); - */ - newType.addCompileCommandInOrder(newCmd); - } - // add compile type and all its contents to the types list - types.add(newType); - } - // if we currently have an older version on disk, we may have added new default types and associated - // default compile commands for this release. so find out what new default source types we have - // in this release, and add them to list of types in memory. - // We only want to add these new default types to the default private profile. - // Warning:: this will not handle the case where we want to change a default compile command for - // an existing type with a new release. Need to modify the code below for that. - //TODO - XUAN need to handling migration later on - /* - if (parentManager.wantToPrimeWithDefaults(this) && oldversion) { - SystemDefaultCompileCommands allCmds = parentManager.getDefaultCompileCommands(); - if (allCmds == null) { - return types; - } - // get all default types - String[] defaultTypes = allCmds.getAllDefaultSuppliedSourceTypes(); - // for each default type, find out if we already have it in memory, i.e. - // it exists from a previous release and so is not new. - for (int i = 0; i < defaultTypes.length; i++) { - boolean typeFound = false; - Iterator iter = types.iterator(); - // iterate over all types in memory - while (iter.hasNext()) { - SystemCompileType tempType = (SystemCompileType) iter.next(); - // if the types match, we know this type is not new - if (tempType.getType().equalsIgnoreCase(defaultTypes[i])) { - typeFound = true; - break; - } - } - // type wasn't found in memory, so this is a new default type which we need to add - // also need to add the default commands for that source type - if (!typeFound) { - SystemCompileType type = new SystemCompileType(this, defaultTypes[i]); - SystemDefaultCompileCommand[] defaultCmds = allCmds.getCommandsForSrcType(defaultTypes[i]); - if ((defaultCmds == null) || (defaultCmds.length == 0)) { - types.add(type); - continue; - } - SystemCompileCommand[] cmds = new SystemCompileCommand[defaultCmds.length]; - for (int j = 0; j < defaultCmds.length; j++) { - String cmdName = defaultCmds[j].getLabel(); - String commandString = defaultCmds[j].getCommandWithParameters(); - // we can pass in null for the id, because the constructor checks if id is null - // and if so tries to configure id automatically. This will work for IBM supplied commands. - cmds[j] = new SystemCompileCommand(type, null, cmdName, ISystemCompileXMLConstants.NATURE_IBM_VALUE, commandString, commandString, ISystemCompileXMLConstants.MENU_BOTH_VALUE, j); - type.addCompileCommandInOrder(cmds[j]); - String jobEnv = defaultCmds[j].getJobEnvironment(); - if (jobEnv != null) { - cmds[j].setJobEnvironment(jobEnv); - } - if (j == 0) { - type.setLastUsedCompileCommand(cmds[j]); - } - } - types.add(type); - } - } - } - */ - return types; - } - - /** - * - * Add compile contributions made through extension points for the given resource, - * and save them to disk. - */ - public void addContributions(Object element) { - // we only add contributions to the default private profile - // Should we update existing labels in other profiles, e.g. a user may have copied a contributed - // label to another profile? This won't change those labels, only the label in the default private profile. - if (parentManager.wantToPrimeWithDefaults(this)) { - SystemCompileContributorManager.getInstance().contributeCompileCommands(this, element); - } - // write the contributions to disk - // writeToDisk(); - } - - /** - * Opportunity for subclasses to do migration of compile commands read from disk, - * from a document that has an older vrm than the current vrm. - */ - protected SystemCompileCommand migrateCompileCommand(SystemCompileCommand oldCmd, String oldVrm) { - return oldCmd; - } - - /** - * Do substring substitution. Using you are replacing &1 (say) with - * another string. - * @param string - string containing substring to be substituted. - * @param subOld - substitution variable. Eg "%1" - * @param subNew - substitution data. Eg "001" - * @return string with all occurrences of subOld substituted with subNew. - */ - protected String sub(String string, String subOld, String subNew) { - if (string == null) return string; - StringBuffer temp = new StringBuffer(); - int lastHit = 0; - int newHit = 0; - for (newHit = string.indexOf(subOld, lastHit); newHit != -1; lastHit = newHit, newHit = string.indexOf(subOld, lastHit)) { - if (newHit >= 0) temp.append(string.substring(lastHit, newHit)); - temp.append(subNew); - newHit += subOld.length(); - } - if (lastHit >= 0) temp.append(string.substring(lastHit)); - return temp.toString(); - } - - /** - * Write the contents of the file, given the contents as a Vector of SystemCompileType objects. - */ - private void write(Vector types, ISystemProfile systemProfile) { - - //Get the propertySet first - String osType = getParentManager().getOSType(); - String compileCommandPropertySetName = ISystemCompileXMLConstants.COMPILE_COMMAND_PROPRERTY_SET_PREFIX + osType; - IPropertySet compileCommandPropertySet = systemProfile.getPropertySet(compileCommandPropertySetName); - if (null == compileCommandPropertySet) - { - compileCommandPropertySet = systemProfile.createPropertySet(compileCommandPropertySetName); - //Set its name and type attributes - String compileCommandPropertySetLabel = ISystemCompileXMLConstants.COMPILE_COMMAND_NAME + " - " + osType; //$NON-NLS-1$ - compileCommandPropertySet.addProperty(ISystemCompileXMLConstants.LABEL_ATTRIBUTE, compileCommandPropertySetLabel); - } - // write type and compile commands for each - for (int i = 0; i < types.size(); i++) { - SystemCompileType compileType = (SystemCompileType) (types.get(i)); - //Element typeElement = doc.createElement(ISystemCompileXMLConstants.TYPE_ELEMENT); - //typeElement.setAttribute(ISystemCompileXMLConstants.TYPE_ATTRIBUTE, type.getType()); - SystemCompileCommand lastUsedCompileName = compileType.getLastUsedCompileCommand(); - String lastUsedName = null; - if (lastUsedCompileName == null) { - lastUsedName = ""; //$NON-NLS-1$ - } else { - lastUsedName = lastUsedCompileName.getLabel(); - } - //now create a propertySet for this compile type - - IPropertySet thisCompileTypePropertySet = compileCommandPropertySet.createPropertySet(compileType.getType()); - //Set its properties. - thisCompileTypePropertySet.addProperty(ISystemCompileXMLConstants.TYPE_ATTRIBUTE, ISystemCompileXMLConstants.TYPE_ELEMENT); - thisCompileTypePropertySet.addProperty(ISystemCompileXMLConstants.LABEL_ATTRIBUTE, compileType.getType()); - thisCompileTypePropertySet.addProperty(ISystemCompileXMLConstants.LASTUSED_ATTRIBUTE, lastUsedName); - thisCompileTypePropertySet.addProperty(ISystemCompileXMLConstants.SOURCETYPE_ATTRIBUTE, compileType.getType()); - Vector cmds = compileType.getCompileCommands(); - for (int j = 0; j < cmds.size(); j++) { - SystemCompileCommand cmd = (SystemCompileCommand) (cmds.get(j)); - IPropertySet thisCompileCommandPropertySet = thisCompileTypePropertySet.createPropertySet(cmd.getLabel() + j); - if (null != cmd.getId()) - { - thisCompileCommandPropertySet.addProperty(ISystemCompileXMLConstants.ID_ATTRIBUTE, cmd.getId()); - } - thisCompileCommandPropertySet.addProperty(ISystemCompileXMLConstants.LABEL_ATTRIBUTE, cmd.getLabel()); - thisCompileCommandPropertySet.addProperty(ISystemCompileXMLConstants.TYPE_ATTRIBUTE, ISystemCompileXMLConstants.COMPILECOMMAND_ELEMENT); - thisCompileCommandPropertySet.addProperty(ISystemCompileXMLConstants.NATURE_ATTRIBUTE, cmd.getNature()); - thisCompileCommandPropertySet.addProperty(ISystemCompileXMLConstants.DEFAULT_ATTRIBUTE, cmd.getDefaultString()); - thisCompileCommandPropertySet.addProperty(ISystemCompileXMLConstants.CURRENT_ATTRIBUTE, cmd.getCurrentString()); - thisCompileCommandPropertySet.addProperty(ISystemCompileXMLConstants.ID_ATTRIBUTE, cmd.getId()); - thisCompileCommandPropertySet.addProperty(ISystemCompileXMLConstants.MENU_ATTRIBUTE, cmd.getMenuOption()); - thisCompileCommandPropertySet.addProperty(ISystemCompileXMLConstants.ORDER_ATTRIBUTE, String.valueOf(j)); - thisCompileCommandPropertySet.addProperty(ISystemCompileXMLConstants.LABEL_EDITABLE_ATTRIBUTE, String.valueOf(cmd.isLabelEditable())); - if (cmd.getJobEnvironment() != null) { - thisCompileCommandPropertySet.addProperty(ISystemCompileXMLConstants.JOBENV_ATTRIBUTE, cmd.getJobEnvironment()); - } - - } - } - //Need to persist it. - systemProfile.commit(); - /* - // write out document to XML file - TransformerFactory transformerFactory = TransformerFactory.newInstance(); - Transformer transformer = transformerFactory.newTransformer(); - DOMSource input = new DOMSource(doc); - Result output = new StreamResult(file); - transformer.transform(input, output); - // now refresh the eclipse workspace model for the parent folder, to recognize changes we made - SystemResourceHelpers.getResourceHelpers().refreshResource(getCompileFolder()); - */ - } - - /** - * Prime document with default (supplied) types and names. - * Return true if any written, false if none to write. - */ - private Vector writeDefaults(ISystemProfile systemProfile) { - SystemDefaultCompileCommands allCmds = parentManager.getDefaultCompileCommands(); - if (allCmds == null) return null; - String[] defaultTypes = allCmds.getAllDefaultSuppliedSourceTypes(); - Vector types = new Vector(); - for (int i = 0; i < defaultTypes.length; i++) { - SystemCompileType type = new SystemCompileType(this, defaultTypes[i]); - SystemDefaultCompileCommand[] defaultCmds = allCmds.getCommandsForSrcType(defaultTypes[i]); - if ((defaultCmds == null) || (defaultCmds.length == 0)) { - types.add(type); - continue; - } - SystemCompileCommand[] cmds = new SystemCompileCommand[defaultCmds.length]; - for (int j = 0; j < defaultCmds.length; j++) { - String cmdName = defaultCmds[j].getLabel(); - String commandString = defaultCmds[j].getCommandWithParameters(); - // we can pass in null for the id, because the constructor checks if id is null - // and if so tries to configure id automatically. This will work for IBM supplied commands. - cmds[j] = new SystemCompileCommand(type, null, cmdName, ISystemCompileXMLConstants.NATURE_IBM_VALUE, commandString, commandString, ISystemCompileXMLConstants.MENU_BOTH_VALUE, j); - type.addCompileCommandInOrder(cmds[j]); - String jobEnv = defaultCmds[j].getJobEnvironment(); - if (jobEnv != null) cmds[j].setJobEnvironment(jobEnv); - if (j == 0) { - type.setLastUsedCompileCommand(cmds[j]); - } - } - types.add(type); - } - write(types, systemProfile); - //printCommandsByType(types); // temporary, for debugging - return types; - } - - /** - * Print the commands to standard out, sorted by source type, for debugging purposes - */ - public void printCommandsByType(Vector compileTypes) { - System.out.println(); - System.out.println("Compile commands"); //$NON-NLS-1$ - System.out.println("-----------------"); //$NON-NLS-1$ - for (int idx = 0; idx < compileTypes.size(); idx++) { - SystemCompileType type = (SystemCompileType) compileTypes.elementAt(idx); - System.out.println("Type: " + type.getType()); //$NON-NLS-1$ - for (int jdx = 0; jdx < type.getNumOfCommands(); jdx++) { - SystemCompileCommand cmd = type.getCompileCommand(jdx); - cmd.printCommand(" "); //$NON-NLS-1$ - } - } - System.out.println(); - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileRemoteObjectMatcher.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileRemoteObjectMatcher.java deleted file mode 100644 index 77385f1e7..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileRemoteObjectMatcher.java +++ /dev/null @@ -1,190 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 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 - * Martin Oberhuber (Wind River) - [168870] refactor org.eclipse.rse.core package of the UI plugin - *******************************************************************************/ -package org.eclipse.rse.internal.useractions.ui.compile; - -import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter; -import org.eclipse.rse.ui.view.SystemAdapterHelpers; - -public class SystemCompileRemoteObjectMatcher { - private String ssfId, nameFilter, typeFilter; - private boolean allSsfs, allNames, allTypes; - private boolean genericSsfStart, genericNamesStart, genericTypesStart; - private boolean genericSsfEnd, genericNamesEnd, genericTypesEnd; - private String ssfIdPart, nameFilterPart, typeFilterPart; - - public SystemCompileRemoteObjectMatcher(String ssfId, String nameFilter, String typeFilter) { - this.ssfId = ssfId; - this.nameFilter = nameFilter; - this.typeFilter = typeFilter; - if (ssfId == null) { - ssfId = "*"; //$NON-NLS-1$ - } - if (nameFilter == null) { - nameFilter = "*"; //$NON-NLS-1$ - } - if (typeFilter == null) { - typeFilter = "*"; //$NON-NLS-1$ - } - // determine if any attribute is totally generic - this.allSsfs = ssfId.equals("*"); //$NON-NLS-1$ - this.allNames = nameFilter.equals("*"); //$NON-NLS-1$ - this.allTypes = typeFilter.equals("*"); //$NON-NLS-1$ - // determine if any attribute value starts with asterisk - this.genericSsfStart = !allSsfs && startsWithAsterisk(ssfId); - this.genericNamesStart = !allNames && startsWithAsterisk(nameFilter); - this.genericTypesStart = !allTypes && startsWithAsterisk(typeFilter); - // determine if any attribute value ends with asterisk - this.genericSsfEnd = !allSsfs && endsWithAsterisk(ssfId); - this.genericNamesEnd = !allNames && endsWithAsterisk(nameFilter); - this.genericTypesEnd = !allTypes && endsWithAsterisk(typeFilter); - // strip of leading asterisk if there is one - if (genericSsfStart) { - ssfIdPart = stripLeadingAsterisk(ssfId); - } - if (genericNamesStart) { - nameFilterPart = stripLeadingAsterisk(nameFilter); - } - if (genericTypesStart) { - typeFilterPart = stripLeadingAsterisk(typeFilter); - } - // strip of trailing asterisk if there is one - if (genericSsfEnd) { - ssfIdPart = stripTrailingAsterisk(ssfId); - } - if (genericNamesEnd) { - nameFilterPart = stripTrailingAsterisk(nameFilter); - } - if (genericTypesEnd) { - typeFilterPart = stripTrailingAsterisk(typeFilter); - } - } - - /** - * Helper method. - * Returns true if given name starts with an asterisk. - */ - protected boolean startsWithAsterisk(String name) { - return name.startsWith("*"); //$NON-NLS-1$ - } - - /** - * Helper method. - * Returns true if given name ends with an asterisk. - */ - protected boolean endsWithAsterisk(String name) { - return name.endsWith("*"); //$NON-NLS-1$ - } - - /** - * Helper method. - * Strips off the leading asterisk. - */ - protected String stripLeadingAsterisk(String name) { - return name.substring(1); - } - - /** - * Helper method. - * Strips off the trailing asterisk. - */ - protected String stripTrailingAsterisk(String name) { - return name.substring(0, name.length() - 1); - } - - /** - * Getter method. - * Return what was specified for the <samp>subsystemconfigurationid</samp> xml attribute. - */ - public String getSubSystemFactoryId() { - return ssfId; - } - - /** - * Getter method. - * Return what was specified for the <samp>namefilter</samp> xml attribute. - */ - public String getNameFilter() { - return nameFilter; - } - - /** - * Getter method. - * Return what was specified for the <samp>typefilter</samp> xml attribute. - */ - public String getTypeFilter() { - return typeFilter; - } - - /** - * Returns true if the current selection matches all the given filtering criteria, false otherwise. - */ - public boolean appliesTo(Object element) { - ISystemRemoteElementAdapter adapter = SystemAdapterHelpers.getRemoteAdapter(element); - if (adapter == null) { - return false; - } - boolean applies = true; - // must match on all attributes - // check for match on subsystem factory id - boolean ssfIdMatch = true; - if (!allSsfs) { - String subsystem = adapter.getSubSystemConfigurationId(element); - if (ssfId == null) { - ssfIdMatch = false; - } else if (!genericSsfStart && !genericSsfEnd) { - ssfIdMatch = subsystem.equals(ssfId); - } else if (genericSsfStart) { - ssfIdMatch = subsystem.endsWith(ssfIdPart); - } else if (genericSsfEnd) { - ssfIdMatch = subsystem.startsWith(ssfIdPart); - } - } - if (!ssfIdMatch) { - return false; - } - // check for match on name filter - boolean nameMatch = true; - if (!allNames) { - String name = adapter.getName(element); - if (name == null || !genericNamesStart) { - nameMatch = false; - } else if (!genericNamesStart && !genericNamesEnd) { - nameMatch = name.equals(nameFilter); - } else if (genericNamesStart) { - nameMatch = name.endsWith(nameFilterPart); - } else if (genericNamesEnd) { - nameMatch = name.startsWith(nameFilterPart); - } - } - if (!nameMatch) { - return false; - } - // check for match on type filter - boolean typeMatch = true; - if (!allTypes) { - String type = adapter.getRemoteSourceType(element); - if (type == null) { - typeMatch = false; - } else if (!genericTypesStart && !genericTypesEnd) { - typeMatch = type.equals(typeFilter); - } else if (genericTypesStart) { - typeMatch = type.endsWith(typeFilterPart); - } else if (genericTypesEnd) { - typeMatch = type.startsWith(typeFilterPart); - } - } - if (!typeMatch) { - return false; - } - return applies; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileType.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileType.java deleted file mode 100644 index 3288a1f8b..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileType.java +++ /dev/null @@ -1,348 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.compile; - -/******************************************************************************* - * Copyright (c) 2002, 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 - *******************************************************************************/ -import java.util.Vector; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.Platform; - -/** - * A SystemCompileType is effectively an index that maps a compilable source type (like ".cpp") to a - * list of SystemCompileCommand objects that represent the commands that are registered against that source - * type. It also remembers the last-used such compile command. - * <p> - * There is a one-to-one relationship between a source type like (".cpp") and a SystemCompileType... for - * each compilable source type there will be one SystemCompileType object. It is a list of these that is - * effectively persisted to disk via an xml file, one file per system profile. This is what the SystemCompileProfile - * class manages ... a list of SystemCompileProfile objects. - */ -public class SystemCompileType implements IAdaptable { - private SystemCompileProfile profile; - private String type; - private SystemCompileCommand lastUsedCompileCommand; - private Vector commands = new Vector(); - - /** - * Constructor for SystemCompileType when the source type isn't known yet. - * @see #setType(String) - */ - public SystemCompileType(SystemCompileProfile profile) { - super(); - setParentProfile(profile); - } - - /** - * Constructor for SystemCompileType when you know the source type it represents. - */ - public SystemCompileType(SystemCompileProfile profile, String type) { - super(); - setParentProfile(profile); - setType(type); - } - - /** - * Constructor for SystemCompileType when you know the source type and last used command - */ - public SystemCompileType(SystemCompileProfile profile, String type, SystemCompileCommand lastUsedCompileCmd) { - super(); - setParentProfile(profile); - setType(type); - setLastUsedCompileCommand(lastUsedCompileCmd); - } - - /** - * Set the parent SystemCompileProfile profile - * @param profile the parent profile - */ - public void setParentProfile(SystemCompileProfile profile) { - this.profile = profile; - } - - /** - * Get the parent SystemCompileProfile profile - * @return the parent profile - */ - public SystemCompileProfile getParentProfile() { - return profile; - } - - /** - * Set the source type value this represents. This is typically a file type like "cpp". - * @param type the type - */ - public void setType(String type) { - //this.type = type.toUpperCase(); defect 46282 - this.type = type; - } - - /** - * Get the source type value this represents. This is typically a file type like "cpp". - * @return the type - */ - public String getType() { - return type; - } - - /** - * Set the last used compile command - * @param lastUsedCompileCommand the last used compile command - */ - public void setLastUsedCompileCommand(SystemCompileCommand lastUsedCompileCommand) { - this.lastUsedCompileCommand = lastUsedCompileCommand; - } - - /** - * Get the last used compile command - */ - public SystemCompileCommand getLastUsedCompileCommand() { - return lastUsedCompileCommand; - } - - /** - * Add a compile command at the end. - * @param command a compile command object - */ - public void addCompileCommand(SystemCompileCommand command) { - flushCache(); - commands.add(command); - } - - /** - * Add a compile command, into its appropriate order as per its getOrder() value. - * @param compileCommand a compile command object - */ - public void addCompileCommandInOrder(SystemCompileCommand compileCommand) { - flushCache(); - if (commands.size() == 0) { - commands.add(compileCommand); - return; - } - int order = compileCommand.getOrder(); - SystemCompileCommand cmd = null; - for (int i = 0; i < commands.size(); i++) { - cmd = (SystemCompileCommand) (commands.get(i)); - if (order < cmd.getOrder()) { - commands.insertElementAt(compileCommand, i); - return; - } - } - // reached the end, so just add - commands.add(compileCommand); - } - - /** - * Remove a compile command give its reference - * @param cmd the compile command to remove - */ - public void removeCompileCommand(SystemCompileCommand cmd) { - flushCache(); - SystemCompileCommand compileCmd; - for (int i = 0; i < commands.size(); i++) { - compileCmd = (SystemCompileCommand) (commands.get(i)); - if (compileCmd == cmd) { - commands.remove(i); - return; - } - } - } - - /** - * Remove a compile command given its index - * @param index the zero-based index of the compile command to remove - */ - public SystemCompileCommand removeCompileCommand(int index) { - flushCache(); - return (SystemCompileCommand) (commands.remove(index)); - } - - /** - * Insert a compile command at the given index - * @param compileName a compile command - * @param index the zero-based index to insert it at - */ - public void insertCompileCommand(SystemCompileCommand compileName, int index) { - commands.insertElementAt(compileName, index); - flushCache(); - } - - /** - * Get all compile commands associated with this type - * @return a Vector of SystemCompileCommand objects - */ - public Vector getCompileCommands() { - return commands; - } - - /** - * Get all compile commands associated with this type, as an array. - * @return an array of SystemCompileCommand objects - */ - public SystemCompileCommand[] getCompileCommandsArray() { - SystemCompileCommand[] cmds = new SystemCompileCommand[commands.size()]; - for (int idx = 0; idx < cmds.length; idx++) - cmds[idx] = (SystemCompileCommand) commands.elementAt(idx); - return cmds; - } - - /** - * Get the number of compile commands associated with this type - */ - public int getNumOfCommands() { - return commands.size(); - } - - /** - * Get all promptable compile commands associated with this type - * @return a vector of all promptable compile commands ... that is, SystemCompileCommand objecs - */ - public Vector getPromptableCompileCommands() { - Vector promptableCmds = new Vector(); - SystemCompileCommand compileCmd = null; - for (int i = 0; i < commands.size(); i++) { - compileCmd = (SystemCompileCommand) (commands.get(i)); - if (compileCmd.isPromptable()) promptableCmds.add(compileCmd); - } - return promptableCmds; - } - - /** - * Get all non-promptable compile commands associated with this type - * @return a vector of all non-promptable compile commands ... that is, SystemCompileCommand objecs - */ - public Vector getNonPromptableCompileCommands() { - Vector nonPromptableCmds = new Vector(); - SystemCompileCommand compileCmd = null; - for (int i = 0; i < commands.size(); i++) { - compileCmd = (SystemCompileCommand) (commands.get(i)); - if (compileCmd.isNonPromptable()) nonPromptableCmds.add(compileCmd); - } - return nonPromptableCmds; - } - - /** - * Get the compile command, given its label - */ - public SystemCompileCommand getCompileLabel(String label) { - SystemCompileCommand compileCmd = null; - for (int i = 0; i < commands.size(); i++) { - compileCmd = (SystemCompileCommand) (commands.get(i)); - if (compileCmd.getLabel().equalsIgnoreCase(label)) { - return compileCmd; - } - } - return null; - } - - /** - * Get compile commands, given the id. Note that compile commands with the same - * id might exist for a compile type. This is possible if a user copies a compile - * command in the Work With dialog, and pastes it in the same type. We only - * require the label to be changed, but the id remains the same. - * @return a vector of compile commands that have the given id. - */ - public Vector getCompileId(String id) { - Vector list = new Vector(); - SystemCompileCommand compileCmd = null; - for (int i = 0; i < commands.size(); i++) { - compileCmd = (SystemCompileCommand) (commands.get(i)); - if (compileCmd.getId().equalsIgnoreCase(id)) { - list.add(compileCmd); - } - } - return list; - } - - /** - * Find out if a given compile label already exists - */ - public boolean isIdExists(String id) { - SystemCompileCommand compileCmd = null; - for (int idx = 0; idx < commands.size(); idx++) { - compileCmd = (SystemCompileCommand) (commands.get(idx)); - if (compileCmd.getId().equalsIgnoreCase(id)) { - return true; - } - } - return false; - } - - /** - * Get the compile command, given its index - */ - public SystemCompileCommand getCompileCommand(int index) { - return (SystemCompileCommand) (commands.get(index)); - } - - /** - * Find out if a given compile label already exists - */ - public boolean isLabelExists(String nameString) { - SystemCompileCommand compileCmd = null; - for (int idx = 0; idx < commands.size(); idx++) { - compileCmd = (SystemCompileCommand) (commands.get(idx)); - if (compileCmd.getLabel().equalsIgnoreCase(nameString)) return true; - } - return false; - } - - /** - * Find out if a compile label with the same name already exists. - * Checks if it exists twice or more, since the first is assumed to - * be the current one being edited. - */ - public boolean isDuplicateLabelExists(String nameString) { - SystemCompileCommand compileCmd = null; - boolean once = false; - // has to match twice for us to know that there is a duplicate - for (int idx = 0; idx < commands.size(); idx++) { - compileCmd = (SystemCompileCommand) (commands.get(idx)); - if (compileCmd.getLabel().equalsIgnoreCase(nameString)) { - if (!once) - once = true; - else - return true; - } - } - return false; - } - - /** - * Return a vector of Strings representing the labels for all the compile commands - * within this type. This is typically for uniqueness checking. - */ - public Vector getExistingLabels() { - Vector labels = new Vector(); - for (int idx = 0; idx < commands.size(); idx++) - labels.add(((SystemCompileCommand) commands.get(idx)).getLabel()); - return labels; - } - - /** - * Return this object as a string. - */ - public String toString() { - return getType(); - } - - /** - * This is the method required by the IAdaptable interface. - * Given an adapter class type, return an object castable to the type, or - * null if this is not possible. - */ - public Object getAdapter(Class adapterType) { - return Platform.getAdapterManager().getAdapter(this, adapterType); - } - - // PRIVATE METHODS - private void flushCache() { - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemDefaultCompileCommand.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemDefaultCompileCommand.java deleted file mode 100644 index c9ecc3122..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemDefaultCompileCommand.java +++ /dev/null @@ -1,214 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.compile; - -/******************************************************************************* - * Copyright (c) 2002, 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 - *******************************************************************************/ -import java.util.StringTokenizer; - -/** - * This class encapsulates, for a particular compile command, the - * important information for that command including: - * <ul> - * <li>The label of the command... which is what the user sees in the compile menu - * <li>The name of the command... without parameters. - * <li>The default command string with the minimum parameters we need to compile with this command, using substitution variables. - * </ul> - */ -public class SystemDefaultCompileCommand { - // instance variables - protected String name, label, jobEnv; - protected String addlParms; - protected String[] srcTypes; - - /** - * Constructor that takes a command name and label. - * You must call setAdditionalCommandParameters after this. - */ - public SystemDefaultCompileCommand(String commandLabel, String commandName) { - super(); - this.name = commandName; - this.label = commandLabel; - } - - /** - * Constructor that just takes a command name and defaults the label to it. - * You must call setAdditionalCommandParameters after this. - */ - public SystemDefaultCompileCommand(String commandName) { - this(commandName, commandName); - } - - /** - * Constructor that takes a command name and label and the parameters. - * This avoids you having to call setAdditionalCommandParameters. - */ - public SystemDefaultCompileCommand(String commandLabel, String commandName, String parameters) { - this(commandLabel, commandName); - setAdditionalParameters(parameters); - } - - /** - * Set additional minimum parameters not specified via the constructor. Will be appended to the - * command string in the methods getMinimumCommandWithParameters and getFullCommandWithParameters. - * <p> - * Don't worry about a leading blank. - */ - public void setAdditionalParameters(String parms) { - this.addlParms = " " + parms; //$NON-NLS-1$ - } - - /** - * Set the source type this applies to, when there is only one - */ - public void setSourceType(String type) { - setSourceTypes(new String[] { type }); - } - - /** - * Set the source types this applies to - */ - public void setSourceTypes(String[] types) { - this.srcTypes = types; - } - - /** - * Get the source types this applies to - */ - public String[] getSourceTypes() { - return srcTypes; - } - - /** - * Return true if this command applies to the given source type - */ - public boolean appliesToSourceType(String type) { - if (srcTypes == null) - return false; - else { - boolean match = false; - for (int idx = 0; !match && (idx < srcTypes.length); idx++) { - if (type.equals(srcTypes[idx])) match = true; - } - return match; - } - } - - /** - * Return the command label - */ - public String getLabel() { - return label; - } - - /** - * Return the command name, without parameters - */ - public String getName() { - return name; - } - - /** - * Return command fully populated with default parameters and substitution variables - */ - public String getCommandWithParameters() { - return getCommandWithParameters(null); - } - - /** - * Set the job environment. Some systems support multiple command systems, and this attribute - * is needed to identify which system this should run in. - */ - public void setJobEnvironment(String jobEnv) { - this.jobEnv = jobEnv; - } - - /** - * Return the job environment. This is not often used, but sometimes needed for systems - * that support multiple command systems. - */ - public String getJobEnvironment() { - return jobEnv; - } - - /** - * Given user-specified command paramaters (minus the cmd name), - * verify it has all the minimum parameters we defined for this command. - * For any that are missing, add them... - */ - public String fillWithRequiredParams(String commandParams) { - if ((commandParams == null) || (commandParams.length() == 0)) - return getCommandWithParameters(); - else - return getCommandWithParameters(commandParams); - } - - /** - * Print the command lable to standard out, for debugging purposes - */ - public void printCommandLabel() { - System.out.println(label); - } - - /** - * Print the command name to standard out, for debugging purposes - */ - public void printCommandName() { - System.out.println(name); - } - - /** - * Print the full command string to standard out, for debugging purposes - */ - public void printCommand() { - System.out.println(getCommandWithParameters()); - } - - // ------------------- - // PRIVATE METHODS... - // ------------------- - /** - * Private implementation that supports two modes: - * - append all required parameters - * - append only those required parameters that do not already exist - * <p> - * Typically not overridden. Rather populateWithParameters is overridden, which this calls. - */ - protected String getCommandWithParameters(String existingParameters) { - StringBuffer buffer = null; - if (existingParameters == null) - buffer = new StringBuffer(name); - else - buffer = new StringBuffer(name + " " + existingParameters); //$NON-NLS-1$ - populateWithParameters(buffer); - if (addlParms != null) { - if (existingParameters == null) - buffer.append(" " + addlParms); //$NON-NLS-1$ - else { - // we have to look at each additional parameter and determine if it has been specified in - // given parameter string or not. If not, we add that additional parameter. - StringTokenizer tokens = new StringTokenizer(addlParms); - while (tokens.hasMoreTokens()) { - String parm = tokens.nextToken(); - String parmName = parm.substring(0, parm.indexOf('(') + 1); // "PARM(" - if (existingParameters.indexOf(parmName) == -1) buffer.append(" " + parm); //$NON-NLS-1$ - } - } - } - return buffer.toString(); - } - - /** - * Overridable method that will append required parameters to the command string. - * These are any not already specified via additional parameters - */ - protected void populateWithParameters(StringBuffer bufferSoFar) { - return; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemDefaultCompileCommands.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemDefaultCompileCommands.java deleted file mode 100644 index 2ba9c5908..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemDefaultCompileCommands.java +++ /dev/null @@ -1,196 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.compile; - -/******************************************************************************* - * Copyright (c) 2002, 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 - *******************************************************************************/ -import java.util.Vector; - -/** - * This class manages a list of compile commands. - */ -public abstract class SystemDefaultCompileCommands { - // instance variables - private Vector commands = new Vector(); - private SystemDefaultCompileCommand[] array; - private String[] nameArray, stringArray; - - /** - * Constructor for ISeriesCompileCommands. - */ - public SystemDefaultCompileCommands() { - super(); - } - - /** - * Return all pre-defined compilable source types. Eg, for a typical file system, this - * would be file extensions, like ".c", ".cpp",etc. - */ - public abstract String[] getAllDefaultSuppliedSourceTypes(); - - /** - * Get the compile command at the given index - */ - public SystemDefaultCompileCommand getCommand(int idx) { - return (SystemDefaultCompileCommand) commands.elementAt(idx); - } - - /** - * Get the compile command the corresponds to the given command name. - * Will return null if none found. - */ - public SystemDefaultCompileCommand getCommand(String commandName) { - SystemDefaultCompileCommand match = null; - for (int idx = 0; (match == null) && (idx < commands.size()); idx++) { - SystemDefaultCompileCommand cmd = (SystemDefaultCompileCommand) commands.elementAt(idx); - if (cmd.getName().equalsIgnoreCase(commandName)) match = cmd; - } - return match; - } - - /** - * Get the commands as an array - */ - public SystemDefaultCompileCommand[] getCommands() { - if ((array == null) || (array.length != commands.size())) { - array = new SystemDefaultCompileCommand[commands.size()]; - for (int idx = 0; idx < commands.size(); idx++) - array[idx] = (SystemDefaultCompileCommand) commands.elementAt(idx); - } - return array; - } - - /** - * Get the commands that match the given source types. - * Never returns null, but may return an empty array. - */ - public SystemDefaultCompileCommand[] getCommandsForSrcType(String srcType) { - Vector v = new Vector(); - for (int idx = 0; idx < commands.size(); idx++) { - if (((SystemDefaultCompileCommand) commands.elementAt(idx)).appliesToSourceType(srcType)) v.addElement(commands.elementAt(idx)); - } - SystemDefaultCompileCommand[] matches = new SystemDefaultCompileCommand[v.size()]; - for (int idx = 0; idx < matches.length; idx++) - matches[idx] = (SystemDefaultCompileCommand) v.elementAt(idx); - return matches; - } - - /** - * Get the command names only as an array - */ - public String[] getCommandNames() { - if ((nameArray == null) || (nameArray.length != commands.size())) { - nameArray = new String[commands.size()]; - for (int idx = 0; idx < commands.size(); idx++) - nameArray[idx] = ((SystemDefaultCompileCommand) commands.elementAt(idx)).getName(); - } - return nameArray; - } - - /** - * Get the fully-populated command strings as an array of string - */ - public String[] getCommandStrings() { - if ((stringArray == null) || (stringArray.length != commands.size())) { - stringArray = new String[commands.size()]; - for (int idx = 0; idx < commands.size(); idx++) - stringArray[idx] = ((SystemDefaultCompileCommand) commands.elementAt(idx)).getCommandWithParameters(); - } - return stringArray; - } - - /** - * Return a count of the compile commands in this list - */ - public int getSize() { - return commands.size(); - } - - /** - * Given a user-specified command string, check if the command is one of those defined in this list, - * and if so, verify it has all the minimum parameters. For any that are missing, add them... - */ - public String fillWithRequiredParams(String commandString) { - if (commandString == null) return null; - // first, extract the command name - commandString = commandString.trim(); - if (commandString.length() == 0) return commandString; - int blankIdx = commandString.indexOf(' '); - String cmdName = null; - String cmdParms = null; - if (blankIdx == -1) // no blanks? - { - cmdName = commandString; // assume the string only contains a command name, no parms - } else { - cmdName = commandString.substring(0, blankIdx); - cmdParms = commandString.substring(blankIdx + 1); - } - // second, test if this command name is in our list... - SystemDefaultCompileCommand cmdMatch = getCommand(cmdName); - if (cmdMatch != null) - return cmdMatch.fillWithRequiredParams(cmdParms); - else - return commandString; - } - - /** - * Add a new compile command to the list - */ - public void addCommand(SystemDefaultCompileCommand cmd) { - commands.add(cmd); - clearCache(); - } - - /** - * Print the command labels to standard out, for debugging purposes - */ - public void printCommandLabels() { - System.out.println(); - System.out.println("Total commands: " + getSize()); //$NON-NLS-1$ - for (int idx = 0; idx < commands.size(); idx++) { - SystemDefaultCompileCommand cmd = (SystemDefaultCompileCommand) commands.elementAt(idx); - cmd.printCommandLabel(); - } - System.out.println(); - } - - /** - * Print the command names to standard out, for debugging purposes - */ - public void printCommandNames() { - System.out.println(); - System.out.println("Total commands: " + getSize()); //$NON-NLS-1$ - for (int idx = 0; idx < commands.size(); idx++) { - SystemDefaultCompileCommand cmd = (SystemDefaultCompileCommand) commands.elementAt(idx); - cmd.printCommandName(); - } - System.out.println(); - } - - /** - * Print the full command strings to standard out, for debugging purposes - */ - public void printCommands() { - System.out.println(); - System.out.println("Total commands: " + getSize()); //$NON-NLS-1$ - for (int idx = 0; idx < commands.size(); idx++) { - SystemDefaultCompileCommand cmd = (SystemDefaultCompileCommand) commands.elementAt(idx); - cmd.printCommand(); - } - System.out.println(); - } - - /** - * Clear array cache - */ - private void clearCache() { - array = null; - nameArray = null; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemNewCompileSrcTypeDialog.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemNewCompileSrcTypeDialog.java deleted file mode 100644 index b7cb5a6eb..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemNewCompileSrcTypeDialog.java +++ /dev/null @@ -1,217 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.compile; - -/******************************************************************************* - * Copyright (c) 2002, 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 - *******************************************************************************/ -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources; -import org.eclipse.rse.services.clientserver.messages.SystemMessage; -import org.eclipse.rse.ui.ISystemMassager; -import org.eclipse.rse.ui.SystemWidgetHelpers; -import org.eclipse.rse.ui.dialogs.SystemPromptDialog; -import org.eclipse.rse.ui.validators.ISystemValidator; -import org.eclipse.rse.ui.validators.ISystemValidatorUniqueString; -import org.eclipse.rse.ui.validators.ValidatorSourceType; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; - -/** - * Dialog used when in the Work With Compile Commands dialog when the user presses - * the "Add..." button to add a new source type. - * <p> - * This class is designed so that it need not be subclassed. Rather, the mri, validation - * and massaging can all be configured. - */ -public class SystemNewCompileSrcTypeDialog extends SystemPromptDialog { - // gui - protected Text srcTypeText; - // input - protected SystemCompileManager manager; - protected ISystemValidator srcTypeValidator; - protected ISystemMassager srcTypeMassager; - protected boolean caseSensitive; - protected String[] existingTypes; - // output - protected String newSrcType; - // state - protected SystemMessage errorMessage; - protected boolean ignoreEvents; - // mri - protected String mriVerbageLabel, mriPromptLabel, mriPromptTooltip; - - /** - * Constructor when you want to use the default title. - * @param shell The parent window hosting this dialog - * @param compileManager The compile manager that manages these compile commands - * @param caseSensitive True if source types are case-sensitive. False if not. - */ - public SystemNewCompileSrcTypeDialog(Shell shell, SystemCompileManager compileManager, boolean caseSensitive) { - this(shell, compileManager, caseSensitive, SystemUDAResources.RESID_COMPILE_NEWSRCTYPE_TITLE); - } - - /** - * Constructor when you want to supply your own title. - * @param shell The parent window hosting this dialog - * @param compileManager The compile manager that manages these compile commands - * @param caseSensitive True if source types are case-sensitive. False if not. - */ - public SystemNewCompileSrcTypeDialog(Shell shell, SystemCompileManager compileManager, boolean caseSensitive, String title) { - super(shell, title); - this.manager = compileManager; - this.caseSensitive = caseSensitive; - setMRI(SystemUDAResources.RESID_COMPILE_NEWSRCTYPE_VERBAGE_LABEL, SystemUDAResources.RESID_COMPILE_NEWSRCTYPE_PROMPT_LABEL, SystemUDAResources.RESID_COMPILE_NEWSRCTYPE_PROMPT_TOOLTIP); - } - - public void setMRI(String verbageMRILabel, String promptMRILabel, String promptMRITooltip) { - if (verbageMRILabel != null) this.mriVerbageLabel = verbageMRILabel; - if (promptMRILabel != null) this.mriPromptLabel = promptMRILabel; - if (promptMRITooltip != null) this.mriPromptTooltip = promptMRITooltip; - } - - /** - * Set the validator for the new src type - */ - public void setSrcTypeValidator(ISystemValidator validator) { - this.srcTypeValidator = validator; - if ((existingTypes != null) && (srcTypeValidator instanceof ISystemValidatorUniqueString)) { - ((ISystemValidatorUniqueString) srcTypeValidator).setExistingNamesList(existingTypes); - } - } - - /** - * Set the existing source types so error checking will prevent them from being entered again. - */ - public void setExistingSrcTypes(String[] srcTypes) { - this.existingTypes = srcTypes; - if ((srcTypeValidator != null) && (srcTypeValidator instanceof ISystemValidatorUniqueString)) { - ((ISystemValidatorUniqueString) srcTypeValidator).setExistingNamesList(existingTypes); - } - } - - /** - * Set the massager for the new src type. This will be - * called to massage the source type before it is returned. - * Eg, you might pass MassagerFoldCase to fold the result to uppercase or lowercase. - */ - public void setSrcTypeMassager(ISystemMassager massager) { - this.srcTypeMassager = massager; - } - - /** - * Create GUI controls, populate into given composite. - */ - protected Control createInner(Composite parent) { - if (srcTypeValidator == null) setSrcTypeValidator(new ValidatorSourceType(caseSensitive)); - // Inner composite - int nbrColumns = 2; - Composite composite_prompts = SystemWidgetHelpers.createComposite(parent, nbrColumns); - // VERBAGE - SystemWidgetHelpers.createVerbiage(composite_prompts, mriVerbageLabel, nbrColumns, false, 250); - // ENTRY FIELD - srcTypeText = SystemWidgetHelpers.createLabeledTextField(composite_prompts, null, mriPromptLabel, mriPromptTooltip); - // add keystroke listeners... - srcTypeText.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - validateInput(); - } - }); - setPageComplete(false); // since input is currently empty - return composite_prompts; - } - - /** - * Return widget to set initial focus to - */ - protected Control getInitialFocusControl() { - return srcTypeText; - } - - /** - * Called when user presses OK button. - * Return true to close dialog. - * Return false to not close dialog. - */ - protected boolean processOK() { - newSrcType = srcTypeText.getText().trim(); - if (srcTypeMassager != null) { - newSrcType = srcTypeMassager.massage(newSrcType); - ignoreEvents = true; - srcTypeText.setText(newSrcType); - ignoreEvents = false; - } - boolean closeDialog = verify(); - if (closeDialog) { - setOutputObject(newSrcType); - } - return closeDialog; - } - - /** - * Verifies all input. - * @return true if there are no errors in the user input - */ - public boolean verify() { - errorMessage = validateInput(); - if (errorMessage == null) - clearErrorMessage(); - else { - srcTypeText.setFocus(); - setErrorMessage(errorMessage); - } - return (errorMessage == null); - } - - /** - * This hook method is called whenever the text changes in the cmd input field. - * Currently not used. - */ - protected SystemMessage validateInput() { - if (ignoreEvents) return errorMessage; - errorMessage = null; - if (srcTypeValidator != null) errorMessage = srcTypeValidator.validate(srcTypeText.getText().trim()); - if (errorMessage != null) - setErrorMessage(errorMessage); - else - clearErrorMessage(); - setPageComplete(); - return errorMessage; - } - - /** - * This method can be called by the dialog or wizard page host, to decide whether to enable - * or disable the next, final or ok buttons. It returns true if the minimal information is - * available and is correct. - */ - public boolean isPageComplete() { - boolean pageComplete = false; - if (errorMessage == null) { - pageComplete = (srcTypeText.getText().trim().length() > 0); - } - return pageComplete; - } - - /** - * Inform caller of page-complete status of this form - */ - public void setPageComplete() { - setPageComplete(isPageComplete()); - } - - /** - * Returns the user-specified new source type - */ - public String getNewSrcType() { - //System.out.println("Returning " + newSrcType); - return newSrcType; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemPromptCompileCommandDialog.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemPromptCompileCommandDialog.java deleted file mode 100644 index e74317da6..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemPromptCompileCommandDialog.java +++ /dev/null @@ -1,84 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.compile; - -/******************************************************************************* - * Copyright (c) 2002, 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 - *******************************************************************************/ -import org.eclipse.rse.internal.useractions.ui.SystemPromptCommandDialog; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources; -import org.eclipse.swt.widgets.Shell; - -/** - * Dialog used when running a user action, which has the prompt option specified. - * This allows the user to edit the resolved command, and the result is placed - * in the output object. - * <p> - * This default implementation merely puts the command into an entry field, which - * the user can edit. - */ -public class SystemPromptCompileCommandDialog extends SystemPromptCommandDialog { - /** - * Constructor. - * @param shell The parent window hosting this dialog - * @param command The resolved command from the user action - */ - public SystemPromptCompileCommandDialog(Shell shell, String command) { - super(shell, command, SystemUDAResources.RESID_COMPILE_PROMPTCMD_TITLE); - this.cmd = command; - //setHelp(RSEUIPlugin.HELPPREFIX+"drnp0000"); - } - - /** - * Translated text configuration method. - * Override to return OK button label if you don't want the default - */ - protected String getOKButtonLabel() { - return SystemUDAResources.RESID_COMPILE_PROMPTCMD_OKBUTTON_LABEL; - } - - /** - * Translated text configuration method. - * Override to return OK button tooltip if you don't want the default - */ - protected String getOKButtonToolTipText() { - return SystemUDAResources.RESID_COMPILE_PROMPTCMD_OKBUTTON_TOOLTIP; - } - - /** - * Translated text configuration method. - * Override to return Cancel button tooltip if you don't want the default - */ - protected String getCancelButtonToolTipText() { - return SystemUDAResources.RESID_COMPILE_PROMPTCMD_CANCELBUTTON_TOOLTIP; - } - - /** - * Translated text configuration method. - * Override to return verbage message if you don't want the default - */ - protected String getVerbage() { - return SystemUDAResources.RESID_COMPILE_PROMPTCMD_VERBAGE_LABEL; - } - - /** - * Translated text configuration method. - * Override to return label for the command prompt, if you don't want the default - */ - protected String getPromptLabel() { - return SystemUDAResources.RESID_COMPILE_PROMPTCMD_PROMPT_LABEL; - } - - /** - * Translated text configuration method. - * Override to return tooltip text for the command prompt, if you don't want the default - */ - protected String getPromptToolTipText() { - return SystemUDAResources.RESID_COMPILE_PROMPTCMD_PROMPT_TOOLTIP; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemWorkWithCompileCommandsDialog.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemWorkWithCompileCommandsDialog.java deleted file mode 100644 index b48d005a5..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemWorkWithCompileCommandsDialog.java +++ /dev/null @@ -1,1125 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core - * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry - * David Dykstal (IBM) - [186589] move user types, user actions, and compile commands - * API to the user actions plugin - * David Dykstal (IBM) - [232318] fixing layout problems with button composite - *******************************************************************************/ - -package org.eclipse.rse.internal.useractions.ui.compile; - -import java.util.Vector; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.rse.core.RSECorePlugin; -import org.eclipse.rse.core.events.ISystemModelChangeEvents; -import org.eclipse.rse.internal.ui.view.SystemViewMenuListener; -import org.eclipse.rse.internal.useractions.IUserActionsModelChangeEvents; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources; -import org.eclipse.rse.services.clientserver.messages.SystemMessage; -import org.eclipse.rse.ui.ISystemContextMenuConstants; -import org.eclipse.rse.ui.ISystemMessages; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.SystemWidgetHelpers; -import org.eclipse.rse.ui.actions.ISystemAction; -import org.eclipse.rse.ui.dialogs.SystemPromptDialog; -import org.eclipse.rse.ui.messages.SystemMessageDialog; -import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter; -import org.eclipse.rse.ui.view.SystemAdapterHelpers; -import org.eclipse.rse.ui.widgets.ISystemEditPaneStates; -import org.eclipse.rse.ui.widgets.SystemEditPaneStateMachine; -import org.eclipse.swt.dnd.Clipboard; -import org.eclipse.swt.dnd.TextTransfer; -import org.eclipse.swt.dnd.Transfer; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.events.KeyListener; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.events.MouseListener; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.List; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Widget; - -/** - * A dialog that allows the user to work with the compile commands for the compile actions in this subsystem. - */ -public class SystemWorkWithCompileCommandsDialog extends SystemPromptDialog implements SelectionListener, ISystemCompileCommandEditPaneListener, IMenuListener, Runnable, - ISystemCompileCommandEditPaneHoster { - protected Button applyButton, revertButton, newSrcTypeButton, rmvSrcTypeButton; - protected Combo profileCombo; - protected Combo srcTypeCombo; - protected List listView; - protected Label ccLabel; - protected SystemEditPaneStateMachine sm; - // context menu actions support - private SystemCompileCommandActionCopy copyAction; - private SystemCompileCommandActionPaste pasteAction; - private SystemCompileCommandActionDelete deleteAction; - private SystemCompileCommandActionMoveUp moveUpAction; - private SystemCompileCommandActionMoveDown moveDownAction; - private SystemCompileCommandActionRestoreDefaults restoreAction; - private MenuManager menuMgr; - private Clipboard clipboard; - private boolean menuListenerAdded; - // inputs - protected SystemCompileManager compileManager; - protected SystemCompileCommandEditPane editpane; - protected SystemCompileProfile[] compProfiles; - protected SystemCompileProfile currentCompProfile; - protected SystemCompileType currentCompType; - protected boolean caseSensitive; - protected boolean supportsAddSrcTypeButton; - private String srcTypeLabel, srcTypeTooltip; - // state - protected boolean ignoreEvents = false; - protected boolean restoreProfileComboSelection = true; - protected boolean showProfileCombo; - protected boolean resetting = false; - protected boolean giveEditorFocus = true; - protected int prevProfileComboSelection = 0; - protected int prevSrcTypeComboSelection = 0; - protected int prevListSelection = 0; - protected String[] compileTypeNames; - private boolean traceTest; - - /** - * Constructor - */ - public SystemWorkWithCompileCommandsDialog(Shell shell, SystemCompileManager compileManager, SystemCompileProfile currentCompProfile) { - this(shell, compileManager, currentCompProfile, SystemUDAResources.RESID_WWCOMPCMDS_TITLE); - } - - /** - * Constructor, when unique title desired - */ - public SystemWorkWithCompileCommandsDialog(Shell shell, SystemCompileManager compileManager, SystemCompileProfile currentCompProfile, String title) { - super(shell, title); - this.compileManager = compileManager; - this.currentCompProfile = currentCompProfile; - this.compProfiles = new SystemCompileProfile[] { currentCompProfile }; - this.supportsAddSrcTypeButton = true; - setCancelButtonLabel(SystemUDAResources.BUTTON_CLOSE); - setShowOkButton(false); - setOutputObject(null); - setHelp(); - // default mri values... - setSourceTypePromptMRI(compileManager.getSourceTypePromptMRILabel(), compileManager.getSourceTypePromptMRITooltip()); - } - - /** - * Overridable extension point for setting dialog help - */ - protected void setHelp() { - setHelp(RSEUIPlugin.HELPPREFIX + "wwcc0000"); //$NON-NLS-1$ - } - - // INPUT/CONFIGURATION - /** - * Specify an edit pane that prompts the user for the contents of a compile command - */ - public void setCompileCommandEditPane(SystemCompileCommandEditPane editPane) { - this.editpane = editPane; - } - - /** - * Set the compile profiles to show in the profile combo. - * @param profiles - array of profiles to show - */ - public void setProfiles(SystemCompileProfile[] profiles) { - if (profiles == null) - compProfiles = new SystemCompileProfile[0]; - else { - compProfiles = profiles; - showProfileCombo = true; - } - } - - /** - * Set whether the source types, labels, etc are case sensitive - */ - public void setCaseSensitive(boolean caseSensitive) { - this.caseSensitive = caseSensitive; - } - - /** - * Set supports the "Add..." button beside the source type combo. - * The default is true. - */ - public void setSupportsAddSrcTypeButton(boolean supports) { - this.supportsAddSrcTypeButton = supports; - } - - /** - * Set the mri for the source type prompt - */ - public void setSourceTypePromptMRI(String srcTypeMRILabel, String srcTypeMRITooltip) { - this.srcTypeLabel = srcTypeMRILabel; - this.srcTypeTooltip = srcTypeMRITooltip; - } - - /** - * Set the compile to pre-select in the types combo - */ - public void setCompileType(SystemCompileType type) { - this.currentCompType = type; - } - - /** - * @see SystemPromptDialog#getInitialFocusControl() - */ - protected Control getInitialFocusControl() { - return editpane.getInitialFocusControl(); - } - - /** - * @see SystemPromptDialog#createInner(Composite) - */ - protected Control createInner(Composite parent) { - editpane = getCompileCommandEditPane(getShell()); - //editpane.setSubSystem(subsystem); - // Inner composite - int nbrColumns = 4; - Composite composite = SystemWidgetHelpers.createComposite(parent, nbrColumns); - // profile combo - profileCombo = SystemWidgetHelpers.createLabeledReadonlyCombo(composite, null, SystemUDAResources.RESID_WWCOMPCMDS_PROFILE_LABEL, SystemUDAResources.RESID_WWCOMPCMDS_PROFILE_TOOLTIP); - ((GridData) profileCombo.getLayoutData()).horizontalSpan = nbrColumns - 1; - // source type combo - srcTypeCombo = SystemWidgetHelpers.createLabeledReadonlyCombo(composite, null, srcTypeLabel, srcTypeTooltip); - if (supportsAddSrcTypeButton) { - newSrcTypeButton = SystemWidgetHelpers.createPushButton(composite, null, SystemUDAResources.RESID_WWCOMPCMDS_TYPES_BUTTON_ADD_LABEL, - SystemUDAResources.RESID_WWCOMPCMDS_TYPES_BUTTON_ADD_TOOLTIP); - rmvSrcTypeButton = SystemWidgetHelpers.createPushButton(composite, null, SystemUDAResources.RESID_WWCOMPCMDS_TYPES_BUTTON_RMV_LABEL, - SystemUDAResources.RESID_WWCOMPCMDS_TYPES_BUTTON_RMV_TOOLTIP); - rmvSrcTypeButton.setEnabled(false); - } else - ((GridData) srcTypeCombo.getLayoutData()).horizontalSpan = nbrColumns - 1; - //SystemWidgetHelpers.setHelp(profileCombo, RSEUIPlugin.HELPPREFIX + "ccon0001", parentHelpId); - addFillerLine(composite, nbrColumns); - // create list view on left - listView = SystemWidgetHelpers.createListBox(composite, SystemUDAResources.RESID_WWCOMPCMDS_LIST_LABEL, null, false, 1); - //listView.setToolTipText(listPromptTip); annoying! - GridData data = (GridData) listView.getLayoutData(); - data.grabExcessHorizontalSpace = false; - data.horizontalAlignment = GridData.FILL; - data.grabExcessVerticalSpace = true; - data.verticalAlignment = GridData.FILL; - data.widthHint = 110; - // we want the tree view on the left to extend to the bottom of the page, so on the right - // we create a 1-column composite that will hold the edit pane on top, and the apply/revert - // buttons on the bottom... - Composite rightSideComposite = SystemWidgetHelpers.createFlushComposite(composite, 1); - ((GridData) rightSideComposite.getLayoutData()).horizontalSpan = nbrColumns - 1; - // now add a top spacer line and visual separator line, for the right side - addFillerLine(rightSideComposite, 1); - ccLabel = SystemWidgetHelpers.createLabel(rightSideComposite, ""); //$NON-NLS-1$ - addSeparatorLine(rightSideComposite, 1); - // now populate top of right-side composite with edit pane... - editpane.createContents(rightSideComposite); - // now add a bottom visual separator line - addSeparatorLine(rightSideComposite, 1); - // now populate bottom of right-side composite with apply/revert buttons within their own composite - int nbrColumns_buttonComposite = 3; - Composite applyResetButtonComposite = SystemWidgetHelpers.createFlushComposite(rightSideComposite, nbrColumns_buttonComposite); - // now populate the buttons composite with apply and revert buttons - Label filler = SystemWidgetHelpers.createLabel(applyResetButtonComposite, ""); //$NON-NLS-1$ - ((GridData) filler.getLayoutData()).grabExcessHorizontalSpace = true; - ((GridData) filler.getLayoutData()).horizontalAlignment = GridData.FILL; - applyButton = SystemWidgetHelpers.createPushButton(applyResetButtonComposite, this, SystemUDAResources.RESID_WWCOMPCMDS_BUTTON_APPLY_LABEL, - SystemUDAResources.RESID_WWCOMPCMDS_BUTTON_APPLY_TOOLTIP); - ((GridData) applyButton.getLayoutData()).grabExcessHorizontalSpace = false; - revertButton = SystemWidgetHelpers.createPushButton(applyResetButtonComposite, this, SystemUDAResources.RESID_WWCOMPCMDS_BUTTON_REVERT_LABEL, - SystemUDAResources.RESID_WWCOMPCMDS_BUTTON_REVERT_TOOLTIP); - ((GridData) revertButton.getLayoutData()).grabExcessHorizontalSpace = false; - // now add a spacer to soak up left-over height... - addGrowableFillerLine(rightSideComposite, 1); - // create state machine to manage edit pane - sm = new SystemEditPaneStateMachine(rightSideComposite, applyButton, revertButton); - sm.setApplyLabelForNewMode(SystemUDAResources.RESID_WWCOMPCMDS_BUTTON_CREATE_LABEL, SystemUDAResources.RESID_WWCOMPCMDS_BUTTON_CREATE_TOOLTIP); - sm.setUnsetMode(); - // populate profile dropdown - initProfileCombo(); - composite.layout(true); - // add listeners - profileCombo.addSelectionListener(this); - srcTypeCombo.addSelectionListener(this); - if (supportsAddSrcTypeButton) { - newSrcTypeButton.addSelectionListener(this); - rmvSrcTypeButton.addSelectionListener(this); - } - listView.addSelectionListener(this); - applyButton.addSelectionListener(this); - revertButton.addSelectionListener(this); - editpane.addChangeListener(this); - // add special listeners for accessibility -- do not change focus when navigating list with keys - listView.addMouseListener(new MouseListener() { - public void mouseDoubleClick(MouseEvent e) { - giveEditorFocus = true; - } - - public void mouseDown(MouseEvent e) { - giveEditorFocus = true; - } - - public void mouseUp(MouseEvent e) { - giveEditorFocus = true; - } - }); - listView.addKeyListener(new KeyListener() { - public void keyPressed(KeyEvent e) { - giveEditorFocus = false; - } - - public void keyReleased(KeyEvent e) { - giveEditorFocus = false; - } - }); - // add context menu - // ----------------------------- - // Enable right-click popup menu - // ----------------------------- - menuMgr = new MenuManager("#WWCompCmdsPopupMenu"); //$NON-NLS-1$ - menuMgr.setRemoveAllWhenShown(true); - menuMgr.addMenuListener(this); - Menu menu = menuMgr.createContextMenu(listView); - listView.setMenu(menu); - editpane.configureHeadingLabel(ccLabel); - editpane.isComplete();// side effect is initial enablement of test button - return composite; - } - - /** - * Intercept of parent so we can reset the default button - */ - protected void createButtonsForButtonBar(Composite parent) { - super.createButtonsForButtonBar(parent); - getShell().setDefaultButton(applyButton); // defect 46129 - } - - /** - * Return our edit pane. Overriding this is an alternative to calling setEditPane. - * This is called in createContents - */ - protected SystemCompileCommandEditPane getCompileCommandEditPane(Shell shell) { - if (editpane == null) editpane = compileManager.getCompileCommandEditPane(shell, this, caseSensitive); - return editpane; - } - - /** - * Initialize contents and selection of profile combo - */ - private void initProfileCombo() { - if (profileCombo != null) { - if ((compProfiles != null) && (compProfiles.length > 0)) { - String[] names = new String[compProfiles.length]; - int selIdx = -1; - for (int idx = 0; idx < names.length; idx++) { - names[idx] = compProfiles[idx].getProfileName(); - if ((currentCompProfile != null) && (currentCompProfile == compProfiles[idx])) selIdx = idx; - } - if (selIdx == -1) { - selIdx = 0; - currentCompProfile = compProfiles[0]; - } - profileCombo.setItems(names); - profileCombo.setText(names[selIdx]); - prevProfileComboSelection = selIdx; - if (currentCompProfile != null) { - if (currentCompType != null) - processProfileSelected(currentCompType.getType()); - else - processProfileSelected(null); - } - } - } - } - - /** - * Process when a profile is selected - */ - private void processProfileSelected(String srcType) { - if (srcType == null) { - ISystemRemoteElementAdapter rmtAdapter = SystemAdapterHelpers.getRemoteAdapter(getInputObject()); - if (rmtAdapter != null) { - srcType = rmtAdapter.getRemoteSourceType(getInputObject()); - /* - if (currentCompProfile.getCompileType(srcType) == null) - { - currentCompProfile.addCompileType(new SystemCompileType(currentCompProfile, srcType)); - saveData(); - }*/ - } - } - Vector types = currentCompProfile.getCompileTypes(); - if (srcType == null) { - if (types.size() > 0) - srcType = ((SystemCompileType) types.elementAt(0)).getType(); - else { - srcType = ""; //$NON-NLS-1$ - } - } - compileTypeNames = new String[types.size()]; - int index = 0; - // when profile is selected, show the member type - // of the DataElement selected. - for (int i = 0; i < compileTypeNames.length; i++) { - compileTypeNames[i] = ((SystemCompileType) types.get(i)).getType(); - if (!caseSensitive) { - if (srcType.equalsIgnoreCase(compileTypeNames[i])) index = i; - } else { - if (srcType.equals(compileTypeNames[i])) index = i; - } - } - srcTypeCombo.setItems(compileTypeNames); - if (srcTypeCombo.getItemCount() > 0) { - srcTypeCombo.setText(srcTypeCombo.getItem(index)); - prevSrcTypeComboSelection = index; - currentCompType = currentCompProfile.getCompileType(srcTypeCombo.getText()); - processSrcTypeSelected(0); - } else { - prevSrcTypeComboSelection = -1; - currentCompType = null; - processSrcTypeSelected(-1); - } - } - - /** - * Process when src type selected - */ - private void processSrcTypeSelected(int selection) { - Vector cmds = new Vector(); - if (currentCompType != null) cmds = currentCompType.getCompileCommands(); - if (rmvSrcTypeButton != null) rmvSrcTypeButton.setEnabled((currentCompType != null) && (cmds.size() == 0)); - if (currentCompType != null) { - String[] listItems = new String[1 + cmds.size()]; - listItems[0] = SystemUDAResources.RESID_WWCOMPCMDS_LIST_NEWITEM; - for (int idx = 0; idx < cmds.size(); idx++) - listItems[idx + 1] = ((SystemCompileCommand) cmds.get(idx)).getLabel(); - listView.setItems(listItems); - listView.setSelection(selection); - } else { - listView.removeAll(); - } - processCommandsListSelected(); - } - - /** - * Process when compile command is selected in the list view - */ - private void processCommandsListSelected() { - int index = listView.getSelectionIndex(); - if (index == 0) { - sm.setNewMode(); - editpane.setCompileCommand(currentCompType, null); - editpane.configureHeadingLabel(ccLabel); - } else if (index > -1) // and not zero - { - SystemCompileCommand currCmd = getCurrentlySelectedCompileCommand(); - sm.setEditMode(); - editpane.setCompileCommand(currentCompType, currCmd); - editpane.configureHeadingLabel(ccLabel); - } else { - sm.setUnsetMode(); - editpane.setCompileCommand(null, null); - } - prevListSelection = index; - } - - /** - * Gets the current compile profile, given the profile selection index - */ - private SystemCompileProfile getCompileProfile(int currSelIdx) { - return compProfiles[currSelIdx]; - } - - /** - * Parent override. - * Called when user presses CLOSE button. - * We simply close the dialog (since we save as we go), unless there are pending changes. - */ - protected boolean processCancel() { - if (sm.isSaveRequired()) { - ignoreEvents = true; - if ((editpane.verify() != null)) { - ignoreEvents = false; - sm.setChangesMade(); // defect 45773 - return false; // pending errors. Cannot save, so cannot close! - } - ignoreEvents = false; - //saveData(); - applyPressed(false); // defect 46379 - } - return super.processCancel(); - } - - /** - * Save the data in the currently selected profile - */ - private void saveData() { - if (currentCompProfile != null) currentCompProfile.writeToDisk(); - } - - /** - * Handles events generated by controls on this page. - */ - public void widgetSelected(SelectionEvent e) { - clearMessage(); - Widget source = e.widget; - if (resetting) return; - if (source == applyButton) { - applyPressed(true); - } else if (source == revertButton) { - revertPressed(); - } else if (source == newSrcTypeButton) { - newSrcTypePressed(); - } else if (source == rmvSrcTypeButton) { - rmvSrcTypePressed(); - } else if (source == listView) { - if (traceTest) System.out.println("Inside widgetSelected for listView: " + listView.getSelectionIndex()); //$NON-NLS-1$ - // change for pendings changes or unresolved errors... - if (editpane.areErrorsPending()) { - //System.out.println("errors pending in editpane"); - e.doit = false; // dang, this doesn't work! - resetting = true; - listView.select(prevListSelection); - resetting = false; - return; - } else if (sm.isSaveRequired()) { - boolean newMode = (sm.getMode() == ISystemEditPaneStates.MODE_NEW); - if (editpane.verify() != null) { - //System.out.println("verify in editpane returned an error"); - e.doit = false; // dang, this doesn't work! - resetting = true; - listView.select(prevListSelection); - resetting = false; - sm.setChangesMade(); // isSaveRequired() resets it so we need to undo that - return; - } - int newSelection = listView.getSelectionIndex(); - saveCompileCommand(editpane.saveChanges(), newMode, prevListSelection); - listView.select(newSelection); // the save changed the selection, so we need to restore it - } - processCommandsListSelected(); - if (giveEditorFocus) { - Control c = editpane.getInitialFocusControl(); - if ((c != null) && !c.isDisposed() && c.isVisible()) c.setFocus(); - } - } else if (source == profileCombo) { - if (editpane.areErrorsPending()) { - restoreProfileComboSelection = true; - profileCombo.getDisplay().asyncExec(this); - return; - } else if (sm.isSaveRequired()) // defect 46318 - { - boolean newMode = (sm.getMode() == ISystemEditPaneStates.MODE_NEW); - if (editpane.verify() != null) { - restoreProfileComboSelection = true; - sm.setChangesMade(); // isSaveRequired() resets it so we need to undo that - profileCombo.getDisplay().asyncExec(this); - return; // newly-found errors are pending so go no further - } - //int newSelection = listView.getSelectionIndex(); - saveCompileCommand(editpane.saveChanges(), newMode, prevListSelection); - //listView.select(newSelection); // the save changed the selection, so we need to restore it - } - int idx = profileCombo.getSelectionIndex(); - currentCompProfile = getCompileProfile(idx); - //processProfileSelected(srcTypeCombo.getText()); - processProfileSelected(null); - prevProfileComboSelection = idx; - } else if (source == srcTypeCombo) { - if (editpane.areErrorsPending()) { - restoreProfileComboSelection = false; - srcTypeCombo.getDisplay().asyncExec(this); - return; - } else if (sm.isSaveRequired()) // defect 46318 - { - boolean newMode = (sm.getMode() == ISystemEditPaneStates.MODE_NEW); - if (editpane.verify() != null) { - restoreProfileComboSelection = false; - sm.setChangesMade(); // isSaveRequired() resets it so we need to undo that - profileCombo.getDisplay().asyncExec(this); - return; // newly-found errors are pending so go no further - } - //int newSelection = listView.getSelectionIndex(); - saveCompileCommand(editpane.saveChanges(), newMode, prevListSelection); - //listView.select(newSelection); // the save changed the selection, so we need to restore it - } - int idx = srcTypeCombo.getSelectionIndex(); - currentCompType = currentCompProfile.getCompileType(srcTypeCombo.getText()); - processSrcTypeSelected(0); - prevSrcTypeComboSelection = idx; - } - } - - /** - * User pressed Apply to save the pending changes the current filter string - */ - protected void applyPressed(boolean doVerify) { - ignoreEvents = true; - if (!doVerify || (editpane.verify() == null)) { - SystemCompileCommand editedCompileCmd = editpane.saveChanges(); - boolean ok = (editedCompileCmd != null); - if (ok) { - boolean newMode = (sm.getMode() == ISystemEditPaneStates.MODE_NEW); - sm.applyPressed(); - saveCompileCommand(editedCompileCmd, newMode, prevListSelection); - processCommandsListSelected(); - if (newMode) - RSECorePlugin.getTheSystemRegistry().fireModelChangeEvent(ISystemModelChangeEvents.SYSTEM_RESOURCE_ADDED, IUserActionsModelChangeEvents.SYSTEM_RESOURCETYPE_COMPILECMD, editedCompileCmd, - null); - else - RSECorePlugin.getTheSystemRegistry().fireModelChangeEvent(ISystemModelChangeEvents.SYSTEM_RESOURCE_CHANGED, IUserActionsModelChangeEvents.SYSTEM_RESOURCETYPE_COMPILECMD, - editedCompileCmd, null); - } - } - ignoreEvents = false; - } - - /** - * User pressed Revert to discard the pending changes the current filter string - */ - protected void revertPressed() { - ignoreEvents = true; - editpane.clearErrorMessage(); - sm.resetPressed(); - if (isNewSelected() || (listView.getSelectionIndex() == -1)) - editpane.setCompileCommand(currentCompType, null); - else - editpane.setCompileCommand(currentCompType, getCurrentlySelectedCompileCommand()); - setPageComplete(true); - clearErrorMessage(); - ignoreEvents = false; - } - - /** - * User pressed New... beside the Source Type combo - */ - protected void newSrcTypePressed() { - if (sm.isSaveRequired()) { - ignoreEvents = true; - if ((editpane.verify() != null)) { - ignoreEvents = false; - return; // pending errors. Cannot save, so cannot process! - } - ignoreEvents = false; - //saveData(); - applyPressed(false); // defect 46379 - } - SystemNewCompileSrcTypeDialog dlg = compileManager.getNewSrcTypeDialog(getShell(), caseSensitive); - dlg.setExistingSrcTypes(compileTypeNames); - dlg.open(); - if (!dlg.wasCancelled()) { - String newSrcType = dlg.getNewSrcType(); - currentCompProfile.addCompileType(new SystemCompileType(currentCompProfile, newSrcType)); - saveData(); - processProfileSelected(newSrcType); - //System.out.println("New src type: " + newSrcType); - } - } - - /** - * User pressed Remove... beside the Source Type combo - */ - protected void rmvSrcTypePressed() { - if (sm.isSaveRequired()) { - ignoreEvents = true; - if ((editpane.verify() != null)) { - ignoreEvents = false; - return; // pending errors. Cannot save, so cannot process! - } - ignoreEvents = false; - //saveData(); - applyPressed(false); // defect 46379 - } - currentCompProfile.removeCompileType(currentCompType); - saveData(); - processProfileSelected(null); - } - - /** - * Handles events generated by controls on this page. - */ - public void widgetDefaultSelected(SelectionEvent e) { - } - - /** - * Save the given edited/new compile command and updates the gui list. - */ - protected void saveCompileCommand(SystemCompileCommand editedCompileCommand, boolean newMode, int selectionIndex) { - if (newMode) { - currentCompType.addCompileCommand(editedCompileCommand); - listView.add(editedCompileCommand.getLabel()); - saveData(); - //listView.select(listView.getItemCount()-1); - processSrcTypeSelected(listView.getItemCount() - 1); - } else { - saveData(); - //listView.select(selectionIndex); - //listView.setItem(selectionIndex, editedCompileCommand.getLabel()); - //processCommandsListSelected(); - processSrcTypeSelected(selectionIndex); - } - } - - /** - * Intercept of parent method so we can direct it to the Apply button versus the OK button (which we don't have). - */ - public void setPageComplete(boolean complete) { - // d45795 - if (applyButton != null) { - if (!complete) applyButton.setEnabled(false); - // else: we never enable it because the state machine does that anyway on any user-input change - } - } - - // --------------- - // HELPER METHODS - // --------------- - /** - * Returns the implementation of ISystemRemoteElement for the given - * object. Returns null if this object does not adaptable to this. - */ - protected ISystemRemoteElementAdapter getRemoteAdapter(Object o) { - ISystemRemoteElementAdapter adapter = null; - if (!(o instanceof IAdaptable)) - adapter = (ISystemRemoteElementAdapter) Platform.getAdapterManager().getAdapter(o, ISystemRemoteElementAdapter.class); - else - adapter = (ISystemRemoteElementAdapter) ((IAdaptable) o).getAdapter(ISystemRemoteElementAdapter.class); - return adapter; - } - - // ------------ - // List methods - // ------------ - /** - * Return true if currently selected item is "New" - */ - protected boolean isNewSelected() { - return (listView.getSelectionIndex() == 0); - } - - /** - * Return true if currently selected item is IBM- or vendor-supplied - */ - protected boolean isIBMSupplied() { - if (listView.getSelectionIndex() > 0) { - return !getCurrentlySelectedCompileCommand().isUserSupplied(); - } else - return false; - } - - /** - * Return currently selected list item - */ - protected String getCurrentSelection() { - if (listView.getSelectionCount() >= 1) - return listView.getSelection()[0]; - else - return null; - } - - /** - * Return the currently selected compile command - */ - protected SystemCompileCommand getCurrentlySelectedCompileCommand() { - int selIdx = listView.getSelectionIndex(); - if (selIdx > 0) // item 0 is "new" so skip it - return currentCompType.getCompileCommand(selIdx - 1); - else - return null; - } - - // ---------------------------------------------- - // EDIT PANE CHANGE LISTENER INTERFACE METHODS... - // ---------------------------------------------- - /** - * Callback method. The user has changed the compile command. It may or may not - * be valid. If not, the given message is non-null. If it is, and you want it, - * call getCompileCommand() in the edit pane. - */ - public void compileCommandChanged(SystemMessage message) { - if (message != null) - setErrorMessage(message); - else - clearErrorMessage(); - if (!ignoreEvents) // this is set on while verifying, indicating these are not real change events per se - { - sm.setChangesMade(); - } - setPageComplete(message == null); // d45795 - } - - // ------------------------------ - // CONTEXT MENU ACTION SUPPORT... - // ------------------------------ - /** - * Called when the context menu is about to open. - * Calls {@link #fillContextMenu(IMenuManager)} - */ - public void menuAboutToShow(IMenuManager menu) { - fillContextMenu(menu); - if (!menuListenerAdded) { - if (menu instanceof MenuManager) { - Menu m = ((MenuManager) menu).getMenu(); - if (m != null) { - menuListenerAdded = true; - SystemViewMenuListener ml = new SystemViewMenuListener(); - //ml.setShowToolTipText(true, wwDialog.getMessageLine()); does not work for some reason - m.addMenuListener(ml); - } - } - } - } - - /** - * This is method is called to populate the popup menu - */ - public void fillContextMenu(IMenuManager menu) { - String currentString = getCurrentSelection(); - IStructuredSelection selection = null; - if (currentString != null) selection = new StructuredSelection(currentString); - // Partition into groups... - createStandardGroups(menu); - ISystemAction action = null; - boolean isNewSelected = isNewSelected(); - //System.out.println("new selected? " + isNewSelected); - if ((selection != null) && !isNewSelected) { - action = getDeleteAction(selection); - menu.appendToGroup(action.getContextMenuGroup(), action); - action = getCopyAction(selection); - menu.appendToGroup(action.getContextMenuGroup(), action); - action = getMoveUpAction(selection); - menu.appendToGroup(action.getContextMenuGroup(), action); - action = getMoveDownAction(selection); - menu.appendToGroup(action.getContextMenuGroup(), action); - action = getRestoreAction(selection); - menu.appendToGroup(action.getContextMenuGroup(), action); - } - //if (!isNewSelected) - { - action = getPasteAction(selection); - menu.appendToGroup(action.getContextMenuGroup(), action); - } - } - - /** - * Creates the Systems plugin standard groups in a context menu. - */ - public void createStandardGroups(IMenuManager menu) { - if (!menu.isEmpty()) return; - menu.add(new Separator(ISystemContextMenuConstants.GROUP_REORGANIZE)); // rename,move,copy,delete,bookmark,refactoring - menu.add(new Separator(ISystemContextMenuConstants.GROUP_REORDER)); // move up, move down - menu.add(new Separator(ISystemContextMenuConstants.GROUP_CHANGE)); // restore - menu.add(new Separator(ISystemContextMenuConstants.GROUP_ADDITIONS)); // user or BP/ISV additions - } - - /** - * Get the delete action - */ - private SystemCompileCommandActionDelete getDeleteAction(ISelection selection) { - if (deleteAction == null) deleteAction = new SystemCompileCommandActionDelete(this); - deleteAction.setShell(getShell()); - deleteAction.setSelection(selection); - return deleteAction; - } - - /** - * Get the move up action - */ - private SystemCompileCommandActionMoveUp getMoveUpAction(ISelection selection) { - if (moveUpAction == null) moveUpAction = new SystemCompileCommandActionMoveUp(this); - moveUpAction.setShell(getShell()); - moveUpAction.setSelection(selection); - return moveUpAction; - } - - /** - * Get the move down action - */ - private SystemCompileCommandActionMoveDown getMoveDownAction(ISelection selection) { - if (moveDownAction == null) moveDownAction = new SystemCompileCommandActionMoveDown(this); - moveDownAction.setShell(getShell()); - moveDownAction.setSelection(selection); - return moveDownAction; - } - - /** - * Get the copy action - */ - private SystemCompileCommandActionCopy getCopyAction(ISelection selection) { - if (copyAction == null) copyAction = new SystemCompileCommandActionCopy(this); - copyAction.setShell(getShell()); - copyAction.setSelection(selection); - return copyAction; - } - - /** - * Get the paste action - */ - private SystemCompileCommandActionPaste getPasteAction(ISelection selection) { - if (pasteAction == null) pasteAction = new SystemCompileCommandActionPaste(this); - pasteAction.setShell(getShell()); - if (selection != null) pasteAction.setSelection(selection); - return pasteAction; - } - - /** - * Get the restore defaults action - */ - private SystemCompileCommandActionRestoreDefaults getRestoreAction(ISelection selection) { - if (restoreAction == null) restoreAction = new SystemCompileCommandActionRestoreDefaults(this); - restoreAction.setShell(getShell()); - if (selection != null) restoreAction.setSelection(selection); - return restoreAction; - } - - // ------------------------------------------------------------- - // CALLBACK METHODS FROM THE RIGHT CLICK CONTEXT MENU ACTIONS... - // ------------------------------------------------------------- - /** - * Decide if we can do the delete or not. - * Will decide the enabled state of the delete action. - */ - public boolean canDelete() { - return (sm.getMode() == ISystemEditPaneStates.MODE_EDIT) && !sm.areChangesPending() && !isNewSelected() && (listView.getSelectionIndex() != -1) && !isIBMSupplied(); - } - - /** - * Perform the delete action - */ - public void doDelete() { - int idx = listView.getSelectionIndex(); - SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_CONFIRM_DELETE); - SystemMessageDialog msgDlg = new SystemMessageDialog(getShell(), msg); - try { - if (msgDlg.openQuestion()) { - SystemCompileCommand deletedCmd = getCurrentlySelectedCompileCommand(); - currentCompType.removeCompileCommand(deletedCmd); - saveData(); - //traceTest = true; - listView.remove(idx); // remove item from list - if (idx <= (listView.getItemCount() - 1)) // can we select next item? - listView.select(idx); // select next item - else - listView.select(idx - 1); // select previous item - processCommandsListSelected(); - if (listView.getItemCount() == 1) //d47206 - rmvSrcTypeButton.setEnabled(true); - //traceTest = false; - // fire model change event in case any BP code is listening... - RSECorePlugin.getTheSystemRegistry().fireModelChangeEvent(ISystemModelChangeEvents.SYSTEM_RESOURCE_REMOVED, IUserActionsModelChangeEvents.SYSTEM_RESOURCETYPE_COMPILECMD, deletedCmd, null); - } - } catch (Exception exc) { - } - } - - /** - * Decide if we can do the move up or not. - * Will decide the enabled state of the move up action. - */ - public boolean canMoveUp() { - boolean can = (sm.getMode() == ISystemEditPaneStates.MODE_EDIT) && !sm.areChangesPending() && !isNewSelected() && (listView.getSelectionIndex() != -1); - if (can) { - int idx = listView.getSelectionIndex(); - can = (idx > 1); // skip new at index 0, and skip first actual compile command as it can't be moved up - } - return can; - } - - /** - * Perform the move up action - */ - public void doMoveUp() { - int idx = listView.getSelectionIndex(); - SystemCompileCommand currCmd = getCurrentlySelectedCompileCommand(); - if (currCmd == null) return; // better never happen! - // remove and add in model... - currentCompType.removeCompileCommand(currCmd); // remove item from model - currentCompType.insertCompileCommand(currCmd, idx - 2); // re-add one position up (remembering that the UI has one extra node at the top for "new") - saveData(); - // remove and add in UI... - listView.remove(idx); // remove item from UI list - listView.add(currCmd.getLabel(), idx - 1); // re-add one position up - listView.select(idx - 1); - listView.showSelection(); - processCommandsListSelected(); - // fire model change event in case any BP code is listening... - RSECorePlugin.getTheSystemRegistry().fireModelChangeEvent(ISystemModelChangeEvents.SYSTEM_RESOURCE_REORDERED, IUserActionsModelChangeEvents.SYSTEM_RESOURCETYPE_COMPILECMD, currCmd, null); - } - - /** - * Decide if we can do the move down or not. - * Will decide the enabled state of the move down action. - */ - public boolean canMoveDown() { - boolean can = (sm.getMode() == ISystemEditPaneStates.MODE_EDIT) && !sm.areChangesPending() && !isNewSelected() && (listView.getSelectionIndex() != -1); - if (can) { - int idx = listView.getSelectionIndex(); - can = (idx <= (listView.getItemCount() - 2)); // -1 is to be zero-based. Another -1 is to discount "New". - } - return can; - } - - /** - * Perform the move down action - */ - public void doMoveDown() { - int idx = listView.getSelectionIndex(); - SystemCompileCommand currCmd = getCurrentlySelectedCompileCommand(); - if (currCmd == null) return; // better never happen! - // remove and add in model... - currentCompType.removeCompileCommand(currCmd); // remove item from model - currentCompType.insertCompileCommand(currCmd, idx); // re-add one position down (remembering that the UI has one extra node at the top for "new") - saveData(); - // remove and add in UI... - listView.remove(idx); // remove item from UI list - listView.add(currCmd.getLabel(), idx + 1); // re-add one position down - listView.select(idx + 1); - listView.showSelection(); - processCommandsListSelected(); - // fire model change event in case any BP code is listening... - RSECorePlugin.getTheSystemRegistry().fireModelChangeEvent(ISystemModelChangeEvents.SYSTEM_RESOURCE_REORDERED, IUserActionsModelChangeEvents.SYSTEM_RESOURCETYPE_COMPILECMD, currCmd, null); - } - - /** - * Decide if we can do the copy or not. - * Will decide the enabled state of the copy action. - */ - public boolean canCopy() { - boolean can = (sm.getMode() == ISystemEditPaneStates.MODE_EDIT) && !sm.areChangesPending() && !isNewSelected() && (listView.getSelectionIndex() != -1); - return can; - } - - /** - * Actually do the copy of the current filter string to the clipboard. - */ - public void doCopy() { - if (clipboard == null) clipboard = new Clipboard(getShell().getDisplay()); - String selection = getCurrentSelection(); - TextTransfer transfer = TextTransfer.getInstance(); - clipboard.setContents(new Object[] { selection }, new Transfer[] { transfer }); - } - - /** - * Decide if we can do the paste or not. - * Will decide the enabled state of the copy action. - */ - public boolean canPaste() { - if (clipboard == null) return false; - TextTransfer textTransfer = TextTransfer.getInstance(); - String textData = (String) clipboard.getContents(textTransfer); - return ((textData != null) && (textData.length() > 0)); - } - - /** - * Actually do the copy of the current filter string to the clipboard. - * If an existing string is selected, it is pasted before it. Else. it is appended to the end of the list. - */ - public void doPaste() { - if (clipboard == null) return; - TextTransfer textTransfer = TextTransfer.getInstance(); - String textData = (String) clipboard.getContents(textTransfer); - SystemCompileCommand oldCmd = currentCompType.getCompileLabel(textData); - if (oldCmd == null) return; - SystemCompileCommand newCmd = (SystemCompileCommand) oldCmd.clone(); - newCmd.setLabel(getUniqueCloneLabel(oldCmd)); - String newCopy = newCmd.getLabel(); - int newLocation = listView.getSelectionIndex(); - if (newLocation <= 0) { - listView.add(newCopy); - listView.select(listView.getItemCount() - 1); - } else { - listView.add(newCopy, newLocation); - listView.select(newLocation); - } - listView.showSelection(); - currentCompType.insertCompileCommand(newCmd, listView.getSelectionIndex() - 1); // the "-1" is to discount for the "new" item at the top - saveData(); - processCommandsListSelected(); - // we don't need to do the following but for consistency with change user actions and types, we do - clipboard.dispose(); - clipboard = null; - // fire model change event in case any BP code is listening... - RSECorePlugin.getTheSystemRegistry().fireModelChangeEvent(ISystemModelChangeEvents.SYSTEM_RESOURCE_REMOVED, IUserActionsModelChangeEvents.SYSTEM_RESOURCETYPE_COMPILECMD, oldCmd, null); - } - - /** - * Return a new unique label to assign to a pastable compile command node clone - */ - private String getUniqueCloneLabel(SystemCompileCommand clonableCmd) { - String newName = SystemUDAResources.RESID_WWCOMPCMDS_COPY_NAME_1; - newName = SystemMessage.sub(newName, "%1", clonableCmd.getLabel()); //$NON-NLS-1$ - Vector existingNames = currentCompType.getExistingLabels(); - boolean nameInUse = (existingNames.indexOf(newName) >= 0); - int nbr = 2; - while (nameInUse) { - newName = SystemUDAResources.RESID_WWCOMPCMDS_COPY_NAME_N; - newName = SystemMessage.sub(newName, "%1", clonableCmd.getLabel()); //$NON-NLS-1$ - newName = SystemMessage.sub(newName, "%2", Integer.toString(nbr)); //$NON-NLS-1$ - nameInUse = (existingNames.indexOf(newName) >= 0); - ++nbr; - } - return newName; - } - - /** - * Decide if we can do the restore defaults or not. - * Will decide the enabled state of the restore defaults action. - */ - public boolean canRestore() { - boolean can = (sm.getMode() == ISystemEditPaneStates.MODE_EDIT) && !sm.areChangesPending() && !isNewSelected(); - if (can) { - SystemCompileCommand cmd = getCurrentlySelectedCompileCommand(); - if (cmd != null) - can = !cmd.isUserSupplied() && !cmd.getDefaultString().equals(cmd.getCurrentString()); - else - can = false; - } - return can; - } - - /** - * Perform the restore defaults action - */ - public void doRestore() { - SystemCompileCommand cmd = getCurrentlySelectedCompileCommand(); - cmd.setCurrentString(cmd.getDefaultString()); - saveData(); - processCommandsListSelected(); - } - - /** - * For asynch exec we defer some operations until other pending events are processed. - */ - public void run() { - if (restoreProfileComboSelection) - profileCombo.select(prevProfileComboSelection); - else - srcTypeCombo.select(prevSrcTypeComboSelection); - super.run(); - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/ISystemUDAConstants.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/ISystemUDAConstants.java deleted file mode 100644 index 56ad08372..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/ISystemUDAConstants.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.uda; - -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - * Xuan Chen (IBM) - [222263] Need to provide a PropertySet Adapter for System Team View (cleanup some use action stuff) - * Kevin Doyle (IBM) - [222829] MoveUp/Down Broken in Work with User Actions Dialog - *******************************************************************************/ -/** - * @author coulthar - * - * Constants used throughout the User Defined Action framework. - */ -public interface ISystemUDAConstants { - - public static final String USER_DEFINED_ACTION_PROPRERTY_SET_PREFIX = "UserActoins."; //$NON-NLS-1$ - - public static final String USER_DEFINED_ACTION_PROPRERTY_SET_Name = "User Actions"; //$NON-NLS-1$ - - static final String UDA_ROOT_ATTR = "uda_root"; //$NON-NLS-1$ - static final String FILETYPES_ROOT = "FileTypes"; //$NON-NLS-1$ - static final String ACTIONS_ROOT = "Actions"; //$NON-NLS-1$ - static final String ACTION_FILETYPES = "User Action File Types"; //$NON-NLS-1$ - - /** - * The name of the xml tag for domain tags. - * Domains are used to partition actions. - * Eg, you might have "Folder" and "File" domains - * or for iSeries "Object" and "Member" domains - */ - public static final String XE_DOMAIN = "Domain"; //$NON-NLS-1$ - - /** - * The name of the xml attribute of domain tags which - * identifies the domain type. Its values will be - * an untranslated name like "Object" or "Folder". - */ - public static final String XE_DOMTYPE = "DomainType"; //$NON-NLS-1$ - - /** - * The name of the xml attribute of domain tags which - * identifies the domain name. Its values will be - * a translated name like "Object" or "Folder". - */ - public static final String XE_DOMNAME = "name"; //$NON-NLS-1$ - - /** - * The name of the attribute we consistently use to store an element's name - */ - public static final String NAME_ATTR = "name"; //$NON-NLS-1$ - - /** - * The type of the attribute we consistently use to store an element's name - */ - public static final String TYPE_ATTR = "type"; //$NON-NLS-1$ - - /** - * The name of the attribute we consistently use to store an element's original IBM-supplied name - */ - public static final String ORIGINAL_NAME_ATTR = "OriginalName"; //$NON-NLS-1$ - - /** - * The position in the list of other user actions a user action should show up in - */ - public static final String ORDER_ATTR = "Order"; //$NON-NLS-1$ - - /** - * The name of the attribute we consistently use to store a release number - */ - public static final String RELEASE_ATTR = "release"; //$NON-NLS-1$ - - public static final String RELEASE_VALUE = "7.5"; //$NON-NLS-1$ -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/ISystemUDAEditPaneHoster.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/ISystemUDAEditPaneHoster.java deleted file mode 100644 index ea7f0e470..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/ISystemUDAEditPaneHoster.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 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.ui.uda; - -//import org.eclipse.jface.viewers.ISelection; -//import org.eclipse.jface.viewers.IStructuredSelection; -//import org.eclipse.jface.viewers.StructuredSelection; -//import org.eclipse.jface.viewers.ISelection; -import org.eclipse.rse.ui.messages.ISystemMessageLine; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; - -/** - * The interface that must be implemented for any dialog or property page that wants to - * host a user action edit pane. - */ -public interface ISystemUDAEditPaneHoster extends ISystemMessageLine { - /** - * Get the shell for this dialog or property page - */ - public Shell getShell(); - - /** - * Identify that the page/dialog is complete - */ - public void setPageComplete(boolean complete); - - /** - * Set the help for the given control - */ - public void setHelp(Control c, String id); -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/ISystemUDSelectTypeListener.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/ISystemUDSelectTypeListener.java deleted file mode 100644 index 28d42ab28..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/ISystemUDSelectTypeListener.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.uda; - -/******************************************************************************* - * Copyright (c) 2002, 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 - *******************************************************************************/ -/** - * @author coulthar - * - * This is an interface for listening for changes made to the - * user-selected list of types for an action. - * Used by the SystemUDSelectTypesForm class. - */ -public interface ISystemUDSelectTypeListener { - /** - * The user has added or removed a type. - * Call getTypes() on given form to get the new list. - */ - public void selectedTypeListChanged(SystemUDSelectTypesForm form); - - /** - * The user has edited the master list of types. It needs to be refreshed. - * You must call setMasterTypes() to update the form's master type list - */ - public void masterTypeListChanged(SystemUDSelectTypesForm form); -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/ISystemUDTreeView.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/ISystemUDTreeView.java deleted file mode 100644 index bd42b13fe..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/ISystemUDTreeView.java +++ /dev/null @@ -1,130 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 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 - *******************************************************************************/ -/* - * Created on Dec 5, 2003 - * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -package org.eclipse.rse.internal.useractions.ui.uda; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.TreeItem; - -/** - * @author coulthar - * - * To change the template for this generated type comment go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -public interface ISystemUDTreeView { - /** - * Expand the non-new domain (parent) nodes - */ - public abstract void expandDomainNodes(); - - /** - * Expand the given domain (parent) node, named by its - * translatable name. - */ - public abstract void expandDomainNode(String displayName); - - /** - * Convenience method for returning the shell of this viewer. - */ - public abstract Shell getShell(); - - /** - * Return the action or type manager - */ - public abstract SystemUDBaseManager getDocumentManager(); - - /** - * Get the selected action or type name. - * Returns "" if nothing selected - */ - public abstract String getSelectedElementName(); - - /** - * Get the selected action or type domain. - * Returns -1 if nothing selected or domains not supported - */ - public abstract int getSelectedElementDomain(); - - /** - * Return true if currently selected element is "ALL" - */ - public boolean isElementAllSelected(); - - // ------------------------------------ - public abstract SystemXMLElementWrapper getSelectedElement(); - - /** - * Select the given type - */ - public abstract void selectElement(SystemXMLElementWrapper element); - - /** - * Find the parent tree item of the given type. - * If it is not currently shown in the tree, or there is no parent, returns null. - */ - public abstract TreeItem findParentItem(SystemXMLElementWrapper element); - - /** - * Refresh the parent of the given action. - * That is, find the parent and refresh the children. - * If the parent is not found, assume it is because it is new too, - * so refresh the whole tree. - */ - public abstract void refreshElementParent(SystemXMLElementWrapper element); - - /** - * Returns the tree item of the first selected object. - */ - public abstract TreeItem getSelectedTreeItem(); - - /** - * Returns the tree item of the sibling before the first selected object. - */ - public abstract TreeItem getSelectedPreviousTreeItem(); - - /** - * Returns the tree item of the sibling after the first selected object. - */ - public abstract TreeItem getSelectedNextTreeItem(); - - /** - * Returns the tree item of the sibling two after the first selected object. - */ - public abstract TreeItem getSelectedNextNextTreeItem(); - - /** - * Return true if currently selected element is vendor supplied - */ - public boolean isSelectionVendorSupplied(); - - /** - * Return the vendor that is responsible for pre-supplying this existing type, - * or null if not applicable. - */ - public String getVendorOfSelection(); - - /** - * Set the selection - */ - public void setSelection(ISelection selection); - - /** - * Refresh given element - */ - public void refresh(Object element); -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/ISystemUDTypeEditPaneTypesSelector.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/ISystemUDTypeEditPaneTypesSelector.java deleted file mode 100644 index 9ca68a1fa..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/ISystemUDTypeEditPaneTypesSelector.java +++ /dev/null @@ -1,108 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.uda; - -/******************************************************************************* - * Copyright (c) 2002, 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 - *******************************************************************************/ -import org.eclipse.rse.services.clientserver.messages.SystemMessage; -import org.eclipse.rse.ui.messages.ISystemMessageLine; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.widgets.Control; - -/** - * @author coulthar - * - * Within the Work With Files Types dialog is an edit pane - * ({@link org.eclipse.rse.internal.useractions.ui.uda.SystemUDTypeEditPane}) - * that contains an entry field for the name, and then one or - * more widgets that prompt for the file types that constitute - * this named type. - * <p> - * This is interface abstracts out the minimal requirements for that - * set of widgets, so that it can be pluggable by subsystems wishing - * to supply customer widgets. These could be as simple as an entry - * field or as complex as a checkbox viewer with add and remove - * buttons. As far as the edit pane class is concerned, it need only - * be able to set the inputs, get the outputs and listen for changes. - * - */ -public interface ISystemUDTypeEditPaneTypesSelector { - /** - * Set domain. - * The edit pane may possibly appear differently, depending on the domain. - * When the domain changes (either in "new" or "edit" mode) this method is called. - */ - public void setDomain(int domain); - - /** - * Set the msg line in case this composite widget needs to issue an error msg - */ - public void setMessageLine(ISystemMessageLine msgLine); - - /** - * Initialize the types. These are stored as a single string using - * a subsystem-decidable delimiter character. This is called when - * entering "edit" mode. - */ - public void setTypes(String types); - - /** - * Clear the types. That is, make sure none are selected. This is - * called when entering "new" mode. - */ - public void clearTypes(); - - /** - * Retrieve the types as a single string. The delimiter used is up to - * the implementor, as long as it knows how to parse and assemble the - * types list as a single string. - */ - public String getTypes(); - - /** - * Allow the edit pane (or any consumer) to be informed as - * changes are made to the list. When events are fired, the consumer - * will call getTypes() to get the new list. - */ - public void addModifyListener(ModifyListener listener); - - /** - * Allow the edit pane (or any consumer) to stop listening as - * changes are made to the list. - */ - public void removeModifyListener(ModifyListener listener); - - /** - * Validate input, and return the error message if an error is found. - * This is called by the consumer upon receipt of a modify event, to - * show any error messages and to know if there are errors pending or - * not. - */ - public SystemMessage validate(); - - /** - * Return the primary input-capable control. - * Used to set focus, among other things. - */ - public Control getControl(); - - /** - * Enable or disable the input-capability of the constituent controls - */ - public void setEnabled(boolean enable); - - /** - * We want to disable editing of IBM or vendor-supplied - * types, so when one of these is selected, this method is - * called to enter non-editable mode. - * @param editable Whether to disable editing of this type or not - * @param vendor When disabling, it contains the name of the vendor for substitution purposes - */ - public void setEditable(boolean editable, String vendor); -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/ISystemUDWorkWithDialog.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/ISystemUDWorkWithDialog.java deleted file mode 100644 index cfbd86381..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/ISystemUDWorkWithDialog.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.uda; - -/******************************************************************************* - * Copyright (c) 2002, 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 - *******************************************************************************/ -import org.eclipse.rse.ui.messages.ISystemMessageLine; - -/** - * A common interface that the action, and types, edit panes for user actions - * implement. - */ -public interface ISystemUDWorkWithDialog { - /** - * Decide if we can do the delete or not. - * Will decide the enabled state of the delete action. - */ - public boolean canDelete(Object selectedObject); - - /** - * Decide if we can do the move up or not. - * Will decide the enabled state of the move up action. - */ - public boolean canMoveUp(Object selectedObject); - - /** - * Decide if we can do the move down or not. - * Will decide the enabled state of the move down action. - */ - public boolean canMoveDown(Object selectedObject); - - /** - * Decide if we can do the copy or not. - * Will decide the enabled state of the copy action. - */ - public boolean canCopy(Object selectedObject); - - /** - * Return the message line - */ - public ISystemMessageLine getMessageLine(); - - /** - * Return true if changes are pending in the edit pane - */ - public boolean areChangesPending(); - - /** - * Process the apply button - */ - public void processApply(); - - /** - * Process the revert button - */ - public void processRevert(); -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/ISystemXMLElementWrapperFactory.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/ISystemXMLElementWrapperFactory.java deleted file mode 100644 index ad9e2d5fe..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/ISystemXMLElementWrapperFactory.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.uda; - -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - *******************************************************************************/ -import org.eclipse.rse.core.model.IPropertySet; -import org.eclipse.rse.core.model.ISystemProfile; - -/** - * @author coulthar - * - * Classes that implement this know how to create the approprate - * subclass of SystemXMLElementWrapper - */ -public interface ISystemXMLElementWrapperFactory { - /** - * Given an xml element node, create an instance of the appropriate - * subclass of SystemXMLElementWrapper to represent it. - */ - public SystemXMLElementWrapper createElementWrapper(IPropertySet xmlElementToWrap, ISystemProfile profile, int domain); - - /** - * Return the tag name for these elements. Will be "Action" or "Type" - */ - public String getTagName(); -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemPromptUDADialog.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemPromptUDADialog.java deleted file mode 100644 index 4b8edc28f..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemPromptUDADialog.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.uda; - -/******************************************************************************* - * Copyright (c) 2002, 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 - *******************************************************************************/ -import org.eclipse.rse.internal.useractions.ui.SystemPromptCommandDialog; -import org.eclipse.swt.widgets.Shell; - -/** - * Dialog used when running a user action, which has the prompt option specified. - * This allows the user to edit the resolved command, and the result is placed - * in the output object. - */ -public class SystemPromptUDADialog extends SystemPromptCommandDialog { - /** - * Constructor. - * @param shell The parent window hosting this dialog - * @param command The resolved command from the user action - */ - public SystemPromptUDADialog(Shell shell, String command) { - super(shell, command, SystemUDAResources.RESID_UDA_PROMPTCMD_TITLE); - //setHelp(RSEUIPlugin.HELPPREFIX+"drnp0000"); - } - - /** - * Translated text configuration method. - * Override to return OK button label if you don't want the default - */ - protected String getOKButtonLabel() { - return SystemUDAResources.RESID_UDA_PROMPTCMD_OKBUTTON_LABEL; - } - - /** - * Translated text configuration method. - * Override to return OK button tooltip if you don't want the default - */ - protected String getOKButtonToolTipText() { - return SystemUDAResources.RESID_UDA_PROMPTCMD_OKBUTTON_TOOLTIP; - } - - /** - * Translated text configuration method. - * Override to return Cancel button tooltip if you don't want the default - */ - protected String getCancelButtonToolTipText() { - return SystemUDAResources.RESID_UDA_PROMPTCMD_CANCELBUTTON_TOOLTIP; - } - - /** - * Translated text configuration method. - * Override to return verbage message if you don't want the default - */ - protected String getVerbage() { - return SystemUDAResources.RESID_UDA_PROMPTCMD_VERBAGE_LABEL; - } - - /** - * Translated text configuration method. - * Override to return label for the command prompt, if you don't want the default - */ - protected String getPromptLabel() { - return SystemUDAResources.RESID_UDA_PROMPTCMD_PROMPT_LABEL; - } - - /** - * Translated text configuration method. - * Override to return tooltip text for the command prompt, if you don't want the default - */ - protected String getPromptToolTipText() { - return SystemUDAResources.RESID_UDA_PROMPTCMD_PROMPT_TOOLTIP; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDACascadeAction.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDACascadeAction.java deleted file mode 100644 index 33fe921e1..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDACascadeAction.java +++ /dev/null @@ -1,102 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry - *******************************************************************************/ - -package org.eclipse.rse.internal.useractions.ui.uda; - -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.rse.core.RSECorePlugin; -import org.eclipse.rse.core.model.ISystemProfile; -import org.eclipse.rse.internal.useractions.ui.uda.actions.SystemWorkWithUDAsAction; -import org.eclipse.rse.ui.ISystemContextMenuConstants; -import org.eclipse.rse.ui.SystemPreferencesManager; -import org.eclipse.rse.ui.actions.SystemBaseDummyAction; -import org.eclipse.rse.ui.actions.SystemBaseSubMenuAction; -import org.eclipse.swt.widgets.Shell; - -/** - * A cascading menu action for "User actions->" - */ -public class SystemUDACascadeAction extends SystemBaseSubMenuAction implements IMenuListener { - private SystemUDActionSubsystem udsubsystem; - //private IStructuredSelection selection; - private SystemWorkWithUDAsAction wwAction; - - /** - * Constructor for the "User Actions" menu item. - * Expansion will either list profiles, or actions, depending on preferences setting - */ - public SystemUDACascadeAction(SystemUDActionSubsystem udsubsystem, IStructuredSelection selection) { - super(SystemUDAResources.ACTION_UDA_CASCADE_LABEL, SystemUDAResources.ACTION_UDA_CASCADE_TOOLTIP, null); - this.udsubsystem = udsubsystem; - super.setSelection(selection); - setCreateMenuEachTime(false); - setPopulateMenuEachTime(true); - } - - /** - * This is called by the parent class, in its getSubMenu() method. - * That in turn is called when this menu is added to its parent menu. - */ - public IMenuManager populateSubMenu(IMenuManager menu) { - menu.addMenuListener(this); - menu.setRemoveAllWhenShown(true); - //menu.setEnabled(true); - menu.add(new SystemBaseDummyAction()); - //((SystemSubMenuManager)menu).setTracing(true); - return menu; - } - - /** - * Called when submenu is about to show, by JFace. - * It is part of the IMenuListener interface, and we are called - * because we registered ourself as a listener in our populateSubMenu - * method. - */ - public void menuAboutToShow(IMenuManager ourSubMenu) { - //System.out.println("UDA submenu AboutToShow():"); - Shell shell = getShell(); - // is cascading-by-profile preference turned off? - //System.out.println("Preference setting: " + SystemPreferencesGlobal.getGlobalSystemPreferences().getCascadeUserActions()); - if (!SystemPreferencesManager.getCascadeUserActions()) { - udsubsystem.addUserActions(ourSubMenu, getSelection(), null, shell); - } - // is cascading-by-profile preference turned on? - else { - ISystemProfile[] activeProfiles = RSECorePlugin.getTheSystemRegistry().getActiveSystemProfiles(); - for (int idx = 0; idx < activeProfiles.length; idx++) { - SystemBaseSubMenuAction profileAction = new SystemUDACascadeByProfileAction(shell, udsubsystem, getSelection(), activeProfiles[idx]); - ourSubMenu.add(profileAction.getSubMenu()); - } - } - ourSubMenu.add(new Separator(ISystemContextMenuConstants.GROUP_WORKWITH)); - if (wwAction == null) { - wwAction = new SystemWorkWithUDAsAction(shell, udsubsystem.getSubsystem(), udsubsystem); - wwAction.setText(SystemUDAResources.RESID_WORKWITH_UDAS_ACTION_LABEL); - wwAction.setToolTipText(SystemUDAResources.RESID_WORKWITH_UDAS_ACTION_TOOLTIP); - wwAction.allowOnMultipleSelection(true); - } - ourSubMenu.appendToGroup(ISystemContextMenuConstants.GROUP_WORKWITH, wwAction); - } - - /** - * Override for debugging - */ - public void setInputs(Shell shell, Viewer v, ISelection selection) { - super.setInputs(shell, v, selection); - //System.out.println("Inside setInputs for SystemCascadeAction"); - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDACascadeByProfileAction.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDACascadeByProfileAction.java deleted file mode 100644 index a6680033d..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDACascadeByProfileAction.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.uda; - -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - *******************************************************************************/ -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.rse.core.model.ISystemProfile; -import org.eclipse.rse.internal.ui.view.SystemViewMenuListener; -import org.eclipse.rse.ui.ISystemIconConstants; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.actions.ISystemViewMenuListener; -import org.eclipse.rse.ui.actions.SystemBaseDummyAction; -import org.eclipse.rse.ui.actions.SystemBaseSubMenuAction; -import org.eclipse.swt.widgets.Shell; - -/** - * A cascading submenu action for "User Actions->". - * This is after the first cascade, which lists profiles. - * Here, for that profile, we list actions - */ -public class SystemUDACascadeByProfileAction extends SystemBaseSubMenuAction implements IMenuListener { - private ISystemProfile profile; - private SystemUDActionSubsystem udsubsystem; - - //private IStructuredSelection selection; - /** - * Constructor. - */ - public SystemUDACascadeByProfileAction(Shell shell, SystemUDActionSubsystem udss, IStructuredSelection selection, ISystemProfile profile) { - super(profile.getName(), RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_PROFILE_ID), shell); - this.profile = profile; - this.udsubsystem = udss; - super.setSelection(selection); - setCreateMenuEachTime(false); - setPopulateMenuEachTime(true); - //System.out.println("Inside ctor for SystemUDACascadeByProfileAction"); - } - - /** - * @see org.eclipse.rse.ui.actions.SystemBaseSubMenuAction#getSubMenu() - */ - public IMenuManager populateSubMenu(IMenuManager menu) { - //System.out.println("Inside populateSubMenu for SystemUDACascadeByProfileAction"); - menu.addMenuListener(this); - menu.setRemoveAllWhenShown(true); - //menu.setEnabled(true); - menu.add(new SystemBaseDummyAction()); - return menu; - } - - /** - * Called when submenu is about to show. Called because we - * implement IMenuListener, and registered ourself for this event. - */ - public void menuAboutToShow(IMenuManager ourSubMenu) { - //System.out.println("Inside menuAboutToShow for SystemUDACascadeByProfileAction"); - Shell shell = getShell(); - udsubsystem.addUserActions(ourSubMenu, getSelection(), profile, shell); - } - - /** - * Overridable method from parent that instantiates the menu listener who job is to add mnemonics. - * @param setMnemonicsOnlyOnce true if the menu is static and so mnemonics need only be set once. False if it is dynamic - */ - protected ISystemViewMenuListener createMnemonicsListener(boolean setMnemonicsOnlyOnce) { - return new SystemViewMenuListener(false); // our menu is re-built dynamically each time - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDAFileTypesForName.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDAFileTypesForName.java deleted file mode 100644 index 56633aa66..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDAFileTypesForName.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.uda; - -/******************************************************************************* - * Copyright (c) 2002, 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 - *******************************************************************************/ -public class SystemUDAFileTypesForName { - String name; - String types; - - public SystemUDAFileTypesForName(String p_name, String p_types) { - name = p_name; - types = p_types; - } - - public String getName() { - return name; - } - - public String getTypes() { - return types; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDAResolvedTypes.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDAResolvedTypes.java deleted file mode 100644 index cf1943c46..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDAResolvedTypes.java +++ /dev/null @@ -1,135 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.uda; - -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - * David Dykstal (IBM) - [232106] - NPE when resolving types - *******************************************************************************/ -import java.util.Vector; - -/** - * - */ -public class SystemUDAResolvedTypes { - protected Vector previousTypes = null; - protected Vector[] UDAFileTypesForNameByDomain; - protected Vector UDAFileTypesForNameNoDomain; - - //private char delimiter = ' '; - // I have done a bit of work in here, but I really have not analyzed this logic - // to see what its doing, and if its doing it all correctly. Phil. - /** - * Constructor when using blank as the type delimiter - */ - public SystemUDAResolvedTypes() { - previousTypes = null; - } - - /* - * Constructor when specifying your own character as the type delimiter - * - public UDAResolvedTypes(char delimiter) - { - previousTypes = null; - this.delimiter = delimiter; - }*/ - /** - * - */ - protected void addTypesToVector(Vector v, Object[] objElems) { - for (int i = 0; i < objElems.length; i++) { - SystemUDTypeElement typeElem = (SystemUDTypeElement) objElems[i]; - String name = typeElem.toString(); - resolveType(name, v, objElems); - } - } - - /** - * - */ - protected String resolveTypes(String types, Vector v, Object[] objElems) { - int i = types.indexOf("<"); //$NON-NLS-1$ - if (i < 0) return types; - int j = types.indexOf(">"); //$NON-NLS-1$ - if (i >= j) return types; - String type = types.substring(i + 1, j); - String resolvedType = resolveType(type, v, objElems); - return types.substring(0, i) + " " + resolvedType + " " + resolveTypes(types.substring(j + 1), v, objElems); //$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * - */ - protected String resolveType(String type, Vector v, Object[] objElems) { - if (previousTypes.contains(type)) return ""; //$NON-NLS-1$ - String resolvedTypes = resolveType(type, v); - if (resolvedTypes != null) return resolvedTypes; - for (int i = 0; i < objElems.length; i++) { - SystemUDTypeElement typeElem = (SystemUDTypeElement) objElems[i]; - if (type.equals(typeElem.toString())) { - previousTypes.addElement(type); - String types = typeElem.getTypes(); - if (types != null) { - resolvedTypes = resolveTypes(types, v, objElems); - } - previousTypes.remove(type); - v.addElement(new SystemUDAFileTypesForName(type, resolvedTypes)); - return resolvedTypes; - } - } - return ""; //$NON-NLS-1$ - } - - /** - * - */ - protected String resolveType(String type, Vector v) { - for (int i = 0; i < v.size(); i++) { - SystemUDAFileTypesForName typesForName = (SystemUDAFileTypesForName) v.elementAt(i); - if (type.equals(typesForName.getName())) return typesForName.getTypes(); - } - return null; - } - - /** - * Given a named type, return all the types that this typed name represents, - * concatenated as a single string. - * @param name - the named type to be resolved - * @param domain - the domain, expressed in its integer form - */ - public String getFileTypesForTypeName(String name, int domain, SystemUDTypeManager typeMgr) { - Vector typesVector = null; - boolean supportsDomains = typeMgr.getActionSubSystem().supportsDomains(); - boolean needToPopulate = false; - if (supportsDomains) { - if (UDAFileTypesForNameByDomain == null) { - int nbrDomains = typeMgr.getActionSubSystem().getMaximumDomain() + 1; - UDAFileTypesForNameByDomain = new Vector[nbrDomains]; - } - typesVector = UDAFileTypesForNameByDomain[domain]; - if (typesVector == null) { - typesVector = new Vector(); - UDAFileTypesForNameByDomain[domain] = typesVector; - needToPopulate = true; - } - } else { - typesVector = UDAFileTypesForNameNoDomain; - if (typesVector == null) { - typesVector = new Vector(); - UDAFileTypesForNameNoDomain = typesVector; - needToPopulate = true; - } - } - if (needToPopulate) { - previousTypes = new Vector(); // what's this for? - addTypesToVector(typesVector, typeMgr.getTypes(null, domain)); - } - return resolveType(name, typesVector); - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDAResources.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDAResources.java deleted file mode 100644 index c0d9f7339..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDAResources.java +++ /dev/null @@ -1,267 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2008 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.ui.uda; - -import org.eclipse.osgi.util.NLS; - -public class SystemUDAResources extends NLS { - private static String BUNDLE_NAME = "org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources";//$NON-NLS-1$ - // WORK WITH USER DEFINED ACTIONS DIALOG... - public static String RESID_WORKWITH_UDAS_TITLE; - public static String RESID_WORKWITH_UDAS_ACTION_LABEL; - public static String RESID_WORKWITH_UDAS_ACTION_TOOLTIP; - public static String RESID_UDA_TREE_TIP; - public static String RESID_UDA_PROFILE_LABEL; - public static String RESID_UDA_PROFILE_TOOLTIP; - public static String RESID_UDA_APPLY_BUTTON_LABEL; - public static String RESID_UDA_APPLY_BUTTON_TOOLTIP; - public static String RESID_UDA_RESET_BUTTON_LABEL; - public static String RESID_UDA_RESET_BUTTON_TOOLTIP; - public static String RESID_UDA_REVERT_BUTTON_LABEL; - public static String RESID_UDA_REVERT_BUTTON_TOOLTIP; - public static String RESID_UDA_DELETE_BUTTON_LABEL; - public static String RESID_UDA_DELETE_BUTTON_TOOLTIP; - public static String RESID_UDA_COPY_BUTTON_LABEL; - public static String RESID_UDA_COPY_BUTTON_TOOLTIP; - public static String RESID_UDA_COPY_NAME_1; - public static String RESID_UDA_COPY_NAME_N; - public static String RESID_UDA_IBM_VERBAGE; - public static String RESID_UDA_VENDOR_VERBAGE; - // WORK WITH USER DEFINED ACTIONS NEW/EDIT PANE ... - public static String RESID_UDA_NAME_LABEL; - public static String RESID_UDA_NAME_TOOLTIP; - public static String RESID_UDA_COMMENT_LABEL; - public static String RESID_UDA_COMMENT_TOOLTIP; - public static String RESID_UDA_COMMAND_LABEL; - public static String RESID_UDA_COMMAND_TOOLTIP; - public static String RESID_UDA_INSERTVAR_BUTTON_LABEL; - public static String RESID_UDA_INSERTVAR_BUTTON_TOOLTIP; - public static String RESID_UDA_EDIT_BUTTON_LABEL; - public static String RESID_UDA_EDIT_BUTTON_TOOLTIP; - public static String RESID_UDA_OPTION_PROMPT_LABEL; - public static String RESID_UDA_OPTION_PROMPT_TOOLTIP; - public static String RESID_UDA_OPTION_SHOW_LABEL; - public static String RESID_UDA_OPTION_SHOW_TOOLTIP; - public static String RESID_UDA_OPTION_REFRESH_LABEL; - public static String RESID_UDA_OPTION_REFRESH_TOOLTIP; - public static String RESID_UDA_OPTION_COLLECT_LABEL; - public static String RESID_UDA_OPTION_COLLECT_TOOLTIP; - public static String RESID_UDA_OPTION_SINGLESEL_LABEL; - public static String RESID_UDA_OPTION_SINGLESEL_TOOLTIP; - public static String RESID_UDA_OPTION_REMOTE_LABEL; - public static String RESID_UDA_OPTION_REMOTE_TOOLTIP; - public static String RESID_UDA_TYPE_LIST_LABEL; - public static String RESID_UDA_TYPE_LIST_TOOLTIP; - public static String RESID_UDA_TYPE_LIST_MASTER_LABEL; - public static String RESID_UDA_TYPE_LIST_MASTER_TOOLTIP; - public static String RESID_UDA_TYPE_LIST_SELECTED_LABEL; - public static String RESID_UDA_TYPE_LIST_SELECTED_TOOLTIP; - public static String RESID_UDA_TYPE_EDIT_BUTTON_LABEL; - public static String RESID_UDA_TYPE_EDIT_BUTTON_TOOLTIP; - public static String RESID_UDA_TYPE_ADD_BUTTON_LABEL; - public static String RESID_UDA_TYPE_ADD_BUTTON_TOOLTIP; - public static String RESID_UDA_TYPE_RMV_BUTTON_LABEL; - public static String RESID_UDA_TYPE_RMV_BUTTON_TOOLTIP; - // PROMPT USER DEFINED ACTION COMMAND DIALOG... - public static String RESID_UDA_PROMPTCMD_TITLE; - public static String RESID_UDA_PROMPTCMD_VERBAGE_LABEL; - public static String RESID_UDA_PROMPTCMD_PROMPT_LABEL; - public static String RESID_UDA_PROMPTCMD_PROMPT_TOOLTIP; - public static String RESID_UDA_PROMPTCMD_OKBUTTON_LABEL; - public static String RESID_UDA_PROMPTCMD_OKBUTTON_TOOLTIP; - public static String RESID_UDA_PROMPTCMD_CANCELBUTTON_TOOLTIP; - // COMMON USER DEFINED ACTION SUBSTITUTION VARIABLES SUPPORT... - public static String RESID_UDA_SUBVAR_ACTION_NAME; - public static String RESID_UDA_SUBVAR_CONNECTION_NAME; - public static String RESID_UDA_SUBVAR_LOCAL_HOSTNAME; - public static String RESID_UDA_SUBVAR_LOCAL_IP; - public static String RESID_UDA_SUBVAR_USER_ID; - public static String RESID_UDA_SUBVAR_SYSTEM_TEMPDIR; - public static String RESID_UDA_SUBVAR_SYSTEM_HOMEDIR; - public static String RESID_UDA_SUBVAR_SYSTEM_HOSTNAME; - public static String RESID_UDA_SUBVAR_SYSTEM_PATHSEP; - public static String RESID_UDA_SUBVAR_SYSTEM_FILESEP; - // Resource type shown in property sheet / delete confirmation dialog for - // UDAs - public static String RESID_UDA_RESOURCE_TYPE; - // WORK WITH USER DEFINED TYPE DIALOG... - public static String RESID_WORKWITH_UDT_TITLE; - public static String RESID_UDT_TREE_TIP; - public static String RESID_UDT_NAME_LABEL; - public static String RESID_UDT_NAME_TOOLTIP; - public static String RESID_UDT_TYPES_LABEL; - public static String RESID_UDT_TYPES_TOOLTIP; - public static String RESID_UDT_TYPESLIST_LABEL_LABEL; - public static String RESID_UDT_TYPESLIST_LABEL_TOOLTIP; - public static String RESID_UDT_DELETE_BUTTON_LABEL; - public static String RESID_UDT_DELETE_BUTTON_TOOLTIP; - public static String RESID_UDT_IBM_VERBAGE; - public static String RESID_UDT_VENDOR_VERBAGE; - // Resource type shown in property sheet / delete confirmation dialog for - // UDTs - public static String RESID_UDT_RESOURCE_TYPE; - // UNIVERSAL FILE SYSTEM USER DEFINED ACTION SUPPORT... - public static String RESID_UDA_FILES_DOMAIN_FOLDER; - public static String RESID_UDA_FILES_DOMAIN_FILE; - public static String RESID_UDA_FILES_DOMAIN_NEWFOLDER; - public static String RESID_UDA_FILES_DOMAIN_NEWFILE; - public static String RESID_UDA_FILES_NEWNODE_LABEL; - // UNIVERSAL FILE SYSTEM USER DEFINED TYPE SUPPORT... - public static String RESID_UDT_FILES_DOMAIN_NEWFOLDER; - public static String RESID_UDT_FILES_DOMAIN_NEWFILE; - public static String RESID_UDT_FILES_TYPESGROUP_LABEL; - public static String RESID_UDT_FILES_TYPESGROUP_TOOLTIP; - public static String RESID_UDT_FILES_DEFINEDTYPES_LABEL; - public static String RESID_UDT_FILES_DEFINEDTYPES_TOOLTIP; - public static String RESID_UDT_FILES_USERTYPES_LABEL; - public static String RESID_UDT_FILES_USERTYPES_TOOLTIP; - // UNIVERSAL RUN COMMAND DIALOG - public static String RESID_UCMD_RUN_IN_NEW_SHELL_LABEL; - public static String RESID_UCMD_RUN_IN_NEW_SHELL_TOOLTIP; - public static String RESID_UCMD_RUN_COMMAND_LABEL; - public static String RESID_UCMD_COMMAND_LABEL; - public static String RESID_UCMD_COMMAND_TOOLTIP; - public static String RESID_UCMD_COMAMND_SHELL_LABEL; - // UNIVERSAL FILE SYSTEM UDA SUPPORT... - public static String RESID_UDA_FILES_SUBVAR_RESOURCE_DATE; - public static String RESID_UDA_FILES_SUBVAR_RESOURCE_NAME; - public static String RESID_UDA_FILES_SUBVAR_RESOURCE_PATH; - public static String RESID_UDA_FILES_SUBVAR_RESOURCE_NAME_ROOT; - public static String RESID_UDA_FILES_SUBVAR_RESOURCE_NAME_EXT; - public static String RESID_UDA_FILES_SUBVAR_RESOURCE_PATH_ROOT; - public static String RESID_UDA_FILES_SUBVAR_RESOURCE_PATH_DRIVE; - public static String RESID_UDA_FILES_SUBVAR_CONTAINER_NAME; - public static String RESID_UDA_FILES_SUBVAR_CONTAINER_PATH; - // UNIVERSAL FILE SYSTEM COMPILE COMMAND SUPPORT... - public static String RESID_COMPILE_FILES_SUBVAR_CONNECTION_NAME; - public static String RESID_COMPILE_FILES_SUBVAR_LOCAL_HOSTNAME; - public static String RESID_COMPILE_FILES_SUBVAR_LOCAL_IP; - public static String RESID_COMPILE_FILES_SUBVAR_USER_ID; - public static String RESID_COMPILE_FILES_SUBVAR_SYSTEM_TEMPDIR; - public static String RESID_COMPILE_FILES_SUBVAR_SYSTEM_HOMEDIR; - public static String RESID_COMPILE_FILES_SUBVAR_SYSTEM_HOSTNAME; - public static String RESID_COMPILE_FILES_SUBVAR_SYSTEM_PATHSEP; - public static String RESID_COMPILE_FILES_SUBVAR_SYSTEM_FILESEP; - public static String RESID_COMPILE_FILES_SUBVAR_RESOURCE_DATE; - public static String RESID_COMPILE_FILES_SUBVAR_RESOURCE_NAME; - public static String RESID_COMPILE_FILES_SUBVAR_RESOURCE_PATH; - public static String RESID_COMPILE_FILES_SUBVAR_RESOURCE_NAME_ROOT; - public static String RESID_COMPILE_FILES_SUBVAR_RESOURCE_NAME_EXT; - public static String RESID_COMPILE_FILES_SUBVAR_RESOURCE_PATH_ROOT; - public static String RESID_COMPILE_FILES_SUBVAR_RESOURCE_PATH_DRIVE; - public static String RESID_COMPILE_FILES_SUBVAR_CONTAINER_NAME; - public static String RESID_COMPILE_FILES_SUBVAR_CONTAINER_PATH; - // WORK WITH COMPILE COMMANDS DIALOG... - public static String RESID_WWCOMPCMDS_TITLE; - public static String RESID_WWCOMPCMDS_PROFILE_LABEL; - public static String RESID_WWCOMPCMDS_PROFILE_TOOLTIP; - public static String RESID_WWCOMPCMDS_TYPES_LABEL; - public static String RESID_WWCOMPCMDS_TYPES_TOOLTIP; - public static String RESID_WWCOMPCMDS_TYPES_BUTTON_ADD_LABEL; - public static String RESID_WWCOMPCMDS_TYPES_BUTTON_ADD_TOOLTIP; - public static String RESID_WWCOMPCMDS_TYPES_BUTTON_CHG_LABEL; - public static String RESID_WWCOMPCMDS_TYPES_BUTTON_CHG_TOOLTIP; - public static String RESID_WWCOMPCMDS_TYPES_BUTTON_RMV_LABEL; - public static String RESID_WWCOMPCMDS_TYPES_BUTTON_RMV_TOOLTIP; - public static String RESID_WWCOMPCMDS_LIST_LABEL; - public static String RESID_WWCOMPCMDS_LIST_TOOLTIP; - public static String RESID_WWCOMPCMDS_LIST_NEWITEM; - public static String RESID_WWCOMPCMDS_EDITCMD_LABEL; - public static String RESID_WWCOMPCMDS_EDITCMD_TOOLTIP; - public static String RESID_WWCOMPCMDS_NEWCMD_LABEL; - public static String RESID_WWCOMPCMDS_NEWCMD_TOOLTIP; - public static String RESID_WWCOMPCMDS_CMDLABEL_LABEL; - public static String RESID_WWCOMPCMDS_CMDLABEL_TOOLTIP; - public static String RESID_WWCOMPCMDS_CMD_LABEL; - public static String RESID_WWCOMPCMDS_CMD_TOOLTIP; - public static String RESID_WWCOMPCMDS_BUTTON_CREATE_LABEL; - public static String RESID_WWCOMPCMDS_BUTTON_CREATE_TOOLTIP; - public static String RESID_WWCOMPCMDS_BUTTON_APPLY_LABEL; - public static String RESID_WWCOMPCMDS_BUTTON_APPLY_TOOLTIP; - public static String RESID_WWCOMPCMDS_BUTTON_REVERT_LABEL; - public static String RESID_WWCOMPCMDS_BUTTON_REVERT_TOOLTIP; - // Popup menu actions within this dialog - public static String RESID_WWCOMPCMDS_COPY_NAME_1; - public static String RESID_WWCOMPCMDS_COPY_NAME_N; - // PROMPT COMPILE COMMAND DIALOG... - public static String RESID_COMPILE_PROMPTCMD_TITLE; - public static String RESID_COMPILE_PROMPTCMD_VERBAGE_LABEL; - public static String RESID_COMPILE_PROMPTCMD_PROMPT_LABEL; - public static String RESID_COMPILE_PROMPTCMD_PROMPT_TOOLTIP; - public static String RESID_COMPILE_PROMPTCMD_OKBUTTON_LABEL; - public static String RESID_COMPILE_PROMPTCMD_OKBUTTON_TOOLTIP; - public static String RESID_COMPILE_PROMPTCMD_CANCELBUTTON_TOOLTIP; - // ADD COMPILABLE SOURCE TYPE DIALOG... - public static String RESID_COMPILE_NEWSRCTYPE_TITLE; - public static String RESID_COMPILE_NEWSRCTYPE_VERBAGE_LABEL; - public static String RESID_COMPILE_NEWSRCTYPE_PROMPT_LABEL; - public static String RESID_COMPILE_NEWSRCTYPE_PROMPT_TOOLTIP; - // EDIT COMPILABLE SOURCE TYPE DIALOG... - public static String RESID_COMPILE_EDITSRCTYPED_TITLE; - public static String RESID_COMPILE_EDITSRCTYPE_VERBAGE_LABEL; - public static String RESID_COMPILE_EDITSRCTYPE_PROMPT_LABEL; - public static String RESID_COMPILE_EDITSRCTYPE_PROMPT_TOOLTIP; - public static String RESID_UDA_ACTION_DELETE_LABEL; - public static String RESID_UDA_ACTION_DELETE_TOOLTIP; - public static String RESID_UDA_ACTION_COPY_LABEL; - public static String RESID_UDA_ACTION_COPY_TOOLTIP; - public static String RESID_UDA_ACTION_PASTE_LABEL; - public static String RESID_UDA_ACTION_PASTE_TOOLTIP; - public static String RESID_UDA_ACTION_MOVEUP_LABEL; - public static String RESID_UDA_ACTION_MOVEUP_TOOLTIP; - public static String RESID_UDA_ACTION_MOVEDOWN_LABEL; - public static String RESID_UDA_ACTION_MOVEDOWN_TOOLTIP; - public static String RESID_UDA_ACTION_RESTORE_LABEL; - public static String RESID_UDA_ACTION_RESTORE_TOOLTIP; - public static String RESID_WWCOMPCMDS_ACTION_DELETE_LABEL; - public static String RESID_WWCOMPCMDS_ACTION_DELETE_TOOLTIP; - public static String RESID_WWCOMPCMDS_ACTION_COPY_LABEL; - public static String RESID_WWCOMPCMDS_ACTION_COPY_TOOLTIP; - public static String RESID_WWCOMPCMDS_ACTION_PASTE_LABEL; - public static String RESID_WWCOMPCMDS_ACTION_PASTE_TOOLTIP; - public static String RESID_WWCOMPCMDS_ACTION_MOVEUP_LABEL; - public static String RESID_WWCOMPCMDS_ACTION_MOVEUP_TOOLTIP; - public static String RESID_WWCOMPCMDS_ACTION_MOVEDOWN_LABEL; - public static String RESID_WWCOMPCMDS_ACTION_MOVEDOWN_TOOLTIP; - public static String RESID_WWCOMPCMDS_ACTION_RESTORE_LABEL; - public static String RESID_WWCOMPCMDS_ACTION_RESTORE_TOOLTIP; - public static String ACTION_WORKWITH_UDAS_LABEL; - public static String ACTION_WORKWITH_UDAS_TOOLTIP; - public static String ACTION_WORKWITH_WWUDAS_LABEL; - public static String ACTION_WORKWITH_WWUDAS_TOOLTIP; - public static String ACTION_WORKWITH_NAMEDTYPES_LABEL; - public static String ACTION_WORKWITH_NAMEDTYPES_TOOLTIP; - public static String ACTION_WORKWITH_COMPILE_CMDS_LABEL; - public static String ACTION_WORKWITH_COMPILE_CMDS_TOOLTIP; - public static String ACTION_WORKWITH_WWCOMPILE_CMDS_LABEL; - public static String ACTION_WORKWITH_WWCOMPILE_CMDS_TOOLTIP; - public static String ACTION_UDA_CASCADE_LABEL; - public static String ACTION_UDA_CASCADE_TOOLTIP; - public static String RESID_PREF_UDAS_CASCADEBYPROFILE_LABEL; - public static String RESID_PREF_UDAS_CASCADEBYPROFILE_TOOLTIP; - public static String SystemCompileManager_0; - - //Resources used to be in other internal plugins: - public static String EditorManager_saveResourcesMessage; - public static String EditorManager_saveResourcesTitle; - - public static String BUTTON_CLOSE; - public static String RESID_PP_PROPERTIES_TYPE_LABEL; - public static String RESID_PP_PROPERTIES_TYPE_TOOLTIP; - public static String ACTION_CASCADING_NEW_LABEL; - public static String ACTION_CASCADING_NEW_TOOLTIP; - - - static { - // load message values from bundle file - NLS.initializeMessages(BUNDLE_NAME, SystemUDAResources.class); - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDAResources.properties b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDAResources.properties deleted file mode 100644 index d37740823..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDAResources.properties +++ /dev/null @@ -1,423 +0,0 @@ -############################################################################### -# Copyright (c) 2002, 2008 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 -# Xuan Chen (IBM) - [223103] [cleanup] remove duplicate NL strings for user action plugin -############################################################################### - -# NLS_MESSAGEFORMAT_NONE -# NLS_ENCODING=UTF-8 - -#============================================================= -# WORK WITH USER-DEFINED ACTIONS DIALOG... -#============================================================= -RESID_WORKWITH_UDAS_TITLE=Work With User Actions -RESID_UDA_TREE_TIP=Existing user actions. Press F1 for details. -RESID_UDA_ACTION_DELETE_LABEL=Delete... -RESID_UDA_ACTION_DELETE_TOOLTIP=Delete selected action or type. Will be asked to confirm -RESID_UDA_ACTION_COPY_LABEL=Copy -RESID_UDA_ACTION_COPY_TOOLTIP=Copy selected action or type to clipboard so it can be pasted for a duplication operation -RESID_UDA_ACTION_PASTE_LABEL=Paste -RESID_UDA_ACTION_PASTE_TOOLTIP=Paste action or type from clipboard -RESID_UDA_ACTION_MOVEUP_LABEL=Move up -RESID_UDA_ACTION_MOVEUP_TOOLTIP=Move selected action or type up in the list -RESID_UDA_ACTION_MOVEDOWN_LABEL=Move down -RESID_UDA_ACTION_MOVEDOWN_TOOLTIP=Move selected action or type down in the list -RESID_UDA_ACTION_RESTORE_LABEL=Restore defaults -RESID_UDA_ACTION_RESTORE_TOOLTIP=Restore to original state as supplied by IBM -RESID_UDA_COPY_NAME_1=Copy of %1 -RESID_UDA_COPY_NAME_N=Copy (%2) of %1 -RESID_UDA_IBM_VERBAGE=This action is supplied by IBM and is not editable. -RESID_UDA_VENDOR_VERBAGE=This action is supplied by vendor %1 and is not editable. - -RESID_WORKWITH_UDAS_ACTION_LABEL=Work With User Actions... -RESID_WORKWITH_UDAS_ACTION_TOOLTIP=Work with your user action definitions - - -#============================================================= -# USER-DEFINED ACTION NEW/EDIT PANE... -#============================================================= - -#============================================================= -# USER-DEFINED ACTION RESOURCE TYPE (FOR DELETE CONFIRM DIALOG) -#============================================================= -RESID_UDA_RESOURCE_TYPE= User-defined action - -#============================================================= -# WORK WITH USER-DEFINED (File) Types DIALOG... -#============================================================= -RESID_WORKWITH_UDT_TITLE=Work With Named Types -RESID_UDT_TREE_TIP=Existing named types. Press F1 for details. -RESID_UDT_IBM_VERBAGE=This named type is supplied by IBM and is not editable. -RESID_UDT_VENDOR_VERBAGE=This named type is supplied by vendor %1 and is not editable. - -#============================================================= -# USER-DEFINED ACTION RESOURCE TYPE (FOR DELETE CONFIRM DIALOG) -#============================================================= -RESID_UDT_RESOURCE_TYPE= User-defined file type - -#============================================================= -# PROMPT USER-DEFINED-ACTION COMMAND DIALOG... -#============================================================= -RESID_UDA_PROMPTCMD_TITLE=Prompt User Action Command - -#============================================================= -# PROMPT COMPILE COMMAND DIALOG... -#============================================================= -RESID_COMPILE_PROMPTCMD_TITLE=Prompt Compile Command - - -#============================================================= -# COMMON USER-DEFINED ACTIONS SUBSTITUTION VARIABLES... -#============================================================= -RESID_UDA_SUBVAR_ACTION_NAME = This user action's name -RESID_UDA_SUBVAR_CONNECTION_NAME = The name of the connection expanded to see these resources -RESID_UDA_SUBVAR_LOCAL_HOSTNAME = Local workstation host name -RESID_UDA_SUBVAR_LOCAL_IP = Local workstation IP address -RESID_UDA_SUBVAR_USER_ID = User ID used to make the connection -RESID_UDA_SUBVAR_SYSTEM_TEMPDIR = Temporary directory on the target system -RESID_UDA_SUBVAR_SYSTEM_HOMEDIR = Home directory on the target system, for the connection's user ID -RESID_UDA_SUBVAR_SYSTEM_HOSTNAME = Remote system host name -RESID_UDA_SUBVAR_SYSTEM_PATHSEP = Path separator. ";" on Windows, ":" on Unix and Linux -RESID_UDA_SUBVAR_SYSTEM_FILESEP = File separator. "\\" on Windows, "/" on Unix and Linux - - - -#============================================================= -# UNIVERSAL FILE SUBSYSTEM USER-DEFINED ACTIONS MRI... -#============================================================= -RESID_UDA_FILES_DOMAIN_FOLDER= Folder -RESID_UDA_FILES_DOMAIN_FILE= File -RESID_UDA_FILES_DOMAIN_NEWFOLDER= Folder action -RESID_UDA_FILES_DOMAIN_NEWFILE= File action -RESID_UDA_FILES_NEWNODE_LABEL= New named type... - -#================================================================= -# UNIVERSAL FILE SUBSYSTEM SUBSTITUTION VARIABLES FOR USER ACTIONS -#================================================================= -RESID_UDA_FILES_SUBVAR_RESOURCE_DATE = Last modified date of selected resource -RESID_UDA_FILES_SUBVAR_RESOURCE_NAME = Name of selected resource, unqualified -RESID_UDA_FILES_SUBVAR_RESOURCE_PATH = Path of selected resource, including name -RESID_UDA_FILES_SUBVAR_RESOURCE_NAME_ROOT=Name of selected resource without the extension -RESID_UDA_FILES_SUBVAR_RESOURCE_NAME_EXT=Extension part of the name of the selected resource -RESID_UDA_FILES_SUBVAR_RESOURCE_PATH_ROOT=Root of selected file's path. "c:\\" on Windows, or "/" on others -RESID_UDA_FILES_SUBVAR_RESOURCE_PATH_DRIVE=Drive letter on Windows, empty string on others -RESID_UDA_FILES_SUBVAR_CONTAINER_NAME=Name of folder containing selected resource, unqualified -RESID_UDA_FILES_SUBVAR_CONTAINER_PATH=Path of folder containing selected resource, including name - -#================================================================= -# UNIVERSAL FILE SUBSYSTEM SUBSTITUTION VARIABLES FOR COMPILE ACTIONS -#================================================================= -RESID_COMPILE_FILES_SUBVAR_CONNECTION_NAME = The name of the connection expanded to see these resources -RESID_COMPILE_FILES_SUBVAR_LOCAL_HOSTNAME = Local workstation host name -RESID_COMPILE_FILES_SUBVAR_LOCAL_IP = Local workstation IP address -RESID_COMPILE_FILES_SUBVAR_USER_ID = User ID used to make the connection -RESID_COMPILE_FILES_SUBVAR_SYSTEM_TEMPDIR = Temporary directory on the target system -RESID_COMPILE_FILES_SUBVAR_SYSTEM_HOMEDIR = Home directory on the target system, for the connection's user ID -RESID_COMPILE_FILES_SUBVAR_SYSTEM_HOSTNAME = Remote system host name -RESID_COMPILE_FILES_SUBVAR_SYSTEM_PATHSEP = Path separator. ";" on Windows, ":" on Unix and Linux -RESID_COMPILE_FILES_SUBVAR_SYSTEM_FILESEP = File separator. "\\" on Windows, "/" on Unix and Linux -RESID_COMPILE_FILES_SUBVAR_RESOURCE_DATE = Last modified date of selected resource -RESID_COMPILE_FILES_SUBVAR_RESOURCE_NAME = Name of selected resource, unqualified -RESID_COMPILE_FILES_SUBVAR_RESOURCE_PATH = Path of selected resource, including name -RESID_COMPILE_FILES_SUBVAR_RESOURCE_NAME_ROOT=Name of selected resource without the extension -RESID_COMPILE_FILES_SUBVAR_RESOURCE_NAME_EXT=Extension part of the name of the selected resource -RESID_COMPILE_FILES_SUBVAR_RESOURCE_PATH_ROOT=Root of selected file's path. "c:\\" on Windows, or "/" on others -RESID_COMPILE_FILES_SUBVAR_RESOURCE_PATH_DRIVE=Drive letter on Windows, empty string on others -RESID_COMPILE_FILES_SUBVAR_CONTAINER_NAME=Name of folder containing selected resource, unqualified -RESID_COMPILE_FILES_SUBVAR_CONTAINER_PATH=Path of folder containing selected resource, including name - - -#============================================================= -# UNIVERSAL FILE SUBSYSTEM USER-DEFINED TYPES MRI... -#============================================================= -RESID_UDT_FILES_DOMAIN_NEWFOLDER= Folder type -RESID_UDT_FILES_DOMAIN_NEWFILE= File type - -#============================================================= -# SELECT REMOTE FILES RE-USABLE WIDGET... -#============================================================= - -#============================================================= -# WORK WITH COMPILE COMMANDS DIALOG... -#============================================================= -RESID_WWCOMPCMDS_TITLE=Work With Compile Commands -RESID_WWCOMPCMDS_LIST_NEWITEM=New command -# POPUP-MENU ITEMS WITHIN THIS DIALOG -RESID_WWCOMPCMDS_COPY_NAME_1=Copy of %1 -RESID_WWCOMPCMDS_COPY_NAME_N=Copy (%2) of %1 -#============================================================= -# PROMPT FOR NEW COMPILE SOURCE TYPE... -#============================================================= -RESID_COMPILE_NEWSRCTYPE_TITLE=Add Source Type -#============================================================= -# PROMPT FOR EDITING COMPILE SOURCE TYPE... -#============================================================= -RESID_COMPILE_EDITSRCTYPED_TITLE=Edit Source Type -#================================================================= -# UNIVERSAL FILE SUBSYSTEM SUBSTITUTION VARIABLES FOR USER ACTIONS -#================================================================= -ACTION_WORKWITH_UDAS_LABEL=User Actions... -ACTION_WORKWITH_UDAS_TOOLTIP=Create or manage user-defined actions for remote objects - -ACTION_WORKWITH_WWUDAS_LABEL=Work With User Actions... -ACTION_WORKWITH_WWUDAS_TOOLTIP=Create or manage user-defined actions for remote objects - -ACTION_WORKWITH_NAMEDTYPES_LABEL=Named Types... -ACTION_WORKWITH_NAMEDTYPES_TOOLTIP=Create or manage named lists of pre-defined resource types - -ACTION_WORKWITH_COMPILE_CMDS_LABEL=Compile Commands... -ACTION_WORKWITH_COMPILE_CMDS_TOOLTIP=Create or manage commands used to compile selected resources - -ACTION_WORKWITH_WWCOMPILE_CMDS_LABEL=Work With Compile Commands... -ACTION_WORKWITH_WWCOMPILE_CMDS_TOOLTIP=Create or manage commands used to compile selected resources - - -ACTION_UDA_CASCADE_LABEL=User Actions -ACTION_UDA_CASCADE_TOOLTIP=User defined actions for the selected resources - -RESID_PREF_UDAS_CASCADEBYPROFILE_LABEL=Cascade user actions and compile commands by profile -RESID_PREF_UDAS_CASCADEBYPROFILE_TOOLTIP=Cascade the User Actions and Compile pop-up menus by active profile, for remote objects - - - -#============================================================= -# WORK WITH USER-DEFINED ACTIONS DIALOG... -#============================================================= -RESID_UDA_PROFILE_LABEL=Parent profile -RESID_UDA_PROFILE_TOOLTIP=Select profile whose user actions you wish to work with - -RESID_UDA_APPLY_BUTTON_LABEL=Apply -RESID_UDA_APPLY_BUTTON_TOOLTIP=Apply changes - -RESID_UDA_RESET_BUTTON_LABEL=Reset -RESID_UDA_RESET_BUTTON_TOOLTIP=Reset settings - -RESID_UDA_REVERT_BUTTON_LABEL=Revert -RESID_UDA_REVERT_BUTTON_TOOLTIP=Revert changes - -RESID_UDA_DELETE_BUTTON_LABEL=Delete... -RESID_UDA_DELETE_BUTTON_TOOLTIP=Delete selected action - -RESID_UDA_COPY_BUTTON_LABEL=Copy -RESID_UDA_COPY_BUTTON_TOOLTIP=Duplicate this action in the same or different profile - -#============================================================= -# USER-DEFINED ACTION NEW/EDIT PANE... -#============================================================= - -RESID_UDA_NAME_LABEL=Action name -RESID_UDA_NAME_TOOLTIP=Unique name for the action - -RESID_UDA_COMMENT_LABEL=Comment -RESID_UDA_COMMENT_TOOLTIP=Enter a comment to describe this action in more detail - -RESID_UDA_COMMAND_LABEL=Command -RESID_UDA_COMMAND_TOOLTIP=The command string which will be run when the action is invoked - -RESID_UDA_INSERTVAR_BUTTON_LABEL=Insert variable... -RESID_UDA_INSERTVAR_BUTTON_TOOLTIP=Insert a substitution variable into the command, at the cursor - -RESID_UDA_EDIT_BUTTON_LABEL=Edit... -RESID_UDA_EDIT_BUTTON_TOOLTIP=Edit the command string - -RESID_UDA_OPTION_PROMPT_LABEL=Prompt first -RESID_UDA_OPTION_PROMPT_TOOLTIP=Prompt for command parameter changes when the action is invoked - -RESID_UDA_OPTION_SHOW_LABEL=Show action -RESID_UDA_OPTION_SHOW_TOOLTIP=Show this action when it applies - -RESID_UDA_OPTION_REFRESH_LABEL=Refresh after -RESID_UDA_OPTION_REFRESH_TOOLTIP=Refresh information on the selected resources after the action is invoked - -RESID_UDA_OPTION_COLLECT_LABEL=Invoke once -RESID_UDA_OPTION_COLLECT_TOOLTIP=Invoke the action once for all selected objects, versus once for each. The name substitution variable holds the quoted full name of each object, delimited by blanks - -RESID_UDA_OPTION_SINGLESEL_LABEL=Single selection only -RESID_UDA_OPTION_SINGLESEL_TOOLTIP=Show action only if a single object is selected - -RESID_UDA_OPTION_REMOTE_LABEL=Remote command -RESID_UDA_OPTION_REMOTE_TOOLTIP=Command is a remote command versus a local command - -RESID_UDA_TYPE_LIST_LABEL=Resource types for which this action will appear -RESID_UDA_TYPE_LIST_TOOLTIP=Select types to scope this action to - -RESID_UDA_TYPE_LIST_MASTER_LABEL=Defined Types -RESID_UDA_TYPE_LIST_MASTER_TOOLTIP=Master list of all previously defined types - -RESID_UDA_TYPE_LIST_SELECTED_LABEL=Selected Types -RESID_UDA_TYPE_LIST_SELECTED_TOOLTIP=Select list of types to scope this action to - -RESID_UDA_TYPE_EDIT_BUTTON_LABEL=Edit... -RESID_UDA_TYPE_EDIT_BUTTON_TOOLTIP=Edit master list of file types - -RESID_UDA_TYPE_ADD_BUTTON_LABEL=Add> -RESID_UDA_TYPE_ADD_BUTTON_TOOLTIP=Add selected type from master list to the selected list - -RESID_UDA_TYPE_RMV_BUTTON_LABEL=<Remove -RESID_UDA_TYPE_RMV_BUTTON_TOOLTIP=Remove selected type from the selected list - -#============================================================= -# PROMPT USER-DEFINED-ACTION COMMAND DIALOG... -#============================================================= -RESID_UDA_PROMPTCMD_VERBAGE_LABEL=Optionally edit the command for this user action. Press Run to run it. -RESID_UDA_PROMPTCMD_PROMPT_LABEL=Command -RESID_UDA_PROMPTCMD_PROMPT_TOOLTIP=Command to be run, with substitution variables resolved. Can be edited -RESID_UDA_PROMPTCMD_OKBUTTON_LABEL=Run -RESID_UDA_PROMPTCMD_OKBUTTON_TOOLTIP=Run the command -RESID_UDA_PROMPTCMD_CANCELBUTTON_TOOLTIP=Do not run the command - - -#============================================================= -# WORK WITH COMPILE COMMANDS DIALOG... -#============================================================= - -RESID_WWCOMPCMDS_PROFILE_LABEL=Parent profile: -RESID_WWCOMPCMDS_PROFILE_TOOLTIP=Select profile whose compile commands you wish to work with - -RESID_WWCOMPCMDS_TYPES_LABEL=Source type: -RESID_WWCOMPCMDS_TYPES_TOOLTIP=Select the source type for which these compile commands apply - -RESID_WWCOMPCMDS_TYPES_BUTTON_ADD_LABEL=Add... -RESID_WWCOMPCMDS_TYPES_BUTTON_ADD_TOOLTIP=Add a source type for which there will be associated compile commands - -RESID_WWCOMPCMDS_TYPES_BUTTON_CHG_LABEL=Edit... -RESID_WWCOMPCMDS_TYPES_BUTTON_CHG_TOOLTIP=Edit this source type, for which there are associated compile commands - -RESID_WWCOMPCMDS_TYPES_BUTTON_RMV_LABEL=Remove -RESID_WWCOMPCMDS_TYPES_BUTTON_RMV_TOOLTIP=Remove this source type. Only enabled if there are no associated compile commands. - -RESID_WWCOMPCMDS_LIST_LABEL=Compile Commands: -RESID_WWCOMPCMDS_LIST_TOOLTIP=Commands to compile with. Use the pop-up menu for additional actions - -RESID_WWCOMPCMDS_EDITCMD_LABEL=Selected compile command: -RESID_WWCOMPCMDS_EDITCMD_TOOLTIP=Edit the compile command and press Apply to change it in the list - -RESID_WWCOMPCMDS_NEWCMD_LABEL=New compile command: -RESID_WWCOMPCMDS_NEWCMD_TOOLTIP=Specify the new compile command, then press Create to add it to the list - -RESID_WWCOMPCMDS_CMDLABEL_LABEL=Label: -RESID_WWCOMPCMDS_CMDLABEL_TOOLTIP=A unique label for the compile command, shown in the compile menu for resources of the selected type. Labels of IBM-supplied compile commands are not editable. - -RESID_WWCOMPCMDS_CMD_LABEL=Command: -RESID_WWCOMPCMDS_CMD_TOOLTIP=Specify the compile command, including any parameters and substitution variables desired - -RESID_WWCOMPCMDS_BUTTON_CREATE_LABEL=Create -RESID_WWCOMPCMDS_BUTTON_CREATE_TOOLTIP=Press to create a new compile command using the given label and command string - -RESID_WWCOMPCMDS_BUTTON_APPLY_LABEL=Apply -RESID_WWCOMPCMDS_BUTTON_APPLY_TOOLTIP=Press to apply the changes to the currently selected compile command - -RESID_WWCOMPCMDS_BUTTON_REVERT_LABEL=Revert -RESID_WWCOMPCMDS_BUTTON_REVERT_TOOLTIP=Press to revert to the last saved values for the currently selected compile command - -RESID_WWCOMPCMDS_ACTION_DELETE_LABEL=Delete... -RESID_WWCOMPCMDS_ACTION_DELETE_TOOLTIP=Delete selected action or type. Will be asked to confirm -RESID_WWCOMPCMDS_ACTION_COPY_LABEL=Copy -RESID_WWCOMPCMDS_ACTION_COPY_TOOLTIP=Copy selected action or type to clipboard so it can be pasted for a duplication operation -RESID_WWCOMPCMDS_ACTION_PASTE_LABEL=Paste -RESID_WWCOMPCMDS_ACTION_PASTE_TOOLTIP=Paste action or type from clipboard -RESID_WWCOMPCMDS_ACTION_MOVEUP_LABEL=Move up -RESID_WWCOMPCMDS_ACTION_MOVEUP_TOOLTIP=Move selected action or type up in the list -RESID_WWCOMPCMDS_ACTION_MOVEDOWN_LABEL=Move down -RESID_WWCOMPCMDS_ACTION_MOVEDOWN_TOOLTIP=Move selected action or type down in the list -RESID_WWCOMPCMDS_ACTION_RESTORE_LABEL=Restore defaults -RESID_WWCOMPCMDS_ACTION_RESTORE_TOOLTIP=Restore to original state as supplied by IBM - - -#============================================================= -# PROMPT COMPILE COMMAND DIALOG... -#============================================================= -RESID_COMPILE_PROMPTCMD_VERBAGE_LABEL=Optionally edit the command before running it. Press Run to run it. - -RESID_COMPILE_PROMPTCMD_PROMPT_LABEL=Compile command -RESID_COMPILE_PROMPTCMD_PROMPT_TOOLTIP=Command to be run, with substitution variables resolved. Can be edited - -RESID_COMPILE_PROMPTCMD_OKBUTTON_LABEL=Run -RESID_COMPILE_PROMPTCMD_OKBUTTON_TOOLTIP=Run the compile command - -RESID_COMPILE_PROMPTCMD_CANCELBUTTON_TOOLTIP=Do not run the compile command - - - -#============================================================= -# PROMPT FOR NEW COMPILE SOURCE TYPE... -#============================================================= - -RESID_COMPILE_NEWSRCTYPE_VERBAGE_LABEL=Specify a new compilable source type - -RESID_COMPILE_NEWSRCTYPE_PROMPT_LABEL=New source type -RESID_COMPILE_NEWSRCTYPE_PROMPT_TOOLTIP=Identify a source type for which compile commands will be associated - - -#============================================================= -# PROMPT FOR EDITING COMPILE SOURCE TYPE... -#============================================================= - -RESID_COMPILE_EDITSRCTYPE_VERBAGE_LABEL=Change the compilable source type - -RESID_COMPILE_EDITSRCTYPE_PROMPT_LABEL=Source type -RESID_COMPILE_EDITSRCTYPE_PROMPT_TOOLTIP=Re-specify this source type with which compile commands are associated - - - -#============================================================= -# USER-DEFINED ACTION RESOURCE TYPE (FOR DELETE CONFIRM DIALOG) -#============================================================= -com.ibm.etools.systems.ui.uda.resourceType = User-defined action - -#============================================================= -# WORK WITH USER-DEFINED (File) Types DIALOG... -#============================================================= -RESID_UDT_NAME_LABEL=Name -RESID_UDT_NAME_TOOLTIP=Unique name for the named type - -RESID_UDT_TYPES_LABEL=Types -RESID_UDT_TYPES_TOOLTIP=One or more blank-delimited resource types. These can be simple or generic - -RESID_UDT_TYPESLIST_LABEL_LABEL=Select types -RESID_UDT_TYPESLIST_LABEL_TOOLTIP=Select one or more resource types which this named type will represent - -RESID_UDT_DELETE_BUTTON_LABEL=Delete -RESID_UDT_DELETE_BUTTON_TOOLTIP=Delete selected type - - -#============================================================= -# UNIVERSAL FILE SUBSYSTEM USER-DEFINED TYPES MRI... -#============================================================= -RESID_UDT_FILES_TYPESGROUP_LABEL=File Types -RESID_UDT_FILES_TYPESGROUP_TOOLTIP=Select one or more file types which this named type will represent - -RESID_UDT_FILES_DEFINEDTYPES_LABEL=Selected types -RESID_UDT_FILES_DEFINEDTYPES_TOOLTIP=All types currently selected for this named type - -RESID_UDT_FILES_USERTYPES_LABEL=Other types -RESID_UDT_FILES_USERTYPES_TOOLTIP=Enter additional extensions, comma-separated. Press F1 for details. - - -################################################################################### -############################ Universal Commands ############################ -################################################################################### -RESID_UCMD_RUN_IN_NEW_SHELL_LABEL = Run in new shell -RESID_UCMD_RUN_IN_NEW_SHELL_TOOLTIP = Indicate whether the command is to be launched in a new shell or the system default shell -RESID_UCMD_RUN_COMMAND_LABEL = Run Command -RESID_UCMD_COMMAND_LABEL = Command -RESID_UCMD_COMMAND_TOOLTIP = Enter the command to invoke -RESID_UCMD_COMAMND_SHELL_LABEL = Command Shell - -SystemCompileManager_0=An error has been detected that is probably a programming bug. Please submit your .log file in the .metadata subfolder for service. - - -EditorManager_saveResourcesMessage = Select the &resources to save: -EditorManager_saveResourcesTitle = Save Resources - -BUTTON_CLOSE=Close -RESID_PP_PROPERTIES_TYPE_LABEL=Resource type -RESID_PP_PROPERTIES_TYPE_TOOLTIP=What type of artifact is this? -ACTION_CASCADING_NEW_LABEL=New -ACTION_CASCADING_NEW_TOOLTIP=Create a new resource diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDARestoreDefaultsActions.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDARestoreDefaultsActions.java deleted file mode 100644 index d8f0eb905..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDARestoreDefaultsActions.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.uda; - -/******************************************************************************* - * Copyright (c) 2002, 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 - *******************************************************************************/ -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.rse.ui.ISystemContextMenuConstants; -import org.eclipse.rse.ui.ISystemIconConstants; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.actions.SystemBaseAction; - -/** - * The action is used within the Work With User Actions dialog, in the context menu - * of the selected user-defined action.<br> - * It is used to restore shipped defaults of the selected IBM-supplied user action - */ -public class SystemUDARestoreDefaultsActions extends SystemBaseAction { - private SystemUDBaseTreeView parentTree; - - /** - * Constructor - */ - public SystemUDARestoreDefaultsActions(SystemUDBaseTreeView parentTree) { - super(SystemUDAResources.RESID_UDA_ACTION_RESTORE_LABEL, SystemUDAResources.RESID_UDA_ACTION_RESTORE_TOOLTIP, RSEUIPlugin.getDefault().getImageDescriptorFromIDE( - ISystemIconConstants.ICON_IDE_REFRESH_ID), null); - allowOnMultipleSelection(false); - this.parentTree = parentTree; - setContextMenuGroup(ISystemContextMenuConstants.GROUP_CHANGE); - setHelp(RSEUIPlugin.HELPPREFIX + "udrd0000"); //$NON-NLS-1$ - } - - /** - * We override from parent to do unique checking. - * We intercept to ensure this is an IBM-supplied compile command - */ - public boolean updateSelection(IStructuredSelection selection) { - return parentTree.canRestore(); - } - - /** - * This is the method called when the user selects this action. - */ - public void run() { - parentTree.doRestore(); - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDASubstVarListCommon.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDASubstVarListCommon.java deleted file mode 100644 index 2895153c5..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDASubstVarListCommon.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 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 - * Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods - *******************************************************************************/ -package org.eclipse.rse.internal.useractions.ui.uda; - -import org.eclipse.rse.internal.useractions.ui.SystemCmdSubstVarList; - -/** - * @author coulthar - * - * Encapsulation of the substitution variables that are typically common for - * absolutely every subsystem. - */ -public class SystemUDASubstVarListCommon extends SystemCmdSubstVarList { - private static final String[] COMMON_VARNAMES = { "action_name", "connection_name", "local_hostname", "local_ip", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - "system_filesep", "system_homedir", "system_hostname", "system_pathsep", "system_tempdir", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ - "user_id" }; //$NON-NLS-1$ - private static final String[] COMMON_VARNAME_DESCRIPTIONS = { SystemUDAResources.RESID_UDA_SUBVAR_ACTION_NAME, SystemUDAResources.RESID_UDA_SUBVAR_CONNECTION_NAME, - SystemUDAResources.RESID_UDA_SUBVAR_LOCAL_HOSTNAME, SystemUDAResources.RESID_UDA_SUBVAR_LOCAL_IP, SystemUDAResources.RESID_UDA_SUBVAR_SYSTEM_FILESEP, - SystemUDAResources.RESID_UDA_SUBVAR_SYSTEM_HOMEDIR, SystemUDAResources.RESID_UDA_SUBVAR_SYSTEM_HOSTNAME, SystemUDAResources.RESID_UDA_SUBVAR_SYSTEM_PATHSEP, - SystemUDAResources.RESID_UDA_SUBVAR_SYSTEM_TEMPDIR, SystemUDAResources.RESID_UDA_SUBVAR_USER_ID }; - private static SystemUDASubstVarListCommon inst = null; - - /** - * Constructor . - * Not to be used directly. Rather, use {@link #getInstance()}. - */ - SystemUDASubstVarListCommon() { - super(COMMON_VARNAMES, COMMON_VARNAME_DESCRIPTIONS); - } - - /** - * Return the singleton of this object. No need ever for more than one instance - */ - public static SystemUDASubstVarListCommon getInstance() { - if (inst == null) inst = new SystemUDASubstVarListCommon(); - return inst; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDActionEditPane.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDActionEditPane.java deleted file mode 100644 index 84b82b6d4..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDActionEditPane.java +++ /dev/null @@ -1,1195 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core - * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry - * David Dykstal (IBM) - [186589] move user types, user actions, and compile commands - * API to the user actions plugin - *******************************************************************************/ - -package org.eclipse.rse.internal.useractions.ui.uda; - -import java.util.Vector; - -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.rse.core.RSECorePlugin; -import org.eclipse.rse.core.events.ISystemModelChangeEvents; -import org.eclipse.rse.core.model.ISystemProfile; -import org.eclipse.rse.core.subsystems.ISubSystem; -import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; -import org.eclipse.rse.internal.useractions.IUserActionsModelChangeEvents; -import org.eclipse.rse.internal.useractions.ui.ISystemCommandTextAdditionalGUIProvider; -import org.eclipse.rse.internal.useractions.ui.SystemCmdSubstVarList; -import org.eclipse.rse.internal.useractions.ui.SystemCommandTextField; -import org.eclipse.rse.internal.useractions.ui.SystemCommandViewerConfiguration; -import org.eclipse.rse.internal.useractions.ui.validators.ValidatorUserActionComment; -import org.eclipse.rse.internal.useractions.ui.validators.ValidatorUserActionName; -import org.eclipse.rse.services.clientserver.messages.SystemMessage; -import org.eclipse.rse.shells.ui.view.ISystemCommandTextModifyListener; -import org.eclipse.rse.ui.ISystemMassager; -import org.eclipse.rse.ui.SystemWidgetHelpers; -import org.eclipse.rse.ui.validators.ISystemValidator; -import org.eclipse.rse.ui.validators.ISystemValidatorUniqueString; -import org.eclipse.rse.ui.widgets.SystemEditPaneStateMachine; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.FocusEvent; -import org.eclipse.swt.events.FocusListener; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.events.KeyListener; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.events.MouseListener; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; - -/** - * This is the default edit pane shown on the right, when - * an action is selected on the left. It is also used when - * "new..." is selected on the left, so there are three states - * for this class: new, edit and not-set. - */ -public class SystemUDActionEditPane implements SelectionListener, // for the checkboxes - ISelectionChangedListener, Listener, ISystemUDSelectTypeListener, ISystemCommandTextAdditionalGUIProvider, ISystemCommandTextModifyListener, MouseListener, KeyListener { - // gui widgets - protected Text textName, textComment; - //protected SourceViewer textCommand; - protected SystemCommandTextField commandField; - //protected SystemUDASourceViewerConfiguration sourceViewerConfiguration; - protected Button promptCB, refreshCB, showCB, singleSelCB, collectCB; - protected Button resetButton; - //protected Button insertVariableButton; - protected Label typesSeparator; - protected SystemUDSelectTypesForm selectTypesForm; - protected boolean menuListenerAdded; - protected String testActionName; - // actions for popup of command SourceViewer - // private Map fGlobalActions= new HashMap(10); - // private List fSelectionActions = new ArrayList(3); - // Current selection not valid if errorMessage not null - protected SystemMessage errorMessage; - protected ISubSystem subsystem; - protected SystemUDActionSubsystem udaActionSubsys; - protected ISubSystemConfiguration subsystemFactory; - protected ISystemProfile profile; - public SystemUDActionElement currentAction; - protected ISystemValidator nameValidator; - //protected ISystemValidator cmdValidator; - protected ISystemValidator cmtValidator; - //protected ISystemMassager cmdMassager; - private boolean isEnabled = false; - private boolean recursiveCall = false; - private boolean ignoreChanges = false; - // entry fields enabled from last selection - private NameModifyListener nameML = new NameModifyListener(); - private NameFocusListener nameFL = new NameFocusListener(); - private CommentModifyListener commentML = new CommentModifyListener(); - //protected SystemWorkWithUDAsDialog parentDialog; - protected ISystemUDAEditPaneHoster parentDialog; - protected ISystemUDTreeView treeView; - // Switch to trigger a tree view refresh when the item's name is changed. - private boolean nameChanged = false; - protected boolean newMode = false; - private int newModeDomain = -1; - private SystemUDTreeViewNewItem newModeNewItem; - private Vector EMPTY_VECTOR = new Vector(); - // state - private boolean grabFocus = true; // grab the focus away from the tree when processing selection events - // state machine - private SystemEditPaneStateMachine stateMachine; - - /** - * Constructor when we have a subsystem or a subsystemconfiguration/profile pair. - */ - public SystemUDActionEditPane(SystemUDActionSubsystem udaActionSubsys, ISystemUDAEditPaneHoster parent, ISystemUDTreeView tv) { - super(); - this.udaActionSubsys = udaActionSubsys; - this.subsystem = udaActionSubsys.getSubsystem(); - this.subsystemFactory = subsystem.getSubSystemConfiguration(); - this.profile = (profile == null) ? subsystem.getSystemProfile() : profile; - parentDialog = parent; - treeView = tv; - commandField = new SystemCommandTextField(getCommandTextViewerConfiguration()); - testActionName = getUDActionSubsystem().getTestActionName().toLowerCase(); - } - - /** - * Return the user defined action subsystem - */ - protected SystemUDActionSubsystem getUDActionSubsystem() { - return udaActionSubsys; - } - - /** - * For child classes to return their own subclasses of the default configurator - * used to enable proposal support in the command entry field. - */ - protected SystemCommandViewerConfiguration getCommandTextViewerConfiguration() { - return new SystemCommandViewerConfiguration(); - } - - /** - * For child classes (such as iSeries IFS) that need to dynamically change the command - * entry field configuration, on the fly. - */ - protected void setCommandTextViewerConfiguration(SystemCommandViewerConfiguration cmdAssistant) { - commandField.setCommandTextViewerConfiguration(cmdAssistant); - } - - /** - * For child classes to access current subsystem. If null, use getSubSystemFactory and getProfile - */ - protected ISubSystem getSubSystem() { - return subsystem; - } - - /** - * For child classes to access current profile - */ - protected ISystemProfile getProfile() { - return profile; - } - - /** - * For child classes to access current shell - */ - protected Shell getShell() { - return parentDialog.getShell(); - } - - // ------------------------------ - // CONFIGURATION/INPUT METHODS... - // ------------------------------ - /** - * Set the state machine. - * Called by the UDA dialog - */ - public void setStateMachine(SystemEditPaneStateMachine sm) { - this.stateMachine = sm; - } - - /** - * Set the action name validator - */ - public void setNameValidator(ISystemValidator validator) { - this.nameValidator = validator; - } - - /** - * Set the action comment validator - */ - public void setCommentValidator(ISystemValidator validator) { - this.cmtValidator = validator; - } - - /** - * Set the action command validator. This is called per keystroke as - * the user types the command. - */ - public void setCommandValidator(ISystemValidator validator) { - commandField.setCommandValidator(validator); - } - - /** - * Set the action command massager. This is called before saving the - * command to the persistent store, to allow for massaging what the - * user typed, such as doing intelligent uppercasing. - */ - public void setCommandMassager(ISystemMassager massager) { - commandField.setCommandMassager(massager); - } - - /** - * Set the substitution variable list that Insert Variable will use. - */ - public void setSubstitutionVariableList(SystemCmdSubstVarList varList) { - commandField.setSubstitutionVariableList(varList); - } - - // ------------------------------ - // DATA EXTRACTION METHODS - // ------------------------------ - // ------------------------------ - // EXTERNAL LIFECYCLE METHODS... - // ------------------------------ - /** - * Method createContents. - * @param parent parent of this pane - * @return Control - */ - public Control createContents(Composite parent) { - if (nameValidator == null) nameValidator = new ValidatorUserActionName(); - if (cmtValidator == null) cmtValidator = new ValidatorUserActionComment(); - //Composite composite_prompts = SystemWidgetHelpers.createComposite(parent, 1); // why??? - // Inner composite - final int nbrColumns = 3; // 2 - Composite comp = SystemWidgetHelpers.createComposite(parent, nbrColumns); - // Action name - textName = SystemWidgetHelpers.createLabeledTextField(comp, null, SystemUDAResources.RESID_UDA_NAME_LABEL, SystemUDAResources.RESID_UDA_NAME_TOOLTIP); - ((GridData) textName.getLayoutData()).horizontalSpan = nbrColumns - 1; - // Comment - textComment = SystemWidgetHelpers.createLabeledTextField(comp, null, SystemUDAResources.RESID_UDA_COMMENT_LABEL, SystemUDAResources.RESID_UDA_COMMENT_TOOLTIP); - ((GridData) textComment.getLayoutData()).horizontalSpan = nbrColumns - 1; - // Re-usable command field... - commandField.setMRI(SystemUDAResources.RESID_UDA_COMMAND_LABEL, SystemUDAResources.RESID_UDA_COMMAND_TOOLTIP, SystemUDAResources.RESID_UDA_INSERTVAR_BUTTON_LABEL, - SystemUDAResources.RESID_UDA_INSERTVAR_BUTTON_TOOLTIP); - commandField.createContents(comp, nbrColumns, this); - // old way... - /* - Label labelCommand = SystemWidgetHelpers.createLabel(comp,rb,RESID_UDA_COMMAND_ROOT); - String s = labelCommand.getText(); - if (!s.endsWith(":")) - labelCommand.setText(s+":"); - if (!createCommandLabelLineControls(comp, nbrColumns-1)) - ((GridData)labelCommand.getLayoutData()).horizontalSpan = nbrColumns; - - int cmdSpan = nbrColumns; - textCommand = createEditor(comp, cmdSpan, sourceViewerConfiguration); - textCommand.getControl().setToolTipText(rb.getString(RESID_UDA_COMMAND_ROOT_TOOLTIP); - // Insert Variable... button - insertVariableButton = SystemWidgetHelpers.createPushButton(comp, null, rb, ISystemConstants.RESID_UDA_INSERTVAR_BUTTON_ROOT); - // SUBCLASS-SUPPLIED BUTTONS - if (!createExtraButtons(comp, nbrColumns-1)) - addFillerLine(comp, nbrColumns-1); - */ - //Label filler = SystemWidgetHelpers.createLabel(comp, ""); - //((GridData)filler.getLayoutData()).horizontalSpan = nbrColumns; - // SEPARATOR BEFORE OPTIONS - /* - SystemWidgetHelpers.createLabel(comp, ""); - addSeparatorLine(comp, 1); - SystemWidgetHelpers.createLabel(comp, ""); - */ - addFillerLine(comp, nbrColumns); - // OPTION CHECKBOXES - Composite options_composite = SystemWidgetHelpers.createTightComposite(comp, 3); - ((GridData) options_composite.getLayoutData()).horizontalSpan = nbrColumns; - // Prompt before - promptCB = SystemWidgetHelpers.createCheckBox(options_composite, 1, null, SystemUDAResources.RESID_UDA_OPTION_PROMPT_LABEL, SystemUDAResources.RESID_UDA_OPTION_PROMPT_TOOLTIP); - // Refresh after - refreshCB = SystemWidgetHelpers.createCheckBox(options_composite, 1, null, SystemUDAResources.RESID_UDA_OPTION_REFRESH_LABEL, SystemUDAResources.RESID_UDA_OPTION_REFRESH_TOOLTIP); - // Show action - showCB = SystemWidgetHelpers.createCheckBox(options_composite, 1, null, SystemUDAResources.RESID_UDA_OPTION_SHOW_LABEL, SystemUDAResources.RESID_UDA_OPTION_SHOW_TOOLTIP); - // Single selection only - singleSelCB = SystemWidgetHelpers.createCheckBox(options_composite, 1, null, SystemUDAResources.RESID_UDA_OPTION_SINGLESEL_LABEL, SystemUDAResources.RESID_UDA_OPTION_SINGLESEL_TOOLTIP); - // Collect names of selected object into delimited string - collectCB = SystemWidgetHelpers.createCheckBox(options_composite, 1, null, getInvokeOnceLabel(), getInvokeOnceTooltip()); - // SUBCLASS-SUPPLIED OPTION CHECKBOXES - Control[] extraOptions = createExtraOptionCheckBoxes(options_composite); - // SEPARATOR BEFORE TYPES - if (getUDActionSubsystem().supportsTypes()) { - //SystemWidgetHelpers.createLabel(comp, ""); - //typesSeparator = addSeparatorLine(comp, 1); - //SystemWidgetHelpers.createLabel(comp, ""); - addFillerLine(comp, nbrColumns); - } - //Label filler2 = SystemWidgetHelpers.createLabel(comp, ""); - //((GridData)filler2.getLayoutData()).horizontalSpan = nbrColumns; - // TYPE SELECTION FORM - if (udaActionSubsys != null) - selectTypesForm = createSelectTypesForm(parentDialog.getShell(), subsystem, udaActionSubsys); - else - { - // FIXME: Xuan - selectTypesForm = createSelectTypesForm(parentDialog.getShell(), profile); - } - if (selectTypesForm != null) { - selectTypesForm.createContents(comp, nbrColumns); - } - // CONFIGURE THE WIDGETS... - //resetButton = SystemWidgetHelpers.createPushButton(comp,this,rb,"com.ibm.etools.systems.core.ui.uda.ResetButton."); - //((GridData)resetButton.getLayoutData()).horizontalAlignment = GridData.BEGINNING; - textName.setTextLimit(ValidatorUserActionName.MAX_UDANAME_LENGTH); - textComment.setTextLimit(ValidatorUserActionComment.MAX_UDACMT_LENGTH); - //textName.setEditable(false); - //textComment.setEditable(false); - promptCB.addSelectionListener(this); - refreshCB.addSelectionListener(this); - showCB.addSelectionListener(this); - singleSelCB.addSelectionListener(this); - collectCB.addSelectionListener(this); - if (extraOptions != null) for (int idx = 0; idx < extraOptions.length; idx++) - if (extraOptions[idx] instanceof Button) - ((Button) extraOptions[idx]).addSelectionListener(this); - else if (extraOptions[idx] instanceof Combo) - ((Combo) extraOptions[idx]).addSelectionListener(this); - else if (extraOptions[idx] instanceof org.eclipse.swt.widgets.List) ((org.eclipse.swt.widgets.List) extraOptions[idx]).addSelectionListener(this); - if (selectTypesForm != null) selectTypesForm.addSelectionListener(this); - // ??? id ??? - // SystemWidgetHelpers.setHelp(comp, this, RSEUIPlugin.HELPPREFIX+"cprf0000"); - textName.addModifyListener(nameML); - textName.addFocusListener(nameFL); - textComment.addModifyListener(commentML); - commandField.addModifyListener(this); - return comp; - } - - protected String getInvokeOnceLabel() { - return SystemUDAResources.RESID_UDA_OPTION_COLLECT_LABEL; - } - - protected String getInvokeOnceTooltip() { - return SystemUDAResources.RESID_UDA_OPTION_COLLECT_TOOLTIP; - } - - /** - * Are errors pending? If so, don't allow user to change selection - * or profile or anything! - */ - public boolean areErrorsPending() { - return ((errorMessage != null) && ((currentAction != null) || newMode)); - } - - /** - * This is called when user changes their selection in the left-side tree view - */ - public void selectionChanged(SelectionChangedEvent se) { - if (recursiveCall) return; // ignore! - IStructuredSelection ss = (IStructuredSelection) se.getSelection(); - Object so = ss.getFirstElement(); - if (areErrorsPending()) { - if (newMode || SystemUDBaseManager.inCurrentTree(currentAction.getElement())) { - if (!newMode && (so != currentAction)) - treeView.setSelection(new StructuredSelection(currentAction)); - else if (newMode && (so != newModeNewItem)) treeView.setSelection(new StructuredSelection(newModeNewItem)); - return; - } - } - // We need to test for pending changes, and if any are pending, prompt - // user to continue (and lose changes) or cancel... - if ((stateMachine != null) && stateMachine.isSaveRequired()) { - saveData(); - if (newMode) { - // interesting problem! The save of the new data resulted in a new node, - // but this is not visible in the tree view. To make it visible means we - // we will lose focus, and this method will be recalled recursively... - recursiveCall = true; - treeView.refreshElementParent(currentAction); // show new item in tree view - recursiveCall = false; - if (so instanceof SystemUDActionElement) // if user was selecting an action, it might have a new binary address after the refresh - treeView.selectElement((SystemUDActionElement) so); - else if (so != null) treeView.setSelection(new StructuredSelection(so)); // restore what user selected - return; // avoid recursion! - } - } - recursiveCall = false; - // Clear any page-valid errors remaining from previous selection - // (Since validation on the new selection is only run if editing - // changes are made - errorMessage = null; - resetPageValidation(); - newMode = ((so instanceof SystemUDTreeViewNewItem) && ((SystemUDTreeViewNewItem) so).isExecutable()); - if (newMode) newModeDomain = ((SystemUDTreeViewNewItem) so).getDomain(); - // Refresh tree view if name changed on last item - if (nameChanged) { - nameChanged = false; - if (currentAction != null) treeView.refresh(currentAction); - } - SystemUDActionElement sn = null; - //temp = null; - if ((null != so) && (so instanceof SystemUDActionElement)) sn = (SystemUDActionElement) so; - currentAction = sn; - setIgnoreChanges(true); - boolean changeMode = false; - // entering un-selected mode? we turn invisible for this... - if (!newMode && ((null == sn) || sn.isDomain())) { - isEnabled = false; - textName.setText(""); //$NON-NLS-1$ - textComment.setText(""); //$NON-NLS-1$ - setCommandText(""); //$NON-NLS-1$ - enableExtraButtons(false); - } - // entering new or selected mode? we turn visible for this... - else if (newMode) { - isEnabled = true; - SystemCmdSubstVarList varList = null; - /* - if (!newMode) // existing action selected - { - textName.setText(sn.toString()); - textComment.setText(sn.getComment()); - setCommandText(sn.getCommand()); - - promptCB.setSelection(sn.getPrompt()); - refreshCB.setSelection(sn.getRefresh()); - showCB.setSelection(sn.getShow()); - singleSelCB.setSelection(sn.getSingleSelection()); - collectCB.setSelection( sn.getCollect()); - //if (singleSelCB.getSelection()) - collectCB.setEnabled(!singleSelCB.getSelection()); - resetExtraOptions(sn); - - varList = getActionSubstVarList(sn.getDomain()); - //setEditable(!parentDialog.isSelectionVendorSupplied(), parentDialog.getVendorOfSelection()); todo - } - else // new mode - {*/ - textName.setText(""); //$NON-NLS-1$ - textComment.setText(""); //$NON-NLS-1$ - setCommandText(""); //$NON-NLS-1$ - promptCB.setSelection(false); - refreshCB.setSelection(false); - showCB.setSelection(true); - singleSelCB.setSelection(false); - collectCB.setSelection(false); - resetExtraOptionsForNewMode(); - if (so != null) { - varList = getActionSubstVarList(((SystemUDTreeViewNewItem) so).getDomain()); - } - /*}*/ - // update the substitution variable list - //sourceViewerConfiguration.setSubstVarList(varList); - commandField.setSubstitutionVariableList(varList); - //varList.printDisplayStrings(); // temp. todo - remove - enableExtraButtons(true); - } - // existing action - else { - isEnabled = true; - changeMode = true; - setAction(sn); - } - setIgnoreChanges(false); // re-enable modify listeners - if (newMode) { - //System.out.println("entering New mode"); - stateMachine.setNewMode(); // resets Apply/Reset button status - newModeNewItem = (SystemUDTreeViewNewItem) so; - //System.out.println("newModeDomain = " + newModeDomain); - } else if ((sn == null) || sn.isDomain()) { - //System.out.println("entering Unset mode"); - stateMachine.setUnsetMode(); // resets Apply/Reset button status - } else { - //System.out.println("entering Edit mode"); - stateMachine.setEditMode(); // resets Apply/Reset button status } - } - if (isEnabled && (typesSeparator != null)) { - int domain = getDomain(); - if (domain == -1) - typesSeparator.setVisible(getUDActionSubsystem().supportsTypes()); - else - typesSeparator.setVisible(getUDActionSubsystem().supportsTypes(domain)); - } - if (!changeMode && (selectTypesForm != null)) // already done for change mode - reConfigureSelectTypesForm(selectTypesForm); - if (isEnabled && newMode) // we have already done it for new mode - { - if (grabFocus) { - textName.setFocus(); - } - //if (!wasEnabled) - if (nameValidator instanceof ISystemValidatorUniqueString) { - ((ISystemValidatorUniqueString) nameValidator).setExistingNamesList(getExistingActionNames()); - /* - System.out.println("...got existing names: "); - Vector v = getExistingActionNames(); - for (int idx=0; idx<v.size(); idx++) - System.out.print(v.elementAt(idx) + ", "); - System.out.println(); - */ - } - } - setPageComplete(); - } - - /** - * This is called when to set the input to an existing action - */ - public void setAction(SystemUDActionElement action) { - currentAction = action; - boolean currentIgnoreState = ignoreChanges; - setIgnoreChanges(true); - textName.setText(action.toString()); - textComment.setText(action.getComment()); - setCommandText(action.getCommand()); - promptCB.setSelection(action.getPrompt()); - refreshCB.setSelection(action.getRefresh()); - showCB.setSelection(action.getShow()); - singleSelCB.setSelection(action.getSingleSelection()); - collectCB.setSelection(action.getCollect()); - //if (singleSelCB.getSelection()) - collectCB.setEnabled(!singleSelCB.getSelection()); - resetExtraOptions(action); - // update the substitution variable list - commandField.setSubstitutionVariableList(getActionSubstVarList(action.getDomain())); - setIgnoreChanges(currentIgnoreState); // re-enable modify listeners - if (selectTypesForm != null) reConfigureSelectTypesForm(selectTypesForm); - if (grabFocus) textName.setFocus(); - if (nameValidator instanceof ISystemValidatorUniqueString) ((ISystemValidatorUniqueString) nameValidator).setExistingNamesList(getExistingActionNames()); - enableExtraButtons(true); - } - - /* - * Mouse and key listeners for mouse and key events in the tree. Used - * to determine focus for accessibility. - */ - /* - * Process the mouse down event. - */ - public void mouseDown(MouseEvent e) { - grabFocus = true; - } - - /* - * Process the mouse up event. - */ - public void mouseUp(MouseEvent e) { - grabFocus = true; - } - - /* - * Process the mouse double-click event. - */ - public void mouseDoubleClick(MouseEvent e) { - grabFocus = true; - } - - /* - * Process the key pressed event. - */ - public void keyPressed(KeyEvent e) { - grabFocus = false; - } - - /* - * Process the key released event. - */ - public void keyReleased(KeyEvent e) { - grabFocus = false; - } - - /** - * Return the current domain of the selected node or New item - */ - protected int getDomain() { - if (newMode) - return newModeDomain; - else if (currentAction != null) - return currentAction.getDomain(); - else - return -1; - } - - /** - * Revert button pressed - */ - public void revertPressed() { - if ((currentAction != null) && !currentAction.isDomain()) { - textName.setText(currentAction.toString()); - setCommandText(currentAction.getCommand()); - textComment.setText(currentAction.getComment()); - promptCB.setSelection(currentAction.getPrompt()); - refreshCB.setSelection(currentAction.getRefresh()); - showCB.setSelection(currentAction.getShow()); - singleSelCB.setSelection(currentAction.getSingleSelection()); - collectCB.setSelection(currentAction.getCollect()); - collectCB.setEnabled(!singleSelCB.getSelection()); - resetExtraOptions(currentAction); - if (selectTypesForm != null) selectTypesForm.setTypes(currentAction.getFileTypes()); - if (stateMachine != null) stateMachine.resetPressed(); - } else if (newMode) { - resetPageValidation(); - setIgnoreChanges(true); // disable modify listeners - textName.setText(""); //$NON-NLS-1$ - setCommandText(""); //$NON-NLS-1$ - textComment.setText(""); //$NON-NLS-1$ - promptCB.setSelection(false); - refreshCB.setSelection(false); - showCB.setSelection(true); - singleSelCB.setSelection(false); - collectCB.setSelection(false); - collectCB.setEnabled(true); - resetExtraOptionsForNewMode(); - if (selectTypesForm != null) selectTypesForm.resetTypes(); - setIgnoreChanges(false); // re-enable modify listeners - if (stateMachine != null) stateMachine.resetPressed(); - } - resetPageValidation(); // defect 45772 - //setPageComplete(); - } - - /** - * Process the apply button - */ - public void applyPressed() { - if ((newMode || ((currentAction != null) && !currentAction.isDomain())) && validateInput(true, null)) { - saveData(); - if (stateMachine != null) stateMachine.applyPressed(); - if (newMode) { - // Now update tree view to show new item - recursiveCall = true; - treeView.refreshElementParent(currentAction); - recursiveCall = false; - treeView.selectElement(currentAction); - } else - treeView.refresh(currentAction); - } - setPageComplete(); - } //apply - - // ------------------------------ - // OVERRIDABLE METHODS - // ------------------------------ - /** - * Overridable entry point for subclasses that wish to put something to the right of the "Command:" label - * From interface ISystemCommandTextAdditionalGUIProvider. - * @return true if something entered to take up the available columns, false otherwise (will be padded) - */ - public boolean createCommandLabelLineControls(Composite parent, int availableColumns) { - return false; - } - - /** - * Create additional buttons, to go under command prompt. - * Overridable. - * From interface ISystemCommandTextAdditionalGUIProvider. - * @return true if something entered to take up the available columns, false otherwise (will be padded) - */ - public boolean createExtraButtons(Composite parent, int availableColumns) { - return false; - } - - /** - * Create the select-types form. - * Override if you want to change the mri, but first call super.createSelectTypeForm()! - * Or override and return null to not prompt user for file types in your edit pane. - * @return the created form, or null if you don't wish to include the GUI for selecting types - */ - protected SystemUDSelectTypesForm createSelectTypesForm(Shell shell, ISubSystem subsystem, SystemUDActionSubsystem udaActionSubsys) { - - if (udaActionSubsys.supportsTypes()) - { - return new SystemUDSelectTypesForm(shell, subsystem, udaActionSubsys.getUDTypeManager()); - } - return null; - } - - /** - * Re-configure the type-selection form when the state changes. - * Important to set the input type lists (master and current selection) - * Overridable, but you MUST call super.xxx first! - */ - protected void reConfigureSelectTypesForm(SystemUDSelectTypesForm form) { - SystemUDActionSubsystem udas = getUDActionSubsystem(); - SystemUDTypeManager udtm = udas.getUDTypeManager(); - // Populate the listboxes - if (currentAction != null) { - //String domainName = udas.getDomainName(currentAction); - int domainType = currentAction.getDomain(); - if ((domainType != -1) && !udas.supportsTypes(domainType)) - form.setVisible(false); - else { - form.setVisible(true); - form.setMasterTypes(udtm.getTypeNames(currentAction.getDomain())); - form.setTypes(currentAction.getFileTypes()); - form.setDomain(domainType); - } - } else if (newMode) { - //form.reset(); - if ((newModeDomain != -1) && !udas.supportsTypes(newModeDomain)) { - form.setVisible(false); - } else { - form.setVisible(true); - form.setMasterTypes(udtm.getTypeNames(newModeDomain)); - form.resetTypes(); - form.setDomain(newModeDomain); - } - } else - form.reset(); - } - - /** - * Return the list of substitutation variables for the given domain type - */ - protected SystemCmdSubstVarList getActionSubstVarList(int actionDomainType) { - SystemCmdSubstVarList varList = getUDActionSubsystem().getActionSubstVarList(actionDomainType); - //varList.printDisplayStrings(); - return varList; - } - - /** - * Create additional option checkboxes, to go under default options. - * Overridable. - * @param parent - the options composite to place checkboxes in - * @return An array of the widgets created - */ - protected Control[] createExtraOptionCheckBoxes(Composite parent) { - return null; - } - - /** - * Enable/disable extra buttons added by subclass. - * Called when state changes - * Overridable - */ - protected void enableExtraButtons(boolean b) { - } - - /** - * Overridable method for saving data in subclass-supplied additional options - */ - protected void processExtraOptionsChanges(SystemUDActionElement currentAction) { - } - - /** - * Overridable method for resetting options in subclass-supplied additional options, - * when in "edit" mode - */ - protected void resetExtraOptions(SystemUDActionElement originalAction) { - } - - /** - * Overridable method for resetting options in subclass-supplied additional options, - * when in "new" mode - */ - protected void resetExtraOptionsForNewMode() { - } - - // ------------------------------ - // INTERNAL LISTENER METHODS... - // ------------------------------ - /** - * @see org.eclipse.swt.widgets.Listener#handleEvent(Event) - */ - public void handleEvent(Event arg0) { - } - - /** - * SelectionListener Interface: - * For the checkboxes - */ - public void widgetDefaultSelected(SelectionEvent e) { - } - - /** - * SelectionListener Interface: - * For the checkboxes - */ - public void widgetSelected(SelectionEvent e) { - if (!newMode && (currentAction == null)) return; - Object source = e.getSource(); - if (source == singleSelCB) { - if (singleSelCB.getSelection()) { - collectCB.setSelection(false); - collectCB.setEnabled(false); - } else - collectCB.setEnabled(true); - } - if ((source instanceof Button) || (source instanceof Combo)) { - //errorMessage = null; - //parentDialog.clearErrorMessage(); - validateInput(false, null); - } - setChangesMade(); - setPageComplete(); - } - - /** - * Scenario: User edits an item, producing a syntax error. - * (eg. clear action name field) Gets error msg, OK button disabled. - * then changes selection to another item. - * Current Problem: Error msg stays, OK remains disabled, until - * they edit a field. (ValidateInput isnt re-reun until - * another field is changed.) - * Solution: When changing selection, reset the errorMessage and - * page-valid status, since we are not saving invalid field changes . - * Need to add/remove listeners around selection changes, so - * I can set text fields without triggering modify event. - * So listeners implemented as internal classes - */ - private class NameModifyListener implements ModifyListener { - public void modifyText(ModifyEvent e) { - if (ignoreChanges) return; - setChangesMade(); - errorMessage = validateName(textName.getText().trim()); - if (errorMessage != null) { - parentDialog.setErrorMessage(errorMessage); - setPageComplete(); - } else { - validateInput(false, textName); - nameChanged = true; - } - } - } //class - - /** - * Focus listener for name field - */ - private class NameFocusListener implements FocusListener { - public void focusLost(FocusEvent event) { - if (ignoreChanges) return; - String name = textName.getText().trim().toLowerCase(); - if (name.startsWith(testActionName) && (textComment.getText().trim().length() == 0) && (getCommandText().length() == 0)) { - textComment.setText(getUDActionSubsystem().getTestFilePath()); - setCommandText(getUDActionSubsystem().getTestFileName()); - } - } - - public void focusGained(FocusEvent event) { - } - } - - /** - * Modify listener for comment field - */ - private class CommentModifyListener implements ModifyListener { - public void modifyText(ModifyEvent e) { - if (ignoreChanges) return; - setChangesMade(); - errorMessage = validateComment(textComment.getText().trim()); - if (errorMessage != null) { - parentDialog.setErrorMessage(errorMessage); - setPageComplete(); - } else - validateInput(false, textComment); - } - } //class - - /** - * From ISystemUDSelectTypeListener interface, called from - * SystemUDSelectTypesFrom widget. - * <p> - * The user has added or removed a type. - * Call getTypes() on given form to get the new list. - */ - public void selectedTypeListChanged(SystemUDSelectTypesForm form) { - setChangesMade(); - setPageComplete(); - validateInput(false, null); - } - - /** - * From ISystemUDSelectTypeListener interface, called from - * SystemUDSelectTypesFrom widget. - * <p> - * The user has edited the master list of types. It needs to be refreshed. - * We must call setMasterTypes() to update the form's master type list - */ - public void masterTypeListChanged(SystemUDSelectTypesForm form) { - SystemUDActionSubsystem udas = getUDActionSubsystem(); - SystemUDTypeManager udtm = udas.getUDTypeManager(); - // Re-populate the master listbox - if (currentAction != null) { - form.setMasterTypes(udtm.getTypeNames(currentAction.getDomain())); - } else if (newMode) { - form.setMasterTypes(udtm.getTypeNames(newModeDomain)); - } - } - - // ------------------------------ - // INTERNAL VALIDATION METHODS... - // ------------------------------ - /** - * Scenario: User edits an item, producing a syntax error. - * (eg. clear action name field) Gets error msg, OK button disabled. - * then changes selection to another item. - * Current Problem: Error msg stays, OK remains disabled, until - * they edit a field. (ValidateInput isnt re-reun until - * another field is changed.) - * <p> - * Solution: When changing selection, reset the errorMessage and - * page-valid status. Can get away with this because we - * do not propagate invalid field changes to the UDA data in memory. - */ - private void resetPageValidation() { - // setMessage( null); - errorMessage = null; - parentDialog.clearErrorMessage(); - parentDialog.setPageComplete(true); - } - - /** - * Check all input for errors. - * Subclasses should not override. Rather, they should override - * doAdditionalValidation(boolean) which this method calls. - * @param setFocus - true if to set focus on offending control - * @param skipControl - control to skip since already checked - * @return true if no errors - */ - protected final boolean validateInput(boolean setFocus, Control skipControl) { - Control errCtl = null; - errorMessage = null; - if (skipControl != textName) errorMessage = validateName(textName.getText().trim()); - errCtl = textName; - if ((errorMessage == null) && (skipControl != textComment)) { - errorMessage = validateComment(textComment.getText().trim()); - errCtl = textComment; - } - if ((errorMessage == null) && (skipControl != getCommandWidget())) { - errorMessage = validateCommand(); - errCtl = getCommandWidget(); - } - if (errorMessage == null) errorMessage = doAdditionalValidation(setFocus); // let child classes try - if (errorMessage != null) { - parentDialog.setErrorMessage(errorMessage); - if (setFocus) errCtl.setFocus(); - } else - parentDialog.clearErrorMessage(); - setPageComplete(); - return (errorMessage == null); - } - - /** - * Overridable extension point for subclasses to do validation of options and - * such when Apply is pressed. If you do report an error, consider setting the - * focus to the appropriate widget, if setFocus is set. - * @return error message if an error detected, else null - */ - protected SystemMessage doAdditionalValidation(boolean doSetFocus) { - return null; - } - - /** - * Validate name input - */ - protected SystemMessage validateName(String input) { - return nameValidator.validate(input); - } - - /** - * Validate comment input - */ - protected SystemMessage validateComment(String input) { - return cmtValidator.validate(input); - } - - /** - * Validate command input - */ - protected SystemMessage validateCommand() { - return commandField.validateCommand(); - } - - // ------------------------------------------- - // METHODS FOR USE BY US AND OUR CHILD CLASSES - // ------------------------------------------- - /** - * Return the control widget for the command prompt - */ - protected Control getCommandWidget() { - return commandField.getCommandWidget(); - } - - /** - * Set the text contents of the command widget - */ - protected void setCommandText(String text) { - commandField.setCommandText(text); - } - - /** - * Enable/disable command widget - */ - protected void enableCommandWidget(boolean enable) { - commandField.enableCommandWidget(enable); - } - - /** - * Get the contents of the command field - */ - protected String getCommandText() { - return commandField.getCommandText(); - } - - /** - * Turn on or off event ignoring flag - */ - protected void setIgnoreChanges(boolean ignore) { - ignoreChanges = ignore; - commandField.setIgnoreChanges(ignore); - } - - // ------------------------------ - // INTERNAL METHODS... - // ------------------------------ - /** - * Return true if the page is complete, so to enable Finish. - * Called by setPageComplete - */ - protected boolean isPageComplete() { - return ((errorMessage == null) && (textName.getText().trim().length() > 0) && (getCommandText().length() > 0)); - } - - /** - * Set page complete... enables/disables Apply button - */ - protected void setPageComplete() { - boolean complete = isPageComplete(); - parentDialog.setPageComplete(complete); - } - - /** - * When user presses Apply, commit all pending changes... - */ - protected void processChanges() { - currentAction.setComment(textComment.getText().trim()); - currentAction.setName(textName.getText().trim()); - String cmd = commandField.getMassagedCommandText(); - if (commandField.getCommandMassager() != null) { - if (!newMode) { - setIgnoreChanges(true); // disable modify listeners - setCommandText(cmd); - setIgnoreChanges(false); // re-enable modify listeners - } - } - currentAction.setCommand(cmd); - currentAction.setPrompt(promptCB.getSelection()); - currentAction.setRefresh(refreshCB.getSelection()); - currentAction.setShow(showCB.getSelection()); - currentAction.setSingleSelection(singleSelCB.getSelection()); - currentAction.setCollect(collectCB.getSelection()); - processExtraOptionsChanges(currentAction); - if (selectTypesForm != null) currentAction.setFileTypes(selectTypesForm.getTypes()); - } //process changes - - /** - * Save current state to disk - */ - protected void saveData() { - if (newMode) { - currentAction = createNewAction(textName.getText().trim(), newModeDomain); - } - processChanges(); - SystemUDActionSubsystem udas = getUDActionSubsystem(); - SystemUDActionManager udam = udas.getUDActionManager(); - ISystemProfile currentProfile = udam.getCurrentProfile(); - if (currentProfile == null) // shouldn't! - currentProfile = profile; - //subsystem.getUDActionSubsystem().getUDActionManager().saveUserData(); - udam.saveUserData(currentProfile); - // inform anybody registered as listeners that we have created/changed model object... - if (newMode) - RSECorePlugin.getTheSystemRegistry().fireModelChangeEvent(ISystemModelChangeEvents.SYSTEM_RESOURCE_ADDED, IUserActionsModelChangeEvents.SYSTEM_RESOURCETYPE_USERACTION, currentAction, null); - else - RSECorePlugin.getTheSystemRegistry().fireModelChangeEvent(ISystemModelChangeEvents.SYSTEM_RESOURCE_CHANGED, IUserActionsModelChangeEvents.SYSTEM_RESOURCETYPE_USERACTION, currentAction, null); - } - - /** - * Call this whenever the user makes ANY changes. - * Used to enable/disable apply/revert buttons - */ - protected void setChangesMade() { - if (stateMachine != null) stateMachine.setChangesMade(); - } - - /** - * In "new" mode, create a new action when Apply is pressed. - * This only creates the action. It does not populate the attributes - * @return The new action - */ - protected SystemUDActionElement createNewAction(String actionName, int domain) { - // code was originally in SystemNewUDAsWizardMainPage - SystemUDActionSubsystem udas = getUDActionSubsystem(); - SystemUDActionManager udam = udas.getUDActionManager(); - ISystemProfile currentProfile = udam.getCurrentProfile(); - if (currentProfile == null) // shouldn't! - currentProfile = profile; - SystemUDActionElement na = udam.addAction(currentProfile, actionName, domain); - // ??? handle failure ??? check for ??? - if (null != na) { - // Set default types to ALL, if ALL is not a type we create it with types string * - if (domain != SystemUDActionSubsystem.DOMAIN_NONE) { - SystemUDTypeManager typeManager = getUDActionSubsystem().getUDTypeManager(); - if (typeManager.findChildByName(currentProfile, SystemUDTypeManager.ALL_TYPE, domain) == null) { - SystemUDTypeElement nt = typeManager.addType(domain, SystemUDTypeManager.ALL_TYPE); - nt.setTypes("*"); //$NON-NLS-1$ - typeManager.saveUserData(currentProfile); - } - // Add the ALL type to the action - String[] types = new String[1]; - types[0] = SystemUDTypeManager.ALL_TYPE; - na.setFileTypes(types); - } - // Now update tree view to show new item, and set selection to it. - //SystemUDActionElement parentEl = (SystemUDActionElement) udas.getUDActionManager().getParent(na); - //treeView.internalRefresh(parentEl); - } - return na; - } - - /** - * For uniqueness checking, get the list of existing action names - */ - protected Vector getExistingActionNames() { - if (newMode) { - SystemUDActionSubsystem udas = getUDActionSubsystem(); - SystemUDActionManager udam = udas.getUDActionManager(); - ISystemProfile currentProfile = udam.getCurrentProfile(); - if (currentProfile == null) // shouldn't! - currentProfile = profile; - //System.out.println("Asking for existing names for newModeDomain " + newModeDomain); - return udam.getExistingNames(currentProfile, newModeDomain); - } else if (currentAction != null) - return currentAction.getExistingNames(); - else - return EMPTY_VECTOR; - } - - /** - * Callback from SystemCommandTextField when the user modifies the command. - * @param cmdText - current contents of the field - * @param errorMessage - potential error detected by the default validator - */ - public void commandModified(String cmdText, SystemMessage errorMessage) { - this.errorMessage = errorMessage; - setChangesMade(); - if (errorMessage != null) { - parentDialog.setErrorMessage(errorMessage); - setPageComplete(); - } else - validateInput(false, getCommandWidget()); - processCommandTextChange(cmdText, (errorMessage != null)); - } - - /** - * Method called as user types into the command field - * Encapsulated out so that it can be called from various types of listeners. - * Further, it is easily overridden - */ - protected void processCommandTextChange(String newText, boolean hasError) { - } - - // ----------------------------- - // Helper methods... - // ----------------------------- - /** - * Add a separator line. This is a physically visible line. - */ - protected Label addSeparatorLine(Composite parent, int nbrColumns) { - Label separator = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL); - GridData data = new GridData(); - data.horizontalSpan = nbrColumns; - data.horizontalAlignment = GridData.FILL; - separator.setLayoutData(data); - return separator; - } - - /** - * Add a spacer line - */ - protected Label addFillerLine(Composite parent, int nbrColumns) { - Label filler = new Label(parent, SWT.LEFT); - GridData data = new GridData(); - data.horizontalSpan = nbrColumns; - data.horizontalAlignment = GridData.FILL; - filler.setLayoutData(data); - return filler; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDActionElement.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDActionElement.java deleted file mode 100644 index 781888a7a..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDActionElement.java +++ /dev/null @@ -1,303 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.uda; - -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - *******************************************************************************/ -import java.util.StringTokenizer; - -import org.eclipse.rse.core.model.IProperty; -import org.eclipse.rse.core.model.IPropertySet; -import org.eclipse.rse.core.model.ISystemProfile; -import org.eclipse.rse.internal.useractions.UserActionsIcon; -import org.eclipse.swt.graphics.Image; - -/** - * Represents a single user defined action, as an adaptable - * eclipse-friendly object - */ -public class SystemUDActionElement extends SystemXMLElementWrapper { - private final static String ACTION_TAG = "Action"; //$NON-NLS-1$ - private final static String COMMENT_TAG = "Comment"; //$NON-NLS-1$ - private final static String COMMAND_TAG = "Command"; //$NON-NLS-1$ - private final static String FILETYPES_TAG = "FileTypes"; //$NON-NLS-1$ - private final static String PROMPT_ATTR = "Prompt"; //$NON-NLS-1$ - private final static String REFRESH_ATTR = "Refresh"; //$NON-NLS-1$ - private final static String COLLECT_ATTR = "Collect"; //$NON-NLS-1$ - private final static String SINGLESEL_ATTR = "SingleSelection"; //$NON-NLS-1$ - private final static String SHOW_ATTR = "Enable"; //$NON-NLS-1$ - //for reseting - private String initCommand; - private Object data; - - /** - * Constructor - * @param e - The actual xml document element for this action - * @param am - The subsystemFactory-specific manager of actions - * @param profile - The system profile which owns this action - * @param domainType - The integer representation of the domain this is in (or this is, for a domain element) - */ - public SystemUDActionElement(IPropertySet e, SystemUDActionManager am, ISystemProfile profile, int domainType) { - super(e, am, profile, domainType); - } - - /** - * Return the value of this node's "Name" attribute, but with "..." appended if - * the action is a prompting action. This is used for popup menu labels. - */ - public String getLabel() { - String name = getName(); - if (getPrompt()) name = name + "..."; //$NON-NLS-1$ - return name; - } - - /** - * Return image to use for this item, in tree views - */ - public Image getImage() { - if (isIBM()) { - if (isUserChanged()) - return UserActionsIcon.USERACTION_IBMUSR.getImage(); - else - return UserActionsIcon.USERACTION_IBM.getImage(); - } else - return UserActionsIcon.USERACTION_USR.getImage(); - } - - /** - * Return our tag name - */ - public String getTagName() { - return ACTION_TAG; - } - - /** - * Return value of the "Comment" sub-tag - */ - - public String getComment() { - //Get the property for this - IProperty commentProperty = elm.getProperty(COMMENT_TAG); - if (commentProperty != null) - { - return commentProperty.getValue(); - } - return ""; //$NON-NLS-1$ - } - - /** - * Return value of the "Command" sub-tag, which is the current command value - */ - public String getCommand() { - //Get the property for this - IProperty commentProperty = elm.getProperty(COMMAND_TAG); - if (commentProperty != null) - { - return commentProperty.getValue(); - } - return ""; //$NON-NLS-1$ - } - - /** - * Return value of the "Prompt" attribute - */ - public boolean getPrompt() { - return getBooleanAttribute(PROMPT_ATTR, false); - } - - /** - * Return value of the "Refresh" attribute - */ - public boolean getRefresh() { - return getBooleanAttribute(REFRESH_ATTR, false); - } - - /** - * Return value of the "Show" attribute - */ - public boolean getShow() { - return getBooleanAttribute(SHOW_ATTR, true); - } - - /** - * Return value of the "Collect" attribute - */ - public boolean getCollect() { - return getBooleanAttribute(COLLECT_ATTR, false); - } - - /** - * Return value of the "Single Selection" attribute - */ - public boolean getSingleSelection() { - return getBooleanAttribute(SINGLESEL_ATTR, false); - } - - /** - * Return value of the "FileTypes" sub-tag - */ - public String[] getFileTypes() { - //Get the property for this - IProperty fileTypeProperty = elm.getProperty(FILETYPES_TAG); - if (fileTypeProperty != null) - { - String fts = fileTypeProperty.getValue(); - // returns an empty string if no attribute - StringTokenizer st = new StringTokenizer(fts); - int n = st.countTokens(); - String sa[] = new String[n]; - for (int i = 0; i < n; i++) { - sa[i] = st.nextToken(); - } - return sa; - } - - return new String[0]; - } - - /** - * Set the value of the "Comment" sub-tag - */ - public void setComment(String s) { - IProperty commentProperty = elm.getProperty(COMMENT_TAG); - if (null != commentProperty) - { - commentProperty.setValue(s); - } - else - { - elm.addProperty(COMMENT_TAG, s); - } - - setUserChanged(true); - } - - /** - * Set the value of the "Command" sub-tag. - */ - public void setCommand(String s) { - IProperty commandProperty = elm.getProperty(COMMAND_TAG); - if (null != commandProperty) - { - commandProperty.setValue(s); - } - else - { - elm.addProperty(COMMAND_TAG, s); - } - setUserChanged(true); - } - - /** - * Set the value of the "Prompt" attribute - */ - public void setPrompt(boolean b) { - setBooleanAttribute(PROMPT_ATTR, b); - setUserChanged(true); - } - - /** - * Set the value of the "Refresh" attribute - */ - public void setRefresh(boolean b) { - setBooleanAttribute(REFRESH_ATTR, b); - setUserChanged(true); - } - - /** - * Set the value of the "Show" attribute - */ - public void setShow(boolean b) { - setBooleanAttribute(SHOW_ATTR, b); - setUserChanged(true); - } - - /** - * Set the value of the "Collect" attribute - */ - public void setCollect(boolean b) { - setBooleanAttribute(COLLECT_ATTR, b); - setUserChanged(true); - } - - /** - * Set the value of the "Single Selection Only" attribute - */ - public void setSingleSelection(boolean b) { - setBooleanAttribute(SINGLESEL_ATTR, b); - setUserChanged(true); - } - - /** - * Set the value of the "FileTypes" sub-tag - */ - public void setFileTypes(String sa[]) { - String s = ""; //$NON-NLS-1$ - for (int i = 0; i < sa.length; i++) { - s = s + " " + sa[i]; //$NON-NLS-1$ - } - - IProperty fileTypeProperty = elm.getProperty(FILETYPES_TAG); - if (null != fileTypeProperty) - { - fileTypeProperty.setValue(s); - } - else - { - elm.addProperty(FILETYPES_TAG, s); - } - - setUserChanged(true); - } - - // *************************************** - // Determing file type matches - // *************************************** - /** - * Is this action's file types a generic value - */ - public boolean isGeneric() { - // ?? may not be optimal - String fts[] = getFileTypes(); - if (0 == fts.length) return true; - for (int i = 0; i < fts.length; i++) { - if ("*".equals(fts[i])) //$NON-NLS-1$ - return true; - } - return true; - } - - /** - * Set the initial command value - */ - public void setInitCommand(String s) { - this.initCommand = s; - } - - /** - * Get the initial command value - */ - public String getInitCommand() { - return this.initCommand; - } - - /** - * Set data. Useful when used in context like trees. - */ - public void setData(Object data) { - this.data = data; - } - - /** - * Return data as set by setData - */ - public Object getData() { - return data; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDActionManager.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDActionManager.java deleted file mode 100644 index 885da96e4..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDActionManager.java +++ /dev/null @@ -1,200 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - * David Dykstal (IBM) - [186589] move user actions API out of org.eclipse.rse.ui - *******************************************************************************/ -package org.eclipse.rse.internal.useractions.ui.uda; - -import java.util.Vector; - -import org.eclipse.core.resources.IFolder; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.rse.core.model.IPropertySet; -import org.eclipse.rse.core.model.ISystemProfile; -import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; -import org.eclipse.rse.internal.useractions.UserActionsIcon; -import org.eclipse.rse.internal.useractions.UserActionsPersistenceUtil; -import org.eclipse.swt.graphics.Image; - -/** - * Instances of this class hold the UDA definitions unique to: - * <ol> - * <li>The SystemProfile - according to the subsystem - * <li>The SubSystem type - according to the subclassed SystemUDActionSubsystem - * </ol> - * Instances of this class will be linked to a SubSystem instance - * - * - * Eventually, would hope to create a factory method for this class which will - * return existing instances common to the subsystems of different connections - * within the same profile. - */ -public class SystemUDActionManager extends SystemUDBaseManager -// implements ErrorHandler, - implements ITreeContentProvider { - private static final String XE_ROOT = ISystemUDAConstants.ACTIONS_ROOT; - private static final String XE_ACTION = "Action"; //$NON-NLS-1$ - - /** - * Constructor - */ - public SystemUDActionManager(SystemUDActionSubsystem udas) { - super(udas); - } - - /** - * Return true if this is user actions, false if this is named types. - */ - protected boolean isUserActionsManager() { - return true; - } - - /** - * Get the icon to show in the tree views, for the "new" expandable item - */ - public Image getNewImage() { - return UserActionsIcon.USERACTION_NEW.getImage(); - } - - /** - * Parent method override for returning the "New" icon label for the Work With dialog tree view. - * For us, we defer to the getActionSubSystem().{@link SystemUDActionSubsystem#getNewNodeActionLabel() getNewNodeActionLabel()}. - * Do not override this. - * @return translated value for "New" in new icon for WW action and type dialogs. Default is "New" - */ - protected String getNewNodeLabel() { - return getActionSubSystem().getNewNodeActionLabel(); - } - - /** - * Overridable method for child classes to do migration of their document. - * This is called on first load of a document, which has a release stamp other than - * the current release - * @return true if any migration was done - */ - protected boolean doMigration(ISystemProfile profile, String oldRelease) { - return getActionSubSystem().doActionsMigration(profile, oldRelease); - } - - /** - * Get the document root tag name. - * We return "Actions" - */ - public String getDocumentRootTagName() { - return XE_ROOT; // "Actions" - } - - /** - * Do we uppercase the value of the "Name" attribute? - * No, we don't for actions. - */ - protected boolean uppercaseName() { - return false; - } - - /** - * Return true if the elements managed by this class are scoped by - * profile. Usually true for actions, false for types - */ - public boolean supportsProfiles() { - return true; - } - - /** - * Prime the given document with any default actions/types - * Should be overridden! - */ - public SystemXMLElementWrapper[] primeDocument(ISystemProfile profile) { - if (profile.isDefaultPrivate()) // we only prime the user's private profile with default actions - return getActionSubSystem().primeDefaultActions(this, profile); - else - return null; - } - - /** - * Get the folder containing the xml file used to persist the actions, - * for the given profile - */ - protected IFolder getDocumentFolder(ISubSystemConfiguration subsystemFactory, ISystemProfile profile) { - return UserActionsPersistenceUtil.getUserActionsFolder(profile.getName(), subsystemFactory); - } - - /** - * Intended for IMPORT actions only, where no Subsystem instance available: - */ - public void setFolder(String profileName, String factoryId) { - importCaseFolder = UserActionsPersistenceUtil.getUserActionsFolder(profileName, factoryId); - } - - /** - * Add a user-defined action - */ - public SystemUDActionElement addAction(ISystemProfile profile, String name, int domain) { - return (SystemUDActionElement) super.addElement(profile, domain, name); - } - - /** - * Return xml element wrapper objects for all actions, for the - * given domain, or for the whole document if domain is -1 (iff - * domains not supported). - * @param v - existing vector to populate. If null passed, it is - * not populated. - * @param profile - the profile to limit the search to - * @param domain - the integer representation of the given domain, - * or -1 iff supportsDomains() is false - * @return array of action objects - */ - public SystemUDActionElement[] getActions(Vector v, ISystemProfile profile, int domain) { - v = super.getXMLWrappers(v, domain, profile); - if (v == null) return new SystemUDActionElement[0]; - SystemUDActionElement[] actions = new SystemUDActionElement[v.size()]; - for (int idx = 0; idx < actions.length; idx++) - actions[idx] = (SystemUDActionElement) v.elementAt(idx); - return actions; - } - - /** - * Return all the actions for the given profile, in all domains. - * @param v - existing vector to populate. If null passed, it is not populated. - * @param profile - the profile to limit the search to - * @return array of action objects - */ - public SystemUDActionElement[] getAllActions(Vector v, ISystemProfile profile) { - if (!getActionSubSystem().supportsDomains()) return getActions(v, profile, -1); - if (v == null) v = new Vector(); - int nbrDomains = getActionSubSystem().getMaximumDomain() + 1; - for (int domain = 0; domain < nbrDomains; domain++) { - super.getXMLWrappers(v, domain, profile); - } - SystemUDActionElement[] actions = new SystemUDActionElement[v.size()]; - for (int idx = 0; idx < actions.length; idx++) - actions[idx] = (SystemUDActionElement) v.elementAt(idx); - return actions; - } - - // ----------------------------------------------------------- - // ISystemXMLElementWrapperFactory - // ----------------------------------------------------------- - /** - * Return the tag name for our managed elements. - * Eg: will be "Action" for user actions, and "Type" for file types. - */ - public String getTagName() { - return XE_ACTION; - } - - /** - * Given an xml element node, create an instance of the appropriate - * subclass of SystemXMLElementWrapper to represent it. - */ - public SystemXMLElementWrapper createElementWrapper(IPropertySet xmlElementToWrap, ISystemProfile profile, int domain) { - SystemUDActionElement elementWrapper = new SystemUDActionElement(xmlElementToWrap, this, profile, domain); - return elementWrapper; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDActionSubsystem.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDActionSubsystem.java deleted file mode 100644 index 41dcf2a4c..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDActionSubsystem.java +++ /dev/null @@ -1,1159 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core - * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API - * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry - * David McKnight (IBM) - [225506] [api][breaking] RSE UI leaks non-API types - * Kevin Doyle (IBM) - [241015] Add getActionSubstVarList(SystemUDActionElement) - * Kevin Doyle (IBM) - [241866] Refresh After doesn't work for User Actions - *******************************************************************************/ - -package org.eclipse.rse.internal.useractions.ui.uda; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.PrintWriter; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.StringTokenizer; -import java.util.Vector; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.rse.core.RSECorePlugin; -import org.eclipse.rse.core.events.ISystemResourceChangeEvents; -import org.eclipse.rse.core.events.ISystemResourceChangeListener; -import org.eclipse.rse.core.events.SystemResourceChangeEvent; -import org.eclipse.rse.core.model.ISystemProfile; -import org.eclipse.rse.core.model.ISystemRegistry; -import org.eclipse.rse.core.subsystems.ISubSystem; -import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; -import org.eclipse.rse.internal.useractions.UserActionsIcon; -import org.eclipse.rse.internal.useractions.ui.ISystemSubstitutor; -import org.eclipse.rse.internal.useractions.ui.SystemCmdSubstVarList; -import org.eclipse.rse.services.clientserver.messages.SystemMessage; -import org.eclipse.rse.shells.ui.RemoteCommandHelpers; -import org.eclipse.rse.subsystems.files.core.model.RemoteFileUtility; -import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCmdSubSystem; -import org.eclipse.rse.ui.ISystemMessages; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.SystemBasePlugin; -import org.eclipse.rse.ui.messages.SystemMessageDialog; -import org.eclipse.rse.ui.view.ISystemEditableRemoteObject; -import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter; -import org.eclipse.rse.ui.view.SystemTableViewProvider; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.dialogs.ListSelectionDialog; -import org.eclipse.ui.model.AdaptableList; -import org.eclipse.ui.model.WorkbenchContentProvider; - -/** - * Provide the interface to customize and implement the user-defined actions support - * for the subsystems which implement it. Subsystems are expected to override - * these methods as required. - * <p> - * For some subsystem factories, actions and types can be partitioned/scoped by - * "domain". Eg, for iSeries actions are scoped by object and member, and each - * has unique lists of actions and types. - * This base class offers all the support for supporting domains, but it is triggered - * by the method supportsDomains() which is overridden by child classes appropriately. - * <p> - * Some subsystems will support named types by which actions can be scoped. This - * support is triggered by supportsTypes(), which returns true by default but can - * be overridden by childclasses. - */ -public abstract class SystemUDActionSubsystem implements ISystemSubstitutor { - public final static int DOMAIN_NONE = -1; - protected ISubSystem _subsystem; // May be null for an import action - protected ISubSystemConfiguration subsystemFactory; // for use in Team view where we show user actions per SSF. - protected SystemUDActionManager udActionManager; - protected SystemUDTypeManager udTypeManager; - protected SystemUDAResolvedTypes udaResolvedTypes; - protected SystemUDActionElement currentAction; // current action being processed - protected boolean testAction; // is current action the test action? - protected String osType = "default"; //$NON-NLS-1$ - - /** - * Constructor - */ - public SystemUDActionSubsystem() { - super(); - //this._subsystem = subsys; - } - - /** - * Overridable method for child classes to do migration of their actions. - * This is called on first load of a document, which has a release stamp other than - * the current release - * @return true if any migration was done - */ - protected abstract boolean doActionsMigration(ISystemProfile profile, String oldRelease); - - /** - * Overridable method for child classes to do migration of their types. - * This is called on first load of a document, which has a release stamp other than - * the current release - * @return true if any migration was done - */ - protected abstract boolean doTypesMigration(ISystemProfile profile, String oldRelease); - - /** - * Overridable method for child classes to supply the label to display in the - * "New" node for actions. Typically only overridden if domains are not supported, - * as otherwise the child nodes of "New" have the specific labels.<br> - * If not overridden, then "New" is used. - * @return translated label - */ - protected String getNewNodeActionLabel() { - return SystemUDAResources.ACTION_CASCADING_NEW_LABEL; - } - - /** - * Overridable method for child classes to supply the label to display in the - * "New" node for type. Typically only overridden if domains are not supported, - * as otherwise the child nodes of "New" have the specific labels.<br> - * If not overridden, then "New" is used. - * @return translated label - */ - protected String getNewNodeTypeLabel() { - return SystemUDAResources.ACTION_CASCADING_NEW_LABEL; - } - - /** - * Get the singleton manager of user-defined actions for this subsystem factory - */ - public SystemUDActionManager getUDActionManager() { - if (udActionManager == null) udActionManager = new SystemUDActionManager(this); - return udActionManager; - } - - /** - * Get the singleton manager of named file types for this subsystem factory - */ - public SystemUDTypeManager getUDTypeManager() { - if ((udTypeManager == null) && supportsTypes()) udTypeManager = new SystemUDTypeManager(this); - return udTypeManager; - } - - /** - * Return the list of substitution variables for the given domain type. - * Called from edit pane in work with dialog. - * This must be overridden! - */ - public abstract SystemCmdSubstVarList getActionSubstVarList(int actionDomainType); - - /** - * Return the list of substitution variables for the given UDA action. - */ - public SystemCmdSubstVarList getActionSubstVarList(SystemUDActionElement action) - { - int actionDomainType = action.getDomain(); - return getActionSubstVarList(actionDomainType); - } - - /** - * Retrieve current subsystem - */ - public ISubSystem getSubsystem() { - return _subsystem; - } - - /** - * Set current subsystem - */ - public void setSubsystem(ISubSystem ss) { - _subsystem = ss; - if (ss != null) setSubSystemFactory(ss.getSubSystemConfiguration()); - } - - /** - * Retrieve current subsystem factory. Useful when we don't have a subsystem - */ - public ISubSystemConfiguration getSubSystemFactory() { - return subsystemFactory; - } - - /** - * Set current subsystem factory. Useful when we don't have a subsystem - */ - public void setSubSystemFactory(ISubSystemConfiguration ssf) { - subsystemFactory = ssf; - } - - /** - * Return true if actions can be scoped by file types - * Default is true - */ - public boolean supportsTypes() { - return true; - } - - /** - * Return true if actions can be scoped by file types for the given domain. - * Default is supportsTypes() - */ - public boolean supportsTypes(int domain) { - return supportsTypes(); - } - - /** - * Return true if the action/type manager supports domains. - * Default is false - */ - public boolean supportsDomains() { - return false; - } - - /** - * In some cases, we supports domains in general, but only want to expose - * one of those domains to the user. For example, for file subsystems, - * we support folder and file domains, but for named types we really only - * support the file domain. - * <p> - * Default is -1 - */ - public int getSingleDomain(SystemUDBaseManager docManager) { - return -1; - } - - // ************************************************************** - // User Interface: Adding Menu Actions, etc. - // ************************************************************** - /** - * Return the action's edit pane. - * Subclasses should override if they want to return their own edit pane. - * @param ss - the subsystem if you have it. If you don't have it, pass null. - * @param ssFactory - the subsystem factory, if you don't have the subsystem. - * @param profile - the subsystem factory, if you don't have the subsystem. - * @param parent - the hosting dialog/property page - * @param tv - the tree view if the parent is a dialog. - * */ - public SystemUDActionEditPane getCustomUDActionEditPane(ISubSystem ss, ISubSystemConfiguration ssFactory, ISystemProfile profile, ISystemUDAEditPaneHoster parent, ISystemUDTreeView tv) { - return new SystemUDActionEditPane(this, parent, tv); - } - - /** - * Historical. - * Now replaced with {@link #getCustomUDActionEditPane(ISubSystem, ISubSystemConfiguration, ISystemProfile, ISystemUDAEditPaneHoster, ISystemUDTreeView)} - */ - protected final SystemUDActionEditPane getCustomUDActionEditPane(ISubSystem ss, ISystemUDAEditPaneHoster parent, ISystemUDTreeView tv) { - return getCustomUDActionEditPane(ss, null, null, parent, tv); - } - - /** - * Historical. - * Now replaced with {@link #getCustomUDActionEditPane(ISubSystem, ISubSystemConfiguration, ISystemProfile, ISystemUDAEditPaneHoster, ISystemUDTreeView)} - */ - protected final SystemUDActionEditPane getCustomUDActionEditPane(ISubSystemConfiguration ssFactory, ISystemProfile profile, ISystemUDAEditPaneHoster parent, ISystemUDTreeView tv) { - return getCustomUDActionEditPane(null, ssFactory, profile, parent, tv); - } - - /** - * Subclasses may override to provide a custom type edit pane subclass. - * Subclasses should override if they want to return their own types pane. - * @param parent - the hosting dialog/property page - * @param tv - the tree view if the parent is a dialog. - */ - public SystemUDTypeEditPane getCustomUDTypeEditPane(ISystemUDAEditPaneHoster parent, ISystemUDTreeView tv) { - return new SystemUDTypeEditPane(this, parent, tv); - } - - // ************************************************************** - // Accessing UDA/UDT's in memory/storage: - // ************************************************************** - /** - * Prime the user data with the default types. - */ - public abstract SystemUDTypeElement[] primeDefaultTypes(SystemUDTypeManager udtd); - - /** - * Prime the user data with the default actions. Subsystem and profile specific - */ - public abstract SystemUDActionElement[] primeDefaultActions(SystemUDActionManager udad, ISystemProfile profile); - - /** - * Given this IBM-supplied user action, restore it to its IBM-supplied state. - * @return true if all went well, false if it wasn't restore for some reason - */ - public boolean restoreDefaultAction(SystemUDActionElement element, int domain, String actionName) { - return false; - } - - /** - * Given this IBM-supplied named type, restore it to its IBM-supplied state - * @return true if all went well, false if it wasn't restore for some reason - */ - public boolean restoreDefaultType(SystemUDTypeElement element, int domain, String typeName) { - return false; - } - - // ************************************************************** - // Running commands: - // ************************************************************** - /** - * Return the command name that tells us this is an action for testing substitution variables. - * <p> - * Returns "ibm test action" - */ - public String getTestActionName() { - return "ibm test action"; //$NON-NLS-1$ - } - - /** - * Return the default name of the test file in test mode. - * The test file is generated at action run-time when the action name is {@link #getTestActionName()}. - * <p> - * Returns "TESTUSERACTION.TXT" - */ - public String getTestFileName() { - return "TESTUSERACTION.TXT"; //$NON-NLS-1$ - } - - /** - * Return the default path of the test file in test mode - * The test file is generated at action run-time when the action name is {@link #getTestActionName()}. - * <p> - * Returns "c:\\Test_RSE_User_Actions" - */ - public String getTestFilePath() { - return "c:\\Test_RSE_User_Actions"; //$NON-NLS-1$ - } - - /** - * Overriddable method for printing out information about the collected names - * for "invoke once" actions, when in test mode. - */ - protected void printTestActionInvokeOnceInformation(Shell shell, PrintWriter writer) { - } - - /** - * When the user selects one or more objects in the RSE, then right clicks - * and selects a user action, this method is called (by the SystemUDAsBaseAction - * class). - * <p> - * For each selected object, the action's command is resolved (variable substitution done) - * by calling doCommandSubstitution, and then run by calling runCommand(...). - * @param shell - the shell to use for display the prompt, if appropriate - * @param action - the user action to run - * @param selection - the currently selected objects - * @param viewer - the viewer we are running this from. Used to do the refresh if requested in this action. Can be null. - */ - public void run(Shell shell, SystemUDActionElement action, IStructuredSelection selection, ISystemResourceChangeListener viewer) { - //Assert.isLegal(shell != null, "shell argument is null"); //$NON-NLS-1$ - processingSelection(true); - Iterator elements = selection.iterator(); - this.currentAction = action; - IRemoteCmdSubSystem cmdSubSystem = null; - boolean runOnce = action.getCollect(); - boolean actionRunEvenOnce = false; - boolean cancelled = false; - /* - * DKM - I've taken the linebreak stripping out. Now we intend to support - * batches of commands. The interpreting of line breaks is now - * delegated to implementors of runCommand() - */ - String command = action.getCommand(); - // what is test action? For testing purposes, creating an action with this name means - // generating a local file to prove the variable substitution works... - testAction = action.getName().toLowerCase().startsWith(getTestActionName()); - File testFile = null; - PrintWriter testWriter = null; - if (testAction) { - this.currentAction = action; - try { - String testFileDir = action.getComment(); - if ((testFileDir == null) || (testFileDir.trim().length() == 0)) testFileDir = getTestFilePath(); - File testDir = new File(testFileDir); - if (!testDir.exists()) { - testDir.mkdir(); - } - String testFileName = command; - if ((testFileName == null) || (testFileName.trim().length() == 0)) testFileName = getTestFileName(); - testFile = new File(testDir, testFileName); - String message = "In test action mode. Output file is: {0}"; //$NON-NLS-1$ - message = MessageFormat.format(message, new Object[] { testFile.getAbsolutePath() }); - SystemBasePlugin.logInfo(message); - testWriter = new PrintWriter(new FileOutputStream(testFile)); - getActionSubstVarList(action.getDomain()).printDisplayStrings(testWriter); - } catch (Exception exc) { - if (testFile != null) { - String message = "Error creating test file {0} for user actions:"; //$NON-NLS-1$ - message = MessageFormat.format(message, new Object[] { testFile.getAbsolutePath() }); - SystemBasePlugin.logError(message, exc); - } - return; - } - } - // ------------------------------------------------------------ - // THIS ACTION IS TO BE RUN ONCE PER SELECTED OBJECT - // ------------------------------------------------------------ - try { - if (checkDirtyEditors(selection)) { - if (!runOnce) { - Object selectedObject = null; - while (!cancelled && elements.hasNext()) { - selectedObject = elements.next(); - //cmdSubSystemContext = selectedObject; - if (cmdSubSystem == null) { - cmdSubSystem = getCommandSubSystem(selectedObject); - } - if (testAction) { - SystemCmdSubstVarList supportedVariables = getActionSubstVarList(action.getDomain()); - String[] substitutedVariables = supportedVariables.doAllSubstitutions(selectedObject, this); - if (testWriter != null) { - testWriter.println("Selected Object: " + getRemoteAdapter(selectedObject).getAbsoluteName(selectedObject)); //$NON-NLS-1$ - for (int idx = 0; idx < substitutedVariables.length; idx++) { - testWriter.println("....." + substitutedVariables[idx]); //$NON-NLS-1$ - } - } - } else { - String cmd = doCommandSubstitutions(action, command, selectedObject); - // Prompt support - if (action.getPrompt()) { - // Prompt user and allow to edit the command. Honor their request to cancel - cmd = promptCommand(shell, cmd); - if (cmd == null) cancelled = true; - } - if (!cancelled) cancelled = !runCommand(shell, action, cmd, cmdSubSystem, selectedObject, (Viewer) viewer); - if (!cancelled && !actionRunEvenOnce) actionRunEvenOnce = true; - } // end else !testAction - } // end while loop - } // end if !runOnce - // ------------------------------------------------------------ - // THIS ACTION IS TO BE RUN ONCE ONLY, FOR ALL SELECTED OBJECTS - // ------------------------------------------------------------ - else { - StringBuffer collectedNames = new StringBuffer(); - Object firstSelectedObject = collectNames(shell, elements, collectedNames); - if (firstSelectedObject == null) // happens when something goes wrong. Msg already shown to user - return; - String nameVar = getAllNamesSubstitutionVariable(); - String cmd = command; - if (nameVar != null) { - if (testAction) cmd = nameVar; - int nameVarIdx = cmd.indexOf(nameVar); - if (nameVarIdx >= 0) { - cmd = cmd.substring(0, nameVarIdx) + collectedNames.toString() + cmd.substring(nameVarIdx + nameVar.length()); - } - } - if (testAction && testWriter != null) { - SystemCmdSubstVarList supportedVariables = getActionSubstVarList(action.getDomain()); - String[] substitutedVariables = supportedVariables.doAllSubstitutions(firstSelectedObject, this); - testWriter.println("First Selected Object: " + getRemoteAdapter(firstSelectedObject).getAbsoluteName(firstSelectedObject)); //$NON-NLS-1$ - if (nameVar != null) testWriter.println("....." + nameVar + " = " + cmd); //$NON-NLS-1$ //$NON-NLS-2$ - for (int idx = 0; idx < substitutedVariables.length; idx++) - testWriter.println("....." + substitutedVariables[idx]); //$NON-NLS-1$ - printTestActionInvokeOnceInformation(shell, testWriter); - } else { - cmd = doCommandSubstitutions(action, cmd, firstSelectedObject); - // Prompt support - if (action.getPrompt()) { - // Prompt user and allow to edit the command. Honor their request to cancel - cmd = promptCommand(shell, cmd); - if (cmd == null) cancelled = true; - } - if (!cancelled) { - cmdSubSystem = getCommandSubSystem(firstSelectedObject); - cancelled = !runCommand(shell, action, cmd, cmdSubSystem, firstSelectedObject, (Viewer) viewer); - } - if (!cancelled) actionRunEvenOnce = true; - } // end else !testAction - } // end else runOnce - // ANYTHING GO WRONG?? - } - } catch (Exception exc) { - SystemMessageDialog.displayExceptionMessage(shell, exc); - System.out.println("Error running user action " + command + ": " + exc.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$ - return; - } - // ------------------------------------------------------------ - // REFRESH VIEW IF REQUESTED IN ACTION - // ------------------------------------------------------------ - if (actionRunEvenOnce && action.getRefresh()) { - ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry(); - try { - Thread.sleep(500L); - } catch (Exception exc) { - } // defect 46380: give action's command time to run? I don't know, but this works! - if (viewer != null) { - sr.fireEvent(viewer, new SystemResourceChangeEvent(selection.toArray(), ISystemResourceChangeEvents.EVENT_REFRESH_REMOTE, null)); - } else { - sr.fireEvent(new SystemResourceChangeEvent(selection.toArray(), ISystemResourceChangeEvents.EVENT_REFRESH_REMOTE, null)); - } - // todo! verify we are sending the right event! ok, done... its the right one. - } - if (testWriter != null && testFile != null) { - testWriter.flush(); - testWriter.close(); - SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_GENERIC_I_HELP); - msg.makeSubstitution("Test file " + testFile.getName() + " generated successfully", "The file was generated in directory " + testFile.getParent()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - SystemMessageDialog dlg = new SystemMessageDialog(shell, msg); - dlg.openWithDetails(); - } - processingSelection(false); - } // end method - - /** - * After an action's command has been resolved (vars substituted) this method - * is called to actually do the remote command execution - * @param shell - the shell to use if need to prompt for password or show msg dialog - * @param action - the action being processed, in case attributes of it need to be queried - * @param cmdString - the resolved command - * @param cmdSubSystem - this connection's command subsystem, which will run the command - * @param context - any context information the subsystem's runCommand might need - * @return true if we should continue, false if something went wrong - */ - protected boolean runCommand(Shell shell, SystemUDActionElement action, String cmdString, IRemoteCmdSubSystem cmdSubSystem, Object context, Viewer viewer) { - boolean ok = false; - if (cmdSubSystem != null) { - ok = true; - try { - cmdSubSystem.runCommand(cmdString, context, new NullProgressMonitor()); - } catch (Exception e) { - SystemBasePlugin.logError("RunUserAction", e); //$NON-NLS-1$ - SystemMessageDialog.displayExceptionMessage(shell, e); - ok = false; - } - } // end if - return ok; - } // end method - - /** - * Called when user selects a user action to run, from the base user - * action class. Called by our run(...) method - */ - protected String doCommandSubstitutions(SystemUDActionElement action, String cmd, Object selectedObject) { - this.currentAction = action; - SystemCmdSubstVarList supportedVariables = getActionSubstVarList(action); - return supportedVariables.doSubstitutions(cmd, selectedObject, this); - } // end method - - /** - * When processing an action that has elected to be invoked only once, versus - * once per selected object, we call this method to collect the names of the - * selected objects into a single string buffer. - * <p> - * This can be overridden if need be. The default behaviour is to concatenate - * the quoted absolute name of each selected object. - * - * @return first selected object, or null if something went wrong (msg will have been issued) - */ - protected Object collectNames(Shell shell, Iterator elements, StringBuffer collectedNames) { - return collectNamesDefaultMethod(shell, elements, collectedNames); - } // end method - - /** - * Allows subclasses to call it even if their immediate parent overrides - */ - protected Object collectNamesDefaultMethod(Shell shell, Iterator elements, StringBuffer collectedNames) { - Object firstSelectedObject = null; - while (elements.hasNext()) { - Object selectedObject = elements.next(); - if (firstSelectedObject == null) - firstSelectedObject = selectedObject; - else - collectedNames.append(" "); //$NON-NLS-1$ - collectedNames.append(getNameDelimiter()); - collectedNames.append(getRemoteAdapter(selectedObject).getAbsoluteName(selectedObject)); - collectedNames.append(getNameDelimiter()); - } // end while loop - return firstSelectedObject; - } // end method - - /** - * When processing an action that has elected to be invoked only once, versus - * once per selected object, we call this method to get the "all names" - * substitution variable so that we can substitute it with the collection - * of names of all selected objects. - * <p> - * The default is "${resource_name}", but can be overridden. - */ - protected String getAllNamesSubstitutionVariable() { - return "${resource_name}"; //$NON-NLS-1$ - } - - /** - * When processing an action that has elected to be invoked only once, versus - * once per selected object, we call this method to get the delimiter - * character to surround each name in. - * <p> - * The default is a double quote, but can be overridden. For example, for iSeries - * native file systems, this is overridden with a single quote. - */ - protected char getNameDelimiter() { - return '\"'; - } - - /** - * Called when processing user action that has the "prompt" attribute set. - * By default, puts up dialog allowing user to see and edit the fully resolved command. - * @param shell - the shell to host the modal dialog - * @param command - the fully resolved (variables substituted) command - * @return the edited command string, or null if the user pressed cancel - */ - protected String promptCommand(Shell shell, String command) { - return promptCommandDefault(shell, command); - } - - /** - * This allows child classes to call this directly - */ - protected String promptCommandDefault(Shell shell, String command) { - SystemPromptUDADialog dialog = new SystemPromptUDADialog(shell, command); - dialog.open(); - if (!dialog.wasCancelled()) - return dialog.getCommand(); - else - return null; - } - - /** - * Get the command subsystem associated the given remote object - */ - protected static IRemoteCmdSubSystem getCommandSubSystem(Object selectedObject) { - return RemoteCommandHelpers.getCmdSubSystem(getRemoteAdapter(selectedObject).getSubSystem(selectedObject).getHost()); - } - - /** - * Get the first file subsystem associated the given remote object. - * May return null! - */ - protected static IRemoteFileSubSystem getFileSubSystem(Object selectedObject) { - IRemoteFileSubSystem[] rfsss = RemoteFileUtility.getFileSubSystems(getCommandSubSystem(selectedObject).getHost()); - if ((rfsss != null) && (rfsss.length > 0)) - return rfsss[0]; - else - return null; - } - - /** - * Returns the implementation of ISystemRemoteElement for the given - * object. Returns null if this object does not adaptable to this. - */ - protected static ISystemRemoteElementAdapter getRemoteAdapter(Object o) { - if (!(o instanceof IAdaptable)) - return (ISystemRemoteElementAdapter) Platform.getAdapterManager().getAdapter(o, ISystemRemoteElementAdapter.class); - else - return (ISystemRemoteElementAdapter) ((IAdaptable) o).getAdapter(ISystemRemoteElementAdapter.class); - } - - /** - * From the interface ISystemSubstitutor. - * <p> - * Return the string to substitute for the given substitution - * variable, given the current context object. This object will - * be passed whatever was passed into the doSubstitution method. - * <p>It is VERY IMPORTANT to return null if you can't do the - * substitution for some reason! This is a clue to the algorithm - * that no change was made and increases performance. - * <p> - * We try to handle common substitutions here in the base class, and - * pass on any other requests to the child classes via a call to - * internalGetSubstitutionValue(String var, Object context) - */ - public String getSubstitutionValue(String subvar, Object context) { - return getCommonSubstitutionValues(subvar, context); - } - - /** - * This abstraction allows child subclasses to override getSubstitutionValues, yet - * grandchild subclasses to still call this common class if needed. - */ - public String getCommonSubstitutionValues(String subvar, Object context) { - // ${action_name} = This user defined action name - if (subvar.equals("${action_name}")) //$NON-NLS-1$ - return currentAction.toString(); - // ${connection_name} = The connection in which this action is launched - if (subvar.equals("${connection_name}")) //$NON-NLS-1$ - return getCommandSubSystem(context).getHost().getAliasName(); - // ${user_id} = The user ID that was used to signon with - else if (subvar.equals("${user_id}")) //$NON-NLS-1$ - return getCommandSubSystem(context).getConnectorService().getUserId(); - // ${system_tempdir} = The fully qualified temp directory in remote system - else if (subvar.equals("${system_tempdir}")) //$NON-NLS-1$ - return getCommandSubSystem(context).getConnectorService().getTempDirectory(); - // ${system_homedir} = The fully qualified home directory in remote system, for current user - else if (subvar.equals("${system_homedir}")) //$NON-NLS-1$ - return getCommandSubSystem(context).getConnectorService().getHomeDirectory(); - // ${system_pathsep} = The path separator. ';' on Windows, ':' on Unix and Linux - else if (subvar.equals("${system_pathsep}")) //$NON-NLS-1$ - { - IRemoteFileSubSystem rfss = getFileSubSystem(context); - if (rfss != null) - return rfss.getParentRemoteFileSubSystemConfiguration().getPathSeparator(); - else - return "system_pathsep not available"; // hopefully will never happen //$NON-NLS-1$ - } - // ${system_filesep} = The file separator. '\\' on Windows, '/' on Unix and Linux - else if (subvar.equals("${system_filesep}")) //$NON-NLS-1$ - { - IRemoteFileSubSystem rfss = getFileSubSystem(context); - if (rfss != null) - return rfss.getParentRemoteFileSubSystemConfiguration().getSeparator(); - else - return "system_filesep not available"; // hopefully will never happen //$NON-NLS-1$ - } - // ${system_hostname} = The host name of the remote system - else if (subvar.equals("${system_hostname}")) //$NON-NLS-1$ - return getCommandSubSystem(context).getHost().getHostName(); - // ${local_hostname} = The host name of the local system - else if (subvar.equals("${local_hostname}")) //$NON-NLS-1$ - return RSECorePlugin.getLocalMachineName(); - // ${local_ip} = The ip address of the local system - else if (subvar.equals("${local_ip}")) //$NON-NLS-1$ - return RSECorePlugin.getLocalMachineIPAddress(); - // ---------------------------------------------------------------------- - // We leave it to each subsystem plugin to define the following, as they - // will each define their own mri for the display text. However, we can - // do the substitutions right here as it generic code... - // ---------------------------------------------------------------------- - // ${resource_name} = The name of the selected object - else if (subvar.equals("${resource_name}")) //$NON-NLS-1$ - return getRemoteAdapter(context).getName(context); - // ${resource_path} = The fully qualified name of the selected resource - else if (subvar.equals("${resource_path}")) //$NON-NLS-1$ - return getRemoteAdapter(context).getAbsoluteName(context); - else - return internalGetSubstitutionValue(currentAction, subvar, context); - } - - /** - * Overridable extension point for child class to do variable substitution for variables unique to them. - * - */ - public abstract String internalGetSubstitutionValue(SystemUDActionElement currentAction, String substitutionVariable, Object context); - - /** - * - */ - public boolean hasUnsupportedSubstitutionVars(Object action, int domain) { - return false; - } - - /** - * Check to see it any actions will apply to this selection. - * Stop checking as soon as 1 action is found. - * This method is an optimized, find-1-only, version of addUserActions() below. - * May be overriden for subsystem specific filtering of actions - * <b>CURRENTLY WE JUST RETURN TRUE</b> - */ - public boolean eligibleUserActionsForSelection(IStructuredSelection selection, ISystemProfile profile) { - return true; // todo. Maybe ... doesn't seem worth it! - } - - /** - * Populate context menu ("User Actions->" cascading action) with user - * actions that meet their type-scoping criteria for given selection. - * <p> - * If given a profile, the list is scoped to that, else it includes actions - * for all active profiles. - */ - public Action[] addUserActions(IMenuManager menu, IStructuredSelection selection, ISystemProfile profile, Shell shell) { - // access UDA tree for this subsystem - SystemUDActionManager actMgr = getUDActionManager(); - // Go through each profile for this subsystem's factory - ISystemProfile[] profiles = null; - if (profile == null) - profiles = getActiveSystemProfiles(); - else - profiles = new ISystemProfile[] { profile }; - int domain = -1; - if (supportsDomains()) { - domain = getDomainFromSelection(selection); - if (domain == -1) - return new Action[0]; - } - boolean multiSelection = (selection.size() != 1); - ArrayList actionList = new ArrayList(); - for (int idx = 0; idx < profiles.length; idx++) { - profile = profiles[idx]; - SystemUDActionElement[] actionElements = actMgr.getActions(null, profile, domain); - // Scan UDA's for matching types and add to menu. - // if any match, then create the initial UDA submenu cascade item - for (int i = 0; i < actionElements.length; i++) { - SystemUDActionElement actionElement = actionElements[i]; - if (!actionElement.getShow()) continue; - if (multiSelection && actionElement.getSingleSelection()) continue; - if (supportsDomains() && (domain != actionElement.getDomain())) continue; // newly added... we were getting file actions on folders - if (!supportsTypes() || meetsSelection(actionElement, selection, domain)) { - SystemUDAsBaseAction uda = new SystemUDAsBaseAction(actionElement, shell, this); - uda.setSelection(selection); - uda.setShell(shell); - uda.setEnabled(!getWorkingOfflineMode()); - actionList.add(uda); - if (null != menu) - { - menu.add(uda); - } - - } - } // end for-loop - } // end for all profiles loop - Action[] list = (Action[])actionList.toArray(new Action[]{}); - - return list; - - } - - /** - * We disable user defined actions if we are in work-offline mode. - * Currently, how we determine this is dependent on the subsystem factory. - */ - public boolean getWorkingOfflineMode() { - return false; - } - - /** - * Determine domain, given the selection. - * Eg subsystem that supports domains has to do this via overriding this method. - * If domains not supported, return -1. - */ - protected abstract int getDomainFromSelection(IStructuredSelection selection); - - /** - * Given an action, and the currently selected remote objects, and the domain of those, - * return true if ALL of the selected remote objects matches any of the type criteria - * for this action - */ - protected boolean meetsSelection(SystemUDActionElement action, IStructuredSelection selection, int domainType) { - String unresolvedActionTypes[] = action.getFileTypes(); - // fastpath for "ALL"! - if ((unresolvedActionTypes == null) || (unresolvedActionTypes.length == 0)) - return true; // what else to do? - else if (unresolvedActionTypes[0].equals("ALL")) //$NON-NLS-1$ - return true; - Object actionTypes[] = resolveTypes(unresolvedActionTypes, domainType); - Iterator elements = selection.iterator(); - Object element = null; - while (elements.hasNext()) { - element = elements.next(); - // OK if matches any one of the file types for an action - boolean foundMatch = false; - for (int j = 0; !foundMatch && (j < actionTypes.length); j++) { - // compare current unnamed type to current selected object - if (isMatch(actionTypes[j], element, domainType)) { - foundMatch = true; - break; - } - } // for j - if (!foundMatch) return false; - } - return true; - } - - /** - * Given a list of names that represent named types, - * resolve that into a concatenated list of all types for - * the given type names. - * <p> - * Basically, this concatenates all the subtypes together. - * However, it also weeds out any redundancies - */ - protected String[] resolveTypes(String[] p_types, int domainType) { - Vector types = new Vector(); - for (int i = 0; i < p_types.length; i++) { - String fileTypes = getFileTypesForTypeName(p_types[i], domainType); - if (fileTypes != null) { - StringTokenizer st = new StringTokenizer(fileTypes, getTypesDelimiter()); - int n = st.countTokens(); - for (int j = 0; j < n; j++) { - String token = st.nextToken().trim(); - if (types.indexOf(token) < 0) types.addElement(token); - } - } - } - String[] allTypes = new String[types.size()]; - for (int idx = 0; idx < allTypes.length; idx++) - allTypes[idx] = (String) types.elementAt(idx); - return allTypes; - } - - /** - * Given a named-type name and a domain, find that type element and - * return the types for that named type. - */ - private String getFileTypesForTypeName(String name, int domainType) { - if (udaResolvedTypes == null) udaResolvedTypes = getResolvedTypesHelper(); - return udaResolvedTypes.getFileTypesForTypeName(name, domainType, getUDTypeManager()); - } - - /** - * Compares a particular file type (not named, but actual scalar/generic type) - * to a specific user-selected remote object. - * Returns true if the object's information matches that of the given type - * <p> - * Must be overridden, but only called if supportsTypes() returns true. - * Else, just return true! - * @param actionType - an unnamed file type, as in "*.cpp" - * @param selectedObject - one of the currently selected remote objects - * @param domainType - integer representation of current domain - */ - protected abstract boolean isMatch(Object actionType, Object selectedObject, int domainType); - - /** - * Get the delimiter used to delimiter the types in a type string. - * Default is " " - */ - protected String getTypesDelimiter() { - return " "; //$NON-NLS-1$ - } - - /** - * - */ - public void resetResolvedTypes() { - udaResolvedTypes = null; - } - - /** - * - */ - public SystemUDAResolvedTypes getResolvedTypesHelper() { - return new SystemUDAResolvedTypes(); - } - - // --------------------------------------------------------------------------- - // NEW METHODS MOVED DOWN TO ABSTRACT-OUT/ENCAPSULATE THE NOTION OF DOMAINS... - // DONE BY PHIL IN RELEASE 2. - // PREVIOUSLY DOMAINS ONLY INTRODUCED IN THE ISERIES SUBCLASS FOR NATIVE FILES - // XML SYNTAX FOR A DOMAIN: - // <Domain Name="XlatedDomainName" Type="DomainName" - // --------------------------------------------------------------------------- - /** - * For efficiency reasons, internally we use an integer to represent a domain. - * However, that has to be mapped to a name which is actually what is stored as the - * "name" attribute for the xml domain node. - * This returns the maximum integer number supported by this action/type manager. - * Returns -1 by default. - * Needs to be overridden by children that support domains - */ - public int getMaximumDomain() { - return -1; - } - - /** - * For efficiency reasons, internally we use an integer to represent a domain. - * However, that has to be mapped to a name which is actually what is stored as the - * "type" attribute for the xml domain node. - * <p>XML ATTRIBUTE SYNTAX FOR A DOMAIN: - * <code> - * <Domain Name="XlatedDomainName" Type="DomainName"/> - * </code> - * This maps the given integer to its domain name. - * Returns null by default. - * Needs to be overridden by children that support domains - */ - public String mapDomainName(int domainInteger) { - if ((domainInteger >= 0) && (domainInteger <= getMaximumDomain())) - return getDomainNames()[domainInteger]; - else - return null; - } - - /** - * Map a given untranslated domain name to its integer value - */ - public int mapDomainName(String domainName) { - String[] domainNames = getDomainNames(); - int match = -1; - if ((domainNames != null) && (domainNames.length > 0)) { - for (int idx = 0; (match == -1) && (idx < domainNames.length); idx++) - if (domainNames[idx].equals(domainName)) match = idx; - } - return match; - } - - /** - * For efficiency reasons, internally we use an integer to represent a domain. - * However, that has to be mapped to a translated name occasionally for the UI, - * and indeed the translated name is stored in the XML in the "Name" attribute. - * <p>XML ATTRIBUTE SYNTAX FOR A DOMAIN: - * <code> - * <Domain Name="XlatedDomainName" Type="DomainName"/> - * </code> - * This maps the given integer to its translated domain name. - * Returns null by default. - * Needs to be overridden by children that support domains - */ - public String mapDomainXlatedName(int domainInteger) { - if ((domainInteger >= 0) && (domainInteger <= getMaximumDomain())) - return getXlatedDomainNames()[domainInteger]; - else - return null; - } - - /** - * Same as above but specifically for what is shown in the work with user actions dialog for the new element - */ - public String mapDomainXlatedNewName(int domainInteger) { - if ((domainInteger >= 0) && (domainInteger <= getMaximumDomain())) - return getXlatedDomainNewNames()[domainInteger]; - else - return null; - } - - /** - * Same as above but specifically for what is shown in the work with named types dialog for the new element - */ - public String mapDomainXlatedNewTypeName(int domainInteger) { - if ((domainInteger >= 0) && (domainInteger <= getMaximumDomain())) - return getXlatedDomainNewTypeNames()[domainInteger]; - else - return null; - } - - /** - * Get the list of untranslated domain names - */ - public String[] getDomainNames() { - return null; - } - - /** - * Get the list of translated domain names - */ - public String[] getXlatedDomainNames() { - return null; - } - - /** - * Get the list of translated domain names for use in the tree view, for the "New" nodes, - * in the Work With User Actions dialog. - */ - public String[] getXlatedDomainNewNames() { - return null; - } - - /** - * Get the list of translated domain names for use in the tree view, for the "New" nodes, - * in the Work With User Types dialog. - */ - public String[] getXlatedDomainNewTypeNames() { - return null; - } - - /** - * Get the domain icon to show in the tree views - */ - public Image getDomainImage(int domain) { - return null; - } - - /** - * Get the domain icon to show in the tree views, for the new item for this domain - */ - public Image getDomainNewImage(int domain) { - return UserActionsIcon.USERACTION_NEW.getImage(); - } - - /** - * Get the domain icon to show in the named type tree view, for the new item for this domain - */ - public Image getDomainNewTypeImage(int domain) { - return UserActionsIcon.USERTYPE_NEW.getImage(); - } - - /** - * Get the active system profiles - */ - protected ISystemProfile[] getActiveSystemProfiles() { - return RSECorePlugin.getTheSystemRegistry().getActiveSystemProfiles(); - } - - protected List getDirtyEditors(IStructuredSelection sel) { - List dirtyEditors = new ArrayList(); - List selection = sel.toList(); - for (int i = 0; i < selection.size(); i++) { - Object selected = selection.get(i); - if (selected instanceof IAdaptable) { - ISystemEditableRemoteObject editable = getEditableFor((IAdaptable) selected); - if (editable != null) { - try { - // is the file being edited? - if (editable.checkOpenInEditor() == 0) { - // reference the editing editor - editable.openEditor(); - // file is open in editor - prompt for save - if (editable.isDirty()) { - dirtyEditors.add(editable); - } - } - } catch (Exception e) { - } - } - } - } - return dirtyEditors; - } - - protected ISystemEditableRemoteObject getEditableFor(IAdaptable selected) { - ISystemRemoteElementAdapter adapter = (ISystemRemoteElementAdapter) selected.getAdapter(ISystemRemoteElementAdapter.class); - if (adapter.canEdit(selected)) { - ISystemEditableRemoteObject editable = adapter.getEditableRemoteObject(selected); - try { - editable.setLocalResourceProperties(); - } catch (Exception e) { - } - return editable; - } - return null; - } - - protected boolean checkDirtyEditors(IStructuredSelection selection) { - List dirtyEditors = getDirtyEditors(selection); - if (dirtyEditors.size() > 0) { - AdaptableList input = new AdaptableList(); - for (int i = 0; i < dirtyEditors.size(); i++) { - ISystemEditableRemoteObject rmtObj = (ISystemEditableRemoteObject) dirtyEditors.get(i); - input.add(rmtObj.getRemoteObject()); - } - WorkbenchContentProvider cprovider = new WorkbenchContentProvider(); - SystemTableViewProvider lprovider = new SystemTableViewProvider(); - // TODO: Cannot use WorkbenchMessages -- it's internal - ListSelectionDialog dlg = new ListSelectionDialog(SystemBasePlugin.getActiveWorkbenchShell(), input, cprovider, lprovider, SystemUDAResources.EditorManager_saveResourcesMessage); - dlg.setInitialSelections(input.getChildren()); - dlg.setTitle(SystemUDAResources.EditorManager_saveResourcesTitle); - int result = dlg.open(); - //Just return false to prevent the operation continuing - if (result == IDialogConstants.CANCEL_ID) return false; - Object[] filesToSave = dlg.getResult(); - for (int s = 0; s < filesToSave.length; s++) { - IAdaptable rmtObj = (IAdaptable) filesToSave[s]; - ISystemEditableRemoteObject editable = getEditableFor(rmtObj); - editable.doImmediateSaveAndUpload(); - } - } - return true; - } - - /** - * Method called at the start and end of running user actions - * This allows children a chance to perform some action before and after - * the actions are run by overriding this method. - * @param processingSelection true before proecssing, false after processing - */ - protected void processingSelection(boolean processingSelection) { - } - - public String getOSType() - { - return osType; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDActionTreeView.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDActionTreeView.java deleted file mode 100644 index e9f511f39..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDActionTreeView.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core - * David Dykstal (IBM) - [186589] move user types, user actions, and compile commands - * API to the user actions plugin - *******************************************************************************/ -package org.eclipse.rse.internal.useractions.ui.uda; - -import org.eclipse.jface.viewers.IBasicPropertyConstants; -import org.eclipse.rse.core.model.ISystemProfile; -import org.eclipse.rse.core.subsystems.ISubSystem; -import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; -import org.eclipse.rse.internal.useractions.IUserActionsModelChangeEvents; -import org.eclipse.swt.widgets.Composite; - -/** - * In the Work With User Defined Actions dialog, this is the - * tree view for showing the existing actions. - */ -public class SystemUDActionTreeView extends SystemUDBaseTreeView { - /** - * Constructor when we have a subsystem - */ - public SystemUDActionTreeView(Composite parent, ISystemUDWorkWithDialog editPane, ISubSystem ss, SystemUDActionSubsystem udaActionSubsystem) { - super(parent, editPane, ss, udaActionSubsystem.getUDActionManager()); - } - - /** - * Constructor when we have a subsystem factory - */ - public SystemUDActionTreeView(Composite parent, ISystemUDWorkWithDialog editPane, ISubSystemConfiguration ssFactory, ISystemProfile profile) { - super(parent, editPane, ssFactory, profile, - // FIXME - UDA can't be coupled with subsystem API - //((ISubsystemFactoryAdapter)ssFactory.getAdapter(ISubsystemFactoryAdapter.class)).getActionSubSystem(ssFactory, null).getUDActionManager() - null); - } - - /** - * Return the {@link org.eclipse.rse.core.events.ISystemModelChangeEvents} constant representing the resource type managed by this tree. - * This is a parent class override. - */ - protected int getResourceType() { - return IUserActionsModelChangeEvents.SYSTEM_RESOURCETYPE_USERACTION; - } - - /** - * Parent override. - * Restore the selected action to its IBM-supplied default value. - */ - public void doRestore() { - SystemXMLElementWrapper selectedElement = getSelectedElement(); - if ((selectedElement == null) || !(selectedElement instanceof SystemUDActionElement)) return; - SystemUDActionElement action = (SystemUDActionElement) selectedElement; - boolean ok = getDocumentManager().getActionSubSystem().restoreDefaultAction(action, action.getDomain(), action.getOriginalName()); - if (ok) { - action.setUserChanged(false); - getDocumentManager().saveUserData(profile); - selectElement(selectedElement); - String[] allProps = { IBasicPropertyConstants.P_TEXT, IBasicPropertyConstants.P_IMAGE }; - update(selectedElement, allProps); - } - } - - // ------------------------------------ - // HELPER METHODS CALLED FROM EDIT PANE - // ------------------------------------ - /** - * Select the given action - */ - public void selectAction(SystemUDActionElement element) { - super.selectElement(element); - } - - /** - * Refresh the parent of the given action. - * That is, find the parent and refresh the children. - * If the parent is not found, assume it is because it is new too, - * so refresh the whole tree. - */ - public void refreshActionParent(SystemUDActionElement element) { - super.refreshElementParent(element); - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDAsBaseAction.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDAsBaseAction.java deleted file mode 100644 index 3de6841cb..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDAsBaseAction.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 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 - * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core - *******************************************************************************/ - -package org.eclipse.rse.internal.useractions.ui.uda; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.rse.core.events.ISystemResourceChangeListener; -import org.eclipse.rse.internal.useractions.UserActionsIcon; -import org.eclipse.rse.ui.actions.SystemBaseAction; -import org.eclipse.swt.widgets.Shell; - -/** - * Base action for user-defined actions, shown in the "User actions->" menu. - * When one of these is run, it does variable substitution and runs the command. - */ -public class SystemUDAsBaseAction extends SystemBaseAction { - private SystemUDActionSubsystem udaSubsystem; - private SystemUDActionElement action; - - public SystemUDAsBaseAction(SystemUDActionElement action, Shell parent, SystemUDActionSubsystem udasubsys) { - super(action.getLabel(), action.isIBM() ? UserActionsIcon.USERACTION_IBM.getImageDescriptor() : UserActionsIcon.USERACTION_USR.getImageDescriptor(), parent); - this.udaSubsystem = udasubsys; - this.action = action; - allowOnMultipleSelection(true); - // yantzi: artemis60, set SystemConnection to enable the offline support to - // automatically disable UDA when the system connection is offline - setHost(udasubsys.getSubsystem().getHost()); - } - - /** - * This is the method called when the user selects this action. - * Child classes need to override this. If you need the parent shell, - * call getShell. If you need to know the current selection, call - * getSelection(), or getFirstSelection() followed by getNextSelection() - * until null is returned. - * @see Action#run() - */ - public void run() { - IStructuredSelection selection = getSelection(); - if (viewer instanceof ISystemResourceChangeListener) - udaSubsystem.run(getShell(), action, selection, (ISystemResourceChangeListener) viewer); - else - udaSubsystem.run(getShell(), action, selection, null); - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDBaseManager.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDBaseManager.java deleted file mode 100644 index 1dd75639b..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDBaseManager.java +++ /dev/null @@ -1,1350 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - * Martin Oberhuber (Wind River) - [180562][api] dont implement ISystemUDAConstants - * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry - * David Dykstal (IBM) - [186589] move user types, user actions, and compile commands - * API to the user actions plugin - * Xuan Chen (IBM) - [222263] Need to provide a PropertySet Adapter for System Team View (cleanup some use action stuff) - * Kevin Doyle (IBM) - [222825] NPE when changing profile on Work with User Actions Dialog - * Kevin Doyle (IBM) - [222828] Icons for some Actions Missing - * Kevin Doyle (IBM) - [240725] Add Null Pointer checking when there are no default user actions - * Kevin Doyle (IBM) - [239702] Copy/Paste doesn't work with User Defined Actions and Named Types - * Kevin Doyle (IBM) - [222829] MoveUp/Down Broken in Work with User Actions Dialog - * Xuan Chen (IBM) - [246807] [useractions] - Command Command property set from different os and subsystem are all shown as "Compile Commands" in Team view - *******************************************************************************/ - -package org.eclipse.rse.internal.useractions.ui.uda; - -import java.util.Hashtable; -import java.util.Vector; - -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceChangeEvent; -import org.eclipse.core.resources.IResourceChangeListener; -import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.rse.core.RSECorePlugin; -import org.eclipse.rse.core.SystemResourceManager; -import org.eclipse.rse.core.model.IProperty; -import org.eclipse.rse.core.model.IPropertySet; -import org.eclipse.rse.core.model.IPropertySetContainer; -import org.eclipse.rse.core.model.ISystemProfile; -import org.eclipse.rse.core.model.PropertySet; -import org.eclipse.rse.core.subsystems.ISubSystem; -import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; -import org.eclipse.rse.services.clientserver.messages.SystemMessage; -import org.eclipse.rse.ui.ISystemIconConstants; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.SystemBasePlugin; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.model.IWorkbenchAdapter; -import org.xml.sax.SAXException; -import org.xml.sax.SAXParseException; - - -/** - * Instances of this class hold the UDA definitions unique to - * <ol> - * <li> The SystemProfile - according to the subsystem - * <li> the SubSystem type - according to the SubSystemFactory - * </ol> - * Instances of this class will be linked to a SubSystem instance - * Eventually, would hope to create a factory method for this class which will - * return existing instances common to the subsystems of different connections - * within the same profile. - * <p> - * When used for IMPORT: NO SubSystem instance available. Will be NULL! - * <p> - * This is the base class for both action managers and types managers. - * Only action managers are actually scoped by profile. - * <p> - * Architecturally, this class and the SystemXMLElementWrapper class - * encapsulate all knowledge of the fact the underlying store is a xml document. - */ -public abstract class SystemUDBaseManager implements IResourceChangeListener, ISystemXMLElementWrapperFactory, ITreeContentProvider { - // state - protected SystemUDActionSubsystem _udas; - protected IFolder importCaseFolder; // Only set during Import processing - private SystemUDTreeViewNewItem[] newItemsPerDomain; - private boolean ignoreMyResourceChange = false; // avoid recursion - // profile-indexed state. - // Access to these is carefully guarded, for the case when - // a subclass does not support profiles. - private Hashtable udocsByProfile; - private Hashtable hasChangedByProfile; - private Hashtable dirPathByProfile; - // used by subclasses that are not profile-indexed - private IPropertySet udocNoProfile; - private boolean hasChangedNoProfile = false; - private Object[] dirPathNoProfile; - // Profile for which we are working for actions for... - private ISystemProfile currentlyActiveProfile; // set in UDA GUI - // Clipboard copy/paste support - private IPropertySet currentNodeClone = null; - private String currentNodeCloneID = ""; //$NON-NLS-1$ - // private String currentNodeCloneName = ""; //$NON-NLS-1$ - private int currentNodeCloneDomain = -1; - // constants - protected static final Object[] EMPTY_ARRAY = new Object[0]; - /** - * Current release as a string. Eg "5.0" - */ - private static final String CURRENT_RELEASE_NAME = RSECorePlugin.CURRENT_RELEASE_NAME; //"5.1.2"; // Historical from when part of iSeries. - - /** - * Constructor - */ - public SystemUDBaseManager(SystemUDActionSubsystem udas) { - super(); - _udas = udas; - if (supportsProfiles()) { - udocsByProfile = new Hashtable(); - hasChangedByProfile = new Hashtable(); - dirPathByProfile = new Hashtable(); - } - addListener(); - } - - /** - * Return the action subsystem object - */ - public SystemUDActionSubsystem getActionSubSystem() { - return _udas; - } - - /** - * Get the icon to show in the tree views, for the "new" expandable item - */ - public Image getNewImage() { - return RSEUIPlugin.getDefault().getImage(ISystemIconConstants.ICON_SYSTEM_NEW_ID); - } - - // ----------------------------------------------------------- - // ISystemXMLElementWrapperFactory - // ----------------------------------------------------------- - /** - * Return the tag name for our managed elements. - * Eg: will be "Action" for user actions, and "Type" for file types. - */ - public abstract String getTagName(); - - /** - * Given an xml element node, create an instance of the appropriate - * subclass of SystemXMLElementWrapper to represent it. - */ - public abstract SystemXMLElementWrapper createElementWrapper(IPropertySet xmlElementToWrap, ISystemProfile profile, int domain); - - // ----------------------------------------------------------- - // ITREECONTENTPROVIDER METHODS... - // ----------------------------------------------------------- - /** - * Returns the implementation of IWorkbenchAdapter for the given - * object. Returns null if the adapter is not defined or the - * object is not adaptable. - */ - protected IWorkbenchAdapter getAdapter(Object o) { - if (!(o instanceof IAdaptable)) return null; - return (IWorkbenchAdapter) ((IAdaptable) o).getAdapter(IWorkbenchAdapter.class); - } - - public void dispose() { - // To be safe, we clear the parent profile name when the tree is disposed, - // so it doesn't linger. This will happen because we only instantiate ourselves - // once and then always re-use that instance. - setCurrentProfile(null); - } - - /** - * Method declared on ITreeContentProvider. - * We return null. - */ - public Object getParent(Object element) { - return null; - } - - /** - * Method declared on ITreeContentProvider. - */ - public boolean hasChildren(Object element) { - //return getChildren(element).length > 0; - if (element instanceof SystemUDTreeViewNewItem) { - if (getActionSubSystem().supportsDomains()) - return !((SystemUDTreeViewNewItem) element).isExecutable(); - else - return false; - } else if (element instanceof SystemXMLElementWrapper) { - if (getActionSubSystem().supportsDomains()) { - SystemXMLElementWrapper wrapper = (SystemXMLElementWrapper) element; - if (!wrapper.isDomain()) - return false; - else - { - IPropertySet[] childrenPropertySet = wrapper.getElement().getPropertySets(); - if (childrenPropertySet == null || childrenPropertySet.length == 0) - { - return false; - } - else - { - return true; - } - } - } else - return false; - } else if (element == null) { - SystemBasePlugin.logError("Unexpected null input to hasChildren!"); //$NON-NLS-1$ - } else { - String message = "Unexpected input to hasChildren: " + element.getClass().getName(); //$NON-NLS-1$ - SystemBasePlugin.logError(message); - } - return false; - } - - /** - * Method declared on IContentProvider. - * Callen when input changed. We do nothing. - */ - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - } - - // ----------------------------------------------------------- - // THE FOLLOWING ABSTRACT OUT THE DIFFERENCES BETWEEN ACTIONS - // AND TYPES - // ----------------------------------------------------------- - /** - * Get the document root tag name. - * Will be "FileTypes" for types, and "Actions" for actions - */ - public abstract String getDocumentRootTagName(); - - /** - * Do we uppercase the value of the "Name" attribute? - * Yes, we do for types, and No, we don't for actions - */ - protected abstract boolean uppercaseName(); - - /** - * Retrieve the action/type tags for the given profile and domain, - * wrapped in appropriate xml wrapper objects - * @param children - existing vector to populate. Pass null to create and return new vector - * @param domain - the integer representation of the domain, or -1 iff domains not support - * @param profile - profile to determine the document to query. If profiles not supported, pass null. - * @return a vector of the action/type tags - */ - public Vector getXMLWrappers(Vector children, int domain, ISystemProfile profile) { - SystemXMLElementWrapper domainElement = null; - if (getActionSubSystem().supportsDomains()) { - domainElement = getDomainWrapper(profile, domain); - if (domainElement == null) // if parent domain not found, don't continue! - return children; - } - return getXMLWrappers(children, domainElement, profile); - } - - /** - * Retrieve the action/type tags for the given profile and domain, - * wrapped in appropriate xml wrapper objects - * @param children - existing vector to populate. Pass null to create and return new vector - * @param parentOrDomain - if domains supported, this must be the parent domain whose kids are being queried, or an Integer for single-domains, else null - * @param profile - profile to determine the document to query. If profiles not supported, pass null. - * @return a vector of the action/type tags - */ - public Vector getXMLWrappers(Vector children, Object parentOrDomain, ISystemProfile profile) { - int domain = -1; - IPropertySet parentElement = null; - if (parentOrDomain instanceof SystemXMLElementWrapper) { - parentElement = ((SystemXMLElementWrapper) parentOrDomain).getElement(); - domain = ((SystemXMLElementWrapper) parentOrDomain).getDomain(); - } else if (parentOrDomain instanceof IPropertySet) parentElement = (IPropertySet) parentOrDomain; - children = SystemXMLElementWrapper.getChildren(children, parentElement, getDocument(profile), profile, this, domain); - return children; - } - - /** - * Return true if the elements managed by this class are scoped by - * profile. Usually true for actions, false for types - */ - public boolean supportsProfiles() { - return true; - } - - // ------------------------------------- - // - // ------------------------------------- - /** - * - */ - private void addListener() { - // Team support - // Register a listener for resource change events on objects - // in our remote system project. - // Dont register multiple times, if already done once. - // (Since this load method may be repeated) - /* ADDED BY JOHN, BUT COMMENTED OUT BY PHIL. OUR MODEL FOR RECOVERING FROM A TEAM SYNCH - * IS TO REQUIRE THE USER TO RUN RELOADRSE. - if (!listening) - { - listening = true; - SystemResourceManager.addResourceChangeListener(this); - } - */ - } - - - /** - * Get the current subsystem. Will be null for import, or working in team view when - * no subsystems exist yet for a particular subsystem factory. - */ - protected ISubSystem getSubSystem() { - if (_udas != null) - return _udas.getSubsystem(); - else - return null; - } - - /** - * Get the current subsystem. Will be set in SystemProfileImpl's getUserActions method - * for cases when there are no subsystems created for a subsystemconfiguration yet. - */ - protected ISubSystemConfiguration getSubSystemFactory() { - if (_udas != null) - return _udas.getSubSystemFactory(); - else - return null; - } - - - - - /** - * loadAndParseXMLFile: - * tries to load and parse the specified XML file. - * @param profile the profile in which the user defined actions are kept - * @return the document containing the user defined actions - */ - protected IPropertySet loadAndParseXMLFile(ISystemProfile profile) { - - String osType = _udas.getOSType(); - String udaRootPropertySetName = ISystemUDAConstants.USER_DEFINED_ACTION_PROPRERTY_SET_PREFIX + osType + "." + getDocumentRootTagName(); //$NON-NLS-1$ - IPropertySet userDefinedActionPropertySet = profile.getPropertySet(udaRootPropertySetName); - - return userDefinedActionPropertySet; - - } - - - // ********************************************************** - // ErrorHandler Interface: (XML SAX parsing) - // ********************************************************** - /** Warning. */ - public void warning(SAXParseException ex) { - SystemBasePlugin.logWarning("SystemAbstractUDdata: XML Warning: " + ex.toString()); //$NON-NLS-1$ - } - - /** Error. */ - public void error(SAXParseException ex) { - SystemBasePlugin.logError("SystemAbstractUDdata: XML Error: " + ex.toString(), ex); //$NON-NLS-1$ - } - - /** Fatal error. */ - public void fatalError(SAXParseException ex) throws SAXException { - SystemBasePlugin.logError("SystemAbstractUDdata: Fatal XML error: " + ex.toString(), ex); //$NON-NLS-1$ - throw (ex); - } - - // ********************************************************** - // - // ********************************************************** - /** - * Interface org.eclipse.core.resources. IResourceChangeListener - */ - public void resourceChanged(IResourceChangeEvent event) { - //System.out.println( "SystemUDBaseManager.resourceChanged: flag=" + String.valueOf(ignoreMyResourceChange) ); - if (ignoreMyResourceChange) return; - if (IResourceChangeEvent.POST_CHANGE != event.getType()) return; - Object source = event.getSource(); - // if (ignoreEvents || !(event.getSource() instanceof IWorkspace)) - if (!(source instanceof IWorkspace)) return; - // int type = event.getType(); - // String sType = SystemResourceListener.getTypeString(type); - // System.out.println("RESOURCE CHANGED EVENT: eventType="+sType+", eventSource=" + source.toString() ); - // System.out.println("RESOURCE DELTA:"); //$NON-NLS-1$ - // IResource resource = event.getResource(); - IResourceDelta delta = event.getDelta(); - if (null == delta) return; - /* - if ((resource == null) && (delta != null)) - resource = delta.getResource(); - - if ( null != resource) - { - String rname = resource.getLocation().toOSString(); - - System.out.println("RESOURCE " + rname); - System.out.println("RESOURCE Name: " + resource.getName() ); - System.out.println("RESOURCE type: " + SystemResourceListener.getTypeString( resource.getType()) ); - - if ( null != resource.getProject() ) - System.out.println("RESOURCE Proj: " + resource.getProject().getName() ); - - } - - resource = delta.getResource(); - if ( null != resource) - { - String rname = resource.getLocation().toOSString(); - - System.out.println("RESOURCE DELTA: " + rname); - System.out.println("RESOURCE Name: " + resource.getName() ); - System.out.println("RESOURCE type: " + SystemResourceListener.getTypeString( resource.getType()) ); - - if ( null != resource.getProject() ) - System.out.println("RESOURCE Proj: " + resource.getProject().getName() ); - } - */ - //System.out.println("res UD file:" ); - if (supportsProfiles()) { - ISystemProfile[] activeProfiles = getActiveSystemProfiles(); - for (int idx = 0; idx < activeProfiles.length; idx++) { - ISystemProfile profile = activeProfiles[idx]; - //ensureDirPathResolved(profile); - searchDelta(profile, delta, 0); - } - } else { - //ensureDirPathResolved(null); - searchDelta(null, delta, 0); - } - } - - private void searchDelta(ISystemProfile profile, IResourceDelta parent, int nestLevel) { - Object[] dirPath = getProfileIndexedInstanceVariable_dirPath(profile); - String target = (String) dirPath[nestLevel]; - // System.out.println("search for: "+String.valueOf( nestLevel)+ ": "+target); - IResourceDelta resdel[] = parent.getAffectedChildren(IResourceDelta.CHANGED | IResourceDelta.ADDED | IResourceDelta.REMOVED); - for (int i = 0; i < resdel.length; i++) { - IResource resource = resdel[i].getResource(); - // System.out.println(" .. " + String.valueOf(i) + ": " + resource.getName()); - if ((null != resource) && target.equals(resource.getName())) { - // End of the search chain? - nestLevel++; - if (nestLevel < dirPath.length) - // Recurse - searchDelta(profile, resdel[i], nestLevel); - else { - // Matches !! - //System.out.println("Matches! " ); - processResourceChangeHit(profile); - } - // Stop further searching at this level - return; - } - } - } - - /** - * Get the active system profiles - */ - private ISystemProfile[] getActiveSystemProfiles() { - return RSECorePlugin.getTheSystemRegistry().getActiveSystemProfiles(); - } - - // --------------------------------------------------------------------------- - // The GUI for working with user-defined actions sets the current profile - // as the user selects it. This becomes the default profile to work with until - // the user changes it again - // --------------------------------------------------------------------------- - /** - * Set the profile we are working with the actions for, until reset. - * Note, to reduce chance for errors, we do not implicitly use this profile - * anywhere! Rather, this is simply a convenient holding place for it, - * and the caller must explicitly call getCurrentProfile to retrieve it - * when it is needed as input to any of the other methods in this class - * or a child class. - */ - public void setCurrentProfile(ISystemProfile profile) { - this.currentlyActiveProfile = profile; - } - - /** - * Get the profile we are currently working with, as set by a call to setCurrentProfile - */ - public ISystemProfile getCurrentProfile() { - return currentlyActiveProfile; - } - - // ----------------------------------------------------------- - // THE FOLLOWING METHODS ARE ALL INDEXED BY SYSTEM PROFILE... - // ----------------------------------------------------------- - /** - * Prime the given document with any default actions/types - * Should be overridden! - */ - public SystemXMLElementWrapper[] primeDocument(ISystemProfile profile) { - return null; - } - - /** - * Get the release of the document. Eg, value of the "release"attribute of the root. - * If not set then we assume it is release "4.0" - */ - /* - public String getDocumentRelease(ISystemProfile profile) { - Document doc = getDocument(profile); - Element root = doc.getDocumentElement(); - String rel = root.getAttribute(ISystemUDAConstants.RELEASE_ATTR); - if (rel == null) - return "4.0"; //$NON-NLS-1$ - else - return rel; - } - */ - - /** - * Load document for given SystemProfile only if not already done. - */ - public IPropertySet getDocument(ISystemProfile profile) { - IPropertySet doc = getProfileIndexedInstanceVariable_Document(profile); - if (doc == null) { - doc = loadUserData(profile); - if (doc == null) - { - //No user action for this profile - return doc; - } - setProfileIndexedInstanceVariable_Document(profile, doc); - // document is good. Now, check the release date stamped on it. - // if not the current release, then we must consider migration... - /* - Element docroot = doc.getDocumentElement(); - String docRelease = docroot.getAttribute(ISystemUDAConstants.RELEASE_ATTR); - if ((docRelease == null) || (docRelease.length() == 0)) docRelease = "4.0"; //$NON-NLS-1$ - if (!docRelease.equals(CURRENT_RELEASE_NAME)) { - //System.out.println("Doing migration from "+docRelease+" to " + ISystemConstants.CURRENT_RELEASE_NAME + "..."); - boolean migrationDone = doMigration(profile, docRelease); - docroot.setAttribute(ISystemUDAConstants.RELEASE_ATTR, RSECorePlugin.CURRENT_RELEASE_NAME); - if (migrationDone) { - setChanged(profile); // is this the right thing to do? - saveUserData(profile); - } - } - */ - } else { - } - - return doc; - } - - /** - * Overridable extension point for child classes to do migration of their document. - * This is called on first load of a document, which has a release stamp other than - * the current release - * @return true if any migration was done - */ - protected abstract boolean doMigration(ISystemProfile profile, String oldRelease); - - - /** - * Indicate the data has changed for the document for the given system profile - */ - public void setChanged(ISystemProfile profile) { - dataChanged(profile); - setProfileIndexedInstanceVariable_hasChanged(profile, true); - } - - /** - * Reload the User data for the given profile, from disk if it has been changed in memory - */ - public void resetUserData(ISystemProfile profile) { - //System.out.println("UD reset: " + getFileName() ); - if (!getProfileIndexedInstanceVariable_hasChanged(profile)) setProfileIndexedInstanceVariable_Document(profile, loadUserData(profile)); - } - - /** - * Force a re-load - */ - public void processResourceChangeHit(ISystemProfile profile) { - setProfileIndexedInstanceVariable_Document(profile, null); - dataChanged(profile); - } - - /** - * Indicate data has changed for the given profile - */ - protected void dataChanged(ISystemProfile profile) { - } - - /** - * Load the user actions from the XML document, for the given profile - */ - protected IPropertySet loadUserData(ISystemProfile profile) { - //System.out.println("UD load: " + getFileName() ); - dataChanged(profile); // not sure why we call this, at this time!! Phil - setProfileIndexedInstanceVariable_hasChanged(profile, false); - /* - String fn = getFilePath(profile); - Document doc = null; - if (!(new File(fn)).canRead()) - doc = createAndPrimeDocument(profile); - else - doc = loadAndParseXMLFile(fn, profile); - //addListener(); - */ - //We use PropertySet to store User Action instead. - //We need to get the compile command information from the system profile now. - //Get the propertySet first - String osType = _udas.getOSType(); - String udaRootPropertySetName = ISystemUDAConstants.USER_DEFINED_ACTION_PROPRERTY_SET_PREFIX + osType + "." + getDocumentRootTagName(); //$NON-NLS-1$ - IPropertySet udaRootPropertySet = profile.getPropertySet(udaRootPropertySetName); - if (null == udaRootPropertySet) - { - if (profile.isDefaultPrivate()) // we only prime the user's private profile with default compile commands - { - udaRootPropertySet = createAndPrimeDocument(profile); - } else { - udaRootPropertySet = profile.createPropertySet(udaRootPropertySetName); - } - } - else - { - udaRootPropertySet = loadAndParseXMLFile(profile); - } - return udaRootPropertySet; - } - - /** - * Create and prime the XML document - */ - protected IPropertySet createAndPrimeDocument(ISystemProfile profile) { - //Document doc = initializeDocument(); - //setProfileIndexedInstanceVariable_Document(profile, doc); - SystemXMLElementWrapper[] primedElements = primeDocument(profile); - if (primedElements != null) { - for (int idx = 0; idx < primedElements.length; idx++) { - SystemXMLElementWrapper newElement = primedElements[idx]; - newElement.setIBM(true); - newElement.setUserChanged(false); - } - } - saveUserData(profile); - - String osType = _udas.getOSType(); - String udaRootPropertySetName = ISystemUDAConstants.USER_DEFINED_ACTION_PROPRERTY_SET_PREFIX + osType + "." + getDocumentRootTagName(); //$NON-NLS-1$ - IPropertySet userDefinedActionPropertySet = profile.getPropertySet(udaRootPropertySetName); - - return userDefinedActionPropertySet; - - } - - /** - * Save user data for the given system profile - */ - public void saveUserData(ISystemProfile profile) { - //System.out.println("UD save: " + getFileName() ); - if (!getProfileIndexedInstanceVariable_hasChanged(profile)) { - //System.out.println("UD save: No changes. " + getFileName() ); - return; - } - profile.commit(); - ignoreMyResourceChange = false; - SystemResourceManager.turnOnResourceEventListening(); - } - - /** - * Move given element down one in document, save document - * @return true if move successful - */ - public boolean moveElementDown(SystemXMLElementWrapper elementWrapper/*, SystemXMLElementWrapper nextNextElementWrapper*/) { - getDocument(elementWrapper.getProfile()); - IPropertySet element = elementWrapper.getElement(); - IPropertySetContainer parentElement = element.getContainer(); - IPropertySet[] allChildren = parentElement.getPropertySets(); - - IPropertySet elementBelow = null; - int elementOrder = getOrder(element); - // Find the element whose order index is 1 more then the current element - for (int i = 0; i < allChildren.length && elementBelow == null; ++i) - { - // Get the order attribute of the current property set - int order = getOrder(allChildren[i]); - - // Compare to the current elements order attribute - if (order != -1 && (elementOrder + 1) == order) - elementBelow = allChildren[i]; - } - - // Swap the order for the 2 elements - if (elementBelow != null) { - elementBelow.addProperty(ISystemUDAConstants.ORDER_ATTR, Integer.toString(elementOrder)); - element.addProperty(ISystemUDAConstants.ORDER_ATTR, Integer.toString(elementOrder + 1)); - - // Save User Data - setProfileIndexedInstanceVariable_hasChanged(elementWrapper.getProfile(), true); - saveUserData(elementWrapper.getProfile()); - return true; - } - return false; - } - - /** - * Move given element up one in document, save document - * @return true if move successful - */ - public boolean moveElementUp(SystemXMLElementWrapper elementWrapper/*, SystemXMLElementWrapper previousElementWrapper*/) { - getDocument(elementWrapper.getProfile()); - IPropertySet element = elementWrapper.getElement(); - IPropertySetContainer parentElement = element.getContainer(); - IPropertySet[] allChildren = parentElement.getPropertySets(); - - IPropertySet elementAbove = null; - int elementOrder = getOrder(element); - for (int i = 0; i < allChildren.length && elementAbove == null; ++i) - { - // Get the order attribute of the current property set - int order = getOrder(allChildren[i]); - - // Compare to the current elements order attribute - if (order != -1 && (elementOrder - 1) == order) - elementAbove = allChildren[i]; - } - - // Swap the order for the 2 elements - if (elementAbove != null) { - elementAbove.addProperty(ISystemUDAConstants.ORDER_ATTR, Integer.toString(elementOrder)); - element.addProperty(ISystemUDAConstants.ORDER_ATTR, Integer.toString(elementOrder - 1)); - - // Save User Data - setProfileIndexedInstanceVariable_hasChanged(elementWrapper.getProfile(), true); - saveUserData(elementWrapper.getProfile()); - return true; - } - return false; - } - - /** - * Prepares a given element for the clipboard. - * This clones the element in transient memory, and returns a reference to the clone - * that can be placed in a local clipboard instance. Subsequently, paste is only enabled - * if the reference in the clipboard corresponds to a node clone in this object. - * @return an id that uniquely identifies the cloned node, or null if it failed. - */ - public String prepareClipboardCopy(SystemXMLElementWrapper elementWrapper) { - getDocument(elementWrapper.getProfile()); - IPropertySet element = elementWrapper.getElement(); - currentNodeClone = new PropertySet(element); - currentNodeCloneID = getActionSubSystem().getClass().getName() + "." + //$NON-NLS-1$ - getActionSubSystem().getOSType() + "." + //$NON-NLS-1$ - elementWrapper.getName(); - currentNodeCloneDomain = elementWrapper.getDomain(); -// currentNodeCloneName = elementWrapper.getName(); - return currentNodeCloneID; - } - - - /** - * Test if the given ID, read from the clipboard, matches a node we prepared for - * the clipboard. It also ensure that domains match. - * <p> - * This decides if the paste action will be enabled or not - */ - public boolean enablePaste(SystemXMLElementWrapper selectedElementWrapper, String id) { - if (id == null) return false; - int selectedElementDomain = selectedElementWrapper.getDomain(); - return (id.equals(currentNodeCloneID) && (selectedElementDomain == currentNodeCloneDomain)); - } - - /** - * After a successful call to enablePaste, this is called to do the paste operation. - * The new object is inserted before the current selection if appropriate, else to the end of the domain - * @return SystemXMLElementWrapper wrapper object of pasted element, or null if it failed - */ - public SystemXMLElementWrapper pasteClipboardCopy(SystemXMLElementWrapper selectedElementWrapper, String id) { - ISystemProfile profile = selectedElementWrapper.getProfile(); - if (profile == null) - profile = getActionSubSystem().getSubsystem().getSystemProfile(); - getDocument(profile); - IPropertySet selectedElement = selectedElementWrapper.getElement(); - SystemXMLElementWrapper pastedElementWrapper = null; - try { - IPropertySetContainer parentElement = null; - IPropertySet pastedElement = null; - - pastedElementWrapper = createElementWrapper(currentNodeClone, selectedElementWrapper.getProfile(), selectedElementWrapper.getDomain()); - pastedElementWrapper.setName(getUniqueCloneName(pastedElementWrapper)); - currentNodeClone.setName(getUniqueCloneName(pastedElementWrapper)); - pastedElementWrapper.setIBM(false); // not an IBM action, even if source was - - if (selectedElementWrapper.isDomain()) { - parentElement = selectedElement; - IPropertySet[] allChildren = parentElement.getPropertySets(); - currentNodeClone.addProperty(ISystemUDAConstants.ORDER_ATTR, Integer.toString(allChildren.length)); - - parentElement.addPropertySet(currentNodeClone); - pastedElement = currentNodeClone; - } else { - parentElement = selectedElement.getContainer(); - IPropertySet[] allChildren = parentElement.getPropertySets(); - IPropertySet elementBelow = null; - int elementOrder = getOrder(selectedElement); - for (int i = 0; i < allChildren.length && elementBelow == null; ++i) - { - // Get the order attribute of the current property set - int order = getOrder(allChildren[i]); - - // Increment the order value for each property set greater then the current element's as we - // insert the new pasted element right below the selected - if (order > elementOrder) { - allChildren[i].addProperty(ISystemUDAConstants.ORDER_ATTR, Integer.toString(order + 1)); - } - } - currentNodeClone.addProperty(ISystemUDAConstants.ORDER_ATTR, Integer.toString(elementOrder + 1)); - parentElement.addPropertySet(currentNodeClone); - pastedElement = currentNodeClone; - } - - } catch (Exception exc) { - SystemBasePlugin.logError("Error pasting user action/type", exc); //$NON-NLS-1$ - return null; - } - saveUserData(profile); - return pastedElementWrapper; - } - - /** - * Return a new unique name to assign to a pastable element node clone - */ - private String getUniqueCloneName(SystemXMLElementWrapper elementWrapper) { - String newName = SystemUDAResources.RESID_UDA_COPY_NAME_1; - newName = SystemMessage.sub(newName, "%1", elementWrapper.getName()); //$NON-NLS-1$ - Vector existingNames = getExistingNames(elementWrapper.getProfile(), elementWrapper.getDomain()); - boolean nameInUse = (existingNames.indexOf(newName) >= 0); - int nbr = 2; - while (nameInUse) { - newName = SystemUDAResources.RESID_UDA_COPY_NAME_N; - newName = SystemMessage.sub(newName, "%1", elementWrapper.getName()); //$NON-NLS-1$ - newName = SystemMessage.sub(newName, "%2", Integer.toString(nbr)); //$NON-NLS-1$ - nameInUse = (existingNames.indexOf(newName) >= 0); - ++nbr; - } - return newName; - } - - // ---------------------------------------------------------------------- - // THE FOLLOWING WERE PULLED DOWN FROM VARIOUS SUBCLASSES, AND ABSTRACTED - // TO BE USABLE AS IS FOR ALL SCENARIOS: - // ACTIONS VS TYPES - // PROFILE-SCOPED VS NOT-PROFILE-SCOPED - // SUPPORTS-DOMAINS VS DOESN'T-SUPPORT DOMAINS - // ---------------------------------------------------------------------- - /** - * Method declared on IStructuredContentProvider. - * Returns root elements for the currently set profile (see setCurrentProfile). - * If this is null, returns root elements for all active profiles - */ - - public Object[] getElements(Object element) { - if (!supportsProfiles()) - return getElements((ISystemProfile) null, element); - else { - ISystemProfile currProfile = getCurrentProfile(); - if (currProfile != null) - return getElements(currProfile, element); - else - return getElements(getActiveSystemProfiles(), element); - } - } - - - /** - * Return root elements for given profile. - */ - public Object[] getElements(ISystemProfile profile, Object element) { - return getElements(new ISystemProfile[] { profile }, element); - } - - /** - * Return the root elements. - * <p> - * If domains are supported, returns a root "New" item plus element wrappers for - * any existing domain tags in the xml - * If domains are not supported, returns a non-root "New" item plus element - * wrappers for all action/type xml tags found under the root of the xml document - */ - public Object[] getElements(ISystemProfile[] profiles, Object input) { - /* - if (input == null) - System.out.println("Inside getElements. input is null"); - else - System.out.println("Inside getElements. input is of type " + input.getClass().getName()); - */ - if ((input != null) && !(input instanceof String)) return EMPTY_ARRAY; - Vector v = new Vector(); - // if domains supported, return "New" root item, plus wrappers of - // any domain xml elements found... - int onlyDomain = getActionSubSystem().getSingleDomain(this); - if (getActionSubSystem().supportsDomains() && (onlyDomain == -1)) { - v.add(SystemUDTreeViewNewItem.getRootNewItem(isUserActionsManager(), getNewNodeLabel())); - if (supportsProfiles()) { - // get domain elements per given profile - for (int idx = 0; idx < profiles.length; idx++) { - ISystemProfile profile = profiles[idx]; - v = createExistingDomainElementWrappers(v, profile); - } - } else { - // get domain elements - v = createExistingDomainElementWrappers(v, null); - } - } - // if domains not supported, return singleton New item, plus wrappers - // of any action/type elements found - else { - IPropertySetContainer parentDomainElement = null; - if (onlyDomain == -1) - v.add(SystemUDTreeViewNewItem.getOnlyNewItem(isUserActionsManager(), getNewNodeLabel())); - else - v.add(SystemUDTreeViewNewItem.getOnlyNewItem(onlyDomain, isUserActionsManager(), getNewNodeLabel())); - if (supportsProfiles()) { - // get actual elements (actions/types) per given profile - for (int idx = 0; idx < profiles.length; idx++) { - ISystemProfile profile = profiles[idx]; - if (onlyDomain != -1) parentDomainElement = findDomainElement(getDocument(profile), onlyDomain); - v = getXMLWrappers(v, parentDomainElement, profile); - } - } else { - // get actual elements (actions/types) - if (onlyDomain != -1) parentDomainElement = findDomainElement(getDocument(null), onlyDomain); - v = getXMLWrappers(v, parentDomainElement, null); - } - } - return v.toArray(); - } - - /** - * Overridable method for returning the label for the "New" nodes in the tree view. - * Will usually be different for actions versus types. - * @return translated value for "New" in new icon. Default is "New" - */ - protected String getNewNodeLabel() { - return SystemUDAResources.ACTION_CASCADING_NEW_LABEL; - } - - /** - * Return true if this is user actions, false if this is named types. - */ - protected abstract boolean isUserActionsManager(); - - /** - * Return all the user actions/types under the given node. - * If input is a New item, return New items per domain - * If input is a Domain element wrapper, return wrappers of all child actions/types under that domain, - * for that domain's profile. - */ - public Object[] getChildren(Object element) { - /* - if (element == null) - System.out.println("Inside getElements. input is null"); - else - System.out.println("Inside getElements. input is of type " + element.getClass().getName()); - */ - if (element instanceof SystemUDTreeViewNewItem) { - // Only on the (parent) cascade item. - // Will only happen if we support domains - if (!((SystemUDTreeViewNewItem) element).isExecutable()) { - boolean isUserActionDialog = ((SystemUDTreeViewNewItem) element).isWorkWithActionsDialog(); - if (newItemsPerDomain == null) { - int nbrDomains = getActionSubSystem().getMaximumDomain() + 1; - newItemsPerDomain = new SystemUDTreeViewNewItem[nbrDomains]; - for (int idx = 0; idx < newItemsPerDomain.length; idx++) { - if (isUserActionDialog) - newItemsPerDomain[idx] = new SystemUDTreeViewNewItem(true, getActionSubSystem().mapDomainXlatedNewName(idx), idx, isUserActionDialog); - else - newItemsPerDomain[idx] = new SystemUDTreeViewNewItem(true, getActionSubSystem().mapDomainXlatedNewTypeName(idx), idx, isUserActionDialog); - } - } - return newItemsPerDomain; - } - return EMPTY_ARRAY; - } - // getElements() is called to get roots, so we should never be - // called here unless we have been given a domain element wrapper - if (!(element instanceof SystemXMLElementWrapper) || !((SystemXMLElementWrapper) element).isDomain()) return EMPTY_ARRAY; - SystemXMLElementWrapper parent = (SystemXMLElementWrapper) element; - Vector v = new Vector(); - ISystemProfile profile = parent.getProfile(); - getXMLWrappers(v, parent, profile); - return v.toArray(); - } - - /** - * Find a child element of a given name. - * Returns the xml node element or null - */ - public IPropertySet findChildByName(ISystemProfile profile, String name, int domain) { - IPropertySet xdoc = getDocument(profile); - if (getActionSubSystem().supportsDomains() && (domain >= 0)) { - IPropertySet domainElement = findDomainElement(xdoc, domain); - return SystemXMLElementWrapper.findChildByName(domainElement, xdoc, getTagName(), name); - } else { - return SystemXMLElementWrapper.findChildByName(null, xdoc, getTagName(), name); - } - } - - /** - * Find a child element of a given name. - * Returns the wrapper of the xml node element or null - */ - public SystemXMLElementWrapper findByName(ISystemProfile profile, String name, int domain) { - IPropertySet element = findChildByName(profile, name, domain); - if (element == null) - return null; - else - return createElementWrapper(element, profile, domain); - } - - /** - * Get a list of existing names, for unique-name checking. - */ - public Vector getExistingNames(ISystemProfile profile, int domain) { - IPropertySet xdoc = getDocument(profile); - if (getActionSubSystem().supportsDomains() && (domain >= 0)) { - IPropertySet domainElement = findDomainElement(xdoc, domain); - if (domainElement == null) return new Vector(); // defect 46147 - return SystemXMLElementWrapper.getExistingNames(domainElement, xdoc, getTagName()); - } else { - return SystemXMLElementWrapper.getExistingNames(null, xdoc, getTagName()); - } - } - - /** - * Add a new user action or type. - * Creates the new XML node in the document, - * and creates and returns a wrapper object for it. - */ - public SystemXMLElementWrapper addElement(ISystemProfile profile, int domain, String name) { - - String osType = _udas.getOSType(); - String udaRootPropertySetName = ISystemUDAConstants.USER_DEFINED_ACTION_PROPRERTY_SET_PREFIX + osType + "." + getDocumentRootTagName(); //$NON-NLS-1$ - //String userDefinedActionPropertySetName = ISystemUDAConstants.USER_DEFINED_ACTION_PROPRERTY_SET_PREFIX + osType; - //ISystemProfile systemProfile = SystemRegistry.getInstance().getSystemProfile(profile.getName()); - IPropertySet udaRootPropertySet = profile.getPropertySet(udaRootPropertySetName); - if (udaRootPropertySet == null) - { - udaRootPropertySet = profile.createPropertySet(udaRootPropertySetName); - udaRootPropertySet.addProperty(ISystemUDAConstants.NAME_ATTR, ISystemUDAConstants.ACTION_FILETYPES + " - " + osType); //$NON-NLS-1$ - udaRootPropertySet.addProperty(ISystemUDAConstants.RELEASE_ATTR, CURRENT_RELEASE_NAME); - udaRootPropertySet.addProperty(ISystemUDAConstants.UDA_ROOT_ATTR, getDocumentRootTagName()); - } - IPropertySet child = null; - // Get domain element, create if necessary - if (getActionSubSystem().supportsDomains()) - { - IPropertySet se = findOrCreateDomainElement(udaRootPropertySet, domain); - child = se.createPropertySet(name); - } - else - { - child = udaRootPropertySet.createPropertySet(name); - } - child.addProperty(ISystemUDAConstants.NAME_ATTR, uppercaseName() ? name.toUpperCase() : name); - child.addProperty(ISystemUDAConstants.TYPE_ATTR, getTagName()); - - // Set the Order - IPropertySetContainer parentElement = child.getContainer(); - IPropertySet[] allChildren = parentElement.getPropertySets(); - child.addProperty(ISystemUDAConstants.ORDER_ATTR, Integer.toString(allChildren.length - 1)); // -1 the length because we are already part of the child list - - SystemXMLElementWrapper newElementWrapper = null; - - newElementWrapper = createElementWrapper(child, profile, domain); - setChanged(profile); - return newElementWrapper; - } - - /** - * Delete a give user action or type, given its wrapper. - * Deletes the xml node from the document. - */ - public void delete(ISystemProfile profile, SystemXMLElementWrapper elementWrapper) { - elementWrapper.deleteElement(); - setChanged(profile); - } - - // ----------------------------------------------------------- - // ISOLATE READING AND WRITING OF PROFILE-INDEXED VARIABLES... - // ----------------------------------------------------------- - /** - * Set the profile-indexed document instance variable - */ - private void setProfileIndexedInstanceVariable_Document(ISystemProfile profile, IPropertySet doc) { - if (!supportsProfiles()) - udocNoProfile = doc; - else - udocsByProfile.put(profile, doc); - } - - /** - * Get the profile-indexed document instance variable - */ - private IPropertySet getProfileIndexedInstanceVariable_Document(ISystemProfile profile) { - if (!supportsProfiles()) - return udocNoProfile; - else - return (IPropertySet) udocsByProfile.get(profile); - } - - /** - * Set the profile-indexed has-changed instance variable - */ - private void setProfileIndexedInstanceVariable_hasChanged(ISystemProfile profile, boolean hasChanged) { - if (!supportsProfiles()) - hasChangedNoProfile = hasChanged; - else { - if (hasChanged) - hasChangedByProfile.put(profile, Boolean.TRUE); - else - hasChangedByProfile.put(profile, Boolean.FALSE); - } - } - - /** - * Get the profile-indexed has-changed instance variable - */ - private boolean getProfileIndexedInstanceVariable_hasChanged(ISystemProfile profile) { - if (!supportsProfiles()) - return hasChangedNoProfile; - else { - Boolean b = (Boolean) hasChangedByProfile.get(profile); - if (b == null) - return false; - else - return (b == Boolean.TRUE); - } - } - - /** - * Get the dir-path has-changed instance variable - */ - private Object[] getProfileIndexedInstanceVariable_dirPath(ISystemProfile profile) { - if (!supportsProfiles()) - return dirPathNoProfile; - else - return (Object[]) dirPathByProfile.get(profile); - } - - // ------------------------------------- - // METHODS RELATED TO DOMAIN ELEMENTS... - // ------------------------------------- - /** - * Given a domain's integer representation, find its element in - * xml document and return the wrapper for it. If not found, - * returns null - */ - protected SystemXMLElementWrapper getDomainWrapper(ISystemProfile profile, int domain) { - IPropertySet udaRootPropertySet = getDocument(profile); - if (udaRootPropertySet == null) - { - return null; - } - IPropertySet element = findDomainElement(getDocument(profile), domain); - if (element != null) - return createDomainElementWrapper(element, profile, domain); - else - return null; - } - - /** - * Find all existing domain XML elements that are children of the root, - * and create wrapper objects for them, and add them to the given vector. - * <p> - * It is important to note these are returned in the pre-determined order, - * not the order they are found in the document! - */ - protected Vector createExistingDomainElementWrappers(Vector v, ISystemProfile profile) { - IPropertySet xdoc = getDocument(profile); - if (xdoc == null) - return v; - // get the "domain" children of the root, in the pre-determined order of domains - IPropertySet[] subList = xdoc.getPropertySets(); - if ((subList == null) || (subList.length == 0)) return v; - String[] domains = getActionSubSystem().getDomainNames(); - int subListLen = subList.length; - for (int idx = 0; idx < domains.length; idx++) { - IPropertySet match = null; - for (int jdx = 0; (match == null) && (jdx < subListLen); jdx++) { - IPropertySet currNode = subList[jdx]; - if (isDomainElement(currNode, domains[idx])) { - //Element currElement = (Element)currNode; - //if (currElement.getAttribute(XE_DOMTYPE).equals(domains[idx])) - match = currNode; - } - } - if (match != null) v.add(createDomainElementWrapper(match, profile, idx)); - } - return v; - } - - /** - * Create a domain element wrapper - */ - protected SystemXMLElementWrapper createDomainElementWrapper(IPropertySet xmlDomainElementToWrap, ISystemProfile profile, int domain) { - return createElementWrapper(xmlDomainElementToWrap, profile, domain); - } - - /** - * Given an xml action/type document, try to find a domain element ("Domain" tag) - * of the given domain type. If not found, do NOT create it. - */ - protected IPropertySet findDomainElement(IPropertySet xdoc, int domain) { - return findOrCreateDomainElement(xdoc, domain, false); - } - - /** - * Given an xml action/type document, try to find a domain element ("Domain" tag) - * of the given untranslated name ("Type" attribute). If not found, create it. - */ - protected IPropertySet findOrCreateDomainElement(IPropertySet xdoc, int domain) { - return findOrCreateDomainElement(xdoc, domain, true); - } - - /** - * Given an xml action/type document, try to find a domain element ("Domain" tag) - * of the given untranslated name ("Type" attribute). If not found, optionally create it. - */ - protected IPropertySet findOrCreateDomainElement(IPropertySet xdoc, int domain, boolean create) { - if (xdoc == null) - return null; - - IPropertySet[] domainSets = xdoc.getPropertySets(); - String domainName = getActionSubSystem().mapDomainName(domain); // unxlated name. Eg "Type" parm - IPropertySet domainElement = null; - for (int i = 0; i < domainSets.length; i++) - { - IPropertySet thisDomain = domainSets[i]; - if (null != thisDomain) - { - if (isDomainElement(thisDomain, domainName)) - { - domainElement = thisDomain; - } - } - - } - /* - NodeList subList = xdoc.getDocumentElement().getChildNodes(); - String domainName = getActionSubSystem().mapDomainName(domain); // unxlated name. Eg "Type" parm - Element domainElement = null; - if (subList != null) { - for (int idx = 0; (domainElement == null) && (idx < subList.getLength()); idx++) { - Node sn = subList.item(idx); - if (sn instanceof Element) { - if (isDomainElement((Element) sn, domainName)) domainElement = (Element) sn; - } - } - } - */ - if (create && (domainElement == null)) domainElement = createDomainElement(xdoc, domain); - return domainElement; - } - - /** - * Create a new xml domain element. That, an element of tag name "Domain". - * @param xdoc - the document to add it to. Will be added as child of root - * @param domain - the integer representation of the domain, used to get its name and translated name - */ - protected IPropertySet createDomainElement(IPropertySet xdoc, int domain) { - IPropertySet element = xdoc.createPropertySet(getActionSubSystem().mapDomainXlatedName(domain)); - element.addProperty(ISystemUDAConstants.XE_DOMTYPE, getActionSubSystem().mapDomainName(domain)); - element.addProperty(ISystemUDAConstants.XE_DOMNAME, getActionSubSystem().mapDomainXlatedName(domain)); - element.addProperty(ISystemUDAConstants.TYPE_ATTR, ISystemUDAConstants.XE_DOMAIN); - return element; - } - - // ------------------------------------------- - // STATIC HELPER METHODS RELATED TO DOMAINS... - // ------------------------------------------- - /** - * Given an xml Element object, return true if it is a Domain - * element. That is, if its tag name is "Domain" - */ - public static boolean isDomainElement(IPropertySet element) { - return (element.getPropertyValue(ISystemUDAConstants.TYPE_ATTR).equals(ISystemUDAConstants.XE_DOMAIN)); - } - - /** - * Given an xml Element object, return true if it is a Domain - * element and its "Type" attribute matches the given name. - */ - public static boolean isDomainElement(IPropertySet element, String domainName) { - return isDomainElement(element) && domainTypeEquals(element, domainName); - } - - /** - * Given an xml Domain element, return true if it's "type" attribute matches - * the given untranslated domain name - */ - public static boolean domainTypeEquals(IPropertySet element, String domainName) { - return (element.getPropertyValue(ISystemUDAConstants.XE_DOMTYPE).equals(domainName)); - } - - /** - * Checking not deleted. Still in document tree? - * (for Actions and Types). - * Needed by tree view/ Edit pane selection change processing. - * If current selection has validation errors, & user tries to - * change selection, want to set view back to the old selection, - * but have to confirm it hasn't been deleted, first. - * - * Do so by traversing the tree backwards, back to the Document root, - * then forwards again to verify the child links are in place. - */ - public static boolean inCurrentTree(IPropertySet n) { - String udaRootType = n.getPropertyValue(ISystemUDAConstants.UDA_ROOT_ATTR); - if (udaRootType != null && (udaRootType.equals(ISystemUDAConstants.ACTIONS_ROOT) || udaRootType.equals(ISystemUDAConstants.FILETYPES_ROOT))) - { - //It is one of the UDA related root. - return true; - } - IPropertySetContainer parent = n.getContainer(); - if (null == parent) return false; - // Recursive, walk tree back to root, then finally Document. - if (parent instanceof IPropertySet) - { - if (!inCurrentTree((IPropertySet)parent)) return false; - } - else - { - return false; - } - // Finally, check this is still a child of the parent - IPropertySet[] siblings = parent.getPropertySets(); - for (int i=0; i<siblings.length; i++) - { - if (n == siblings[i]) - { - return true; - } - } - return false; - } - - private int getOrder(IPropertySet elm) { - IProperty orderProperty = elm.getProperty(ISystemUDAConstants.ORDER_ATTR); - int order = -1; - - if (orderProperty != null) - { - order = Integer.valueOf(orderProperty.getValue()).intValue(); - } - return order; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDBaseTreeView.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDBaseTreeView.java deleted file mode 100644 index 4fd93e5b5..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDBaseTreeView.java +++ /dev/null @@ -1,820 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core - * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry - * David Dykstal (IBM) - [186589] move user types, user actions, and compile commands - * API to the user actions plugin - * David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared - * Kevin Doyle (IBM) - [222831] Can't Delete User Actions/Named Types - * Kevin Doyle (IBM) - [222827] Treeview is collapsed after creating new user action - * Kevin Doyle (IBM) - [239702] Copy/Paste doesn't work with User Defined Actions and Named Types - *******************************************************************************/ - -package org.eclipse.rse.internal.useractions.ui.uda; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.viewers.DoubleClickEvent; -import org.eclipse.jface.viewers.IDoubleClickListener; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.rse.core.RSECorePlugin; -import org.eclipse.rse.core.events.ISystemModelChangeEvents; -import org.eclipse.rse.core.model.IPropertySet; -import org.eclipse.rse.core.model.ISystemProfile; -import org.eclipse.rse.core.subsystems.ISubSystem; -import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; -import org.eclipse.rse.internal.ui.view.SystemViewMenuListener; -import org.eclipse.rse.internal.useractions.Activator; -import org.eclipse.rse.internal.useractions.IUserActionsMessageIds; -import org.eclipse.rse.internal.useractions.UserActionsResources; -import org.eclipse.rse.services.clientserver.messages.SimpleSystemMessage; -import org.eclipse.rse.services.clientserver.messages.SystemMessage; -import org.eclipse.rse.ui.ISystemContextMenuConstants; -import org.eclipse.rse.ui.SystemBasePlugin; -import org.eclipse.rse.ui.actions.ISystemAction; -import org.eclipse.rse.ui.messages.SystemMessageDialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.dnd.Clipboard; -import org.eclipse.swt.dnd.TextTransfer; -import org.eclipse.swt.dnd.Transfer; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Item; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.TreeItem; -import org.eclipse.swt.widgets.Widget; - -/** - * Base class for tree views for both actions and types. - */ -public class SystemUDBaseTreeView extends TreeViewer implements IMenuListener, IDoubleClickListener, ISystemUDTreeView { - protected Composite parent; - protected MenuManager menuMgr; - protected SystemUDBaseManager docManager; - protected ISubSystem subsystem; - protected ISubSystemConfiguration subsystemFactory; - protected ISystemProfile profile; - protected ISystemUDWorkWithDialog wwDialog; - protected SystemUDTreeActionCopy copyAction; - protected SystemUDTreeActionPaste pasteAction; - protected SystemUDTreeActionDelete deleteAction; - protected SystemUDTreeActionMoveUp moveUpAction; - protected SystemUDTreeActionMoveDown moveDownAction; - protected SystemUDARestoreDefaultsActions restoreAction; - protected Clipboard clipboard; - protected boolean menuListenerAdded; - - /** - * Constructor when we have a subsystem - */ - public SystemUDBaseTreeView(Composite parent, ISystemUDWorkWithDialog editPane, ISubSystem ss, SystemUDBaseManager docManager) { - //super(parent); - // I don't think multi-selection makes sense for this tree! Phil - super(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); // no SWT_MULTI - // this.shell = shell; - this.parent = parent; - this.subsystem = ss; - this.subsystemFactory = subsystem.getSubSystemConfiguration(); - this.profile = subsystem.getSystemProfile(); - this.docManager = docManager; - this.wwDialog = editPane; - init(); - getTree().addDisposeListener(new DisposeListener() { - public void widgetDisposed(DisposeEvent event) { - if (clipboard != null) clipboard.dispose(); - } - }); - } - - /** - * Constructor when we have a subsystem factory and profile - */ - public SystemUDBaseTreeView(Composite parent, ISystemUDWorkWithDialog editPane, ISubSystemConfiguration ssFactory, ISystemProfile profile, SystemUDBaseManager docManager) { - //super(parent); - // I don't think multi-selection makes sense for this tree! Phil - super(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); // no SWT_MULTI - // this.shell = shell; - this.parent = parent; - this.subsystemFactory = ssFactory; - this.profile = profile; - this.docManager = docManager; - this.wwDialog = editPane; - init(); - getTree().addDisposeListener(new DisposeListener() { - public void widgetDisposed(DisposeEvent event) { - if (clipboard != null) clipboard.dispose(); - } - }); - } - - protected void init() { - setContentProvider(docManager); - setLabelProvider(new SystemUDBaseTreeViewLabelProvider(docManager)); - // For double-click on "New..." items in tree - addDoubleClickListener(this); - //setAutoExpandLevel(2); // does not work!! - // ----------------------------- - // Enable right-click popup menu - // ----------------------------- - menuMgr = new MenuManager("#UDTreePopupMenu"); //$NON-NLS-1$ - // menuMgr = new SystemSubMenuManager("#UDTreePopupMenu"); - menuMgr.setRemoveAllWhenShown(true); - menuMgr.addMenuListener(this); - Menu menu = menuMgr.createContextMenu(getTree()); - getTree().setMenu(menu); - /**/ - setInput("0"); // this should trigger displaying the roots //$NON-NLS-1$ - } - - /** - * Expand the non-new domain (parent) nodes - */ - public void expandDomainNodes() { - // for usability we try to auto-expand the domain (parent) nodes... - if (docManager.getActionSubSystem().supportsDomains()) { - TreeItem[] rootItems = getTree().getItems(); - for (int idx = 0; idx < rootItems.length; idx++) { - if (rootItems[idx].getData() instanceof SystemXMLElementWrapper) // assume a domain node - { - setExpandedState(rootItems[idx].getData(), true); - } else if (rootItems[idx].getData() instanceof SystemUDTreeViewNewItem) { - SystemUDTreeViewNewItem newNode = (SystemUDTreeViewNewItem) rootItems[idx].getData(); - if (!newNode.isExecutable()) setExpandedState(rootItems[idx].getData(), true); - } - } - } - } - - /** - * Expand the given domain (parent) node, named by its - * translatable name. - */ - public void expandDomainNode(String displayName) { - // for usability we try to auto-expand the domain (parent) nodes... - if (docManager.getActionSubSystem().supportsDomains()) { - TreeItem[] rootItems = getTree().getItems(); - for (int idx = 0; idx < rootItems.length; idx++) { - if (rootItems[idx].getData() instanceof SystemXMLElementWrapper) // assume a domain node - { - //System.out.println(rootItems[idx].getText()); - if (rootItems[idx].getText().equals(displayName)) { - setExpandedState(rootItems[idx].getData(), true); - return; - } - } - } - } - } - - /** - * Called when the context menu is about to open. - * Calls {@link #fillContextMenu(IMenuManager)} - */ - public void menuAboutToShow(IMenuManager menu) { - fillContextMenu(menu); - if (!menuListenerAdded) { - if (menu instanceof MenuManager) { - Menu m = ((MenuManager) menu).getMenu(); - if (m != null) { - menuListenerAdded = true; - SystemViewMenuListener ml = new SystemViewMenuListener(); - //ml.setShowToolTipText(true, wwDialog.getMessageLine()); does not work for some reason - m.addMenuListener(ml); - } - } - } - } - - /** - * This is method is called to populate the popup menu - */ - public void fillContextMenu(IMenuManager menu) { - IStructuredSelection selection = (IStructuredSelection) getSelection(); - // this code assumes single select. if we ever change to allow multiple selection, - // this code will have to change - int selectionCount = selection.size(); - if (selectionCount > 0) // something selected - { - Object firstSelection = selection.getFirstElement(); - if ((firstSelection instanceof SystemXMLElementWrapper) && !((SystemXMLElementWrapper) firstSelection).isDomain()) { - // Partition into groups... - createStandardGroups(menu); - ISystemAction action = getDeleteAction(selection); - menu.appendToGroup(action.getContextMenuGroup(), action); - action = getCopyAction(selection); - menu.appendToGroup(action.getContextMenuGroup(), action); - action = getPasteAction(selection); - menu.appendToGroup(action.getContextMenuGroup(), action); - action = getMoveUpAction(selection); - menu.appendToGroup(action.getContextMenuGroup(), action); - action = getMoveDownAction(selection); - menu.appendToGroup(action.getContextMenuGroup(), action); - action = getRestoreAction(selection); - if (action != null) menu.appendToGroup(action.getContextMenuGroup(), action); - } else if ((firstSelection instanceof SystemXMLElementWrapper) && ((SystemXMLElementWrapper) firstSelection).isDomain()) { - // Partition into groups... - createStandardGroups(menu); - ISystemAction action = getPasteAction(selection); - menu.appendToGroup(action.getContextMenuGroup(), action); - } - } - } - - /** - * Creates the Systems plugin standard groups in a context menu. - */ - public void createStandardGroups(IMenuManager menu) { - if (!menu.isEmpty()) return; - menu.add(new Separator(ISystemContextMenuConstants.GROUP_REORGANIZE)); // rename,move,copy,delete,bookmark,refactoring - menu.add(new Separator(ISystemContextMenuConstants.GROUP_REORDER)); // move up, move down - menu.add(new Separator(ISystemContextMenuConstants.GROUP_CHANGE)); // restore - menu.add(new Separator(ISystemContextMenuConstants.GROUP_ADDITIONS)); // user or BP/ISV additions - } - - /** - * Get the delete action - */ - private SystemUDTreeActionDelete getDeleteAction(ISelection selection) { - if (deleteAction == null) deleteAction = new SystemUDTreeActionDelete(this); - deleteAction.setInputs(getShell(), this, selection); - return deleteAction; - } - - /** - * Get the move up action - */ - private SystemUDTreeActionMoveUp getMoveUpAction(ISelection selection) { - if (moveUpAction == null) moveUpAction = new SystemUDTreeActionMoveUp(this); - moveUpAction.setInputs(getShell(), this, selection); - return moveUpAction; - } - - /** - * Get the move down action - */ - private SystemUDTreeActionMoveDown getMoveDownAction(ISelection selection) { - if (moveDownAction == null) moveDownAction = new SystemUDTreeActionMoveDown(this); - moveDownAction.setInputs(getShell(), this, selection); - return moveDownAction; - } - - /** - * Get the copy action - */ - private SystemUDTreeActionCopy getCopyAction(ISelection selection) { - if (copyAction == null) copyAction = new SystemUDTreeActionCopy(this); - copyAction.setInputs(getShell(), this, selection); - return copyAction; - } - - /** - * Get the paste action - */ - private SystemUDTreeActionPaste getPasteAction(ISelection selection) { - if (pasteAction == null) pasteAction = new SystemUDTreeActionPaste(this); - pasteAction.setInputs(getShell(), this, selection); - return pasteAction; - } - - /** - * Get the restore defaults action - */ - protected SystemUDARestoreDefaultsActions getRestoreAction(ISelection selection) { - if (restoreAction == null) restoreAction = new SystemUDARestoreDefaultsActions(this); - restoreAction.setShell(getShell()); - if (selection != null) restoreAction.setSelection(selection); - return restoreAction; - } - - /** - * Convenience method for returning the shell of this viewer. - */ - public Shell getShell() { - return getTree().getShell(); - } - - /** - * Clear the clipboard - */ - public void clearClipboard() { - if (clipboard != null) { - clipboard.dispose(); - clipboard = null; - } - } - - // ---------------------------------- - // METHODS USED BY POPUP MENU ACTIONS - // ---------------------------------- - /** - * Decide if we can do the delete or not. - * Decision deferred to work-with dialog hosting this tree - */ - public boolean canDelete() { - return wwDialog.canDelete(((IStructuredSelection) getSelection()).getFirstElement()); - } - - /** - * Return true if the currently selected item can be moved up or not. - * Called by the SystemUDTreeActionMoveUp action class. - */ - public boolean canMoveUp() { - return wwDialog.canMoveUp(((IStructuredSelection) getSelection()).getFirstElement()); - } - - /** - * Return true if the currently selected item can be moved down or not. - * Called by the SystemUDTreeActionMoveDown action class. - */ - public boolean canMoveDown() { - return wwDialog.canMoveDown(((IStructuredSelection) getSelection()).getFirstElement()); - } - - /** - * Return true if the currently selected item can be copied to the clipboard or not. - * Called by the SystemChangeFilterActionCopyString action class. - */ - public boolean canCopy() { - return wwDialog.canCopy(((IStructuredSelection) getSelection()).getFirstElement()); - } - - /** - * Return true if the current contents of the clipboard apply to us or not. - * Called by the SystemUDTreeActionPaste action class. - */ - public boolean canPaste() { - if (clipboard == null) return false; - IStructuredSelection selection = (IStructuredSelection) getSelection(); - if (!(selection.getFirstElement() instanceof SystemXMLElementWrapper)) return false; - SystemXMLElementWrapper firstSelect = (SystemXMLElementWrapper) selection.getFirstElement(); - TextTransfer textTransfer = TextTransfer.getInstance(); - String textData = (String) clipboard.getContents(textTransfer); - return docManager.enablePaste(firstSelect, textData); - } - - /** - * Actually do the delete of currently selected item. - * Return true if it worked. Return false if it didn't (eg, user cancelled confirm) - * Called by the SystemUDTreeActionDelete action class. - */ - public boolean doDelete() { - IStructuredSelection selection = (IStructuredSelection) getSelection(); - boolean deleted = false; - SystemMessage confirmDlt = getDeleteConfirmationMessage(); - SystemMessageDialog msgDlg = new SystemMessageDialog(getShell(), confirmDlt); - try { - deleted = msgDlg.openQuestion(); - if (deleted) { - docManager.delete(docManager.getCurrentProfile(), (SystemXMLElementWrapper) selection.getFirstElement()); - docManager.saveUserData(docManager.getCurrentProfile()); - deleted = true; - } - } catch (Exception exc) { - SystemBasePlugin.logError("Error deleting user actions", exc); //$NON-NLS-1$ - } - if (deleted) { - remove(selection.getFirstElement()); - RSECorePlugin.getTheSystemRegistry().fireModelChangeEvent(ISystemModelChangeEvents.SYSTEM_RESOURCE_REMOVED, getResourceType(), selection.getFirstElement(), null); - } - return deleted; - } - - /** - * Return the {@link org.eclipse.rse.core.events.ISystemModelChangeEvents} constant representing the resource type managed by this tree. - * This must be overridden. - */ - protected int getResourceType() { - return -1; - } - - /** - * Return message for delete confirmation - */ - protected SystemMessage getDeleteConfirmationMessage() { - SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, - IUserActionsMessageIds.MSG_CONFIRM_DELETE_USERACTION, - IStatus.ERROR, UserActionsResources.MSG_CONFIRM_DELETE_USERACTION, UserActionsResources.MSG_CONFIRM_DELETE_USERTYPE_DETAILS); - msg.setIndicator(SystemMessage.INQUIRY); - return msg; - } - - /** - * Actually do the move up of currently selected item. - * Return true if all went well. - * Called by the SystemUDTreeActionMoveUp action class. - */ - public boolean doMoveUp() { - IStructuredSelection selection = (IStructuredSelection) getSelection(); - SystemXMLElementWrapper firstSelect = (SystemXMLElementWrapper) selection.getFirstElement(); - //SystemXMLElementWrapper previousElement = (SystemXMLElementWrapper) getSelectedPreviousTreeItem().getData(); - boolean moved = docManager.moveElementUp(firstSelect/*, previousElement*/); - if (moved) { - refreshElementParent(firstSelect); - selectElement(firstSelect); - docManager.saveUserData(docManager.getCurrentProfile()); - RSECorePlugin.getTheSystemRegistry().fireModelChangeEvent(ISystemModelChangeEvents.SYSTEM_RESOURCE_REORDERED, getResourceType(), firstSelect, null); - } - return true; - } - - /** - * Actually do the move down of currently selected item. - * Return true if all went well. - * Called by the SystemUDTreeActionMoveDown action class. - */ - public boolean doMoveDown() { - IStructuredSelection selection = (IStructuredSelection) getSelection(); - SystemXMLElementWrapper firstSelect = (SystemXMLElementWrapper) selection.getFirstElement(); - //SystemXMLElementWrapper nextElement = null; - //if (nextNextItem != null) nextElement = (SystemXMLElementWrapper) nextNextItem.getData(); - boolean moved = docManager.moveElementDown(firstSelect/*, nextElement*/); - if (moved) { - refreshElementParent(firstSelect); - selectElement(firstSelect); - docManager.saveUserData(docManager.getCurrentProfile()); - RSECorePlugin.getTheSystemRegistry().fireModelChangeEvent(ISystemModelChangeEvents.SYSTEM_RESOURCE_REORDERED, getResourceType(), firstSelect, null); - } - return true; - } - - /** - * Actually do the copy of currently selected item to the clipboard. - * Return true if all went well. - * Called by the SystemChangeFilterActionCopyString action class. - */ - public boolean doCopy() { - IStructuredSelection selection = (IStructuredSelection) getSelection(); - SystemXMLElementWrapper firstSelect = (SystemXMLElementWrapper) selection.getFirstElement(); - if (clipboard == null) clipboard = new Clipboard(getShell().getDisplay()); - String id = docManager.prepareClipboardCopy(firstSelect); - if (id == null) return false; - TextTransfer transfer = TextTransfer.getInstance(); - clipboard.setContents(new Object[] { id }, new Transfer[] { transfer }); - return true; - } - - /** - * Actually do the paste of clipboard contents relative to currently selected object. - * Return true if all went well. - * Called by the SystemUDTreeActionPaste action class. - */ - public boolean doPaste() { - if (clipboard == null) return false; - IStructuredSelection selection = (IStructuredSelection) getSelection(); - SystemXMLElementWrapper firstSelect = (SystemXMLElementWrapper) selection.getFirstElement(); - TextTransfer textTransfer = TextTransfer.getInstance(); - String textData = (String) clipboard.getContents(textTransfer); - SystemXMLElementWrapper pastedElementWrapper = docManager.pasteClipboardCopy(firstSelect, textData); - if (pastedElementWrapper != null) { - if (firstSelect.isDomain()) { - refresh(firstSelect); - setExpandedState(firstSelect, true); // force expansion, just in case - } else - refreshElementParent(firstSelect); - selectElement(pastedElementWrapper); - RSECorePlugin.getTheSystemRegistry().fireModelChangeEvent(ISystemModelChangeEvents.SYSTEM_RESOURCE_ADDED, getResourceType(), pastedElementWrapper, null); - } - clipboard.dispose(); - clipboard = null; - return (pastedElementWrapper != null); - } - - /** - * Return true if we are to enable the Restore Defaults actions - */ - public boolean canRestore() { - if (wwDialog.areChangesPending()) return false; - SystemXMLElementWrapper selectedElement = getSelectedElement(); - if ((selectedElement == null) || !((selectedElement instanceof SystemUDActionElement) || (selectedElement instanceof SystemUDTypeElement))) return false; - return selectedElement.isIBM() && selectedElement.isUserChanged(); - } - - /** - * Restore the selected action/type to its IBM-supplied default value. - * Needs to be overridden by children that want to support it. - */ - public void doRestore() { - } - - // -------------- - // Miscellaneous - // -------------- - /** - * Return the action or type manager - */ - public SystemUDBaseManager getDocumentManager() { - return docManager; - } - - // For Interface IDoubleClickListener - // For double-click on "New..." items in tree - public void doubleClick(DoubleClickEvent event) { - } - - /** - * Get the selected action or type name. - * Returns "" if nothing selected - */ - public String getSelectedElementName() { - String seldName = ""; //$NON-NLS-1$ - IStructuredSelection sel = (IStructuredSelection) getSelection(); - if ((sel != null) && (sel.getFirstElement() != null)) { - Object selObj = sel.getFirstElement(); - if (selObj instanceof SystemXMLElementWrapper) seldName = ((SystemXMLElementWrapper) selObj).toString(); - } - return seldName; - } - - /** - * Return true if currently selected element is "ALL" - */ - public boolean isElementAllSelected() { - return getSelectedElementName().equals("ALL"); //$NON-NLS-1$ - } - - /** - * Return true if currently selected element is vendor supplied - */ - public boolean isSelectionVendorSupplied() { - SystemXMLElementWrapper selectedElement = getSelectedElement(); - if (selectedElement != null) { - String vendor = selectedElement.getVendor(); - //System.out.println("Vendor value: '"+vendor+"'"); - return ((vendor != null) && (vendor.length() > 0)); - } - return false; - } - - /** - * Return the vendor that is responsible for pre-supplying this existing type, - * or null if not applicable. - */ - public String getVendorOfSelection() { - SystemXMLElementWrapper selectedElement = getSelectedElement(); - if (selectedElement != null) { - String vendor = selectedElement.getVendor(); - if ((vendor != null) && (vendor.length() > 0)) return vendor; - } - return null; - } - - /** - * Get the selected action or type domain. - * Returns -1 if nothing selected or domains not supported - */ - public int getSelectedElementDomain() { - int seldDomain = -1; - IStructuredSelection sel = (IStructuredSelection) getSelection(); - if ((sel != null) && (sel.getFirstElement() != null)) { - Object selObj = sel.getFirstElement(); - if (selObj instanceof SystemXMLElementWrapper) seldDomain = ((SystemXMLElementWrapper) selObj).getDomain(); - } - return seldDomain; - } - - // ------------------------------------ - // HELPER METHODS CALLED FROM EDIT PANE - // ------------------------------------ - /** - * Return the selected non-domain element, or null if an existing element - * is not currently selected - */ - public SystemXMLElementWrapper getSelectedElement() { - IStructuredSelection sel = (IStructuredSelection) getSelection(); - if ((sel != null) && (sel.getFirstElement() != null)) { - Object selObj = sel.getFirstElement(); - if (selObj instanceof SystemXMLElementWrapper) { - SystemXMLElementWrapper selEle = (SystemXMLElementWrapper) selObj; - if (!selEle.isDomain()) return selEle; - } - } - return null; - } - - /** - * Select the given type - */ - public void selectElement(SystemXMLElementWrapper element) { - //System.out.println("Inside selectElement of tree for action: " + element); - // here is our problem: - // We are given an element object that wrappers an xml node object. - // These wrappers are re-created on the fly, whenever the tree is refreshed. - // So, we might not find a binary match on the wrapper. - // Hence, we need to see if there is such a match, and if not, then - // we have to walk the tree comparing the xml node objects. - // The assumption is that we are always given something that is in fact - // in the tree. - Widget w = findItem(element); - if (w != null) // we found it! - super.setSelection(new StructuredSelection(element), true); // select it - else { - //start walking! - TreeItem matchingItem = findElement(element.getElement()); - if (matchingItem != null) - super.setSelection(new StructuredSelection(matchingItem.getData()), true); // select it - else - super.setSelection((ISelection) null); // deselect what is currently selected - } - } - - /** - * Find the parent tree item of the given type. - * If it is not currently shown in the tree, or there is no parent, returns null. - */ - public TreeItem findParentItem(SystemXMLElementWrapper element) { -// IPropertySet parentElement = element.getParentDomainElement(); - // Since we use PropertySet's now we don't want the parent domain element, just the parent element - IPropertySet parentElement = element.getParentElement(); - TreeItem parentItem = null; - if (parentElement != null) - parentItem = findElement(parentElement); - else { - //System.out.println("asked to find parent item, yet there is no parent element"); - } - return parentItem; - } - - /** - * Refresh the parent of the given action. - * That is, find the parent and refresh the children. - * If the parent is not found, assume it is because it is new too, - * so refresh the whole tree. - */ - public void refreshElementParent(SystemXMLElementWrapper element) { - TreeItem parentItem = findParentItem(element); - if (parentItem == null) // parent not found? - { - //System.out.println("parentItem null. Refreshing tree"); - refresh(); // refresh whole tree - // now, try again to find parent to ensure it is expanded... - parentItem = findParentItem(element); - } else { - //System.out.println("parentItem not null. Refreshing it"); - refresh(parentItem.getData()); // refresh this element - } - if (parentItem != null) // should not happen - { - //System.out.println("parentItem not null. Expanded? " + parentItem.getExpanded()); - if (!parentItem.getExpanded()) // not expanded yet? - { - //System.out.println(" expanding parent... " + parentItem.getExpanded()); - setExpandedState(parentItem.getData(), true); // expand it now - } - } - } - - /** - * Given an xml node, find the wrapper for the element in the tree, - * scanning entire tree. - */ - private TreeItem findElement(IPropertySet searchNode) { - TreeItem match = null; - TreeItem[] roots = getTree().getItems(); - for (int idx = 0; (match == null) && (idx < roots.length); idx++) - match = findElement(roots[idx], searchNode); - return match; - } - - /** - * Given an xml node and parent tree item, find the wrapper for the element in the tree - * under the given parent. - */ - private TreeItem findElement(TreeItem parentItem, IPropertySet searchNode) { - TreeItem match = null; - // first, check for match on the given parent itself... - Object itemData = parentItem.getData(); - IPropertySet itemNode = null; - if ((itemData != null) && (itemData instanceof SystemXMLElementWrapper)) { - itemNode = ((SystemXMLElementWrapper) itemData).getElement(); - if (itemNode == searchNode) return parentItem; - } - // no match on parent, check kids... - TreeItem[] kids = parentItem.getItems(); - if (kids != null) for (int idx = 0; (match == null) && (idx < kids.length); idx++) - match = findElement(kids[idx], searchNode); - return match; - } - - /** - * Returns the tree item of the first selected object. - */ - public TreeItem getSelectedTreeItem() { - TreeItem[] selectedItems = getTree().getSelection(); - if ((selectedItems != null) && (selectedItems.length > 0)) - return selectedItems[0]; - else - return null; - } - - /** - * Returns the tree item of the sibling before the first selected object. - */ - public TreeItem getSelectedPreviousTreeItem() { - TreeItem selectedItem = getSelectedTreeItem(); - if (selectedItem == null) return null; - TreeItem[] siblings = null; - if (selectedItem.getParentItem() != null) - siblings = selectedItem.getParentItem().getItems(); - else - siblings = selectedItem.getParent().getItems(); - for (int idx = 0; idx < siblings.length; idx++) { - if (siblings[idx] == selectedItem) { - if (idx == 0) - return null; - else - return siblings[idx - 1]; - } - } - return null; - } - - /** - * Returns the tree item of the sibling after the first selected object. - */ - public TreeItem getSelectedNextTreeItem() { - TreeItem selectedItem = getSelectedTreeItem(); - if (selectedItem == null) return null; - TreeItem[] siblings = null; - if (selectedItem.getParentItem() != null) - siblings = selectedItem.getParentItem().getItems(); - else - siblings = selectedItem.getParent().getItems(); - for (int idx = 0; idx < siblings.length; idx++) { - if (siblings[idx] == selectedItem) { - if (idx >= (siblings.length - 1)) - return null; - else - return siblings[idx + 1]; - } - } - return null; - } - - /** - * Returns the tree item of the sibling two after the first selected object. - */ - public TreeItem getSelectedNextNextTreeItem() { - TreeItem selectedItem = getSelectedTreeItem(); - if (selectedItem == null) return null; - TreeItem[] siblings = null; - if (selectedItem.getParentItem() != null) - siblings = selectedItem.getParentItem().getItems(); - else - siblings = selectedItem.getParent().getItems(); - for (int idx = 0; idx < siblings.length; idx++) { - if (siblings[idx] == selectedItem) { - if (idx >= (siblings.length - 2)) - return null; - else - return siblings[idx + 2]; - } - } - return null; - } - - /** - * Move one tree item to a new location - */ - protected void moveTreeItem(Widget parentItem, Item item, Object src, int newPosition) { - if (getExpanded(item)) { - setExpanded(item, false); - refresh(src); // flush items from memory - } - createTreeItem(parentItem, src, newPosition); - //createTreeItem(parentItem, (new String("New")), newPosition); - //remove(src); - disassociate(item); - item.dispose(); - } - - /** - * Get the position of a tree item within its parent - */ - protected int getTreeItemPosition(Widget parentItem, Item childItem) { - int pos = -1; - Item[] children = null; - if (parentItem instanceof Item) - children = getItems((Item) parentItem); - else - children = getChildren(parentItem); - for (int idx = 0; (pos == -1) && (idx < children.length); idx++) { - if (children[idx] == childItem) pos = idx; - } - return pos; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDBaseTreeViewLabelProvider.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDBaseTreeViewLabelProvider.java deleted file mode 100644 index 81c7248b5..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDBaseTreeViewLabelProvider.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.uda; - -/******************************************************************************* - * Copyright (c) 2002, 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 - *******************************************************************************/ -//import org.eclipse.jface.util.ListenerList; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.swt.graphics.Image; - -/** - * Label provider for our user actions and named types tree views - */ -public class SystemUDBaseTreeViewLabelProvider extends LabelProvider { - private SystemUDBaseManager docManager; - - /** - * Constructor - */ - public SystemUDBaseTreeViewLabelProvider(SystemUDBaseManager docManager) { - super(); - this.docManager = docManager; - } - - /** - * Override of parent so we can supply an image, if we desire. - */ - public Image getImage(Object element) { - if (element instanceof SystemUDTreeViewNewItem) { - if (!((SystemUDTreeViewNewItem) element).isExecutable()) { - //System.out.println("Calling docManager.getNewImage..."); - return docManager.getNewImage(); - } else { - //System.out.println("Calling actionss.getDomainNewImage..."); - if (!docManager.isUserActionsManager()) - return docManager.getActionSubSystem().getDomainNewTypeImage(((SystemUDTreeViewNewItem) element).getDomain()); - else - return docManager.getActionSubSystem().getDomainNewImage(((SystemUDTreeViewNewItem) element).getDomain()); - } - } else if (element instanceof SystemXMLElementWrapper) { - if (((SystemXMLElementWrapper) element).isDomain()) - return docManager.getActionSubSystem().getDomainImage(((SystemXMLElementWrapper) element).getDomain()); - else - return ((SystemXMLElementWrapper) element).getImage(); - } - return null; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDSelectTypesForm.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDSelectTypesForm.java deleted file mode 100644 index 0a8859092..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDSelectTypesForm.java +++ /dev/null @@ -1,478 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.uda; - -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - *******************************************************************************/ -import java.util.Vector; - -import org.eclipse.rse.core.model.ISystemProfile; -import org.eclipse.rse.core.subsystems.ISubSystem; -import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; -import org.eclipse.rse.internal.useractions.ui.uda.actions.SystemWorkWithFileTypesAction; -import org.eclipse.rse.ui.SystemWidgetHelpers; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.List; -import org.eclipse.swt.widgets.Shell; - -/** - * This is a subclassable and configurable encapsulation of a - * composite that allows users to select file types from a master - * list, as well as edit that master list. - * <p> - * It is used in the edit pane of the Work With User Actions - * dialog, to allow the user to indicate which file types this - * action is scoped to. - */ -public class SystemUDSelectTypesForm implements SelectionListener { - // inputs - protected Shell shell; - protected ISubSystem subsystem = null; - protected ISubSystemConfiguration subsystemFactory = null; - protected ISystemProfile profile; - protected SystemUDTypeManager udtm; - protected int domain; - protected String groupLabel, groupTooltip; - protected String masterListLabel, masterListTooltip; - protected String ourListLabel, ourListTooltip; - protected String ALL_TYPE = "ALL"; //$NON-NLS-1$ - protected String[] inpMasterTypes = { ALL_TYPE }; - protected String[] inpSelectedTypes = { ALL_TYPE }; - protected Vector listeners = new Vector(); - // widgets - protected Composite composite_prompts; - protected List masterList; - protected List ourList; - protected Button addButton, rmvButton, editButton; - protected Label verbageLabel; - protected Label msgLine; - // static - protected String[] ALL_TYPE_ARRAY = { ALL_TYPE }; - - /** - * Constructor for SystemUDSelectTypesForm, when we have a subsystem. - */ - public SystemUDSelectTypesForm(Shell shell, ISubSystem subsystem, SystemUDTypeManager mgr) { - super(); - this.shell = shell; - this.subsystem = subsystem; - this.subsystemFactory = subsystem.getSubSystemConfiguration(); - this.profile = subsystem.getSystemProfile(); - this.udtm = mgr; - setGroupLabel(SystemUDAResources.RESID_UDA_TYPE_LIST_LABEL, SystemUDAResources.RESID_UDA_TYPE_LIST_TOOLTIP); - setMasterListLabel(SystemUDAResources.RESID_UDA_TYPE_LIST_MASTER_LABEL, SystemUDAResources.RESID_UDA_TYPE_LIST_MASTER_TOOLTIP); - setSelectedListLabel(SystemUDAResources.RESID_UDA_TYPE_LIST_SELECTED_LABEL, SystemUDAResources.RESID_UDA_TYPE_LIST_SELECTED_TOOLTIP); - } - - /** - * Constructor for SystemUDSelectTypesForm, when we have a subsystem factory and profile - */ - public SystemUDSelectTypesForm(Shell shell, ISubSystemConfiguration subsystemFactory, ISystemProfile profile, SystemUDTypeManager mgr) { - super(); - this.shell = shell; - this.subsystemFactory = subsystemFactory; - this.profile = profile; - this.udtm = mgr; - setGroupLabel(SystemUDAResources.RESID_UDA_TYPE_LIST_LABEL, SystemUDAResources.RESID_UDA_TYPE_LIST_TOOLTIP); - setMasterListLabel(SystemUDAResources.RESID_UDA_TYPE_LIST_MASTER_LABEL, SystemUDAResources.RESID_UDA_TYPE_LIST_MASTER_TOOLTIP); - setSelectedListLabel(SystemUDAResources.RESID_UDA_TYPE_LIST_SELECTED_LABEL, SystemUDAResources.RESID_UDA_TYPE_LIST_SELECTED_TOOLTIP); - } - - // ------------------------ - // CONFIGURATION METHODS... - // ------------------------ - /** - * Set what type string represents "all". - * The default is "ALL" - */ - public void setAllType(String allType) { - this.ALL_TYPE = allType; - ALL_TYPE_ARRAY = new String[] { allType }; - } - - /** - * Configuration method. - * <p> - * Set the verbage and tooltip for the overall group - * <p> - */ - public void setGroupLabel(String label, String tooltip) { - this.groupLabel = label; - this.groupTooltip = tooltip; - } - - /** - * Configuration method. - * Set the label and tooltip for the master list of all defined types - */ - public void setMasterListLabel(String label, String tooltip) { - this.masterListLabel = label; - this.masterListTooltip = tooltip; - } - - /** - * Configuration method. - * Set the label and tooltip for the user-select list of types for this action, - */ - public void setSelectedListLabel(String label, String tooltip) { - this.ourListLabel = label; - this.ourListTooltip = tooltip; - } - - /** - * Set the whole form to be visible or not - */ - public void setVisible(boolean visible) { - if (composite_prompts != null) { - verbageLabel.setVisible(visible); - composite_prompts.setVisible(visible); - } - } - - /** - * Set the domain of the action we are creating or editing. - */ - public void setDomain(int domain) { - this.domain = domain; - } - - // --------------------------------- - // LISTENER CONFIGURATION METHODS... - // --------------------------------- - public void addSelectionListener(ISystemUDSelectTypeListener l) { - listeners.add(l); - } - - // ----------------------------- - // DATA CONFIGURATION METHODS... - // ----------------------------- - /** - * Set the initial master list of all defined types - */ - public void setMasterTypes(String[] types) { - this.inpMasterTypes = types; - if (masterList != null) { - masterList.removeAll(); - if (types != null) { - masterList.setItems(types); - if (types.length > 0) { - masterList.select(0); - addButton.setEnabled(true); - } - } - setMessage(masterList); - } - } - - /** - * Set the initial list of all types selected for this action. - * For "new" actions, you don't have to call this to insert ALL, - * as that is done for you - */ - public void setTypes(String[] types) { - this.inpSelectedTypes = types; - if (ourList != null) { - ourList.removeAll(); - if (types != null) { - ourList.setItems(types); - if (types.length > 0) { - ourList.select(0); - } - } - enableDisableRmvButton(); - setMessage(ourList); - } - } - - /** - * Reset the master types list to just "ALL" - */ - public void resetMasterTypes() { - setMasterTypes(ALL_TYPE_ARRAY); - } - - /** - * Reset the user-selected types to just "ALL" - */ - public void resetTypes() { - setTypes(ALL_TYPE_ARRAY); - } - - /** - * Reset state (like when now working on a new action) - */ - public void reset() { - resetMasterTypes(); - resetTypes(); - /* - masterList.removeAll(); - inpMasterTypes = ALL_TYPE_ARRAY; - masterList.setItems(inpMasterTypes); - - inpSelectedTypes = ALL_TYPE_ARRAY; - ourList.removeAll(); - ourList.setItems(inpSelectedTypes); - */ - } - - // -------------------------- - // DATA EXTRACTION METHODS... - // -------------------------- - /** - * Return the master list of defined types. - * This may have changed by way of the user pressing Edit - */ - public String[] getMasterTypes() { - return masterList.getItems(); - } - - /** - * Return the list of user-selected types, as an array of strings. - * Never an empty list! Enforced to select at least one type, which is defaulted to <ALL> - */ - public String[] getTypes() { - return ourList.getItems(); - } - - // ------------------------ - // INTERNAL METHODS... - // ------------------------ - /** - * Create the widgets and populate the composite. - * @param parent - the parent composite these widgets will be added to (actually we create our own composite to hold the widgets) - * @param span - the number of columns within the parent composite that our widgets are to span - */ - public Composite createContents(Composite parent, int span) { - verbageLabel = SystemWidgetHelpers.createVerbiage(parent, groupLabel, span, false, -1); - //addFillerLine(parent, span); - int nbrColumns = 3; - //composite_prompts = SystemWidgetHelpers.createGroupComposite(parent, nbrColumns, groupLabel); - composite_prompts = SystemWidgetHelpers.createFlushComposite(parent, nbrColumns); - composite_prompts.setToolTipText(groupTooltip); - ((GridData) composite_prompts.getLayoutData()).horizontalSpan = span; - ((GridLayout) composite_prompts.getLayout()).marginHeight = 0; - ((GridLayout) composite_prompts.getLayout()).marginWidth = 2; - masterList = createListBox(composite_prompts, masterListLabel, masterListTooltip); - Composite middle_composite = SystemWidgetHelpers.createComposite(composite_prompts, 1); - ((GridLayout) middle_composite.getLayout()).marginWidth = 0; - SystemWidgetHelpers.createLabel(middle_composite, ""); //$NON-NLS-1$ - Composite button_composite = SystemWidgetHelpers.createTightComposite(middle_composite, 1); - addButton = SystemWidgetHelpers.createPushButton(button_composite, null, SystemUDAResources.RESID_UDA_TYPE_ADD_BUTTON_LABEL, SystemUDAResources.RESID_UDA_TYPE_ADD_BUTTON_TOOLTIP); - rmvButton = SystemWidgetHelpers.createPushButton(button_composite, null, SystemUDAResources.RESID_UDA_TYPE_RMV_BUTTON_LABEL, SystemUDAResources.RESID_UDA_TYPE_RMV_BUTTON_TOOLTIP); - editButton = SystemWidgetHelpers.createPushButton(button_composite, null, SystemUDAResources.RESID_UDA_TYPE_EDIT_BUTTON_LABEL, SystemUDAResources.RESID_UDA_TYPE_EDIT_BUTTON_TOOLTIP); - Label bottomFiller = SystemWidgetHelpers.createLabel(button_composite, ""); //$NON-NLS-1$ - ((GridData) bottomFiller.getLayoutData()).grabExcessVerticalSpace = true; - ((GridData) bottomFiller.getLayoutData()).verticalAlignment = GridData.FILL; - ourList = createListBox(composite_prompts, ourListLabel, ourListTooltip); - msgLine = SystemWidgetHelpers.createLabel(composite_prompts, "");//, 1, true); //$NON-NLS-1$ - ((GridData) msgLine.getLayoutData()).horizontalSpan = nbrColumns; - ((GridData) msgLine.getLayoutData()).widthHint = 150; - // add our own listeners to our own widgets - masterList.addSelectionListener(this); - ourList.addSelectionListener(this); - addButton.addSelectionListener(this); - rmvButton.addSelectionListener(this); - editButton.addSelectionListener(this); - boolean enableAdd = false; - boolean enableRmv = false; - // prefill data - if (inpMasterTypes != null) { - masterList.setItems(inpMasterTypes); - if (inpMasterTypes.length > 0) { - masterList.select(0); - enableAdd = true; - } - } - if (inpSelectedTypes != null) { - ourList.setItems(inpSelectedTypes); - if (inpSelectedTypes.length > 0) { - ourList.select(0); - enableRmv = !inpSelectedTypes[0].equals(ALL_TYPE); - } - } - setMessage(ourList); - // initially disable buttons - addButton.setEnabled(enableAdd); - rmvButton.setEnabled(enableRmv); - return composite_prompts; - } - - /** - * create list box - */ - private List createListBox(Composite c, String label, String tooltip) { - List listbox = SystemWidgetHelpers.createListBox(c, null, false, label, tooltip); - ((GridData) listbox.getLayoutData()).widthHint = 50; - ((GridData) listbox.getLayoutData()).heightHint = 78; // 120 - return listbox; - } - - /** - * enable/disable rmv button - */ - private void enableDisableRmvButton() { - int selIdx = ourList.getSelectionIndex(); - rmvButton.setEnabled((selIdx >= 0) && !((ourList.getItemCount() == 1) && (ourList.getItem(0).equals(ALL_TYPE)))); - } - - /** - * SelectionListener interface. - * Called when button selected - */ - public void widgetSelected(SelectionEvent event) { - Object src = event.getSource(); - boolean fireEvent = false; - if (src == masterList) { - int selIdx = masterList.getSelectionIndex(); - addButton.setEnabled(selIdx >= 0); - enableDisableRmvButton(); - setMessage(masterList); - } else if (src == ourList) { - enableDisableRmvButton(); - setMessage(ourList); - } else if (src == rmvButton) { - int selIdx = ourList.getSelectionIndex(); - if (selIdx < 0) return; - ourList.remove(selIdx); - if (ourList.getItemCount() == 0) ourList.add(ALL_TYPE); - enableDisableRmvButton(); - fireEvent = true; - } else // add or edit - { - String[] selected = masterList.getSelection(); - String selection = null; - if ((selected != null) && (selected.length > 0)) { - selection = selected[0]; - } - int selIdx = -1; - if (src == addButton) { - if (selected == null || selection == null) // should never happen if our enablement is correct - { - addButton.setEnabled(false); - return; - } - // is the selected type already in the selected-list? - selIdx = ourList.indexOf(selection); - if (selIdx < 0) // no, not already in list - { - if (selection.equals(ALL_TYPE)) // adding ALL? - ourList.removeAll(); - else { - try { - ourList.remove(ALL_TYPE); - } catch (Exception exc) { - } - } - ourList.add(selection); - enableDisableRmvButton(); - fireEvent = true; - } - } else if (src == editButton) { - SystemWorkWithFileTypesAction editTypesAction = null; - if (subsystem != null) - editTypesAction = new SystemWorkWithFileTypesAction(shell, udtm.getActionSubSystem()); - else - editTypesAction = new SystemWorkWithFileTypesAction(shell, subsystemFactory, profile); - if (selection != null) { - editTypesAction.preSelectType(domain, selection); - } - editTypesAction.run(); - String outputSelectedTypeName = editTypesAction.getSelectedTypeName(); - int outputSelectedTypeDomain = editTypesAction.getSelectedTypeDomain(); - //System.out.println("outputSelectedTypeName = " + outputSelectedTypeName); - // the following will result in a callback to us to refresh the master list - fireSelectedListChange(false, true); - // now, select something in master list - if ((outputSelectedTypeName != null) && (outputSelectedTypeDomain == domain)) { - masterList.setSelection(new String[] { outputSelectedTypeName }); - masterList.showSelection(); - } else if (selection != null) masterList.setSelection(new String[] { selection }); - } - } - if (fireEvent) fireSelectedListChange(true, false); - } - - /** - * SelectionListener interface. - * Called when enter pressed on widget we are listening to - */ - public void widgetDefaultSelected(SelectionEvent event) { - } - - /** - * Set the text in the message line below the lists - */ - private void setMessage(List listbox) { - int selIdx = listbox.getSelectionIndex(); - if (selIdx < 0) - msgLine.setText(""); //$NON-NLS-1$ - else { - String type = listbox.getItem(selIdx); - String types = udtm.getTypesForTypeName(type, domain); - if (types == null) { - msgLine.setText(""); //$NON-NLS-1$ - msgLine.setToolTipText(""); //$NON-NLS-1$ - } else { - String msg = null; - if (types.length() > 35) - msg = type + ": " + types.substring(0, 34) + "..."; //$NON-NLS-1$ //$NON-NLS-2$ - else - msg = type + ": " + types; //$NON-NLS-1$ - //System.out.println(msg); - msgLine.setText(msg); - msgLine.setToolTipText(types); - } - } - } - - /** - * The user has changed the selected-types list. - * Inform all listeners - */ - private void fireSelectedListChange(boolean selectedListChanged, boolean masterListChanged) { - for (int idx = 0; idx < listeners.size(); idx++) { - if (selectedListChanged) ((ISystemUDSelectTypeListener) listeners.elementAt(idx)).selectedTypeListChanged(this); - if (masterListChanged) ((ISystemUDSelectTypeListener) listeners.elementAt(idx)).masterTypeListChanged(this); - } - } - - // ----------------------------- - // Helper methods... - // ----------------------------- - /** - * Add a separator line. This is a physically visible line. - */ - protected Label addSeparatorLine(Composite parent, int nbrColumns) { - Label separator = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL); - GridData data = new GridData(); - data.horizontalSpan = nbrColumns; - data.horizontalAlignment = GridData.FILL; - separator.setLayoutData(data); - return separator; - } - - /** - * Add a spacer line - */ - protected Label addFillerLine(Composite parent, int nbrColumns) { - Label filler = new Label(parent, SWT.LEFT); - GridData data = new GridData(); - data.horizontalSpan = nbrColumns; - data.horizontalAlignment = GridData.FILL; - filler.setLayoutData(data); - return filler; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDSimpleTypesListEditor.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDSimpleTypesListEditor.java deleted file mode 100644 index bc2ebcf99..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDSimpleTypesListEditor.java +++ /dev/null @@ -1,193 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.uda; - -/******************************************************************************* - * Copyright (c) 2002, 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 - * David Dykstal (IBM) - [186589] move user actions API out of org.eclipse.rse.ui - *******************************************************************************/ -import org.eclipse.rse.internal.useractions.ui.validators.ValidatorUserTypeTypes; -import org.eclipse.rse.services.clientserver.messages.SystemMessage; -import org.eclipse.rse.ui.SystemWidgetHelpers; -import org.eclipse.rse.ui.messages.ISystemMessageLine; -import org.eclipse.rse.ui.validators.ISystemValidator; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; - -/** - * Default implementation of ISystemUDTypeEditPaneTypesSelector, which is - * simply a labeled text field. - * These editors are used in the Named Types dialog, to prompt for the list of - * constituent types. - */ -public class SystemUDSimpleTypesListEditor implements ISystemUDTypeEditPaneTypesSelector { - protected Text textTypes; - protected Label typesLabel, nonEditableVerbage; - private boolean autoUpperCase = false; - private ISystemValidator typesValidator; - private int currentDomain = -1; - protected ISystemMessageLine msgLine; - protected Shell shell; - - /** - * constructor - */ - public SystemUDSimpleTypesListEditor(Composite parent, int nbrColumns) { - shell = parent.getShell(); - createContents(parent, nbrColumns); - setValidator(new ValidatorUserTypeTypes()); - } - - /** - * Set the msg line in case this composite widget needs to issue an error msg - */ - public void setMessageLine(ISystemMessageLine msgLine) { - this.msgLine = msgLine; - } - - /** - * Create and populate widgets - */ - protected void createContents(Composite parent, int nbrColumns) { - textTypes = SystemWidgetHelpers.createLabeledTextField(parent, null, SystemUDAResources.RESID_UDT_TYPES_LABEL, SystemUDAResources.RESID_UDT_TYPES_TOOLTIP); - typesLabel = SystemWidgetHelpers.getLastLabel(); - ((GridData) textTypes.getLayoutData()).horizontalSpan = nbrColumns - 1; - textTypes.setTextLimit(ValidatorUserTypeTypes.MAX_UDTTYPES_LENGTH); - nonEditableVerbage = SystemWidgetHelpers.createVerbiage(parent, "", nbrColumns, false, 200); //$NON-NLS-1$ - nonEditableVerbage.setVisible(false); - } - - /** - * Set domain. - * The edit pane may possibly appear differently, depending on the domain. - * When the domain changes (either in "new" or "edit" mode) this method is called. - */ - public void setDomain(int domain) { - this.currentDomain = domain; - } - - /** - * Get the domain of the currently selected existing new type, or "new" node. - */ - public int getDomain() { - return currentDomain; - } - - /** - * Set the validator to use for the types - */ - public void setValidator(ISystemValidator validator) { - typesValidator = validator; - } - - /** - * Initialize the types. These are stored as a single string using - * a subsystem-decidable delimiter character. - */ - public void setTypes(String types) { - textTypes.setText(types); - } - - /** - * Clear the types. That is, make sure none are selected. This is - * called when entering "new" mode. - */ - public void clearTypes() { - textTypes.setText(""); //$NON-NLS-1$ - } - - /** - * Retrieve the types as a single string. The delimiter used is up to - * the implementor, as long as it knows how to parse and assemble the - * types list as a single string. - */ - public String getTypes() { - if (autoUpperCase) - return textTypes.getText().trim().toUpperCase(); - else - return textTypes.getText().trim(); - } - - /** - * Allow the edit pane (or any consumer) to be informed as - * changes are made to the list. When events are fired, the consumer - * will call getTypes() to get the new list. - */ - public void addModifyListener(ModifyListener listener) { - textTypes.addModifyListener(listener); - } - - /** - * Allow the edit pane (or any consumer) to stop listening as - * changes are made to the list. - */ - public void removeModifyListener(ModifyListener listener) { - textTypes.removeModifyListener(listener); - } - - /** - * Validate input, and return the error message if an error is found. - * This is called by the consumer upon receipt of a modify event, to - * show any error messages and to know if there are errors pending or - * not. - */ - public SystemMessage validate() { - return typesValidator.validate(getTypes()); - } - - /** - * Return primary control for setting focus, among other things - */ - public Control getControl() { - return textTypes; - } - - /** - * Enable or disable the input-capability of the constituent controls - */ - public void setEnabled(boolean enable) { - textTypes.setEnabled(enable); - } - - /** - * We want to disable editing of IBM or vendor-supplied - * types, so when one of these is selected, this method is - * called to enter non-editable mode. - * @param editable Whether to disable editing of this type or not - * @param vendor When disabling, it contains the name of the vendor for substitution purposes - */ - public void setEditable(boolean editable, String vendor) { - textTypes.setEditable(editable); - if (editable) - nonEditableVerbage.setVisible(false); - else { - nonEditableVerbage.setVisible(true); - if (vendor.equals("IBM")) //$NON-NLS-1$ - nonEditableVerbage.setText(SystemUDAResources.RESID_UDT_IBM_VERBAGE); - else { - String verbage = SystemUDAResources.RESID_UDT_VENDOR_VERBAGE; - verbage = SystemMessage.sub(verbage, "%1", vendor); //$NON-NLS-1$ - nonEditableVerbage.setText(verbage); - } - } - } - - /** - * Not from interface. - * Specify if the types are to be auto-uppercased or not. - * Default is false. - */ - public void setAutoUpperCase(boolean autoUpperCase) { - this.autoUpperCase = autoUpperCase; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDTreeActionCopy.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDTreeActionCopy.java deleted file mode 100644 index 628b0ba28..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDTreeActionCopy.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.uda; - -/******************************************************************************* - * Copyright (c) 2002, 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 - *******************************************************************************/ -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.rse.ui.ISystemContextMenuConstants; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.actions.SystemBaseAction; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; - -/** - * The action allows users to copy the currently selected user action or type to the clipboard - */ -public class SystemUDTreeActionCopy extends SystemBaseAction { - private SystemUDBaseTreeView parentTreeView; - - /** - * Constructor - */ - public SystemUDTreeActionCopy(SystemUDBaseTreeView parentTreeView) { - super(SystemUDAResources.RESID_UDA_ACTION_COPY_LABEL, SystemUDAResources.RESID_UDA_ACTION_COPY_TOOLTIP, PlatformUI.getWorkbench().getSharedImages().getImageDescriptor( - ISharedImages.IMG_TOOL_COPY), null); - allowOnMultipleSelection(false); - this.parentTreeView = parentTreeView; - setContextMenuGroup(ISystemContextMenuConstants.GROUP_REORGANIZE); - setHelp(RSEUIPlugin.HELPPREFIX + "udac0000"); //$NON-NLS-1$ - } - - /** - * We override from parent to do unique checking. - * We intercept to ensure this is isn't the last action/type - */ - public boolean updateSelection(IStructuredSelection selection) { - return parentTreeView.canCopy(); - } - - /** - * This is the method called when the user selects this action. - */ - public void run() { - parentTreeView.doCopy(); - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDTreeActionDelete.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDTreeActionDelete.java deleted file mode 100644 index e54cf2362..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDTreeActionDelete.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.uda; - -/******************************************************************************* - * Copyright (c) 2002, 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 - *******************************************************************************/ -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.rse.ui.ISystemContextMenuConstants; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.actions.SystemBaseAction; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; - -/** - * The action allows users to delete the currently selected user action or type - */ -public class SystemUDTreeActionDelete extends SystemBaseAction { - private SystemUDBaseTreeView parentTreeView; - - /** - * Constructor - */ - public SystemUDTreeActionDelete(SystemUDBaseTreeView parentTreeView) { - super(SystemUDAResources.RESID_UDA_ACTION_DELETE_LABEL, SystemUDAResources.RESID_UDA_ACTION_DELETE_TOOLTIP, PlatformUI.getWorkbench().getSharedImages().getImageDescriptor( - ISharedImages.IMG_TOOL_DELETE), null); - allowOnMultipleSelection(false); - this.parentTreeView = parentTreeView; - setContextMenuGroup(ISystemContextMenuConstants.GROUP_REORGANIZE); - setHelp(RSEUIPlugin.HELPPREFIX + "udad0000"); //$NON-NLS-1$ - } - - /** - * We override from parent to do unique checking. - * We intercept to ensure this is isn't the last action/type - */ - public boolean updateSelection(IStructuredSelection selection) { - return parentTreeView.canDelete(); - } - - /** - * This is the method called when the user selects this action. - */ - public void run() { - parentTreeView.doDelete(); - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDTreeActionMoveDown.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDTreeActionMoveDown.java deleted file mode 100644 index 10232bde3..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDTreeActionMoveDown.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.uda; - -/******************************************************************************* - * Copyright (c) 2002, 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 - *******************************************************************************/ -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.rse.ui.ISystemContextMenuConstants; -import org.eclipse.rse.ui.ISystemIconConstants; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.actions.SystemBaseAction; - -/** - * The action allows users to move the currently selected user action or type down in the list - */ -public class SystemUDTreeActionMoveDown extends SystemBaseAction { - private SystemUDBaseTreeView parentTreeView; - - /** - * Constructor - */ - public SystemUDTreeActionMoveDown(SystemUDBaseTreeView parentTreeView) { - super(SystemUDAResources.RESID_UDA_ACTION_MOVEDOWN_LABEL, SystemUDAResources.RESID_UDA_ACTION_MOVEDOWN_TOOLTIP, RSEUIPlugin.getDefault().getImageDescriptor( - ISystemIconConstants.ICON_SYSTEM_MOVEDOWN_ID), null); - allowOnMultipleSelection(false); - this.parentTreeView = parentTreeView; - setContextMenuGroup(ISystemContextMenuConstants.GROUP_REORDER); - setHelp(RSEUIPlugin.HELPPREFIX + "udmd0000"); //$NON-NLS-1$ - } - - /** - * We override from parent to do unique checking. - * We intercept to ensure this is isn't the last action/type - */ - public boolean updateSelection(IStructuredSelection selection) { - return parentTreeView.canMoveDown(); - } - - /** - * This is the method called when the user selects this action. - */ - public void run() { - parentTreeView.doMoveDown(); - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDTreeActionMoveUp.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDTreeActionMoveUp.java deleted file mode 100644 index 7260d1301..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDTreeActionMoveUp.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.uda; - -/******************************************************************************* - * Copyright (c) 2002, 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 - *******************************************************************************/ -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.rse.ui.ISystemContextMenuConstants; -import org.eclipse.rse.ui.ISystemIconConstants; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.actions.SystemBaseAction; - -/** - * The action allows users to move the currently selected user action or type up in the list - */ -public class SystemUDTreeActionMoveUp extends SystemBaseAction { - private SystemUDBaseTreeView parentTreeView; - - /** - * Constructor - */ - public SystemUDTreeActionMoveUp(SystemUDBaseTreeView parentTreeView) { - super(SystemUDAResources.RESID_UDA_ACTION_MOVEUP_LABEL, SystemUDAResources.RESID_UDA_ACTION_MOVEUP_TOOLTIP, RSEUIPlugin.getDefault().getImageDescriptor( - ISystemIconConstants.ICON_SYSTEM_MOVEUP_ID), null); - allowOnMultipleSelection(false); - this.parentTreeView = parentTreeView; - setContextMenuGroup(ISystemContextMenuConstants.GROUP_REORDER); - setHelp(RSEUIPlugin.HELPPREFIX + "udmu0000"); //$NON-NLS-1$ - } - - /** - * We override from parent to do unique checking. - * We intercept to ensure this is isn't the fist action/type - */ - public boolean updateSelection(IStructuredSelection selection) { - return parentTreeView.canMoveUp(); - } - - /** - * This is the method called when the user selects this action. - */ - public void run() { - parentTreeView.doMoveUp(); - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDTreeActionPaste.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDTreeActionPaste.java deleted file mode 100644 index 90fe429a0..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDTreeActionPaste.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.uda; - -/******************************************************************************* - * Copyright (c) 2002, 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 - *******************************************************************************/ -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.rse.ui.ISystemContextMenuConstants; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.actions.SystemBaseAction; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; - -/** - * The action allows users to paste a user action or type from the clipboard - */ -public class SystemUDTreeActionPaste extends SystemBaseAction { - private SystemUDBaseTreeView parentTreeView; - - /** - * Constructor - */ - public SystemUDTreeActionPaste(SystemUDBaseTreeView parentTreeView) { - super(SystemUDAResources.RESID_UDA_ACTION_PASTE_LABEL, SystemUDAResources.RESID_UDA_ACTION_PASTE_TOOLTIP, PlatformUI.getWorkbench().getSharedImages().getImageDescriptor( - ISharedImages.IMG_TOOL_PASTE), null); - allowOnMultipleSelection(false); - this.parentTreeView = parentTreeView; - setContextMenuGroup(ISystemContextMenuConstants.GROUP_REORGANIZE); - setHelp(RSEUIPlugin.HELPPREFIX + "udap0000"); //$NON-NLS-1$ - } - - /** - * We override from parent to do unique checking. - * We intercept to ensure this is isn't the last action/type - */ - public boolean updateSelection(IStructuredSelection selection) { - return parentTreeView.canPaste(); - } - - /** - * This is the method called when the user selects this action. - */ - public void run() { - parentTreeView.doPaste(); - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDTreeViewNewItem.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDTreeViewNewItem.java deleted file mode 100644 index 041795bc7..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDTreeViewNewItem.java +++ /dev/null @@ -1,118 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.uda; - -/******************************************************************************* - * Copyright (c) 2002, 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 - *******************************************************************************/ -//import com.ibm.etools.systems.core.*; -/** - * This represent a tree-node for "New" items - */ -public class SystemUDTreeViewNewItem { - // state - private String label; - private boolean executable; // cascading or not? - private int domain = -1; - private boolean wwActionsDialog; // true for ww user actions, false for ww user types - // constants - private static SystemUDTreeViewNewItem rootActionInst, rootTypeInst; - private static SystemUDTreeViewNewItem rootActionOnlyInst, rootTypeOnlyInst; - - /** - * Constructor - * @param _executable -> true if this is a leaf node - * @param _label -> label to show the user, in the tre - * @param _domain -> domain this represents - * @param _wwActionsDialog -> true if this is for the ww user actions dialog, false for the ww named types dialog - */ - public SystemUDTreeViewNewItem(boolean _executable, String _label, int _domain, boolean _wwActionsDialog) { - super(); - label = _label; - executable = _executable; - domain = _domain; - wwActionsDialog = _wwActionsDialog; - } - - /** - * Return the label - */ - public String toString() { - return label; - } - - /** - * Is this executable? Ie, should it launch a "New" wizard? - */ - public boolean isExecutable() { - return executable; - } - - /** - * Is this the work with actions dialog (true) or the work with types dialog (false) - */ - public boolean isWorkWithActionsDialog() { - return wwActionsDialog; - } - - /** - * Get the domain this represents - */ - public int getDomain() { - return domain; - } - - /** - * Return singleon instance of new item that does have children. - * This is used for the first element when domains are supported. - * @param wwActionsDialog true if called from dialog - * @param newNodeLabel the translated label for the node. - */ - public static SystemUDTreeViewNewItem getRootNewItem(boolean wwActionsDialog, String newNodeLabel) { - if (wwActionsDialog) { - if (rootActionInst == null) rootActionInst = new SystemUDTreeViewNewItem(false, // this item is not executable - newNodeLabel, 0, wwActionsDialog); - return rootActionInst; - } else { - if (rootTypeInst == null) rootTypeInst = new SystemUDTreeViewNewItem(false, // this item is not executable - newNodeLabel, 0, wwActionsDialog); - return rootTypeInst; - } - } - - /** - * Return singleton instance of root new item that does not have children. - * This is used for the first element when domains are not supported. - * @param wwActionsDialog true if called from dialog - * @param newNodeLabel the translated label for the node. - */ - public static SystemUDTreeViewNewItem getOnlyNewItem(boolean wwActionsDialog, String newNodeLabel) { - if (wwActionsDialog) { - if (rootActionOnlyInst == null) rootActionOnlyInst = new SystemUDTreeViewNewItem(true, // this item is executable - newNodeLabel, -1, wwActionsDialog); - return rootActionOnlyInst; - } else { - if (rootTypeOnlyInst == null) rootTypeOnlyInst = new SystemUDTreeViewNewItem(true, // this item is executable - newNodeLabel, -1, wwActionsDialog); - return rootTypeOnlyInst; - } - } - - /** - * Return non-singleton instance of root new item that does not have children. - * This is used for the first element when domains are supported internally, but externally - * only one is used. - * @param domain - the domain to use - * @param wwActionsDialog - true if called from dialog - * @param newNodeLabel - the translated label for the node - */ - public static SystemUDTreeViewNewItem getOnlyNewItem(int domain, boolean wwActionsDialog, String newNodeLabel) { - return new SystemUDTreeViewNewItem(true, // this item is executable - newNodeLabel, domain, wwActionsDialog); - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDTypeEditPane.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDTypeEditPane.java deleted file mode 100644 index ca023264a..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDTypeEditPane.java +++ /dev/null @@ -1,536 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core - * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry - * David Dykstal (IBM) - [186589] move user types, user actions, and compile commands - * API to the user actions plugin - * Kevin Doyle (IBM) - [242717] Need a way to set the name validator of Named Types - *******************************************************************************/ - -package org.eclipse.rse.internal.useractions.ui.uda; - -import java.util.Vector; - -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.rse.core.RSECorePlugin; -import org.eclipse.rse.core.events.ISystemModelChangeEvents; -import org.eclipse.rse.core.model.ISystemProfile; -import org.eclipse.rse.core.subsystems.ISubSystem; -import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; -import org.eclipse.rse.internal.useractions.IUserActionsModelChangeEvents; -import org.eclipse.rse.internal.useractions.ui.validators.ValidatorUserTypeName; -import org.eclipse.rse.services.clientserver.messages.SystemMessage; -import org.eclipse.rse.ui.SystemWidgetHelpers; -import org.eclipse.rse.ui.validators.ISystemValidator; -import org.eclipse.rse.ui.validators.ISystemValidatorUniqueString; -import org.eclipse.rse.ui.widgets.SystemEditPaneStateMachine; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Text; - -/** - * This is the eidt pane on the right, when a named type is selected - * on the left (or "New" is selected). It is used to create or edit - * a named type definition, which is nothing more than a name associated - * with one or more file types. - */ -public class SystemUDTypeEditPane implements ISelectionChangedListener { - // gui - private Composite comp; - private Text textName; - private ISystemUDTypeEditPaneTypesSelector typesEditor; - // input - protected SystemUDActionSubsystem udaActionSubsys; - protected ISubSystem subsystem; - protected ISubSystemConfiguration subsystemFactory; - protected ISystemProfile profile; - protected ISystemUDTreeView treeView; - protected ISystemUDAEditPaneHoster parentDialog; - // validators - private ISystemValidator nameValidator; - // listeners - private NameModifyListener nameML = new NameModifyListener(); - private TypesModifyListener typesML = new TypesModifyListener(); - // current error message - private SystemMessage errorMessage; - // state related to current selection or state - private boolean newMode = false; - private boolean recursiveCall = false; - private int newModeDomain = -1; - private SystemUDTreeViewNewItem newModeNewItem; - private SystemEditPaneStateMachine stateMachine; - private int currentDomain = -1; - private SystemUDTypeElement currentType; - // misc state - private boolean nameChanged = false; - private boolean isEnabled = false; - private boolean ignoreChanges = false; - // constants - private static final Vector EMPTY_VECTOR = new Vector(); - - /** - * Constructor - */ - public SystemUDTypeEditPane(SystemUDActionSubsystem udaActionSubsys, ISystemUDAEditPaneHoster parent, ISystemUDTreeView tv) { - super(); - this.udaActionSubsys = udaActionSubsys; - subsystem = udaActionSubsys.getSubsystem(); - subsystemFactory = subsystem.getSubSystemConfiguration(); - this.profile = subsystem.getSystemProfile(); - //this.subsystemFactory = ss.getParentSubSystemFactory(); - //this.profile = ss.getSystemProfile(); - treeView = tv; - parentDialog = parent; - } - - /** - * Set domain. - * The edit pane may possibly appear differently, depending on the domain. - * When the domain changes (either in "new" or "edit" mode) this method is called. - */ - public void setDomain(int domain) { - this.currentDomain = domain; - if (typesEditor != null) typesEditor.setDomain(domain); - } - - /** - * Get the current domain. - * This is equivalent to newModeDomain in "new" mode, and currentType.getDomain() in "edit" mode - */ - public int getDomain() { - if (currentDomain == -1) { - if (newMode) - return newModeDomain; - else if (currentType != null) - return currentType.getDomain(); - else - return -1; - } else - return currentDomain; - } - - /** - * Set the state machine. - * Called by the UDA dialog - */ - public void setStateMachine(SystemEditPaneStateMachine sm) { - this.stateMachine = sm; - } - - /** - * Create widgets and populate/return composite - */ - public Control createContents(Composite parent) { - if (nameValidator == null) - nameValidator = new ValidatorUserTypeName(); - - // Inner composite - int nbrColumns = 2; - comp = SystemWidgetHelpers.createComposite(parent, nbrColumns); - // Action name - textName = SystemWidgetHelpers.createLabeledTextField(comp, null, SystemUDAResources.RESID_UDT_NAME_LABEL, SystemUDAResources.RESID_UDT_NAME_TOOLTIP); - // List of selected types as a single string... - typesEditor = createTypesListEditor(comp, nbrColumns); - typesEditor.setMessageLine(parentDialog); - // configuration of widgets... - textName.setTextLimit(ValidatorUserTypeName.MAX_UDTNAME_LENGTH); - return comp; - } - - /** - * Overridable exit point. - * Create the edit widgets that will allow the user to see and - * edit the list of file types that constitute this named type. - * <p> - * To better facilitate this, the only requirement is that this - * "editor" meet the minimal interface - * {@link org.eclipse.rse.internal.useractions.ui.uda.ISystemUDTypeEditPaneTypesSelector} - * <p> - * The default implementation is simply a labeled entry field! - * - * @param parent - the parent composite where the widgets are to go - * @param nbrColumns - the number of columns in the parent composite, which these - * widgets should span - * @return a class implementing the required interface - */ - protected ISystemUDTypeEditPaneTypesSelector createTypesListEditor(Composite parent, int nbrColumns) { - SystemUDSimpleTypesListEditor simpleEditor = new SystemUDSimpleTypesListEditor(parent, nbrColumns); - simpleEditor.setAutoUpperCase(getAutoUpperCaseTypes()); - return simpleEditor; - } - - /** - * Overridable exit point. - * Return true if the types are to be auto-uppercased. - * Default is true. - * Only used if not supplying your own types editor. - */ - protected boolean getAutoUpperCaseTypes() { - return true; - } - - /** - * Enable/disable entire pane - */ - public void setEnabled(boolean enable) { - textName.setEnabled(enable); - typesEditor.setEnabled(enable); - } - - /** - * Check all input for errors - * @param setFocus - true if to set focus on offending control - * @param skipControl - control to skip since already checked - * @return true if no errors - */ - protected boolean validateInput(boolean setFocus, Control skipControl) { - Control errCtl = null; - errorMessage = null; - if (skipControl != textName) errorMessage = nameValidator.validate(textName.getText().trim()); - errCtl = textName; - if ((errorMessage == null) && (skipControl != typesEditor.getControl())) { - errorMessage = typesEditor.validate(); - if (errorMessage == null) errorMessage = doTypesStringValidation(setFocus); - errCtl = typesEditor.getControl(); - } - if (errorMessage == null) errorMessage = doAdditionalValidation(setFocus); // let child classes try - if (errorMessage != null) { - parentDialog.setErrorMessage(errorMessage); - if (setFocus) errCtl.setFocus(); - } else - parentDialog.clearErrorMessage(); - setPageComplete(); - return (errorMessage == null); - } - - /** - * Overridable entry point for doing validation of the type string. - * Called by validateInput. - * If setFocus is true, set the focus at the appropriate widget that is in error. - * If setFocus is true, you can assume we are doing OK processing vs keystroke processor. - * @return error message if an error detected, else null - */ - protected SystemMessage doTypesStringValidation(boolean doSetFocus) { - return null; - } - - /** - * Overridable entry point for doing validation of input. - * Called by validateInput. - * If setFocus is true, set the focus at the appropriate widget that is in error. - * If setFocus is true, you can assume we are doing OK processing vs keystroke processor. - * @return error message if an error detected, else null - */ - protected SystemMessage doAdditionalValidation(boolean doSetFocus) { - return null; - } - - // Scenario: User edits an item, producing a syntax error. - // (eg. clear action name field) Gets error msg, OK button disabled. - // then changes selection to another item. - // Current Problem: Error msg stays, OK remains disabled, until - // they edit a field. (ValidateInput isnt re-reun until - // another field is changed.) - // Solution: When changing selection, reset the errorMessage and - // page-valid status. Can get away with this because we - // do not propagate invalid field changes to the UDA data in memory. - private void resetPageValidation() { - errorMessage = null; - parentDialog.clearErrorMessage(); - parentDialog.setPageComplete(true); - } - - /** - * Return true if the page is complete, so to enable Finish. - * Called by setPageComplete - */ - protected boolean isPageComplete() { - return ((errorMessage == null) && (textName.getText().trim().length() > 0) && (typesEditor.getTypes().length() > 0)); - } - - /** - * Set page complete... enables/disables Apply button - */ - protected void setPageComplete() { - boolean complete = isPageComplete(); - parentDialog.setPageComplete(complete); - } - - /** - * Call this whenever the user makes ANY changes. - * Used to enable/disable apply/revert buttons - */ - protected void setChangesMade() { - if (stateMachine != null) stateMachine.setChangesMade(); - } - - /** - * Are errors pending? If so, don't allow user to change selection - * or profile or anything! - */ - public boolean areErrorsPending() { - return ((errorMessage != null) && ((currentType != null) || newMode)); - } - - /** - * This is called when user changes their selection in the left-side tree view - */ - public void selectionChanged(SelectionChangedEvent se) { - if (recursiveCall) return; // ignore! - // Calling the setText() methods here was causing Modify events - // when just switching the selection, even on Domain items, leading - // to setComment(), etc calls on the Action item, caausing these tags to - // even be written in the saved XML. Even for Domain items! - // So, turning off/on the modifyListeners around the selection change, - // based on the isEnabled switch - IStructuredSelection ss = (IStructuredSelection) se.getSelection(); - Object so = ss.getFirstElement(); - // if old selection has validation errors, don't allow selection to be changed. - if (areErrorsPending()) { - // Verify old selection has not been deleted from tree - if (newMode || SystemUDBaseManager.inCurrentTree(currentType.getElement())) { - if (!newMode && (so != currentType)) - treeView.setSelection(new StructuredSelection(currentType)); - else if (newMode && (so != newModeNewItem)) treeView.setSelection(new StructuredSelection(newModeNewItem)); - return; - } - } - // We need to test for pending changes, and if any are pending, prompt - // user to continue (and lose changes) or cancel... - if ((stateMachine != null) && stateMachine.isSaveRequired()) { - saveData(); - if (newMode) { - // interesting problem! The save of the new data resulted in a new node, - // but this is not visible in the tree view. To make it visible means we - // we will lose focus, and this method will be recalled recursively... - recursiveCall = true; - treeView.refreshElementParent(currentType); // show new item in tree view - recursiveCall = false; - if (so instanceof SystemUDTypeElement) // if user was selecting a type, it might have a new binary address after the refresh - treeView.selectElement((SystemUDTypeElement) so); - else if (so != null) treeView.setSelection(new StructuredSelection(so)); // restore what user selected - return; // avoid recursion! - } - } - recursiveCall = false; - // Clear any page-valid errors remaining from previous selection - // (Since validation on the new selection is only run if editing - // changes are made - errorMessage = null; - resetPageValidation(); - newMode = ((so instanceof SystemUDTreeViewNewItem) && ((SystemUDTreeViewNewItem) so).isExecutable()); - // Refresh tree view if name changed on last item - if (nameChanged) { - nameChanged = false; - if (null != currentType) treeView.refresh(currentType); - } - SystemUDTypeElement sn = null; - if ((null != so) && (so instanceof SystemUDTypeElement)) sn = (SystemUDTypeElement) so; - currentType = sn; - // Disable modifyListeners prior to resetting fields - if (isEnabled) { - textName.removeModifyListener(nameML); - typesEditor.removeModifyListener(typesML); - } - // Clear all fields if not a file type entry. Could be a domain node - //boolean prevEnabledState = isEnabled; - //boolean newEnabledState = false; - // domain node selected. Note we will be hidden in this case, by the - // state machine - if (!newMode && ((null == sn) || sn.isDomain())) { - isEnabled = false; - //newEnabledState = false; - textName.setText(""); //$NON-NLS-1$ - typesEditor.clearTypes(); - } - // "new" node or existing node selected - else { - isEnabled = true; - //newEnabledState = true; - if (!newMode && sn != null) { - textName.setText(sn.toString()); - typesEditor.setTypes(sn.getTypes()); - //setEnabled(!treeView.isElementAllSelected() && !treeView.isSelectionVendorSupplied()); - //typesEditor.setEditable(!treeView.isSelectionVendorSupplied(), treeView.getVendorOfSelection()); - setEnabled(!treeView.isElementAllSelected()); - typesEditor.setEditable(!treeView.isElementAllSelected(), treeView.isElementAllSelected() ? treeView.getVendorOfSelection() : null); - } else { - textName.setText(""); //$NON-NLS-1$ - typesEditor.clearTypes(); - typesEditor.setEditable(true, null); - setEnabled(true); - } - // isEnabled will = true when leaving this logic branch - // Will always need to re-add the listeners - textName.addModifyListener(nameML); - typesEditor.addModifyListener(typesML); - } - //System.out.println("selection changed: " + (testCounter++) + ", new? " + newMode + ", enabled? " + isEnabled); - // update state machine - if (newMode) { - stateMachine.setNewMode(); // resets Apply/Reset button status - newModeNewItem = (SystemUDTreeViewNewItem) so; - newModeDomain = newModeNewItem.getDomain(); - if (newModeDomain != currentDomain) setDomain(newModeDomain); //indicate domain change - } else if ((sn == null) || sn.isDomain()) { - stateMachine.setUnsetMode(); // resets Apply/Reset button status - } else { - stateMachine.setEditMode(); // resets Apply/Reset button status } - if (sn.getDomain() != currentDomain) setDomain(sn.getDomain()); //indicate domain change - } - if (nameValidator instanceof ISystemValidatorUniqueString) - ((ISystemValidatorUniqueString) nameValidator).setExistingNamesList(getExistingNames()); - setPageComplete(); - } - - /** - * Need to add/remove listeners around selection changes, so - * I can set text fields without triggering modify event. - * So listeners implemented as internal classes - */ - private class NameModifyListener implements ModifyListener { - public void modifyText(ModifyEvent e) { - if (ignoreChanges) return; - setChangesMade(); - String s = textName.getText().trim().toUpperCase(); - errorMessage = nameValidator.validate(s); - if (errorMessage != null) { - parentDialog.setErrorMessage(errorMessage); - setPageComplete(); - } else { - validateInput(false, textName); - if (currentType != null) { - nameChanged = true; - } - } - } - } //class - - private class TypesModifyListener implements ModifyListener { - public void modifyText(ModifyEvent e) { - if (ignoreChanges) return; - setChangesMade(); - errorMessage = typesEditor.validate(); - if (errorMessage != null) { - parentDialog.setErrorMessage(errorMessage); - setPageComplete(); - } else { - validateInput(false, typesEditor.getControl()); - } - } - } //class - - /** - * For uniqueness checking, get the list of existing type names - */ - protected Vector getExistingNames() { - if (newMode) { - SystemUDActionSubsystem udas = getUDActionSubsystem(); - SystemUDTypeManager udtm = udas.getUDTypeManager(); - return udtm.getExistingNames(null, newModeDomain); - } else if (currentType != null) - return currentType.getExistingNames(); - else - return EMPTY_VECTOR; - } - - /** - * Return the user defined action subsystem - */ - protected SystemUDActionSubsystem getUDActionSubsystem() { - return udaActionSubsys; - } - - /** - * When user presses Apply, commit all pending changes... - */ - protected void processChanges() { - currentType.setName(textName.getText().trim()); - currentType.setTypes(typesEditor.getTypes()); - } //process changes - - /** - * Save current state to disk - */ - protected void saveData() { - if (newMode) { - currentType = createNewType(textName.getText().trim(), newModeDomain); - } - processChanges(); - SystemUDActionSubsystem udas = getUDActionSubsystem(); - SystemUDTypeManager udtm = udas.getUDTypeManager(); - udtm.saveUserData(); - // inform anybody registered as listeners that we have created/changed model object... - if (newMode) - RSECorePlugin.getTheSystemRegistry().fireModelChangeEvent(ISystemModelChangeEvents.SYSTEM_RESOURCE_ADDED, IUserActionsModelChangeEvents.SYSTEM_RESOURCETYPE_NAMEDTYPE, currentType, null); - else - RSECorePlugin.getTheSystemRegistry().fireModelChangeEvent(ISystemModelChangeEvents.SYSTEM_RESOURCE_CHANGED, IUserActionsModelChangeEvents.SYSTEM_RESOURCETYPE_NAMEDTYPE, currentType, null); - } - - /** - * In "new" mode, create a new type when Apply is pressed. - * This only creates the type. It does not populate the attributes - * @return The new action - */ - protected SystemUDTypeElement createNewType(String typeName, int domain) { - // code was originally in SystemNewUDAsWizardMainPage - SystemUDActionSubsystem udas = getUDActionSubsystem(); - SystemUDTypeManager udtm = udas.getUDTypeManager(); - SystemUDTypeElement nt = udtm.addType(domain, typeName); - return nt; - } - - /** - * Revert button pressed - */ - public void revertPressed() { - ignoreChanges = true; - resetPageValidation(); - if ((currentType != null) && !currentType.isDomain()) { - textName.setText(currentType.toString()); - typesEditor.setTypes(currentType.getTypes()); - if (stateMachine != null) stateMachine.resetPressed(); - } else if (newMode) { - textName.setText(""); //$NON-NLS-1$ - typesEditor.clearTypes(); - if (stateMachine != null) stateMachine.resetPressed(); - } - ignoreChanges = false; - setPageComplete(); - } - - /** - * Process the apply button - */ - public void applyPressed() { - if ((newMode || ((currentType != null) && !currentType.isDomain())) && validateInput(true, null)) { - saveData(); - if (stateMachine != null) stateMachine.applyPressed(); - if (newMode) { - // Now update tree view to show new item - recursiveCall = true; - treeView.refreshElementParent(currentType); - recursiveCall = false; - treeView.selectElement(currentType); - } else - treeView.refresh(currentType); - } - setPageComplete(); - } //apply - - public void setNameValidator(ISystemValidator validator) { - nameValidator = validator; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDTypeElement.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDTypeElement.java deleted file mode 100644 index 3ae3dfa27..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDTypeElement.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.uda; - -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - *******************************************************************************/ -import org.eclipse.rse.core.model.IProperty; -import org.eclipse.rse.core.model.IPropertySet; -import org.eclipse.rse.internal.useractions.UserActionsIcon; -import org.eclipse.swt.graphics.Image; - -/** - * Wraps a "Type" XML tag - */ -public class SystemUDTypeElement extends SystemXMLElementWrapper { - private final static String NO_TYPE = ""; //$NON-NLS-1$ - private final static String TYPES_TAG = "Types"; //$NON-NLS-1$ - private final static String TYPE_TAG = "Type"; //$NON-NLS-1$ - - /** - * Constructor - * @param element The actual xml document element for this action - * @param tm The subsystemFactory-specific manager of actions - * @param domainType - The integer representation of the domain this is in (or this is, for a domain element) - */ - public SystemUDTypeElement(IPropertySet element, SystemUDTypeManager tm, int domainType) { - super(element, tm, null, domainType); - } - - /** - * Return image to use for this item, in tree views - */ - public Image getImage() { - Image image = null; - if (isIBM()) { - if (isUserChanged()) - image = UserActionsIcon.USERTYPE_IBMUSR.getImage(); - else - image = UserActionsIcon.USERTYPE_IBM.getImage(); - } else - image = UserActionsIcon.USERTYPE_USR.getImage(); - //System.out.println("... image returned = "+image); - return image; - } - - /** - * Return our tag name - */ - public String getTagName() { - return TYPE_TAG; - } - - /** - * Return the list of types - */ - public String getTypes() { - IProperty typesProperty = elm.getProperty(TYPES_TAG); - if (typesProperty != null) - { - return typesProperty.getValue(); - } - return NO_TYPE; - } - - /** - * Set the list of types - */ - public void setTypes(String s) { - IProperty typesProperty = elm.getProperty(TYPES_TAG); - if (typesProperty == null) - { - typesProperty = elm.addProperty(TYPES_TAG, s); - } - else - { - typesProperty.setValue(s); - } - setUserChanged(true); - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDTypeManager.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDTypeManager.java deleted file mode 100644 index 0e7094408..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDTypeManager.java +++ /dev/null @@ -1,250 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - * Martin Oberhuber (Wind River) - [168870] refactor org.eclipse.rse.core package of the UI plugin - * David Dykstal (IBM) - [186589] move user actions API out of org.eclipse.rse.ui - *******************************************************************************/ -package org.eclipse.rse.internal.useractions.ui.uda; - -import java.util.Vector; - -import org.eclipse.rse.core.model.IPropertySet; -import org.eclipse.rse.core.model.ISystemProfile; -import org.eclipse.rse.internal.useractions.UserActionsIcon; -import org.eclipse.swt.graphics.Image; - -/** - * Instances of this class hold the UDA Type definitions unique to - * the SubSystem type - according to the SubSystemFactory - * - * Note that unlike user actions, types are not scoped by profile. - * For each subsystem factory there is but a single master list of types. - * - * Instances of this class will be linked to a SubSystem instance for - * now, but should be linked to a subsystem factory instance in the future. - * - */ -public class SystemUDTypeManager extends SystemUDBaseManager { - private static final String XE_ROOT = ISystemUDAConstants.FILETYPES_ROOT; - public static final String XE_TYPE = "Type"; //$NON-NLS-1$ - public static final String ALL_TYPE = "ALL"; //$NON-NLS-1$ - - /** - * Constructor - */ - public SystemUDTypeManager(SystemUDActionSubsystem udas) { - super(udas); - } - - /** - * Return true if this is user actions, false if this is named types. - */ - protected boolean isUserActionsManager() { - return false; - } - - /** - * Get the icon to show in the tree views, for the "new" expandable item - */ - public Image getNewImage() { - return UserActionsIcon.USERTYPE_NEW.getImage(); - } - - - /** - * Overridable extension point for child classes to do migration of their document. - * This is called on first load of a document, which has a release stamp other than - * the current release - * @return true if any migration was done - */ - protected boolean doMigration(ISystemProfile profile, String oldRelease) { - return getActionSubSystem().doTypesMigration(profile, oldRelease); - } - - /** - * Parent method override for returning the "New" icon label for the Work With dialog tree view. - * For us, we defer to the getActionSubSystem().{@link SystemUDActionSubsystem#getNewNodeTypeLabel() getNewNodeTypeLabel()}. - * Do not override this. - * @return translated value for "New" in new icon for WW action and type dialogs. Default is "New" - */ - protected String getNewNodeLabel() { - return getActionSubSystem().getNewNodeTypeLabel(); - } - - // ----------------------------------------------------------- - // ISystemXMLElementWrapperFactory - // ----------------------------------------------------------- - /** - * Return the tag name for our managed elements. - * Eg: will be "Action" for user actions, and "Type" for file types. - */ - public String getTagName() { - return XE_TYPE; - } - - /** - * Given an xml element node, create an instance of the appropriate - * subclass of SystemXMLElementWrapper to represent it. - */ - public SystemXMLElementWrapper createElementWrapper(IPropertySet xmlElementToWrap, ISystemProfile profile, int domain) { - SystemUDTypeElement elementWrapper = new SystemUDTypeElement(xmlElementToWrap, this, domain); - return elementWrapper; - } - - // ----------------------------------------------------------- - // THE FOLLOWING ARE PARENT METHODS THAT ABSTRACT OUT THE - // DIFFERENCES BETWEEN ACTIONS AND TYPES - // ----------------------------------------------------------- - /** - * Get the document root tag name. - * We return "FileTypes" - */ - public String getDocumentRootTagName() { - return XE_ROOT; // "FileTypes" - } - - /** - * Do we uppercase the value of the "Name" attribute? - * Yes, we do for types - */ - protected boolean uppercaseName() { - return true; - } - - /** - * Return true if the elements managed by this class are scoped by - * profile. Usually true for actions, false for types - */ - public boolean supportsProfiles() { - return false; - } - - /** - * Prime the given document with any default types - * Calls primeDefaultTypes in action subsystem. - */ - public SystemXMLElementWrapper[] primeDocument(ISystemProfile profile) { - return getActionSubSystem().primeDefaultTypes(this); - } - - - - - - /** - * Indicate data has changed for the given profile - */ - protected void dataChanged(ISystemProfile profile) { - // ADDED THIS LINE TO RESET THE RESOLVED TYPES WHEN A TYPE IS ADDED - _udas.resetResolvedTypes(); - } - - // ----------------------------------------------------------- - // TYPE-MANAGER UNIQUE METHODS... - // ----------------------------------------------------------- - /** - * Given a type name and domain, find the named type and return - * its types, or null if not found - */ - public String getTypesForTypeName(String typeName, int domain) { - ISystemProfile profile = getSubSystem().getSystemProfile(); - SystemUDTypeElement element = (SystemUDTypeElement) findByName(profile, typeName, domain); - if (element != null) - return element.getTypes(); - else - return null; - } - - /** - * Return xml element wrapper objects for all types, for the - * given domain, or for the whole document if domain is -1 (iff - * domains not supported). - * @param v - existing vector to populate. If null passed, it is - * not populated. - * @param domain - the integer representation of the given domain, - * or -1 iff supportsDomains() is false - * @return array of type objects - */ - public SystemUDTypeElement[] getTypes(Vector v, int domain) { - v = super.getXMLWrappers(v, domain, _udas.getSubsystem().getSystemProfile()); - if (v == null) return new SystemUDTypeElement[0]; - SystemUDTypeElement[] types = new SystemUDTypeElement[v.size()]; - for (int idx = 0; idx < types.length; idx++) - types[idx] = (SystemUDTypeElement) v.elementAt(idx); - return types; - } - - /** - * Return list of names of types in the given domain, or in doc - * if domain is -1 (which must only happen if supportsDomains() is false!) - */ - public String[] getTypeNames(int domain) { - Vector v = new Vector(); - // step 1: find the parent domain object, if any... - if (domain != -1) { - SystemUDTypeElement parentDomainElement = (SystemUDTypeElement) getDomainWrapper(null, domain); - // step 1a: ask that parent to return its children names... - v = parentDomainElement.getExistingNames(); - String[] names = new String[v.size()]; - for (int idx = 0; idx < names.length; idx++) - names[idx] = (String) v.elementAt(idx); - return names; - } - // step 2: no domain name given, so assume document roots are the types so find them and return their names - else { - v = SystemXMLElementWrapper.getExistingNames(null, getDocument(null), XE_TYPE); - String[] names = new String[v.size()]; - for (int idx = 0; idx < names.length; idx++) - names[idx] = (String) v.elementAt(idx); - return names; - } - } - - /** - * Add a new user type. - * Creates the new XML node in the document, - * and creates and returns a wrapper object for it. - * <p> - * Optimized flavour of addElement that does not require a profile, - * and is typed to return SystemUDTypeElement - */ - public SystemUDTypeElement addType(int domain, String name) { - ISystemProfile profile = getSubSystem().getSystemProfile(); - return (SystemUDTypeElement) super.addElement(profile, domain, name); - } - - /** - * Delete a give user action or type, given its wrapper. - * Deletes the xml node from the document. - * <p> - * Optimized flavour of delete that does not require a profile, - * and is typed to take SystemUDTypeElement - */ - public void delete(SystemUDTypeElement typeElement) { - super.delete(null, typeElement); - } - - // ------------------------------------------------------------------------- - // SPECIAL FLAVOURS OF PARENT METHODS, THAT DON'T REQUIRE A PROFILE PARM... - // ------------------------------------------------------------------------- - /** - * Save user data - */ - public void saveUserData() { - ISystemProfile profile = getActionSubSystem().getSubsystem().getSystemProfile(); - super.saveUserData(profile); - } - /* - * Get our xml document - * - protected Document getDocument() - { - return super.getDocument(null); - }*/ -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDTypeTreeView.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDTypeTreeView.java deleted file mode 100644 index dc7128abb..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDTypeTreeView.java +++ /dev/null @@ -1,134 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core - * David Dykstal (IBM) - [186589] move user types, user actions, and compile commands - * API to the user actions plugin - * David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared - * Kevin Doyle (IBM) - [222831] Can't Delete User Actions/Named Types - *******************************************************************************/ -package org.eclipse.rse.internal.useractions.ui.uda; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.viewers.IBasicPropertyConstants; -import org.eclipse.rse.core.model.ISystemProfile; -import org.eclipse.rse.core.subsystems.ISubSystem; -import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; -import org.eclipse.rse.internal.useractions.Activator; -import org.eclipse.rse.internal.useractions.IUserActionsMessageIds; -import org.eclipse.rse.internal.useractions.IUserActionsModelChangeEvents; -import org.eclipse.rse.internal.useractions.UserActionsResources; -import org.eclipse.rse.services.clientserver.messages.SimpleSystemMessage; -import org.eclipse.rse.services.clientserver.messages.SystemMessage; -import org.eclipse.swt.widgets.Composite; - -/** - * In the Work With User Defined File Types dialog, this is the - * tree view for showing the existing types. - */ -public class SystemUDTypeTreeView extends SystemUDBaseTreeView { - /** - * Constructor when we have a subsystem - */ - public SystemUDTypeTreeView(Composite parent, ISystemUDWorkWithDialog editPane, ISubSystem ss, SystemUDActionSubsystem udaActionSubsystem) { - /* FIXME - UDA not coupled with subsystem API anymore */ - super(parent, editPane, ss, udaActionSubsystem.getUDTypeManager()); - } - - /** - * Constructor when we have a subsystem factory and profile - */ - public SystemUDTypeTreeView(Composite parent, ISystemUDWorkWithDialog editPane, ISubSystemConfiguration ssFactory, ISystemProfile profile) { - super(parent, editPane, ssFactory, profile, - /* FIXME - UDA not coupled with subsystem API anymore - ((ISubsystemFactoryAdapter)ssFactory.getAdapter(ISubsystemFactoryAdapter.class)).getActionSubSystem(ssFactory, null).getUDTypeManager() - */ - null); - } - - /** - * Return types manager - */ - public SystemUDTypeManager getTypeManager() { - return (SystemUDTypeManager) super.getDocumentManager(); - } - - /** - * Get the selected type name. - * Returns "" if nothing selected - */ - public String getSelectedTypeName() { - return super.getSelectedElementName(); - } - - /** - * Get the selected type domain. - * Returns -1 if nothing selected or domains not supported - */ - public int getSelectedTypeDomain() { - return super.getSelectedElementDomain(); - } - - /** - * Return message for delete confirmation - */ - protected SystemMessage getDeleteConfirmationMessage() { - SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, - IUserActionsMessageIds.MSG_CONFIRM_DELETE_USERTYPE, - IStatus.WARNING, UserActionsResources.MSG_CONFIRM_DELETE_USERTYPE, UserActionsResources.MSG_CONFIRM_DELETE_USERTYPE_DETAILS); - msg.setIndicator(SystemMessage.INQUIRY); - return msg; - } - - /** - * Return the {@link org.eclipse.rse.core.events.ISystemModelChangeEvents} constant representing the resource type managed by this tree. - * This is a parent class override. - */ - protected int getResourceType() { - return IUserActionsModelChangeEvents.SYSTEM_RESOURCETYPE_NAMEDTYPE; - } - - /** - * Parent override. - * Restore the selected type to its IBM-supplied default value. - */ - public void doRestore() { - SystemXMLElementWrapper selectedElement = getSelectedElement(); - if ((selectedElement == null) || !(selectedElement instanceof SystemUDTypeElement)) return; - SystemUDTypeElement type = (SystemUDTypeElement) selectedElement; - boolean ok = getDocumentManager().getActionSubSystem().restoreDefaultType(type, type.getDomain(), type.getOriginalName()); - if (ok) { - type.setUserChanged(false); - getDocumentManager().saveUserData(profile); - selectElement(selectedElement); - String[] allProps = { IBasicPropertyConstants.P_TEXT, IBasicPropertyConstants.P_IMAGE }; - update(selectedElement, allProps); - } - } - - // ------------------------------------ - // HELPER METHODS CALLED FROM EDIT PANE - // ------------------------------------ - /** - * Select the given type - */ - public void selectType(SystemUDTypeElement element) { - super.selectElement(element); - } - - /** - * Refresh the parent of the given action. - * That is, find the parent and refresh the children. - * If the parent is not found, assume it is because it is new too, - * so refresh the whole tree. - */ - public void refreshTypeParent(SystemUDTypeElement element) { - super.refreshElementParent(element); - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUserActionExtension.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUserActionExtension.java deleted file mode 100644 index 56ef482da..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUserActionExtension.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - * Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType - *******************************************************************************/ - -package org.eclipse.rse.internal.useractions.ui.uda; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.rse.core.IRSESystemType; - -/** - * This class represents a user action read from a user action extension point - * <p> - * THIS CLASS IS THE BEGINNING OF SUPPORT FOR USER ACTION EXTENSION POINTS. - * IT IS NOT COMPLETE YET AND NOT SUPPORTED YET. - */ -public class SystemUserActionExtension { - private String types; - private String id, vendor; - private boolean allTypes; - - // SEE FILE plugin.xml.udaExtensionPoint.notused - /** - * Constructor - */ - public SystemUserActionExtension(IConfigurationElement element) { - types = element.getAttribute("systemTypes"); //$NON-NLS-1$ - if ((types == null) || types.equals("*")) //$NON-NLS-1$ - allTypes = true; - id = element.getAttribute("id"); //$NON-NLS-1$ - vendor = element.getAttribute("vendor"); //$NON-NLS-1$ - } - - /** - * Return the value of the "vendor" attribute - */ - public String getVendor() { - return vendor; - } - - /** - * Return the value of the "id" attribute - */ - public String getId() { - return id; - } - - /** - * Return true if this extension's systemTypes attribute matches the given system type - */ - public boolean appliesToSystemType(IRSESystemType type) { - //System.out.println("INSIDE APPLIESTO FOR " + type + ". allTypes = " + allTypes + ". types = " + types); - if (allTypes) - return true; - else { - //FIXME migrate to using ID - return (types.indexOf(type.getId()) >= 0); - } - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUserActionExtensionManager.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUserActionExtensionManager.java deleted file mode 100644 index 41e90c2dd..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUserActionExtensionManager.java +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 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 - * Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType - *******************************************************************************/ - -package org.eclipse.rse.internal.useractions.ui.uda; - -import java.util.Vector; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtensionRegistry; -import org.eclipse.core.runtime.Platform; -import org.eclipse.rse.core.IRSESystemType; - -/** - * This class manages reading user action extension points. - * Each subsystem is responsible for defining their own extension points - * to allow BPs and ISVs to pre-supply user actions, if desired. - * <p> - * Further, the extension points must all support a common set of subtags: - * <code>userActionContribution</code>, - * <code>namedType</code> and <code>userAction</code>. - * <p> - * This class is the base class for the reader for parsing these - * extension points. - * - * <p> - * THIS CLASS IS THE BEGINNING OF SUPPORT FOR USER ACTION EXTENSION POINTS. - * IT IS NOT COMPLETE YET AND NOT SUPPORTED YET. - */ -public class SystemUserActionExtensionManager { - private String pluginID, extensionID; - private boolean read; - private Vector elements; - - // SEE FILE plugin.xml.udaExtensionPoint.notused - /** - * Constructor - * @param pluginID - the ID of the plugin which defined this extension - * @param extensionID - the ID of the extension - */ - public SystemUserActionExtensionManager(String pluginID, String extensionID) { - this.pluginID = pluginID; - this.extensionID = extensionID; - } - - /** - * Return list of user-actions defined by the given extension point, for the given - * system type. - */ - public SystemUserActionExtension[] getUserActionExtensions(IRSESystemType systemType) { - int count = 0; - if (!read) readExtensions(); - if ((elements == null) || (elements.size() == 0)) return null; - for (int idx = 0; idx < elements.size(); idx++) { - SystemUserActionExtension currAction = (SystemUserActionExtension) elements.elementAt(idx); - if (currAction.appliesToSystemType(systemType)) ++count; - } - if (count == 0) return null; - SystemUserActionExtension[] actions = new SystemUserActionExtension[count]; - count = 0; - for (int idx = 0; idx < elements.size(); idx++) { - SystemUserActionExtension currAction = (SystemUserActionExtension) elements.elementAt(idx); - if (currAction.appliesToSystemType(systemType)) actions[count++] = currAction; - } - return actions; - } - - /** - * Return true if the extensions have been read in yet from the registry - */ - protected boolean hasBeenRead() { - return read; - } - - /** - * Read list of extensions from registry - */ - protected void readExtensions() { - // Get reference to the plug-in registry - IExtensionRegistry registry = Platform.getExtensionRegistry(); - // Get configured extenders - IConfigurationElement[] userActionExtensions = registry.getConfigurationElementsFor(pluginID, extensionID); - if (userActionExtensions != null) { - elements = new Vector(); - for (int idx = 0; idx < userActionExtensions.length; idx++) { - elements.add(createUserActionExtension(userActionExtensions[idx])); - } - } - read = true; - } - - /** - * Overridable method for instantiating a new SystemUserActionExtension object - */ - protected SystemUserActionExtension createUserActionExtension(IConfigurationElement element) { - return new SystemUserActionExtension(element); - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemWorkWithUDAsDialog.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemWorkWithUDAsDialog.java deleted file mode 100644 index d90aecf9a..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemWorkWithUDAsDialog.java +++ /dev/null @@ -1,450 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core - * Martin Oberhuber (Wind River) - [cleanup] Avoid using SystemStartHere in production code - *******************************************************************************/ -package org.eclipse.rse.internal.useractions.ui.uda; - -import org.eclipse.rse.core.RSECorePlugin; -import org.eclipse.rse.core.model.ISystemProfile; -import org.eclipse.rse.core.subsystems.ISubSystem; -import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.SystemWidgetHelpers; -import org.eclipse.rse.ui.dialogs.SystemPromptDialog; -import org.eclipse.rse.ui.widgets.ISystemEditPaneStates; -import org.eclipse.rse.ui.widgets.SystemEditPaneStateMachine; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.TreeItem; -import org.eclipse.swt.widgets.Widget; - -/** - * A dialog that allows the user to manipulate their user defined actions for a - * given subsystem factory. - */ -public class SystemWorkWithUDAsDialog extends SystemPromptDialog implements ISystemUDWorkWithDialog, ISystemUDAEditPaneHoster, Listener, SelectionListener, - Runnable { - // Changes: - // June 2002, Phil Coulthard: Added prompt for parent profile, similar to New Connection and New Filter Pool wizards. - // Similar to SystemConnectionForm - protected Shell shell; // shell hosting this viewer - // GUI widgets - protected Label labelProfile, labelProfileValue; - protected Combo profileCombo; - protected SystemUDActionTreeView treeView; - protected int prevProfileComboSelection = 0; - // inputs - protected ISubSystem subsystem; - protected ISubSystemConfiguration subsystemFactory; - protected SystemUDActionSubsystem udaActionSubsystem; - //protected String defaultProfileName; - //protected String[] defaultProfileNames; - protected ISystemProfile[] systemProfiles; - protected ISystemProfile currentProfile; - // state - protected SystemUDActionEditPane editpane; - protected Button applyButton, revertButton; - protected SystemEditPaneStateMachine sm; - - /** - * Constructor when we have a subsystem - */ - public SystemWorkWithUDAsDialog(Shell shell, ISubSystem ss, SystemUDActionSubsystem udaActionSubsystem) { - super(shell, SystemUDAResources.RESID_WORKWITH_UDAS_TITLE); - setCancelButtonLabel(SystemUDAResources.BUTTON_CLOSE); - setShowOkButton(false); - this.shell = shell; - this.subsystem = ss; - this.subsystemFactory = ss.getSubSystemConfiguration(); - this.udaActionSubsystem = udaActionSubsystem; - setProfiles(RSECorePlugin.getTheSystemProfileManager().getActiveSystemProfiles(), subsystem.getSystemProfile()); - //setMinimumSize(600, 520); // x, y - //pack(); - setHelp(); - } - - /** - * Constructor when we have a subsystem factory - */ - public SystemWorkWithUDAsDialog(Shell shell, ISubSystemConfiguration ssFactory, ISystemProfile profile, SystemUDActionSubsystem udaActionSubsystem) { - super(shell, SystemUDAResources.RESID_WORKWITH_UDAS_TITLE); - setCancelButtonLabel(SystemUDAResources.BUTTON_CLOSE); - setShowOkButton(false); - this.shell = shell; - this.subsystemFactory = ssFactory; - this.udaActionSubsystem = udaActionSubsystem; - setProfiles(RSECorePlugin.getTheSystemProfileManager().getActiveSystemProfiles(), profile); - //setMinimumSize(600, 520); // x, y - //pack(); - setHelp(); - } - - /** - * Overridable extension point for setting dialog help - */ - protected void setHelp() { - setHelp(RSEUIPlugin.HELPPREFIX + "wwua0000"); //$NON-NLS-1$ - } - - /** - * Set the profiles to show in the combo. - * @param profiles array of profiles to show - * @param profile the profile to pre-select - */ - public void setProfiles(ISystemProfile[] profiles, ISystemProfile profile) { - if (profiles == null) profiles = new ISystemProfile[0]; - this.systemProfiles = profiles; - this.currentProfile = profile; - initProfileCombo(); - } - - /** - * @see SystemPromptDialog#getInitialFocusControl() - */ - protected Control getInitialFocusControl() { - return null; - } - - /** - * Return the user defined action subsystem - */ - protected SystemUDActionSubsystem getUDActionSubsystem() { - return udaActionSubsystem; - } - - /** - * @see SystemPromptDialog#createInner(Composite) - */ - protected Control createInner(Composite parent) { - // 2 columns - int nbrColumns = 2; - Composite composite = SystemWidgetHelpers.createComposite(parent, nbrColumns); - Composite profileComposite = SystemWidgetHelpers.createFlushComposite(composite, 2); - ((GridData) profileComposite.getLayoutData()).horizontalSpan = nbrColumns; - String temp = SystemWidgetHelpers.appendColon(SystemUDAResources.RESID_UDA_PROFILE_LABEL); - labelProfile = SystemWidgetHelpers.createLabel(profileComposite, temp); - labelProfile.setToolTipText(SystemUDAResources.RESID_UDA_PROFILE_TOOLTIP); - profileCombo = SystemWidgetHelpers.createReadonlyCombo(profileComposite, null, SystemUDAResources.RESID_UDA_PROFILE_TOOLTIP); - //SystemWidgetHelpers.setHelp(profileCombo, RSEUIPlugin.HELPPREFIX + "ccon0001", parentHelpId); - if (currentProfile != null) // important to set this before instantiating action tree - getUDActionSubsystem().getUDActionManager().setCurrentProfile(currentProfile); - // create tree view on left - if (subsystem != null) - treeView = new SystemUDActionTreeView(composite, this, subsystem, udaActionSubsystem); - else - { - // FIXME - Xuan - //treeView = new SystemUDActionTreeView(composite, this, subsystemFactory, currentProfile); - } - Control c = treeView.getControl(); - //c.setToolTipText(RSEUIPlugin.getString(RESID_UDA_TREE_TIP)); - GridData data = (GridData) c.getLayoutData(); - if (data == null) data = new GridData(); - data.grabExcessHorizontalSpace = false; - data.horizontalAlignment = GridData.FILL; - data.grabExcessVerticalSpace = true; - data.verticalAlignment = GridData.FILL; - data.widthHint = 140; // 170 - data.heightHint = publicConvertHeightInCharsToPixels(12); // high enough to show 12 entries - c.setLayoutData(data); - // we want the tree view on the left to extend to the bottom of the page, so on the right - // we create a 1-column composite that will hold the edit pane on top, and the apply/revert - // buttons on the bottom... - Composite rightSideComposite = SystemWidgetHelpers.createFlushComposite(composite, 1); - // now populate top of right-side composite with edit pane... - if (subsystem != null) - editpane = getUDActionSubsystem().getCustomUDActionEditPane(subsystem, this, treeView); - else - editpane = getUDActionSubsystem().getCustomUDActionEditPane(subsystemFactory, currentProfile, this, treeView); - editpane.createContents(rightSideComposite); - // now add a visual separator line - addSeparatorLine(rightSideComposite, 1); - // now populate bottom of right-side composite with apply/revert buttons within their own composite - int nbrColumns_buttonComposite = 4; - Composite applyResetButtonComposite = SystemWidgetHelpers.createFlushComposite(rightSideComposite, nbrColumns_buttonComposite); - //((GridData)applyResetButtonComposite.getLayoutData()).horizontalIndent = 200; // shift buttons to the right - // now populate the buttons composite with apply and revert buttons - Label filler = SystemWidgetHelpers.createLabel(applyResetButtonComposite, ""); //$NON-NLS-1$ - ((GridData) filler.getLayoutData()).grabExcessHorizontalSpace = true; - ((GridData) filler.getLayoutData()).horizontalAlignment = GridData.FILL; - applyButton = SystemWidgetHelpers.createPushButton(applyResetButtonComposite, this, SystemUDAResources.RESID_UDA_APPLY_BUTTON_LABEL, SystemUDAResources.RESID_UDA_APPLY_BUTTON_TOOLTIP); - revertButton = SystemWidgetHelpers.createPushButton(applyResetButtonComposite, this, SystemUDAResources.RESID_UDA_REVERT_BUTTON_LABEL, SystemUDAResources.RESID_UDA_REVERT_BUTTON_TOOLTIP); - // now add a spacer to soak up left-over height... - addGrowableFillerLine(rightSideComposite, 1); - // populate profile dropdown - initProfileCombo(); - // add state machine to edit pane - sm = new SystemEditPaneStateMachine(rightSideComposite, applyButton, revertButton); - editpane.setStateMachine(sm); - // add listeners... - profileCombo.addSelectionListener(this); - treeView.addSelectionChangedListener(editpane); - getShell().addDisposeListener(new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - //System.out.println("Inside dispose for SystemWorkWithUDAsDialog"); - getUDActionSubsystem().getUDActionManager().setCurrentProfile(null); - } - }); - treeView.getControl().addMouseListener(editpane); - treeView.getControl().addKeyListener(editpane); - composite.layout(true); - rightSideComposite.setVisible(false); - treeView.expandDomainNodes(); - return composite; - } - - /** - * Intercept of parent so we can reset the default button - */ - protected void createButtonsForButtonBar(Composite parent) { - super.createButtonsForButtonBar(parent); - getShell().setDefaultButton(applyButton); // defect 46129 - } - - /** - * Initialize contents and selection of profile combo - */ - private void initProfileCombo() { - if (profileCombo != null) { - if ((systemProfiles != null) && (systemProfiles.length > 0)) { - String[] names = new String[systemProfiles.length]; - int selIdx = 0; - for (int idx = 0; idx < names.length; idx++) { - names[idx] = systemProfiles[idx].getName(); - if ((currentProfile != null) && (currentProfile == systemProfiles[idx])) selIdx = idx; - } - profileCombo.setItems(names); - profileCombo.setText(names[selIdx]); - prevProfileComboSelection = selIdx; - } - } - } - - /** - * Intercept of parent method so we can direct it to the Apply button versus the OK button - */ - public void setPageComplete(boolean complete) { - if (applyButton != null) { - if (!complete) applyButton.setEnabled(false); - // else: we never enable it because the state machine does that anyway on any user-input change - } - } - - /** - * Parent override. - * Called when user presses CLOSE button. - * We simply close the dialog (since we save as we go), unless there are pending changes. - */ - protected boolean processCancel() { - if (sm.isSaveRequired()) { - if (!editpane.validateInput(true, null)) { - sm.setChangesMade(); // defect 45773 - return false; // pending errors. Cannot save, so cannot close! - } - editpane.saveData(); - } - return super.processCancel(); - } - - // --------------------------------- - // METHODS FOR INTERFACES... - // --------------------------------- - /** - * Handles events generated by controls on this page. - */ - public void handleEvent(Event e) { - clearMessage(); - Widget source = e.widget; - if (source == applyButton) { - processApply(); - } else if (source == revertButton) { - processRevert(); - } - } - - /** - * Process the apply button - */ - public void processApply() { - editpane.applyPressed(); - } - - /** - * Process the revert button - */ - public void processRevert() { - editpane.revertPressed(); - } - - /** - * Combo selection listener method - */ - public void widgetDefaultSelected(SelectionEvent event) { - } - - /** - * Combo selection listener method - */ - public void widgetSelected(SelectionEvent event) { - Object src = event.getSource(); - if (src == profileCombo) { - if (editpane.areErrorsPending()) { - profileCombo.getDisplay().asyncExec(this); - return; - } - // SystemUDActionManager udam = getUDActionSubsystem().getUDActionManager(); - if (sm.isSaveRequired()) { - if (!editpane.validateInput(true, null)) // errors in pending input? - { - sm.setChangesMade(); - profileCombo.getDisplay().asyncExec(this); - return; - } - //udam.saveUserData(udam.getCurrentProfile()); - editpane.saveData(); // defect 45771 - } - sm.applyPressed(); - int idx = profileCombo.getSelectionIndex(); - if (idx < 0) // should never happen? - idx = 0; - prevProfileComboSelection = idx; - currentProfile = systemProfiles[idx]; - getUDActionSubsystem().getUDActionManager().setCurrentProfile(currentProfile); - treeView.clearClipboard(); - treeView.setInput("0"); //$NON-NLS-1$ - treeView.expandDomainNodes(); - } - } - - // ------------------------------------------------------- - // METHOD REQUIRED BY RUNNABLE, USED IN CALL TO ASYNCEXEC - // ------------------------------------------------------- - /** - * Run asynchronously verification of data when user changes profile - * selection. If errors pending, re-select previous profile - */ - public void run() { - profileCombo.select(prevProfileComboSelection); - super.run(); - } - - // --------------- - // HELPER METHODS - // --------------- - // ----------------------------------- - // ISystemUDWorkWithDialog methods... - // ----------------------------------- - /** - * Decide if we can do the delete or not. - * Will decide the enabled state of the delete action. - */ - public boolean canDelete(Object selectedObject) { - return (sm.getMode() == ISystemEditPaneStates.MODE_EDIT) && !sm.areChangesPending() && !isSelectionVendorSupplied(); - } - - /** - * Decide if we can do the move up or not. - * Will decide the enabled state of the move up action. - */ - public boolean canMoveUp(Object selectedObject) { - boolean can = (sm.getMode() == ISystemEditPaneStates.MODE_EDIT) && !sm.areChangesPending(); - if (can) { - TreeItem selectedItem = treeView.getSelectedTreeItem(); - TreeItem parentItem = selectedItem.getParentItem(); - if (parentItem != null) - can = (parentItem.getItems()[0] != selectedItem); - else // this means we don't have domains - { - TreeItem[] roots = treeView.getTree().getItems(); - for (int idx = 0; idx < roots.length; idx++) { - if (roots[idx].getData() instanceof SystemXMLElementWrapper) { - can = (roots[idx] != selectedItem); - break; - } - } - } - } - return can; - } - - /** - * Decide if we can do the move down or not. - * Will decide the enabled state of the move down action. - */ - public boolean canMoveDown(Object selectedObject) { - boolean can = (sm.getMode() == ISystemEditPaneStates.MODE_EDIT) && !sm.areChangesPending(); - if (can) { - TreeItem selectedItem = treeView.getSelectedTreeItem(); - TreeItem parentItem = selectedItem.getParentItem(); - if (parentItem != null) - can = (parentItem.getItems()[parentItem.getItemCount() - 1] != selectedItem); - else // this means we don't have domains - { - TreeItem[] roots = treeView.getTree().getItems(); - can = (roots[roots.length - 1] != selectedItem); - } - } - return can; - } - - /** - * Decide if we can do the copy or not. - * Will decide the enabled state of the copy action. - */ - public boolean canCopy(Object selectedObject) { - boolean can = (sm.getMode() == ISystemEditPaneStates.MODE_EDIT) && !sm.areChangesPending(); - return can; - } - - /** - * Return true if currently selected type is vendor supplied - */ - protected boolean isSelectionVendorSupplied() { - SystemXMLElementWrapper selectedElement = treeView.getSelectedElement(); - if (selectedElement != null) { - String vendor = selectedElement.getVendor(); - //System.out.println("Vendor value: '"+vendor+"'"); - return ((vendor != null) && (vendor.length() > 0)); - } - return false; - } - - /** - * Return the vendor that is responsible for pre-supplying this existing type, - * or null if not applicable. - */ - protected String getVendorOfSelection() { - SystemXMLElementWrapper selectedElement = treeView.getSelectedElement(); - if (selectedElement != null) { - String vendor = selectedElement.getVendor(); - if ((vendor != null) && (vendor.length() > 0)) return vendor; - } - return null; - } - - /** - * Return true if changes are pending in the edit pane - */ - public boolean areChangesPending() { - return sm.areChangesPending(); - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemWorkWithUDTypeDialog.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemWorkWithUDTypeDialog.java deleted file mode 100644 index f238bc686..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemWorkWithUDTypeDialog.java +++ /dev/null @@ -1,426 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.uda; - -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - *******************************************************************************/ -import java.util.ResourceBundle; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.rse.core.model.ISystemProfile; -import org.eclipse.rse.core.subsystems.ISubSystem; -import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.SystemWidgetHelpers; -import org.eclipse.rse.ui.dialogs.SystemPromptDialog; -import org.eclipse.rse.ui.widgets.ISystemEditPaneStates; -import org.eclipse.rse.ui.widgets.SystemEditPaneStateMachine; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.TreeItem; -import org.eclipse.swt.widgets.Widget; - -/** - * A dialog that allows the user to manipulate their user defined actions for a given subsystem factory. - * <p> - */ -public class SystemWorkWithUDTypeDialog extends SystemPromptDialog implements ISystemUDWorkWithDialog, Listener, Runnable, ISystemUDAEditPaneHoster { - protected Shell shell; // shell hosting this viewer - protected ResourceBundle rb; - protected SystemUDActionSubsystem udaActionSubsystem; - protected ISubSystem subsystem; - protected ISubSystemConfiguration subsystemFactory; - protected ISystemProfile profile; - protected SystemUDTypeEditPane editpane; - protected Button applyButton, revertButton; - protected SystemEditPaneStateMachine sm; - protected SystemUDTypeTreeView treeView; - private String typeToPreSelect; - private String currentType; - private int preSelectTypeDomain; - private int currentDomain = -1; - private Object objectToPreSelect; - private String domainToPreExpand; - - /** - * Constructor when we have a subsystem - */ - public SystemWorkWithUDTypeDialog(Shell shell, ISubSystem ss, SystemUDActionSubsystem udaActionSubsystem) { - super(shell, SystemUDAResources.RESID_WORKWITH_UDT_TITLE); - setCancelButtonLabel(SystemUDAResources.BUTTON_CLOSE); - setShowOkButton(false); - this.shell = shell; - this.udaActionSubsystem = udaActionSubsystem; - this.subsystem = ss; - this.subsystemFactory = subsystem.getSubSystemConfiguration(); - this.profile = subsystem.getSystemProfile(); - setOutputObject(null); - //setMinimumSize(550, 300); // x, y - setHelp(); - } - - /** - * Constructor when we have a subsystem factory and profile - */ - public SystemWorkWithUDTypeDialog(Shell shell, ISubSystemConfiguration ssFactory, ISystemProfile profile) { - super(shell, SystemUDAResources.RESID_WORKWITH_UDT_TITLE); - setCancelButtonLabel(SystemUDAResources.BUTTON_CLOSE); - setShowOkButton(false); - this.shell = shell; - this.subsystemFactory = ssFactory; - this.profile = profile; - setOutputObject(null); - //setMinimumSize(550, 300); // x, y - setHelp(); - } - - /** - * Overridable extension point for setting dialog help - */ - protected void setHelp() { - setHelp(RSEUIPlugin.HELPPREFIX + "wwnt0000"); //$NON-NLS-1$ - } - - /** - * Set a type to preselect in the dialog. - * If domains are supported, specify the domain number, else - * pass -1. - */ - public void preSelectType(int domain, String type) { - this.preSelectTypeDomain = domain; - this.typeToPreSelect = type; - } - - /** - * @see SystemPromptDialog#getInitialFocusControl() - */ - protected Control getInitialFocusControl() { - return treeView.getControl(); - } - - /** - * @see SystemPromptDialog#createInner(Composite) - */ - protected Control createInner(Composite parent) { - // Inner composite - int nbrColumns = 2; - Composite composite = SystemWidgetHelpers.createComposite(parent, nbrColumns); - // create tree view on left - if (subsystem != null) - treeView = new SystemUDTypeTreeView(composite, this, subsystem, udaActionSubsystem); - else - treeView = new SystemUDTypeTreeView(composite, this, subsystemFactory, profile); - Control c = treeView.getControl(); - //c.setToolTipText(SystemUDAResources.RESID_UDA_TREE_TIP)); it is too annoying - GridData data = (GridData) c.getLayoutData(); - if (data == null) data = new GridData(); - data.grabExcessHorizontalSpace = false; - data.horizontalAlignment = GridData.FILL; - data.grabExcessVerticalSpace = true; - data.verticalAlignment = GridData.FILL; - data.widthHint = 140; // 150, or 170 - data.heightHint = publicConvertHeightInCharsToPixels(12); // high enough to show 12 entries - c.setLayoutData(data); - // we want the tree view on the left to extend to the bottom of the page, so on the right - // we create a 1-column composite that will hold the edit pane on top, and the apply/revert - // buttons on the bottom... - Composite rightSideComposite = SystemWidgetHelpers.createFlushComposite(composite, 1); - // now populate top of right-side composite with edit pane... - //editpane = new SystemUDTypeEditPane( subsystem, this, treeView); - //if (subsystem!=null) - // editpane = getUDActionSubsystem().getCustomUDTypeEditPane( subsystem, this, treeView); - //else - // editpane = getUDActionSubsystem().getCustomUDTypeEditPane( subsystemFactory, profile, this, treeView); - editpane = getUDActionSubsystem().getCustomUDTypeEditPane(this, treeView); - editpane.createContents(rightSideComposite); - // now add a visual separator line - addSeparatorLine(rightSideComposite, 1); - // now populate bottom of right-side composite with apply/revert buttons within their own composite - int nbrColumns_buttonComposite = 4; - Composite applyResetButtonComposite = SystemWidgetHelpers.createFlushComposite(rightSideComposite, nbrColumns_buttonComposite); - //((GridData)applyResetButtonComposite.getLayoutData()).horizontalIndent = 200; // shift buttons to the right - // now populate the buttons composite with apply and revert buttons - Label filler = SystemWidgetHelpers.createLabel(applyResetButtonComposite, ""); //$NON-NLS-1$ - ((GridData) filler.getLayoutData()).grabExcessHorizontalSpace = true; - ((GridData) filler.getLayoutData()).horizontalAlignment = GridData.FILL; - applyButton = SystemWidgetHelpers.createPushButton(applyResetButtonComposite, this, SystemUDAResources.RESID_UDA_APPLY_BUTTON_LABEL, SystemUDAResources.RESID_UDA_APPLY_BUTTON_TOOLTIP); - //applyButton.setImage(RSEUIPlugin.getDefault().getImage(ISystemConstants.ICON_SYSTEM_OK_ID)); - revertButton = SystemWidgetHelpers.createPushButton(applyResetButtonComposite, this, SystemUDAResources.RESID_UDA_REVERT_BUTTON_LABEL, SystemUDAResources.RESID_UDA_REVERT_BUTTON_TOOLTIP); - // now add a spacer to soak up left-over height... - addGrowableFillerLine(rightSideComposite, 1); - // add state machine to edit pane - sm = new SystemEditPaneStateMachine(rightSideComposite, applyButton, revertButton); - editpane.setStateMachine(sm); - composite.layout(true); - rightSideComposite.setVisible(false); - // if we have been given a type to preselect, do so now... - //System.out.println("typeToPreSelect = " + typeToPreSelect); - if (typeToPreSelect != null) { - SystemUDTypeManager udtm = getUDActionSubsystem().getUDTypeManager(); - SystemUDTypeElement type = null; - if (preSelectTypeDomain >= 0) { - domainToPreExpand = getUDActionSubsystem().mapDomainXlatedName(preSelectTypeDomain); - //treeView.expandDomainNode(domainToPreExpand); - } - // add listeners, after expansion... - treeView.addSelectionChangedListener(editpane); - if (subsystem != null) - { - type = (SystemUDTypeElement) udtm.findByName(subsystem.getSystemProfile(), typeToPreSelect, preSelectTypeDomain); - } - if (type != null) objectToPreSelect = type; - } else { - //treeView.expandDomainNodes(); - // add listeners, after expansion... - treeView.addSelectionChangedListener(editpane); - } - //System.out.println("Test1"); - treeView.getShell().getDisplay().asyncExec(this); - //System.out.println("Test2"); - return composite; - } - - /** - * Intercept of parent so we can reset the default button - */ - protected void createButtonsForButtonBar(Composite parent) { - super.createButtonsForButtonBar(parent); - getShell().setDefaultButton(applyButton); // defect 46129 - } - - /** - * Return the user defined action subsystem - */ - protected SystemUDActionSubsystem getUDActionSubsystem() { - return udaActionSubsystem; - } - - /** - * Parent override. - * Called when user presses CLOSE button. - * If we exit, then we set the dialog's output object to be the - * name of the selected type. - */ - protected boolean processCancel() { - if (sm.isSaveRequired()) { - if (!editpane.validateInput(true, null)) { - sm.setChangesMade(); // defect 45773 - return false; // pending errors. Cannot save, so cannot close! - } - editpane.saveData(); - } - currentType = treeView.getSelectedTypeName(); - if (currentType.length() > 0) setOutputObject(currentType); - currentDomain = treeView.getSelectedTypeDomain(); - return super.processCancel(); - } - - /** - * Get the name of the type that was selected at the time we left - */ - public String getSelectedTypeName() { - return currentType; - } - - /** - * Get the domain of the type that was selected at the time we left - */ - public int getSelectedTypeDomain() { - return currentDomain; - } - - /** - * Override of parent method so we can direct it to the Apply button versus the OK button - */ - public void setPageComplete(boolean complete) { - if (applyButton != null) { - if (!complete) applyButton.setEnabled(false); - // else: we never enable it because the state machine does that anyway on any user-input change - } - } - - /** - * Return true if currently selected type is "ALL" - */ - protected boolean isAllTypeSelected() { - return treeView.getSelectedTypeName().equals("ALL"); //$NON-NLS-1$ - } - - /** - * Return true if currently selected type is vendor supplied - */ - protected boolean isSelectionVendorSupplied() { - return treeView.isSelectionVendorSupplied(); - } - - /** - * Return the vendor that is responsible for pre-supplying this existing type, - * or null if not applicable. - */ - protected String getVendorOfSelection() { - return treeView.getVendorOfSelection(); - } - - /** - * Handles events generated by controls on this page. - */ - public void handleEvent(Event e) { - clearMessage(); - Widget source = e.widget; - if (source == applyButton) { - processApply(); - } else if (source == revertButton) { - processRevert(); - } - } - - /** - * Process the apply button - */ - public void processApply() { - editpane.applyPressed(); - } - - /** - * Process the revert button - */ - public void processRevert() { - editpane.revertPressed(); - } - - // --------------- - // HELPER METHODS - // --------------- - /** - * Expose inherited protected method convertWidthInCharsToPixels as a publicly - * excessible method - */ - public int publicConvertWidthInCharsToPixels(int chars) { - return convertWidthInCharsToPixels(chars); - } - - /** - * Expose inherited protected method convertHeightInCharsToPixels as a publicly - * excessible method - */ - public int publicConvertHeightInCharsToPixels(int chars) { - return convertHeightInCharsToPixels(chars); - } - - // ----------------------------------- - // ISystemUDWorkWithDialog methods... - // ----------------------------------- - /** - * Decide if we can do the delete or not. - * Will decide the enabled state of the delete action. - */ - public boolean canDelete(Object selectedObject) { - return (sm.getMode() == ISystemEditPaneStates.MODE_EDIT) && !sm.areChangesPending() && !isSelectionVendorSupplied(); - } - - /** - * Decide if we can do the move up or not. - * Will decide the enabled state of the move up action. - */ - public boolean canMoveUp(Object selectedObject) { - boolean can = (sm.getMode() == ISystemEditPaneStates.MODE_EDIT) && !sm.areChangesPending() && !isAllTypeSelected(); - if (can) { - TreeItem selectedItem = treeView.getSelectedTreeItem(); - TreeItem parentItem = selectedItem.getParentItem(); - if (parentItem != null) - can = (parentItem.getItems()[0] != selectedItem); - else // this means we don't have domains - { - TreeItem[] roots = treeView.getTree().getItems(); - for (int idx = 0; idx < roots.length; idx++) { - if (roots[idx].getData() instanceof SystemXMLElementWrapper) { - can = (roots[idx] != selectedItem); - break; - } - } - } - } - return can; - } - - /** - * Decide if we can do the move down or not. - * Will decide the enabled state of the move down action. - */ - public boolean canMoveDown(Object selectedObject) { - boolean can = (sm.getMode() == ISystemEditPaneStates.MODE_EDIT) && !sm.areChangesPending() && !isAllTypeSelected(); - if (can) { - TreeItem selectedItem = treeView.getSelectedTreeItem(); - TreeItem parentItem = selectedItem.getParentItem(); - if (parentItem != null) - can = (parentItem.getItems()[parentItem.getItemCount() - 1] != selectedItem); - else // this means we don't have domains - { - TreeItem[] roots = treeView.getTree().getItems(); - can = (roots[roots.length - 1] != selectedItem); - } - } - return can; - } - - /** - * Decide if we can do the copy or not. - * Will decide the enabled state of the copy action. - */ - public boolean canCopy(Object selectedObject) { - boolean can = (sm.getMode() == ISystemEditPaneStates.MODE_EDIT) && !sm.areChangesPending() && !isAllTypeSelected(); - return can; - } - - /** - * For AsyncExec. - * Do selection, after tree is created - */ - public void run() { - // check it out! This run method executes multiple times even though it is only called once!!! - //System.out.println("Test1"); - if (domainToPreExpand != null) - treeView.expandDomainNode(domainToPreExpand); - else - treeView.expandDomainNodes(); - //System.out.println("Test2"); - //if (true) - // return; // for debugging - if (objectToPreSelect != null) { - if (objectToPreSelect instanceof SystemXMLElementWrapper) - treeView.selectElement((SystemXMLElementWrapper) objectToPreSelect); - else { - ISelection selection = new StructuredSelection(objectToPreSelect); - treeView.setSelection(selection, true); - } - } else - //else if (treeView.getTree().getSelectionCount() == 0) - { - objectToPreSelect = (treeView.getTree().getItems()[0]).getData(); - ISelection selection = new StructuredSelection(objectToPreSelect); - //System.out.println("Test5"); - treeView.setSelection(selection, true); - //System.out.println("Test6"); - } - } - - /** - * Return true if changes are pending in the edit pane - */ - public boolean areChangesPending() { - return sm.areChangesPending(); - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemXMLElementWrapper.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemXMLElementWrapper.java deleted file mode 100644 index ef5c18bad..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemXMLElementWrapper.java +++ /dev/null @@ -1,542 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - * Martin Oberhuber (Wind River) - [180562][api] dont implement ISystemUDAConstants - * Xuan Chen (IBM) - [222263] Need to provide a PropertySet Adapter for System Team View (cleanup some use action stuff) - * Kevin Doyle (IBM) - [240725] Add Null Pointer checking when there are no default user actions - * Kevin Doyle (IBM) - [222829] MoveUp/Down Broken in Work with User Actions Dialog - *******************************************************************************/ - -package org.eclipse.rse.internal.useractions.ui.uda; - -import java.util.Vector; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.Platform; -import org.eclipse.rse.core.model.IProperty; -import org.eclipse.rse.core.model.IPropertySet; -import org.eclipse.rse.core.model.IPropertySetContainer; -import org.eclipse.rse.core.model.ISystemProfile; -import org.eclipse.swt.graphics.Image; - - -/** - * This is a base class for classes that wrapper UDA elements. - * Eg, there are child classes to represent action UDA elements, and - * type UDA elements. - */ -public abstract class SystemXMLElementWrapper implements IAdaptable { - //parameters - protected IPropertySet elm; - private boolean isDomainElement; - private SystemUDBaseManager database; // For setChanged() - private ISystemProfile profile; - private int domainType; - // constants - /** - * What we store in UDA document for TRUE - */ - private static final String UDA_TRUE = "True"; //$NON-NLS-1$ - /** - * What we store in UDA document for FALSE - */ - private static final String UDA_FALSE = "False"; //$NON-NLS-1$ - /** - * The XML attribute name for the "IBM-Supplied" attribute - */ - private static final String UDA_ATTR_VENDOR = "Vendor"; //$NON-NLS-1$ - /** - * The XML attribute name for the "User-Changed" attribute - */ - private static final String UDA_ATTR_CHANGED = "UserChanged"; //$NON-NLS-1$ - /** - * The value we place in the Vendor attribute for IBM-supplied actions/types - */ - private static final String VENDOR_IBM = "IBM"; //$NON-NLS-1$ - - /** - * Constructor - * @param elm - The actual UDA element for this action/type - * @param mgr - The parent manager of these actions/types - * @param profile - The system profile which owns this action - * @param domainType - The integer representation of the domain this is in (or this is, for a domain element) - */ - public SystemXMLElementWrapper(IPropertySet elm, SystemUDBaseManager mgr, ISystemProfile profile, int domainType) { - super(); - this.elm = elm; - this.isDomainElement = elm.getPropertyValue(ISystemUDAConstants.TYPE_ATTR).equals(ISystemUDAConstants.XE_DOMAIN); - this.domainType = domainType; - database = mgr; - this.profile = profile; - } - - // ---------------------------------- - // METHODS THAT MUST BE OVERRIDDEN... - // ---------------------------------- - protected abstract String getTagName(); - - public abstract Image getImage(); - - // ------------------------------------- - // - // ------------------------------------- - /** - * Convert to a string - * Same as calling getName - */ - public String toString() { - return getName(); - } - - /** - * As required by the IAdaptable interface. - * @see IAdaptable#getAdapter(Class) - */ - public Object getAdapter(Class adapterType) { - return Platform.getAdapterManager().getAdapter(this, adapterType); - } - - /** - * Get the profile this is associated with - */ - public ISystemProfile getProfile() { - return profile; - } - - /** - * Get the manager that manages the document this element is part of. - */ - public SystemUDBaseManager getManager() { - return database; - } - - /** - * Get the UDA element this node wraps - */ - public IPropertySet getElement() { - return elm; - } - - /** - * Get the document this element is a part of - */ - public IPropertySet getDocument() { - // this method added by phil. - // this allows getChildren in xxxmanager classes to avoid deducing the document - return (IPropertySet)elm.getContainer(); - } - - /** - * Get the parent UDA element of this element. - * If domains aren't supported, this will return null - */ - public IPropertySet getParentDomainElement() { - IPropertySet parent = getParentElement(); - if ((parent != null) && parent.getPropertyValue(ISystemUDAConstants.NAME_ATTR).equals(ISystemUDAConstants.XE_DOMAIN)) - return parent; - else - return null; - } - - /** - * Get the parent UDA element of this element. - * Only returns null if this is the root, which should never happen. - */ - public IPropertySet getParentElement() { - Object parent = elm.getContainer(); - if (parent instanceof IPropertySet) - return (IPropertySet) parent; - else - return null; - } - - /** - * Is this a "Domain" tag? - */ - public boolean isDomain() { - return isDomainElement; - } - - /** - * Return the domain this element is in, or represents if it is a domain element itself. - * This is the integer representation used internally. - * Will be -1 if domains not supported for this subsystem. - */ - public int getDomain() { - return domainType; - } - - /** - * Return the value of this node's "name" attribute - */ - public String getName() { - return elm.getPropertyValue(ISystemUDAConstants.NAME_ATTR); - } - - /** - * Set the value of this tag's "Name" attribute. - * If this is an IBM-supplied user action, then it will cause an addition attribute to - * be created named "OriginalName", containing the IBM-supplied name. - */ - public void setName(String s) { - if (isIBM()) { - String orgName = elm.getPropertyValue(ISystemUDAConstants.ORIGINAL_NAME_ATTR); - if ((orgName != null) && (orgName.length() > 0)) { - // no need to do anything, as its already set. - } - else - { - IProperty property = elm.getProperty(ISystemUDAConstants.ORIGINAL_NAME_ATTR); - if (null == property) - { - elm.addProperty(ISystemUDAConstants.ORIGINAL_NAME_ATTR, getName()); - } - else - { - property.setValue(getName()); - } - } - } - setAttribute(ISystemUDAConstants.NAME_ATTR, s); - setUserChanged(true); - } - - /** - * Return the value of this node's "order" attribute - */ - public int getOrder() { - IProperty orderProperty = elm.getProperty(ISystemUDAConstants.ORDER_ATTR); - int order = -1; - - if (orderProperty != null) - { - order = Integer.valueOf(orderProperty.getValue()).intValue(); - } - return order; - } - - public void setOrder(int order) { - elm.addProperty(ISystemUDAConstants.ORDER_ATTR, Integer.toString(order)); - } - - /** - * For IBM-supplied elements that have been edited, returns the original IBM-supplied name - */ - public String getOriginalName() { - String s = elm.getPropertyValue(ISystemUDAConstants.ORIGINAL_NAME_ATTR); - if ((s == null) || (s.length() == 0)) - return getName(); - else - return s; - } - - /** - * Return the value of this node's "IBM" attribute. - * That is, is this an IBM-supplied tag? - */ - public boolean isIBM() { - String vendor = elm.getPropertyValue(UDA_ATTR_VENDOR); - if (vendor == null) - return false; - else - return vendor.equals(VENDOR_IBM); - } - - /** - * Set the name of the vendor who supplied this user action or type - */ - public void setVendor(String vendor) { - setAttribute(UDA_ATTR_VENDOR, vendor); - } - - /** - * Get the name of the vendor who supplied this user action or type. - * May be null, if created by a user - */ - public String getVendor() { - return elm.getPropertyValue(UDA_ATTR_VENDOR); - } - - /** - * Set the value of this tag's "Vendor" attribute to "IBM", - * or clear the IBM attribute (after a duplication action for example). - */ - public void setIBM(boolean isFromIBM) { - if (isFromIBM) - setAttribute(UDA_ATTR_VENDOR, VENDOR_IBM); - else - setAttribute(UDA_ATTR_VENDOR, null); - } - - /** - * Return the value of this node's "user-changed" attribute. - * That is, if this an IBM-supplied tag, has the user changed it? - */ - public boolean isUserChanged() { - boolean changed = false; - if (!isIBM()) - changed = true; - else if (isDomainElement) - changed = false; - else - changed = getBooleanAttribute(UDA_ATTR_CHANGED, false); - //System.out.println("Inside isUserChanged, returning "+changed+": isIBM()="+isIBM()+", isDomainElement="+isDomainElement); - return changed; - } - - /** - * Set the value of this tag's "user-changed" attribute - */ - public void setUserChanged(boolean isUserChanged) { - if (isIBM() && !isDomainElement) setBooleanAttribute(UDA_ATTR_CHANGED, isUserChanged); - } - - /** - * Delete this element from the document - */ - public void deleteElement() { - // Not intended for root. Only for Actions - //elm.getParentNode().removeChild(elm); - int elmOrder = getOrder(); - elm.getContainer().removePropertySet(elm.getName()); - IPropertySetContainer parentElement = elm.getContainer(); - IPropertySet[] allChildren = parentElement.getPropertySets(); - for (int i = 0; i < allChildren.length; i++) { - IProperty orderProperty = allChildren[i].getProperty(ISystemUDAConstants.ORDER_ATTR); - int order = -1; - if (orderProperty != null) - { - order = Integer.valueOf(orderProperty.getValue()).intValue(); - } - - // Decrease the order of all elements greater then elmOrder - if (order > elmOrder) { - allChildren[i].addProperty(ISystemUDAConstants.ORDER_ATTR, Integer.toString(order - 1)); - } - } - - - } - - /** - * Set the value of a boolean attribute - */ - public void setBooleanAttribute(String attr, boolean b) { - IProperty property = elm.getProperty(attr); - if (null == property) - { - elm.addProperty(attr, (b) ? UDA_TRUE : UDA_FALSE); - } - else - { - property.setValue((b) ? UDA_TRUE : UDA_FALSE); - } - database.setChanged(profile); - } - - /** - * Return the boolean value of a given attribute. It must exist! - * @param attr - name of the attribute to query - */ - public boolean getBooleanAttribute(String attr) { - String val = elm.getPropertyValue(attr); - if (UDA_TRUE.equals(val)) return true; - return false; - } - - /** - * Return the boolean value of a given attribute. - * @param attr - name of the attribute to query - * @param defaultValue - value to return if the attribute is not found - */ - public boolean getBooleanAttribute(String attr, boolean defaultValue) { - String val = elm.getPropertyValue(attr); - if (val == null) return defaultValue; - if (UDA_TRUE.equals(val)) return true; - return false; - } - - /** - * Set the text value of the given attribute. - * Specify a default value to return if the attribute is not found - */ - public String getAttribute(String attr, String defaultValue) { - String value = elm.getPropertyValue(attr); - if (value == null) value = defaultValue; - return value; - } - - /** - * Set the text value of the given attribute to a given value - */ - public void setAttribute(String attr, String value) { - if (value != null) - { - IProperty property = elm.getProperty(attr); - if (property == null) - { - elm.addProperty(attr, value); - } - else - { - property.setValue(value); - } - } - else - { - elm.removeProperty(attr); - } - database.setChanged(profile); - } - - /** - * For unique-name checking. - * If this is a domain element, returns all child action names. - * If this is an action/tag element, returns all sibling action names, minus this one. - * Always returns a non-null vector, although it may be empty - */ - public Vector getExistingNames() { - IPropertySet parentElement = null; - String currName = null; - if (isDomain()) - parentElement = this.getElement(); - else { - parentElement = getParentElement(); - currName = getName(); - } - Vector nameList = getExistingNames(parentElement, getDocument()); - if (currName != null) nameList.remove(currName); - return nameList; - } - - /** - * For unique-name checking. - * Given a parent element XML node, returns all child action names. - * Always returns a non-null vector, although it may be empty - */ - public Vector getExistingNames(IPropertySet parentElement, IPropertySet xdoc) { - return getExistingNames(parentElement, xdoc, getTagName()); - } - - /** - * For unique-name checking. - * Given a parent UDA node, returns all child action names. - * Always returns a non-null vector of Strings, although it may be empty - */ - public static Vector getExistingNames(IPropertySet parentElement, IPropertySet xdoc, String tagName) { - Vector nameList = new Vector(); - IPropertySet[] subList = null; - if (parentElement != null) - subList = parentElement.getPropertySets(); - else if (xdoc != null) - subList = xdoc.getPropertySets(); - if (subList != null) { - for (int idx = 0; idx < subList.length; idx++) { - IPropertySet sn = subList[idx]; - if (sn.getPropertyValue(ISystemUDAConstants.TYPE_ATTR).equals(tagName)) - { - nameList.add(sn.getPropertyValue(ISystemUDAConstants.NAME_ATTR)); - } - } // end for all subnodes - } // end if sublist != null - return nameList; - } - - /** - * Given a parent element XML node, returns wrappers of all child tags of which we are interested - * Always returns a non-null vector, although it may be empty - */ - public Vector getChildren(Vector children, IPropertySet parentElement, IPropertySet xdoc, ISystemProfile profile) { - return getChildren(children, parentElement, xdoc, profile, database, getDomain()); - } - - /** - * Given a parent element XML node, returns wrappers all child tag elements with the given tag name - * Always returns a non-null vector, although it may be empty. - * If the parentElement is null, uses the roots of the given document. Should only be true if domains not supported! - * @return Vector of SystemXMLElementWrapper objects - */ - public static Vector getChildren(Vector children, IPropertySet parentElement, IPropertySet xdoc, ISystemProfile profile, ISystemXMLElementWrapperFactory factory, int domain) { - if (children == null) children = new Vector(); - Vector ordered = new Vector(); - String tagName = factory.getTagName(); - - IPropertySet[] subList = null; - if (parentElement != null) - subList = parentElement.getPropertySets(); - else if (xdoc != null) - subList = xdoc.getPropertySets(); - if (subList != null) { - Vector unordered = new Vector(); - for (int idx = 0; idx < subList.length; idx++) { - IPropertySet sn = subList[idx]; - if (sn.getPropertyValue(ISystemUDAConstants.TYPE_ATTR).equals(tagName)) - { - unordered.add(sn); - } - } // end for all subnodes - ordered.setSize(unordered.size()); - for (int i = 0; i < unordered.size(); i++) { - int order = i; - // get the ordering - IPropertySet sn = ((IPropertySet) unordered.get(i)); - IProperty orderProperty = sn.getProperty(ISystemUDAConstants.ORDER_ATTR); - if (orderProperty != null) { - order = Integer.valueOf(orderProperty.getValue()).intValue(); - } - - SystemXMLElementWrapper thisWrapper = factory.createElementWrapper(sn, profile, domain); - try { - ordered.remove(order); - ordered.add(order, thisWrapper); - } catch (Exception e) { - e.printStackTrace(); - } - } - } // end if sublist != null - // Set the order position of all attributes to handle 3.0 where we didn't have the order attribute - for (int i = 0; i < ordered.size(); i++) { - if (ordered.get(i) instanceof SystemXMLElementWrapper) { - SystemXMLElementWrapper element = (SystemXMLElementWrapper) ordered.get(i); - if (element != null) - element.setOrder(i); - } - children.add(ordered.get(i)); - } - return children; - } - - /** - * For unique-name checking. - * Given a parent element XML node, returns the xml Element node with the given name attribute, - * or null if not found. - */ - public static IPropertySet findChildByName(IPropertySet parentElement, IPropertySet xdoc, String tagName, String searchName) { - IPropertySet match = null; - IPropertySet[] subList = null; - if (parentElement != null) - subList = parentElement.getPropertySets(); - else - subList = xdoc.getPropertySets(); - if (subList != null) { - for (int idx = 0; (match == null) && (idx < subList.length); idx++) { - IPropertySet sn = subList[idx]; - if (sn.getName().equals(searchName)) - { - IProperty typeProperty = sn.getProperty(ISystemUDAConstants.TYPE_ATTR); - if (typeProperty.getValue().equals(tagName)) - { - match = sn; - } - } - } // end for all subnodes - } // end if sublist != null - return match; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/actions/SystemWorkWithFileTypesAction.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/actions/SystemWorkWithFileTypesAction.java deleted file mode 100644 index 343b53c4e..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/actions/SystemWorkWithFileTypesAction.java +++ /dev/null @@ -1,158 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.uda.actions; - -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - * David Dykstal (IBM) - [186589] move user types, user actions, and compile commands - * API to the user actions plugin - * Xuan Chen (IBM) - [225617] [useraction][api] Remove Team view support inside user action. - * Kevin Doyle (IBM) - [222828] Icons for some Actions Missing - *******************************************************************************/ -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.rse.core.model.ISystemProfile; -import org.eclipse.rse.core.subsystems.ISubSystem; -import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; -import org.eclipse.rse.internal.useractions.Activator; -import org.eclipse.rse.internal.useractions.IUserActionsImageIds; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDActionSubsystem; -import org.eclipse.rse.internal.useractions.ui.uda.SystemWorkWithUDTypeDialog; -import org.eclipse.rse.ui.ISystemContextMenuConstants; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.actions.SystemBaseDialogAction; -import org.eclipse.swt.widgets.Shell; - -/** - * The action that displays the Work With File Types GUI - */ -public class SystemWorkWithFileTypesAction extends SystemBaseDialogAction { - private ISubSystem subsystem = null; - private ISubSystemConfiguration subsystemFactory = null; - private SystemUDActionSubsystem udaActionSubsystem; - private ISystemProfile profile; - private SystemWorkWithUDTypeDialog ourDlg = null; - private String typeToPreSelect = null; - private int preSelectTypeDomain; - private String outputSelectedType; - private int outputSelectedDomain = -1; - - /** - * Constructor when we have a subsystem - * @param parent The Shell of the parent UI for this dialog - * @param udaActionSubsystem The User Define Action subsystem we are launching this from/for - */ - public SystemWorkWithFileTypesAction(Shell parent, SystemUDActionSubsystem udaActionSubsystem) { - this(parent); - this.udaActionSubsystem = udaActionSubsystem; - this.subsystem = udaActionSubsystem.getSubsystem(); - if (subsystem != null) { - this.subsystemFactory = subsystem.getSubSystemConfiguration(); - this.profile = subsystem.getSystemProfile(); - } - setAvailableOffline(true); - } - - /** - * Constructor when we have a subsystem factory and profile - * @param parent The Shell of the parent UI for this dialog - * @param subSystemFactory The subsystem factory we are launching this from/for - * @param profile The profile we are launching this from/for - */ - public SystemWorkWithFileTypesAction(Shell parent, ISubSystemConfiguration subSystemFactory, ISystemProfile profile) { - this(parent); - this.subsystemFactory = subSystemFactory; - this.profile = profile; - } - - /** - * Constructor when we don't have anything - * At run time, the input is deduced from the first selected object. - * @param parent The Shell of the parent UI for this dialog - */ - public SystemWorkWithFileTypesAction(Shell parent) { - super(SystemUDAResources.ACTION_WORKWITH_NAMEDTYPES_LABEL, SystemUDAResources.ACTION_WORKWITH_NAMEDTYPES_TOOLTIP, Activator.getDefault().getImageDescriptor( - IUserActionsImageIds.WORK_WITH_NAMED_TYPES_1), parent); - allowOnMultipleSelection(false); - setContextMenuGroup(ISystemContextMenuConstants.GROUP_WORKWITH); - setHelp(RSEUIPlugin.HELPPREFIX + "actn0046"); //$NON-NLS-1$ - } - - /** - * Set a type to preselect in the dialog. - * If domains are supported, specify the domain number, else - * pass -1. - */ - public void preSelectType(int domain, String type) { - this.typeToPreSelect = type; - this.preSelectTypeDomain = domain; - } - - /** - * Called by SystemBaseAction when selection is set. - * Our opportunity to verify we are allowed for this selected type. - */ - public boolean checkObjectType(Object selectedObject) { - return true; - } - - /** - * If you decide to use the supplied run method as is, - * then you must override this method to create and return - * the dialog that is displayed by the default run method - * implementation. - * <p> - * If you override run with your own, then - * simply implement this to return null as it won't be used. - * @see #run() - */ - protected Dialog createDialog(Shell parent) { - if ((subsystem == null) && (getFirstSelection() instanceof ISubSystem)) - subsystem = (ISubSystem) getFirstSelection(); - if (subsystem != null) - ourDlg = new SystemWorkWithUDTypeDialog(parent, subsystem, udaActionSubsystem); - else - ourDlg = new SystemWorkWithUDTypeDialog(parent, subsystemFactory, profile); - if (typeToPreSelect != null) ourDlg.preSelectType(preSelectTypeDomain, typeToPreSelect); - return ourDlg; - } - - /** - * Required by parent. After the dialog closes, its output - * object contains the type that was selected at the time - * of the close. This might be of interest to someone, so - * we scoop it out here, and return it in the - * getSelectedTypeName() method. - */ - protected Object getDialogValue(Dialog dlg) { - outputSelectedType = ((SystemWorkWithUDTypeDialog) dlg).getSelectedTypeName(); - if ((outputSelectedType != null) && (outputSelectedType.length() == 0)) outputSelectedType = null; - return outputSelectedType; - } - - /** - * Return the name of the type that was selected at the - * time of exiting the dialog. Might be null! - */ - public String getSelectedTypeName() { - outputSelectedType = ourDlg.getSelectedTypeName(); - //System.out.println("outputSelectedType = " + outputSelectedType); - if ((outputSelectedType != null) && (outputSelectedType.length() == 0)) outputSelectedType = null; - return outputSelectedType; - } - - /** - * Return the domain of the type that was selected at the - * time of exiting the dialog. Might be -1! - */ - public int getSelectedTypeDomain() { - outputSelectedDomain = ourDlg.getSelectedTypeDomain(); - //System.out.println("outputSelectedDomain = " + outputSelectedDomain); - return outputSelectedDomain; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/actions/SystemWorkWithUDAsAction.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/actions/SystemWorkWithUDAsAction.java deleted file mode 100644 index 517e86fcb..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/actions/SystemWorkWithUDAsAction.java +++ /dev/null @@ -1,179 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.uda.actions; - -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - * David Dykstal (IBM) - [186589] move user types, user actions, and compile commands - * API to the user actions plugin - * Xuan Chen (IBM) - [225617] [useraction][api] Remove Team view support inside user action. - * Kevin Doyle (IBM) - [222828] Icons for some Actions Missing - * Kevin Doyle (IBM) - [252296] Work With User Actions action is not available in offline mode - *******************************************************************************/ -//import java.util.Iterator; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.rse.core.model.ISystemProfile; -import org.eclipse.rse.core.subsystems.ISubSystem; -import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; -import org.eclipse.rse.internal.useractions.Activator; -import org.eclipse.rse.internal.useractions.IUserActionsImageIds; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDActionSubsystem; -import org.eclipse.rse.internal.useractions.ui.uda.SystemWorkWithUDAsDialog; -import org.eclipse.rse.ui.ISystemContextMenuConstants; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.actions.SystemBaseDialogAction; -import org.eclipse.swt.widgets.Shell; - -/** - * The action that displays the Work With User-Defined Actions GUI - */ -public class SystemWorkWithUDAsAction extends SystemBaseDialogAction { - private ISubSystem subsystem = null; - private ISubSystemConfiguration subsystemFactory = null; - private ISystemProfile profile; - private SystemUDActionSubsystem udaActionSubsystem = null; - - /** - * Constructor when starting with a subsystem (such as in RS view) - * @param parent The Shell of the parent UI for this dialog - * @param subSystem The subsystem we are launching this from/for - */ - public SystemWorkWithUDAsAction(Shell parent, ISubSystem subSystem, SystemUDActionSubsystem udaActionSubsystem) { - this(parent); - setSubSystem(subSystem); - setActionSubsystem(udaActionSubsystem); - setAvailableOffline(true); - } - - /** - * Constructor when starting with a subsystem factory (such as in Team view) - * @param parent The Shell of the parent UI for this dialog - * @param subSystemFactory The subsystem factory we are launching this from/for - */ - public SystemWorkWithUDAsAction(Shell parent, ISubSystemConfiguration subSystemFactory, ISystemProfile profile, SystemUDActionSubsystem udaActionSubsystem) { - this(parent); - setSubSystemFactory(subsystemFactory, profile); - setActionSubsystem(udaActionSubsystem); - } - - /** - * Constructor when we don't have anything. - * At run time, the input is deduced from the first selected object. - * @param parent The Shell of the parent UI for this dialog - */ - public SystemWorkWithUDAsAction(Shell parent) { - super(SystemUDAResources.ACTION_WORKWITH_UDAS_LABEL, SystemUDAResources.ACTION_WORKWITH_UDAS_TOOLTIP, Activator.getDefault().getImageDescriptor( - IUserActionsImageIds.WORK_WITH_USER_ACTIONS_1), parent); - allowOnMultipleSelection(false); - setContextMenuGroup(ISystemContextMenuConstants.GROUP_WORKWITH); - setHelp(RSEUIPlugin.HELPPREFIX + "actn0045"); //$NON-NLS-1$ - } - - /** - * Constructor when we don't have anything, and we want to choose between "Work with->User Actions" and "Work With User Actions". - * At run time, the input is deduced from the first selected object. - * @param parent The Shell of the parent UI for this dialog - * @param fromCascadingCompileAction true to get "Work with Compile Commands" label, false to get "Compile Commands" label. - */ - public SystemWorkWithUDAsAction(Shell parent, boolean fromCascadingCompileAction) { - super(fromCascadingCompileAction ? SystemUDAResources.ACTION_WORKWITH_WWUDAS_LABEL : SystemUDAResources.ACTION_WORKWITH_UDAS_LABEL, - fromCascadingCompileAction ? SystemUDAResources.ACTION_WORKWITH_WWUDAS_TOOLTIP : SystemUDAResources.ACTION_WORKWITH_UDAS_TOOLTIP, Activator.getDefault().getImageDescriptor( - IUserActionsImageIds.WORK_WITH_USER_ACTIONS_1), parent); - allowOnMultipleSelection(false); - if (!fromCascadingCompileAction) - setContextMenuGroup(ISystemContextMenuConstants.GROUP_WORKWITH); - else - setContextMenuGroup(ISystemContextMenuConstants.GROUP_REORGANIZE); - setHelp(RSEUIPlugin.HELPPREFIX + "actn0045"); //$NON-NLS-1$ - setAvailableOffline(true); - } - - /** - * Reset between runs - */ - public void reset() { - subsystem = null; - subsystemFactory = null; - profile = null; - } - - /** - * Set the subsystem which is the input to this action. You either call this, - * or setSubSystemFactory, or the input is deduced from the selection when the action is run. - */ - public void setSubSystem(ISubSystem subsystem) { - this.subsystem = subsystem; - if (subsystem != null) { - this.subsystemFactory = subsystem.getSubSystemConfiguration(); - this.profile = subsystem.getSystemProfile(); - } - } - - /** - * Set the subsystem factory and profile, which are the input to this action. You either call this, - * or setSubSystem, or the input is deduced from the selection when the action is run. - */ - public void setSubSystemFactory(ISubSystemConfiguration subsystemFactory, ISystemProfile profile) { - this.subsystemFactory = subsystemFactory; - this.profile = profile; - } - - public void setActionSubsystem(SystemUDActionSubsystem udaActionSubsystem) { - this.udaActionSubsystem = udaActionSubsystem; - } - /** - * Called by SystemBaseAction when selection is set. - * Our opportunity to verify we are allowed for this selected type. - */ - public boolean updateSelection(IStructuredSelection selection) { - return true; - } - - /** - * If you decide to use the supplied run method as is, - * then you must override this method to create and return - * the dialog that is displayed by the default run method - * implementation. - * <p> - * If you override run with your own, then - * simply implement this to return null as it won't be used. - * @see #run() - */ - protected Dialog createDialog(Shell parent) { - Object element = getFirstSelection(); - //System.out.println("First selection: "+element); - if ((subsystem == null) && (element instanceof ISubSystem)) { - subsystem = (ISubSystem) element; - } - //Don't think we need to support invoking Work With User Action dialog from Team view - /* - else if ((subsystemFactory == null) && (element instanceof SystemTeamViewSubSystemConfigurationNode)) { - SystemTeamViewSubSystemConfigurationNode ssfNode = (SystemTeamViewSubSystemConfigurationNode) element; - subsystemFactory = ssfNode.getSubSystemConfiguration(); - profile = ssfNode.getProfile(); - //System.out.println("Profile is: "+profile); - } - */ - SystemWorkWithUDAsDialog dlg = null; - if (subsystem != null) - dlg = new SystemWorkWithUDAsDialog(parent, subsystem, udaActionSubsystem); - else - dlg = new SystemWorkWithUDAsDialog(parent, subsystemFactory, profile, udaActionSubsystem); - return dlg; - } - - /** - * Required by parent. We use it to return the new name. - * In our case, we don't need it, so we return null. - */ - protected Object getDialogValue(Dialog dlg) { - return null; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/util/MatchStr.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/util/MatchStr.java deleted file mode 100644 index a0cc154db..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/util/MatchStr.java +++ /dev/null @@ -1,97 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.uda.util; - -/******************************************************************************* - * Copyright (c) 2002, 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 - *******************************************************************************/ -import java.util.StringTokenizer; -import java.util.Vector; - -public class MatchStr { - private String matchStr; - private Vector mStrTokens; - private boolean splatAtEnd; - - public MatchStr(String p_matchStr) { - matchStr = p_matchStr; - StringTokenizer st = new StringTokenizer(matchStr, "*"); //$NON-NLS-1$ - int n = st.countTokens(); - mStrTokens = new Vector(); - for (int i = 0; i < n; i++) { - mStrTokens.addElement(st.nextToken()); - } - splatAtEnd = matchStr.charAt(matchStr.length() - 1) == '*'; - } - - public boolean isMatch(String str) { - if (str.indexOf("*") == 0) //$NON-NLS-1$ - { - str = str.substring(1); - } - if (mStrTokens.size() == 0) { - return true; - } - if (!str.startsWith((String) mStrTokens.elementAt(0))) { - return false; - } - if (!splatAtEnd) { - if (mStrTokens.size() == 1) { - return str.equals(mStrTokens.elementAt(0)); - } else if (!str.endsWith((String) mStrTokens.elementAt(mStrTokens.size() - 1))) { - return false; - } - } - int i = ((String) mStrTokens.elementAt(0)).length(); - int j = 1; - while (i < str.length() && j < mStrTokens.size()) { - String tempStr = str.substring(i); - if (tempStr.startsWith((String) mStrTokens.elementAt(j))) { - i = i + tempStr.length(); - j++; - } - i++; - } - return mStrTokens.size() == j; - } - /* public static void main(String[] args) - { - MatchStr matchStr = new MatchStr("AB*"); - - if (matchStr.isMatch("ABaasBdddd")) - { - System.out.println("true"); - } - else - { - System.out.println("false"); - } - - matchStr = new MatchStr("*"); - boolean one = matchStr.isMatch("lskda"); - boolean two = matchStr.isMatch(""); - boolean three = matchStr.isMatch("1"); - - - matchStr = new MatchStr("abc"); - boolean four = matchStr.isMatch("abcdabc"); - boolean five = matchStr.isMatch("abc"); - - - matchStr = new MatchStr("abc*"); - boolean six = matchStr.isMatch("abcdabc"); - boolean seven = matchStr.isMatch("abc"); - - - try { - System.in.read(); - } catch (Exception e) - { - } - }*/ -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/util/UDAFileTypesForName.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/util/UDAFileTypesForName.java deleted file mode 100644 index f4eb9c8e3..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/util/UDAFileTypesForName.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.uda.util; - -/******************************************************************************* - * Copyright (c) 2002, 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 - *******************************************************************************/ -public class UDAFileTypesForName { - String name; - String types; - - public UDAFileTypesForName(String p_name, String p_types) { - name = p_name; - types = p_types; - } - - public String getName() { - return name; - } - - public String getTypes() { - return types; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/util/UDAResolvedTypes.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/util/UDAResolvedTypes.java deleted file mode 100644 index 49dc88533..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/util/UDAResolvedTypes.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.eclipse.rse.internal.useractions.ui.uda.util; - -/******************************************************************************* - * Copyright (c) 2002, 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 - *******************************************************************************/ -import java.util.Vector; - -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDTypeElement; -import org.eclipse.rse.internal.useractions.ui.uda.SystemUDTypeManager; - -public class UDAResolvedTypes { - protected Vector previousTypes = null; - - public UDAResolvedTypes() { - previousTypes = null; - } - - protected void addTypesToVector(Vector v, Object[] objElems) { - for (int i = 0; i < objElems.length; i++) { - SystemUDTypeElement typeElem = (SystemUDTypeElement) objElems[i]; - String name = typeElem.toString(); - resolveType(name, v, objElems); - } - } - - protected String resolveTypes(String types, Vector v, Object[] objElems) { - int i = types.indexOf("<"); //$NON-NLS-1$ - if (i < 0) return types; - int j = types.indexOf(">"); //$NON-NLS-1$ - if (i >= j) return types; - String type = types.substring(i + 1, j); - String resolvedType = resolveType(type, v, objElems); - return types.substring(0, i) + " " + resolvedType + " " + resolveTypes(types.substring(j + 1), v, objElems); //$NON-NLS-1$ //$NON-NLS-2$ - } - - protected String resolveType(String type, Vector v, Object[] objElems) { - if (previousTypes.contains(type)) { - return ""; //$NON-NLS-1$ - } - String resolvedTypes = resolveType(type, v); - if (resolvedTypes != null) return resolvedTypes; - for (int i = 0; i < objElems.length; i++) { - SystemUDTypeElement typeElem = (SystemUDTypeElement) objElems[i]; - if (type.equals(typeElem.toString())) { - previousTypes.addElement(type); - resolvedTypes = resolveTypes(typeElem.getTypes(), v, objElems); - previousTypes.remove(type); - v.addElement(new UDAFileTypesForName(type, resolvedTypes)); - return resolvedTypes; - } - } - return ""; //$NON-NLS-1$ - } - - protected String resolveType(String type, Vector v) { - for (int i = 0; i < v.size(); i++) { - UDAFileTypesForName typesForName = (UDAFileTypesForName) v.elementAt(i); - if (type.equals(typesForName.getName())) { - return typesForName.getTypes(); - } - } - return null; - } - - public String getFileTypesForTypeName(String name, int type, SystemUDTypeManager typeMgr) { - // ?? Implement for non NFS types??? - return null; - } -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/validators/ValidatorCompileCommandLabel.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/validators/ValidatorCompileCommandLabel.java deleted file mode 100644 index c5e33fd44..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/validators/ValidatorCompileCommandLabel.java +++ /dev/null @@ -1,148 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * David Dykstal (IBM) - [186589] move user types, user actions, and compile commands - * API to the user actions plugin - * David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared - *******************************************************************************/ - -package org.eclipse.rse.internal.useractions.ui.validators; - -import java.util.Collection; - -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.rse.internal.useractions.Activator; -import org.eclipse.rse.internal.useractions.IUserActionsMessageIds; -import org.eclipse.rse.internal.useractions.UserActionsResources; -import org.eclipse.rse.services.clientserver.messages.SimpleSystemMessage; -import org.eclipse.rse.services.clientserver.messages.SystemMessage; -import org.eclipse.rse.ui.validators.ISystemValidator; -import org.eclipse.rse.ui.validators.ValidatorUniqueString; - -/** - * This class is used to verify a user defined compile command's label - */ -public class ValidatorCompileCommandLabel extends ValidatorUniqueString implements ISystemValidator { - public static final int MAX_CMDLABEL_LENGTH = 50; // max name for a compile command name - - protected boolean fUnique; - protected SystemMessage msg_Invalid; - protected IWorkspace workspace = ResourcesPlugin.getWorkspace(); - - /** - * Use this constructor when you have a list of existing labels. - * The collection will not be modified by the validator. - */ - public ValidatorCompileCommandLabel(Collection existingLabelList) { - super(existingLabelList, CASE_INSENSITIVE); // case insensitive uniqueness - init(); - } - - /** - * Use this constructor when you have an array of existing labels. - */ - public ValidatorCompileCommandLabel(String existingLabelList[]) { - super(existingLabelList, CASE_INSENSITIVE); // case insensitive uniqueness - init(); - } - - /** - * Use this constructor when the name need not be unique, and you just want - * the syntax checking. Or if you will call setExistingNamesList later. - */ - public ValidatorCompileCommandLabel() { - super(new String[0], CASE_INSENSITIVE); - init(); - } - - private void init() { - String msg1Txt = UserActionsResources.MSG_VALIDATE_COMPILELABEL_EMPTY; - String msg1Details = UserActionsResources.MSG_VALIDATE_COMPILELABEL_EMPTY_DETAILS; - - SystemMessage msg1 = new SimpleSystemMessage(Activator.PLUGIN_ID, - IUserActionsMessageIds.MSG_VALIDATE_COMPILELABEL_EMPTY, - IStatus.ERROR, msg1Txt, msg1Details); - - String msg2Txt = UserActionsResources.MSG_VALIDATE_COMPILELABEL_NOTUNIQUE; - String msg2Details = UserActionsResources.MSG_VALIDATE_COMPILELABEL_NOTUNIQUE_DETAILS; - - SystemMessage msg2 = new SimpleSystemMessage(Activator.PLUGIN_ID, - IUserActionsMessageIds.MSG_VALIDATE_COMPILELABEL_NOTUNIQUE, - IStatus.ERROR, msg2Txt, msg2Details); - - super.setErrorMessages(msg1, msg2); - fUnique = true; - - String msg3Txt = UserActionsResources.MSG_VALIDATE_COMPILELABEL_NOTVALID; - String msg3Details= UserActionsResources.MSG_VALIDATE_COMPILELABEL_NOTVALID_DETAILS; - - msg_Invalid = new SimpleSystemMessage(Activator.PLUGIN_ID, - IUserActionsMessageIds.MSG_VALIDATE_COMPILELABEL_NOTVALID, - IStatus.ERROR, msg3Txt, msg3Details); - } - - /** - * Supply your own error message text. By default, messages from RSEUIPlugin resource bundle are used. - * @param msg_Empty error message when entry field is empty - * @param msg_NonUnique error message when value entered is not unique - * @param msg_Invalid error message when syntax is not valid - */ - public void setErrorMessages(SystemMessage msg_Empty, SystemMessage msg_NonUnique, SystemMessage msg_Invalid) { - super.setErrorMessages(msg_Empty, msg_NonUnique); - this.msg_Invalid = msg_Invalid; - } - - /** - * Overridable method for invalidate character check, beyond what this class offers - * @return true if valid, false if not - */ - protected boolean checkForBadCharacters(String newText) { - return ((newText.indexOf('&') == -1) && // causes problems in menu popup as its a mnemonic character. - (newText.indexOf('@') == -1)); // defect 43950 - } - - public String toString() { - return getClass().getName(); - } - - // --------------------------- - // Parent Overrides... - // --------------------------- - /** - * Validate each character. - * Override of parent method. - * Override yourself to refine the error checking. - */ - public SystemMessage isSyntaxOk(String newText) { - if (newText.length() > getMaximumNameLength()) - currentMessage = msg_Invalid; - else - currentMessage = checkForBadCharacters(newText) ? null : msg_Invalid; - return currentMessage; - } - - // --------------------------- - // ISystemValidator methods... - // --------------------------- - - /** - * Return the max length for compile commands: 50 - */ - public int getMaximumNameLength() { - return MAX_CMDLABEL_LENGTH; - } - -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/validators/ValidatorUserActionCommand.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/validators/ValidatorUserActionCommand.java deleted file mode 100644 index 557f2f02a..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/validators/ValidatorUserActionCommand.java +++ /dev/null @@ -1,125 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * David Dykstal (IBM) - [186589] move user types, user actions, and compile commands - * API to the user actions plugin - * David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared - *******************************************************************************/ - -package org.eclipse.rse.internal.useractions.ui.validators; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.rse.internal.useractions.Activator; -import org.eclipse.rse.internal.useractions.IUserActionsMessageIds; -import org.eclipse.rse.internal.useractions.UserActionsResources; -import org.eclipse.rse.services.clientserver.messages.SimpleSystemMessage; -import org.eclipse.rse.services.clientserver.messages.SystemMessage; -import org.eclipse.rse.ui.validators.ISystemValidator; - -/** - * This class is used to verify a user defined action's command - */ -public class ValidatorUserActionCommand implements ISystemValidator { - public static final int MAX_UDACMD_LENGTH = 512; // max command for an action - - protected SystemMessage emptyMsg, invalidMsg, currentMessage; - - /** - * Constructor to use when wanting to specify the "value required" error message, - * but use the default for the "Value not valid" error message - */ - public ValidatorUserActionCommand() { - String msg1Txt = UserActionsResources.MSG_VALIDATE_UDACMD_EMPTY; - String msg1Details = UserActionsResources.MSG_VALIDATE_UDACMD_EMPTY_DETAILS; - - SystemMessage msg1 = new SimpleSystemMessage(Activator.PLUGIN_ID, - IUserActionsMessageIds.MSG_VALIDATE_UDACMD_EMPTY, - IStatus.ERROR, msg1Txt, msg1Details); - - String msg2Txt = UserActionsResources.MSG_VALIDATE_UDACMD_NOTVALID; - String msg2Details = UserActionsResources.MSG_VALIDATE_UDACMD_NOTVALID_DETAILS; - - SystemMessage msg2 = new SimpleSystemMessage(Activator.PLUGIN_ID, - IUserActionsMessageIds.MSG_VALIDATE_UDACMD_NOTVALID, - IStatus.ERROR, msg2Txt, msg2Details); - setErrorMessages(msg1,msg2); - } - - /** - * Set the error messages, overriding the defaults - */ - public void setErrorMessages(SystemMessage emptyMsg, SystemMessage invalidMsg) { - this.emptyMsg = emptyMsg; - this.invalidMsg = invalidMsg; - } - - // --------------------------- - // ISystemValidator methods... - // --------------------------- - - /** - * @see org.eclipse.jface.viewers.ICellEditorValidator#isValid(java.lang.Object) - */ - public String isValid(Object input) { - currentMessage = null; - if (!(input instanceof String)) { - return null; - } else - return isValid((String) input); - } - - /** - * @see org.eclipse.jface.dialogs.IInputValidator#isValid(java.lang.String) - * @see #getSystemMessage() - */ - public String isValid(String input) { - currentMessage = null; - if ((input == null) || (input.length() == 0)) { - currentMessage = emptyMsg; - } else { - if (input.length() > MAX_UDACMD_LENGTH) currentMessage = invalidMsg; - } - return (currentMessage == null) ? null : currentMessage.getLevelOneText(); - } - - /** - * When isValid returns non-null, call this to get the SystemMessage object for the error - * versus the simple string message. - */ - public SystemMessage getSystemMessage() { - return currentMessage; - } - - /** - * Return the max length for comments - */ - public int getMaximumNameLength() { - return MAX_UDACMD_LENGTH; - } - - /** - * For convenience, this is a shortcut to calling: - * <pre><code> - * if (isValid(text) != null) - * msg = getSystemMessage(); - * </code></pre> - */ - public SystemMessage validate(String text) { - if (isValid(text) != null) - return currentMessage; - else - return null; - } - -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/validators/ValidatorUserActionComment.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/validators/ValidatorUserActionComment.java deleted file mode 100644 index 676f1303d..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/validators/ValidatorUserActionComment.java +++ /dev/null @@ -1,126 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * David Dykstal (IBM) - [186589] move user types, user actions, and compile commands - * API to the user actions plugin - * David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared - *******************************************************************************/ - -package org.eclipse.rse.internal.useractions.ui.validators; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.rse.internal.useractions.Activator; -import org.eclipse.rse.internal.useractions.IUserActionsMessageIds; -import org.eclipse.rse.internal.useractions.UserActionsResources; -import org.eclipse.rse.services.clientserver.messages.SimpleSystemMessage; -import org.eclipse.rse.services.clientserver.messages.SystemMessage; -import org.eclipse.rse.ui.validators.ISystemValidator; - -/** - * This class is used to verify a user defined action's comment - */ -public class ValidatorUserActionComment implements ISystemValidator { - public static final int MAX_UDACMT_LENGTH = 256; // max comment for an action - - protected SystemMessage emptyMsg, invalidMsg, currentMessage; - - /** - * Constructor to use when wanting to specify the "value required" error message, - * but use the default for the "Value not valid" error message - */ - public ValidatorUserActionComment() { - String msg1Txt = UserActionsResources.MSG_VALIDATE_UDACMT_EMPTY; - String msg1Details = UserActionsResources.MSG_VALIDATE_UDACMT_EMPTY_DETAILS; - - SystemMessage msg1 = new SimpleSystemMessage(Activator.PLUGIN_ID, - IUserActionsMessageIds.MSG_VALIDATE_UDACMT_EMPTY, - IStatus.ERROR, msg1Txt, msg1Details); - - String msg2Txt = UserActionsResources.MSG_VALIDATE_UDACMT_NOTVALID; - String msg2Details = UserActionsResources.MSG_VALIDATE_UDACMT_NOTVALID_DETAILS; - - SystemMessage msg2 = new SimpleSystemMessage(Activator.PLUGIN_ID, - IUserActionsMessageIds.MSG_VALIDATE_UDACMT_NOTVALID, - IStatus.ERROR, msg2Txt, msg2Details); - - setErrorMessages(msg1, msg2); - } - - /** - * Set the error messages, overriding the defaults - */ - public void setErrorMessages(SystemMessage emptyMsg, SystemMessage invalidMsg) { - this.emptyMsg = emptyMsg; - this.invalidMsg = invalidMsg; - } - - // --------------------------- - // ISystemValidator methods... - // --------------------------- - - /** - * @see org.eclipse.jface.viewers.ICellEditorValidator#isValid(java.lang.Object) - */ - public String isValid(Object input) { - currentMessage = null; - if (!(input instanceof String)) { - return null; - } else - return isValid((String) input); - } - - /** - * @see org.eclipse.jface.dialogs.IInputValidator#isValid(java.lang.String) - * @see #getSystemMessage() - */ - public String isValid(String input) { - currentMessage = null; - if ((input == null) || (input.length() == 0)) { - //currentMessage = emptyMsg; - } else { - if (input.length() > MAX_UDACMT_LENGTH) currentMessage = invalidMsg; - } - return (currentMessage == null) ? null : currentMessage.getLevelOneText(); - } - - /** - * When isValid returns non-null, call this to get the SystemMessage object for the error - * versus the simple string message. - */ - public SystemMessage getSystemMessage() { - return currentMessage; - } - - /** - * Return the max length for comments - */ - public int getMaximumNameLength() { - return MAX_UDACMT_LENGTH; - } - - /** - * For convenience, this is a shortcut to calling: - * <pre><code> - * if (isValid(text) != null) - * msg = getSystemMessage(); - * </code></pre> - */ - public SystemMessage validate(String text) { - if (isValid(text) != null) - return currentMessage; - else - return null; - } - -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/validators/ValidatorUserActionName.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/validators/ValidatorUserActionName.java deleted file mode 100644 index 93106c986..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/validators/ValidatorUserActionName.java +++ /dev/null @@ -1,152 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * David Dykstal (IBM) - [186589] move user types, user actions, and compile commands - * API to the user actions plugin - * David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared - *******************************************************************************/ - -package org.eclipse.rse.internal.useractions.ui.validators; - -import java.util.Collection; - -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.rse.internal.useractions.Activator; -import org.eclipse.rse.internal.useractions.IUserActionsMessageIds; -import org.eclipse.rse.internal.useractions.UserActionsResources; -import org.eclipse.rse.services.clientserver.messages.SimpleSystemMessage; -import org.eclipse.rse.services.clientserver.messages.SystemMessage; -import org.eclipse.rse.ui.validators.ISystemValidator; -import org.eclipse.rse.ui.validators.ValidatorUniqueString; - -/** - * This class is used to verify a user defined action's name. - */ -public class ValidatorUserActionName extends ValidatorUniqueString implements ISystemValidator { - public static final int MAX_UDANAME_LENGTH = 256; // max name for an action - - protected boolean fUnique; - protected SystemMessage msg_Invalid; - protected IWorkspace workspace = ResourcesPlugin.getWorkspace(); - - /** - * Use this constructor when the name must be unique. - * @param existingNameList a collection of existing names to compare against. - * The collection will not be modified by the validator. - */ - public ValidatorUserActionName(Collection existingNameList) { - super(existingNameList, CASE_SENSITIVE); // case sensitive uniqueness - init(); - } - - /** - * Use this constructor when the name must be unique. Give the - * ctor a string array of existing names to compare against. - */ - public ValidatorUserActionName(String existingNameList[]) { - super(existingNameList, CASE_SENSITIVE); // case sensitive uniqueness - init(); - } - - /** - * Use this constructor when the name need not be unique, and you just want - * the syntax checking. - */ - public ValidatorUserActionName() { - super(new String[0], CASE_SENSITIVE); - init(); - } - - private void init() { - String msg1Txt = UserActionsResources.MSG_VALIDATE_UDANAME_EMPTY; - String msg1Details = UserActionsResources.MSG_VALIDATE_UDANAME_EMPTY_DETAILS; - - SystemMessage msg1 = new SimpleSystemMessage(Activator.PLUGIN_ID, - IUserActionsMessageIds.MSG_VALIDATE_UDANAME_EMPTY, - IStatus.ERROR, msg1Txt, msg1Details); - - String msg2Txt = UserActionsResources.MSG_VALIDATE_UDANAME_NOTUNIQUE; - String msg2Details = UserActionsResources.MSG_VALIDATE_UDANAME_NOTUNIQUE_DETAILS; - - SystemMessage msg2 = new SimpleSystemMessage(Activator.PLUGIN_ID, - IUserActionsMessageIds.MSG_VALIDATE_UDANAME_NOTUNIQUE, - IStatus.ERROR, msg2Txt, msg2Details); - - - super.setErrorMessages(msg1, msg2); - fUnique = true; - - String msg3Txt = UserActionsResources.MSG_VALIDATE_UDANAME_NOTVALID; - String msg3Details = UserActionsResources.MSG_VALIDATE_UDANAME_NOTVALID_DETAILS; - - SystemMessage msg3 = new SimpleSystemMessage(Activator.PLUGIN_ID, - IUserActionsMessageIds.MSG_VALIDATE_UDANAME_NOTVALID, - IStatus.ERROR, msg3Txt, msg3Details); - msg_Invalid = msg3; - } - - /** - * Supply your own error message text. By default, messages from RSEUIPlugin resource bundle are used. - * @param msg_Empty error message when entry field is empty - * @param msg_NonUnique error message when value entered is not unique - * @param msg_Invalid error message when syntax is not valid - */ - public void setErrorMessages(SystemMessage msg_Empty, SystemMessage msg_NonUnique, SystemMessage msg_Invalid) { - super.setErrorMessages(msg_Empty, msg_NonUnique); - this.msg_Invalid = msg_Invalid; - } - - /** - * Overridable method for invalidate character check, beyond what this class offers - * @return true if valid, false if not - */ - protected boolean checkForBadCharacters(String newText) { - return ((newText.indexOf('&') == -1) && // causes problems in menu popup as its a mnemonic character - (newText.indexOf('@') == -1)); // defect 43950 - } - - public String toString() { - return "UserActionNameValidator class"; //$NON-NLS-1$ - } - - // --------------------------- - // Parent Overrides... - // --------------------------- - /** - * Validate each character. - * Override of parent method. - * Override yourself to refine the error checking. - */ - public SystemMessage isSyntaxOk(String newText) { - if (newText.length() > getMaximumNameLength()) - currentMessage = msg_Invalid; - else - currentMessage = checkForBadCharacters(newText) ? null : msg_Invalid; - return currentMessage; - } - - // --------------------------- - // ISystemValidator methods... - // --------------------------- - - /** - * Return the max length for folder names: 256 - */ - public int getMaximumNameLength() { - return MAX_UDANAME_LENGTH; - } - -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/validators/ValidatorUserTypeName.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/validators/ValidatorUserTypeName.java deleted file mode 100644 index 2968df96d..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/validators/ValidatorUserTypeName.java +++ /dev/null @@ -1,123 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * David Dykstal (IBM) - [186589] move user types, user actions, and compile commands - * API to the user actions plugin - * David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared - *******************************************************************************/ - -package org.eclipse.rse.internal.useractions.ui.validators; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.rse.internal.useractions.Activator; -import org.eclipse.rse.internal.useractions.IUserActionsMessageIds; -import org.eclipse.rse.internal.useractions.UserActionsResources; -import org.eclipse.rse.services.clientserver.messages.SimpleSystemMessage; -import org.eclipse.rse.services.clientserver.messages.SystemMessage; -import org.eclipse.rse.ui.validators.ISystemValidator; -import org.eclipse.rse.ui.validators.ValidatorUniqueString; - -/** - * This class is used to verify a user defined type's name. - */ -public class ValidatorUserTypeName extends ValidatorUniqueString implements ISystemValidator { - public static final int MAX_UDTNAME_LENGTH = 50; // max name for a file type - - protected SystemMessage msg_Invalid; - - /** - * Use this constructor when the name need not be unique, and you just want the syntax checking. - */ - public ValidatorUserTypeName() { - super(new String[0], CASE_INSENSITIVE); - init(); - } - - private void init() { - String msg1Txt = UserActionsResources.MSG_VALIDATE_UDTNAME_EMPTY; - String msg1Details = UserActionsResources.MSG_VALIDATE_UDTNAME_EMPTY_DETAILS; - - SystemMessage msg1 = new SimpleSystemMessage(Activator.PLUGIN_ID, - IUserActionsMessageIds.MSG_VALIDATE_UDTNAME_EMPTY, - IStatus.ERROR, msg1Txt, msg1Details); - - String msg2Txt = UserActionsResources.MSG_VALIDATE_UDTNAME_NOTUNIQUE; - String msg2Details = UserActionsResources.MSG_VALIDATE_UDTNAME_NOTUNIQUE_DETAILS; - - SystemMessage msg2 = new SimpleSystemMessage(Activator.PLUGIN_ID, - IUserActionsMessageIds.MSG_VALIDATE_UDTNAME_NOTUNIQUE, - IStatus.ERROR, msg2Txt, msg2Details); - - super.setErrorMessages(msg1, msg2); - - String msg3Txt = UserActionsResources.MSG_VALIDATE_UDTNAME_NOTVALID; - String msg3Details = UserActionsResources.MSG_VALIDATE_UDTNAME_NOTVALID_DETAILS; - - SystemMessage msg3 = new SimpleSystemMessage(Activator.PLUGIN_ID, - IUserActionsMessageIds.MSG_VALIDATE_UDTNAME_NOTVALID, - IStatus.ERROR, msg3Txt, msg3Details); - msg_Invalid = msg3; - } - - /** - * Supply your own error message text. By default, messages from RSEUIPlugin resource bundle are used. - * @param msg_Empty error message when entry field is empty - * @param msg_NonUnique error message when value entered is not unique - * @param msg_Invalid error message when syntax is not valid - */ - public void setErrorMessages(SystemMessage msg_Empty, SystemMessage msg_NonUnique, SystemMessage msg_Invalid) { - super.setErrorMessages(msg_Empty, msg_NonUnique); - this.msg_Invalid = msg_Invalid; - } - - /** - * Overridable method for invalidate character check, beyond what this class offers - * @return true if valid, false if not - */ - protected boolean checkForBadCharacters(String newText) { - return true; - } - - public String toString() { - return "UserTypeNameValidator class"; //$NON-NLS-1$ - } - - // --------------------------- - // Parent Overrides... - // --------------------------- - /** - * Validate each character. - * Override of parent method. - * Override yourself to refine the error checking. - */ - public SystemMessage isSyntaxOk(String newText) { - if (newText.length() > getMaximumNameLength()) - currentMessage = msg_Invalid; - else - currentMessage = checkForBadCharacters(newText) ? null : msg_Invalid; - return currentMessage; - } - - // --------------------------- - // ISystemValidator methods... - // --------------------------- - - /** - * Return the max length for folder names: 50 - */ - public int getMaximumNameLength() { - return MAX_UDTNAME_LENGTH; - } - -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/validators/ValidatorUserTypeTypes.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/validators/ValidatorUserTypeTypes.java deleted file mode 100644 index 1e38769d4..000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/validators/ValidatorUserTypeTypes.java +++ /dev/null @@ -1,127 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2008 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 - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * David Dykstal (IBM) - [186589] move user types, user actions, and compile commands - * API to the user actions plugin - * David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared - *******************************************************************************/ - -package org.eclipse.rse.internal.useractions.ui.validators; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.rse.internal.useractions.Activator; -import org.eclipse.rse.internal.useractions.IUserActionsMessageIds; -import org.eclipse.rse.internal.useractions.UserActionsResources; -import org.eclipse.rse.services.clientserver.messages.SimpleSystemMessage; -import org.eclipse.rse.services.clientserver.messages.SystemMessage; -import org.eclipse.rse.ui.validators.ISystemValidator; - -/** - * This class is used to verify a user defined action's comment - */ -public class ValidatorUserTypeTypes implements ISystemValidator { - public static final int MAX_UDTTYPES_LENGTH = 512; - - protected SystemMessage emptyMsg, invalidMsg, currentMessage; - - /** - * Constructor to use when wanting to specify the "value required" error message, - * but use the default for the "Value not valid" error message - */ - public ValidatorUserTypeTypes() { - String msg1Txt = UserActionsResources.MSG_VALIDATE_UDTTYPES_EMPTY; - String msg1Details = UserActionsResources.MSG_VALIDATE_UDTTYPES_EMPTY_DETAILS; - - SystemMessage msg1 = new SimpleSystemMessage(Activator.PLUGIN_ID, - IUserActionsMessageIds.MSG_VALIDATE_UDTTYPES_EMPTY, - IStatus.ERROR, msg1Txt, msg1Details); - - String msg2Txt = UserActionsResources.MSG_VALIDATE_UDTTYPES_NOTVALID; - String msg2Details = UserActionsResources.MSG_VALIDATE_UDTTYPES_NOTVALID_DETAILS; - - SystemMessage msg2 = new SimpleSystemMessage(Activator.PLUGIN_ID, - IUserActionsMessageIds.MSG_VALIDATE_UDTTYPES_NOTVALID, - IStatus.ERROR, msg2Txt, msg2Details); - - - setErrorMessages(msg1, msg2); - } - - /** - * Set the error messages, overriding the defaults - */ - public void setErrorMessages(SystemMessage emptyMsg, SystemMessage invalidMsg) { - this.emptyMsg = emptyMsg; - this.invalidMsg = invalidMsg; - } - - // --------------------------- - // ISystemValidator methods... - // --------------------------- - - /** - * @see org.eclipse.jface.viewers.ICellEditorValidator#isValid(java.lang.Object) - */ - public String isValid(Object input) { - currentMessage = null; - if (!(input instanceof String)) { - return null; - } else - return isValid((String) input); - } - - /** - * @see org.eclipse.jface.dialogs.IInputValidator#isValid(java.lang.String) - * @see #getSystemMessage() - */ - public String isValid(String input) { - currentMessage = null; - if ((input == null) || (input.length() == 0)) { - currentMessage = emptyMsg; - } else { - if (input.length() > MAX_UDTTYPES_LENGTH) currentMessage = invalidMsg; - } - return (currentMessage == null) ? null : currentMessage.getLevelOneText(); - } - - /** - * When isValid returns non-null, call this to get the SystemMessage object for the error - * versus the simple string message. - */ - public SystemMessage getSystemMessage() { - return currentMessage; - } - - /** - * Return the max length for comments - */ - public int getMaximumNameLength() { - return MAX_UDTTYPES_LENGTH; - } - - /** - * For convenience, this is a shortcut to calling: - * <pre><code> - * if (isValid(text) != null) - * msg = getSystemMessage(); - * </code></pre> - */ - public SystemMessage validate(String text) { - if (isValid(text) != null) - return currentMessage; - else - return null; - } - -} |