Skip to content
Snippets Groups Projects
Commit 60401902 authored by Dominique Marcadet's avatar Dominique Marcadet
Browse files

rename SclFileCheckBox to FileCheckBox

parent 2c01c184
No related branches found
No related tags found
1 merge request!14Resolve "update HMI from previous version to allow for loading NSD files"
Pipeline #1239 passed
......@@ -22,12 +22,12 @@ import java.io.File;
import javax.swing.JCheckBox;
public class SclFileCheckBox {
public class FileCheckBox {
private File file;
private JCheckBox checkBox;
public SclFileCheckBox( File file ) {
public FileCheckBox( File file ) {
this.file = file;
this.checkBox = new JCheckBox( file.getName() );
this.checkBox.setSelected( true );
......
......@@ -37,14 +37,14 @@ import javax.swing.border.EmptyBorder;
* Adapted from http://www.devx.com/tips/Tip/5342
*/
@SuppressWarnings( "serial" )
public class SclFileList extends JList< SclFileCheckBox > {
public class SclFileList extends JList< FileCheckBox > {
protected static Border noFocusBorder = new EmptyBorder( 1, 1, 1, 1 );
private DefaultListModel< SclFileCheckBox > model;
private DefaultListModel< FileCheckBox > model;
public SclFileList() {
model = new DefaultListModel< SclFileCheckBox >();
model = new DefaultListModel< FileCheckBox >();
setModel( model );
setCellRenderer( new SclFileCellRenderer() );
......@@ -71,14 +71,14 @@ public class SclFileList extends JList< SclFileCheckBox > {
}
}
SclFileCheckBox check = new SclFileCheckBox( file );
FileCheckBox check = new FileCheckBox( file );
model.addElement( check );
}
protected class SclFileCellRenderer implements ListCellRenderer< SclFileCheckBox > {
protected class SclFileCellRenderer implements ListCellRenderer< FileCheckBox > {
@Override
public Component getListCellRendererComponent( JList< ? extends SclFileCheckBox > list, SclFileCheckBox file, int index,
public Component getListCellRendererComponent( JList< ? extends FileCheckBox > list, FileCheckBox file, int index,
boolean isSelected, boolean cellHasFocus ) {
JCheckBox checkbox = file.getCheckBox();
checkbox.setBackground( isSelected ? getSelectionBackground() : getBackground() );
......
......@@ -37,7 +37,7 @@ public class TreeFilePane extends JTree {
private DefaultMutableTreeNode root;
public TreeFilePane( File fileRoot ) {
root = new DefaultMutableTreeNode( new SclFileCheckBox( fileRoot ) );
root = new DefaultMutableTreeNode( new FileCheckBox( fileRoot ) );
setModel( new DefaultTreeModel( root ) );
setShowsRootHandles( true );
......@@ -52,14 +52,14 @@ public class TreeFilePane extends JTree {
if( selRow != -1 ) {
TreePath selPath = getPathForLocation( e.getX(), e.getY() );
DefaultMutableTreeNode node = (( DefaultMutableTreeNode ) selPath.getLastPathComponent() );
SclFileCheckBox checkbox = ( SclFileCheckBox ) node.getUserObject();
FileCheckBox checkbox = ( FileCheckBox ) node.getUserObject();
propagateInTree( node, ! checkbox.getCheckBox().isSelected() );
repaint();
}
}
private void propagateInTree( DefaultMutableTreeNode node, boolean selected ) {
SclFileCheckBox checkbox = ( SclFileCheckBox ) node.getUserObject();
FileCheckBox checkbox = ( FileCheckBox ) node.getUserObject();
checkbox.getCheckBox().setSelected( selected );
for( int i = 0; i < node.getChildCount(); ++i ) {
propagateInTree( ( DefaultMutableTreeNode ) node.getChildAt( i ), selected );
......@@ -74,7 +74,7 @@ public class TreeFilePane extends JTree {
if( files == null ) return;
for( File file : files ) {
DefaultMutableTreeNode childNode = new DefaultMutableTreeNode( new SclFileCheckBox( file ) );
DefaultMutableTreeNode childNode = new DefaultMutableTreeNode( new FileCheckBox( file ) );
node.add( childNode );
if( file.isDirectory() ) {
createChildren( file, childNode );
......@@ -88,7 +88,7 @@ public class TreeFilePane extends JTree {
public Component getTreeCellRendererComponent( JTree tree, Object value, boolean selected, boolean expanded,
boolean leaf, int row, boolean hasFocus ) {
DefaultMutableTreeNode node = ( DefaultMutableTreeNode ) value;
SclFileCheckBox file = ( SclFileCheckBox ) node.getUserObject();
FileCheckBox file = ( FileCheckBox ) node.getUserObject();
JCheckBox checkbox = file.getCheckBox();
checkbox.setEnabled( isEnabled() );
checkbox.setFont( getFont() );
......@@ -103,7 +103,7 @@ public class TreeFilePane extends JTree {
}
private void getSelectedFiles( DefaultMutableTreeNode node, ArrayList< File > oclFiles ) {
SclFileCheckBox checkbox = ( SclFileCheckBox ) node.getUserObject();
FileCheckBox checkbox = ( FileCheckBox ) node.getUserObject();
if( checkbox.getFile().isFile() ) {
if( checkbox.getCheckBox().isSelected() ) {
oclFiles.add( checkbox.getFile() );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment