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

[173267][api] "empty list" should not be displayed (apply patch from Tobias Schwarz)

This commit is contained in:
Martin Oberhuber 2007-05-30 23:20:58 +00:00
parent 525d45f5f9
commit 4f611be414
8 changed files with 119 additions and 67 deletions

View file

@ -12,16 +12,19 @@
*
* Contributors:
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
* Tobias Schwarz (Wind River) - [173267] "empty list" should not be displayed
********************************************************************************/
package org.eclipse.rse.internal.ui.view;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.model.ISystemMessageObject;
import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.core.model.SystemMessageObject;
import org.eclipse.rse.ui.ISystemMessages;
import org.eclipse.rse.ui.ISystemPreferencesConstants;
import org.eclipse.rse.ui.RSEUIPlugin;
import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
@ -45,11 +48,15 @@ public abstract class SystemAbstractAPIProvider
protected ISystemRegistry sr;
protected Object[] emptyList = new Object[0];
protected Object[] msgList = new Object[1];
protected Object[] msgList = new Object[1];
/**
* @deprecated Use {@link #checkForEmptyList(Object[], Object, boolean)} instead.
*/
protected SystemMessageObject nullObject = null;
protected SystemMessageObject canceledObject = null;
protected SystemMessageObject errorObject = null;
private Preferences fPrefStore = null;
/**
* Constructor
@ -104,17 +111,51 @@ public abstract class SystemAbstractAPIProvider
return viewer;
}
private void initMsgObjects()
{
nullObject = new SystemMessageObject(RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXPAND_EMPTY),ISystemMessageObject.MSGTYPE_EMPTY, null);
canceledObject = new SystemMessageObject(RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_LIST_CANCELLED),ISystemMessageObject.MSGTYPE_CANCEL, null);
errorObject = new SystemMessageObject(RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXPAND_FAILED),ISystemMessageObject.MSGTYPE_ERROR, null);
}
protected final void initMsgObjects()
{
nullObject = new SystemMessageObject(RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXPAND_EMPTY),ISystemMessageObject.MSGTYPE_EMPTY, null);
canceledObject = new SystemMessageObject(RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_LIST_CANCELLED),ISystemMessageObject.MSGTYPE_CANCEL, null);
errorObject = new SystemMessageObject(RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXPAND_FAILED),ISystemMessageObject.MSGTYPE_ERROR, null);
}
/**
* <i>Callable by subclasses. Do not override</i><br>
* In getChildren, return <samp>checkForEmptyList(children, parent, true/false)<.samp>
* versus your array directly. This method checks for a null array which is
* not allowed and replaces it with an empty array.
* If true is passed then it returns the "Empty list" message object if the array is null or empty
*
* @param children The list of children.
* @param parent The parent for the children.
* @param returnNullMsg <code>true</code> if an "Empty List" message should be returned.
* @return The list of children, a list with the "Empty List" message object or an empty list.
*/
protected Object[] checkForEmptyList(Object[] children, Object parent, boolean returnNullMsg) {
if ((children == null) || (children.length == 0)) {
if (fPrefStore == null) {
fPrefStore = RSEUIPlugin.getDefault().getPluginPreferences();
}
if (!returnNullMsg
|| (fPrefStore != null && !fPrefStore
.getBoolean(ISystemPreferencesConstants.SHOW_EMPTY_LISTS))) {
return emptyList;
} else {
return new Object[] {
new SystemMessageObject(
RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXPAND_EMPTY),
ISystemMessageObject.MSGTYPE_EMPTY,
parent)};
}
}
return children;
}
/**
* In getChildren, return checkForNull(children, true/false) vs your array directly.
* This method checks for a null array which not allow and replaces it with an empty array.
* If true is passed then it returns the "Empty list" message object if the array is null or empty
*
* @deprecated Use {@link #checkForEmptyList(Object[], Object, boolean)} instead.
*/
protected Object[] checkForNull(Object[] children, boolean returnNullMsg)
{

View file

@ -15,6 +15,7 @@
* Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType
* Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
* Martin Oberhuber (Wind River) - [175680] Deprecate obsolete ISystemRegistry methods
* Tobias Schwarz (Wind River) - [173267] "empty list" should not be displayed
********************************************************************************/
package org.eclipse.rse.internal.ui.view;
@ -364,7 +365,7 @@ public class SystemSelectRemoteObjectAPIProviderImpl
children = resolveFilterString(subsystem, filterString);
}
return checkForNull(children, true);
return checkForEmptyList(children, null, true);
}
/**
@ -401,10 +402,11 @@ public class SystemSelectRemoteObjectAPIProviderImpl
{
Object[] children = null;
ISubSystem[] subsystems = getSubSystems(selectedConnection);
ISubSystem subsystem = null;
if ((subsystems != null) && (subsystems.length > 0))
{
ISubSystem subsystem = subsystems[0]; // always just use first. Hopefully never a problem!
subsystem = subsystems[0]; // always just use first. Hopefully never a problem!
if (subsystems.length > 1)
SystemBasePlugin.logWarning(this.getClass().getName() + ": More than one subsystem meeting criteria. SSFID = "+subsystemConfigurationId+", SSFCat = "+subsystemConfigurationCategory); //$NON-NLS-1$ //$NON-NLS-2$
@ -457,7 +459,7 @@ public class SystemSelectRemoteObjectAPIProviderImpl
}
}
return checkForNull(children, true);
return checkForEmptyList(children, subsystem, true);
}
}
@ -539,7 +541,7 @@ public class SystemSelectRemoteObjectAPIProviderImpl
multiConnections = ((conns!=null) && (conns.length>1)); // 50167pc
}
return checkForNull(children, false);
return checkForEmptyList(children, null, false);
}
/**

View file

@ -12,16 +12,13 @@
*
* Contributors:
* Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
* Tobias Schwarz (Wind River) - [173267] "empty list" should not be displayed
********************************************************************************/
package org.eclipse.rse.internal.ui.view;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.core.model.ISystemMessageObject;
import org.eclipse.rse.core.model.SystemMessageObject;
import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.ui.ISystemMessages;
import org.eclipse.rse.ui.RSEUIPlugin;
import org.eclipse.rse.ui.SystemBasePlugin;
import org.eclipse.rse.ui.view.ISystemViewInputProvider;
@ -51,13 +48,6 @@ public class SystemTestFilterStringAPIProviderImpl
this.filterString = filterString;
}
private void initMsgObjects()
{
nullObject = new SystemMessageObject(RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXPAND_EMPTY),ISystemMessageObject.MSGTYPE_EMPTY, null);
canceledObject = new SystemMessageObject(RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_LIST_CANCELLED),ISystemMessageObject.MSGTYPE_CANCEL, null);
errorObject = new SystemMessageObject(RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXPAND_FAILED),ISystemMessageObject.MSGTYPE_ERROR, null);
}
/**
* Change the input subsystem
*/
@ -88,25 +78,13 @@ public class SystemTestFilterStringAPIProviderImpl
try
{
children = subsystem.resolveFilterString(filterString, new NullProgressMonitor());
if ((children == null) || (children.length==0))
{
if (nullObject == null)
initMsgObjects();
msgList[0] = nullObject;
children = msgList;
}
children = checkForEmptyList(children, null, true);
} catch (InterruptedException exc)
{
if (canceledObject == null)
initMsgObjects();
msgList[0] = canceledObject;
children = msgList;
children = getCancelledMessageObject();
} catch (Exception exc)
{
if (errorObject == null)
initMsgObjects();
msgList[0] = errorObject;
children = msgList;
children = getFailedMessageObject();
SystemBasePlugin.logError("Error in SystemTestFilterStringAPIProviderImpl#getSystemViewRoots()",exc); //$NON-NLS-1$
}
return children;

View file

@ -12,6 +12,7 @@
*
* Contributors:
* Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
* Tobias Schwarz (Wind River) - [173267] "empty list" should not be displayed
********************************************************************************/
package org.eclipse.rse.internal.ui.view;
@ -138,12 +139,7 @@ public class SystemViewAPIProviderForFilterStrings
try
{
children = ss.resolveFilterString(filterStringReference.getString(), new NullProgressMonitor());
if ((children == null) || (children.length==0))
{
children = new SystemMessageObject[1];
children[0] = new SystemMessageObject(RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXPAND_EMPTY),
ISystemMessageObject.MSGTYPE_EMPTY, element);
}
children = checkForEmptyList(children, element, true);
}
catch (InterruptedException exc)
{

View file

@ -15,6 +15,7 @@
* Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
* Martin Oberhuber (Wind River) - [186748] Move ISubSystemConfigurationAdapter from UI/rse.core.subsystems.util
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
* Tobias Schwarz (Wind River) - [173267] "empty list" should not be displayed
********************************************************************************/
package org.eclipse.rse.internal.ui.view;
@ -212,13 +213,7 @@ public class SystemViewAPIProviderForFilters
SystemBasePlugin.logError("Exception resolving filters' strings ",exc); //$NON-NLS-1$
} // message already issued
if ((children == null) || (children.length==0))
{
children = new SystemMessageObject[1];
children[0] = new SystemMessageObject(RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXPAND_EMPTY),
ISystemMessageObject.MSGTYPE_EMPTY, element);
}
return children;
return checkForEmptyList(children, element, true);
}
}
}

View file

@ -16,6 +16,7 @@
* Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
* Martin Oberhuber (Wind River) - [186748] Move ISubSystemConfigurationAdapter from UI/rse.core.subsystems.util
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
* Tobias Schwarz (Wind River) - [173267] "empty list" should not be displayed
********************************************************************************/
package org.eclipse.rse.internal.ui.view;
@ -53,6 +54,7 @@ import org.eclipse.rse.ui.validators.ValidatorFilterName;
import org.eclipse.rse.ui.view.AbstractSystemViewAdapter;
import org.eclipse.rse.ui.view.ISystemPropertyConstants;
import org.eclipse.rse.ui.view.ISystemViewInputProvider;
import org.eclipse.rse.ui.view.SystemAdapterHelpers;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IActionFilter;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
@ -197,7 +199,7 @@ public class SystemViewFilterAdapter extends AbstractSystemViewAdapter
if (filter.isTransient())
{
if (filter.isPromptable())
return checkForNull(processPromptingFilter(filter), true);
return checkForEmptyList(processPromptingFilter(filter), element, true);
Object[] children = null;
SystemFilterSimple simpleFilter = (SystemFilterSimple)filter;
@ -232,7 +234,7 @@ public class SystemViewFilterAdapter extends AbstractSystemViewAdapter
}
// otherwise, get children and then cache
else {
children = checkForNull(ss.resolveFilterStrings(filterStrings, monitor), true);
children = checkForEmptyList(ss.resolveFilterStrings(filterStrings, monitor), element, true);
if (ss.getSubSystemConfiguration().supportsFilterCaching()) {
simpleFilter.setContents(SystemChildrenContentsType.getInstance(), children);
@ -245,7 +247,7 @@ public class SystemViewFilterAdapter extends AbstractSystemViewAdapter
for (int idx=0; (match==null) && (idx<children.length); idx++)
{
Object child = children[idx];
String objName = getSystemViewElementAdapter(child).getName(child);
String objName = SystemAdapterHelpers.getViewAdapter(child, getViewer()).getName(child);
if ((objName != null) && (objName.equals(preSelectName)))
match = child;
}
@ -270,7 +272,7 @@ public class SystemViewFilterAdapter extends AbstractSystemViewAdapter
}
if (filter.isPromptable())
return checkForNull(null, false);
return checkForEmptyList(null, element, false);
// normal filters...
//Vector strings = filter.getFilterStringsVector();

View file

@ -18,6 +18,7 @@
* Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
* Martin Oberhuber (Wind River) - [186748] Move ISubSystemConfigurationAdapter from UI/rse.core.subsystems.util
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
* Tobias Schwarz (Wind River) - [173267] "empty list" should not be displayed
********************************************************************************/
package org.eclipse.rse.internal.ui.view;
@ -447,12 +448,7 @@ public class SystemViewFilterReferenceAdapter
SystemBasePlugin.logError("Exception resolving filters' strings ", exc); //$NON-NLS-1$
} // message already issued
if ((children == null) || (children.length == 0))
{
children = new SystemMessageObject[1];
children[0] = new SystemMessageObject(RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXPAND_EMPTY), ISystemMessageObject.MSGTYPE_EMPTY, element);
}
return children;
return checkForEmptyList(children, element, true);
}
}
}

View file

@ -19,6 +19,7 @@
* Martin Oberhuber (Wind River) - [186640] Add IRSESystemType.testProperty()
* Martin Oberhuber (Wind River) - [186748] Move ISubSystemConfigurationAdapter from UI/rse.core.subsystems.util
* Martin Oberhuber (Wind River) - [189163] Update IActionFilter constants from subsystemFactory to subsystemConfiguration
* Tobias Schwarz (Wind River) - [173267] "empty list" should not be displayed
********************************************************************************/
package org.eclipse.rse.ui.view;
@ -33,6 +34,7 @@ import java.util.Vector;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.IBasicPropertyConstants;
@ -58,6 +60,7 @@ import org.eclipse.rse.internal.ui.view.ISystemMementoConstants;
import org.eclipse.rse.internal.ui.view.SystemViewPart;
import org.eclipse.rse.internal.ui.view.SystemViewResources;
import org.eclipse.rse.ui.ISystemMessages;
import org.eclipse.rse.ui.ISystemPreferencesConstants;
import org.eclipse.rse.ui.RSEUIPlugin;
import org.eclipse.rse.ui.SystemBasePlugin;
import org.eclipse.rse.ui.SystemMenuManager;
@ -136,6 +139,7 @@ public abstract class AbstractSystemViewAdapter implements ISystemViewElementAda
protected Object[] msgList = new Object[1];
/**
* Frequently returned msg object from getChildren: "empty list"
* @deprecated Use {@link #checkForEmptyList(Object[], Object, boolean)} instead.
*/
protected SystemMessageObject nullObject = null;
/**
@ -186,6 +190,8 @@ public abstract class AbstractSystemViewAdapter implements ISystemViewElementAda
*/
protected Object _lastSelected = null;
private Preferences fPrefStore = null;
/**
* Static constructor.
*/
@ -1518,16 +1524,16 @@ public abstract class AbstractSystemViewAdapter implements ISystemViewElementAda
}
return false;
}
else if (name.equalsIgnoreCase("isRemote"))
else if (name.equalsIgnoreCase("isRemote")) //$NON-NLS-1$
{
return isRemote(target);
return isRemote(target) ? value.equals("true") : value.equals("false"); //$NON-NLS-1$ //$NON-NLS-2$
}
// Give the ISV's as the element owners/contibutors the chance to extend the standard RSE action
// Give the ISV's as the element owners/contributors the chance to extend the standard RSE action
// filters for their specific needs. We do this by trying to determine the system type from the
// target object and try to adapt the system type to an IActionFilter.
//
// Note: Everything we do here is performance critical to the menu to show up. Therefor
// Note: Everything we do here is performance critical to the menu to show up. Therefore
// we cache as much as possible here. The cache is static to all AbstractSystemViewAdapter
// instances throughout the whole hierarchy.
IHost conn = null;
@ -1821,11 +1827,45 @@ public abstract class AbstractSystemViewAdapter implements ISystemViewElementAda
errorObject = new SystemMessageObject(RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXPAND_FAILED),ISystemMessageObject.MSGTYPE_ERROR, null);
}
/**
* <i>Callable by subclasses. Do not override</i><br>
* In getChildren, return <samp>checkForEmptyList(children, parent, true/false)<.samp>
* versus your array directly. This method checks for a null array which is
* not allowed and replaces it with an empty array.
* If true is passed then it returns the "Empty list" message object if the array is null or empty
*
* @param children The list of children.
* @param parent The parent for the children.
* @param returnNullMsg <code>true</code> if an "Empty List" message should be returned.
* @return The list of children, a list with the "Empty List" message object or an empty list.
*/
protected Object[] checkForEmptyList(Object[] children, Object parent, boolean returnNullMsg) {
if ((children == null) || (children.length == 0)) {
if (fPrefStore == null) {
fPrefStore = RSEUIPlugin.getDefault().getPluginPreferences();
}
if (!returnNullMsg
|| (fPrefStore != null && !fPrefStore
.getBoolean(ISystemPreferencesConstants.SHOW_EMPTY_LISTS))) {
return emptyList;
} else {
return new Object[] {
new SystemMessageObject(
RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXPAND_EMPTY),
ISystemMessageObject.MSGTYPE_EMPTY,
parent)};
}
}
return children;
}
/**
* <i>Callable by subclasses. Do not override</i><br>
* In getChildren, return <samp>checkForNull(children, true/false)<.samp> versus your array directly.
* In getChildren, return <samp>checkForNull(children, true/false)</samp> versus your array directly.
* This method checks for a null array which is not allowed and replaces it with an empty array.
* If true is passed then it returns the "Empty list" message object if the array is null or empty
*
* @deprecated Use {@link #checkForEmptyList(Object[], Object, boolean)} instead.
*/
protected Object[] checkForNull(Object[] children, boolean returnNullMsg)
{
@ -1847,7 +1887,7 @@ public abstract class AbstractSystemViewAdapter implements ISystemViewElementAda
/**
* <i>Callable by subclasses. Do not override</i><br>
* Return the "Operation cancelled by user" msg as an object array so can be used to answer getChildren()
* Return the "Operation canceled by user" msg as an object array so can be used to answer getChildren()
*/
protected final Object[] getCancelledMessageObject()
{
@ -1870,6 +1910,8 @@ public abstract class AbstractSystemViewAdapter implements ISystemViewElementAda
/**
* <i>Callable by subclasses. Do not override</i><br>
* Return the "Empty list" msg as an object array so can be used to answer getChildren()
*
* @deprecated Use {@link #checkForEmptyList(Object[], Object, boolean)} instead.
*/
protected final Object[] getEmptyMessageObject()
{