本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
}
}
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}