当前位置: 首页>>代码示例>>Java>>正文


Java IEvaluationContext类代码示例

本文整理汇总了Java中org.eclipse.core.expressions.IEvaluationContext的典型用法代码示例。如果您正苦于以下问题:Java IEvaluationContext类的具体用法?Java IEvaluationContext怎么用?Java IEvaluationContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IEvaluationContext类属于org.eclipse.core.expressions包,在下文中一共展示了IEvaluationContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getVariable

import org.eclipse.core.expressions.IEvaluationContext; //导入依赖的package包/类
private static <T> Optional<T> getVariable(final String variableName, final Class<T> expectedClass) {

		if (isNullOrEmpty(variableName) || null == expectedClass) {
			return absent();
		}

		final Optional<IEvaluationContext> state = getCurrentWorkbenchState();
		if (!state.isPresent()) {
			return absent();
		}

		final Object variable = state.get().getVariable(variableName);
		if (null == variable || UNDEFINED_VARIABLE == variable) {
			return absent();
		}

		if (expectedClass.isAssignableFrom(variable.getClass())) {
			return fromNullable(expectedClass.cast(variable));
		}

		return absent();
	}
 
开发者ID:eclipse,项目名称:n4js,代码行数:23,代码来源:HandlerServiceUtils.java

示例2: testCopyUrl

import org.eclipse.core.expressions.IEvaluationContext; //导入依赖的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());
}
 
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:18,代码来源:CopyBookmarkUrlHandlerTest.java

示例3: getProjectFromContext

import org.eclipse.core.expressions.IEvaluationContext; //导入依赖的package包/类
protected IProject getProjectFromContext(Object context) {
	IProject project = null;
	if (context instanceof IEvaluationContext) {

		Object evalContext = ((IEvaluationContext) context)
				.getDefaultVariable();

		if (evalContext instanceof List<?>) {
			List<?> content = (List<?>) evalContext;
			if (!content.isEmpty()) {
				evalContext = content.get(0);
			}
		}

		if (evalContext instanceof IProject) {
			project = (IProject) evalContext;
		} else if (evalContext instanceof IAdaptable) {
			project = (IProject) ((IAdaptable) evalContext)
					.getAdapter(IProject.class);
		}
	}
	return project;
}
 
开发者ID:eclipse,项目名称:cft,代码行数:24,代码来源:ProjectExplorerMenuFactory.java

示例4: createContributionItems

import org.eclipse.core.expressions.IEvaluationContext; //导入依赖的package包/类
@Override
public void createContributionItems(IServiceLocator serviceLocator, IContributionRoot additions) {
	IMenuService menuService = (IMenuService) serviceLocator.getService(IMenuService.class);
	if (menuService == null) {
		CloudFoundryPlugin
				.logError("Unable to retrieve Eclipse menu service. Cannot add Cloud Foundry context menus."); //$NON-NLS-1$
		return;
	}

	List<IAction> debugActions = getActions(menuService);
	for (IAction action : debugActions) {
		additions.addContributionItem(new ActionContributionItem(action), new Expression() {
			public EvaluationResult evaluate(IEvaluationContext context) {
				return EvaluationResult.TRUE;
			}

			public void collectExpressionInfo(ExpressionInfo info) {
			}
		});
	}
}
 
开发者ID:eclipse,项目名称:cft,代码行数:22,代码来源:AbstractMenuContributionFactory.java

示例5: createContributionItems

import org.eclipse.core.expressions.IEvaluationContext; //导入依赖的package包/类
@Override
public void createContributionItems(IServiceLocator serviceLocator, IContributionRoot additions) {
	IMenuService menuService = (IMenuService) serviceLocator.getService(IMenuService.class);
	if (menuService == null) {
		DockerFoundryPlugin
				.logError("Unable to retrieve Eclipse menu service. Cannot add Cloud Foundry context menus."); //$NON-NLS-1$
		return;
	}

	List<IAction> debugActions = getActions(menuService);
	for (IAction action : debugActions) {
		additions.addContributionItem(new ActionContributionItem(action), new Expression() {
			public EvaluationResult evaluate(IEvaluationContext context) {
				return EvaluationResult.TRUE;
			}

			public void collectExpressionInfo(ExpressionInfo info) {
			}
		});
	}
}
 
开发者ID:osswangxining,项目名称:dockerfoundry,代码行数:22,代码来源:AbstractMenuContributionFactory.java

示例6: matches

import org.eclipse.core.expressions.IEvaluationContext; //导入依赖的package包/类
public boolean matches(
    IEvaluationContext context, IParticipantDescriptorFilter filter, RefactoringStatus status)
    throws CoreException {
  //		IConfigurationElement[] elements=
  // fConfigurationElement.getChildren(ExpressionTagNames.ENABLEMENT);
  //		if (elements.length == 0)
  //			return false;
  //		Assert.isTrue(elements.length == 1);
  //		Expression exp= ExpressionConverter.getDefault().perform(elements[0]);
  //		if (!convert(exp.evaluate(context)))
  //			return false;
  //		if (filter != null && !filter.select(fConfigurationElement, status))
  //			return false;

  return true;
}
 
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:ParticipantDescriptor.java

示例7: setEnabled

import org.eclipse.core.expressions.IEvaluationContext; //导入依赖的package包/类
@Override
public void setEnabled(Object evalContext) {
  if (null == evalContext) {
    isEnabled = false;
    return;
  }

  IEvaluationContext context = (IEvaluationContext) evalContext;
  Object editor = context.getVariable(ISources.ACTIVE_EDITOR_NAME);
  if (editor instanceof ViewEditor) {
    isEnabled = true;
    return;
  }

  isEnabled = false;
  return;
}
 
开发者ID:google,项目名称:depan,代码行数:18,代码来源:AbstractViewEditorHandler.java

示例8: getFlusher

import org.eclipse.core.expressions.IEvaluationContext; //导入依赖的package包/类
private ConsoleStreamFlusher getFlusher(Object context) {
	if (context instanceof IEvaluationContext) {
		IEvaluationContext evaluationContext = (IEvaluationContext) context;
		Object o = evaluationContext.getVariable(ISources.ACTIVE_PART_NAME);
		if (!(o instanceof IWorkbenchPart)) {
			return null;
		}
		IWorkbenchPart part = (IWorkbenchPart) o;
		if (part instanceof IConsoleView && ((IConsoleView) part).getConsole() instanceof IConsole) {
			IConsole activeConsole = (IConsole) ((IConsoleView) part).getConsole();
			IProcess process = activeConsole.getProcess();
			return (ConsoleStreamFlusher) process.getAdapter(ConsoleStreamFlusher.class);
		}
	}
	return null;
}
 
开发者ID:RichardBirenheide,项目名称:brainfuck,代码行数:17,代码来源:FlushConsoleHandler.java

示例9: createContributionItems

import org.eclipse.core.expressions.IEvaluationContext; //导入依赖的package包/类
@Override
public void createContributionItems(IServiceLocator serviceLocator,
		IContributionRoot additions) {
	CommandContributionItemParameter toggleWatchpointParam = new CommandContributionItemParameter(serviceLocator, null, "org.eclipse.debug.ui.commands.ToggleWatchpoint", CommandContributionItem.STYLE_PUSH);
	toggleWatchpointParam.icon = DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_WATCHPOINT);
	toggleWatchpointParam.disabledIcon = DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_WATCHPOINT_DISABLED);
	toggleWatchpointParam.label = "Add Watchpoint";
	CommandContributionItem toggleWatchpoint = new CommandContributionItem(toggleWatchpointParam);
	Expression toggleWatchpointVisible = new Expression() {
		
		@Override
		public EvaluationResult evaluate(IEvaluationContext context)
				throws CoreException {
			return EvaluationResult.valueOf((context.getVariable("activeEditor") instanceof BfEditor));
		}
	};
	additions.addContributionItem(toggleWatchpoint, toggleWatchpointVisible);
}
 
开发者ID:RichardBirenheide,项目名称:brainfuck,代码行数:19,代码来源:WatchpointExtensionFactory.java

示例10: run

import org.eclipse.core.expressions.IEvaluationContext; //导入依赖的package包/类
@Override
public void run(IAction action) {
   System.err.println("In run(IACtion)");
   if (serviceLocator == null) {
      serviceLocator = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
   } 
   
   // Create an ExecutionEvent using Eclipse machinery.
   ICommandService srv = (ICommandService) serviceLocator.getService(ICommandService.class);
   IHandlerService hsrv = (IHandlerService) serviceLocator.getService(IHandlerService.class);
   ExecutionEvent event = hsrv.createExecutionEvent(srv.getCommand(ActionCommands.COMPARE_WITH_ROUTE_ACTION), null);
   // Fill it my current active selection.
   if (event.getApplicationContext() instanceof IEvaluationContext) {
      ((IEvaluationContext) event.getApplicationContext()).addVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME, mySelection);
   }
   
   try {
      handler.execute(event);
   } catch (ExecutionException e) {
      Activator.handleError(e.getMessage(), e, true);
   }
}
 
开发者ID:lbroudoux,项目名称:eip-designer,代码行数:23,代码来源:CompareWithRouteAction.java

示例11: run

import org.eclipse.core.expressions.IEvaluationContext; //导入依赖的package包/类
@Override
public void run(IAction action) {
   if (serviceLocator == null) {
      serviceLocator = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
   } 
   
   // Create an ExecutionEvent using Eclipse machinery.
   ICommandService srv = (ICommandService) serviceLocator.getService(ICommandService.class);
   IHandlerService hsrv = (IHandlerService) serviceLocator.getService(IHandlerService.class);
   ExecutionEvent event = hsrv.createExecutionEvent(srv.getCommand(ActionCommands.PERSIST_TO_ROUTE_MODEL_ACTION), null);
   // Fill it my current active selection.
   if (event.getApplicationContext() instanceof IEvaluationContext) {
      ((IEvaluationContext) event.getApplicationContext()).addVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME, mySelection);
   }
   
   try {
      handler.execute(event);
   } catch (ExecutionException e) {
      Activator.handleError(e.getMessage(), e, true);
   }
}
 
开发者ID:lbroudoux,项目名称:eip-designer,代码行数:22,代码来源:PersistToRouteModelAction.java

示例12: setEnabled

import org.eclipse.core.expressions.IEvaluationContext; //导入依赖的package包/类
@Override
public void setEnabled(final Object context) {
    boolean enabled = false;
    if (context instanceof IEvaluationContext) {
        final IEvaluationContext evaluationContext = (IEvaluationContext) context;
        final Object obj = evaluationContext.getVariable(ACTIVE_WORKBENCH_WINDOW_NAME);
        if (null != obj && UNDEFINED_VARIABLE != obj && obj instanceof IWorkbenchWindow) {
            final IWorkbenchPage activePage = ((IWorkbenchWindow) obj).getActivePage();
            if (null != activePage) {
                final IEditorPart activeEditor = activePage.getActiveEditor();
                if (activeEditor instanceof VisualForceMultiPageEditor) {
                    enabled = null != ((VisualForceMultiPageEditor) activeEditor).getTextEditor();
                }
            }
        }
    }
    setBaseEnabled(enabled);
}
 
开发者ID:forcedotcom,项目名称:idecore,代码行数:19,代码来源:MergeFieldsHandler.java

示例13: execute

import org.eclipse.core.expressions.IEvaluationContext; //导入依赖的package包/类
public Object execute( ExecutionEvent event ) throws ExecutionException
	{

		super.execute( event );
		
//		String filePath = SessionHandleAdapter.getInstance( )
//				.getReportDesignHandle( )
//				.getFileName( );
//		String fileName = filePath.substring( filePath.lastIndexOf( File.separator ) + 1 );

		IEvaluationContext context = (IEvaluationContext) event.getApplicationContext( );
		String fileName = (String)UIUtil.getVariableFromContext( context, ICommandParameterNameContants.PUBLISH_LIBRARY_FILENAME);
		LibraryHandle libHandle = (LibraryHandle) UIUtil.getVariableFromContext( context, ICommandParameterNameContants.PUBLISH_LIBRARY_LIBRARY_HANDLE);
	
		PublishLibraryWizard publishLibrary = new PublishLibraryWizard( libHandle,
				fileName,
				ReportPlugin.getDefault( ).getResourceFolder( ) );

		WizardDialog dialog = new BaseWizardDialog( UIUtil.getDefaultShell( ),
				publishLibrary );

		dialog.setPageSize( 500, 250 );
		dialog.open( );
		
		return Boolean.TRUE;
	}
 
开发者ID:eclipse,项目名称:birt,代码行数:27,代码来源:PublishToLibraryHandler.java

示例14: execute

import org.eclipse.core.expressions.IEvaluationContext; //导入依赖的package包/类
public Object execute( ExecutionEvent event ) throws ExecutionException
{
	super.execute( event );

	IEvaluationContext context = (IEvaluationContext) event.getApplicationContext( );
	Object position = UIUtil.getVariableFromContext( context, ICommandParameterNameContants.INSERT_COLUMN_POSITION );
	int intPos = -1;
	if ( position instanceof Integer )
	{
		intPos = ( (Integer) position ).intValue( );
	}

	if ( Policy.TRACING_ACTIONS )
	{
		System.out.println( "Insert row above action >> Run ..." ); //$NON-NLS-1$
	}
	if ( getTableEditPart( ) != null && !getColumnHandles( ).isEmpty( ) )
	{
		// has combined two behavior into one.
		getTableEditPart( ).insertColumns( intPos, getColumnNumbers( ) );
	}

	return Boolean.TRUE;
}
 
开发者ID:eclipse,项目名称:birt,代码行数:25,代码来源:InsertColumnHandler.java

示例15: getFirstSelectVariable

import org.eclipse.core.expressions.IEvaluationContext; //导入依赖的package包/类
protected Object getFirstSelectVariable( )
{
	IEvaluationContext context = (IEvaluationContext) event.getApplicationContext( );
	Object selectVariable = UIUtil.getVariableFromContext( context, ISources.ACTIVE_CURRENT_SELECTION_NAME );
	Object selectList = selectVariable;
	if ( selectVariable instanceof StructuredSelection )
	{
		selectList = ( (StructuredSelection) selectVariable ).toList( );
	}

	if ( selectList instanceof List && ( (List) selectList ).size( ) > 0 )
	{
		selectVariable = getFirstElement( (List) selectList );
	}

	return selectVariable;
}
 
开发者ID:eclipse,项目名称:birt,代码行数:18,代码来源:SelectionHandler.java


注:本文中的org.eclipse.core.expressions.IEvaluationContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。