net.sf.sdedit.ui
Interface UserInterface

All Known Implementing Classes:
UserInterfaceImpl

public interface UserInterface

Specifies the methods required of a (multi-tabbed) user interface for the Quick Sequence Diagram Editor.

Author:
Markus Strauch

Method Summary
 void addAction(String category, Action action, Activator activator)
          Adds a choosable component to the user interface such that on choosing it the given action is performed.
 void addCategory(String category, String icon)
           
 void addConfigurationAction(String category, ConfigurationAction<?> action, Activator activator)
           
 void addListener(UserInterfaceListener listener)
          Adds a listener to this UserInterface.
 String addTab(String title, Bean<Configuration> configuration)
          Adds a new tab to the user interface which becomes the tab that is currently selected.
 void addToolbarSeparator()
           
 void addToToolbar(Action action, Activator activator)
          Adds an action that can be quickly performed (by just a single click, for instance).
 void appendText(String tab, String text)
          Appends text in the text area of the tab identified by the first argument.
 void clearDisplay()
          Clears the area where the diagram is displayed.
 void configure(boolean local)
          Shows a window where the preferences can be set
 boolean confirm(String message)
          Asks the user for confirmation.
 int confirmOrCancel(String message)
          Asks the user to confirm something or to cancel the process that lead to the point where something must be confirmed.
 void enterFilterMode()
          Enters the filter mode where the user can enter a command for filtering the contents of the text area.
 void errorMessage(String msg)
          Displays an error message to the user.
 void exit()
          This method is called when the application is exited.
 void fullScreen()
          Shows the diagram most recently generated in a full screen view.
 String getCode()
          Returns the code from which a diagram is to be generated or an empty string if there is no code.
 Bean<Configuration> getConfiguration()
          Returns the configuration belonging to the active tab or null if the active tab does show a help page.
 File getCurrentFile()
          Returns the file that is associated to the text in the current tab, may be null if no such file exists.
 Diagram getDiagram()
          Returns the diagram rendered most recently inside the current tab, or null, if there is not a regular tab visible.
 DiagramError getDiagramError()
          Returns the first error that has occurred during the most recent rendering of a diagram, if any.
 File[] getFiles(boolean open, boolean multiple, String message, String file, File directory, String... filter)
          Lets the user choose one or more files and returns them.
 int getNumberOfTabs()
          Returns the number of tabs currently open.
 String getOption(String text, String... options)
           
 String getString(String question, String initialValue)
          Asks the user to type some string into an input dialog.
 void help(String title, String path, boolean navigation)
          Displays a help page.
 void home()
          Makes the left top corner of the diagram visible, which may imply that the part that is currently visible is scrolled out of view.
 boolean isClean()
          A flag denoting if the user has not changed the text currently displayed since last time the current tab had been added or setClean() had been called.
 boolean isDiagramBlank()
          Returns a flag denoting if there are currently any diagram elements displayed in the current tab
 boolean isDiagramTabSelected()
          Returns a flag denoting if a tab with a diagram is currently selected.
 void layout(int layout)
           
 void leaveFilterMode()
          Leaves the filter mode, no command can be entered any more.
 void message(String msg)
          Displays a message to the user.
 void moveCursorToPosition(int pos)
          Moves the cursor to the given position in the text area.
 void nextTab()
           
 void previousTab()
           
 void redo()
          Redoes the last change that had been made to the text area and that had been made undone.
 void redraw()
          Shows the diagram generated from the code in the current tab.
 void removeAction(String category, Action action)
           
 boolean removeCurrentTab(boolean check)
          Removes the current tab.
 Diagram renderDiagram()
          If a regular tab is open, creates a diagram from the code currently being displayed and returns it.
 boolean selectTabWith(File file)
          Selects the first tab that shows a diagram associated to the given file or does nothing, if no such tab exists.
 void setClean()
          Specifies that the text currently displayed is "clean", this means there are no changes made by the user.
 void setCode(String text)
          Sets a piece of code in the current tab to generate a diagram from.
 void setCurrentFile(File file)
          Associates the given file to the text in the current tab.
 void setErrorStatus(boolean warning, String errorStatus, int begin, int end)
          Displays text that informs about what was entered wrongly.
 void setQuitAction(Action action)
          Sets the action that is to be performed when the user quits.
 void setStatus(String status)
          Sets a status line.
 void setTabTitle(String title)
          Sets the title of the current tab.
 void setTitle(String title)
          Sets the title of the user interface.
 void showAboutDialog(URL aboutURL)
          Shows an about-dialog with a content found at the URL given.
 void showPrintDialog(String filetype)
           
 void showUI()
          Makes the user interface visible.
 void toggleFilterMode()
          Enters the filter mode, if we are not already in it, otherwise leaves it.
 void undo()
          Undoes the last change made to the text area.
 

Method Detail

addListener

void addListener(UserInterfaceListener listener)
Adds a listener to this UserInterface.

Parameters:
listener - a listener for the UserInterface

addAction

void addAction(String category,
               Action action,
               Activator activator)
Adds a choosable component to the user interface such that on choosing it the given action is performed.

Parameters:
category - a string denoting the category of the action
action - a performable action
activator - an Activator that decides whether the action resp. its associated button is to be enabled

addCategory

void addCategory(String category,
                 String icon)

removeAction

void removeAction(String category,
                  Action action)

nextTab

void nextTab()

previousTab

void previousTab()

addConfigurationAction

void addConfigurationAction(String category,
                            ConfigurationAction<?> action,
                            Activator activator)

renderDiagram

Diagram renderDiagram()
If a regular tab is open, creates a diagram from the code currently being displayed and returns it. Otherwise returns null.

Returns:
the newly created diagram

getDiagram

Diagram getDiagram()
Returns the diagram rendered most recently inside the current tab, or null, if there is not a regular tab visible.

Returns:
the diagram rendered most recently

getDiagramError

DiagramError getDiagramError()
Returns the first error that has occurred during the most recent rendering of a diagram, if any.

Returns:
the first error that has occurred during the most recent rendering of a diagram, if any

setQuitAction

void setQuitAction(Action action)
Sets the action that is to be performed when the user quits.

Parameters:
action - the action to be performed when the user quits

setCode

void setCode(String text)
Sets a piece of code in the current tab to generate a diagram from.

Parameters:
text - a piece of code to generate a diagram from

appendText

void appendText(String tab,
                String text)
Appends text in the text area of the tab identified by the first argument.

Parameters:
tab - the name of the tab where the text is to be appended
text - the text to be appended

getCode

String getCode()
Returns the code from which a diagram is to be generated or an empty string if there is no code.

Returns:
the code from which a diagram is to be generated or an empty string if there is no code

redraw

void redraw()
Shows the diagram generated from the code in the current tab.


setStatus

void setStatus(String status)
Sets a status line.

Parameters:
status - a status line

confirmOrCancel

int confirmOrCancel(String message)
Asks the user to confirm something or to cancel the process that lead to the point where something must be confirmed.

Parameters:
message - a message describing what is to be confirmed
Returns:
1 if the user confirms, 0 if the user disagrees, -1 for cancel

confirm

boolean confirm(String message)
Asks the user for confirmation.

Parameters:
message - a message describing what is to be confirmed
Returns:
true iff the user confirms

getFiles

File[] getFiles(boolean open,
                boolean multiple,
                String message,
                String file,
                File directory,
                String... filter)
Lets the user choose one or more files and returns them.

Parameters:
open - true if the files are to be opened
multiple - true if multiple files can be selected
message - the message describing the purpose of the file to be chosen
directory - the directory where to start choosing, or null
filter - can be empty, in which case no file filter is used, otherwise the first string is a description of the filter and the remaining strings are extensions of files to be shown
Returns:
an array of chosen files or null if no file has been chosen

getString

String getString(String question,
                 String initialValue)
Asks the user to type some string into an input dialog.

Parameters:
question - the question to which the string to be typed is an answer
initialValue - the initial string that is suggested as an answer
Returns:
the string typed in by the user

configure

void configure(boolean local)
Shows a window where the preferences can be set

Parameters:
local - flag denoting if diagram preferences are to be configured

message

void message(String msg)
Displays a message to the user.

Parameters:
msg - a message

showUI

void showUI()
Makes the user interface visible.


errorMessage

void errorMessage(String msg)
Displays an error message to the user.

Parameters:
msg - an error message

setTitle

void setTitle(String title)
Sets the title of the user interface.

Parameters:
title - the title of the user interface.

addToToolbar

void addToToolbar(Action action,
                  Activator activator)
Adds an action that can be quickly performed (by just a single click, for instance).

Parameters:
quickAction - an action that can be quickly performed

addToolbarSeparator

void addToolbarSeparator()

moveCursorToPosition

void moveCursorToPosition(int pos)
Moves the cursor to the given position in the text area.

Parameters:
pos - the position to where the cursor is to be moved

setErrorStatus

void setErrorStatus(boolean warning,
                    String errorStatus,
                    int begin,
                    int end)
Displays text that informs about what was entered wrongly.

Parameters:
warning - flag indicating if the user should only be warned
errorStatus - text that informs about what was entered wrongly
begin - the index where the string causing the error begins
end - the index where the string causing the error ends

home

void home()
Makes the left top corner of the diagram visible, which may imply that the part that is currently visible is scrolled out of view.


addTab

String addTab(String title,
              Bean<Configuration> configuration)
Adds a new tab to the user interface which becomes the tab that is currently selected.

Parameters:
title - the title of the tab
configuration - the configuration to be used for the diagram that is displayed by the tab (typically a default configuration for empty tabs or a loaded configuration for tabs that show diagrams loaded from files)
Returns:
the actual unique title of the newly added tab (may differ from the original title)

setTabTitle

void setTabTitle(String title)
Sets the title of the current tab.

Parameters:
title - the title of the current tab

removeCurrentTab

boolean removeCurrentTab(boolean check)
Removes the current tab. If the parameter check is true and there is no other tab open, the tab cannot be removed.

Parameters:
check - flag denoting whether the existence of another tab is a pre-condition for removing the current tab
Returns:
a flag denoting if the current tab has in fact been removed

getCurrentFile

File getCurrentFile()
Returns the file that is associated to the text in the current tab, may be null if no such file exists.

Returns:
the file that is associated to the text in the current tab

setCurrentFile

void setCurrentFile(File file)
Associates the given file to the text in the current tab.

Parameters:
file - the file to be associated to the text in the current tab

isClean

boolean isClean()
A flag denoting if the user has not changed the text currently displayed since last time the current tab had been added or setClean() had been called.

Returns:
flag denoting if the user has changed the text currently displayed

setClean

void setClean()
Specifies that the text currently displayed is "clean", this means there are no changes made by the user.


help

void help(String title,
          String path,
          boolean navigation)
Displays a help page.

Parameters:
title - the title of the tab where the help page is shown
path - the path to the help document (for example /foo/bar/help.html is the path to help.html in the package foo.bar
navigation - flag denoting if a navigation tree is to be built from the anchor names inside the help page

undo

void undo()
Undoes the last change made to the text area.


redo

void redo()
Redoes the last change that had been made to the text area and that had been made undone.


clearDisplay

void clearDisplay()
Clears the area where the diagram is displayed.


getNumberOfTabs

int getNumberOfTabs()
Returns the number of tabs currently open.

Returns:
the number of tabs that are currently open

showAboutDialog

void showAboutDialog(URL aboutURL)
Shows an about-dialog with a content found at the URL given.

Parameters:
aboutURL - a URL with the content of the about dialog

fullScreen

void fullScreen()
Shows the diagram most recently generated in a full screen view.


enterFilterMode

void enterFilterMode()
Enters the filter mode where the user can enter a command for filtering the contents of the text area.


leaveFilterMode

void leaveFilterMode()
Leaves the filter mode, no command can be entered any more.


toggleFilterMode

void toggleFilterMode()
Enters the filter mode, if we are not already in it, otherwise leaves it.


showPrintDialog

void showPrintDialog(String filetype)

selectTabWith

boolean selectTabWith(File file)
Selects the first tab that shows a diagram associated to the given file or does nothing, if no such tab exists.

Parameters:
file - a diagram file
Returns:
flag denoting if an appropriate tab has been found

exit

void exit()
This method is called when the application is exited. It is not supposed to call System.exit().


layout

void layout(int layout)

isDiagramBlank

boolean isDiagramBlank()
Returns a flag denoting if there are currently any diagram elements displayed in the current tab

Returns:
a flag denoting if there are currently any diagram elements displayed in the current tab

isDiagramTabSelected

boolean isDiagramTabSelected()
Returns a flag denoting if a tab with a diagram is currently selected.

Returns:
a flag denoting if a tab with a diagram is currently selected

getConfiguration

Bean<Configuration> getConfiguration()
Returns the configuration belonging to the active tab or null if the active tab does show a help page.

Returns:
the configuration belonging to the active tab

getOption

String getOption(String text,
                 String... options)


Copyright © 2011. All Rights Reserved.