下面列出了怎么用org.eclipse.ui.views.properties.IPropertySource的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
public IPropertySource getPropertySource ( final Object object )
{
// this one has priority in super class
if ( object instanceof IPropertySource )
{
return (IPropertySource)object;
}
// allow the object to adapt to IPropertySource
if ( object instanceof EObject && ( (EObject)object ).eClass () != null )
{
final IPropertySource propertySource = (IPropertySource)this.adapterFactory.adapt ( object, IPropertySource.class );
if ( propertySource != null )
{
return propertySource;
}
}
// fall back to default behavior
return super.getPropertySource ( object );
}
@Override
public Object getAdapter(Object element, @SuppressWarnings("rawtypes") Class key) {
IXdsElement e = (IXdsElement)element;
if (IResource.class.isAssignableFrom(key)) {
return XdsElementUtils.adaptToResource(e, key);
}
if (IPropertySource.class.equals(key)) {
return getProperties(XdsElementUtils.adaptToResource(e, IResource.class));
}
else if (IWorkbenchAdapter.class.equals(key)) {
if (xdsWorkbenchAdapter == null) {
xdsWorkbenchAdapter = new XdsWorkbenchAdapter();
}
return xdsWorkbenchAdapter;
}
else if (IContributorResourceAdapter.class.equals(key)) {
return this;
}
return null;
}
@Override
public void setValues(Object[] objects) {
if (objects == null || objects.length == 0) {
if (workbenchPart != null) {
IPropertySource source = (IPropertySource) workbenchPart
.getAdapter(IPropertySource.class);
if (source != null) {
// wrap source itself; it will be unwrapped by super
// implementation and then passed to
// #getPropertySource(Object), which will return it, so the
// editable value can be retrieved from it
objects = new Object[] { source };
}
}
}
super.setValues(objects);
}
@Override
@SuppressWarnings("rawtypes")
public Object getAdapter(Object adaptableObject, Class adapterType) {
if (adapterType == IPropertySheetPage.class) {
if (adaptableObject instanceof BugExplorerView || adaptableObject instanceof AbstractFindbugsView) {
return new BugPropertySheetPage();
}
}
if (adapterType == IPropertySource.class) {
if (adaptableObject instanceof BugPattern || adaptableObject instanceof BugInstance
|| adaptableObject instanceof DetectorFactory || adaptableObject instanceof Plugin
|| adaptableObject instanceof BugGroup
|| adaptableObject instanceof BugAnnotation) {
return new PropertySource(adaptableObject);
}
IMarker marker = Util.getAdapter(IMarker.class, adaptableObject);
if (!MarkerUtil.isFindBugsMarker(marker)) {
return null;
}
return new MarkerPropertySource(marker);
}
return null;
}
/**
* Method declared on IAdapterFactory.
* Get the given adapter for the given object
*/
public Object getAdapter(Object adaptableObject, Class adapterType) {
if (IWorkbenchAdapter.class == adapterType) {
return getWorkbenchAdapter(adaptableObject);
}
if(IDeferredWorkbenchAdapter.class == adapterType) {
Object o = getWorkbenchAdapter(adaptableObject);
if(o != null && o instanceof IDeferredWorkbenchAdapter) {
return o;
}
return null;
}
if (IPropertySource.class == adapterType) {
return getPropertySource(adaptableObject);
}
if(IHistoryPageSource.class == adapterType) {
return pageHistoryParticipant;
}
return null;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public Object getAdapter(Object adaptableObject, Class adapterType) {
if(!(adaptableObject instanceof HybridPluginFolder))
return null;
HybridPluginFolder pluginFolder = (HybridPluginFolder)adaptableObject;
if(IPropertySource.class.equals(adapterType)){
return new CordovaPluginProperties(pluginFolder);
}
if(IWorkbenchAdapter.class.equals(adapterType)){
return new CordovaPluginWorkbenchAdapter();
}
if(IResource.class.equals(adapterType)){
return pluginFolder.getFolder();
}
return null;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public Object getAdapter(Object adaptableObject, Class adapterType) {
if(!(adaptableObject instanceof HybridPlatformFolder))
return null;
HybridPlatformFolder platform = (HybridPlatformFolder)adaptableObject;
if(IPropertySource.class.equals(adapterType)){
return new CordovaPlatformProperties(platform);
}
if(IWorkbenchAdapter.class.equals(adapterType)){
return new CordovaPlatformWorkbenchAdapter();
}
if(IResource.class.equals(adapterType)){
return platform.getFolder();
}
return null;
}
public boolean performFinish(final ContractConstraint constraintToUpdate,
final IPropertySourceProvider propertySourceProvider) {
final IPropertySource constraintPropertySource = propertySourceProvider.getPropertySource(constraintToUpdate);
constraintPropertySource.setPropertyValue(ProcessPackage.Literals.CONTRACT_CONSTRAINT__EXPRESSION,
constraint.getExpression());
if (inputIndexer != null) {
try {
inputIndexer.join();
} catch (final InterruptedException e) {
BonitaStudioLog.error("Failed to join input indexer job.", e, ContractPlugin.PLUGIN_ID);
return false;
}
}
constraintPropertySource.setPropertyValue(ProcessPackage.Literals.CONTRACT_CONSTRAINT__INPUT_NAMES,
constraint.getInputNames());
return true;
}
@Override
public <T> T getAdapter ( final Class<T> adapter )
{
logger.debug ( "Adapting: {}", adapter );
if ( adapter == ConnectionService.class )
{
return adapter.cast ( this.connectionService );
}
else if ( adapter == IPropertySource.class )
{
return adapter.cast ( new PropertySourceWrapper ( this ) );
}
return null;
}
@Override
public <T> T getAdapter ( final Object adaptableObject, final Class<T> adapterType )
{
logger.debug ( "Adapting: {} to {}", adaptableObject, adapterType );
if ( adaptableObject instanceof ConnectionHolder && adapterType == IPropertySource.class )
{
return adapterType.cast ( new PropertySourceWrapper ( (ConnectionHolder)adaptableObject ) );
}
if ( adaptableObject instanceof IAdaptable )
{
return ( (IAdaptable)adaptableObject ).getAdapter ( adapterType );
}
return null;
}
@Override
@SuppressWarnings ( "rawtypes" )
public Object getAdapter ( final Class adapter )
{
if ( adapter == IPropertySource.class )
{
return new ItemPropertySource ( this );
}
else if ( adapter == Item.class )
{
return makeItem ();
}
return super.getAdapter ( adapter );
}
/**
* This constructs an instance.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated NOT
*/
public IEC60870ItemProviderAdapterFactory ()
{
this.supportedTypes.add ( IEditingDomainItemProvider.class );
this.supportedTypes.add ( IStructuredItemContentProvider.class );
this.supportedTypes.add ( ITreeItemContentProvider.class );
this.supportedTypes.add ( IItemLabelProvider.class );
this.supportedTypes.add ( IItemPropertySource.class );
this.supportedTypes.add ( IPropertySource.class );
}
public Object getAdapter(Object adaptableObject, Class adapterType) {
if (adaptableObject instanceof crossflow.diagram.navigator.CrossflowDomainNavigatorItem) {
crossflow.diagram.navigator.CrossflowDomainNavigatorItem domainNavigatorItem = (crossflow.diagram.navigator.CrossflowDomainNavigatorItem) adaptableObject;
EObject eObject = domainNavigatorItem.getEObject();
if (adapterType == EObject.class) {
return eObject;
}
if (adapterType == IPropertySource.class) {
return domainNavigatorItem.getPropertySourceProvider().getPropertySource(eObject);
}
}
return null;
}
private IPropertySource getProperties(IResource resource) {
if (resource == null) {
return null;
}
if (resource instanceof IFile) {
return new FilePropertySource((IFile) resource);
}
else {
return new ResourcePropertySource(resource);
}
}
@Override
@SuppressWarnings("rawtypes")
public Object getAdapter(Object adaptableObject, Class adapterType) {
if (IPropertySource.class.equals(adapterType)) {
if (adaptableObject instanceof Node) {
return new NodePropertySource((Node) adaptableObject);
}
}
return null;
}
@Override
protected IPropertySource getPropertySource(Object object) {
if (object instanceof IPropertySource) {
return (IPropertySource) object;
}
return super.getPropertySource(object);
}
/**
* @see org.eclipse.ui.views.properties.IPropertySheetEntry#resetPropertyValue()
*/
@Override
public void resetPropertyValue() {
ICompositeOperation cc = new ReverseUndoCompositeOperation("");
if (getParent() == null) {
// root does not have a default value
return;
}
// Use our parent's values to reset our values.
boolean change = false;
Object[] objects = getParent().getValues();
for (int i = 0; i < objects.length; i++) {
IPropertySource source = getPropertySource(objects[i]);
if (source.isPropertySet(getDescriptor().getId())) {
SetPropertyValueOperation restoreCmd = new SetPropertyValueOperation(
getDescriptor().getDisplayName(), source,
getDescriptor().getId(),
SetPropertyValueOperation.DEFAULT_VALUE);
cc.add(restoreCmd);
change = true;
}
}
if (change) {
try {
getOperationHistory().execute(cc, new NullProgressMonitor(),
null);
} catch (ExecutionException e) {
e.printStackTrace();
}
refreshFromRoot();
}
}
private static IPropertyDescriptor getPropertyDescriptor(
IPropertySource propertySource, Object propertyId) {
for (IPropertyDescriptor propertyDescriptor : propertySource
.getPropertyDescriptors()) {
if (propertyDescriptor.getId().equals(propertyId)) {
return propertyDescriptor;
}
}
return null;
}
@Override
@SuppressWarnings("rawtypes")
public Object getAdapter(Object adaptableObject, Class adapterType) {
if (IPropertySource.class.equals(adapterType)) {
if (adaptableObject instanceof GeometricCurve) {
return new GeometricCurvePropertySource(
(GeometricCurve) adaptableObject);
} else if (adaptableObject instanceof GeometricShape) {
return new GeometricShapePropertySource(
(GeometricShape) adaptableObject);
}
}
return null;
}
@Override
public IPropertySource getPropertySource(final Object object) {
if (object instanceof ERDiagramEditPart) {
final ERDiagram diagram = (ERDiagram) ((ERDiagramEditPart) object).getModel();
return new ERDiagramPropertySource(editor, diagram);
} else if (object instanceof ERTableEditPart) {
final ERTable table = (ERTable) ((ERTableEditPart) object).getModel();
return new ERTablePropertySource(editor, table);
}
return null;
}
@Override
public <T> T getAdapter(Object element, Class<T> adapterType) {
ITmfEvent tmfEvent = (ITmfEvent) element;
if (IPropertySource.class.equals(adapterType)) {
return adapterType.cast(new TmfEventPropertySource(tmfEvent));
}
return null;
}
@Override
public <T> T getAdapter(Object element, Class<T> adapterType) {
if (element instanceof BtfEvent && IPropertySource.class.equals(adapterType)) {
BtfEvent tmfEvent = (BtfEvent) element;
return adapterType.cast(new BtfEventPropertySource(tmfEvent));
}
return null;
}
@Override
public <T> T getAdapter(Class<T> adapter) {
if (adapter == IPropertySource.class) {
return adapter.cast(new BaseLoggerPropertySource(this));
}
return null;
}
@Override
public <T> T getAdapter(Class<T> adapter) {
if (adapter == IPropertySource.class) {
return adapter.cast(new UstProviderPropertySource(this));
}
return null;
}
@Override
public <T> @Nullable T getAdapter(Class<T> adapter) {
if (adapter == IPropertySource.class) {
return adapter.cast(new TargetNodePropertySource(this));
}
return null;
}
@Override
public <T> T getAdapter(Class<T> adapter) {
if (adapter == IPropertySource.class) {
return adapter.cast(new TraceChannelPropertySource(this));
}
return null;
}
@Override
public <T> T getAdapter(Class<T> adapter) {
if (adapter == IPropertySource.class) {
return adapter.cast(new TraceLoggerPropertySource(this));
}
return null;
}
@Override
public <T> T getAdapter(Class<T> adapter) {
if (adapter == IPropertySource.class) {
return adapter.cast(new TraceDomainPropertySource(this));
}
return null;
}
@Override
public <T> T getAdapter(Class<T> adapter) {
if (adapter == IPropertySource.class) {
return adapter.cast(new TraceSessionPropertySource(this));
}
return null;
}
@Override
public <T> T getAdapter(Class<T> adapter) {
if (adapter == IPropertySource.class) {
return adapter.cast(new BaseEventPropertySource(this));
}
return null;
}