类org.eclipse.ui.part.IShowInTarget源码实例Demo

下面列出了怎么用org.eclipse.ui.part.IShowInTarget的API类实例代码及写法,或者点击链接到github查看源代码。

public Object getAdapter(Class key) {
	if (key == IShowInSource.class) {
		return getShowInSource();
	}
	if (key == IShowInTargetList.class) {
		return new IShowInTargetList() {
			public String[] getShowInTargetIds() {
				return new String[] { JavaUI.ID_PACKAGES };
			}

		};
	}
	if (key == IShowInTarget.class) {
		return getShowInTarget();
	}

	return null;
}
 
/**
 * Returns the <code>IShowInTarget</code> for this view.
 *
 * @return the {@link IShowInTarget}
 */
protected IShowInTarget getShowInTarget() {
	return new IShowInTarget() {
		public boolean show(ShowInContext context) {
			ISelection sel= context.getSelection();
			if (sel instanceof ITextSelection) {
				ITextSelection tsel= (ITextSelection) sel;
				int offset= tsel.getOffset();
				IJavaElement element= fEditor.getElementAt(offset);
				if (element != null) {
					setSelection(new StructuredSelection(element));
					return true;
				}
			} else if (sel instanceof IStructuredSelection) {
				setSelection(sel);
				return true;
			}
			return false;
		}
	};
}
 
源代码3 项目: goclipse   文件: LangOutlinePage.java
protected IShowInTarget getShowInTarget() {
	return new IShowInTarget() {
		@Override
		public boolean show(ShowInContext context) {
			StructureElement structureElement = getStructureElementFor(context.getSelection());
			
			if(structureElement != null) {
				setSelection(new StructuredSelection(structureElement));
				return true;
			}
			
			return false;
		}

	};
}
 
源代码4 项目: KaiZen-OpenAPI-Editor   文件: DocumentUtils.java
/**
 * Opens the editor for the file located at the given path and reveal the selection.
 * 
 * @param path
 * @param selection
 */
public static void openAndReveal(IPath path, ISelection selection) {
    final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    final IFile file = root.getFile(path);
    final IEditorPart editor = openEditor(file);

    if (editor instanceof IShowInTarget) {
        IShowInTarget showIn = (IShowInTarget) editor;
        showIn.show(new ShowInContext(null, selection));
    }
}
 
源代码5 项目: Pydev   文件: BaseOutlinePage.java
@Override
public Object getAdapter(Class adapter) {
    if (adapter == IShowInTarget.class) {
        return this;
    }
    return null;
}
 
源代码6 项目: goclipse   文件: LangOutlinePage.java
@SuppressWarnings("unchecked")
@Override
public <T> T getAdapter(Class<T> adapter) {
	if(adapter == IShowInTarget.class) {
		return (T) getShowInTarget();
	}
	
	return null;
}
 
public JsonContentOutlinePage(IDocumentProvider documentProvider, IShowInTarget showInTarget) {
    super();
    this.documentProvider = documentProvider;
    this.showInTarget = showInTarget;
}
 
 类所在包
 同包方法