本文整理汇总了Java中org.eclipse.core.runtime.IAdaptable.getAdapter方法的典型用法代码示例。如果您正苦于以下问题:Java IAdaptable.getAdapter方法的具体用法?Java IAdaptable.getAdapter怎么用?Java IAdaptable.getAdapter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.core.runtime.IAdaptable
的用法示例。
在下文中一共展示了IAdaptable.getAdapter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: BatchSourceViewerConfiguration
import org.eclipse.core.runtime.IAdaptable; //导入方法依赖的package包/类
/**
* Creates configuration by given adaptable
*
* @param adaptable
* must provide {@link ColorManager} and {@link IFile}
*/
public BatchSourceViewerConfiguration(IAdaptable adaptable) {
IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore();
this.fPreferenceStore = new ChainedPreferenceStore(
new IPreferenceStore[] { getPreferences().getPreferenceStore(), generalTextStore });
Assert.isNotNull(adaptable, "adaptable may not be null!");
this.annotationHoover = new BatchEditorAnnotationHoover();
this.contentAssistant = new ContentAssistant();
contentAssistProcessor = new BatchEditorSimpleWordContentAssistProcessor();
contentAssistant.enableColoredLabels(true);
contentAssistant.setContentAssistProcessor(contentAssistProcessor, IDocument.DEFAULT_CONTENT_TYPE);
for (BatchDocumentIdentifier identifier: BatchDocumentIdentifiers.values()){
contentAssistant.setContentAssistProcessor(contentAssistProcessor, identifier.getId());
}
contentAssistant.addCompletionListener(contentAssistProcessor.getCompletionListener());
this.colorManager = adaptable.getAdapter(ColorManager.class);
Assert.isNotNull(colorManager, " adaptable must support color manager");
this.defaultTextAttribute = new TextAttribute(
colorManager.getColor(getPreferences().getColor(COLOR_NORMAL_TEXT)));
this.adaptable=adaptable;
}
示例2: BashSourceViewerConfiguration
import org.eclipse.core.runtime.IAdaptable; //导入方法依赖的package包/类
/**
* Creates configuration by given adaptable
*
* @param adaptable
* must provide {@link ColorManager} and {@link IFile}
*/
public BashSourceViewerConfiguration(IAdaptable adaptable) {
IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore();
this.fPreferenceStore = new ChainedPreferenceStore(
new IPreferenceStore[] { getPreferences().getPreferenceStore(), generalTextStore });
Assert.isNotNull(adaptable, "adaptable may not be null!");
this.annotationHoover = new BashEditorAnnotationHoover();
this.contentAssistant = new ContentAssistant();
contentAssistProcessor = new BashEditorSimpleWordContentAssistProcessor();
contentAssistant.enableColoredLabels(true);
contentAssistant.setContentAssistProcessor(contentAssistProcessor, IDocument.DEFAULT_CONTENT_TYPE);
for (BashDocumentIdentifier identifier: BashDocumentIdentifiers.values()){
contentAssistant.setContentAssistProcessor(contentAssistProcessor, identifier.getId());
}
contentAssistant.addCompletionListener(contentAssistProcessor.getCompletionListener());
this.colorManager = adaptable.getAdapter(ColorManager.class);
Assert.isNotNull(colorManager, " adaptable must support color manager");
this.defaultTextAttribute = new TextAttribute(
colorManager.getColor(getPreferences().getColor(COLOR_NORMAL_TEXT)));
this.adaptable=adaptable;
}
示例3: addProjectToSelectedWorkingSet
import org.eclipse.core.runtime.IAdaptable; //导入方法依赖的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});
}
}
}
}
示例4: ModernActionKeyBindingSupport
import org.eclipse.core.runtime.IAdaptable; //导入方法依赖的package包/类
private ModernActionKeyBindingSupport(
final IAdaptable serviceLocator,
final Expression expression,
final int sourcePriorities) {
Check.notNull(serviceLocator, "serviceLocator"); //$NON-NLS-1$
Check.notNull(expression, "expression"); //$NON-NLS-1$
bindingService = (IBindingService) serviceLocator.getAdapter(IBindingService.class);
handlerService = (IHandlerService) serviceLocator.getAdapter(IHandlerService.class);
if (bindingService == null || handlerService == null) {
throw new IllegalArgumentException(
"specified IAdapable could not provide IBindingService or IHandlerService"); //$NON-NLS-1$
}
this.expression = expression;
this.sourcePriorities = sourcePriorities;
}
示例5: JenkinsEditorOutlineContentProvider
import org.eclipse.core.runtime.IAdaptable; //导入方法依赖的package包/类
public JenkinsEditorOutlineContentProvider(IAdaptable adaptable) {
outlineErrorMarkerHelper= createOutlineErrorMarkerHelper();
if (adaptable==null){
return;
}
this.editor = adaptable.getAdapter(IExtendedEditor.class);
this.logSupport = editor.getLogSupport();
}
示例6: canExecute
import org.eclipse.core.runtime.IAdaptable; //导入方法依赖的package包/类
@Override
public boolean canExecute() {
if ((selectedObjects == null) || selectedObjects.size() == 0)
return false;
parts = new ArrayList<EditPart>();
for (Object sel : selectedObjects) {
if ( sel != null && sel instanceof IAdaptable) {
IAdaptable adaptable = (IAdaptable)sel;
EdgePart part = adaptable.getAdapter(EdgePart.class);
if (part!=null) parts.add(part);
}
}
return parts.size() > 0;
}
示例7: getSelectedRemoteFiles
import org.eclipse.core.runtime.IAdaptable; //导入方法依赖的package包/类
/**
* Returns the selected remote files
*/
protected ISVNRemoteFile[] getSelectedRemoteFiles() {
ArrayList resources = null;
if (selection != null && !selection.isEmpty()) {
resources = new ArrayList();
Iterator elements = selection.iterator();
while (elements.hasNext()) {
Object next = elements.next();
if (next instanceof ISVNRemoteFile) {
resources.add(next);
continue;
}
if (next instanceof IAdaptable) {
IAdaptable a = (IAdaptable) next;
Object adapter = a.getAdapter(ISVNRemoteFile.class);
if (adapter instanceof ISVNRemoteFile) {
resources.add(adapter);
continue;
}
}
}
}
if (resources != null && !resources.isEmpty()) {
ISVNRemoteFile[] result = new ISVNRemoteFile[resources.size()];
resources.toArray(result);
return result;
}
return new ISVNRemoteFile[0];
}
示例8: setElement
import org.eclipse.core.runtime.IAdaptable; //导入方法依赖的package包/类
@Override
public void setElement(IAdaptable element) {
this.selectedProject = element.getAdapter(IProject.class);
if (selectedProject == null) {
throw new IllegalArgumentException(
"Provided element " + element + " isn't adaptable to a project."); //$NON-NLS-1$ //$NON-NLS-2$
} else {
this.preferences = WritableDataflowPreferences.forProject(this.selectedProject);
}
}
示例9: getAdapter
import org.eclipse.core.runtime.IAdaptable; //导入方法依赖的package包/类
/**
* Find the object associated with the selected object that is adapted to
* the provided class.
*
* @param selection
* @param c
* @return Object
*/
public static Object getAdapter(Object selection, Class c) {
if (c.isInstance(selection)) {
return selection;
}
if (selection instanceof IAdaptable) {
IAdaptable a = (IAdaptable) selection;
Object adapter = a.getAdapter(c);
if (c.isInstance(adapter)) {
return adapter;
}
}
return null;
}
示例10: getElementLabel
import org.eclipse.core.runtime.IAdaptable; //导入方法依赖的package包/类
/**
* A convenience method for getting the label of an adaptable
* object that responds to the IWorkbenchAdapter adapter interface.
* Returns a toString() of the object if it is not adaptable
*/
public static String getElementLabel(IAdaptable a) {
if (a == null) {
return "";//$NON-NLS-1$
}
IWorkbenchAdapter adapter = (IWorkbenchAdapter)a.getAdapter(IWorkbenchAdapter.class);
if (adapter != null) {
return adapter.getLabel(a);
} else {
return a.toString();
}
}
示例11: GradleEditorOutlineContentProvider
import org.eclipse.core.runtime.IAdaptable; //导入方法依赖的package包/类
public GradleEditorOutlineContentProvider(IAdaptable adaptable) {
outlineErrorMarkerHelper = createOutlineErrorMarkerHelper();
if (adaptable == null) {
return;
}
this.editor = adaptable.getAdapter(IExtendedEditor.class);
this.logSupport = editor.getLogSupport();
}
示例12: getLaunchableResource
import org.eclipse.core.runtime.IAdaptable; //导入方法依赖的package包/类
@Override
public IResource getLaunchableResource(ISelection selection) {
if (!selection.isEmpty() && selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
Object element = structuredSelection.getFirstElement();
if (element instanceof IAdaptable) {
IAdaptable adaptable = (IAdaptable) element;
return adaptable.getAdapter(IResource.class);
}
}
return null;
}
示例13: testIsDataflowProject
import org.eclipse.core.runtime.IAdaptable; //导入方法依赖的package包/类
private boolean testIsDataflowProject(Object receiver) {
if (receiver instanceof IAdaptable) {
IAdaptable adaptable = (IAdaptable) receiver;
IProject project = adaptable.getAdapter(IProject.class);
return isProjectDataflowProject(project);
}
return false;
}
示例14: getModelObjectResource
import org.eclipse.core.runtime.IAdaptable; //导入方法依赖的package包/类
public static IResource getModelObjectResource(Object o) {
IResource resource = null;
if (o instanceof IResource) {
resource = (IResource) o;
} else if (o instanceof IAdaptable) {
IAdaptable adaptable = (IAdaptable) o;
resource = (IResource)adaptable.getAdapter(IResource.class);
if (resource == null) {
IContributorResourceAdapter adapter = (IContributorResourceAdapter)adaptable.getAdapter(IContributorResourceAdapter.class);
if (adapter != null)
resource = adapter.getAdaptedResource(adaptable);
}
}
return resource;
}
示例15: getJavaElement
import org.eclipse.core.runtime.IAdaptable; //导入方法依赖的package包/类
/**
* Try to derive a java element handle from the given object.
*
* @param object
* base object
* @return java element handle or <code>null</code>
*/
private IJavaElement getJavaElement(Object object) {
if (object instanceof IJavaElement) {
return (IJavaElement) object;
}
if (object instanceof IAdaptable) {
IAdaptable a = (IAdaptable) object;
return (IJavaElement) a.getAdapter(IJavaElement.class);
}
return null;
}