Package org.eclipse.ui

Examples of org.eclipse.ui.PartInitException


       
        if (part == null && restore) {
           
            if (state == STATE_CREATION_IN_PROGRESS) {
                IStatus result = WorkbenchPlugin.getStatus(
                        new PartInitException(NLS.bind("Warning: Detected recursive attempt by part {0} to create itself (this is probably, but not necessarily, a bug)"//$NON-NLS-1$
                                getId())));
                WorkbenchPlugin.log(result);
                return null;
            }
           
View Full Code Here


        tooltip = getTitleToolTip();
        title = getTitle();
       
        if (state == STATE_CREATION_IN_PROGRESS) {
            IStatus result = WorkbenchPlugin.getStatus(
                    new PartInitException(NLS.bind("Warning: Blocked recursive attempt by part {0} to dispose itself during creation"//$NON-NLS-1$
                            getId())));
            WorkbenchPlugin.log(result);
            return;
        }
       
View Full Code Here

      } else if (throwable instanceof RuntimeException) {
        throw (RuntimeException) throwable;
      } else if (throwable instanceof WorkbenchException) {
        throw (PartInitException) throwable;
      } else {
        throw new PartInitException(StatusUtil.newStatus(
            WorkbenchPlugin.PI_WORKBENCH, throwable));
      }
    }
  }
View Full Code Here

        }
       
        // Get the input factory.
        IMemento editorMem = getMemento();
        if (editorMem == null) {
            throw new PartInitException(NLS.bind(WorkbenchMessages.EditorManager_no_persisted_state, getId(), getName()));
        }
        IMemento inputMem = editorMem
                .getChild(IWorkbenchConstants.TAG_INPUT);
        String factoryID = null;
        if (inputMem != null) {
            factoryID = inputMem
                    .getString(IWorkbenchConstants.TAG_FACTORY_ID);
        }
        if (factoryID == null) {
            throw new PartInitException(NLS.bind(WorkbenchMessages.EditorManager_no_input_factory_ID, getId(), getName()));
        }
        IAdaptable input = null;
        String label = null; // debugging only
        if (UIStats.isDebugging(UIStats.CREATE_PART_INPUT)) {
            label = getName() != null ? getName() : factoryID;
        }
        try {
            UIStats.start(UIStats.CREATE_PART_INPUT, label);
            IElementFactory factory = PlatformUI.getWorkbench()
                    .getElementFactory(factoryID);
            if (factory == null) {
                throw new PartInitException(NLS.bind(WorkbenchMessages.EditorManager_bad_element_factory, new Object[] { factoryID, getId(), getName() }));
            }

            // Get the input element.
            input = factory.createElement(inputMem);
            if (input == null) {
                throw new PartInitException(NLS.bind(WorkbenchMessages.EditorManager_create_element_returned_null, new Object[] { factoryID, getId(), getName() }));
            }
        } finally {
            UIStats.end(UIStats.CREATE_PART_INPUT, input, label);
        }
        if (!(input instanceof IEditorInput)) {
            throw new PartInitException(NLS.bind(WorkbenchMessages.EditorManager_wrong_createElement_result, new Object[] { factoryID, getId(), getName() }));
        }
        restoredInput = (IEditorInput) input;
        return restoredInput;
    }
View Full Code Here

     */
    protected IWorkbenchPart createPart() {
        if (EditorRegistry.EMPTY_EDITOR_ID.equals(getId())) {
          return getEmptyEditor(getDescriptor());
        }
        PartInitException exception = null;
       
        IWorkbenchPart result = null;
       
        // Try to restore the editor -- this does the real work of restoring the editor
        //
        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 originalStatus = exception.getStatus();
            IStatus logStatus = StatusUtil.newStatus(originalStatus,
                    NLS.bind("Unable to create editor ID {0}: {1}"//$NON-NLS-1$
                            getId(), originalStatus.getMessage()));
            IStatus displayStatus = StatusUtil.newStatus(originalStatus,
          WorkbenchMessages.EditorManager_unableToCreateEditor);
View Full Code Here

            // Get the editor descriptor.
            String editorID = getId();
            EditorDescriptor desc = getDescriptor();
           
            if (desc == null) {
                throw new PartInitException(NLS.bind(WorkbenchMessages.EditorManager_missing_editor_descriptor, editorID));
            }
           
           
            if (desc.isInternal()) {   
                // Create an editor instance.
                try {
                    UIStats.start(UIStats.CREATE_PART, editorID);
                    part = manager.createPart(desc);
                   
                    if (part != null && part instanceof MultiEditor) {
              multiEditorChildren = manager.openMultiEditor(this,
                (MultiEditor) part, (MultiEditorInput) editorInput);
            }
                    if (part instanceof IWorkbenchPart3) {
                      createPartProperties((IWorkbenchPart3)part);
                    }
                } finally {
                    UIStats.end(UIStats.CREATE_PART, this, editorID);
                }
               
            } else if (desc.getId().equals(
                    IEditorRegistry.SYSTEM_INPLACE_EDITOR_ID)) {
               
                part = ComponentSupport.getSystemInPlaceEditor();
               
                if (part == null) {
                    throw new PartInitException(WorkbenchMessages.EditorManager_no_in_place_support);
                }
            } else {
                throw new PartInitException(NLS.bind(WorkbenchMessages.EditorManager_invalid_editor_descriptor, editorID));
            }
            // Create a pane for this part
            PartPane pane = getPane();
   
            pane.createControl((Composite) manager.page.getEditorPresentation().getLayoutPart().getControl());
           
            // Create controls
            int style = SWT.NONE;
            if(part instanceof IWorkbenchPartOrientation){
                style = ((IWorkbenchPartOrientation) part).getOrientation();
            }
   
            // Link everything up to the part reference (the part reference itself should not have
            // been modified until this point)
            site = manager.createSite(this, part, desc, editorInput);
           
            // if there is saved state that's appropriate, pass it on
            if (part instanceof IPersistableEditor && editorState != null) {
        ((IPersistableEditor) part).restoreState(editorState);
      }
           
            // Remember the site and the action bars (now that we've created them, we'll need to dispose
            // them if an exception occurs)
            actionBars = (EditorActionBars) site.getActionBars();
           
            Composite parent = (Composite)pane.getControl();
            content = new Composite(parent, style);
   
            content.setLayout(new FillLayout());
   
            try {
                UIStats.start(UIStats.CREATE_PART_CONTROL, editorID);
                part.createPartControl(content);
           
                parent.layout(true);
            } finally {
                UIStats.end(UIStats.CREATE_PART_CONTROL, part, editorID);
            }
   
            // 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.testEditor(part);
           
            return part;
           
        } catch (Exception e) {
            // Dispose anything which we allocated in the try block
            if (content != null) {
                try {
          content.dispose();
        } catch (RuntimeException re) {
          StatusManager.getManager().handle(
              StatusUtil.newStatus(WorkbenchPlugin.PI_WORKBENCH,
                  re));
        }
            }
   
            if (part != null) {
                try {
                    part.dispose();
                } catch (RuntimeException re) {
          StatusManager.getManager().handle(
              StatusUtil.newStatus(WorkbenchPlugin.PI_WORKBENCH,
                  re));
        }
            }
           
            if (actionBars != null) {
                try {
                    manager.disposeEditorActionBars(actionBars);
                } 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));
        }
            }
           
            throw new PartInitException(StatusUtil.getLocalizedMessage(e), StatusUtil.getCause(e));
        }
   
    }
View Full Code Here

    public IViewReference createView(String id, String secondaryId)
            throws PartInitException {
        IViewDescriptor desc = viewReg.find(id);
        // ensure that the view id is valid
        if (desc == null) {
      throw new PartInitException(NLS.bind(WorkbenchMessages.ViewFactory_couldNotCreate,  id ));
    }
        // ensure that multiple instances are allowed if a secondary id is given
        if (secondaryId != null) {
            if (!desc.getAllowMultiple()) {
                throw new PartInitException(NLS.bind(WorkbenchMessages.ViewFactory_noMultiple, id));
            }
        }
        String key = getKey(id, secondaryId);
        IViewReference ref = (IViewReference) counter.get(key);
        if (ref == null) {
View Full Code Here

        if (input == null || editorID == null) {
            throw new IllegalArgumentException();
        }

        final IEditorPart result[] = new IEditorPart[1];
        final PartInitException ex[] = new PartInitException[1];
        BusyIndicator.showWhile(window.getWorkbench().getDisplay(),
                new Runnable() {
                    public void run() {
                        try {
                            result[0] = busyOpenEditor(input, editorID,
View Full Code Here

      if (input == null || !(editorDescriptor instanceof EditorDescriptor)) {
        throw new IllegalArgumentException();
      }
     
      final IEditorPart result[] = new IEditorPart[1];
      final PartInitException ex[] = new PartInitException[1];
      BusyIndicator.showWhile(window.getWorkbench().getDisplay(),
          new Runnable() {
        public void run() {
          try {
            result[0] = busyOpenEditorFromDescriptor(input, (EditorDescriptor)editorDescriptor,
View Full Code Here

        if (result[0] instanceof IViewPart) {
      return (IViewPart) result[0];
    } else if (result[0] instanceof PartInitException) {
      throw (PartInitException) result[0];
    } else {
      throw new PartInitException(WorkbenchMessages.WorkbenchPage_AbnormalWorkbenchCondition);
    }
    }
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.