當前位置: 首頁>>代碼示例>>Java>>正文


Java ISelectionService.getSelection方法代碼示例

本文整理匯總了Java中org.eclipse.ui.ISelectionService.getSelection方法的典型用法代碼示例。如果您正苦於以下問題:Java ISelectionService.getSelection方法的具體用法?Java ISelectionService.getSelection怎麽用?Java ISelectionService.getSelection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.ui.ISelectionService的用法示例。


在下文中一共展示了ISelectionService.getSelection方法的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: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: getProject

import org.eclipse.ui.ISelectionService; //導入方法依賴的package包/類
public static IProject getProject(){
    IProject project = null;
    
    //1.根據當前編輯器獲取工程
    IEditorPart part = Workbench.getInstance().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    if(part != null){
        Object object = part.getEditorInput().getAdapter(IFile.class);
        if(object != null){
            project = ((IFile)object).getProject();
        }
    }
    
    if(project == null){
        ISelectionService selectionService =   
                Workbench.getInstance().getActiveWorkbenchWindow().getSelectionService();  
        ISelection selection = selectionService.getSelection();  
        if(selection instanceof IStructuredSelection) {  
            Object element = ((IStructuredSelection)selection).getFirstElement();  
            if (element instanceof IResource) {  
                project= ((IResource)element).getProject();  
            } 
        }   
    }
    
    return project;
}
 
開發者ID:winture,項目名稱:wt-studio,代碼行數:27,代碼來源:TableFromDataBaseDialog.java

示例14: isMultiApplyAttempt

import org.eclipse.ui.ISelectionService; //導入方法依賴的package包/類
/**
 * Returns true iff the user is trying to apply quick fixes to multiple issues / markers at once.
 * <p>
 * Implementation note: this method assumes that the entire code of class MarkerResolutionGenerator is only invoked
 * if quick fixes are initiated via the Problems view (not if they are initiated from within the editor). Therefore,
 * this method simply checks whether the Problems view contains a selection of multiple, i.e. two or more, elements.
 */
private boolean isMultiApplyAttempt() {
	if (workbench == null)
		return false;
	try {
		// get the current selection in the problems view
		final ISelectionService service = workbench.getActiveWorkbenchWindow().getSelectionService();
		final IStructuredSelection sel = (IStructuredSelection) service.getSelection(IPageLayout.ID_PROBLEM_VIEW);
		return sel != null && sel.size() >= 2;
	} catch (Exception e) {
		return false;
	}
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:20,代碼來源:N4JSMarkerResolutionGenerator.java

示例15: getCurrentProject

import org.eclipse.ui.ISelectionService; //導入方法依賴的package包/類
public IProject getCurrentProject() {
	ISelectionService selectionService = Workbench.getInstance().getActiveWorkbenchWindow().getSelectionService();
	ISelection selection = selectionService.getSelection();
	IProject project = null;
	if (selection instanceof IStructuredSelection) {
		Object element = ((IStructuredSelection) selection).getFirstElement();
		if (element instanceof IProject) {
			project = ((IResource) element).getProject();
		} else if (element instanceof IFolder) {
			project = ((IFolder) element).getProject();
		} else
			project = getProjectFromActiveGraph();
	}
	return project;
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:16,代碼來源:BuildExpressionEditorDataSturcture.java


注:本文中的org.eclipse.ui.ISelectionService.getSelection方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。