mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-03 23:25:26 +02:00
[218655][api] Provide SystemType enablement info in non-UI
This commit is contained in:
parent
7fbfa4b7e5
commit
8db8a6662e
4 changed files with 67 additions and 25 deletions
|
@ -1,5 +1,5 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006, 2007 IBM Corporation and others. All rights reserved.
|
||||
* Copyright (c) 2006, 2008 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
|
||||
|
@ -15,6 +15,7 @@
|
|||
* Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType
|
||||
* Martin Oberhuber (Wind River) - [186640] Add IRSESystemType.testProperty()
|
||||
* Martin Oberhuber (Wind River) - [186868] Fix IRSESystemType.testProperty() semantics
|
||||
* Martin Oberhuber (Wind River) - [218655][api] Provide SystemType enablement info in non-UI
|
||||
********************************************************************************/
|
||||
package org.eclipse.rse.core;
|
||||
|
||||
|
@ -25,6 +26,7 @@ import org.eclipse.core.runtime.PlatformObject;
|
|||
import org.eclipse.rse.core.model.Host;
|
||||
import org.eclipse.rse.core.model.IHost;
|
||||
import org.eclipse.rse.core.model.ISystemProfile;
|
||||
import org.eclipse.rse.core.subsystems.ISubSystemConfigurationProxy;
|
||||
import org.osgi.framework.Bundle;
|
||||
|
||||
/**
|
||||
|
@ -155,6 +157,24 @@ public abstract class AbstractRSESystemType extends PlatformObject implements IR
|
|||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.rse.core.IRSESystemType#isEnabled()
|
||||
*/
|
||||
public boolean isEnabled() {
|
||||
if (RSEPreferencesManager.getIsSystemTypeEnabled(this)) {
|
||||
// if enabled, check if the system type has any registered subsystems. If
|
||||
// not, this will auto-disable the system type.
|
||||
ISubSystemConfigurationProxy[] proxies = RSECorePlugin.getTheSystemRegistry().getSubSystemConfigurationProxies();
|
||||
for (int i=0; i<proxies.length; i++) {
|
||||
if (proxies[i].appliesToSystemType(this)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.rse.core.IRSESystemType#isLocal()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2000, 2007 IBM Corporation and others. All rights reserved.
|
||||
* Copyright (c) 2000, 2008 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
|
||||
|
@ -13,7 +13,8 @@
|
|||
* Contributors:
|
||||
* Uwe Stieber (Wind River) - Extended system type -> subsystemConfiguration association.
|
||||
* Martin Oberhuber (Wind River) - [185098] Provide constants for all well-known system types
|
||||
* Martin Oberhuber (Wind River) - [186640] Add IRSESystemType.testProperty()
|
||||
* Martin Oberhuber (Wind River) - [186640] Add IRSESystemType.testProperty()
|
||||
* Martin Oberhuber (Wind River) - [218655][api] Provide SystemType enablement info in non-UI
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.core;
|
||||
|
@ -247,6 +248,22 @@ public interface IRSESystemType extends IAdaptable {
|
|||
*/
|
||||
public boolean testProperty(String key, boolean expectedValue);
|
||||
|
||||
/**
|
||||
* Tests whether the system type is currently enabled.
|
||||
*
|
||||
* The enabled state is a dynamic property of a system type, compared to the
|
||||
* static configuration by plugin markup. Enablement is a non-UI property,
|
||||
* which can be set by a Product in the Preferences or modified by a user
|
||||
* to hide certain system types.
|
||||
* <p>
|
||||
* Implementers of custom system types (which are registered by a SystemTypeProvider)
|
||||
* can override this method to provide more advanced enabled checks e.g. based on
|
||||
* license availability.
|
||||
*
|
||||
* @return <code>true</code> if the system type is currently enabled, or <code>false</code> otherwise.
|
||||
*/
|
||||
public boolean isEnabled();
|
||||
|
||||
/**
|
||||
* Tests whether the system type refers to the local system.
|
||||
* This is a shortcut for
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2007 IBM Corporation and others. All rights reserved.
|
||||
* Copyright (c) 2002, 2008 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
|
||||
|
@ -16,6 +16,7 @@
|
|||
* Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType
|
||||
* Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods
|
||||
* Martin Oberhuber (Wind River) - [186640] Add IRSESystemType.testProperty()
|
||||
* Martin Oberhuber (Wind River) - [218655][api] Provide SystemType enablement info in non-UI
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.core;
|
||||
|
@ -94,6 +95,9 @@ public class PasswordPersistenceManager {
|
|||
public Object getAdapter(Class adapter) {
|
||||
return null;
|
||||
}
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006, 2007 IBM Corporation and others. All rights reserved.
|
||||
* Copyright (c) 2006, 2008 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
|
||||
|
@ -19,6 +19,7 @@
|
|||
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
|
||||
* Martin Oberhuber (Wind River) - [181939] avoid subsystem plugin activation just for enablement checking
|
||||
* Uwe Stieber (Wind River) - [199032] [api] Remove method acceptContextMenuActionContribution(...) from RSESystemTypeAdapter
|
||||
* Martin Oberhuber (Wind River) - [218655][api] Provide SystemType enablement info in non-UI
|
||||
********************************************************************************/
|
||||
package org.eclipse.rse.ui;
|
||||
|
||||
|
@ -32,9 +33,7 @@ import org.eclipse.jface.action.IMenuManager;
|
|||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.rse.core.IRSESystemType;
|
||||
import org.eclipse.rse.core.IRSESystemTypeConstants;
|
||||
import org.eclipse.rse.core.RSECorePlugin;
|
||||
import org.eclipse.rse.core.RSEPreferencesManager;
|
||||
import org.eclipse.rse.core.subsystems.ISubSystemConfigurationProxy;
|
||||
import org.eclipse.rse.internal.ui.RSEAdapter;
|
||||
import org.eclipse.rse.ui.wizards.registries.IRSEWizardDescriptor;
|
||||
import org.eclipse.ui.IViewPart;
|
||||
|
@ -101,10 +100,8 @@ public class RSESystemTypeAdapter extends RSEAdapter {
|
|||
* image file. bundle parameter is used as the base for relative paths and
|
||||
* is allowed to be null.
|
||||
*
|
||||
* @param value
|
||||
* the absolute or relative path
|
||||
* @param definingBundle
|
||||
* bundle to be used for relative paths (may be null)
|
||||
* @param value the absolute or relative path
|
||||
* @param definingBundle bundle to be used for relative paths (may be null)
|
||||
* @return ImageDescriptor
|
||||
*/
|
||||
public static ImageDescriptor getImage(String value, Bundle definingBundle) {
|
||||
|
@ -116,10 +113,8 @@ public class RSESystemTypeAdapter extends RSEAdapter {
|
|||
* Create a URL from the argument absolute or relative path. The bundle parameter is
|
||||
* used as the base for relative paths and may be null.
|
||||
*
|
||||
* @param value
|
||||
* the absolute or relative path
|
||||
* @param definingBundle
|
||||
* bundle to be used for relative paths (may be null)
|
||||
* @param value the absolute or relative path
|
||||
* @param definingBundle bundle to be used for relative paths (may be null)
|
||||
* @return the URL to the resource
|
||||
*/
|
||||
public static URL getUrl(String value, Bundle definingBundle) {
|
||||
|
@ -187,26 +182,32 @@ public class RSESystemTypeAdapter extends RSEAdapter {
|
|||
* @param object the object being adapted, usually a system type.
|
||||
* @return true if that system type is enabled. false if the object is
|
||||
* not a system type or if it is not enabled.
|
||||
* @deprecated Clients should use {@link IRSESystemType#isEnabled()}, which is
|
||||
* available without UI dependencies, in order to guarantee consistent
|
||||
* availability of system types.
|
||||
* Providers of custom RSESystemTypeAdapter implementations, which override
|
||||
* this method, should move their code to their IRSESystemType implementations.
|
||||
* See https://bugs.eclipse.org/bugs/show_bug.cgi?id=218655#c1 for details.
|
||||
*/
|
||||
public boolean isEnabled(Object object) {
|
||||
public final boolean isEnabled(Object object) {
|
||||
IRSESystemType systemType = getSystemType(object);
|
||||
if ( systemType != null && RSEPreferencesManager.getIsSystemTypeEnabled(systemType)) {
|
||||
// if enabled, check if the system type has any registered subsystems. If
|
||||
// not, this will auto-disable the system type.
|
||||
ISubSystemConfigurationProxy[] proxies = RSECorePlugin.getTheSystemRegistry().getSubSystemConfigurationProxies();
|
||||
for (int i=0; i<proxies.length; i++) {
|
||||
if (proxies[i].appliesToSystemType(systemType)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (systemType != null) {
|
||||
return systemType.isEnabled();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the enabled state of a particular system type.
|
||||
* <p>
|
||||
* Note that system types which are provided by extenders via the dynamic
|
||||
* sytemTypeProviders extension point may have their own logic to determine
|
||||
* whether they are enabled or not, so changing the enabled setting may
|
||||
* not work for them.
|
||||
*
|
||||
* @param object The system type being adapted.
|
||||
* @param isEnabled true if the system type is enabled. false if it is not.
|
||||
* @deprecated Set the enabled state in {@link RSEPreferencesManager} directly
|
||||
*/
|
||||
public void setIsEnabled(Object object, boolean isEnabled) {
|
||||
IRSESystemType systemType = getSystemType(object);
|
||||
|
|
Loading…
Add table
Reference in a new issue