Package org.eclipse.ui

Examples of org.eclipse.ui.PartInitException


     * The <code>MultiPageEditorExample</code> implementation of this method checks that the input
     * is an instance of <code>IFileEditorInput</code>.
     */
    public void init(IEditorSite site, IEditorInput editorInput) throws PartInitException {
        if (!(editorInput instanceof IFileEditorInput)) {
            throw new PartInitException("Invalid Input: Must be IFileEditorInput");
        }
        super.init(site, editorInput);
    }
View Full Code Here


     * The <code>MultiPageEditorExample</code> implementation of this method checks that the input
     * is an instance of <code>IFileEditorInput</code>.
     */
    public void init(IEditorSite site, IEditorInput editorInput) throws PartInitException {
        if (!(editorInput instanceof IFileEditorInput)) {
            throw new PartInitException("Invalid Input: Must be IFileEditorInput");
        }
        super.init(site, editorInput);
    }
View Full Code Here

  protected IWorkbenchPart createPart() {

    // Check the status of this part

    IWorkbenchPart result = null;
    PartInitException exception = null;

    // Try to restore the view -- this does the real work of restoring the
    // view
    //
    try {
      result = createPartHelper();
    } catch (PartInitException e) {
      exception = e;
    }

    // If unable to create the part, create an error part instead
    // and pass the error to the status handling facility
    if (exception != null) {
      IStatus partStatus = exception.getStatus();
      IStatus displayStatus = StatusUtil.newStatus(partStatus,
          WorkbenchMessages.ViewFactory_initException);
      IStatus logStatus = StatusUtil
          .newStatus(
              partStatus,
View Full Code Here

      stateMem = memento.getChild(IWorkbenchConstants.TAG_VIEW_STATE);
    }

    IViewDescriptor desc = factory.viewReg.find(getId());
    if (desc == null) {
      throw new PartInitException(
          WorkbenchMessages.ViewFactory_couldNotCreate);
    }

    // Create the part pane
    PartPane pane = getPane();

    // Create the pane's top-level control
    pane.createControl(factory.page.getClientComposite());

    String label = desc.getLabel(); // debugging only

    // Things that will need to be disposed if an exception occurs (they are
    // listed here
    // in the order they should be disposed)
    Composite content = null;
    IViewPart initializedView = null;
    ViewSite site = null;
    ViewActionBars actionBars = null;
    // End of things that need to be explicitly disposed from the try block

    try {
      IViewPart view = null;
      try {
        UIStats.start(UIStats.CREATE_PART, label);
        view = desc.createView();
      } finally {
        UIStats.end(UIStats.CREATE_PART, view, label);
      }

      if (view instanceof IWorkbenchPart3) {
        createPartProperties((IWorkbenchPart3)view);
      }
      // Create site
      site = new ViewSite(this, view, factory.page, desc);
      actionBars = new ViewActionBars(factory.page.getActionBars(), site,
          (ViewPane) pane);
      site.setActionBars(actionBars);

      try {
        UIStats.start(UIStats.INIT_PART, label);
        view.init(site, stateMem);
        // Once we've called init, we MUST dispose the view. Remember
        // the fact that
        // we've initialized the view in case an exception is thrown.
        initializedView = view;

      } finally {
        UIStats.end(UIStats.INIT_PART, view, label);
      }

      if (view.getSite() != site) {
        throw new PartInitException(
            WorkbenchMessages.ViewFactory_siteException, null);
      }
      int style = SWT.NONE;
      if (view instanceof IWorkbenchPartOrientation) {
        style = ((IWorkbenchPartOrientation) view).getOrientation();
      }

      // Create the top-level composite
      {
        Composite parent = (Composite) pane.getControl();
        content = new Composite(parent, style);
        content.setLayout(new FillLayout());

        try {
          UIStats.start(UIStats.CREATE_PART_CONTROL, label);
          view.createPartControl(content);

          parent.layout(true);
        } finally {
          UIStats.end(UIStats.CREATE_PART_CONTROL, view, label);
        }
      }

      // Install the part's tools and menu
      {
        //
        // 3.3 start
        //
        IMenuService menuService = (IMenuService) site
            .getService(IMenuService.class);
        menuService.populateContributionManager(
            (ContributionManager) site.getActionBars()
                .getMenuManager(), "menu:" //$NON-NLS-1$
                + site.getId());
        menuService
            .populateContributionManager((ContributionManager) site
                .getActionBars().getToolBarManager(),
                "toolbar:" + site.getId()); //$NON-NLS-1$
        // 3.3 end

        actionBuilder = new ViewActionBuilder();
        actionBuilder.readActionExtensions(view);
        ActionDescriptor[] actionDescriptors = actionBuilder
            .getExtendedActions();
        IKeyBindingService keyBindingService = view.getSite()
            .getKeyBindingService();

        if (actionDescriptors != null) {
          for (int i = 0; i < actionDescriptors.length; i++) {
            ActionDescriptor actionDescriptor = actionDescriptors[i];

            if (actionDescriptor != null) {
              IAction action = actionDescriptors[i].getAction();

              if (action != null
                  && action.getActionDefinitionId() != null) {
                keyBindingService.registerAction(action);
              }
            }
          }
        }

        site.getActionBars().updateActionBars();
      }

      // The editor should now be fully created. Exercise its public
      // interface, and sanity-check
      // it wherever possible. If it's going to throw exceptions or behave
      // badly, it's much better
      // that it does so now while we can still cancel creation of the
      // part.
      PartTester.testView(view);

      result = view;

      IConfigurationElement element = (IConfigurationElement) Util.getAdapter(desc,
          IConfigurationElement.class);
      if (element != null) {
        factory.page.getExtensionTracker().registerObject(
            element.getDeclaringExtension(), view,
            IExtensionTracker.REF_WEAK);
      }
    } catch (Throwable e) {
      if ((e instanceof Error) && !(e instanceof LinkageError)) {
        throw (Error) e;
      }
     
      // An exception occurred. First deallocate anything we've allocated
      // in the try block (see the top
      // of the try block for a list of objects that need to be explicitly
      // disposed)
      if (content != null) {
        try {
          content.dispose();
        } catch (RuntimeException re) {
          StatusManager.getManager().handle(
              StatusUtil.newStatus(WorkbenchPlugin.PI_WORKBENCH,
                  re));
        }
      }

      if (initializedView != null) {
        try {
          initializedView.dispose();
        } catch (RuntimeException re) {
          StatusManager.getManager().handle(
              StatusUtil.newStatus(WorkbenchPlugin.PI_WORKBENCH,
                  re));
        }
      }

      if (site != null) {
        try {
          site.dispose();
        } catch (RuntimeException re) {
          StatusManager.getManager().handle(
              StatusUtil.newStatus(WorkbenchPlugin.PI_WORKBENCH,
                  re));
        }
      }

      if (actionBars != null) {
        try {
          actionBars.dispose();
        } catch (RuntimeException re) {
          StatusManager.getManager().handle(
              StatusUtil.newStatus(WorkbenchPlugin.PI_WORKBENCH,
                  re));
        }
      }

      throw new PartInitException(WorkbenchPlugin.getStatus(e));
    }

    return result;
  }
View Full Code Here

        try {
            IViewDescriptor descriptor = viewFactory.getViewRegistry().find(
                    ViewFactory.extractPrimaryId(viewId));
            if (descriptor == null) {
                throw new PartInitException("View descriptor not found: " + viewId); //$NON-NLS-1$
            }
            if (WorkbenchActivityHelper.filterItem(descriptor)) {
                //create a placeholder instead.
                addPlaceholder(viewId);
                LayoutHelper.addViewActivator(pageLayout, viewId);
View Full Code Here

  }

  @Override
  public void init(IEditorSite site, IEditorInput input) throws PartInitException {
    if (!(input instanceof DeckEditorInput))
      throw new PartInitException("Invalid Input: Must be DeckEditorInput");
   
    setSite(site);
    setInput(input);

    boldFont = SWTUtils.getBoldFont(JFaceResources.getDefaultFont());
View Full Code Here

   */
  public void init(IEditorSite site, IEditorInput editorInput) throws PartInitException {
    XMLInputSource input;

    if (!(editorInput instanceof IFileEditorInput))
      throw new PartInitException(Messages.getString("MultiPageEditor.invalidInputClass")); //$NON-NLS-1$
    fileNeedingContext = file = ((IFileEditorInput) editorInput).getFile();
    String filePathName = file.getLocation().toOSString();

    try {
      input = new XMLInputSource(filePathName);
    } catch (IOException e) {
      String m = Messages.getFormattedString("MultiPageEditor.IOError", //$NON-NLS-1$
              new String[] { AbstractSection.maybeShortenFileName(filePathName) })
              + Messages.getString("MultiPageEditor.10") + getMessagesToRootCause(e); //$NON-NLS-1$
      // skip showing a message because the partInitException
      // shows it
      throw new PartInitException(m);
    }

    super.init(site, editorInput); // to allow other editors to get site and editorInput
       
    // leaves isBadXML set, if it can't parse but isn't throwing
    isContextLoaded = false;
    try {
      parseSource(input, filePathName);
    } catch (MultilevelCancel e) {
      throw new PartInitException("Operation Cancelled");
    }

    isContextLoaded = true;

    // super.init(site, editorInput);
View Full Code Here

      } else {
        if (null == extensionEditor) {
          extensionEditor = getRequiredEditor(inputDescription);
        }
        if (null == extensionEditor) {
          throw new PartInitException(Messages.getFormattedString(
                  "MultiPageEditor.unrecognizedDescType", //$NON-NLS-1$
                  new String[] { AbstractSection.maybeShortenFileName(filePathName) })
                  + Messages.getString("MultiPageEditor.11")); //$NON-NLS-1$
        } else {
          extensionEditor.activateEditor(getEditorSite(), getEditorInput(), this, inputDescription);
View Full Code Here

   */
  @Override
  public void init(IEditorSite site, IEditorInput editorInput)
    throws PartInitException {
    if (!(editorInput instanceof IFileEditorInput))
      throw new PartInitException("Invalid Input: Must be IFileEditorInput");
    super.init(site, editorInput);
  }
View Full Code Here

  @Override
  public void init(IEditorSite site, IEditorInput input)
      throws PartInitException {
    setSite(site);
    if (!(input instanceof SequenceEditorInput)) {
      throw new PartInitException(
          "Invalid Input: Must be a SequenceEditorInput"); //$NON-NLS-1$
    }
    this.setInput(input);

    preferenceListener = new IPropertyChangeListener() {
View Full Code Here

TOP

Related Classes of org.eclipse.ui.PartInitException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.