Package se.conciliate.extensions.ui
Interface Shell
public interface Shell
Note that all shell operations must occur on the event dispathing thread.
- Author:
- Per-Erik
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
Shows a popup at the appropriate location for a status icon.static enum
Describes the shells state.static class
Simple status progress with a static title that consumes progress values between 0-100 where -1 is indeterminate.static interface
Shows an icon in the status bar.static interface
Used to show a progress bar in the status bar. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addNotification
(ShellNotification notification) Adds a notification message to the user-visible notification log.default boolean
litedefault boolean
litevoid
close
(MTModelHeader model) Closes a page for a model if the shell state is MODELING and the model is open.void
Closes a page for if the shell state is MODELING and the page is open.default void
void
Finds a suitable editor for the given object and requested context and starts editing the object with that editor.default void
void
Finds a suitable editor for the given object and requested context and starts editing the object with that editor.void
editProperties
(MTModelHeader model) Opens an editing view for a model, at some time in the future*, if the shell state is MODELING.default Action
liteReturns the currently active language.default Action
litedefault List<MTModelHeader>
litedefault List<MTModelHeader>
liteReturns the currently active shell frame depending on the shell state.getState()
Returns the current state of the shell.void
highlightComponent
(JComponent component, String message, Integer messageWidth) Highlights a component that the user should take special notice of right now.boolean
isBusy()
Returns true if this shell is currently in busy mode, ignoring user input.default void
lockUi
(boolean isBusy) Turns this shells busy mode on or off without showing a 'ticker'.default void
litedefault void
litevoid
open
(MTModelHeader model) Opens a model in a new page, at some time in the future*, if the shell state is MODELING.default void
open
(MTRevisionInfo info) litevoid
Opens a new page, at some time in the future*, if the shell state is MODELING.void
removeIcon
(Shell.StatusIcon icon) Remove icon from the status bar.default void
runWithCheckForUnsavedChanges
(String proceedText, Runnable r) Runs an action after checking if there are unsaved changes.void
setBusy
(boolean isBusy) Turns this shells busy mode on or off.void
showIcon
(Shell.StatusIcon icon) Show icon in the status bar.void
showProgress
(Future<?> f, String text) Show progress in the status bar.void
showProgress
(Shell.StatusProgress progress) Show progress in the status bar.void
switchWorkspace
(MTWorkspace workspace) Switches to a different workspace in the current repository.default void
updateModelHistory
(MTModelHeader model) lite
-
Method Details
-
showIcon
Show icon in the status bar. -
removeIcon
Remove icon from the status bar. -
showProgress
Show progress in the status bar. -
showProgress
Show progress in the status bar. -
runWithCheckForUnsavedChanges
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
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.
-
getBackAction
lite -
getForwardAction
lite -
updateModelHistory
lite -
open
lite- Throws:
IllegalStateException
-
highlightComponent
Highlights a component that the user should take special notice of right now.- Parameters:
component
- The component to highlightmessage
- 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
Opens a model in a new page, at some time in the future*, if the shell state is MODELING. IfisBusy
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
Opens a new page, at some time in the future*, if the shell state is MODELING. IfisBusy
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
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
-
edit
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
-
editProperties
Opens an editing view for a model, at some time in the future*, if the shell state is MODELING. IfisBusy
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
Closes a page for a model if the shell state is MODELING and the model is open. IfisBusy
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
Closes a page for if the shell state is MODELING and the page is open. IfisBusy
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
Returns the currently active language.- Returns:
- the currently active language.
- Throws:
IllegalStateException
- if called from any other thread than the event dispatch thread.
-
getShellFrame
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. TheisBusy
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'. SeesetBusy
for more info lite specific- Parameters:
isBusy
- true to temporarily suspend user input, false otherwise.
-
switchWorkspace
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.
-