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


Java ISelectionService类代码示例

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


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

示例1: isEnabled

import org.eclipse.ui.ISelectionService; //导入依赖的package包/类
@Override
public boolean isEnabled() {
	final boolean res;
	
	ISelectionService service = (ISelectionService) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getService(ISelectionService.class);
	if (service != null) {
		final ISelection selection = service.getSelection();
		if (selection instanceof IStructuredSelection) {
			boolean allValidMSE = true;
			final Iterator<?> it = ((IStructuredSelection) selection).iterator();
			while (allValidMSE && it.hasNext()) {
				Object current = it.next();
				allValidMSE = current instanceof MSE /*&& ((MSE) current).getAction() != null*/;
			}
			res = allValidMSE;
		} else {
			res = false;
		}
	} else {
		res = false;
	}
	
	return res;
}
 
开发者ID:eclipse,项目名称:gemoc-studio-modeldebugging,代码行数:25,代码来源:GemocToggleBreakpointHandler.java

示例2: getContributionItems

import org.eclipse.ui.ISelectionService; //导入依赖的package包/类
@Override
protected IContributionItem[] getContributionItems ()
{
    final ISelectionService ss = this.serviceLocator.getService ( ISelectionService.class );

    if ( ss == null )
    {
        return new IContributionItem[0];
    }

    final ISelection sel = ss.getSelection ();

    final List<IContributionItem> items = new LinkedList<> ();

    addFromFileResource ( items, sel );

    return items.toArray ( new IContributionItem[items.size ()] );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:19,代码来源:ProfilesContribution.java

示例3: execute

import org.eclipse.ui.ISelectionService; //导入依赖的package包/类
public Object execute(ExecutionEvent event) throws ExecutionException {

		final INewWizard wizard = new NewModelWizard();

		// Initialize the selection
		final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
		final ISelectionService service = window.getSelectionService();
		final IStructuredSelection selection = (IStructuredSelection)service
				.getSelection("org.eclipse.sirius.ui.tools.views.model.explorer"); //$NON-NLS-1$
		wizard.init(PlatformUI.getWorkbench(), selection);

		// Open the new model wizard
		final WizardDialog dialog = new WizardDialog(window.getShell(), wizard);
		dialog.open();
		return null;
	}
 
开发者ID:polarsys,项目名称:time4sys,代码行数:17,代码来源:NewTime4SysModel.java

示例4: addProjectToSelectedWorkingSet

import org.eclipse.ui.ISelectionService; //导入依赖的package包/类
/**
 * <p>
 * Adds the newly created project to the currently selected working set.
 * </p>
 * 
 * @param project the project to be added to the selected working set
 */
private void addProjectToSelectedWorkingSet(IProject project) {
	IWorkbench workbench = PlatformUI.getWorkbench();
	IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
	if (workbenchWindow == null) {
		return;
	}
	ISelectionService selectionService = workbenchWindow.getSelectionService();
	ISelection selection = selectionService.getSelection();
	if (selection instanceof IStructuredSelection) {
		IStructuredSelection structuredSelection = (IStructuredSelection) selection;
		Object firstElement = structuredSelection.getFirstElement();
		if (firstElement instanceof IAdaptable) {
			IAdaptable adaptable = (IAdaptable) firstElement;
			IWorkingSet workingSet = (IWorkingSet) adaptable.getAdapter(IWorkingSet.class);
			if (workingSet != null) {
				// new project wizard was invoked by right-clicking a working set
				IWorkingSetManager workingSetManager = workbench.getWorkingSetManager();
				workingSetManager.addToWorkingSets(project, new IWorkingSet[]{workingSet});
			}
		}
	}
}
 
开发者ID:DarwinSPL,项目名称:DarwinSPL,代码行数:30,代码来源:DwprofileNewProjectWizardLogic.java

示例5: execute

import org.eclipse.ui.ISelectionService; //导入依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	// get workbench window
	IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
	// set selection service
	ISelectionService service = window.getSelectionService();
	// set structured selection
	IStructuredSelection structured = (IStructuredSelection) service.getSelection();

	shell = window.getShell();
	logger.info("Umplificating Process Started");
	Object objectSelected = structured.getFirstElement();
	logger.info(objectSelected.toString());
	umplifyElement(objectSelected);
	return null;
}
 
开发者ID:umple,项目名称:umple,代码行数:17,代码来源:UmplifyUnitActionHandler.java

示例6: addListeners

import org.eclipse.ui.ISelectionService; //导入依赖的package包/类
/**
 * addListeners
 */
private void addListeners()
{
	// this.listenForScriptChanges();
	ISelectionService selectionService = getSite().getWorkbenchWindow().getSelectionService();

	// @formatter:off
	selectionService.addPostSelectionListener(
		IPageLayout.ID_PROJECT_EXPLORER,
		new ISelectionListener() {
			public void selectionChanged(IWorkbenchPart part, ISelection selection)
			{
				if (part != IndexView.this && selection instanceof IStructuredSelection)
				{
					setInputFromSelection(selection);
				}
			}
		}
	);
	// @formatter:on
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:24,代码来源:IndexView.java

示例7: getSelectedProject

import org.eclipse.ui.ISelectionService; //导入依赖的package包/类
private static IProject getSelectedProject(String viewID)
{
	ISelectionService service = UIUtils.getActiveWorkbenchWindow().getSelectionService();
	IStructuredSelection structured = (IStructuredSelection) service.getSelection(viewID);
	if (structured instanceof IStructuredSelection)
	{
		Object selectedObject = ((IStructuredSelection) structured).getFirstElement();
		if (selectedObject instanceof IAdaptable)
		{
			IResource resource = (IResource) ((IAdaptable) selectedObject).getAdapter(IResource.class);
			if (resource != null)
			{
				return resource.getProject();
			}
		}
	}
	return null;
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:19,代码来源:UIUtils.java

示例8: retrieveSelectedProject

import org.eclipse.ui.ISelectionService; //导入依赖的package包/类
public static IProject retrieveSelectedProject() {
	IProject project = null;
	ISelectionService selectionService = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();
	ISelection selection = selectionService.getSelection();
	if(selection instanceof IStructuredSelection) {
		IStructuredSelection structuredSelection = (IStructuredSelection)selection;
		for(Object obj : structuredSelection.toList()) {
			// transform cdt elements
			if(obj instanceof ICElement) {
				ICElement element = (ICElement)obj;
				obj = element.getResource();
			}
			
			if(obj instanceof IResource) {
				IResource resource = (IResource) obj;
				if(project == null) {
					project = resource.getProject();
				} else if(!project.equals(resource.getProject())) {
					System.err.println("Multiple Projects");
					return null;
				}
			}
		}
	}
	return project;
}
 
开发者ID:USESystemEngineeringBV,项目名称:cmake-eclipse-helper,代码行数:27,代码来源:ProjectExplorerExtensionContributionFactory.java

示例9: execute

import org.eclipse.ui.ISelectionService; //导入依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
    ISelectionService service = window.getSelectionService();
    ISelection selection = service.getSelection();

    folder = null;
    if (selection instanceof IStructuredSelection) {
        IStructuredSelection structuredSelection = (IStructuredSelection) selection;
        Object elt = structuredSelection.getFirstElement();
        if (elt instanceof IFolder) {
            folder = (IFolder) elt;
        }
    }
    if (isNull(folder)) {
        return null;
    }

    new CreateDynamicInstanceJob(window).schedule();

    return null;
}
 
开发者ID:atlanmod,项目名称:NeoEMF,代码行数:24,代码来源:OpenBackendCommand.java

示例10: ProjectTranspilerPage

import org.eclipse.ui.ISelectionService; //导入依赖的package包/类
public ProjectTranspilerPage() {
	super();

	// get project
	ISelectionService ss = TranspilerUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getSelectionService();
	ISelection sel = ss.getSelection();
	Object selectedObject = sel;

	if (sel instanceof IStructuredSelection) {
		selectedObject = ((IStructuredSelection)sel).getFirstElement();
	}

	if (selectedObject instanceof IAdaptable) {
		IResource res = (IResource) ((IAdaptable) selectedObject).getAdapter(IResource.class);
		project = res.getProject();
	}
}
 
开发者ID:gossi,项目名称:eclipse-transpiler-plugin,代码行数:18,代码来源:ProjectTranspilerPage.java

示例11: obtainSelectedSADLProject

import org.eclipse.ui.ISelectionService; //导入依赖的package包/类
private static IProject obtainSelectedSADLProject() {
	ISelectionService ss = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
	ISelection s = ss.getSelection("org.eclipse.ui.navigator.ProjectExplorer");
	if(s instanceof IStructuredSelection){
		Object o = ((IStructuredSelection)s).getFirstElement();
		if(o instanceof IResource){
			IProject p = ((IResource)o).getProject();
			try {
				if(p != null && p.isOpen() && p.isNatureEnabled("org.eclipse.xtext.ui.shared.xtextNature")){
					return p;
				}
			} catch (CoreException e) {
			}
		}
	}
	return null;
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:18,代码来源:Util.java

示例12: getCurrentProject

import org.eclipse.ui.ISelectionService; //导入依赖的package包/类
public static String getCurrentProject() {
	ISelectionService selectionService = Workbench.getInstance()
			.getActiveWorkbenchWindow().getSelectionService();

	ISelection selection = selectionService.getSelection();

	if (selection instanceof IStructuredSelection) {
		Object element = ((IStructuredSelection) selection).getFirstElement();
		IProject project = null;		
		if (element instanceof IResource) {
			project = ((IResource) element).getProject();
		}
		else if (element instanceof ICElement) {
			project = ((ICElement) element).getResource().getProject();
		}
		if (project != null) {
			return project.getLocation().toOSString();
		}
	}
	return null;
}
 
开发者ID:wangzw,项目名称:CppStyle,代码行数:22,代码来源:CppStylePropertyPage.java

示例13: createPartControl

import org.eclipse.ui.ISelectionService; //导入依赖的package包/类
@Override
public void createPartControl(Composite parent) {
    super.createPartControl(parent);
    // Add selection listener to detect click in problems view or in tree
    // view
    ISelectionService theService = getSite().getWorkbenchWindow().getSelectionService();
    selectionListener = new MarkerSelectionListener(this) {
        @Override
        public void selectionChanged(IWorkbenchPart thePart, ISelection theSelection) {
            selectionInProgress = true;
            super.selectionChanged(thePart, theSelection);
            selectionInProgress = false;
        }
    };
    theService.addSelectionListener(selectionListener);
    getCommonViewer().addSelectionChangedListener(this);
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:18,代码来源:BugExplorerView.java

示例14: createRootControl

import org.eclipse.ui.ISelectionService; //导入依赖的package包/类
@Override
public Composite createRootControl(Composite parent) {

    createRootComposite(parent);

    createAnnotationList(rootComposite);
    //        initScrolledComposite(parent);
    createBrowser(rootComposite);

    // Add selection listener to detect click in problems view or bug tree
    // view
    ISelectionService theService = getSite().getWorkbenchWindow().getSelectionService();

    selectionListener = new MarkerSelectionListener(this);
    theService.addSelectionListener(selectionListener);

    return rootComposite;
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:19,代码来源:BugInfoView.java

示例15: windowActivated

import org.eclipse.ui.ISelectionService; //导入依赖的package包/类
/**
 * @see org.eclipse.ui.IWindowListener#windowActivated(org.eclipse.ui.IWorkbenchWindow)
 */
public void windowActivated(IWorkbenchWindow window) {
    fWindowStack.remove(window);
    fWindowStack.push(window);
    ISelectionService service = window.getSelectionService(); 
    service.addSelectionListener(this);
    IWorkbenchPage page = window.getActivePage();
    if (page != null) {
        IWorkbenchPart part = page.getActivePart();
        if (part != null) {             
            ISelection selection = service.getSelection();
            if (selection != null) {
                selectionChanged(part, selection);
            }
        }
    }
}
 
开发者ID:Elphel,项目名称:vdt-plugin,代码行数:20,代码来源:SelectedResourceManager.java


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