當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。