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; ...@@ -22,12 +22,12 @@ import java.io.File;
import javax.swing.JCheckBox; import javax.swing.JCheckBox;
public class SclFileCheckBox { public class FileCheckBox {
private File file; private File file;
private JCheckBox checkBox; private JCheckBox checkBox;
public SclFileCheckBox( File file ) { public FileCheckBox( File file ) {
this.file = file; this.file = file;
this.checkBox = new JCheckBox( file.getName() ); this.checkBox = new JCheckBox( file.getName() );
this.checkBox.setSelected( true ); this.checkBox.setSelected( true );
......
...@@ -37,14 +37,14 @@ import javax.swing.border.EmptyBorder; ...@@ -37,14 +37,14 @@ import javax.swing.border.EmptyBorder;
* Adapted from http://www.devx.com/tips/Tip/5342 * Adapted from http://www.devx.com/tips/Tip/5342
*/ */
@SuppressWarnings( "serial" ) @SuppressWarnings( "serial" )
public class SclFileList extends JList< SclFileCheckBox > { public class SclFileList extends JList< FileCheckBox > {
protected static Border noFocusBorder = new EmptyBorder( 1, 1, 1, 1 ); protected static Border noFocusBorder = new EmptyBorder( 1, 1, 1, 1 );
private DefaultListModel< SclFileCheckBox > model; private DefaultListModel< FileCheckBox > model;
public SclFileList() { public SclFileList() {
model = new DefaultListModel< SclFileCheckBox >(); model = new DefaultListModel< FileCheckBox >();
setModel( model ); setModel( model );
setCellRenderer( new SclFileCellRenderer() ); setCellRenderer( new SclFileCellRenderer() );
...@@ -71,14 +71,14 @@ public class SclFileList extends JList< SclFileCheckBox > { ...@@ -71,14 +71,14 @@ public class SclFileList extends JList< SclFileCheckBox > {
} }
} }
SclFileCheckBox check = new SclFileCheckBox( file ); FileCheckBox check = new FileCheckBox( file );
model.addElement( check ); model.addElement( check );
} }
protected class SclFileCellRenderer implements ListCellRenderer< SclFileCheckBox > { protected class SclFileCellRenderer implements ListCellRenderer< FileCheckBox > {
@Override @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 ) { boolean isSelected, boolean cellHasFocus ) {
JCheckBox checkbox = file.getCheckBox(); JCheckBox checkbox = file.getCheckBox();
checkbox.setBackground( isSelected ? getSelectionBackground() : getBackground() ); checkbox.setBackground( isSelected ? getSelectionBackground() : getBackground() );
......
...@@ -37,7 +37,7 @@ public class TreeFilePane extends JTree { ...@@ -37,7 +37,7 @@ public class TreeFilePane extends JTree {
private DefaultMutableTreeNode root; private DefaultMutableTreeNode root;
public TreeFilePane( File fileRoot ) { public TreeFilePane( File fileRoot ) {
root = new DefaultMutableTreeNode( new SclFileCheckBox( fileRoot ) ); root = new DefaultMutableTreeNode( new FileCheckBox( fileRoot ) );
setModel( new DefaultTreeModel( root ) ); setModel( new DefaultTreeModel( root ) );
setShowsRootHandles( true ); setShowsRootHandles( true );
...@@ -52,14 +52,14 @@ public class TreeFilePane extends JTree { ...@@ -52,14 +52,14 @@ public class TreeFilePane extends JTree {
if( selRow != -1 ) { if( selRow != -1 ) {
TreePath selPath = getPathForLocation( e.getX(), e.getY() ); TreePath selPath = getPathForLocation( e.getX(), e.getY() );
DefaultMutableTreeNode node = (( DefaultMutableTreeNode ) selPath.getLastPathComponent() ); DefaultMutableTreeNode node = (( DefaultMutableTreeNode ) selPath.getLastPathComponent() );
SclFileCheckBox checkbox = ( SclFileCheckBox ) node.getUserObject(); FileCheckBox checkbox = ( FileCheckBox ) node.getUserObject();
propagateInTree( node, ! checkbox.getCheckBox().isSelected() ); propagateInTree( node, ! checkbox.getCheckBox().isSelected() );
repaint(); repaint();
} }
} }
private void propagateInTree( DefaultMutableTreeNode node, boolean selected ) { private void propagateInTree( DefaultMutableTreeNode node, boolean selected ) {
SclFileCheckBox checkbox = ( SclFileCheckBox ) node.getUserObject(); FileCheckBox checkbox = ( FileCheckBox ) node.getUserObject();
checkbox.getCheckBox().setSelected( selected ); checkbox.getCheckBox().setSelected( selected );
for( int i = 0; i < node.getChildCount(); ++i ) { for( int i = 0; i < node.getChildCount(); ++i ) {
propagateInTree( ( DefaultMutableTreeNode ) node.getChildAt( i ), selected ); propagateInTree( ( DefaultMutableTreeNode ) node.getChildAt( i ), selected );
...@@ -74,7 +74,7 @@ public class TreeFilePane extends JTree { ...@@ -74,7 +74,7 @@ public class TreeFilePane extends JTree {
if( files == null ) return; if( files == null ) return;
for( File file : files ) { for( File file : files ) {
DefaultMutableTreeNode childNode = new DefaultMutableTreeNode( new SclFileCheckBox( file ) ); DefaultMutableTreeNode childNode = new DefaultMutableTreeNode( new FileCheckBox( file ) );
node.add( childNode ); node.add( childNode );
if( file.isDirectory() ) { if( file.isDirectory() ) {
createChildren( file, childNode ); createChildren( file, childNode );
...@@ -88,7 +88,7 @@ public class TreeFilePane extends JTree { ...@@ -88,7 +88,7 @@ public class TreeFilePane extends JTree {
public Component getTreeCellRendererComponent( JTree tree, Object value, boolean selected, boolean expanded, public Component getTreeCellRendererComponent( JTree tree, Object value, boolean selected, boolean expanded,
boolean leaf, int row, boolean hasFocus ) { boolean leaf, int row, boolean hasFocus ) {
DefaultMutableTreeNode node = ( DefaultMutableTreeNode ) value; DefaultMutableTreeNode node = ( DefaultMutableTreeNode ) value;
SclFileCheckBox file = ( SclFileCheckBox ) node.getUserObject(); FileCheckBox file = ( FileCheckBox ) node.getUserObject();
JCheckBox checkbox = file.getCheckBox(); JCheckBox checkbox = file.getCheckBox();
checkbox.setEnabled( isEnabled() ); checkbox.setEnabled( isEnabled() );
checkbox.setFont( getFont() ); checkbox.setFont( getFont() );
...@@ -103,7 +103,7 @@ public class TreeFilePane extends JTree { ...@@ -103,7 +103,7 @@ public class TreeFilePane extends JTree {
} }
private void getSelectedFiles( DefaultMutableTreeNode node, ArrayList< File > oclFiles ) { private void getSelectedFiles( DefaultMutableTreeNode node, ArrayList< File > oclFiles ) {
SclFileCheckBox checkbox = ( SclFileCheckBox ) node.getUserObject(); FileCheckBox checkbox = ( FileCheckBox ) node.getUserObject();
if( checkbox.getFile().isFile() ) { if( checkbox.getFile().isFile() ) {
if( checkbox.getCheckBox().isSelected() ) { if( checkbox.getCheckBox().isSelected() ) {
oclFiles.add( checkbox.getFile() ); 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