public class EditorManager extends Object
MenuAreaButton
buttons in the
application tab menus that are connected to the management of logs, files and editors.
It is used by the Controller that delegates to this class the implementation of the actions
connected to these MenuAreaButton
buttons.
The Controller receives the user'choice by the relative listener and call the right method of this class.
MenuAreaButton
,
EventLogManagerController
Modifier and Type | Field and Description |
---|---|
private EventLogManagerController |
elmController
The
EventLogManagerController element
that represents the Controller of the application
and that is the one that uses this editor manager. |
private EventLogManagerModel |
elmModel
The
EventLogManagerModel element
that represents the Model of the application managed
by the Controller. |
private EventLogManagerView |
elmView
The
EventLogManagerView element
that represents the View of the application managed
by the Controller. |
Constructor and Description |
---|
EditorManager(EventLogManagerController elmController)
Constructs a new
EditorManager , with the EventLogManagerController
passed as parameter associated to it. |
Modifier and Type | Method and Description |
---|---|
boolean |
closeInternalFrame(JInternalFrame internalFrame)
Closes the
JInternalFrame passed as parameter, if one is passed,
or the selected one inside the
contentArea ,
if a frame is set as selected. |
void |
copyEventLog()
This method, if an
EventLogEditor frame is selected, copies the
selected text, if present, into the system clipboard. |
void |
cutEventLog()
This method, if an
EventLogEditor frame is selected, cuts the
selected text, if present, into the system clipboard. |
boolean |
exportDocument(String selectedFileName)
Opens an "Export" dialog to ask the user to decide where to export (and in which format)
the content either of the selected
EventLogEditor editor or of the selected
FootPrintMatrixInfo document (that are both inside the
contentArea ). |
boolean |
importDocument(String selectedFileName)
Opens an "Import" dialog to ask the user to select which file to import, then the method tries
to import it (.CSV and .HTML extensions available).
|
void |
newEventLog(ActionListener listener)
This method asks the View to open a dialog to make the user decide
between an empty Event Log or a generation of an Event Log starting
from an expression that defines the possible event traces.
|
void |
openEventLog(String selectedFileName,
boolean... isAbsolutePath)
Opens an "Open" dialog to ask the user to select which file to open, then the method tries
to open it (.XES, .CSV and .TXT extensions available).
|
void |
pasteEventLog()
This method, if an
EventLogEditor frame is selected, pastes the
content of the system clipboard in the EventLogEditor text area. |
boolean |
printDocument()
Opens a "Print" dialog to make the user select the printing settings, then prints
the document that is inside the selected
EventLogEditor editor (the one
inside the contentArea ). |
void |
redoEventLog()
This method, if an
EventLogEditor frame is selected, redo the
last action undone inside the EventLogEditor text area. |
void |
resetZoomEventLog()
Reset to the default value the font size of the content of the selected
EventLogEditor editor (that is inside the
contentArea ). |
boolean |
saveAsEventLog(String selectedFileName)
Opens a "Save As" dialog to ask the user to decide where to save the content of
the selected
EventLogEditor editor (that is inside the
contentArea ),
then it tries to save the content in the selected file (.XES, .CSV or .TXT extensions available). |
boolean |
saveEventLog()
Saves the content of the selected
EventLogEditor editor (that is inside
the contentArea )
in its own file, if an editor is selected. |
void |
undoEventLog()
This method, if an
EventLogEditor frame is selected, undo the
last action done inside the EventLogEditor text area. |
private boolean |
validateAgainstDTD(String xhtml)
Validates the given XHTML code against the DTD specified inside the document
DOCYPE . |
void |
zoomInEventLog()
Increases by 1pt the font size of the content of the selected
EventLogEditor editor (that is inside the
contentArea ). |
void |
zoomOutEventLog()
Decreases by 1pt the font size of the content of the selected
EventLogEditor editor (that is inside the
contentArea ). |
private EventLogManagerController elmController
EventLogManagerController
element
that represents the Controller of the application
and that is the one that uses this editor manager.EventLogManagerController
private EventLogManagerView elmView
EventLogManagerView
element
that represents the View of the application managed
by the Controller.
We set this reference to the View managed by the Controller from the
getView()
method of the EventLogManagerController
.
EventLogManagerView
private EventLogManagerModel elmModel
EventLogManagerModel
element
that represents the Model of the application managed
by the Controller.
We set this reference to the Model managed by the Controller from the
getModel()
method of the EventLogManagerController
.
EventLogManagerModel
public EditorManager(EventLogManagerController elmController)
EditorManager
, with the EventLogManagerController
passed as parameter associated to it.
The passed Controller is the one that uses this EditorManager
class. This class
uses this reference to the Controller to communicate with it, calling some of its methods.
This class is delegated by the Controller to implement some operations, for this reason it is able to call the View and the Model managed by the Controller directly on behalf of the Controller to handle this operation correctly.
elmController
- the EventLogManagerController
object that represents the Controller and uses this EditorManager
EventLogManagerView
,
EventLogManagerController
,
EventLogManagerModel
public void newEventLog(ActionListener listener)
If the user selects the first option, the method opens an empty
EventLogEditor
internal frame; if the user selects the
second option, the method first defines the structure of the component
that will get the expression from the user, then asks the View to show
the created component inside a dialog to get the user's choice. The method
also adds the passed ActionListener
to the component button
to get the user's action when pressed and start processing the expression.
listener
- the ActionListener
listener that will be associated with the the dialog button
(the dialog for the generation of event logs from expressions).EventLogEditor
public void openEventLog(String selectedFileName, boolean... isAbsolutePath)
The method first looks if there is already an opened EventLogEditor
editor
associated with that file (and in this case it sets it as selected to show it to the user,
asking him then if he wants to reload or to open in a new editor the file content, in case
another application modified it in the meanwhile).
Either if the process does not find any editor associated with the target file,
or the user selected to reload or to open in a new editor the file content, the method tries
to read the content of the selected file and to open it inside an EventLogEditor
(setting its title using the file name, its content using the file content and its source
file using the path of the selected file) in the first case, to reload it in the second one,
and to open it inside an EventLogEditor
(setting its title as a default value,
its content using the file content and without source file associated) in the third one.
The method implements the common behaviour of the Open button in a standard application, with management of errors that may occur during the process.
selectedFileName
- the file name to set as selected in the dialog, null
for no selectionisAbsolutePath
- optional value to set as true
to indicate that the selectedFileName is not just
a file name, but is a complete path to a file and the method should try to open it directly
without asking any selection to the user.EventLogEditor
public boolean closeInternalFrame(JInternalFrame internalFrame)
JInternalFrame
passed as parameter, if one is passed,
or the selected one inside the
contentArea
,
if a frame is set as selected.
This method first checks if the internal frame is an EventLogEditor
, in that
case it looks if this frame has been modified by the user or not: in the first case, it
asks if the user wants to save or not the document before closing; in the second one, checks if the
associated file still exists and decides to close or to ask to save again the document depending on this.
If the internal frame is not an EventLogEditor
, the method then checks if is a FootprintMatrixInfo
.
If it is, the method checks if the document has already been exported or not: in the first case, it checks if the associated file
still exists and decides to close or to ask to export again the document depending on this; in the second one, it asks directly
if the user wants to export or not the document before closing.
If the frame to close is not an FootprintMatrixInfo
either, the method closes directly the internal frame, because
there is not any specific action to do before closing for a generic internal frame.
internalFrame
- the internal frame to close, null
to close the selected internal frame inside the
contentArea
true
if the closing operation successfully close the internal frame, false
otherwise.JInternalFrame
,
EventLogEditor
,
FootprintMatrixInfo
public boolean saveEventLog()
EventLogEditor
editor (that is inside
the contentArea
)
in its own file, if an editor is selected.
This file is the source file of the internal frame, set by the "Open" option or the
"Save As" option. If no source file has been set before, the method delegates the
saveAsEventLog(String)
method to save the document.
The method is made for the EventLogEditor
frame. In case of using it with other
frame types, the method manages this situation with specifics information messages delivered to
the user.
The method implements the common behaviour of the Save button in a standard application, with overwrite checking, selected file existence checking and management of errors that may occur during the process.
At the end of the process, if the saving procedure went right, the method updates the title of the
EventLogEditor
, removing the asterisk at the end of it (if present).
true
if we successfully save the file, false
otherwise.EventLogEditor
public boolean saveAsEventLog(String selectedFileName)
EventLogEditor
editor (that is inside the
contentArea
),
then it tries to save the content in the selected file (.XES, .CSV or .TXT extensions available).
The method is made for the EventLogEditor
frame. In case of using it with other
frame types, the method manages this situation with specifics information messages delivered to
the user.
The method implements the common behaviour of the Save As button in a standard application, with overwrite checking, selected file existence checking and management of errors that may occur during the process.
At the end of the process, if the saving procedure went right, the method updates the path of the
EventLogEditor
source file and its title, removing the asterisk at the end of it (if present).
selectedFileName
- the file name to set as selected in the dialog, null
for using the EventLogEditor
titletrue
if we successfully save the file, false
otherwise.EventLogEditor
public boolean printDocument()
EventLogEditor
editor (the one
inside the contentArea
).EventLogEditor
public boolean importDocument(String selectedFileName)
If a CSV file is selected, the method delegates the process to the AnalysisManager
,
using its method AnalysisManager.parseCSV(String, String)
. This method manages the parsing
process of the target file, from its CSV content to the XES version, then from XES to the XML format
to show the generated content inside an EventLogEditor
. If some warnings are recorded
during the parsing, the method will show a dialog with them to the user.
If an XHTML file is selected, the method first looks if there is already an opened
FootprintMatrixInfo
window associated with that file (and in this case it sets it as selected to show it to the user,
asking him then if he wants to reload or to open in a new editor the file content, in case
another application modified it in the meanwhile).
Either if the process does not find any window associated with the target file,
or the user selected to reload or to open in a new window the file content, the method first
tries to read the content of the selected file and then to validate it, to ensure that
the file content is a well-formed XHTML code. If the document is valid against the specified DTD,
the process opens the file content inside an FootprintMatrixInfo
(setting its title using the file name, its content using the file content and its source
file using the path of the selected file) in the first case, to reload it in the second one,
and to open it inside an FootprintMatrixInfo
(setting its title as a default value,
its content using the file content and without source file associated) in the third one.
The validation of the selected XHTML file against its DTD is needed to ensure that the document is well-formed and therefore it will be displayed correctly inside the application and the export procedure will work perfectly.
This method uses the validateAgainstDTD(String)
method to validate the selected document
against its DTD, check its documentation for detailed information about how it works.
selectedFileName
- the file name to set as selected in the dialog, null
for no selectiontrue
if we successfully import the file, false
otherwise.EventLogEditor
,
FootprintMatrixInfo
private boolean validateAgainstDTD(String xhtml)
DOCYPE
.
The method needs Internet connection to retrieve the correct DTD specified by the URL
inside the document DOCTYPE
. If the connection is present and the URL is reachable,
it validates the document and shows to the user a detailed result; if the connection is not present
or an error with the URL occurs, it advises the user that it cannot validate the document, therefore
it is going to take it as it is if the user wants to proceed anyway, warning him about possible error
while displaying or exporting the document.
This method uses the
checkInternetConnection(String, int)
method of the Controller to check if the Internet connection is present and if the W3C web-site
(where to download the specified DTD) is reachable. Check its documentation for detailed information
about how it works.
During the validation, the SAXParser
utilises the
ParserContentHandler
handler to log all the
validation warning or errors that may occur; at the end, the method will shows this log
to the user inside a dialog box.
xhtml
- the XHTML code to validate against its DTDtrue
if we successfully validate the XHTML code, false
otherwiseSAXParser
,
AnalysisManager.ParserContentHandler
public boolean exportDocument(String selectedFileName)
EventLogEditor
editor or of the selected
FootPrintMatrixInfo
document (that are both inside the
contentArea
).
The method then tries to export the content of the selected frame in the selected file
(CSV format available for the EventLogEditor
; HTML, LaTeX, PDF and PNG formats
available for the FootPrintMatrixInfo
).
If CSV format is selected, the method reads the content of the EventLogEditor
editor
(that is a XES log) and converts it in a CSV format, using the XesCsvSerializer
. At the
end of the process it writes the generated CSV document in the selected file.
If HTML format is selected, the method reads the content of the FootPrintMatrixInfo
document (that is in XHTML format) and write it directly to the selected file. At the end of the process,
if the export procedure went right, the method sets the associated file of the FootPrintMatrixInfo
with the target file and its exported status as true
. This is the only case when the exported
status of the FootPrintMatrixInfo
is set to true
, and it is because the HTML format
is the "save" format of this type of frame: if the user in fact saves the content of a FootPrintMatrixInfo
in HTML and then closes that frame, it is possible for him to open it again inside the application, using the
Import function. Also, the Close function checks this value before closing a FootPrintMatrixInfo
,
to ask the user if he wants to close the frame without saving it in HTML, and ensure that he is advised
about this special saving procedure.
If LaTeX format is selected, the method reads the content of the FootPrintMatrixInfo
document (that is in XHTML format) and uses the "htmltolatex" library to convert the XHTML document
into a LaTex one and to write it in the selected file.
If PDF format is selected, the method reads the content of the FootPrintMatrixInfo
document (that is in XHTML format) and uses the "flyingsaucer" library to create a PDF in the selected
destination that represents the XHTML document. This library, first than creating the PDF file, it
validates the document to ensure that is a well-formed XHTML document, otherwise the library cannot
create a PDF that is a correct representation of the given document. This is why the application passes
to the export procedure only internal XHTML documents (the ones created by the Analysis Manager) or
imported XHTML documents that have been first validated against their DTDs, to ensure that the library
will only work with well-formed documents and therefore the library validation process will always
have success.
If PNG format is selected, the method first creates an image that is the representation of the
FootPrintMatrixInfo
text area (with the same dimension and content), then it writes the
image in the selected file. This means that the user can change the frame dimension (and therefore
also the content position in it, because this changes based on the frame dimension) to get the right
content disposition before exporting it in a PNG image format.
The method implements a behaviour similar to the Save As button, with overwrite checking, selected file existence checking and management of errors that may occur during the process. It simply at the end exports the content in the specified format instead save it as it is in a text file, implementing on this way other saving options for the selected content.
The method is made for the EventLogEditor
and FootPrintMatrixInfo
frames.
In case of using it with other frame types, the method manages this situation with specifics information
messages delivered to the user.
selectedFileName
- the file name to set as selected in the dialog, null
for using the EventLogEditor
titletrue
if we successfully export the file, false
otherwise.EventLogEditor
,
FootprintMatrixInfo
,
XesCsvSerializer
,
AnalysisManager
public void cutEventLog()
EventLogEditor
frame is selected, cuts the
selected text, if present, into the system clipboard.
The implementation of the this procedure is made directly by the
EventLogEditor
class, this method simply calls the
cut()
method
of the selected frame to pass it the cut command to process.
public void copyEventLog()
EventLogEditor
frame is selected, copies the
selected text, if present, into the system clipboard.
The implementation of the this procedure is made directly by the
EventLogEditor
class, this method simply calls the
copy()
method
of the selected frame to pass it the copy command to process.
public void pasteEventLog()
EventLogEditor
frame is selected, pastes the
content of the system clipboard in the EventLogEditor
text area.
The implementation of the this procedure is made directly by the
EventLogEditor
class, this method simply calls the
paste()
method
of the selected frame to pass it the paste command to process.
public void undoEventLog()
EventLogEditor
frame is selected, undo the
last action done inside the EventLogEditor
text area.
The implementation of the this procedure is made directly by the
EventLogEditor
class, this method simply calls the
undo()
method
of the selected frame to pass it the undo command to process.
public void redoEventLog()
EventLogEditor
frame is selected, redo the
last action undone inside the EventLogEditor
text area.
The implementation of the this procedure is made directly by the
EventLogEditor
class, this method simply calls the
redo()
method
of the selected frame to pass it the redo command to process.
public void zoomInEventLog()
EventLogEditor
editor (that is inside the
contentArea
).EventLogEditor
public void zoomOutEventLog()
EventLogEditor
editor (that is inside the
contentArea
).EventLogEditor
public void resetZoomEventLog()
EventLogEditor
editor (that is inside the
contentArea
).EventLogEditor