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


Java ISources类代码示例

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


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

示例1: testCopyUrl

import org.eclipse.ui.ISources; //导入依赖的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

示例2: refreshState

import org.eclipse.ui.ISources; //导入依赖的package包/类
public void refreshState(CommandStack stack) {
    remaining = stack.hasRemaining();
    if (remaining) {
        armed = stack.getActiveCommand().getStackedState() == StackedState.ARMED;
    } else {
        armed = false;
    }

    empty = stack.isEmpty();

    executionStarted = false;
    for (StackedCommand cmd : stack.getCommands()) {
        if (cmd.getStackedState() != StackedState.DISARMED) {
            executionStarted = true;
            break;
        }
    }

    Map newState = getCurrentState();
    log.info(String.format("Fire new stack state %s", newState));
    fireSourceChanged(ISources.WORKBENCH, newState);
}
 
开发者ID:yamcs,项目名称:yamcs-studio,代码行数:23,代码来源:CommandStackStateProvider.java

示例3: setEnabled

import org.eclipse.ui.ISources; //导入依赖的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

示例4: getFlusher

import org.eclipse.ui.ISources; //导入依赖的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

示例5: updateStateTo

import org.eclipse.ui.ISources; //导入依赖的package包/类
/**
 * 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);

}
 
开发者ID:gama-platform,项目名称:gama,代码行数:23,代码来源:SimulationStateProvider.java

示例6: run

import org.eclipse.ui.ISources; //导入依赖的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

示例7: run

import org.eclipse.ui.ISources; //导入依赖的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

示例8: ESLocalProjectPropertySourceProvider

import org.eclipse.ui.ISources; //导入依赖的package包/类
/**
 * Default constructor.
 */
public ESLocalProjectPropertySourceProvider() {

	currentSaveStates = new LinkedHashMap<String, Boolean>();
	// check if workspace can init, exit otherwise
	try {
		ESWorkspaceProviderImpl.init();
		// BEGIN SUPRESS CATCH EXCEPTION
	} catch (final RuntimeException exception) {
		// END SUPRESS CATCH EXCEPTION
		ModelUtil.logException(
			"ProjectSpacePropertySourceProvider init failed because workspace init failed with exception.",
			exception);
		return;
	}
	saveStateChangedObserver = new ESSaveStateChangedObserver() {
		public void saveStateChanged(ESLocalProject localProject, boolean hasUnsavedChangesNow) {
			final Boolean newValue = new Boolean(hasUnsavedChangesNow);
			currentSaveStates.put(localProject.getLastUpdated().toString(), newValue);
			fireSourceChanged(ISources.WORKBENCH, CURRENT_SAVE_STATE_PROPERTY, newValue);
		}

	};
	ESWorkspaceProviderImpl.getObserverBus().register(saveStateChangedObserver);
}
 
开发者ID:edgarmueller,项目名称:emfstore-rest,代码行数:28,代码来源:ESLocalProjectPropertySourceProvider.java

示例9: getFirstSelectVariable

import org.eclipse.ui.ISources; //导入依赖的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

示例10: getSelection

import org.eclipse.ui.ISources; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:eclipse,项目名称:birt,代码行数:23,代码来源:SelectionHandler.java

示例11: startSimulator

import org.eclipse.ui.ISources; //导入依赖的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

示例12: setGluonFound

import org.eclipse.ui.ISources; //导入依赖的package包/类
private void setGluonFound(boolean gluonFound) { 
    if (this.gluonFound == gluonFound) return;
		
    this.gluonFound = gluonFound;  
    String currentState = gluonFound ? GLUON_FOUND : GLUON_NOT_FOUND; 
    fireSourceChanged(ISources.WORKBENCH, SHOW_MENU, currentState); 
}
 
开发者ID:gluonhq,项目名称:ide-plugins,代码行数:8,代码来源:ValidationSourceProvider.java

示例13: setGluonFunctionFound

import org.eclipse.ui.ISources; //导入依赖的package包/类
private void setGluonFunctionFound(boolean gluonFunctionFound) { 
    if (this.gluonFunctionFound == gluonFunctionFound) return;
		
    this.gluonFunctionFound = gluonFunctionFound;  
    String currentState = gluonFunctionFound ? GLUON_FUNCTION_FOUND : GLUON_FUNCTION_NOT_FOUND; 
    fireSourceChanged(ISources.WORKBENCH, SHOW_FUNCTION_MENU, currentState); 
}
 
开发者ID:gluonhq,项目名称:ide-plugins,代码行数:8,代码来源:ValidationSourceProvider.java

示例14: defaultKeyChanged

import org.eclipse.ui.ISources; //导入依赖的package包/类
@Override
public void defaultKeyChanged ( final KeyInformation key, final Date validUntil )
{
    logger.debug ( "Default key changed: {} -> {}", key, validUntil );

    fireSourceChanged ( ISources.WORKBENCH, getCurrentState () );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:8,代码来源:KeyInstanceProvider.java

示例15: getSelectedProject

import org.eclipse.ui.ISources; //导入依赖的package包/类
private IProject getSelectedProject(Object ctx) {
    if (ctx instanceof IEvaluationContext) {
        Object sel = ((IEvaluationContext) ctx).getVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME);
        if (sel instanceof IStructuredSelection) {
            Object el = ((IStructuredSelection) sel).getFirstElement();
            if (el instanceof IAdaptable) {
                return ((IAdaptable) el).getAdapter(IProject.class);
            }
        }
    }
    return null;
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:13,代码来源:OpenEditor.java


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