1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-29 11:55:40 +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,34 +115,28 @@ 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) {
// Basically, once initialized, the list of system types cannot change, but
else if (children == null) // it doesn't hurt to check this in case it changes because of future extensions.
{ if (isRootPrompt) {
children = new ISystemPromptableObject[systemTypes.length]; String[] typeNames = RSECorePlugin.getDefault().getRegistry().getSystemTypeNames();
for (int idx=0; idx<children.length; idx++) if (systemTypes == null || typeNames.length != systemTypes.length)
{ systemTypes = typeNames;
children[idx] = new SystemNewConnectionPromptObject(this, systemTypes[idx]); }
}
} if (systemTypes != null) {
else children = new ISystemPromptableObject[systemTypes.length];
{ for (int idx = 0; idx < children.length; idx++) {
String[] typeNames = RSECorePlugin.getDefault().getRegistry().getSystemTypeNames(); children[idx] = new SystemNewConnectionPromptObject(this, systemTypes[idx]);
if (typeNames.length != systemTypes.length) }
{ }
systemTypes = typeNames; }
children = new ISystemPromptableObject[systemTypes.length];
for (int idx=0; idx<children.length; idx++) return children;
{
children[idx] = new SystemNewConnectionPromptObject(this, systemTypes[idx]);
}
}
}
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,38 +157,34 @@ 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 {
IRSESystemType sysType = RSECorePlugin.getDefault().getRegistry().getSystemType(systemTypes[0]); IRSESystemType sysType = RSECorePlugin.getDefault().getRegistry().getSystemType(systemTypes[0]);
RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(sysType.getAdapter(IRSESystemType.class)); RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(sysType.getAdapter(IRSESystemType.class));
return adapter.getImageDescriptor(sysType); return adapter.getImageDescriptor(sysType);
} }
} }
/** /**
* 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())
if (hasChildren() || systemTypesSet) newConnText = SystemResources.RESID_NEWCONN_PROMPT_LABEL;
{ else
if (hasChildren()) newConnText = SystemResources.RESID_NEWCONN_PROMPT_LABEL + " ..."; //$NON-NLS-1$
newConnText = SystemResources.RESID_NEWCONN_PROMPT_LABEL; } else if (getSystemTypes().length > 0) {
else newConnText = systemTypes[0] + " ..."; //$NON-NLS-1$
newConnText = SystemResources.RESID_NEWCONN_PROMPT_LABEL+"..."; //$NON-NLS-1$ }
}
else
{
newConnText = systemTypes[0]+"..."; //$NON-NLS-1$
}
} }
return newConnText; return newConnText;
} }
/** /**
* Return the type label for this object * Return the type label for this object
*/ */
@ -208,7 +198,7 @@ public class SystemNewConnectionPromptObject
/** /**
* Run this prompt. This should return an appropriate ISystemMessageObject to show * Run this prompt. This should return an appropriate ISystemMessageObject to show
* as the child, reflecting if it ran successfully, was cancelled or failed. * as the child, reflecting if it ran successfully, was cancelled or failed.
*/ */
public Object[] run(Shell shell) public Object[] run(Shell shell)
{ {