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

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

源代码1 项目: APICloud-Studio   文件: InvasiveThemeHijacker.java
public void partClosed(IWorkbenchPartReference partRef)
{
	if (partRef instanceof IEditorReference)
	{
		IEditorPart part = (IEditorPart) partRef.getPart(false);
		if (part instanceof MultiPageEditorPart)
		{
			MultiPageEditorPart multi = (MultiPageEditorPart) part;
			if (pageListener != null)
			{
				multi.getSite().getSelectionProvider().removeSelectionChangedListener(pageListener);
			}
		}
	}
	// If it's a search view, remove any query listeners for it!
	else if (partRef instanceof IViewReference)
	{
		IViewPart view = (IViewPart) partRef.getPart(false);
		if (queryListeners.containsKey(view))
		{
			NewSearchUI.removeQueryListener(queryListeners.remove(view));
		}
	}
}
 
源代码2 项目: APICloud-Studio   文件: InvasiveThemeHijacker.java
public void partOpened(IWorkbenchPartReference partRef)
{
	if (partRef instanceof IEditorReference)
	{
		IEditorPart editorPart = (IEditorPart) partRef.getPart(false);
		hijackEditor(editorPart, false);
		if (editorPart instanceof MultiPageEditorPart)
		{
			MultiPageEditorPart multi = (MultiPageEditorPart) editorPart;
			if (pageListener == null)
			{
				pageListener = new ISelectionChangedListener()
				{

					public void selectionChanged(SelectionChangedEvent event)
					{
						hijackOutline();
					}
				};
			}
			multi.getSite().getSelectionProvider().addSelectionChangedListener(pageListener);
		}
		return;
	}

	if (partRef instanceof IViewReference)
	{
		IViewPart view = (IViewPart) partRef.getPart(false);
		hijackView(view, false);
	}
}
 
源代码3 项目: e4macs   文件: MarkRing.java
/**
 * Verify that the editor in the location is still in use
 * 
 * @param location
 * @return true if editor is valid
 */
private boolean checkEditor(IBufferLocation location) {
	boolean result = false;
	if (location != null) {
		ITextEditor editor = location.getEditor(); 
		if (editor != null) {
			IEditorInput input = editor.getEditorInput();
			// check all the editor references that match the input for a match
			IEditorReference[] refs = EmacsPlusUtils.getWorkbenchPage().findEditors(input,null, IWorkbenchPage.MATCH_INPUT); 
			for (int i=0; i< refs.length; i++) {
				IEditorPart ed = refs[i].getEditor(false);
				// multi page annoyance
				if (ed instanceof MultiPageEditorPart) {
					IEditorPart[] eds = ((MultiPageEditorPart)ed).findEditors(input);
					for (int j=0; j < eds.length; j++) {
						if (eds[i] == editor) {
							result = true;
							break;
						}
					}
					if (result) {
						break;
					}
				} else {
					if (ed == editor) {
						result = true;
						break;
					}
				}
			}
		}
	}
	return result;
}
 
源代码4 项目: eclipse-multicursor   文件: ISourceViewerFinder.java
public static ISourceViewer fromEditorPart(IEditorPart editorPart) {
	Object activeEditor = editorPart;
	if (editorPart instanceof MultiPageEditorPart) {
		MultiPageEditorPart multiPageEditorPart = (MultiPageEditorPart) editorPart;
		activeEditor = multiPageEditorPart.getSelectedPage();
	}
	if (activeEditor instanceof AbstractTextEditor) {
		return fromAbstractTextEditor((AbstractTextEditor) activeEditor);
	} else {
		logger.info("Unable to get ISourceViewer from " + editorPart
				+ " of type " + editorPart.getClass().getCanonicalName());
		return null;
	}
}
 
源代码5 项目: uima-uimaj   文件: MultiPageEditorContributor.java
@Override
public void setActiveEditor(IEditorPart part) {
  if (activeEditorPart == part)
    return;

  if (null == part)
    return;
  activeEditorPart = part;

  IActionBars actionBars = getActionBars();
  if (actionBars != null) {

    MultiPageEditorPart editor = (MultiPageEditorPart) part;

    actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), getAction(editor,
            ITextEditorActionConstants.DELETE));
    actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), getAction(editor,
            ITextEditorActionConstants.UNDO));
    actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), getAction(editor,
            ITextEditorActionConstants.REDO));
    actionBars.setGlobalActionHandler(ActionFactory.CUT.getId(), getAction(editor,
            ITextEditorActionConstants.CUT));
    actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), getAction(editor,
            ITextEditorActionConstants.COPY));
    actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), getAction(editor,
            ITextEditorActionConstants.PASTE));
    actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), getAction(editor,
            ITextEditorActionConstants.SELECT_ALL));
    actionBars.setGlobalActionHandler(ActionFactory.FIND.getId(), getAction(editor,
            ITextEditorActionConstants.FIND));
    actionBars.setGlobalActionHandler(IDEActionFactory.BOOKMARK.getId(), getAction(editor,
            IDEActionFactory.BOOKMARK.getId()));
    actionBars.updateActionBars();
  }
}
 
源代码6 项目: e4macs   文件: MarkGlobalHandler.java
/**
 * Get the next position off the global mark ring and move to that file and location
 *
 * @param editor
 * @param document
 * @param currentSelection
 * @param norotate - if true, pop else rotate and pop
 * @return NO_OFFSET
 * @throws BadLocationException
 */
protected int doTransform(ITextEditor editor, IDocument document, ITextSelection currentSelection, boolean norotate, boolean isTags)
throws BadLocationException {
	// get editor and offset
	IBufferLocation location = (isTags ? MarkUtils.popTagMark() : MarkUtils.popGlobalMark(norotate));
	if (location != null) {
		if (currentSelection != null &&
				location.getEditor() == editor && location.getOffset() == currentSelection.getOffset()) {
			// if we're already at the global mark location, move to next location
			// recurse with no selection to avoid infinite loop if only one global location
			return doTransform(editor,document,null,norotate, isTags);
		}
		ITextEditor jumpTo = location.getEditor();
		int offset = location.getOffset();
		IWorkbenchPage page = getWorkbenchPage();
		IEditorPart part = jumpTo;
		if (part != null) {
			// move to the correct page
			IEditorPart apart = part;
			IEditorSite esite = part.getEditorSite();
			if (esite instanceof MultiPageEditorSite) {
				apart = ((MultiPageEditorSite)esite).getMultiPageEditor();
				// handle multi page by activating the correct part within the parent
				if (apart instanceof MultiPageEditorPart) {
					((MultiPageEditorPart)apart).setActiveEditor(part);
				}
			}
			// check to make sure the editor is still valid
			if (page.findEditor(apart.getEditorInput()) != null)  {
				// then activate
				page.activate(apart);
				page.bringToTop(apart);
				if (part instanceof ITextEditor) {
					selectAndReveal((ITextEditor) part,offset,offset);
					EmacsPlusUtils.clearMessage(part);
				}
			} else {
				EmacsPlusUtils.showMessage(editor, String.format(BAD_MARK, apart.getTitle()), true);
			}
		}
	} else {
		beep();
	}
	return NO_OFFSET;
}
 
源代码7 项目: e4macs   文件: RegisterJumpToHandler.java
/**
 * @see com.mulgasoft.emacsplus.minibuffer.IMinibufferExecutable#executeResult(org.eclipse.ui.texteditor.ITextEditor, java.lang.Object)
 */
public boolean doExecuteResult(ITextEditor editor, Object minibufferResult) {

	if (minibufferResult != null) {
		String key = (String)minibufferResult;
		IRegisterLocation location = TecoRegister.getInstance().getLocation(key);
		if (location != null) {
			IWorkbenchPage page = getWorkbenchPage();
			IEditorPart part = location.getEditor(); 
			int offset = location.getOffset();
			if (part != null) {
				// move to the correct page
				IEditorPart apart = part;
				IEditorSite esite = part.getEditorSite();
				if (esite instanceof MultiPageEditorSite) {
					apart = ((MultiPageEditorSite)esite).getMultiPageEditor();
					// handle multi page by activating the correct part within the parent
					if (apart instanceof MultiPageEditorPart) {
						((MultiPageEditorPart)apart).setActiveEditor(part);
					}
				}
				// now activate
				page.activate(apart);
				page.bringToTop(apart);
			} else {
				// restore the resource from the file system
				if (location.getPath() != null) {
					try {
						// loads and activates
						part = IDE.openEditor(page, location.getPath(), true);
						if (part instanceof IEditorPart) {
							if (part instanceof MultiPageEditorPart) {
								IEditorPart[] parts = ((MultiPageEditorPart)part).findEditors(part.getEditorInput());
								//  TODO this will only work on the first load of a multi page
								// There is no supported way to determine the correct sub part in this case
								// Investigate org.eclipse.ui.PageSwitcher (used in org.eclipse.ui.part.MultiPageEditorPart)
								// as a means for locating the correct sub page at this level
								for (int i = 0; i < parts.length; i++) {
									if (parts[i] instanceof ITextEditor) {
										((MultiPageEditorPart)part).setActiveEditor(parts[i]);
										part = parts[i];
										break;
									}
								}
							}
							location.setEditor((ITextEditor)part);
						}
					} catch (PartInitException e) {
						showResultMessage(editor, String.format(BAD_LOCATION,key + ' ' + e.getLocalizedMessage()), true);				
					}
				} else {
					showResultMessage(editor, String.format(NO_LOCATION,key), true);				
				}
			}
			if (part instanceof ITextEditor) {
				((ITextEditor) part).selectAndReveal(offset, 0);
				showResultMessage(editor, String.format(LOCATED, key), false);
			} else {
			
			}
		} else {
			showResultMessage(editor, NO_REGISTER, true);
		}
	}
	return true;
}
 
源代码8 项目: uima-uimaj   文件: MultiPageEditorContributor.java
/**
 * Returns the action registed with the given text editor.
 *
 * @param editor the editor
 * @param actionID the action ID
 * @return IAction or null if editor is null.
 */
protected IAction getAction(MultiPageEditorPart editor, String actionID) {
  ITextEditor txtEditor = ((MultiPageEditor) editor).getSourcePageEditor();
  return (txtEditor == null ? null : txtEditor.getAction(actionID));
}
 
 类所在包
 同包方法