org.eclipse.ui.part.IPage Java Examples

The following examples show how to use org.eclipse.ui.part.IPage. 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: ResourceUtils.java    From LogViewer with Eclipse Public License 2.0 6 votes vote down vote up
public static ITextViewer getViewer(IPage page) {
    if(page == null){
        return null;
    }
    if(page instanceof TextConsolePage) {
        return ((TextConsolePage)page).getViewer();
    }
    if(page.getClass().equals(MessagePage.class)){
        // empty page placeholder
        return null;
    }
    try {
        /*
         * org.eclipse.cdt.internal.ui.buildconsole.BuildConsolePage does not
         * extend TextConsolePage, so we get access to the viewer with dirty tricks
         */
        Method method = page.getClass().getDeclaredMethod("getViewer", (Class<?>[])null);
        method.setAccessible(true);
        return (ITextViewer) method.invoke(page, (Object[])null);
    } catch (Exception e) {
        // AnyEditToolsPlugin.logError("Can't get page viewer from the console page", e);
    }
    return null;
}
 
Example #2
Source File: ResourceUtils.java    From LogViewer with Eclipse Public License 2.0 6 votes vote down vote up
public static IConsole getConsole(IWorkbenchPart part) {
      if(!(part instanceof IViewPart)){
          return null;
      }

      IViewPart vp =(IViewPart) part;
      if (vp instanceof PageBookView) {
          IPage page = ((PageBookView) vp).getCurrentPage();
          ITextViewer viewer = getViewer(page);
          if (viewer == null || viewer.getDocument() == null)
          	return null;
      }

      IConsole con = null;
  	try {
  		con = ((IConsoleView)part).getConsole();
  	} catch (Exception e) {

}

return con;
  }
 
Example #3
Source File: ExpandLevelHandler.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException
{
	// assumes to expand to level 1 if not specified
	int level = 1;
	String levelStr = event.getParameter(LEVEL);
	if (levelStr != null)
	{
		level = Integer.parseInt(levelStr);
	}

	IWorkbenchPart part = HandlerUtil.getActivePart(event);
	if (part instanceof ContentOutline)
	{
		IPage page = ((ContentOutline) part).getCurrentPage();
		if (page instanceof CommonOutlinePage)
		{
			CommonOutlinePage outlinePage = (CommonOutlinePage) page;
			// we want to expand to the specified level and collapse everything below
			outlinePage.collapseAll();
			outlinePage.expandToLevel(level);
		}
	}
	return null;
}
 
Example #4
Source File: AnnotationEditorView.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
@Override
protected IPage createDefaultPage(PageBook book) {
  MessagePage page = new MessagePage();
  initPage(page);
  page.createControl(book);
  page.setMessage(editorNotAvailableMessage);
  return page;
}
 
Example #5
Source File: CasEditorView.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
@Override
protected IPage createDefaultPage(PageBook book) {
  MessagePage page = new MessagePage();
  initPage(page);
  page.createControl(book);
  page.setMessage(editorNotAvailableMessage);
  return page;
}
 
Example #6
Source File: AnnotationOutline.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
  
  boolean isForeignSelection = true;
  
  if (part instanceof ContentOutline) {
    ContentOutline contentOutline = (ContentOutline) part;
    
    IPage currentPage = contentOutline.getCurrentPage();
    
    if (currentPage instanceof OutlinePageBook) {
      OutlinePageBook pageBook = (OutlinePageBook) currentPage;
      isForeignSelection = pageBook.getCasViewPage() != this;
    }
  }

  if (isForeignSelection && getSite().getPage().getActiveEditor() == editor) {
    if (selection instanceof StructuredSelection) {
      AnnotationSelection annotations = new AnnotationSelection((StructuredSelection) selection);

      if (!annotations.isEmpty()) {
        ISelection tableSelection = new StructuredSelection(new AnnotationTreeNode(editor
                .getDocument(), annotations.getFirst()));

        mTableViewer.setSelection(tableSelection, true);
      }
    }
  }
}
 
Example #7
Source File: AttributeView.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected IPage createDefaultPage( PageBook book )
{
	MessagePage page = new MessagePage( );
	initPage( page );
	page.createControl( book );
	page.setMessage( defaultText );
	if ( defaultPartName == null )
	{
		defaultPartName = getPartName( );
	}
	return page;
}
 
Example #8
Source File: DataView.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates and returns the default page for this view.
 * 
 * @param book
 *            the pagebook control
 * @return the default page
 */
protected IPage createDefaultPage( PageBook book )
{
	MessagePage page = new MessagePage( );
	initPage( page );
	page.createControl( book );
	page.setMessage( defaultText );
	return page;
}
 
Example #9
Source File: LibraryExplorerView.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Destroys a page in the pagebook for a particular part. This page was
 * returned as a result from <code>doCreatePage</code>.
 * 
 * @param part
 *            the input part
 * @param pageRecord
 *            a page record for the part
 * @see #doCreatePage
 */
protected void doDestroyPage( IWorkbenchPart part, PageRec pageRecord )
{
	if ( treeViewPage != null && prefs != null )
	{
		prefs.removePreferenceChangeListener( treeViewPage );
	}
	
	this.resourceFolder = null;

	IPage page = pageRecord.page;
	page.dispose( );
	pageRecord.dispose( );
}
 
Example #10
Source File: LibraryExplorerView.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates and returns the default page for this view.
 * 
 * @param book
 *            the pagebook control
 * @return the default page
 */
protected IPage createDefaultPage( PageBook book )
{
	MessagePage page = new MessagePage( );
	initPage( page );
	page.createControl( book );
	page.setMessage( defaultText );
	return page;
}
 
Example #11
Source File: SpringConfigurationView.java    From tesb-studio-se with Apache License 2.0 5 votes vote down vote up
@Override
protected IPage createDefaultPage(PageBook book) {
    MessagePage page = new MessagePage();
    initPage(page);
    page.createControl(book);
    page.setMessage(CamelDesignerMessages.getString("SpringConfigurationView_defaultMessage")); //$NON-NLS-1$
    return page;
}
 
Example #12
Source File: ExpandAllHandler.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException
{
	IWorkbenchPart part = HandlerUtil.getActivePart(event);
	if (part instanceof ContentOutline)
	{
		IPage page = ((ContentOutline) part).getCurrentPage();
		if (page instanceof CommonOutlinePage)
		{
			((CommonOutlinePage) page).expandAll();
		}
	}
	return null;
}
 
Example #13
Source File: CollapseAllHandler.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException
{
	IWorkbenchPart part = HandlerUtil.getActivePart(event);
	if (part instanceof ContentOutline)
	{
		IPage page = ((ContentOutline) part).getCurrentPage();
		if (page instanceof CommonOutlinePage)
		{
			((CommonOutlinePage) page).collapseAll();
		}
	}
	return null;
}
 
Example #14
Source File: InvasiveThemeHijacker.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
protected void hijackConsole(IViewPart view)
{
	if (view instanceof ConsoleView)
	{
		IPage currentPage = ((ConsoleView) view).getCurrentPage();
		if (currentPage != null)
		{
			hookTheme(currentPage.getControl(), false);
		}
	}
}
 
Example #15
Source File: EmacsPlusCmdHandler.java    From e4macs with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
 */
@SuppressWarnings("unchecked")
public Object execute(ExecutionEvent event) throws ExecutionException {
	ITextEditor editor = getTextEditor(event);
	if (editor == null) { 
		if (isWindowCommand()) {
			Object result = checkExecute(event); 
			if (result == Check.Fail) {
				beep();
				result = null;
			}
			return result; 
		} else if (isConsoleCommand()) {
			// intercept and dispatch execution if console supported and used in a console view
			IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
			if (activePart != null && (activePart instanceof IConsoleView) && (activePart instanceof PageBookView)) {
				IPage textPage = ((PageBookView)activePart).getCurrentPage();
				if (textPage instanceof TextConsolePage) {
					return ((IConsoleDispatch)this).consoleDispatch(((TextConsolePage)textPage).getViewer(),(IConsoleView)activePart,event);
				}				
			}
		}
	}
	try {
		setThisEditor(editor);
		isEditable = getEditable();
		if (editor == null || isBlocked()) {
			beep();
			asyncShowMessage(editor, INEDITABLE_BUFFER, true);
			return null;
		}
		
		// Retrieve the universal-argument parameter value if passed 
		if (extractUniversalCount(event) != 1) {
			// check if we should dispatch a related command based on the universal argument
			String dispatchId = checkDispatchId(event.getCommand().getId());
			if (dispatchId != null) {
				// recurse on new id (inverse or arg value driven)
				return dispatchId(editor, dispatchId, getParams(event.getCommand(), event.getParameters()));
			}
		}
		
		setThisDocument(editor.getDocumentProvider().getDocument(editor.getEditorInput()));

		// Get the current selection
		ISelectionProvider selectionProvider = editor.getSelectionProvider();
		ITextSelection selection = (ITextSelection) selectionProvider.getSelection();
		preTransform(editor, selection);
		return transformWithCount(editor, getThisDocument(), selection, event);
		
	} finally {
		// normal commands clean up here
		if (isTransform()) {
			postExecute();
		}
	}
}
 
Example #16
Source File: DataView.java    From birt with Eclipse Public License 1.0 3 votes vote down vote up
/**
 * Destroys a page in the pagebook for a particular part. This page was
 * returned as a result from <code>doCreatePage</code>.
 * 
 * @param part
 *            the input part
 * @param pageRecord
 *            a page record for the part
 * @see #doCreatePage
 */
protected void doDestroyPage( IWorkbenchPart part, PageRec pageRecord )
{
	IPage page = pageRecord.page;
	page.dispose( );
	pageRecord.dispose( );
}
 
Example #17
Source File: AttributeView.java    From birt with Eclipse Public License 1.0 3 votes vote down vote up
/**
 * Destroys a page in the pagebook for a particular part. This page was
 * returned as a result from <code>doCreatePage</code>.
 * 
 * @param part
 *            the input part
 * @param pageRecord
 *            a page record for the part
 * @see #doCreatePage
 */
protected void doDestroyPage( IWorkbenchPart part, PageRec pageRecord )
{
	IPage page = pageRecord.page;
	page.dispose( );
	pageRecord.dispose( );
}