本文整理汇总了Java中org.eclipse.core.expressions.EvaluationContext类的典型用法代码示例。如果您正苦于以下问题:Java EvaluationContext类的具体用法?Java EvaluationContext怎么用?Java EvaluationContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EvaluationContext类属于org.eclipse.core.expressions包,在下文中一共展示了EvaluationContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCopyUrl
import org.eclipse.core.expressions.EvaluationContext; //导入依赖的package包/类
@Test
public void testCopyUrl() throws ExecutionException {
// Given
String url = "https://github.com/cchabanois/mesfavoris";
Bookmark bookmark = new Bookmark(new BookmarkId(),
ImmutableMap.of(UrlBookmarkProperties.PROP_URL, url));
IEvaluationContext context = new EvaluationContext(null, new Object());
context.addVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME, new StructuredSelection(bookmark));
ExecutionEvent event = new ExecutionEvent(null, new HashMap<>(), null, context);
// When
CopyBookmarkUrlHandler handler = new CopyBookmarkUrlHandler();
executeHandler(handler, event);
// Then
assertEquals(url, getClipboardContents());
}
示例2: getServerModule
import org.eclipse.core.expressions.EvaluationContext; //导入依赖的package包/类
protected IServerModule getServerModule(Object context) {
Object toCheck = context;
if (toCheck instanceof EvaluationContext) {
toCheck = ((EvaluationContext) toCheck).getDefaultVariable();
}
if (toCheck instanceof List<?>) {
List<?> content = (List<?>) toCheck;
if (!content.isEmpty()) {
Object obj = content.get(0);
if (obj instanceof IServerModule) {
return (IServerModule) obj;
}
}
}
return null;
}
示例3: matches
import org.eclipse.core.expressions.EvaluationContext; //导入依赖的package包/类
/**
* Determines if the project matches any enablement expression defined on the extension.
*
* @param javaProject the Java project against which to test the enablement expression, can be
* <code>null</code>
* @return <code>true</code> if any enablement expression matches the given project or if the
* project is <code>null</code> or no enablement expression is specified,
* <code>false</code> otherwise
* @since 3.8
*/
public boolean matches(IJavaProject javaProject) {
if (fEnablementExpression == null) {
return true;
}
if (javaProject == null) {
return false;
}
try {
EvaluationContext evalContext= new EvaluationContext(null, javaProject);
evalContext.addVariable("project", javaProject); //$NON-NLS-1$
return fEnablementExpression.evaluate(evalContext) == EvaluationResult.TRUE;
} catch (CoreException e) {
JavaPlugin.log(e);
}
return false;
}
示例4: matches
import org.eclipse.core.expressions.EvaluationContext; //导入依赖的package包/类
public boolean matches(IJavaProject javaProject) {
if (fStatus != null) {
return fStatus.booleanValue();
}
IConfigurationElement[] children= fConfigurationElement.getChildren(ExpressionTagNames.ENABLEMENT);
if (children.length == 1) {
try {
ExpressionConverter parser= ExpressionConverter.getDefault();
Expression expression= parser.perform(children[0]);
EvaluationContext evalContext= new EvaluationContext(null, javaProject);
evalContext.addVariable("project", javaProject); //$NON-NLS-1$
evalContext.addVariable("sourceLevel", javaProject.getOption(JavaCore.COMPILER_SOURCE, true)); //$NON-NLS-1$
return expression.evaluate(evalContext) == EvaluationResult.TRUE;
} catch (CoreException e) {
JavaPlugin.log(e);
}
return false;
}
fStatus= Boolean.FALSE;
return false;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:23,代码来源:ClasspathFixProcessorDescriptor.java
示例5: createEditPart
import org.eclipse.core.expressions.EvaluationContext; //导入依赖的package包/类
public static EditPart createEditPart( EditPart context, Object model )
{
EvaluationContext econtext = new EvaluationContext( null, model );
for ( Iterator<Expression> iterator = extensionMap.keySet( ).iterator( ); iterator.hasNext( ); )
{
try
{
Expression expression = iterator.next( );
if ( expression.evaluate( econtext ) == EvaluationResult.TRUE )
{
EditPart editPart = (EditPart) extensionMap.get( expression )
.createExecutableExtension( "type" ); //$NON-NLS-1$
editPart.setModel( model );
return editPart;
}
}
catch ( CoreException e )
{
logger.log( Level.SEVERE, e.getMessage( ), e );
}
}
return null;
}
示例6: createEvaluationContext
import org.eclipse.core.expressions.EvaluationContext; //导入依赖的package包/类
private static EvaluationContext createEvaluationContext(
RefactoringProcessor processor, Object element, String[] affectedNatures) {
EvaluationContext result = new EvaluationContext(null, element);
result.setAllowPluginActivation(true);
result.addVariable("element", element); // $NON-NLS-1$
result.addVariable("affectedNatures", Arrays.asList(affectedNatures)); // $NON-NLS-1$
result.addVariable("processorIdentifier", processor.getIdentifier()); // $NON-NLS-1$
return result;
}
示例7: createEvaluationContext
import org.eclipse.core.expressions.EvaluationContext; //导入依赖的package包/类
private IEvaluationContext createEvaluationContext( ISelection selection ) {
IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow();
IEvaluationContext result = new EvaluationContext( null, new Object() );
result.addVariable( ISources.ACTIVE_WORKBENCH_WINDOW_NAME, activeWorkbenchWindow );
result.addVariable( ISources.ACTIVE_CURRENT_SELECTION_NAME, selection );
return result;
}
示例8: createEvaluationContext
import org.eclipse.core.expressions.EvaluationContext; //导入依赖的package包/类
private IEvaluationContext createEvaluationContext( Object editorInput ) {
IWorkbenchWindow activeWorkbenchWindow = workbenchPage.getWorkbenchWindow();
IEvaluationContext result = new EvaluationContext( null, new Object() );
result.addVariable( ISources.ACTIVE_WORKBENCH_WINDOW_NAME, activeWorkbenchWindow );
if( editorInput != null ) {
result.addVariable( ISources.ACTIVE_EDITOR_INPUT_NAME, editorInput );
}
return result;
}
示例9: createEvaluationContext
import org.eclipse.core.expressions.EvaluationContext; //导入依赖的package包/类
private IEvaluationContext createEvaluationContext( IWorkbenchPart activePart ) {
IWorkbenchWindow activeWorkbenchWindow = workbenchPage.getWorkbenchWindow();
IEvaluationContext result = new EvaluationContext( null, new Object() );
result.addVariable( ISources.ACTIVE_WORKBENCH_WINDOW_NAME, activeWorkbenchWindow );
if( activePart != null ) {
result.addVariable( ISources.ACTIVE_PART_NAME, activePart );
}
return result;
}
示例10: getEnabledTextHoverDescriptors
import org.eclipse.core.expressions.EvaluationContext; //导入依赖的package包/类
private List<TextHoverDescriptor> getEnabledTextHoverDescriptors(ITextViewer textViewer, int offset)
{
List<TextHoverDescriptor> result = new ArrayList<TextHoverDescriptor>();
if (fTextEditor == null)
{
return result;
}
try
{
QualifiedContentType contentType = CommonEditorPlugin.getDefault().getDocumentScopeManager()
.getContentType(textViewer.getDocument(), offset);
IEvaluationContext context = new EvaluationContext(null, textViewer);
IWorkbenchPartSite site = fTextEditor.getSite();
if (site != null)
{
context.addVariable(ISources.ACTIVE_EDITOR_ID_NAME, site.getId());
}
for (TextHoverDescriptor descriptor : TextHoverDescriptor.getContributedHovers())
{
if (descriptor.isEnabledFor(contentType, context))
{
result.add(descriptor);
}
}
}
catch (BadLocationException e)
{
}
return result;
}
示例11: matches
import org.eclipse.core.expressions.EvaluationContext; //导入依赖的package包/类
private boolean matches(ICompilationUnit cunit) {
if (fRequiredSourceLevel != null) {
String current= cunit.getJavaProject().getOption(JavaCore.COMPILER_SOURCE, true);
if (JavaModelUtil.isVersionLessThan(current, fRequiredSourceLevel)) {
return false;
}
}
if (fStatus != null) {
return fStatus.booleanValue();
}
IConfigurationElement[] children= fConfigurationElement.getChildren(ExpressionTagNames.ENABLEMENT);
if (children.length == 1) {
try {
ExpressionConverter parser= ExpressionConverter.getDefault();
Expression expression= parser.perform(children[0]);
EvaluationContext evalContext= new EvaluationContext(null, cunit);
evalContext.addVariable("compilationUnit", cunit); //$NON-NLS-1$
IJavaProject javaProject= cunit.getJavaProject();
String[] natures= javaProject.getProject().getDescription().getNatureIds();
evalContext.addVariable("projectNatures", Arrays.asList(natures)); //$NON-NLS-1$
evalContext.addVariable("sourceLevel", javaProject.getOption(JavaCore.COMPILER_SOURCE, true)); //$NON-NLS-1$
return expression.evaluate(evalContext) == EvaluationResult.TRUE;
} catch (CoreException e) {
JavaPlugin.log(e);
}
return false;
}
fStatus= Boolean.FALSE;
return false;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:33,代码来源:ContributedProcessorDescriptor.java
示例12: getAdapterList
import org.eclipse.core.expressions.EvaluationContext; //导入依赖的package包/类
private static List getAdapterList( Object adaptableObject,
Class adatperType )
{
Set adapters = getAdapters( adaptableObject );
if ( adapters == null )
return null;
List adapterObjects = new ArrayList( );
l: for ( Iterator iter = adapters.iterator( ); iter.hasNext( ); )
{
ElementAdapter adapter = (ElementAdapter) iter.next( );
if ( adapter.getExpression( ) != null )
{
EvaluationContext context = new EvaluationContext( null,
adaptableObject );
context.setAllowPluginActivation( true );
try
{
if ( adapter.getExpression( ).evaluate( context ) != EvaluationResult.TRUE )
continue l;
}
catch ( CoreException e )
{
}
}
Object obj = adapter.getAdater( adaptableObject );
if ( obj != null && adatperType.isAssignableFrom( obj.getClass( ) ) )
{
adapterObjects.add( obj );
}
}
return adapterObjects;
}
示例13: createContext
import org.eclipse.core.expressions.EvaluationContext; //导入依赖的package包/类
private IEvaluationContext createContext(Object selection) {
IEvaluationContext context = new EvaluationContext(null, selection);
context.addVariable("selection", selection); //$NON-NLS-1$
return context;
}
示例14: createEvaluationContext
import org.eclipse.core.expressions.EvaluationContext; //导入依赖的package包/类
private IEvaluationContext createEvaluationContext() {
IEvaluationContext result = new EvaluationContext( null, new Object() );
result.addVariable( ACTIVE_WORKBENCH_WINDOW_NAME, workbenchWindow );
return result;
}
示例15: openFilterDialog
import org.eclipse.core.expressions.EvaluationContext; //导入依赖的package包/类
void openFilterDialog() {
final IEvaluationContext ec = new EvaluationContext(null, this);
ec.addVariable(ISources.ACTIVE_PART_NAME, this);
final ExecutionEvent ev = new ExecutionEvent(null, new HashMap<>(), this, ec);
new ConfigureContentsDialogHandler().execute(ev);
}