1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-29 20:05:35 +02:00

[fix] label and children calculation

This commit is contained in:
Uwe Stieber 2007-02-06 16:37:59 +00:00
parent 186495b744
commit 36a73519f3

View file

@ -115,33 +115,27 @@ public class SystemNewConnectionPromptObject
* If this returns null, then SystemViewPromptableAdapter will subsequently * If this returns null, then SystemViewPromptableAdapter will subsequently
* call {@link #run(Shell)}. * call {@link #run(Shell)}.
*/ */
public ISystemPromptableObject[] getChildren() public ISystemPromptableObject[] getChildren() {
{
if (!hasChildren()) if (!hasChildren())
return null; return null;
if (children == null) {
else if (children == null) // Basically, once initialized, the list of system types cannot change, but
{ // it doesn't hurt to check this in case it changes because of future extensions.
children = new ISystemPromptableObject[systemTypes.length]; if (isRootPrompt) {
for (int idx=0; idx<children.length; idx++)
{
children[idx] = new SystemNewConnectionPromptObject(this, systemTypes[idx]);
}
}
else
{
String[] typeNames = RSECorePlugin.getDefault().getRegistry().getSystemTypeNames(); String[] typeNames = RSECorePlugin.getDefault().getRegistry().getSystemTypeNames();
if (typeNames.length != systemTypes.length) if (systemTypes == null || typeNames.length != systemTypes.length)
{
systemTypes = typeNames; systemTypes = typeNames;
}
if (systemTypes != null) {
children = new ISystemPromptableObject[systemTypes.length]; children = new ISystemPromptableObject[systemTypes.length];
for (int idx=0; idx<children.length; idx++) for (int idx = 0; idx < children.length; idx++) {
{
children[idx] = new SystemNewConnectionPromptObject(this, systemTypes[idx]); children[idx] = new SystemNewConnectionPromptObject(this, systemTypes[idx]);
} }
} }
} }
return children; return children;
} }
@ -153,7 +147,7 @@ public class SystemNewConnectionPromptObject
// DKM - I think we shouuld indicate children even if there's only one connection type // DKM - I think we shouuld indicate children even if there's only one connection type
//if (systemTypes.length == 1) //if (systemTypes.length == 1)
if (systemTypes.length == 1 && !isRootPrompt) if (systemTypes == null || (systemTypes.length == 1 && !isRootPrompt))
return false; return false;
else else
return true; return true;
@ -163,8 +157,7 @@ public class SystemNewConnectionPromptObject
* Returns an image descriptor for the image. More efficient than getting the image. * Returns an image descriptor for the image. More efficient than getting the image.
* Calls getImage on the subsystem's owning factory. * Calls getImage on the subsystem's owning factory.
*/ */
public ImageDescriptor getImageDescriptor() public ImageDescriptor getImageDescriptor() {
{
if (hasChildren()) if (hasChildren())
return RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_NEWCONNECTION_ID); return RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_NEWCONNECTION_ID);
else { else {
@ -177,24 +170,21 @@ public class SystemNewConnectionPromptObject
/** /**
* Return the label for this object * Return the label for this object
*/ */
public String getText() public String getText() {
{ if (newConnText == null) {
if (newConnText == null) if (isRootPrompt || getSystemTypes().length == 0) {
{
if (hasChildren() || systemTypesSet)
{
if (hasChildren()) if (hasChildren())
newConnText = SystemResources.RESID_NEWCONN_PROMPT_LABEL; newConnText = SystemResources.RESID_NEWCONN_PROMPT_LABEL;
else else
newConnText = SystemResources.RESID_NEWCONN_PROMPT_LABEL+"..."; //$NON-NLS-1$ newConnText = SystemResources.RESID_NEWCONN_PROMPT_LABEL + " ..."; //$NON-NLS-1$
} } else if (getSystemTypes().length > 0) {
else newConnText = systemTypes[0] + " ..."; //$NON-NLS-1$
{
newConnText = systemTypes[0]+"..."; //$NON-NLS-1$
} }
} }
return newConnText; return newConnText;
} }
/** /**
* Return the type label for this object * Return the type label for this object
*/ */