diff options
Diffstat (limited to 'rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda')
47 files changed, 0 insertions, 11106 deletions
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; - } -} |