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


Java IAdaptable类代码示例

本文整理汇总了Java中org.eclipse.core.runtime.IAdaptable的典型用法代码示例。如果您正苦于以下问题:Java IAdaptable类的具体用法?Java IAdaptable怎么用?Java IAdaptable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: execute

import org.eclipse.core.runtime.IAdaptable; //导入依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
	/*MessageDialog.openInformation(
			window.getShell(),
			"Plugin",
			"Hello, Eclipse world");*/
	
	// Pfad vom Projekt
    if (window != null)
    {
        IStructuredSelection selection = (IStructuredSelection) window.getSelectionService().getSelection();
        Object firstElement = selection.getFirstElement();
        if (firstElement instanceof IAdaptable)
        {
            IProject project = (IProject)((IAdaptable)firstElement).getAdapter(IProject.class);
            IPath path = project.getFullPath();
            System.out.println("Projekt: "+path);
            StartEGL.start(""+path);
        }
    }
	
	return null;
}
 
开发者ID:Nielko,项目名称:MBSE-Vacation-Manager,代码行数:25,代码来源:ExportHandler.java

示例2: getParent

import org.eclipse.core.runtime.IAdaptable; //导入依赖的package包/类
@Override
public Object getParent(Object element) {

	// Required by editor - navigator linking to locate parent item in tree.
	if (element instanceof IProject && workingSetManagerBroker.isWorkingSetTopLevel()) {
		final WorkingSetManager activeManager = workingSetManagerBroker.getActiveManager();
		if (activeManager != null) {
			for (final WorkingSet workingSet : activeManager.getWorkingSets()) {
				final IAdaptable[] elements = workingSet.getElements();
				if (!Arrays2.isEmpty(elements) && Arrays.contains(elements, element)) {
					return workingSet;
				}
			}
		}
	}

	return super.getParent(element);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:19,代码来源:N4JSProjectExplorerContentProvider.java

示例3: getElements

import org.eclipse.core.runtime.IAdaptable; //导入依赖的package包/类
@Override
public IAdaptable[] getElements() {
	final IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
	final IProject[] elements = new IProject[projects.length];
	int elementCount = 0;
	for (int i = 0, size = projects.length; i < size; i++) {
		final IProject project = projects[i];
		final IN4JSProject n4Project = core.findProject(toUri(project)).orNull();
		if (type == null) { // Other Projects
			if (n4Project == null || !n4Project.exists()) {
				elements[elementCount++] = project;
			}
		} else {
			if (n4Project != null && n4Project.exists() && type.equals(n4Project.getProjectType())) {
				elements[elementCount++] = project;
			}
		}
	}
	return Arrays.copyOfRange(elements, 0, elementCount);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:21,代码来源:ProjectTypeAwareWorkingSetManager.java

示例4: isModel

import org.eclipse.core.runtime.IAdaptable; //导入依赖的package包/类
protected boolean isModel(IAdaptable receiver){
	IFile modelFile = (IFile)(receiver).getAdapter(IFile.class);
	if(modelFile !=null){
		ResourceSet rs = new ResourceSetImpl();
		URI modelURI = URI.createURI("platform:/resource/"+modelFile.getFullPath().toString());
		try{
			Resource resource = rs.getResource(modelURI, true);
		if (resource != null) {
			return true;
		}
		} catch (Exception e){
			// not a valid model, simply ignore
			return false;
		}
	}
	return false;
}
 
开发者ID:eclipse,项目名称:gemoc-studio-modeldebugging,代码行数:18,代码来源:GemocSequentialPropertyTester.java

示例5: test

import org.eclipse.core.runtime.IAdaptable; //导入依赖的package包/类
/**
 * Method runs the tests defined from extension points for Run As... and Debug As... menu items.
 * 
 * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
 * @since 3.2
 * @return true if the specified tests pass, false otherwise
 */
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {

	if(PROPERTY_IS_MODEL.equals(property)) {
		if (receiver instanceof IAdaptable) {
			return isModel((IAdaptable)receiver);
		}
		return false;
	}
	if(PROPERTY_IS_EXECUTABLE_DOMAIN_SPECIFIC_MODEL.equals(property)) {
		if (receiver instanceof IAdaptable) {
			return isExecutableDomainSpecificModel((IAdaptable)receiver);
		}
		return false;
	}
	return false;
}
 
开发者ID:eclipse,项目名称:gemoc-studio-modeldebugging,代码行数:24,代码来源:GemocSequentialPropertyTester.java

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

示例7: getAdapter

import org.eclipse.core.runtime.IAdaptable; //导入依赖的package包/类
@Override
public <T> T getAdapter ( final Class<T> adapter )
{
    logger.info ( "Get adaper: {}", adapter );
    if ( adapter == ConnectionDiscoverer.class )
    {
        return adapter.cast ( this.discoverer );
    }
    if ( adapter == ConnectionStore.class && this.discoverer instanceof ConnectionStore )
    {
        return adapter.cast ( this.discoverer );
    }
    if ( this.discoverer instanceof IAdaptable )
    {
        return ( (IAdaptable)this.discoverer ).getAdapter ( adapter );
    }
    return null;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:19,代码来源:ConnectionDiscovererBean.java

示例8: selectionChanged

import org.eclipse.core.runtime.IAdaptable; //导入依赖的package包/类
@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {

	if (!getViewSite().getPage().isPartVisible(this)) return;
	if (selection instanceof IStructuredSelection) {
		Object ob = ((IStructuredSelection)selection).getFirstElement();

		// This slightly funny alg or assign and sometimes update
		// is correct. Do not change unless sure that UI is working afterwards.
		if (ob instanceof IAdaptable) { // TODO Replace with ScanBuilderService
               CompoundModel<IROI> cm = ((IAdaptable)ob).getAdapter(CompoundModel.class);
               if (cm !=null) modelAdaptable = (IAdaptable)ob;
		}
		if (isUpdatableSelection(ob)) updateJob.schedule();

	}
}
 
开发者ID:eclipse,项目名称:scanning,代码行数:18,代码来源:ExecuteView.java

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

示例10: getSelectedFile

import org.eclipse.core.runtime.IAdaptable; //导入依赖的package包/类
protected IFile getSelectedFile() {
	IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
	if (window == null) {
		return null;
	}
	
	ISelection selection = window.getSelectionService().getSelection();
	if (! (selection instanceof IStructuredSelection)){
		return null;
	}
	IStructuredSelection structuredSelection = (IStructuredSelection) selection;
	
	Object firstElement = structuredSelection.getFirstElement();
	if (!(firstElement instanceof IAdaptable)) {
		return null;
	}

	IFile file = (IFile) ((IAdaptable) firstElement).getAdapter(IFile.class);
	return file;
}
 
开发者ID:de-jcup,项目名称:eclipse-bash-editor,代码行数:21,代码来源:OpenWithBashEditor.java

示例11: execute

import org.eclipse.core.runtime.IAdaptable; //导入依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
  ISelection selection = MarkerFactory.getSelection();
  if (selection instanceof ITreeSelection) {
    ITreeSelection treeSelection = (ITreeSelection) selection;
    if (treeSelection.getFirstElement() instanceof IOpenable
        || treeSelection.getFirstElement() instanceof IFile) {
      IResource resource =
          ((IAdaptable) treeSelection.getFirstElement()).getAdapter(IResource.class);
      List<IMarker> markers = MarkerFactory.findMarkers(resource);
      MessageDialog dialog = new MessageDialog(MarkerActivator.getShell(), "Marker Count", null,
          markers.size() + " marker(s)", MessageDialog.INFORMATION, new String[] {"OK"}, 0);
      dialog.open();
    }
  }
  return null;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:18,代码来源:CountMarkersInResourceHandler.java

示例12: execute

import org.eclipse.core.runtime.IAdaptable; //导入依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	TreeSelection selection = (TreeSelection) HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection();
	Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
	Object firstElement = selection.getFirstElement();
	
	if (firstElement instanceof IAdaptable)
       {
           IFile file = (IFile)((IAdaptable)firstElement).getAdapter(IFile.class);
           IPath path = file.getLocation();
           
           try {
           	//TODO fix
			SurveyGenerator.generateAll(path.toOSString(), path.toOSString());
			MessageDialog.openInformation(shell, "Success", "Code was generated successfully");
		} catch (Exception e) {
			//MessageDialog.openError(shell, "Error", e.getMessage());
			e.printStackTrace();
		}
       }
	return null;
}
 
开发者ID:TodorovicNikola,项目名称:SurveyDSL,代码行数:23,代码来源:GenerateATLHandler.java

示例13: execute

import org.eclipse.core.runtime.IAdaptable; //导入依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
  final IPath containerPath = new Path(Initializer.APGAS_CONTAINER_ID);
  try {
    final IJavaProject javaProject = JavaCore
        .create(((IAdaptable) ((IStructuredSelection) HandlerUtil
            .getCurrentSelection(event)).getFirstElement())
                .getAdapter(IProject.class));
    final IClasspathEntry[] entries = javaProject.getRawClasspath();
    for (int i = 0; i < entries.length; i++) {
      if (entries[i].getEntryKind() == IClasspathEntry.CPE_CONTAINER
          && entries[i].getPath().equals(containerPath)) {
        return null;
      }
    }
    final IClasspathEntry[] cp = new IClasspathEntry[entries.length + 1];
    System.arraycopy(entries, 0, cp, 0, entries.length);
    cp[entries.length] = JavaCore.newContainerEntry(containerPath);
    javaProject.setRawClasspath(cp, new NullProgressMonitor());
  } catch (final Exception e) {
    throw new ExecutionException(e.toString(), e);
  }
  return null;
}
 
开发者ID:x10-lang,项目名称:apgas,代码行数:25,代码来源:Handler.java

示例14: searchAndLaunch

import org.eclipse.core.runtime.IAdaptable; //导入依赖的package包/类
/**
 * Resolves a type that can be launched from the given scope and launches in
 * the specified mode.
 * 
 * @param resources
 *            the java children to consider for a type that can be launched
 * @param mode
 *            launch mode
 * @param selectTitle
 *            prompting title for choosing a type to launch
 * @param additionalScope
 *            additional scope for launch
 * @param emptyMessage
 *            error message when no types are resolved for launching
 */
private void searchAndLaunch(Object[] resources, Object additionalScope, String mode, String selectTitle,
		String emptyMessage) {
	IResource resource = null;
	Object object = resources[0];
	if (object instanceof IResource) {
		resource = (IResource) object;
	} else if (object instanceof IAdaptable) {
		IAdaptable adaptable = (IAdaptable) object;
		resource = getLaunchableResource(adaptable);
	} else {
		throw new IllegalArgumentException("EGradle launch shortcut cannot handle object type:" + object);
	}
	if (resource != null) {
		launch(resource, additionalScope, mode);
	}
}
 
开发者ID:de-jcup,项目名称:egradle,代码行数:32,代码来源:EGradleLaunchShortCut.java

示例15: findSelectedProject

import org.eclipse.core.runtime.IAdaptable; //导入依赖的package包/类
private IProject findSelectedProject() {
	IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
	if (window == null) {
		return null;
	}
	
	IStructuredSelection selection = (IStructuredSelection) window.getSelectionService().getSelection();
	if (selection ==null){
		return null;
	}
	
	Object firstElement = selection.getFirstElement();
	if (!(firstElement instanceof IAdaptable)) {
		return null;
	}

	IProject project = (IProject) ((IAdaptable) firstElement).getAdapter(IProject.class);
	return project;
}
 
开发者ID:de-jcup,项目名称:egradle,代码行数:20,代码来源:ShowDependenciesOfSelectecProjectHandler.java


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