类org.eclipse.ui.ISources源码实例Demo

下面列出了怎么用org.eclipse.ui.ISources的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: tracecompass   文件: ExportTracePackageHandler.java
@Override
public void setEnabled(Object evaluationContext) {
    super.setEnabled(evaluationContext);

    fEnabled = true;

    Object s = HandlerUtil.getVariable(evaluationContext, ISources.ACTIVE_MENU_SELECTION_NAME);
    if (s instanceof IStructuredSelection) {
        IStructuredSelection selection = (IStructuredSelection) s;
        // If we have traces selected, make sure they are all from the same
        // project, disable handler otherwise
        Object[] selectedElements = selection.toArray();
        TmfProjectElement firstProject = null;
        for (Object selectedElement : selectedElements) {
            if (selectedElement instanceof TmfTraceElement) {
                TmfTraceElement tmfTraceElement = (TmfTraceElement) selectedElement;
                TmfProjectElement project = tmfTraceElement.getProject();
                if (firstProject != null && !project.equals(firstProject)) {
                    fEnabled =  false;
                }

                firstProject = project;
            }
        }
    }
}
 
源代码2 项目: depan   文件: AbstractViewEditorHandler.java
@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;
}
 
源代码3 项目: gama   文件: SimulationStateProvider.java
/**
 * Change the UI state based on the state of the simulation (none, stopped,
 * running or notready)
 */
@Override
public void updateStateTo(final String state) {
	fireSourceChanged(ISources.WORKBENCH, SIMULATION_RUNNING_STATE, state);
	final IExperimentPlan exp = GAMA.getExperiment();
	final String type = exp == null ? "NONE" : exp.isBatch() ? "BATCH" : exp.isMemorize() ? "MEMORIZE" : "REGULAR";
	fireSourceChanged(ISources.WORKBENCH, SIMULATION_TYPE, type);

	String canStepBack = "CANNOT_STEP_BACK";

	if (exp != null) {
		if (exp.getAgent() != null) {
			canStepBack = exp.getAgent().canStepBack() ? "CAN_STEP_BACK" : "CANNOT_STEP_BACK";
		}
	}

	fireSourceChanged(ISources.WORKBENCH, SIMULATION_STEPBACK, canStepBack);

}
 
源代码4 项目: eip-designer   文件: CompareWithRouteAction.java
@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);
   }
}
 
源代码5 项目: eip-designer   文件: PersistToRouteModelAction.java
@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);
   }
}
 
源代码6 项目: eip-designer   文件: CompareWithRouteAction.java
@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);
   }
}
 
源代码7 项目: eip-designer   文件: PersistToRouteModelAction.java
@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);
   }
}
 
源代码8 项目: birt   文件: SelectionHandler.java
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;
}
 
源代码9 项目: birt   文件: SelectionHandler.java
/**
 * Returns a <code>List</code> containing the currently selected objects.
 * 
 * @return A List containing the currently selected objects.
 */
protected IStructuredSelection getSelection( )
{
	IEvaluationContext context = (IEvaluationContext) event.getApplicationContext( );
	Object selectVariable = UIUtil.getVariableFromContext( context, ISources.ACTIVE_CURRENT_SELECTION_NAME );
	if ( selectVariable != null )
	{
		if ( selectVariable instanceof IStructuredSelection )
		{
			return (IStructuredSelection) selectVariable;
		}
		else
		{
			return new StructuredSelection( selectVariable );
		}
	}
	return null;
}
 
源代码10 项目: neoscada   文件: KeyInstanceProvider.java
@Override
public void defaultKeyChanged ( final KeyInformation key, final Date validUntil )
{
    logger.debug ( "Default key changed: {} -> {}", key, validUntil );

    fireSourceChanged ( ISources.WORKBENCH, getCurrentState () );
}
 
源代码11 项目: tm4e   文件: ThemeContribution.java
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;
}
 
源代码12 项目: xtext-eclipse   文件: ToSaveOrNotToSaveTest.java
protected void renameFooToFooBar(final XtextEditor contextEditor) throws Exception {
		contextEditor.getEditorSite().getPage().activate(contextEditor);
		waitForDisplay();
		IXtextDocument document = contextEditor.getDocument();
		final int offset = document.get().indexOf("foo");
		contextEditor.selectAndReveal(offset, 3);
		
		EvaluationContext evaluationContext = new EvaluationContext(null, new Object());
		evaluationContext.addVariable(ISources.ACTIVE_EDITOR_NAME, contextEditor);
		ExecutionEvent executionEvent = new ExecutionEvent(null, newHashMap(), null, evaluationContext);
		renameElementHandler.execute(executionEvent);
//		syncUtil.totalSync(refactoringPreferences.isSaveAllBeforeRefactoring());
//		IRenameElementContext context = document.readOnly(new IUnitOfWork<IRenameElementContext, XtextResource>() {
//			public IRenameElementContext exec(XtextResource state) throws Exception {
//				EObject target = eObjectAtOffsetHelper.resolveElementAt(state, offset);
//				return renameContextFactory.createRenameElementContext(target, contextEditor, new TextSelection(offset,
//						3), state);
//			}
//		});
//		controller.initialize(context);
//		waitForDisplay();
//		controller.startRefactoring(RefactoringType.LINKED_EDITING);
//		waitForDisplay();
		pressKeys(contextEditor, "fooBar\n");
		waitForDisplay();
		waitForReconciler(fooEditor);
		waitForReconciler(barEditor);
		waitForDisplay();
	}
 
源代码13 项目: xtext-eclipse   文件: ContentAssistHandler.java
@Override
public void setEnabled(Object evaluationContext) {
	boolean contentAssistAvailable = false;
	if (evaluationContext instanceof IEvaluationContext) {
		Object var = ((IEvaluationContext) evaluationContext).getVariable(ISources.ACTIVE_EDITOR_NAME);
		if (var instanceof XtextEditor) {
			contentAssistAvailable = ((XtextEditor) var).isContentAssistAvailable();
		}
	}
	super.setBaseEnabled(isEnabled() & contentAssistAvailable);
}
 
源代码14 项目: eclipse-extras   文件: DeleteEditorFileHandler.java
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;
}
 
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;
}
 
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;
}
 
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;
}
 
源代码18 项目: eclipse-extras   文件: CloseViewHandlerPDETest.java
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;
}
 
源代码19 项目: APICloud-Studio   文件: BaseHandler.java
@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);
						}
					}
				}
			}
		}
	}
}
 
源代码20 项目: APICloud-Studio   文件: UIUtils.java
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;
}
 
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;
}
 
源代码22 项目: APICloud-Studio   文件: ToggleWordWrapHandler.java
@Override
public void setEnabled(Object evaluationContext)
{
	Object activeSite = ((IEvaluationContext) evaluationContext).getVariable(ISources.ACTIVE_SITE_NAME);
	Object activeEditor = ((IEvaluationContext) evaluationContext).getVariable(ISources.ACTIVE_EDITOR_NAME);
	if (activeSite instanceof IWorkbenchSite && activeEditor instanceof AbstractThemeableEditor)
	{
		ICommandService commandService = (ICommandService) ((IWorkbenchSite) activeSite)
				.getService(ICommandService.class);
		Command command = commandService.getCommand(COMMAND_ID);
		State state = command.getState(RegistryToggleState.STATE_ID);
		state.setValue(((AbstractThemeableEditor) activeEditor).getWordWrapEnabled());
	}
}
 
源代码23 项目: saros   文件: SarosSourceProvider.java
private final void connectionChanged() {
  SWTUtils.runSafeSWTAsync(
      null,
      new Runnable() {
        @Override
        public void run() {
          fireSourceChanged(ISources.WORKBENCH, SAROS, saros);
        }
      });
}
 
源代码24 项目: saros   文件: SarosSourceProvider.java
private final void sessionChanged(final ISarosSession session) {
  SWTUtils.runSafeSWTAsync(
      null,
      new Runnable() {
        @Override
        public void run() {
          fireSourceChanged(
              ISources.WORKBENCH,
              SAROS_SESSION,
              session == null ? IEvaluationContext.UNDEFINED_VARIABLE : session);
        }
      });
}
 
源代码25 项目: elexis-3-core   文件: PatientSelectionStatus.java
public void setState(boolean state){
	String value = FALSE;
	if (state == true) {
		value = TRUE;
	} else {
		value = FALSE;
	}
	fireSourceChanged(ISources.WORKBENCH, PATIENTACTIVE, value);
}
 
源代码26 项目: neoscada   文件: LoginSessionProvider.java
public void setLoginSession ( final LoginSession session )
{
    this.session = session;
    fireSourceChanged ( ISources.WORKBENCH, getCurrentState () );
}
 
public ExecutionEventBuilder withActiveShell(Shell shell) {
  when(context.getVariable(ISources.ACTIVE_SHELL_NAME)).thenReturn(shell);
  return this;
}
 
public ExecutionEventBuilder withCurrentSelection(IStructuredSelection selection) {
  when(context.getVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME)).thenReturn(selection);
  return this;
}
 
public void setEnabled() {
    fireSourceChanged(ISources.WORKBENCH, ID, ENABLED);
}
 
源代码30 项目: xds-ide   文件: XBookmarksState.java
public void fireBookmarkSet() {
    markerCount++;
    fireSourceChanged(ISources.WORKBENCH, EXIST_STATE, TRUE);
}
 
 类所在包
 同包方法