1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-09-10 12:03:16 +02:00

[186640][api] Add IRSESystemType.testProperty()

This commit is contained in:
Martin Oberhuber 2007-05-14 08:58:23 +00:00
parent 7270445898
commit a474ccb296
6 changed files with 18 additions and 186 deletions

View file

@ -152,7 +152,12 @@ If not specified, a default icon will be used by RSE.
<li>"icon" to store the value of the icon attribute</li>
<li>"iconLive" to store the value of the iconLive attribute</li>
<li>"enableOffline" to store the value of the enableOffline attribute</li>
<li>"isCaseSensitive" for system types with a case sensitive file system</li>
<li>"isLocal" for system types that refer to the local system</li>
<li>"isWindows" for system types that refer to a Windows kind of system (case insensitive file system with drive letters)</li>
</ul>
In general, clients can use any own properties with system types, but should use reverse DNS notation to qualify their property keys (e.g. <code>com.acme.isFoobarSystem</code>. Property keys without qualifying namespace are reserved for RSE internal use. See also class IRSESystemType, methods getProperty() and testProperty().
</documentation>
</annotation>
<complexType>

View file

@ -222,6 +222,11 @@ public interface IRSESystemType extends IAdaptable {
* Tests whether the given boolean property matches the expected value
* for this system type.
*
* Clients can use their own properties with system types, but should
* use reverse DNS notation to qualify their property keys (e.g.
* <code>com.acme.isFoobarSystem</code>. Property keys without qualifying
* namespace are reserved for RSE internal use.
*
* @param key the name of the property to return
* @param expectedValue the expected boolean value of the property.
* @return <code>true</code> if the Property is set on the system type and

View file

@ -15,7 +15,7 @@
* - updated to use new RSEPreferencesManager
* Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType
* Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods
* Martin Oberhuber (Wind River) - [186640] Add IRSESystemTyep.isLocal()
* Martin Oberhuber (Wind River) - [186640] Add IRSESystemType.testProperty()
********************************************************************************/
package org.eclipse.rse.core;
@ -78,7 +78,7 @@ public class PasswordPersistenceManager {
/**
* Default System Type
*/
private static class DefaultSystemType extends RSESystemType implements IRSESystemType
private static class DefaultSystemType extends AbstractRSESystemType implements IRSESystemType
{
private static final String DEFAULT_ID = "DEFAULT"; //$NON-NLS-1$
private DefaultSystemType() {

View file

@ -1,178 +0,0 @@
/********************************************************************************
* Copyright (c) 2006, 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
*
* Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight, Kushal Munir,
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
*
* Contributors:
* Uwe Stieber (Wind River) - Dynamic system type provider extension.
* Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType
* Martin Oberhuber (Wind River) - [186640] Add IRSESystemTyep.isLocal()
********************************************************************************/
package org.eclipse.rse.core;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.core.runtime.PlatformObject;
import org.osgi.framework.Bundle;
/**
* Abstract base class holding core functionality of a system type.
*
* Extenders must override {@link IRSESystemType#getSubsystemConfigurationIds()}
* according to their strategy of finding subsystem configuration id's that
* match their system type.
*
* Extenders may override any other method.
*/
public abstract class RSESystemType extends PlatformObject implements IRSESystemType {
protected String id = null;
protected String name = null;
protected String label = null;
protected String description = null;
protected Bundle definingBundle = null;
protected Map properties;
/**
* Default constructor.
* Only subclasses may call this if set the id, name, label,
* description and properties attributes themselves.
*/
protected RSESystemType()
{
super();
}
/**
* Constructor for an object representing a system type.
* @param id unique id of this system type. Must be system unique.
* @param name a name of this system type to be used for internal checks.
* @param label a user-visible label of this system type.
* May be <code>null</code> and falls back to the name in this case.
* @param description a user-visible description of this system type.
* May be <code>null</code> and falls back to the label in this case.
*/
public RSESystemType(String id, String name, String label, String description, Bundle definingBundle)
{
super();
this.id = id;
this.name = name;
this.label = label == null ? name : label;
this.description = description == null ? "" : description; //$NON-NLS-1$
this.definingBundle = definingBundle;
this.properties = new HashMap();
}
/**
* Checks whether two system types are the same.
*
* System types are considered the same if they have the same ID.
*/
public boolean equals(Object obj) {
if (obj instanceof IRSESystemType) {
return id.equals( ((IRSESystemType)obj).getId() );
}
return false;
}
/**
* Returns the hashCode for this system type.
*
* The hashCode is the hashCode of its ID.
*/
public int hashCode() {
return id.hashCode();
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.IRSESystemType#getId()
*/
public String getId() {
return id;
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.IRSESystemType#getLabel()
*/
public String getLabel() {
// For default RSE system types, the UI label is equal to the
// name. Therefore, fallback to the name if the label is not
// explicitly set.
if (label == null) return getName();
return label;
}
/*
* (non-Javadoc)
* @see org.eclipse.rse.core.IRSESystemType#getNameOfSystemTypeDeprecated()
*/
public String getName() {
return name;
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.IRSESystemType#getDescription()
*/
public String getDescription() {
return description;
}
/*
* (non-Javadoc)
* @see org.eclipse.rse.core.IRSESystemType#getDefiningBundle()
*/
public Bundle getDefiningBundle() {
return definingBundle;
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.IRSESystemType#getProperty(java.lang.String)
*/
public String getProperty(String key) {
return (String) (properties.get(key));
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.IRSESystemType#getProperty(java.lang.String, boolean)
*/
public boolean getProperty(String key, boolean defaultValue) {
Object val = properties.get(key);
if (val instanceof String) {
return Boolean.valueOf((String)val).booleanValue();
}
return defaultValue;
}
/*
* (non-Javadoc)
* @see org.eclipse.rse.core.IRSESystemType#isLocal()
*/
public boolean isLocal() {
return IRSESystemType.SYSTEMTYPE_LOCAL_ID.equals(getId());
}
/*
* (non-Javadoc)
* @see org.eclipse.rse.core.IRSESystemType#isLocal()
*/
public boolean isWindows() {
return IRSESystemType.SYSTEMTYPE_WINDOWS_ID.equals(getId())
|| (isLocal() && System.getProperty("os.name").toLowerCase().startsWith("win")) //$NON-NLS-1$ //$NON-NLS-2$
|| getProperty(IRSESystemType.PROPERTY_IS_WINDOWS, false);
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
public String toString() {
return getLabel() + " (" + getId() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
}
}

View file

@ -12,7 +12,7 @@
*
* Contributors:
* Uwe Stieber (Wind River) - Added system types provider extension.
* Martin Oberhuber (Wind River) - [186640] Add IRSESystemTyep.isLocal()
* Martin Oberhuber (Wind River) - [186640] Add IRSESystemType.testProperty()
********************************************************************************/
package org.eclipse.rse.internal.core;
@ -147,7 +147,7 @@ public class RSECoreRegistry implements IRSECoreRegistry {
IConfigurationElement element = elements[i];
if (element.getName().equals(ELEMENT_SYTEM_TYPE)) {
IRSESystemType type = new RSEStaticSystemType(element);
IRSESystemType type = new RSESystemType(element);
if (!typeIds.contains(type.getId())) {
types.add(type);
typeIds.add(type.getId());

View file

@ -13,7 +13,7 @@
* Contributors:
* Uwe Stieber (Wind River) - Dynamic system type provider extension.
* Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType
* Martin Oberhuber (Wind River) - [186640] Add IRSESystemTyep.isLocal()
* Martin Oberhuber (Wind River) - [186640] Add IRSESystemType.testProperty()
********************************************************************************/
package org.eclipse.rse.internal.core;
@ -25,12 +25,12 @@ import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.Platform;
import org.eclipse.rse.core.IRSESystemTypeConstants;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.RSESystemType;
import org.eclipse.rse.core.AbstractRSESystemType;
/**
* Class representing a system type statically contributed through plugin.xml.
*/
public class RSEStaticSystemType extends RSESystemType {
public class RSESystemType extends AbstractRSESystemType {
private static final String ATTR_ID = "id"; //$NON-NLS-1$
private static final String ATTR_NAME = "name"; //$NON-NLS-1$
@ -48,7 +48,7 @@ public class RSEStaticSystemType extends RSESystemType {
* Constructor for an object representing a system type.
* @param element the configuration element describing the system type
*/
public RSEStaticSystemType(IConfigurationElement element) {
public RSESystemType(IConfigurationElement element) {
super();
id = element.getAttribute(ATTR_ID);
name = element.getAttribute(ATTR_NAME);