Findbugs violation: resolve all violations from gui package. #925
This commit is contained in:
parent
e1a27939ae
commit
c3dc1a94f3
|
|
@ -82,10 +82,6 @@
|
|||
<Class name="com.puppycrawl.tools.checkstyle.api.TokenTypes" />
|
||||
<Bug pattern="DM_EXIT" />
|
||||
</Match>
|
||||
<Match>
|
||||
<!-- till #925 -->
|
||||
<Package name="~com\.puppycrawl\.tools\.checkstyle\.gui.*" />
|
||||
</Match>
|
||||
<Match>
|
||||
<!-- have never been a case for years, Eclipse does not show any other classes inherited from CommonASTWithHiddenTokens -->
|
||||
<Class name="com.puppycrawl.tools.checkstyle.api.DetailAST" />
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
package com.puppycrawl.tools.checkstyle.gui;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
|
|
@ -47,9 +48,10 @@ public class Main
|
|||
final File f = new File(args[0]);
|
||||
panel.openFile(f, frame);
|
||||
}
|
||||
frame.pack();
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.setVisible(true);
|
||||
|
||||
Runnable runner = new FrameShower(frame);
|
||||
EventQueue.invokeLater(runner);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -66,4 +68,32 @@ public class Main
|
|||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* http://findbugs.sourceforge.net/bugDescriptions.html#SW_SWING_METHODS_INVOKED_IN_SWING_THREAD
|
||||
*/
|
||||
private static class FrameShower implements Runnable
|
||||
{
|
||||
/**
|
||||
* frame
|
||||
*/
|
||||
final JFrame frame;
|
||||
|
||||
/**
|
||||
* contstructor
|
||||
*/
|
||||
public FrameShower(JFrame frame)
|
||||
{
|
||||
this.frame = frame;
|
||||
}
|
||||
|
||||
/**
|
||||
* display a frame
|
||||
*/
|
||||
public void run()
|
||||
{
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,15 +30,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.TooManyListenersException;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.Action;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.*;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
|
||||
import antlr.ANTLRException;
|
||||
|
|
@ -59,7 +51,8 @@ public class ParseTreeInfoPanel extends JPanel
|
|||
{
|
||||
/** For Serialisation that will never happen. */
|
||||
private static final long serialVersionUID = -4243405131202059043L;
|
||||
private final ParseTreeModel parseTreeModel;
|
||||
|
||||
private final transient ParseTreeModel parseTreeModel;
|
||||
private final JTextArea jTextArea;
|
||||
private File lastDirectory;
|
||||
private File currentFile;
|
||||
|
|
@ -270,8 +263,7 @@ public class ParseTreeInfoPanel extends JPanel
|
|||
{
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
final DetailAST treeRoot = null;
|
||||
parseTreeModel = new ParseTreeModel(treeRoot);
|
||||
parseTreeModel = new ParseTreeModel(null);
|
||||
JTreeTable treeTable = new JTreeTable(parseTreeModel);
|
||||
final JScrollPane sp = new JScrollPane(treeTable);
|
||||
this.add(sp, BorderLayout.NORTH);
|
||||
|
|
@ -308,14 +300,7 @@ public class ParseTreeInfoPanel extends JPanel
|
|||
|
||||
private void showErrorDialog(final Component parent, final String msg)
|
||||
{
|
||||
final Runnable showError = new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
JOptionPane.showMessageDialog(parent, msg);
|
||||
}
|
||||
};
|
||||
final Runnable showError = new FrameShower(parent, msg);
|
||||
SwingUtilities.invokeLater(showError);
|
||||
}
|
||||
|
||||
|
|
@ -323,5 +308,38 @@ public class ParseTreeInfoPanel extends JPanel
|
|||
{
|
||||
return lines2position;
|
||||
}
|
||||
|
||||
/**
|
||||
* http://findbugs.sourceforge.net/bugDescriptions.html#SW_SWING_METHODS_INVOKED_IN_SWING_THREAD
|
||||
*/
|
||||
private static class FrameShower implements Runnable
|
||||
{
|
||||
/**
|
||||
* frame
|
||||
*/
|
||||
final Component parent;
|
||||
|
||||
/**
|
||||
* frame
|
||||
*/
|
||||
final String msg;
|
||||
|
||||
/**
|
||||
* contstructor
|
||||
*/
|
||||
public FrameShower(Component parent, final String msg)
|
||||
{
|
||||
this.parent = parent;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* display a frame
|
||||
*/
|
||||
public void run()
|
||||
{
|
||||
JOptionPane.showMessageDialog(parent, msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -84,8 +84,9 @@ public class TreeTableModelAdapter extends AbstractTableModel
|
|||
{
|
||||
/** For Serialisation that will never happen. */
|
||||
private static final long serialVersionUID = 8269213416115369275L;
|
||||
|
||||
private final JTree tree;
|
||||
private final TreeTableModel treeTableModel;
|
||||
private final transient TreeTableModel treeTableModel;
|
||||
|
||||
public TreeTableModelAdapter(TreeTableModel treeTableModel, JTree tree)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue