Java Code Examples for org.eclipse.ui.views.properties.IPropertySource

The following examples show how to use org.eclipse.ui.views.properties.IPropertySource. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
@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 );
}
 
Example 2
Source Project: xds-ide   Source File: XdsElementAdapterFactory.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@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;
  }
 
Example 3
Source Project: gef   Source File: UndoablePropertySheetEntry.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@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);
}
 
Example 4
@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;
}
 
Example 5
/**
 * 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;
}
 
Example 6
Source Project: thym   Source File: CordovaPluginAdapterFactory.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@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;
}
 
Example 7
@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;
}
 
Example 8
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;
}
 
Example 9
Source Project: neoscada   Source File: ConnectionHolder.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@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;
}
 
Example 10
@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;
}
 
Example 11
Source Project: neoscada   Source File: ItemWrapper.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@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 );
}
 
Example 12
/**
 * 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 );
}
 
Example 13
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;
}
 
Example 14
Source Project: xds-ide   Source File: XdsElementAdapterFactory.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private IPropertySource getProperties(IResource resource) {
	if (resource == null) {
		return null;
	}
    if (resource instanceof IFile) {
        return new FilePropertySource((IFile) resource);
    }
    else {
        return new ResourcePropertySource(resource);
    }
}
 
Example 15
Source Project: gef   Source File: PropertySourceAdapterFactory.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@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;
}
 
Example 16
Source Project: gef   Source File: UndoablePropertySheetEntry.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected IPropertySource getPropertySource(Object object) {
	if (object instanceof IPropertySource) {
		return (IPropertySource) object;
	}
	return super.getPropertySource(object);
}
 
Example 17
Source Project: gef   Source File: UndoablePropertySheetEntry.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @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();
	}
}
 
Example 18
Source Project: gef   Source File: SetPropertyValueOperation.java    License: Eclipse Public License 2.0 5 votes vote down vote up
private static IPropertyDescriptor getPropertyDescriptor(
		IPropertySource propertySource, Object propertyId) {
	for (IPropertyDescriptor propertyDescriptor : propertySource
			.getPropertyDescriptors()) {
		if (propertyDescriptor.getId().equals(propertyId)) {
			return propertyDescriptor;
		}
	}
	return null;
}
 
Example 19
Source Project: gef   Source File: PropertySourceAdapterFactory.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@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;
}
 
Example 20
Source Project: ermasterr   Source File: ERDiagramPropertySourceProvider.java    License: Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 21
@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;
}
 
Example 22
@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;
}
 
Example 23
Source Project: tracecompass   Source File: BaseLoggerComponent.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Override
public <T> T getAdapter(Class<T> adapter) {
    if (adapter == IPropertySource.class) {
        return adapter.cast(new BaseLoggerPropertySource(this));
    }
    return null;
}
 
Example 24
Source Project: tracecompass   Source File: UstProviderComponent.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Override
public <T> T getAdapter(Class<T> adapter) {
    if (adapter == IPropertySource.class) {
        return adapter.cast(new UstProviderPropertySource(this));
    }
    return null;
}
 
Example 25
Source Project: tracecompass   Source File: TargetNodeComponent.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Override
public <T> @Nullable T getAdapter(Class<T> adapter) {
    if (adapter == IPropertySource.class) {
        return adapter.cast(new TargetNodePropertySource(this));
    }
    return null;
}
 
Example 26
@Override
public <T> T getAdapter(Class<T> adapter) {
    if (adapter == IPropertySource.class) {
        return adapter.cast(new TraceChannelPropertySource(this));
    }
    return null;
}
 
Example 27
Source Project: tracecompass   Source File: TraceLoggerComponent.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Override
public <T> T getAdapter(Class<T> adapter) {
    if (adapter == IPropertySource.class) {
        return adapter.cast(new TraceLoggerPropertySource(this));
    }
    return null;
}
 
Example 28
Source Project: tracecompass   Source File: TraceDomainComponent.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Override
public <T> T getAdapter(Class<T> adapter) {
    if (adapter == IPropertySource.class) {
        return adapter.cast(new TraceDomainPropertySource(this));
    }
    return null;
}
 
Example 29
@Override
public <T> T getAdapter(Class<T> adapter) {
    if (adapter == IPropertySource.class) {
        return adapter.cast(new TraceSessionPropertySource(this));
    }
    return null;
}
 
Example 30
Source Project: tracecompass   Source File: BaseEventComponent.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Override
public <T> T getAdapter(Class<T> adapter) {
    if (adapter == IPropertySource.class) {
        return adapter.cast(new BaseEventPropertySource(this));
    }
    return null;
}