Class MainFrameModel
- java.lang.Object
-
- com.puppycrawl.tools.checkstyle.gui.MainFrameModel
-
public class MainFrameModel extends java.lang.Object
Model for checkstyle frame.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMainFrameModel.ParseModeParsing modes which available in GUI.
-
Field Summary
Fields Modifier and Type Field Description private java.io.FilecurrentFileThe file which is being parsed.private java.util.List<java.lang.Integer>linesToPositionLines to position map.private MainFrameModel.ParseModeparseModeCurrent mode.private ParseTreeTableModelparseTreeTableModelParse tree model.private booleanreloadActionEnabledWhether the reload action is enabled.private java.lang.StringtextText for a frame's text area.private java.lang.StringtitleTitle for the main frame.
-
Constructor Summary
Constructors Constructor Description MainFrameModel()Instantiate the model.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.io.FilegetCurrentFile()Get current file.private static FileTextgetFileText(java.io.File file)Get FileText from a file.java.io.FilegetLastDirectory()Get the directory of the last loaded file.java.util.List<java.lang.Integer>getLinesToPosition()Get lines to position map.ParseTreeTableModelgetParseTreeTableModel()Get parse tree table model.java.lang.StringgetText()Get text to display in a text area.java.lang.StringgetTitle()Returns title for the main frame.booleanisReloadActionEnabled()Returns true if the reload action is enabled, false otherwise.voidopenFile(java.io.File file)Open file and load the file.voidsetParseMode(MainFrameModel.ParseMode mode)Set current parse mode.static booleanshouldAcceptFile(java.io.File file)Whether a file chooser should accept the file as a source file.
-
-
-
Field Detail
-
parseTreeTableModel
private final ParseTreeTableModel parseTreeTableModel
Parse tree model.
-
linesToPosition
private java.util.List<java.lang.Integer> linesToPosition
Lines to position map.
-
parseMode
private MainFrameModel.ParseMode parseMode
Current mode.
-
currentFile
private java.io.File currentFile
The file which is being parsed.
-
text
private java.lang.String text
Text for a frame's text area.
-
title
private java.lang.String title
Title for the main frame.
-
reloadActionEnabled
private boolean reloadActionEnabled
Whether the reload action is enabled.
-
-
Constructor Detail
-
MainFrameModel
public MainFrameModel()
Instantiate the model.
-
-
Method Detail
-
setParseMode
public void setParseMode(MainFrameModel.ParseMode mode)
Set current parse mode.- Parameters:
mode- ParseMode enum.
-
getParseTreeTableModel
public ParseTreeTableModel getParseTreeTableModel()
Get parse tree table model.- Returns:
- parse tree table model.
-
getText
public java.lang.String getText()
Get text to display in a text area.- Returns:
- text to display in a text area.
-
getTitle
public java.lang.String getTitle()
Returns title for the main frame.- Returns:
- title for the main frame.
-
isReloadActionEnabled
public boolean isReloadActionEnabled()
Returns true if the reload action is enabled, false otherwise.- Returns:
- true if the reload action is enabled.
-
shouldAcceptFile
public static boolean shouldAcceptFile(java.io.File file)
Whether a file chooser should accept the file as a source file.- Parameters:
file- the file to check.- Returns:
- true if the file should be accepted.
-
getLastDirectory
public java.io.File getLastDirectory()
Get the directory of the last loaded file.- Returns:
- directory of the last loaded file.
-
getCurrentFile
public java.io.File getCurrentFile()
Get current file.- Returns:
- current file.
-
getLinesToPosition
public java.util.List<java.lang.Integer> getLinesToPosition()
Get lines to position map. It returns unmodifiable collection to prevent additional overhead of copying and possible state modifications.- Returns:
- lines to position map.
-
openFile
public void openFile(java.io.File file) throws CheckstyleException
Open file and load the file.- Parameters:
file- the file to open.- Throws:
CheckstyleException- if the file can not be parsed.java.lang.IllegalArgumentException- if parseMode is unknown
-
getFileText
private static FileText getFileText(java.io.File file) throws java.io.IOException
Get FileText from a file.- Parameters:
file- the file to get the FileText from.- Returns:
- the FileText.
- Throws:
java.io.IOException- if the file could not be read.
-
-