Package org.eclipse.ui

Examples of org.eclipse.ui.ISaveablesLifecycleListener


   * @param input the input to be set
   * @exception CoreException if input cannot be connected to the document
   *            provider
   */
  protected void doSetInput(IEditorInput input) throws CoreException {
    ISaveablesLifecycleListener listener= (ISaveablesLifecycleListener)getSite().getService(ISaveablesLifecycleListener.class);
    if (listener == null)
      fSavable= null;
   
    if (input == null) {
      close(isSaveOnCloseNeeded());
     
      if (fSavable != null) {
        listener.handleLifecycleEvent(new SaveablesLifecycleEvent(this,  SaveablesLifecycleEvent.POST_CLOSE,  getSaveables(), false));
        fSavable.disconnectEditor();
        fSavable= null;
      }
     
    } else {
      boolean mustSendLifeCycleEvent= false;
      if (fSavable != null) {
        listener.handleLifecycleEvent(new SaveablesLifecycleEvent(this,  SaveablesLifecycleEvent.POST_CLOSE,  getSaveables(), false));
        fSavable.disconnectEditor();
        fSavable= null;
        mustSendLifeCycleEvent= true;
      }

      IEditorInput oldInput= getEditorInput();
      if (oldInput != null)
        getDocumentProvider().disconnect(oldInput);

      super.setInput(input);

      updateDocumentProvider(input);

      IDocumentProvider provider= getDocumentProvider();
      if (provider == null) {
        IStatus s= new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.OK, EditorMessages.Editor_error_no_provider, null);
        throw new CoreException(s);
      }

      provider.connect(input);

      initializeTitle(input);

      if (fSourceViewer != null) {
        initializeSourceViewer(input);

        // Reset the undo context for the undo and redo action handlers
        IAction undoAction= getAction(ITextEditorActionConstants.UNDO);
        IAction redoAction= getAction(ITextEditorActionConstants.REDO);
        boolean areOperationActionHandlersInstalled= undoAction instanceof OperationHistoryActionHandler && redoAction instanceof OperationHistoryActionHandler;
        IUndoContext undoContext= getUndoContext();
        if (undoContext != null && areOperationActionHandlersInstalled) {
          ((OperationHistoryActionHandler)undoAction).setContext(undoContext);
          ((OperationHistoryActionHandler)redoAction).setContext(undoContext);
        } else {
          createUndoRedoActions();
        }
      }

      if (fIsOverwriting)
        toggleOverwriteMode();
      setInsertMode((InsertMode) getLegalInsertModes().get(0));
      updateCaret();

      updateStatusField(ITextEditorActionConstants.STATUS_CATEGORY_ELEMENT_STATE);

      if (fSelectionListener != null)
        fSelectionListener.setDocument(getDocumentProvider().getDocument(input));
     
      IVerticalRuler ruler= getVerticalRuler();
      if (ruler instanceof CompositeRuler)
        updateContributedRulerColumns((CompositeRuler) ruler);
     
      // Send savable life-cycle if needed.
      if (mustSendLifeCycleEvent && listener != null)
        listener.handleLifecycleEvent(new SaveablesLifecycleEvent(this,  SaveablesLifecycleEvent.POST_OPEN, getSaveables(), false));
     
    }
   
  }
View Full Code Here


   * @param input the input to be set
   * @exception CoreException if input cannot be connected to the document
   *            provider
   */
  protected void doSetInput(IEditorInput input) throws CoreException {
    ISaveablesLifecycleListener listener= (ISaveablesLifecycleListener)getSite().getService(ISaveablesLifecycleListener.class);
    if (listener == null)
      fSavable= null;

    if (input == null) {
      close(isSaveOnCloseNeeded());

      if (fSavable != null) {
        listener.handleLifecycleEvent(new SaveablesLifecycleEvent(this,  SaveablesLifecycleEvent.POST_CLOSE,  getSaveables(), false));
        fSavable.disconnectEditor();
        fSavable= null;
      }

    } else {
      boolean mustSendLifeCycleEvent= false;
      if (fSavable != null) {
        listener.handleLifecycleEvent(new SaveablesLifecycleEvent(this,  SaveablesLifecycleEvent.POST_CLOSE,  getSaveables(), false));
        fSavable.disconnectEditor();
        fSavable= null;
        mustSendLifeCycleEvent= true;
      }

      IEditorInput oldInput= getEditorInput();
      if (oldInput != null)
        getDocumentProvider().disconnect(oldInput);

      super.setInput(input);

      updateDocumentProvider(input);

      IDocumentProvider provider= getDocumentProvider();
      if (provider == null) {
        IStatus s= new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.OK, EditorMessages.Editor_error_no_provider, null);
        throw new CoreException(s);
      }

      provider.connect(input);

      initializeTitle(input);

      if (fSourceViewer != null) {
        initializeSourceViewer(input);

        // Reset the undo context for the undo and redo action handlers
        IAction undoAction= getAction(ITextEditorActionConstants.UNDO);
        IAction redoAction= getAction(ITextEditorActionConstants.REDO);
        boolean areOperationActionHandlersInstalled= undoAction instanceof OperationHistoryActionHandler && redoAction instanceof OperationHistoryActionHandler;
        IUndoContext undoContext= getUndoContext();
        if (undoContext != null && areOperationActionHandlersInstalled) {
          ((OperationHistoryActionHandler)undoAction).setContext(undoContext);
          ((OperationHistoryActionHandler)redoAction).setContext(undoContext);
        } else {
          createUndoRedoActions();
        }
      }

      if (fIsOverwriting)
        toggleOverwriteMode();
      setInsertMode((InsertMode) getLegalInsertModes().get(0));
      updateCaret();

      updateStatusField(ITextEditorActionConstants.STATUS_CATEGORY_ELEMENT_STATE);

      if (fSelectionListener != null)
        fSelectionListener.setDocument(getDocumentProvider().getDocument(input));

      IVerticalRuler ruler= getVerticalRuler();
      if (ruler instanceof CompositeRuler)
        updateContributedRulerColumns((CompositeRuler) ruler);

      // Send savable life-cycle if needed.
      if (mustSendLifeCycleEvent && listener != null)
        listener.handleLifecycleEvent(new SaveablesLifecycleEvent(this,  SaveablesLifecycleEvent.POST_OPEN, getSaveables(), false));

    }

  }
View Full Code Here

    private void registerSaveable(boolean init) {
      ICompareContainer container = getContainer();
      IWorkbenchPart part = container.getWorkbenchPart();
      if (part != null) {
        ISaveablesLifecycleListener lifecycleListener = getSaveablesLifecycleListener(part);
        // Remove this saveable from the lifecycle listener
        if (!init)
          lifecycleListener
              .handleLifecycleEvent(new SaveablesLifecycleEvent(
                  part, SaveablesLifecycleEvent.POST_CLOSE,
                  new Saveable[] { this }, false));
        // Now fix the hashing so it uses the connected document
        initializeHashing();
        // Finally, add this saveable back to the listener
        lifecycleListener
            .handleLifecycleEvent(new SaveablesLifecycleEvent(part,
                SaveablesLifecycleEvent.POST_OPEN,
                new Saveable[] { this }, false));
      }
    }
View Full Code Here

      }
    }

    private ISaveablesLifecycleListener getSaveablesLifecycleListener(
        IWorkbenchPart part) {
      ISaveablesLifecycleListener listener = (ISaveablesLifecycleListener) Utils
          .getAdapter(part, ISaveablesLifecycleListener.class);
      if (listener == null)
        listener = CommonUtils.getService(part.getSite(), ISaveablesLifecycleListener.class);
      return listener;
    }
View Full Code Here

TOP

Related Classes of org.eclipse.ui.ISaveablesLifecycleListener

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.