mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-10 12:03:16 +02:00
[fix] Bug 245039 [contributions][api] Provide property tester implementations in parallel to the older action filters
This commit is contained in:
parent
35924fe422
commit
728c02223c
2 changed files with 80 additions and 0 deletions
|
@ -0,0 +1,69 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009 Wind River Systems, Inc. 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:
|
||||
* Uwe Stieber (Wind River) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.ui.view;
|
||||
|
||||
import org.eclipse.core.expressions.PropertyTester;
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.rse.ui.view.AbstractSystemViewAdapter;
|
||||
import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
|
||||
|
||||
/**
|
||||
* Default RSE System View property tester to support org.eclipse.ui.menu extension
|
||||
* point contributions.
|
||||
*/
|
||||
public class SystemViewPropertyTester extends PropertyTester {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
|
||||
*/
|
||||
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
|
||||
// The receiver must be the real object and not the adapter itself. Otherwise
|
||||
// most of the property testings will fail and will evaluate to false.
|
||||
//
|
||||
// Therefor, do not use the property tester within an <adapt> expression
|
||||
// where the target adapter type is ISystemViewElementAdapter.
|
||||
//
|
||||
// Example where the testing will fail:
|
||||
// ...
|
||||
// <adapt type="org.eclipse.rse.ui.view.ISystemViewElementAdapter">
|
||||
// <test property=org.eclipse.rse.ui.systemTypeId" value="org.eclipse.rse.systemtype.local"/>
|
||||
// </adapt>
|
||||
// ...
|
||||
//
|
||||
assert !(receiver instanceof AbstractSystemViewAdapter);
|
||||
|
||||
ISystemViewElementAdapter adapter = null;
|
||||
// Try to adapt the receiver to an ISystemViewElement adapter.
|
||||
if (receiver instanceof IAdaptable) {
|
||||
// Use IAdaptable#getAdapter(...) instead of Platform.getAdapterManager().getAdapter(...) to
|
||||
// give element contributors the chance to provide custom adapter implementations even if there
|
||||
// is an adapter factory registered providing element adaptation to ISystemViewElementAdapter.
|
||||
// This way we can take away a lot of pain from contributors otherwise struggeling with adapter factories.
|
||||
adapter = (ISystemViewElementAdapter)((IAdaptable)receiver).getAdapter(ISystemViewElementAdapter.class);
|
||||
} else {
|
||||
// Fallback to the adapter manager
|
||||
adapter = (ISystemViewElementAdapter)Platform.getAdapterManager().getAdapter(receiver, ISystemViewElementAdapter.class);
|
||||
}
|
||||
|
||||
// If we succeeded to adapt to ISystemViewElementAdapter and the expected value is
|
||||
// of string type (IActionFilter#test(...) supports string testing only, we can
|
||||
// forward the property test to the original IActionFilter test implementation.
|
||||
if (adapter != null && expectedValue instanceof String) {
|
||||
return adapter.testAttribute(receiver, property, (String)expectedValue);
|
||||
}
|
||||
|
||||
// Return false in any case the adaptation fails or if the expected
|
||||
// value is not of String type.
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -20,6 +20,7 @@ Anna Dushistova (MontaVista) - [227535] [rseterminal][api] terminals.ui should
|
|||
Anna Dushistova (MontaVista) - [234274][api] Launch Shell / Terminal commands menu placement and category
|
||||
David McKnight (IBM) - [160105] [usability] Universal action needed to locate a resource in the Remote Systems View
|
||||
David McKnight (IBM) - [260792] Default prompt text color/background color for Remote Shell view is difficult to see
|
||||
Uwe Stieber (Wind River) - [245039] [contributions][api] Provide property tester implementations in parallel to the older action filters
|
||||
-->
|
||||
<?eclipse version="3.1"?>
|
||||
<plugin>
|
||||
|
@ -498,6 +499,9 @@ David McKnight (IBM) - [260792] Default prompt text color/background co
|
|||
</viewerContentBinding>
|
||||
</extension>
|
||||
|
||||
<!-- ================================================================= -->
|
||||
<!-- RSE Property Tester contributions -->
|
||||
<!-- ================================================================= -->
|
||||
<extension point="org.eclipse.core.expressions.propertyTesters">
|
||||
<propertyTester
|
||||
id="org.eclipse.rse.ui.SubSystemPropertyTester"
|
||||
|
@ -506,6 +510,13 @@ David McKnight (IBM) - [260792] Default prompt text color/background co
|
|||
properties="hasSubSystemCategory, isOffline"
|
||||
class="org.eclipse.rse.internal.ui.subsystems.SubSystemPropertyTester">
|
||||
</propertyTester>
|
||||
<propertyTester
|
||||
class="org.eclipse.rse.internal.ui.view.SystemViewPropertyTester"
|
||||
id="org.eclipse.rse.internal.ui.view.SystemViewPropertyTester"
|
||||
namespace="org.eclipse.rse.ui"
|
||||
properties="name,type,hasChildren,connected,offline,systemType,systemTypeId,subsystemConfigurationId,subsystemConfigurationCategory,isRemote"
|
||||
type="org.eclipse.rse.ui.view.ISystemViewElementAdapter">
|
||||
</propertyTester>
|
||||
</extension>
|
||||
|
||||
<extension point="org.eclipse.ui.commands">
|
||||
|
|
Loading…
Add table
Reference in a new issue