Package org.eclipse.ui

Examples of org.eclipse.ui.SaveablesLifecycleEvent


   
    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


      break;
    case SaveablesLifecycleEvent.POST_CLOSE:
      removeModels(event.getSource(), modelArray);
      break;
    case SaveablesLifecycleEvent.DIRTY_CHANGED:
      fireModelLifecycleEvent(new SaveablesLifecycleEvent(this, event
          .getEventType(), event.getSaveables(), false));
      break;
    }
  }
View Full Code Here

      if (removeModel(source, model)) {
        removed.add(model);
      }
    }
    if (removed.size() > 0) {
      fireModelLifecycleEvent(new SaveablesLifecycleEvent(this,
          SaveablesLifecycleEvent.POST_OPEN, (Saveable[]) removed
              .toArray(new Saveable[removed.size()]), false));
    }
  }
View Full Code Here

      if (addModel(source, model)) {
        added.add(model);
      }
    }
    if (added.size() > 0) {
      fireModelLifecycleEvent(new SaveablesLifecycleEvent(this,
          SaveablesLifecycleEvent.POST_OPEN, (Saveable[]) added
              .toArray(new Saveable[added.size()]), false));
    }
  }
View Full Code Here

          }
        }
      }
    }
    if (removed.size() > 0) {
      fireModelLifecycleEvent(new SaveablesLifecycleEvent(this,
          SaveablesLifecycleEvent.POST_CLOSE, (Saveable[]) removed
              .toArray(new Saveable[removed.size()]), false));
    }
  }
View Full Code Here

   * @param actualPart
   */
  public void dirtyChanged(IWorkbenchPart part) {
    Saveable[] saveables = getSaveables(part);
    if (saveables.length > 0) {
      fireModelLifecycleEvent(new SaveablesLifecycleEvent(this,
          SaveablesLifecycleEvent.DIRTY_CHANGED, saveables, false));
    }
  }
View Full Code Here

    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

      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

TOP

Related Classes of org.eclipse.ui.SaveablesLifecycleEvent

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.