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


Java IWorkbenchPartSite.getSelectionProvider方法代码示例

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


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

示例1: isEnabled

import org.eclipse.ui.IWorkbenchPartSite; //导入方法依赖的package包/类
@Override
public boolean isEnabled() {
	IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
	if (window == null) {
		return false;
	}
	IWorkbenchPartSite site = window.getActivePage().getActiveEditor().getSite();
	if (site == null) {
		return false;
	}
	ISelectionProvider selectionProvider = site.getSelectionProvider();
	if (selectionProvider == null) {
		return false;
	}
	ISelection currentSelection = selectionProvider.getSelection();
	setContext(refactoring, currentSelection);
	return refactoring.isExecutable();
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:19,代码来源:RenameElementHandler.java

示例2: search

import org.eclipse.ui.IWorkbenchPartSite; //导入方法依赖的package包/类
public void search() {
	final IWorkbenchPart part = WorkbenchHelper.getActivePart();
	if (part instanceof IEditorPart) {
		final IEditorPart editor = (IEditorPart) part;
		final IWorkbenchPartSite site = editor.getSite();
		if (site != null) {
			final ISelectionProvider provider = site.getSelectionProvider();
			if (provider != null) {
				final ISelection viewSiteSelection = provider.getSelection();
				if (viewSiteSelection instanceof TextSelection) {
					final TextSelection textSelection = (TextSelection) viewSiteSelection;
					text.setText(textSelection.getText());
				}
			}
		}

	}
	activate(null);
	text.setFocus();

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

示例3: clearSelection

import org.eclipse.ui.IWorkbenchPartSite; //导入方法依赖的package包/类
/**
 * Clear all selection providers in all workench pages.
 */
public static void clearSelection() {

	final IWorkbenchWindow wbWin = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
	if (wbWin != null) {

		final IWorkbenchPage[] wbPages = wbWin.getPages();
		for (final IWorkbenchPage wbPage : wbPages) {

			final IWorkbenchPart wbWinPagePart = wbPage.getActivePart();
			if (wbWinPagePart != null) {

				final IWorkbenchPartSite site = wbWinPagePart.getSite();
				if (site != null) {

					final ISelectionProvider selectionProvider = site.getSelectionProvider();

					if (selectionProvider instanceof PostSelectionProvider) {
						((PostSelectionProvider) selectionProvider).clearSelection();
					}
				}
			}
		}
	}
}
 
开发者ID:wolfgang-ch,项目名称:mytourbook,代码行数:28,代码来源:Util.java

示例4: init

import org.eclipse.ui.IWorkbenchPartSite; //导入方法依赖的package包/类
public void init(IWorkbenchPartSite site, T model) {
	this.site = site;
	this.model = model;
	this.timelineModel.eAdapters().add(timelineModelAdapter);
	if (site != null) {
		ISelectionProvider selectionProvider = site.getSelectionProvider();
		if (selectionProvider != null) {
			selectionProvider.addSelectionChangedListener(selectionListener);
		}
	}

	timelineServices = ClassRegistry.createInstances(TimelineService.class);
	for (TimelineService s : timelineServices) {
		s.setTimeline(this);
	}
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:17,代码来源:Timeline.java

示例5: ViewActionGroup

import org.eclipse.ui.IWorkbenchPartSite; //导入方法依赖的package包/类
public ViewActionGroup(int mode, IPropertyChangeListener changeListener, IWorkbenchPartSite site) {
	fChangeListener= changeListener;
	fSite= site;
	if (fChangeListener == null) {
		fChangeListener = new IPropertyChangeListener() {
			public void propertyChange(PropertyChangeEvent event) {}
		};
	}
	fFilterActionGroup= new WorkingSetFilterActionGroup(site, fChangeListener);
	fShowActionGroup= new WorkingSetShowActionGroup(site);
	fWorkingSetAssignementAction= new ConfigureWorkingSetAssignementAction(site);

	ISelectionProvider selectionProvider= site.getSelectionProvider();
	selectionProvider.addSelectionChangedListener(fWorkingSetAssignementAction);

	fMode= mode;
	if (fMode == SHOW_WORKING_SETS)
		fActiveActionGroup= fShowActionGroup;
	else
		fActiveActionGroup= fFilterActionGroup;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:22,代码来源:ViewActionGroup.java

示例6: fireSelection

import org.eclipse.ui.IWorkbenchPartSite; //导入方法依赖的package包/类
/**
 * Fires a post selection for the current view.
 * 
 * @param selection
 * @return Returns <code>true</code> when the selection is fired, otherwise <code>false</code>.
 */
public static boolean fireSelection(final ISelection selection) {

	final IWorkbenchWindow wbWin = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
	if (wbWin != null) {

		final IWorkbenchPage wbWinPage = wbWin.getActivePage();
		if (wbWinPage != null) {

			final IWorkbenchPart wbWinPagePart = wbWinPage.getActivePart();
			if (wbWinPagePart != null) {

				final IWorkbenchPartSite site = wbWinPagePart.getSite();
				if (site != null) {

					final ISelectionProvider selectionProvider = site.getSelectionProvider();
					if (selectionProvider instanceof PostSelectionProvider) {

						/*
						 * restore view state when this view is maximized
						 */
						final IWorkbenchPartReference activePartReference = wbWinPage.getActivePartReference();
						final int partState = wbWinPage.getPartState(activePartReference);

						if (partState != IWorkbenchPage.STATE_RESTORED) {
							wbWinPage.setPartState(activePartReference, IWorkbenchPage.STATE_RESTORED);
						}

						// fire selection
						((PostSelectionProvider) selectionProvider).setSelection(selection);

						return true;
					}
				}
			}
		}
	}

	return false;
}
 
开发者ID:wolfgang-ch,项目名称:mytourbook,代码行数:46,代码来源:PostSelectionProvider.java

示例7: run

import org.eclipse.ui.IWorkbenchPartSite; //导入方法依赖的package包/类
@Override
public void run() {
	IWorkbenchWizard createWizard;
	try {
		createWizard = descriptor.createWizard();
		IWorkbench workbench = workbenchWindow.getWorkbench();
		IStructuredSelection sselection = StructuredSelection.EMPTY;
		if( selection instanceof StructuredSelection ){
			sselection = (StructuredSelection)selection;	
		}else {
			List<EnsembleCommonNavigator> navigators = EnsembleCommonNavigator.getExistingInstances(EnsembleCommonNavigator.class);
			for (EnsembleCommonNavigator navigator : navigators) {
				IWorkbenchPartSite site = navigator.getSite();
				if(site != null) {
					ISelectionProvider selectionProvider = site.getSelectionProvider();
					ISelection potentialSelection = selectionProvider.getSelection();
					if(potentialSelection instanceof IStructuredSelection) {
						sselection = (IStructuredSelection) potentialSelection;
						break;
					}
					
				}
			}
		}
		createWizard.init(workbench, sselection);
		
	} catch (CoreException e) {
		MessageDialog.openError(null, "Error creating wizard", e.getMessage());
		return;
	}
	WizardDialog dialog = new WizardDialog(null, createWizard);
	dialog.open();
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:34,代码来源:OpenWizardDialogAction.java

示例8: setSite

import org.eclipse.ui.IWorkbenchPartSite; //导入方法依赖的package包/类
@Override
protected void setSite(IWorkbenchPartSite newSite) {
	if (selectionProvider != null) {
		selectionProvider.removeSelectionChangedListener(selectionChangedListener);
		selectionProvider = null;
	}
    super.setSite(newSite);
    if (newSite != null) {
    	selectionProvider = newSite.getSelectionProvider();
		if (selectionProvider != null) {
			selectionProvider.addSelectionChangedListener(selectionChangedListener);
		}
    }
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:15,代码来源:AbstractEnsembleEditorPart.java

示例9: updateEnablement

import org.eclipse.ui.IWorkbenchPartSite; //导入方法依赖的package包/类
public void updateEnablement() {
	boolean shouldBeEnabled = false;
	IWorkbenchPartSite site = templatePlanView.getSite();
	if (site != null) {
		ISelectionProvider selectionProvider = site.getSelectionProvider();
		if (selectionProvider != null) {
			ISelection selection = selectionProvider.getSelection();
			shouldBeEnabled = shouldBeEnabled(selection);
		}
	}
	setEnabled(shouldBeEnabled);
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:13,代码来源:TemplatePlanViewAddAction.java

示例10: computeInput

import org.eclipse.ui.IWorkbenchPartSite; //导入方法依赖的package包/类
@Override
protected Object computeInput(Object input) {
	if (getControl() == null || ! (input instanceof IJavaElement))
		return null;

	IWorkbenchPart part= null;
	IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
	if (window != null) {
		IWorkbenchPage page= window.getActivePage();
		if (page != null) {
			part= page.getActivePart();
		}
	}

	ISelection selection= null;
	if (part != null) {
		IWorkbenchPartSite site= part.getSite();
		if (site != null) {
			ISelectionProvider provider= site.getSelectionProvider();
			if (provider != null) {
				selection= provider.getSelection();
			}
		}
	}

	return computeInput(part, selection, (IJavaElement) input, new NullProgressMonitor());
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:28,代码来源:JavadocView.java

示例11: setSelectionFromEditor

import org.eclipse.ui.IWorkbenchPartSite; //导入方法依赖的package包/类
void setSelectionFromEditor(IWorkbenchPart part) {
	if (!fProcessSelectionEvents || !linkBrowsingViewSelectionToEditor() || !(part instanceof IEditorPart))
		return;

	IWorkbenchPartSite site= part.getSite();
	if (site == null)
		return;
	ISelectionProvider provider= site.getSelectionProvider();
	if (provider != null)
		setSelectionFromEditor(part, provider.getSelection());
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:12,代码来源:JavaBrowsingPart.java

示例12: computeInput

import org.eclipse.ui.IWorkbenchPartSite; //导入方法依赖的package包/类
@Override
protected Object computeInput(Object input) {
	if (getControl() == null || ! (input instanceof IJavaElement))
		return getInputForNull();

	IWorkbenchPart part= null;
	IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
	if (window != null) {
		IWorkbenchPage page= window.getActivePage();
		if (page != null) {
			part= page.getActivePart();
		}
	}

	ISelection selection= null;
	if (part != null) {
		IWorkbenchPartSite site= part.getSite();
		if (site != null) {
			ISelectionProvider provider= site.getSelectionProvider();
			if (provider != null) {
				selection= provider.getSelection();
			}
		}
	}

	return computeInput(part, selection, (IJavaElement) input, new NullProgressMonitor());
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:28,代码来源:JavadocView.java

示例13: run

import org.eclipse.ui.IWorkbenchPartSite; //导入方法依赖的package包/类
public void run(IAction action)
{
    IWorkbenchPartSite site = _part.getSite();
    provider = site.getSelectionProvider();
    if (_selected == null)
    {
        MessageDialog.openInformation(new Shell(), "VelocityPlugin", "Unable to open file");
        // VelocityPlugin.log("Unable to open file");
        return;
    }
    if (_selected instanceof IStructuredSelection)
    {
        //
        try
        {
            Object[] items = ((IStructuredSelection) _selected).toArray();
            Set files = new HashSet(items.length, 1.0F);
            try
            {
                for (int i = 0; i < items.length; i++)
                {
                    if (items[i] instanceof IResource)
                    {
                        IResource resource = (IResource) items[i];
                        switch (resource.getType())
                        {
                            case IResource.FOLDER:
                            case IResource.PROJECT:
                                IContainer folder = (IContainer) items[i];
                                getChildren(folder, files);
                                break;
                            case IResource.FILE:
                                files.add((IFile) items[i]);
                                // ((IFile) items[i]).getProject()
                                break;
                            default:
                                /**
                                 * @todo use logger to print warning about
                                 *       invalid type
                                 */
                                break;
                        }
                    }
                }
            }
            catch (CoreException ex)
            {
                ex.printStackTrace();
            }
            for (Iterator iter = files.iterator(); iter.hasNext();)
            {
                IFile directory = (IFile) iter.next();
                formatFile(directory);
               
            }
        }
        catch (Exception e)
        {
            VelocityPlugin.log(e);
        }
    } else
    {
        MessageDialog.openInformation(new Shell(), "VelocityPlugin", "Unable to open file");
        // VelocityPlugin.log("Unable to open shell");
        return;
    }
}
 
开发者ID:ninneko,项目名称:velocity-edit,代码行数:68,代码来源:FormatResourceAction.java

示例14: dispose

import org.eclipse.ui.IWorkbenchPartSite; //导入方法依赖的package包/类
@Override
public void dispose() {
	UndoRedoUtils.disposeUndoRedo(getEditorSite().getActionBars());
	super.dispose();
	if (editingDomain != null) {
		editingDomain.removeResourceSetListener(pageExtentListener);
	}
	if (listener != null) {
		listener.dispose();
		listener = null;
	}
	if (dirtyMonitor != null) {
		dirtyMonitor.dispose();
		dirtyMonitor = null;
	}
	if (synchronizer != null) {
		synchronizer.dispose();
		synchronizer = null;
	}
	if (editingDomain != null) {
		editingDomain.dispose();
		ResourceSet resourceSet = editingDomain.getResourceSet();
		editingDomain = null;
		for (Resource r : resourceSet.getResources()) {
			r.unload();
		}
	}
	if (timeline != null) {
		timeline.dispose();
		timeline = null;
	}
	if (timelineModel != null) {
		timelineModel = null;
	}
	if (profileSynchronizer != null) {
		profileSynchronizer.dispose();
		profileSynchronizer = null;
	}
	IWorkbenchPartSite site = getSite();
	if (site != null) {
		ISelectionProvider provider = site.getSelectionProvider();
		if (provider != null) {
			provider.setSelection(StructuredSelection.EMPTY);
		}
	}
	if (undoContext != null) {
		IOperationHistory history = OperationHistoryFactory.getOperationHistory();
		history.dispose(undoContext, true, true, true);
		undoContext = null;
	}
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:52,代码来源:ChartEditor.java


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