Interface Shell


public interface Shell
Note that all shell operations must occur on the event dispathing thread.
Author:
Per-Erik
  • Method Details

    • showIcon

      void showIcon(Shell.StatusIcon icon)
      Show icon in the status bar.
    • removeIcon

      void removeIcon(Shell.StatusIcon icon)
      Remove icon from the status bar.
    • showProgress

      void showProgress(Shell.StatusProgress progress)
      Show progress in the status bar.
    • showProgress

      void showProgress(Future<?> f, String text)
      Show progress in the status bar.
    • runWithCheckForUnsavedChanges

      default void runWithCheckForUnsavedChanges(String proceedText, Runnable r)
      Runs an action after checking if there are unsaved changes. Note that the runnable will always be executed on the EDT.
      Parameters:
      proceedText - The text shown to the user for continuing even if there are unsaved changes. If null then it will not be possible to continue without saving changes first.
      r - The code to run.
    • addNotification

      void addNotification(ShellNotification notification)
      Adds a notification message to the user-visible notification log. In the current implementation, the notification log is visible by clicking an icon in the lower left part of the shell (in a status bar). This is implementation dependent and may change. The only requirement this method has is to notify the user of the notification. Ideally, notifications are displayed differently depending on their category and may be grouped by category.
      Parameters:
      notification - The notification to add.
    • getNavigationBackHistory

      default List<MTModelHeader> getNavigationBackHistory()
      lite
    • getNavigationForwardHistory

      default List<MTModelHeader> getNavigationForwardHistory()
      lite
    • canNavigateBack

      default boolean canNavigateBack()
      lite
    • canNavigateForward

      default boolean canNavigateForward()
      lite
    • getBackAction

      default Action getBackAction()
      lite
    • getForwardAction

      default Action getForwardAction()
      lite
    • updateModelHistory

      default void updateModelHistory(MTModelHeader model)
      lite
    • open

      default void open(MTRevisionInfo info) throws IllegalStateException
      lite
      Throws:
      IllegalStateException
    • highlightComponent

      void highlightComponent(JComponent component, String message, Integer messageWidth)
      Highlights a component that the user should take special notice of right now.
      Parameters:
      component - The component to highlight
      message - An optional message that will be displayed next to the component while highlighted.
      messageWidth - Optional width of the message popup, passing null will use the default width
    • open

      void open(MTModelHeader model) throws IllegalStateException
      Opens a model in a new page, at some time in the future*, if the shell state is MODELING. If isBusy returns true the new page will be opened when user input is accepted again. If the model is already open in a page, this method will select that page and no loading will be performed.

      The model is loaded asynchronously before opening. No guarantees can be made about when in time the model will be visible as a page.

      NOTE: If the shell state is REPOSITORY_BROWSING, a call to this method is logically a No-op.
      Parameters:
      model - the model to open
      Throws:
      IllegalStateException - if called from any other thread than the event dispatch thread.
    • open

      void open(Page<?> page) throws IllegalStateException
      Opens a new page, at some time in the future*, if the shell state is MODELING. If isBusy returns true the new page will be opened when user input is accepted again. If the model is already open in a page, this method will select that page and no loading will be performed.

      NOTE: If the shell state is REPOSITORY_BROWSING, a call to this method is logically a No-op.
      Parameters:
      page - the page to open
      Throws:
      IllegalStateException - if called from any other thread than the event dispatch thread.
    • edit

      void edit(Object toEdit, int x, int y, String requestedContext, Consumer<?> onSave)
      Finds a suitable editor for the given object and requested context and starts editing the object with that editor. Note that this method makes a best effort to find a suitable editor but might fail if no editor reports the support for the given object. Failure will only result in nothing happening so there is no way for callers to get notified of this.
      Parameters:
      toEdit - The object to edit.
      x - A requested x coordinate on screen where the editor should appear. This is only a hint to the editor and may be ignored depending on the editor. If this number is negative, it means that the caller do not care where the editor appears.
      y - A requested y coordinate on screen where the editor should appear. This is only a hint to the editor and may be ignored depending on the editor. If this number is negative, it means that the caller do not care where the editor appears.
      requestedContext - The context in which the edit should happen. The valid values are implementation specific for each editor but the empty string and null will always mean "no context requested". There is no guarantee that the requested context will be used properly by the chosen editor, although a best effort will be made to find an editor that respects the context.
    • edit

      default void edit(Object toEdit, int x, int y, String requestedContext)
    • edit

      void edit(Object toEdit, String requestedContext, Consumer<?> onSave)
      Finds a suitable editor for the given object and requested context and starts editing the object with that editor. This is equivalent of calling #edit(toEdit, -1, -1, requestedContext).
      Parameters:
      toEdit - The object to edit.
      requestedContext - The context in which the edit should happen.
      See Also:
    • edit

      default void edit(Object toEdit, String requestedContext)
    • editProperties

      void editProperties(MTModelHeader model) throws IllegalStateException
      Opens an editing view for a model, at some time in the future*, if the shell state is MODELING. If isBusy returns true the editing view will be opened when user input is accepted again.

      The model is loaded asynchronously before opening. No guarantees can be made about when in time the model properties will be editable.

      NOTE: If the shell state is REPOSITORY_BROWSING, a call to this method is logically a No-op.
      Parameters:
      model - the model whos properties to edit
      Throws:
      IllegalStateException - if called from any other thread than the event dispatch thread.
    • close

      void close(MTModelHeader model) throws IllegalStateException
      Closes a page for a model if the shell state is MODELING and the model is open. If isBusy returns true the model will be closed when user input is accepted again.

      NOTE 1: If the shell state is REPOSITORY_BROWSING, a call to this method is logically a No-op.

      NOTE 2: If the model is not open, this is logically a No-Op.
      Parameters:
      model - the model to close
      Throws:
      IllegalStateException - if called from any other thread than the event dispatch thread.
    • close

      void close(Page<?> page) throws IllegalStateException
      Closes a page for if the shell state is MODELING and the page is open. If isBusy returns true the model will be closed when user input is accepted again.

      NOTE 1: If the shell state is REPOSITORY_BROWSING, a call to this method is logically a No-op.

      NOTE 2: If the page is not open, this is logically a No-Op.
      Parameters:
      page - the page to close
      Throws:
      IllegalStateException - if called from any other thread than the event dispatch thread.
    • getCurrentLanguage

      MTLanguage getCurrentLanguage() throws IllegalStateException
      Returns the currently active language.
      Returns:
      the currently active language.
      Throws:
      IllegalStateException - if called from any other thread than the event dispatch thread.
    • getShellFrame

      JFrame getShellFrame() throws IllegalStateException
      Returns the currently active shell frame depending on the shell state. This might be either a frame showing repositories or a frame showing a modeling area.
      Returns:
      the currently active shell frame
      Throws:
      IllegalStateException - if called from any other thread than the event dispatch thread.
    • isBusy

      boolean isBusy()
      Returns true if this shell is currently in busy mode, ignoring user input. Generally, this is not usefull information since you may only call this method from the ui thread. However, it can be used to "be nice to" long running background threads by doing as little as possible on the ui thread. If you know that you're doing a heavy painting operation, you may call this method first and do a repaint later if isBusy returns true.
      Returns:
      true if this shell is currently in busy mode
    • setBusy

      void setBusy(boolean isBusy)
      Turns this shells busy mode on or off. A busy shell is one where all user input is ignored. The isBusy flag indicates if the call should turn the busy mode on or off - true for on, false for off. Note that any queued up user input events will be processed. Thus, suspension will only occur when all previously submitted event have been processed.
      NOTE: It is important to return user input eventually. Otherwise the application will appear to have stuck. Thus, using a try-finally block around code that might throw exceptions, and calling this method with false in the finally block, is advised.
      Parameters:
      isBusy - true to temporarily suspend user input, false otherwise.
    • lockUi

      default void lockUi(boolean isBusy)
      Turns this shells busy mode on or off without showing a 'ticker'. See setBusy for more info lite specific
      Parameters:
      isBusy - true to temporarily suspend user input, false otherwise.
    • switchWorkspace

      void switchWorkspace(MTWorkspace workspace)
      Switches to a different workspace in the current repository. This may only be called when in the state ShellState.MODELING
      Parameters:
      workspace - The workspace to switch to. This has to be a workspace in the currently opened repository.
    • getState

      Shell.ShellState getState()
      Returns the current state of the shell.
      Returns:
      the current state of the shell.