1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-22 15:53:58 +02:00

[188284] add ILabeledObject and exploit in server launchers and property sets

This commit is contained in:
David Dykstal 2007-05-22 13:47:46 +00:00
parent cc453b444a
commit 0d4191c560
9 changed files with 96 additions and 4 deletions

View file

@ -0,0 +1,34 @@
/********************************************************************************
* Copyright (c) 2007 IBM Corporation and others. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* David Dykstal (IBM) - initial API and implementation
********************************************************************************/
package org.eclipse.rse.core.model;
/**
* This interface provides a means of extending RSE model objects and property sets
* with labels that can be used for display purposes.
* The persistence characteristics of labels are left to the implementing
* objects.
*/
public interface ILabeledObject {
/**
* @return the display label for the object. If this has not
* previously been set, this can return the name of object or
* some other generated or constant label. It may return null
* if no label can be determined.
*/
public String getLabel();
/**
* @param label A display label for this object.
*/
public void setLabel(String label);
}

View file

@ -29,9 +29,10 @@ import java.util.Set;
* Not thread-safe since the underlying {@link java.util.HashMap} is
* not thread-safe.
*/
public class PropertySet extends RSEPersistableObject implements IPropertySet, Observer {
public class PropertySet extends RSEPersistableObject implements IPropertySet, ILabeledObject, Observer {
private String _name;
private String _label = null;
private Map _properties;
private IPropertySetContainer _container = null;
@ -44,6 +45,10 @@ public class PropertySet extends RSEPersistableObject implements IPropertySet, O
public PropertySet(IPropertySet propertySet) {
_name = propertySet.getName();
_properties = new HashMap();
if (propertySet instanceof ILabeledObject) {
ILabeledObject p = (ILabeledObject) propertySet;
_label = p.getLabel();
}
String[] keys = propertySet.getPropertyKeys();
for (int i = 0; i < keys.length; i++) {
@ -67,6 +72,16 @@ public class PropertySet extends RSEPersistableObject implements IPropertySet, O
public String getName() {
return _name;
}
public String getLabel() {
if (_label != null) return _label;
return _name;
}
public void setLabel(String label) {
_label = label;
setDirty(true);
}
public String getDescription() {
return getPropertyValue(DESCRIPTION_KEY);

View file

@ -20,6 +20,7 @@ package org.eclipse.rse.core.subsystems;
import java.util.Arrays;
import java.util.List;
import org.eclipse.rse.core.model.ILabeledObject;
import org.eclipse.rse.core.model.IProperty;
import org.eclipse.rse.core.model.IPropertySet;
import org.eclipse.rse.core.model.IPropertyType;
@ -57,8 +58,9 @@ public class RemoteServerLauncher extends ServerLauncher implements IRemoteServe
protected static final ServerLaunchType SERVER_LAUNCH_TYPE_EDEFAULT = ServerLaunchType.DAEMON_LITERAL;
// proeprty set keys
// property set keys
protected final String PROPERTY_SET_NAME = "Launcher Properties"; //$NON-NLS-1$
private final String PROPERTY_SET_LABEL = RSECoreMessages.RESID_PROPERTYSET_LAUNCHER_PROPERTIES;
protected final String KEY_DAEMON_PORT = "daemon.port"; //$NON-NLS-1$
protected final String KEY_REXEC_PORT = "rexec.port"; //$NON-NLS-1$
@ -140,6 +142,10 @@ public class RemoteServerLauncher extends ServerLauncher implements IRemoteServe
{
try
{
if (set instanceof ILabeledObject) {
ILabeledObject ps = (ILabeledObject) set;
ps.setLabel(PROPERTY_SET_LABEL);
}
IProperty launchTypeProperty = set.getProperty(KEY_SERVER_LAUNCH_TYPE_NAME);
launchTypeProperty.setLabel(RSECoreMessages.RESID_PROP_SERVERLAUNCHER_MEANS_LABEL);
String launchTypeName = launchTypeProperty.getValue();
@ -194,7 +200,10 @@ public class RemoteServerLauncher extends ServerLauncher implements IRemoteServe
IPropertySet set = getPropertySet(PROPERTY_SET_NAME);
if (set == null)
{
set = createPropertySet(PROPERTY_SET_NAME, getDescription());
set = createPropertySet(PROPERTY_SET_NAME, getDescription());
if (set instanceof ILabeledObject) {
((ILabeledObject)set).setLabel(PROPERTY_SET_LABEL);
}
}
if (_serverLaunchType == null)

View file

@ -37,6 +37,9 @@ public class RSECoreMessages extends NLS {
public static String RESID_CONNECTION_PORT_LABEL;
public static String RESID_SUBSYSTEM_AUTODETECT_LABEL;
public static String RESID_PROPERTYSET_REMOTE_SERVER_LAUNCHER;
public static String RESID_PROPERTYSET_LAUNCHER_PROPERTIES;
// Persistence
public static String PropertyFileProvider_LoadingTaskName;
public static String PropertyFileProvider_SavingTaskName;

View file

@ -31,6 +31,9 @@ RESID_PROP_SERVERLAUNCHER_INVOCATION=Server launch command
RESID_CONNECTION_PORT_LABEL=Port
RESID_CONNECTION_DAEMON_PORT_LABEL=Daemon Port
RESID_PROPERTYSET_REMOTE_SERVER_LAUNCHER=Remote Server Launcher
RESID_PROPERTYSET_LAUNCHER_PROPERTIES=Launcher Properties
# Persistence
RSEPersistenceManager_DeleteProfileJobName=Delete RSE Profile Job
PropertyFileProvider_SavingTaskName=Saving DOM

View file

@ -20,6 +20,7 @@ package org.eclipse.rse.internal.core.subsystems;
import java.util.Arrays;
import java.util.List;
import org.eclipse.rse.core.model.ILabeledObject;
import org.eclipse.rse.core.model.IPropertySet;
import org.eclipse.rse.core.model.IRSEPersistableContainer;
import org.eclipse.rse.core.model.RSEModelObject;
@ -28,11 +29,12 @@ import org.eclipse.rse.core.subsystems.IServerLauncherProperties;
import org.eclipse.rse.internal.core.RSECoreMessages;
public abstract class ServerLauncher extends RSEModelObject implements IServerLauncherProperties
public abstract class ServerLauncher extends RSEModelObject implements IServerLauncherProperties, ILabeledObject
{
protected String _name;
private String _label = null;
protected IConnectorService _connectorService;
protected ServerLauncher(String name, IConnectorService service)
@ -47,6 +49,16 @@ public abstract class ServerLauncher extends RSEModelObject implements IServerLa
return _name;
}
public String getLabel() {
if (_label != null) return _label;
return _name;
}
public void setLabel(String label) {
_label = label;
setDirty(true);
}
public String getDescription()
{
return RSECoreMessages.RESID_MODELOBJECTS_SERVERLAUNCHER_DESCRIPTION;

View file

@ -20,6 +20,7 @@ import java.util.ArrayList;
import java.util.List;
import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.core.model.ILabeledObject;
import org.eclipse.rse.core.model.IProperty;
import org.eclipse.rse.core.model.IPropertySet;
import org.eclipse.rse.core.model.IPropertyType;
@ -62,6 +63,10 @@ implements IPropertySource
public String getName()
{
if (_propertySet instanceof ILabeledObject) {
ILabeledObject ps = (ILabeledObject) _propertySet;
return ps.getLabel();
}
return _propertySet.getName();
}

View file

@ -17,6 +17,7 @@
package org.eclipse.rse.ui.widgets.services;
import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.core.model.ILabeledObject;
import org.eclipse.rse.core.subsystems.IServerLauncherProperties;
import org.eclipse.rse.ui.ISystemIconConstants;
import org.eclipse.rse.ui.RSEUIPlugin;
@ -36,6 +37,10 @@ public class ServerLauncherPropertiesServiceElement extends RSEModelServiceEleme
public String getName()
{
if (_launcherProperties instanceof ILabeledObject) {
ILabeledObject lp = (ILabeledObject) _launcherProperties;
return lp.getLabel();
}
return _launcherProperties.getName();
}

View file

@ -52,6 +52,7 @@ import org.eclipse.rse.core.filters.ISystemFilterPoolReferenceManager;
import org.eclipse.rse.core.filters.ISystemFilterSavePolicies;
import org.eclipse.rse.core.filters.ISystemFilterString;
import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.core.model.ILabeledObject;
import org.eclipse.rse.core.model.IRSEPersistableContainer;
import org.eclipse.rse.core.model.ISystemNewConnectionWizardPage;
import org.eclipse.rse.core.model.ISystemProfile;
@ -59,6 +60,7 @@ import org.eclipse.rse.core.model.ISystemProfileManager;
import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.core.model.SystemStartHere;
import org.eclipse.rse.core.references.IRSEBaseReferencingObject;
import org.eclipse.rse.internal.core.RSECoreMessages;
import org.eclipse.rse.internal.core.filters.SystemFilterPoolManager;
import org.eclipse.rse.internal.core.filters.SystemFilterPoolWrapperInformation;
import org.eclipse.rse.internal.core.filters.SystemFilterStartHere;
@ -2692,6 +2694,10 @@ public abstract class SubSystemConfiguration implements ISubSystemConfiguration
public IServerLauncherProperties createServerLauncher(IConnectorService connectorService)
{
IRemoteServerLauncher sl = new RemoteServerLauncher("Remote Server Launcher", connectorService); //$NON-NLS-1$
if (sl instanceof ILabeledObject) {
((ILabeledObject)sl).setLabel(RSECoreMessages.RESID_PROPERTYSET_REMOTE_SERVER_LAUNCHER);
}
IRSESystemType systemType = connectorService.getHost().getSystemType();
String systemTypeId = systemType.getId();