Examples of IEditorReference


Examples of org.eclipse.ui.IEditorReference

        .getBoolean(IPreferenceConstants.REUSE_EDITORS_BOOLEAN);
    if (!reuse) {
      return null;
    }

    IEditorReference editors[] = page.getSortedEditors();
    if (editors.length < page.getEditorReuseThreshold()) {
      return null;
    }

    IEditorReference dirtyEditor = null;

    // Find a editor to be reused
    for (int i = 0; i < editors.length; i++) {
      IEditorReference editor = editors[i];
      // if(editor == activePart)
      // continue;
      if (editor.isPinned()) {
        continue;
      }
      if (editor.isDirty()) {
        if (dirtyEditor == null) {
          dirtyEditor = editor;
        }
        continue;
      }
View Full Code Here

Examples of org.eclipse.ui.IEditorReference

      EditorManager manager, EditorAreaHelper editorPresentation,
      EditorDescriptor desc, IEditorInput input,
      IEditorReference reusableEditorRef) {
    IEditorPart reusableEditor = reusableEditorRef.getEditor(false);
    if (reusableEditor == null) {
      IEditorReference result = new EditorReference(manager, input, desc);
      page.closeEditor(reusableEditorRef, false);
      return result;
    }

    EditorSite site = (EditorSite) reusableEditor.getEditorSite();
    EditorDescriptor oldDesc = site.getEditorDescriptor();
    if ((desc.getId().equals(oldDesc.getId()))
        && (reusableEditor instanceof IReusableEditor)) {
      Workbench wb = (Workbench) page.getWorkbenchWindow().getWorkbench();
      editorPresentation.moveEditor(reusableEditor, -1);
      wb.getEditorHistory().add(reusableEditor.getEditorInput(),
          site.getEditorDescriptor());
      page.reuseEditor((IReusableEditor) reusableEditor, input);
      return reusableEditorRef;
    }
    // findReusableEditor(...) checks pinned and saves editor if
    // necessary, so it's OK to close "reusableEditor"
    IEditorReference ref = new EditorReference(manager, input, desc);
    reusableEditor.getEditorSite().getPage().closeEditor(reusableEditor,
        false);
    return ref;
  }
View Full Code Here

Examples of org.eclipse.ui.IEditorReference

    /**
     * Adds all editors to elements
     */
    private void updateEditors(IWorkbenchPage[] pages) {
        for (int j = 0; j < pages.length; j++) {
            IEditorReference editors[] = pages[j].getEditorReferences();
            for (int k = 0; k < editors.length; k++) {
                elements.add(new Adapter(editors[k]));
            }
        }
    }
View Full Code Here

Examples of org.eclipse.ui.IEditorReference

    boolean includeEditor = true;

    for (int i = refs.length - 1; i >= 0; i--) {
      if (refs[i] instanceof IEditorReference) {
        if (includeEditor) {
          IEditorReference activeEditor = (IEditorReference) refs[i];
          TableItem item = new TableItem(table, SWT.NONE);
          item.setText(WorkbenchMessages.CyclePartAction_editor);
          item.setImage(activeEditor.getTitleImage());
          item.setData(activeEditor);
          includeEditor = false;
        }
      } else {
        TableItem item = new TableItem(table, SWT.NONE);
View Full Code Here

Examples of org.eclipse.ui.IEditorReference

        if (part != null && !(part.getSite() instanceof PartSite)) {
      return false;
    }

        if (part instanceof IEditorPart) {
            IEditorReference ref = (IEditorReference) getReference(part);
            return ref != null && getEditorManager().containsEditor(ref);
        }
        if (part instanceof IViewPart) {
            Perspective persp = getActivePerspective();
            return persp != null && persp.containsView((IViewPart) part);
View Full Code Here

Examples of org.eclipse.ui.IEditorReference

    /**
     * See IWorkbenchPage
     */
    public boolean closeAllSavedEditors() {
        // get the Saved editors
        IEditorReference editors[] = getEditorReferences();
        IEditorReference savedEditors[] = new IEditorReference[editors.length];
        int j = 0;
        for (int i = 0; i < editors.length; i++) {
            IEditorReference editor = editors[i];
            if (!editor.isDirty()) {
                savedEditors[j++] = editor;
            }
        }
        //there are no unsaved editors
        if (j == 0) {
View Full Code Here

Examples of org.eclipse.ui.IEditorReference

        }
       
        IWorkbenchPartReference oldActivePart = partList.getActivePartReference();
        IWorkbenchPartReference oldActiveEditor = partList.getActiveEditorReference();
        IWorkbenchPartReference newActivePart = null;
        IEditorReference newActiveEditor = null;
       
        if (!window.isClosing()) {
            // If an editor is active, try to keep an editor active
            if (oldActivePart == oldActiveEditor) {
                newActiveEditor = (IEditorReference)activationList.getActiveReference(true);
View Full Code Here

Examples of org.eclipse.ui.IEditorReference

       
        // Check if we're being asked to close any parts that are already closed or cannot
        // be closed at this time
        ArrayList toClose = new ArrayList();
        for (int i = 0; i < refArray.length; i++) {
            IEditorReference reference = refArray[i];
           
            // If we're in the middle of creating this part, this is a programming error. Abort the entire
            // close operation. This usually occurs if someone tries to open a dialog in a method that
            // isn't allowed to do so, and a *syncExec tries to close the part. If this shows up in a log
            // file with a dialog's event loop on the stack, then the code that opened the dialog is usually
            // at fault.
            if (reference == partBeingActivated) {
                WorkbenchPlugin.log(new RuntimeException("WARNING: Blocked recursive attempt to close part "  //$NON-NLS-1$
                        + partBeingActivated.getId() + " while still in the middle of activating it")); //$NON-NLS-1$
                return false;
            }
           
            if(reference instanceof WorkbenchPartReference) {
                WorkbenchPartReference ref = (WorkbenchPartReference) reference;
               
                // If we're being asked to close a part that is disposed (ie: already closed),
                // skip it and proceed with closing the remaining parts.
                if (ref.isDisposed()) {
                    continue;
                }
            }
           
            toClose.add(reference);
        }
       
        IEditorReference[] editorRefs = (IEditorReference[]) toClose.toArray(new IEditorReference[toClose.size()]);
       
        // notify the model manager before the close
        List partsToClose = new ArrayList();
        for (int i = 0; i < editorRefs.length; i++) {
            IEditorPart refPart = editorRefs[i].getEditor(false);
            if (refPart != null) {
              partsToClose.add(refPart);
            }
        }
        SaveablesList modelManager = null;
        Object postCloseInfo = null;
        if(partsToClose.size()>0) {
          modelManager = (SaveablesList) getWorkbenchWindow().getService(ISaveablesLifecycleListener.class);
          // this may prompt for saving and return null if the user canceled:
          postCloseInfo = modelManager.preCloseParts(partsToClose, save, getWorkbenchWindow());
          if (postCloseInfo==null) {
            return false;
          }
        }

        // Fire pre-removal changes
        for (int i = 0; i < editorRefs.length; i++) {
            IEditorReference ref = editorRefs[i];
           
            // Notify interested listeners before the close
            window.firePerspectiveChanged(this, getPerspective(), ref,
                    CHANGE_EDITOR_CLOSE);
           
        }       
       
        deferUpdates(true);
        try {       
          if(modelManager!=null) {
              modelManager.postClose(postCloseInfo);
            }
         
          // Close all editors.
          for (int i = 0; i < editorRefs.length; i++) {
              IEditorReference ref = editorRefs[i];
             
              // Remove editor from the presentation
                editorPresentation.closeEditor(ref);
             
                partRemoved((WorkbenchPartReference)ref);               
View Full Code Here

Examples of org.eclipse.ui.IEditorReference

    }
        if (saveParts && perspList.size() == 1) {
          // collect editors that are dirty
          IEditorReference[] editorReferences = getEditorReferences();
          for (int i = 0; i < editorReferences.length; i++) {
        IEditorReference reference = editorReferences[i];
          if (reference.isDirty()) {
            IEditorPart editorPart = reference.getEditor(false);
            if (editorPart != null) {
              partsToSave.add(editorPart);
            }
          }
      }
View Full Code Here

Examples of org.eclipse.ui.IEditorReference

    /**
     * See IWorkbenchPage.
     */
    public IEditorPart[] getEditors() {
        final IEditorReference refs[] = getEditorReferences();
        final ArrayList result = new ArrayList(refs.length);
        Display d = getWorkbenchWindow().getShell().getDisplay();
        //Must be backward compatible.
        d.syncExec(new Runnable() {
            public void run() {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.