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