mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
228 lines
7.4 KiB
HTML
Executable file
228 lines
7.4 KiB
HTML
Executable file
<!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>
|
|
|
|
<body>
|
|
<h1>TeamResourceAdapter Class After Editing</h1>
|
|
<pre><samp>
|
|
package samples.model;
|
|
|
|
import org.eclipse.jface.resource.ImageDescriptor;
|
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
|
import org.eclipse.rse.ui.SystemMenuManager;
|
|
import org.eclipse.rse.ui.view.AbstractSystemViewAdapter;
|
|
import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
|
|
import org.eclipse.swt.widgets.Shell;
|
|
import org.eclipse.ui.views.properties.IPropertyDescriptor;
|
|
|
|
<strong>import samples.RSESamplesPlugin;</strong>
|
|
<strong>import samples.subsystems.DeveloperSubSystem;</strong>
|
|
|
|
/**
|
|
* This is the adapter which enables us to work with our remote team resources.
|
|
*/
|
|
public class TeamResourceAdapter extends AbstractSystemViewAdapter implements
|
|
ISystemRemoteElementAdapter {
|
|
|
|
/**
|
|
* 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)
|
|
*/
|
|
public void addActions(SystemMenuManager menu,
|
|
IStructuredSelection selection, Shell parent, String menuGroup)
|
|
{
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#getImageDescriptor(java.lang.Object)
|
|
*/
|
|
public ImageDescriptor getImageDescriptor(Object element)
|
|
{
|
|
<strong>return RSESamplesPlugin.getDefault().getImageDescriptor("ICON_ID_TEAM");</strong>
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#getText(java.lang.Object)
|
|
*/
|
|
public String getText(Object element)
|
|
{
|
|
<strong>return ((TeamResource)element).getName();</strong>
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#getAbsoluteName(java.lang.Object)
|
|
*/
|
|
<a id="getAbsoluteName"></a>public String getAbsoluteName(Object object)
|
|
{
|
|
<strong>TeamResource team = (TeamResource)object;
|
|
return "Team_"+team.getName();</strong>
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#getType(java.lang.Object)
|
|
*/
|
|
public String getType(Object element)
|
|
{
|
|
<strong>return RSESamplesPlugin.getResourceString("property.team_resource.type");</strong>
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#getParent(java.lang.Object)
|
|
*/
|
|
public Object getParent(Object element)
|
|
{
|
|
return null; // not really used, which is good because it is ambiguous
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#hasChildren(java.lang.Object)
|
|
*/
|
|
public boolean hasChildren(Object element)
|
|
{
|
|
<strong>return true;</strong>
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#getChildren(java.lang.Object)
|
|
*/
|
|
public Object[] getChildren(Object element)
|
|
{
|
|
<strong>return ((TeamResource)element).getDevelopers();</strong>
|
|
}
|
|
|
|
/**
|
|
* @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#internalGetPropertyDescriptors()
|
|
*/
|
|
protected IPropertyDescriptor[] internalGetPropertyDescriptors()
|
|
{
|
|
return null;
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#internalGetPropertyValue(java.lang.Object)
|
|
*/
|
|
protected Object internalGetPropertyValue(Object key)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* Intercept of parent method to indicate these objects can be renamed using the RSE-supplied
|
|
* rename action.
|
|
*/
|
|
<a id="canRename"></a>public boolean canRename(Object element)
|
|
{
|
|
<strong>return true;</strong>
|
|
}
|
|
|
|
/**
|
|
* 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.
|
|
*/
|
|
<a id="doRename"></a>public boolean doRename(Shell shell, Object element, String newName)
|
|
{
|
|
<strong>((TeamResource)element).setName(newName);
|
|
return true;</strong>
|
|
}
|
|
// --------------------------------------
|
|
// ISystemRemoteElementAdapter methods...
|
|
// --------------------------------------
|
|
|
|
/* (non-Javadoc)
|
|
* @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getAbsoluteParentName(java.lang.Object)
|
|
*/
|
|
public String getAbsoluteParentName(Object element)
|
|
{
|
|
<strong>return "root";</strong> // not really applicable as we have no unique hierarchy
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getSubSystemConfigurationId(java.lang.Object)
|
|
*/
|
|
public String getSubSystemConfigurationId(Object element)
|
|
{
|
|
<strong>return "samples.subsystems.factory";</strong> // as declared in extension in plugin.xml
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getRemoteTypeCategory(java.lang.Object)
|
|
*/
|
|
public String getRemoteTypeCategory(Object element)
|
|
{
|
|
<strong>return "developers";</strong> // Course grained. Same for all our remote resources.
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getRemoteType(java.lang.Object)
|
|
*/
|
|
public String getRemoteType(Object element)
|
|
{
|
|
<strong>return "team";</strong> // Fine grained. Unique to this resource type.
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getRemoteSubType(java.lang.Object)
|
|
*/
|
|
public String getRemoteSubType(Object element)
|
|
{
|
|
return null; // Very fine grained. We don't use it.
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#refreshRemoteObject(java.lang.Object, java.lang.Object)
|
|
*/
|
|
<a id="refreshRemoteObject"></a>public boolean refreshRemoteObject(Object oldElement, Object newElement)
|
|
{
|
|
<strong>TeamResource oldTeam = (TeamResource)oldElement;
|
|
TeamResource newTeam = (TeamResource)newElement;
|
|
newTeam.setName(oldTeam.getName());
|
|
return false;</strong> // If developer objects held references to their team names, we'd have to return true
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getRemoteParent(org.eclipse.swt.widgets.Shell, java.lang.Object)
|
|
*/
|
|
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
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getRemoteParentNamesInUse(org.eclipse.swt.widgets.Shell, java.lang.Object)
|
|
*/
|
|
<a id="getNames"></a>public String[] getRemoteParentNamesInUse(Shell shell, Object element)
|
|
throws Exception
|
|
{
|
|
<strong>DeveloperSubSystem ourSS = (DeveloperSubSystem)getSubSystem(element);
|
|
TeamResource[] allTeams = ourSS.getAllTeams();
|
|
String[] allNames = new String[allTeams.length];
|
|
for (int idx = 0; idx < allTeams.length; idx++)
|
|
allNames[idx] = allTeams[idx].getName();
|
|
return allNames;</strong> // Return list of all team names
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#supportsUserDefinedActions(java.lang.Object)
|
|
*/
|
|
public boolean supportsUserDefinedActions(Object object) {
|
|
<strong>return false;</strong>
|
|
}
|
|
|
|
}
|
|
</samp></pre>
|
|
</body>
|
|
</html>
|