Remote Systems
v6.4.1

com.ibm.etools.systems.core.ui.uda
Class SystemUDBaseManager

java.lang.Object
  extended bycom.ibm.etools.systems.core.ui.uda.SystemUDBaseManager
All Implemented Interfaces:
ErrorHandler, ISystemUDAConstants, ISystemXMLElementWrapperFactory
Direct Known Subclasses:
SystemUDActionManager, SystemUDTypeManager

public abstract class SystemUDBaseManager
extends Object
implements ErrorHandler, ISystemXMLElementWrapperFactory, ISystemUDAConstants

Instances of this class hold the UDA definitions unique to

  1. The SystemProfile - according to the subsystem
  2. the SubSystem type - according to the SubSystemFactory
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.

When used for IMPORT: NO SubSystem instance available. Will be NULL!

This is the base class for both action managers and types managers. Only action managers are actually scoped by profile.

Architecturally, this class and the SystemXMLElementWrapper class encapsulate all knowledge of the fact the underlying store is a xml document.


Field Summary
protected  SystemUDActionSubsystem _udas
           
static String copyright
           
protected static Object[] EMPTY_ARRAY
           
protected  IFolder importCaseFolder
           
 
Fields inherited from interface com.ibm.etools.systems.core.ui.uda.ISystemXMLElementWrapperFactory
Copyright
 
Fields inherited from interface com.ibm.etools.systems.core.ui.uda.ISystemUDAConstants
NAME_ATTR, ORIGINAL_NAME_ATTR, RELEASE_ATTR, XE_DOMAIN, XE_DOMNAME, XE_DOMTYPE
 
Constructor Summary
SystemUDBaseManager(SystemUDActionSubsystem udas)
          Constructor
 
Method Summary
 SystemXMLElementWrapper addElement(SystemProfile profile, int domain, String name)
          Add a new user action or type.
protected  Document createAndPrimeDocument(SystemProfile profile)
          Create and prime the XML document
protected  Element createDomainElement(Document xdoc, int domain)
          Create a new xml domain element.
protected  SystemXMLElementWrapper createDomainElementWrapper(Element xmlDomainElementToWrap, SystemProfile profile, int domain)
          Create a domain element wrapper
abstract  SystemXMLElementWrapper createElementWrapper(Element xmlElementToWrap, SystemProfile profile, int domain)
          Given an xml element node, create an instance of the appropriate subclass of SystemXMLElementWrapper to represent it.
protected  Vector createExistingDomainElementWrappers(Vector v, SystemProfile profile)
          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.
protected  void dataChanged(SystemProfile profile)
          Indicate data has changed for the given profile
 void delete(SystemProfile profile, SystemXMLElementWrapper elementWrapper)
          Delete a give user action or type, given its wrapper.
 void dispose()
           
static boolean domainTypeEquals(Element element, String domainName)
          Given an xml Domain element, return true if it's "type" attribute matches the given untranslated domain name
protected abstract  boolean doMigration(SystemProfile profile, String oldRelease)
          Overridable extension point for child classes to do migration of their document.
 boolean enablePaste(SystemXMLElementWrapper selectedElementWrapper, String id)
          Test if the given ID, read from the clipboard, matches a node we prepared for the clipboard.
 void error(SAXParseException ex)
          Error.
 void fatalError(SAXParseException ex)
          Fatal error.
 SystemXMLElementWrapper findByName(SystemProfile profile, String name, int domain)
          Find a child element of a given name.
 Element findChildByName(SystemProfile profile, String name, int domain)
          Find a child element of a given name.
protected  Element findDomainElement(Document xdoc, int domain)
          Given an xml action/type document, try to find a domain element ("Domain" tag) of the given domain type.
protected  Element findOrCreateDomainElement(Document xdoc, int domain)
          Given an xml action/type document, try to find a domain element ("Domain" tag) of the given untranslated name ("Type" attribute).
protected  Element findOrCreateDomainElement(Document xdoc, int domain, boolean create)
          Given an xml action/type document, try to find a domain element ("Domain" tag) of the given untranslated name ("Type" attribute).
 SystemUDActionSubsystem getActionSubSystem()
          Return the action subsystem object
protected  IWorkbenchAdapter getAdapter(Object o)
          Returns the implementation of IWorkbenchAdapter for the given object.
 Object[] getChildren(Object element)
          Return all the user actions/types under the given node.
 SystemProfile getCurrentProfile()
          Get the profile we are currently working with, as set by a call to setCurrentProfile
 Document getDocument(SystemProfile profile)
          Load document for given SystemProfile only if not already done.
protected abstract  IFolder getDocumentFolder(SubSystemFactory subsystemFactory, SystemProfile profile)
          Get the folder containing the xml file used to persist the actions, for the given profile
 String getDocumentRelease(SystemProfile profile)
          Get the release of the document.
abstract  String getDocumentRootTagName()
          Get the document root tag name.
protected  SystemXMLElementWrapper getDomainWrapper(SystemProfile profile, int domain)
          Given a domain's integer representation, find its element in xml document and return the wrapper for it.
 Object[] getElements(Object element)
          Method declared on IStructuredContentProvider.
 Object[] getElements(SystemProfile[] profiles, Object input)
          Return the root elements.
 Object[] getElements(SystemProfile profile, Object element)
          Return root elements for given profile.
 Vector getExistingNames(SystemProfile profile, int domain)
          Get a list of existing names, for unique-name checking.
abstract  String getFileName()
          Return name of the xml file used to persist the actions
protected  String getFilePath(SystemProfile profile)
          Get the path of the XML document containing the user actions, for the given profile (and current subsystem)
 Image getNewImage()
          Get the icon to show in the tree views, for the "new" expandable item
protected  String getNewNodeLabel()
          Overridable method for returning the label for the "New" nodes in the tree view.
 Object getParent(Object element)
          Method declared on ITreeContentProvider.
protected  SubSystem getSubSystem()
          Get the current subsystem.
protected  SubSystemFactory getSubSystemFactory()
          Get the current subsystem.
abstract  String getTagName()
          Return the tag name for our managed elements.
 Vector getXMLWrappers(Vector children, int domain, SystemProfile profile)
          Retrieve the action/type tags for the given profile and domain, wrapped in appropriate xml wrapper objects
 Vector getXMLWrappers(Vector children, Object parentOrDomain, SystemProfile profile)
          Retrieve the action/type tags for the given profile and domain, wrapped in appropriate xml wrapper objects
 boolean hasChildren(Object element)
          Method declared on ITreeContentProvider.
static boolean inCurrentTree(Node n)
          Checking not deleted.
 Document initializeDocument()
          Initialize a new document
 void inputChanged(Viewer viewer, Object oldInput, Object newInput)
          Method declared on IContentProvider.
static boolean isDomainElement(Element element)
          Given an xml Element object, return true if it is a Domain element.
static boolean isDomainElement(Element element, String domainName)
          Given an xml Element object, return true if it is a Domain element and its "Type" attribute matches the given name.
protected abstract  boolean isUserActionsManager()
          Return true if this is user actions, false if this is named types.
protected  Document loadAndParseXMLFile(String fileName, SystemProfile profile)
          loadAndParseXMLFile: tries to load and parse the specified XML file.
protected  Document loadUserData(SystemProfile profile)
          Load the user actions from the XML document, for the given profile
 boolean moveElementDown(SystemXMLElementWrapper elementWrapper, SystemXMLElementWrapper nextNextElementWrapper)
          Move given element down one in document, save document
 boolean moveElementUp(SystemXMLElementWrapper elementWrapper, SystemXMLElementWrapper previousElementWrapper)
          Move given element up one in document, save document
 SystemXMLElementWrapper pasteClipboardCopy(SystemXMLElementWrapper selectedElementWrapper, String id)
          After a successful call to enablePaste, this is called to do the paste operation.
 String prepareClipboardCopy(SystemXMLElementWrapper elementWrapper)
          Prepares a given element for the clipboard.
 SystemXMLElementWrapper[] primeDocument(SystemProfile profile)
          Prime the given document with any default actions/types Should be overridden!
 void processResourceChangeHit(SystemProfile profile)
          Force a re-load
 void refreshLocal(SystemProfile profile)
          Refresh the xml file from disk.
 void resetUserData(SystemProfile profile)
          Reload the User data for the given profile, from disk if it has been changed in memory
 void resourceChanged(IResourceChangeEvent event)
          Interface org.eclipse.core.resources.
 void saveUserData(SystemProfile profile)
          Save user data for the given system profile
 void setChanged(SystemProfile profile)
          Indicate the data has changed for the document for the given system profile
 void setCurrentProfile(SystemProfile profile)
          Set the profile we are working with the actions for, until reset.
abstract  void setFolder(String profileName, String factoryId)
          Intended for IMPORT actions only, where no Subsystem instance available:
 boolean supportsProfiles()
          Return true if the elements managed by this class are scoped by profile.
protected abstract  boolean uppercaseName()
          Do we uppercase the value of the "Name" attribute?
 void warning(SAXParseException ex)
          Warning.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

copyright

public static final String copyright
See Also:
Constant Field Values

_udas

protected SystemUDActionSubsystem _udas

importCaseFolder

protected IFolder importCaseFolder

EMPTY_ARRAY

protected static final Object[] EMPTY_ARRAY
Constructor Detail

SystemUDBaseManager

public SystemUDBaseManager(SystemUDActionSubsystem udas)
Constructor

Method Detail

getActionSubSystem

public SystemUDActionSubsystem getActionSubSystem()
Return the action subsystem object


getNewImage

public Image getNewImage()
Get the icon to show in the tree views, for the "new" expandable item


getTagName

public abstract String getTagName()
Return the tag name for our managed elements. Eg: will be "Action" for user actions, and "Type" for file types.

Specified by:
getTagName in interface ISystemXMLElementWrapperFactory

createElementWrapper

public abstract SystemXMLElementWrapper createElementWrapper(Element xmlElementToWrap,
                                                             SystemProfile profile,
                                                             int domain)
Given an xml element node, create an instance of the appropriate subclass of SystemXMLElementWrapper to represent it.

Specified by:
createElementWrapper in interface ISystemXMLElementWrapperFactory

getAdapter

protected IWorkbenchAdapter getAdapter(Object o)
Returns the implementation of IWorkbenchAdapter for the given object. Returns null if the adapter is not defined or the object is not adaptable.


dispose

public void dispose()

getParent

public Object getParent(Object element)
Method declared on ITreeContentProvider. We return null.


hasChildren

public boolean hasChildren(Object element)
Method declared on ITreeContentProvider.


inputChanged

public void inputChanged(Viewer viewer,
                         Object oldInput,
                         Object newInput)
Method declared on IContentProvider. Callen when input changed. We do nothing.


getDocumentRootTagName

public abstract String getDocumentRootTagName()
Get the document root tag name. Will be "FileTypes" for types, and "Actions" for actions


uppercaseName

protected abstract boolean uppercaseName()
Do we uppercase the value of the "Name" attribute? Yes, we do for types, and No, we don't for actions


getXMLWrappers

public Vector getXMLWrappers(Vector children,
                             int domain,
                             SystemProfile profile)
Retrieve the action/type tags for the given profile and domain, wrapped in appropriate xml wrapper objects

Parameters:
domain - - the integer representation of the domain, or -1 iff domains not support
profile - - profile to determine the document to query. If profiles not supported, pass null.

getXMLWrappers

public Vector getXMLWrappers(Vector children,
                             Object parentOrDomain,
                             SystemProfile profile)
Retrieve the action/type tags for the given profile and domain, wrapped in appropriate xml wrapper objects

Parameters:
profile - - profile to determine the document to query. If profiles not supported, pass null.

supportsProfiles

public boolean supportsProfiles()
Return true if the elements managed by this class are scoped by profile. Usually true for actions, false for types


getFileName

public abstract String getFileName()
Return name of the xml file used to persist the actions


initializeDocument

public Document initializeDocument()
Initialize a new document


getSubSystem

protected SubSystem getSubSystem()
Get the current subsystem. Will be null for import, or working in team view when no subsystems exist yet for a particular subsystem factory.


getSubSystemFactory

protected SubSystemFactory getSubSystemFactory()
Get the current subsystem. Will be set in SystemProfileImpl's getUserActions method for cases when there are no subsystems created for a subsystemfactory yet.


getFilePath

protected String getFilePath(SystemProfile profile)
Get the path of the XML document containing the user actions, for the given profile (and current subsystem)


loadAndParseXMLFile

protected Document loadAndParseXMLFile(String fileName,
                                       SystemProfile profile)
loadAndParseXMLFile: tries to load and parse the specified XML file.


warning

public void warning(SAXParseException ex)
Warning.

Specified by:
warning in interface ErrorHandler

error

public void error(SAXParseException ex)
Error.

Specified by:
error in interface ErrorHandler

fatalError

public void fatalError(SAXParseException ex)
                throws SAXException
Fatal error.

Specified by:
fatalError in interface ErrorHandler
Throws:
SAXException

resourceChanged

public void resourceChanged(IResourceChangeEvent event)
Interface org.eclipse.core.resources. IResourceChangeListener


setCurrentProfile

public void setCurrentProfile(SystemProfile profile)
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.


getCurrentProfile

public SystemProfile getCurrentProfile()
Get the profile we are currently working with, as set by a call to setCurrentProfile


primeDocument

public SystemXMLElementWrapper[] primeDocument(SystemProfile profile)
Prime the given document with any default actions/types Should be overridden!


getDocumentRelease

public String getDocumentRelease(SystemProfile profile)
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"


getDocument

public Document getDocument(SystemProfile profile)
Load document for given SystemProfile only if not already done.


doMigration

protected abstract boolean doMigration(SystemProfile profile,
                                       String oldRelease)
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

Returns:
true if any migration was done

setChanged

public void setChanged(SystemProfile profile)
Indicate the data has changed for the document for the given system profile


resetUserData

public void resetUserData(SystemProfile profile)
Reload the User data for the given profile, from disk if it has been changed in memory


processResourceChangeHit

public void processResourceChangeHit(SystemProfile profile)
Force a re-load


getDocumentFolder

protected abstract IFolder getDocumentFolder(SubSystemFactory subsystemFactory,
                                             SystemProfile profile)
Get the folder containing the xml file used to persist the actions, for the given profile


setFolder

public abstract void setFolder(String profileName,
                               String factoryId)
Intended for IMPORT actions only, where no Subsystem instance available:


dataChanged

protected void dataChanged(SystemProfile profile)
Indicate data has changed for the given profile


loadUserData

protected Document loadUserData(SystemProfile profile)
Load the user actions from the XML document, for the given profile


createAndPrimeDocument

protected Document createAndPrimeDocument(SystemProfile profile)
Create and prime the XML document


saveUserData

public void saveUserData(SystemProfile profile)
Save user data for the given system profile


refreshLocal

public void refreshLocal(SystemProfile profile)
Refresh the xml file from disk. Eg equivalent to use selecting Refresh.


moveElementDown

public boolean moveElementDown(SystemXMLElementWrapper elementWrapper,
                               SystemXMLElementWrapper nextNextElementWrapper)
Move given element down one in document, save document

Returns:
true if move successful

moveElementUp

public boolean moveElementUp(SystemXMLElementWrapper elementWrapper,
                             SystemXMLElementWrapper previousElementWrapper)
Move given element up one in document, save document

Returns:
true if move successful

prepareClipboardCopy

public String prepareClipboardCopy(SystemXMLElementWrapper elementWrapper)
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.

Returns:
an id that uniquely identifies the cloned node, or null if it failed.

enablePaste

public boolean enablePaste(SystemXMLElementWrapper selectedElementWrapper,
                           String id)
Test if the given ID, read from the clipboard, matches a node we prepared for the clipboard. It also ensure that domains match.

This decides if the paste action will be enabled or not


pasteClipboardCopy

public SystemXMLElementWrapper pasteClipboardCopy(SystemXMLElementWrapper selectedElementWrapper,
                                                  String id)
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

Returns:
SystemXMLElementWrapper wrapper object of pasted element, or null if it failed

getElements

public Object[] getElements(Object element)
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


getElements

public Object[] getElements(SystemProfile profile,
                            Object element)
Return root elements for given profile.


getElements

public Object[] getElements(SystemProfile[] profiles,
                            Object input)
Return the root elements.

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


getNewNodeLabel

protected String getNewNodeLabel()
Overridable method for returning the label for the "New" nodes in the tree view. Will usually be different for actions versus types.

Returns:
translated value for "New" in new icon. Default is "New"

isUserActionsManager

protected abstract boolean isUserActionsManager()
Return true if this is user actions, false if this is named types.


getChildren

public Object[] getChildren(Object element)
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.


findChildByName

public Element findChildByName(SystemProfile profile,
                               String name,
                               int domain)
Find a child element of a given name. Returns the xml node element or null


findByName

public SystemXMLElementWrapper findByName(SystemProfile profile,
                                          String name,
                                          int domain)
Find a child element of a given name. Returns the wrapper of the xml node element or null


getExistingNames

public Vector getExistingNames(SystemProfile profile,
                               int domain)
Get a list of existing names, for unique-name checking.


addElement

public SystemXMLElementWrapper addElement(SystemProfile profile,
                                          int domain,
                                          String name)
Add a new user action or type. Creates the new XML node in the document, and creates and returns a wrapper object for it.


delete

public void delete(SystemProfile profile,
                   SystemXMLElementWrapper elementWrapper)
Delete a give user action or type, given its wrapper. Deletes the xml node from the document.


getDomainWrapper

protected SystemXMLElementWrapper getDomainWrapper(SystemProfile profile,
                                                   int domain)
Given a domain's integer representation, find its element in xml document and return the wrapper for it. If not found, returns null


createExistingDomainElementWrappers

protected Vector createExistingDomainElementWrappers(Vector v,
                                                     SystemProfile profile)
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.

It is important to note these are returned in the pre-determined order, not the order they are found in the document!


createDomainElementWrapper

protected SystemXMLElementWrapper createDomainElementWrapper(Element xmlDomainElementToWrap,
                                                             SystemProfile profile,
                                                             int domain)
Create a domain element wrapper


findDomainElement

protected Element findDomainElement(Document xdoc,
                                    int 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.


findOrCreateDomainElement

protected Element findOrCreateDomainElement(Document xdoc,
                                            int domain)
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.


findOrCreateDomainElement

protected Element findOrCreateDomainElement(Document xdoc,
                                            int domain,
                                            boolean create)
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.


createDomainElement

protected Element createDomainElement(Document xdoc,
                                      int domain)
Create a new xml domain element. That, an element of tag name "Domain".

Parameters:
xdoc - - the document to add it to. Will be added as child of root

isDomainElement

public static boolean isDomainElement(Element element)
Given an xml Element object, return true if it is a Domain element. That is, if its tag name is "Domain"


isDomainElement

public static boolean isDomainElement(Element element,
                                      String domainName)
Given an xml Element object, return true if it is a Domain element and its "Type" attribute matches the given name.


domainTypeEquals

public static boolean domainTypeEquals(Element element,
                                       String domainName)
Given an xml Domain element, return true if it's "type" attribute matches the given untranslated domain name


inCurrentTree

public static boolean inCurrentTree(Node n)
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.


Remote Systems
v6.4.1

Copyright © 2005 IBM Corp. All Rights Reserved.

Note: This documentation is for part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.