2006-05-30 15:32:53 +00:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
< html >
< head >
< META HTTP-EQUIV = "Content-Type" CONTENT = "text/html; charset=UTF-8" >
< META HTTP-EQUIV = "Content-Style-Type" CONTENT = "text/css" >
< meta name = "copyright" content = "Copyright (c) IBM Corporation and others 2002, 2006. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." >
< LINK REL = "STYLESHEET" HREF = "../../book.css" TYPE = "text/css" >
< title > TeamResourceAdapter Class After Editing< / title >
< / head >
2006-08-04 20:37:05 +00:00
< body >
2006-05-30 15:32:53 +00:00
< h1 > TeamResourceAdapter Class After Editing< / h1 >
< pre > < samp >
package samples.model;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.IStructuredSelection;
2006-08-04 20:37:05 +00:00
import org.eclipse.rse.ui.SystemMenuManager;
import org.eclipse.rse.ui.view.AbstractSystemViewAdapter;
import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
2006-05-30 15:32:53 +00:00
import org.eclipse.swt.widgets.Shell;
2006-08-04 20:37:05 +00:00
import org.eclipse.ui.views.properties.IPropertyDescriptor;
2006-05-30 15:32:53 +00:00
2006-08-04 20:37:05 +00:00
< strong > import samples.RSESamplesPlugin;< / strong >
< strong > import samples.subsystems.DeveloperSubSystem;< / strong >
2006-05-30 15:32:53 +00:00
/**
2006-08-04 20:37:05 +00:00
* This is the adapter which enables us to work with our remote team resources.
2006-05-30 15:32:53 +00:00
*/
2006-08-04 20:37:05 +00:00
public class TeamResourceAdapter extends AbstractSystemViewAdapter implements
ISystemRemoteElementAdapter {
2006-05-30 15:32:53 +00:00
/**
2006-08-04 20:37:05 +00:00
* Constructor.
*/
public TeamResourceAdapter() {
super();
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#addActions(org.eclipse.rse.ui.SystemMenuManager,
* org.eclipse.jface.viewers.IStructuredSelection, org.eclipse.swt.widgets.Shell, java.lang.String)
2006-05-30 15:32:53 +00:00
*/
2006-08-04 20:37:05 +00:00
public void addActions(SystemMenuManager menu,
IStructuredSelection selection, Shell parent, String menuGroup)
2006-05-30 15:32:53 +00:00
{
}
2006-08-04 20:37:05 +00:00
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#getImageDescriptor(java.lang.Object)
2006-05-30 15:32:53 +00:00
*/
2006-08-04 20:37:05 +00:00
public ImageDescriptor getImageDescriptor(Object element)
2006-05-30 15:32:53 +00:00
{
2006-08-04 20:37:05 +00:00
< strong > return RSESamplesPlugin.getDefault().getImageDescriptor("ICON_ID_TEAM");< / strong >
2006-05-30 15:32:53 +00:00
}
2006-08-04 20:37:05 +00:00
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#getText(java.lang.Object)
2006-05-30 15:32:53 +00:00
*/
public String getText(Object element)
{
2006-08-04 20:37:05 +00:00
< strong > return ((TeamResource)element).getName();< / strong >
2006-05-30 15:32:53 +00:00
}
2006-08-04 20:37:05 +00:00
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#getAbsoluteName(java.lang.Object)
2006-05-30 15:32:53 +00:00
*/
2006-08-04 20:37:05 +00:00
< a id = "getAbsoluteName" / > public String getAbsoluteName(Object object)
2006-05-30 15:32:53 +00:00
{
2006-08-04 20:37:05 +00:00
< strong > TeamResource team = (TeamResource)object;
return "Team_"+team.getName();< / strong >
2006-05-30 15:32:53 +00:00
}
2006-08-04 20:37:05 +00:00
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#getType(java.lang.Object)
2006-05-30 15:32:53 +00:00
*/
public String getType(Object element)
{
2006-08-04 20:37:05 +00:00
< strong > return RSESamplesPlugin.getResourceString("property.team_resource.type");< / strong >
2006-05-30 15:32:53 +00:00
}
2006-08-04 20:37:05 +00:00
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#getParent(java.lang.Object)
2006-05-30 15:32:53 +00:00
*/
2006-08-04 20:37:05 +00:00
public Object getParent(Object element)
2006-05-30 15:32:53 +00:00
{
return null; // not really used, which is good because it is ambiguous
}
2006-08-04 20:37:05 +00:00
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#hasChildren(java.lang.Object)
2006-05-30 15:32:53 +00:00
*/
public boolean hasChildren(Object element)
{
2006-08-04 20:37:05 +00:00
< strong > return true;< / strong >
2006-05-30 15:32:53 +00:00
}
2006-08-04 20:37:05 +00:00
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#getChildren(java.lang.Object)
2006-05-30 15:32:53 +00:00
*/
2006-08-04 20:37:05 +00:00
public Object[] getChildren(Object element)
2006-05-30 15:32:53 +00:00
{
2006-08-04 20:37:05 +00:00
< strong > return ((TeamResource)element).getDevelopers();< / strong >
2006-05-30 15:32:53 +00:00
}
/**
2006-08-04 20:37:05 +00:00
* @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#internalGetPropertyDescriptors()
2006-05-30 15:32:53 +00:00
*/
protected IPropertyDescriptor[] internalGetPropertyDescriptors()
{
return null;
}
2006-08-04 20:37:05 +00:00
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#internalGetPropertyValue(java.lang.Object)
2006-05-30 15:32:53 +00:00
*/
2006-08-04 20:37:05 +00:00
protected Object internalGetPropertyValue(Object key)
2006-05-30 15:32:53 +00:00
{
return null;
2006-08-04 20:37:05 +00:00
}
/**
2006-05-30 15:32:53 +00:00
* Intercept of parent method to indicate these objects can be renamed using the RSE-supplied
* rename action.
*/
2006-08-04 20:37:05 +00:00
< a id = "canRename" / > public boolean canRename(Object element)
2006-05-30 15:32:53 +00:00
{
2006-08-04 20:37:05 +00:00
< strong > return true;< / strong >
2006-05-30 15:32:53 +00:00
}
/**
* Intercept of parent method to actually do the rename. RSE supplies the rename GUI, but
* defers the action work of renaming to this adapter method.
*/
2006-08-04 20:37:05 +00:00
< a id = "doRename" / > public boolean doRename(Shell shell, Object element, String newName)
2006-05-30 15:32:53 +00:00
{
2006-08-04 20:37:05 +00:00
< strong > ((TeamResource)element).setName(newName);
return true;< / strong >
}
2006-05-30 15:32:53 +00:00
// --------------------------------------
// ISystemRemoteElementAdapter methods...
// --------------------------------------
2006-08-04 20:37:05 +00:00
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getAbsoluteParentName(java.lang.Object)
2006-05-30 15:32:53 +00:00
*/
public String getAbsoluteParentName(Object element)
{
2006-08-04 20:37:05 +00:00
< strong > return "root";< / strong > // not really applicable as we have no unique hierarchy
2006-05-30 15:32:53 +00:00
}
2006-08-04 20:37:05 +00:00
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getSubSystemConfigurationId(java.lang.Object)
2006-05-30 15:32:53 +00:00
*/
2006-08-04 20:37:05 +00:00
public String getSubSystemConfigurationId(Object element)
2006-05-30 15:32:53 +00:00
{
2006-08-04 20:37:05 +00:00
< strong > return "samples.subsystems.factory";< / strong > // as declared in extension in plugin.xml
2006-05-30 15:32:53 +00:00
}
2006-08-04 20:37:05 +00:00
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getRemoteTypeCategory(java.lang.Object)
2006-05-30 15:32:53 +00:00
*/
public String getRemoteTypeCategory(Object element)
{
2006-08-04 20:37:05 +00:00
< strong > return "developers";< / strong > // Course grained. Same for all our remote resources.
2006-05-30 15:32:53 +00:00
}
2006-08-04 20:37:05 +00:00
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getRemoteType(java.lang.Object)
2006-05-30 15:32:53 +00:00
*/
public String getRemoteType(Object element)
{
2006-08-04 20:37:05 +00:00
< strong > return "team";< / strong > // Fine grained. Unique to this resource type.
2006-05-30 15:32:53 +00:00
}
2006-08-04 20:37:05 +00:00
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getRemoteSubType(java.lang.Object)
2006-05-30 15:32:53 +00:00
*/
public String getRemoteSubType(Object element)
{
return null; // Very fine grained. We don't use it.
}
2006-08-04 20:37:05 +00:00
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#refreshRemoteObject(java.lang.Object, java.lang.Object)
2006-05-30 15:32:53 +00:00
*/
2006-08-04 20:37:05 +00:00
< a id = "refreshRemoteObject" / > public boolean refreshRemoteObject(Object oldElement, Object newElement)
2006-05-30 15:32:53 +00:00
{
2006-08-04 20:37:05 +00:00
< strong > TeamResource oldTeam = (TeamResource)oldElement;
2006-05-30 15:32:53 +00:00
TeamResource newTeam = (TeamResource)newElement;
newTeam.setName(oldTeam.getName());
2006-08-04 20:37:05 +00:00
return false;< / strong > // If developer objects held references to their team names, we'd have to return true
2006-05-30 15:32:53 +00:00
}
2006-08-04 20:37:05 +00:00
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getRemoteParent(org.eclipse.swt.widgets.Shell, java.lang.Object)
2006-05-30 15:32:53 +00:00
*/
public Object getRemoteParent(Shell shell, Object element) throws Exception
{
return null; // maybe this would be a Project or Roster object, or leave as null if this is the root
}
2006-08-04 20:37:05 +00:00
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getRemoteParentNamesInUse(org.eclipse.swt.widgets.Shell, java.lang.Object)
2006-05-30 15:32:53 +00:00
*/
2006-08-04 20:37:05 +00:00
< a id = "getNames" / > public String[] getRemoteParentNamesInUse(Shell shell, Object element)
throws Exception
2006-05-30 15:32:53 +00:00
{
2006-08-04 20:37:05 +00:00
< strong > DeveloperSubSystem ourSS = (DeveloperSubSystem)getSubSystem(element);
2006-05-30 15:32:53 +00:00
TeamResource[] allTeams = ourSS.getAllTeams();
String[] allNames = new String[allTeams.length];
2006-08-04 20:37:05 +00:00
for (int idx = 0; idx < allTeams.length; idx++)
2006-05-30 15:32:53 +00:00
allNames[idx] = allTeams[idx].getName();
2006-08-04 20:37:05 +00:00
return allNames;< / strong > // Return list of all team names
2006-05-30 15:32:53 +00:00
}
2006-08-04 20:37:05 +00:00
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#supportsUserDefinedActions(java.lang.Object)
*/
public boolean supportsUserDefinedActions(Object object) {
< strong > return false;< / strong >
}
}
2006-05-30 15:32:53 +00:00
< / samp > < / pre >
< / body >
< / html >