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


Java IAdaptable.getAdapter方法代码示例

本文整理汇总了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;
}
 
开发者ID:de-jcup,项目名称:eclipse-batch-editor,代码行数:32,代码来源:BatchSourceViewerConfiguration.java

示例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;
}
 
开发者ID:de-jcup,项目名称:eclipse-bash-editor,代码行数:32,代码来源:BashSourceViewerConfiguration.java

示例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});
			}
		}
	}
}
 
开发者ID:DarwinSPL,项目名称:DarwinSPL,代码行数:30,代码来源:DwprofileNewProjectWizardLogic.java

示例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;
}
 
开发者ID:Microsoft,项目名称:team-explorer-everywhere,代码行数:19,代码来源:ModernActionKeyBindingSupport.java

示例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();
}
 
开发者ID:de-jcup,项目名称:eclipse-jenkins-editor,代码行数:9,代码来源:JenkinsEditorOutlineContentProvider.java

示例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;
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:16,代码来源:ClearEdgeBendpointLayoutCommand.java

示例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];
}
 
开发者ID:subclipse,项目名称:subclipse,代码行数:32,代码来源:SVNAction.java

示例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);
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:11,代码来源:DefaultRunOptionsPage.java

示例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;
}
 
开发者ID:subclipse,项目名称:subclipse,代码行数:22,代码来源:SVNAction.java

示例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();
	}
}
 
开发者ID:subclipse,项目名称:subclipse,代码行数:17,代码来源:WorkbenchAdapter.java

示例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();
}
 
开发者ID:de-jcup,项目名称:egradle,代码行数:9,代码来源:GradleEditorOutlineContentProvider.java

示例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;
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:13,代码来源:LaunchPipelineShortcut.java

示例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;
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:9,代码来源:DataflowPropertyTester.java

示例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;
}
 
开发者ID:subclipse,项目名称:subclipse,代码行数:16,代码来源:SVNLightweightDecorator.java

示例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;
}
 
开发者ID:eclipse,项目名称:eclemma,代码行数:18,代码来源:SelectionTracker.java


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