org.eclipse.ui.ISources Java Examples
The following examples show how to use
org.eclipse.ui.ISources.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SimulationStateProvider.java From gama with GNU General Public License v3.0 | 6 votes |
/** * 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); }
Example #2
Source File: CompareWithRouteAction.java From eip-designer with Apache License 2.0 | 6 votes |
@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); } }
Example #3
Source File: SelectionHandler.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * 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; }
Example #4
Source File: SelectionHandler.java From birt with Eclipse Public License 1.0 | 6 votes |
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; }
Example #5
Source File: PersistToRouteModelAction.java From eip-designer with Apache License 2.0 | 6 votes |
@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); } }
Example #6
Source File: AbstractViewEditorHandler.java From depan with Apache License 2.0 | 6 votes |
@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; }
Example #7
Source File: ExportTracePackageHandler.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
@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; } } } }
Example #8
Source File: CompareWithRouteAction.java From eip-designer with Apache License 2.0 | 6 votes |
@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); } }
Example #9
Source File: PersistToRouteModelAction.java From eip-designer with Apache License 2.0 | 6 votes |
@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); } }
Example #10
Source File: BaseHandler.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
@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); } } } } } } }
Example #11
Source File: CloseViewHandlerPDETest.java From eclipse-extras with Eclipse Public License 1.0 | 5 votes |
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; }
Example #12
Source File: DeleteEditorFileHandler_FilePDETest.java From eclipse-extras with Eclipse Public License 1.0 | 5 votes |
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; }
Example #13
Source File: UIUtils.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
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; }
Example #14
Source File: CommonSourceViewerConfiguration.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
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; }
Example #15
Source File: ToggleWordWrapHandler.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
@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()); } }
Example #16
Source File: SarosSourceProvider.java From saros with GNU General Public License v2.0 | 5 votes |
private final void connectionChanged() { SWTUtils.runSafeSWTAsync( null, new Runnable() { @Override public void run() { fireSourceChanged(ISources.WORKBENCH, SAROS, saros); } }); }
Example #17
Source File: SarosSourceProvider.java From saros with GNU General Public License v2.0 | 5 votes |
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); } }); }
Example #18
Source File: PatientSelectionStatus.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
public void setState(boolean state){ String value = FALSE; if (state == true) { value = TRUE; } else { value = FALSE; } fireSourceChanged(ISources.WORKBENCH, PATIENTACTIVE, value); }
Example #19
Source File: DeleteEditorFileHandler_ResourcePDETest.java From eclipse-extras with Eclipse Public License 1.0 | 5 votes |
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; }
Example #20
Source File: KeyInstanceProvider.java From neoscada with Eclipse Public License 1.0 | 5 votes |
@Override public void defaultKeyChanged ( final KeyInformation key, final Date validUntil ) { logger.debug ( "Default key changed: {} -> {}", key, validUntil ); fireSourceChanged ( ISources.WORKBENCH, getCurrentState () ); }
Example #21
Source File: OpenWithQuickMenuHandlerPDETest.java From eclipse-extras with Eclipse Public License 1.0 | 5 votes |
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; }
Example #22
Source File: DeleteEditorFileHandler.java From eclipse-extras with Eclipse Public License 1.0 | 5 votes |
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; }
Example #23
Source File: ThemeContribution.java From tm4e with Eclipse Public License 1.0 | 5 votes |
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; }
Example #24
Source File: ToSaveOrNotToSaveTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
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(); }
Example #25
Source File: ContentAssistHandler.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@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); }
Example #26
Source File: LoginSessionProvider.java From neoscada with Eclipse Public License 1.0 | 4 votes |
public void setLoginSession ( final LoginSession session ) { this.session = session; fireSourceChanged ( ISources.WORKBENCH, getCurrentState () ); }
Example #27
Source File: DummyEditorSite.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
@Override public IWorkbenchWindow getWorkbenchWindow() { final IEclipseContext context = ((Workbench) PlatformUI.getWorkbench()).getContext(); return (IWorkbenchWindow) context.get(ISources.ACTIVE_WORKBENCH_WINDOW_NAME); }
Example #28
Source File: ExecutionEventBuilder.java From google-cloud-eclipse with Apache License 2.0 | 4 votes |
public ExecutionEventBuilder withActiveShell(Shell shell) { when(context.getVariable(ISources.ACTIVE_SHELL_NAME)).thenReturn(shell); return this; }
Example #29
Source File: ExecutionEventBuilder.java From google-cloud-eclipse with Apache License 2.0 | 4 votes |
public ExecutionEventBuilder withCurrentSelection(IStructuredSelection selection) { when(context.getVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME)).thenReturn(selection); return this; }
Example #30
Source File: CommandState.java From hybris-commerce-eclipse-plugin with Apache License 2.0 | 4 votes |
public void setEnabled() { fireSourceChanged(ISources.WORKBENCH, ID, ENABLED); }