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


Java IEvaluationContext.getVariable方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: startSimulator

import org.eclipse.core.expressions.IEvaluationContext; //导入方法依赖的package包/类
public static Object startSimulator(final ExecutionEvent event, final String engineTypeId) {
	try {
		final SimulationUIService simulationUiService = Objects.requireNonNull(EclipseContextFactory.getServiceContext(FrameworkUtil.getBundle(SimulatorHandlerHelper.class).getBundleContext()).get(SimulationUIService.class), "unable to get simulation UI service");
		if(simulationUiService.getCurrentState().getSimulationEngine() != null) {
			final MessageBox messageBox = new MessageBox(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
	        messageBox.setMessage("A simulation is already active. Do you want to stop the current simulation?");
	        messageBox.setText("Stop Current Simulation");
	        if(messageBox.open() == SWT.NO) {
	        	return null;
	        }
		}
		
		if(event.getApplicationContext() instanceof IEvaluationContext) {
			final IEvaluationContext appContext = (IEvaluationContext)event.getApplicationContext();
			final ISelection selection = (ISelection)appContext.getVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME);
			final SimulationLaunchShortcut launchShortcut = new SimulationLaunchShortcut();
			launchShortcut.launch(selection, engineTypeId, ILaunchManager.RUN_MODE);
		}
	} catch(final Exception ex) {
		final Status status = new Status(IStatus.ERROR, FrameworkUtil.getBundle(SimulatorHandlerHelper.class).getSymbolicName(), "Error", ex);
		StatusManager.getManager().handle(status, StatusManager.SHOW | StatusManager.LOG);
	}
	
	return null;
}
 
开发者ID:smaccm,项目名称:smaccm,代码行数:26,代码来源:SimulatorHandlerHelper.java

示例5: getActivePart

import org.eclipse.core.expressions.IEvaluationContext; //导入方法依赖的package包/类
private static IEditorPart getActivePart(IEvaluationContext context) {
	if (context == null)
		return null;

	Object activePart = context.getVariable(ISources.ACTIVE_PART_NAME);
	if ((activePart instanceof IEditorPart))
		return (IEditorPart) activePart;

	return null;
}
 
开发者ID:eclipse,项目名称:tm4e,代码行数:11,代码来源:ThemeContribution.java

示例6: getSelection

import org.eclipse.core.expressions.IEvaluationContext; //导入方法依赖的package包/类
private static IStructuredSelection getSelection( IEvaluationContext evaluationContext ) {
  IStructuredSelection result = StructuredSelection.EMPTY;
  Object variable = evaluationContext.getVariable( ISources.ACTIVE_CURRENT_SELECTION_NAME );
  if( variable instanceof IStructuredSelection ) {
    result = ( IStructuredSelection )variable;
  }
  return result;
}
 
开发者ID:rherrmann,项目名称:eclipse-extras,代码行数:9,代码来源:OpenWithQuickMenuHandler.java

示例7: isEnabled

import org.eclipse.core.expressions.IEvaluationContext; //导入方法依赖的package包/类
private static boolean isEnabled( IEvaluationContext evaluationContext ) {
  Object variable = evaluationContext.getVariable( ISources.ACTIVE_EDITOR_INPUT_NAME );
  boolean result = false;
  if( variable instanceof IEditorInput ) {
    IEditorInput editorInput = ( IEditorInput )variable;
    result = ResourceUtil.getFile( editorInput ) != null || getFile( editorInput ) != null;
  }
  return result;
}
 
开发者ID:rherrmann,项目名称:eclipse-extras,代码行数:10,代码来源:DeleteEditorFileHandler.java

示例8: setEnabled

import org.eclipse.core.expressions.IEvaluationContext; //导入方法依赖的package包/类
@Override
public void setEnabled(Object evaluationContext)
{
	// clear cached selection
	this.clearFileStores();

	if (evaluationContext instanceof IEvaluationContext)
	{
		IEvaluationContext context = (IEvaluationContext) evaluationContext;
		Object value = context.getVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME);

		if (value instanceof ISelection)
		{
			ISelection selection = (ISelection) value;

			if (selection instanceof IStructuredSelection && selection.isEmpty() == false)
			{
				IStructuredSelection structuredSelection = (IStructuredSelection) selection;

				for (Object object : structuredSelection.toArray())
				{
					if (object instanceof IProject || object instanceof IFolder || object instanceof IFile)
					{
						IResource resource = (IResource) object;
						IFileStore fileStore = EFSUtils.getFileStore(resource);

						if (this.isValid(fileStore))
						{
							this.addFileStore(fileStore);
						}
					}
				}
			}
		}
	}
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:37,代码来源:BaseHandler.java

示例9: getSelectedResource

import org.eclipse.core.expressions.IEvaluationContext; //导入方法依赖的package包/类
public static IResource getSelectedResource(IEvaluationContext evaluationContext)
{
	if (evaluationContext == null)
	{
		return null;
	}

	Object variable = evaluationContext.getVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME);
	if (variable instanceof IStructuredSelection)
	{
		Object selectedObject = ((IStructuredSelection) variable).getFirstElement();
		if (selectedObject instanceof IAdaptable)
		{
			IResource resource = (IResource) ((IAdaptable) selectedObject).getAdapter(IResource.class);
			if (resource != null)
			{
				return resource;
			}
		}
	}
	else
	{
		// checks the active editor
		variable = evaluationContext.getVariable(ISources.ACTIVE_EDITOR_NAME);
		if (variable instanceof IEditorPart)
		{
			IEditorInput editorInput = ((IEditorPart) variable).getEditorInput();
			if (editorInput instanceof IFileEditorInput)
			{
				return ((IFileEditorInput) editorInput).getFile();
			}
		}
	}
	return null;
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:36,代码来源:UIUtils.java

示例10: getVariableFromContext

import org.eclipse.core.expressions.IEvaluationContext; //导入方法依赖的package包/类
/**
 * Gets the object from the context through the key.If the value is a Object
 * return null.
 * 
 * @param context
 * @param key
 * @return
 */
public static Object getVariableFromContext( IEvaluationContext context,
		String key )
{
	Object retValue = context.getVariable( key );
	if ( retValue == null )
	{
		return null;
	}
	if ( retValue.getClass( ).getName( ).equals( "java.lang.Object" ) )//$NON-NLS-1$
	{
		retValue = null;
	}
	return retValue;
}
 
开发者ID:eclipse,项目名称:birt,代码行数:23,代码来源:UIUtil.java

示例11: isEnabled

import org.eclipse.core.expressions.IEvaluationContext; //导入方法依赖的package包/类
private static boolean isEnabled( IEvaluationContext evaluationContext ) {
  Object activePart = evaluationContext.getVariable( ISources.ACTIVE_PART_NAME );
  return activePart instanceof IViewPart;
}
 
开发者ID:rherrmann,项目名称:eclipse-extras,代码行数:5,代码来源:CloseViewHandler.java

示例12: execute

import org.eclipse.core.expressions.IEvaluationContext; //导入方法依赖的package包/类
public Object execute(ExecutionEvent event) throws ExecutionException
{
	if (event == null)
	{
		return Boolean.FALSE;
	}
	Object context = event.getApplicationContext();
	if (!(context instanceof IEvaluationContext))
	{
		return Boolean.FALSE;
	}

	IEvaluationContext evContext = (IEvaluationContext) event.getApplicationContext();
	Object input = evContext.getVariable(ISources.SHOW_IN_INPUT);
	if (input instanceof IFileEditorInput)
	{
		IFileEditorInput fei = (IFileEditorInput) input;
		return URIUtil.open(fei.getFile().getLocationURI());
	}

	if (input instanceof IURIEditorInput)
	{
		IURIEditorInput uriInput = (IURIEditorInput) input;
		return URIUtil.open(uriInput.getURI());
	}

	boolean result = Boolean.TRUE;
	@SuppressWarnings("unchecked")
	List<Object> selectedFiles = (List<Object>) evContext.getDefaultVariable();
	if (selectedFiles.isEmpty())
	{
		return Boolean.FALSE;
	}

	for (Object selected : selectedFiles)
	{
		IResource resource = null;
		if (selected instanceof IAdaptable)
		{
			resource = (IResource) ((IAdaptable) selected).getAdapter(IResource.class);
			if (resource != null)
			{
				result = result && URIUtil.open(resource.getLocationURI());
			}
			else
			{
				IFileStore fileStore = (IFileStore) ((IAdaptable) selected).getAdapter(IFileStore.class);
				try
				{
					if (fileStore != null && fileStore.toLocalFile(EFS.NONE, null) != null)
					{
						result = result && URIUtil.open(fileStore.toURI());
					}
				}
				catch (CoreException e)
				{
				}
			}
		}
	}
	return result;
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:63,代码来源:OpenInFinderHandler.java


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