org.eclipse.ui.part.IShowInTarget Java Examples

The following examples show how to use org.eclipse.ui.part.IShowInTarget. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JavaOutlinePage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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;
}
 
Example #2
Source File: JavaOutlinePage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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;
		}
	};
}
 
Example #3
Source File: LangOutlinePage.java    From goclipse with Eclipse Public License 1.0 6 votes vote down vote up
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;
		}

	};
}
 
Example #4
Source File: DocumentUtils.java    From KaiZen-OpenAPI-Editor with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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));
    }
}
 
Example #5
Source File: BaseOutlinePage.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Object getAdapter(Class adapter) {
    if (adapter == IShowInTarget.class) {
        return this;
    }
    return null;
}
 
Example #6
Source File: LangOutlinePage.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public <T> T getAdapter(Class<T> adapter) {
	if(adapter == IShowInTarget.class) {
		return (T) getShowInTarget();
	}
	
	return null;
}
 
Example #7
Source File: JsonContentOutlinePage.java    From KaiZen-OpenAPI-Editor with Eclipse Public License 1.0 4 votes vote down vote up
public JsonContentOutlinePage(IDocumentProvider documentProvider, IShowInTarget showInTarget) {
    super();
    this.documentProvider = documentProvider;
    this.showInTarget = showInTarget;
}