Skip to content

Commit

Permalink
Added refresh button to file selection panels
Browse files Browse the repository at this point in the history
  • Loading branch information
maxxkia committed Feb 25, 2018
1 parent 2aff0e6 commit c1e762c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
target/
.idea/
atdl4j.iml
atdl4j-ui.iml
atdl4j.iws
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class SwingFixatdlFileSelectionPanel

JTextField filepathText;
JButton browseButton;
JButton refreshButton;
private String filepath = null;

public Object buildFixatdlFileSelectionPanel(Object parentOrShell, Atdl4jOptions atdl4jOptions)
{
Expand Down Expand Up @@ -101,15 +103,28 @@ public boolean accept(File f) {
int returnVal = fc.showOpenDialog(parentComposite);
if (returnVal == JFileChooser.APPROVE_OPTION){
File f = fc.getSelectedFile();
filepath = f.getPath();
filepathText.setText(f.getPath());
fireFixatdlFileSelectedEvent( f.getPath() );
}
}
});

refreshButton = new JButton("refresh");
refreshButton.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e) {
if (filepath != null) {
fireFixatdlFileSelectedEvent( filepath );
}
}
});

composite.add(refreshButton, BorderLayout.WEST);
composite.add(filepathText, BorderLayout.CENTER);
composite.add(browseButton, BorderLayout.EAST);

return composite;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public class SWTFixatdlFileSelectionPanel

Text filepathText;
Button browseButton;
Button refreshButton;
private String filepath = null;

public Object buildFixatdlFileSelectionPanel(Object parentOrShell, Atdl4jOptions atdl4jOptions)
{
Expand Down Expand Up @@ -74,7 +76,7 @@ public void widgetSelected(SelectionEvent e)
FileDialog dialog = new FileDialog(getShell(), SWT.OPEN);
dialog.setFilterExtensions( new String[] { "*.xml", "*.*" } );
dialog.setFilterNames( new String[] { "XML Files (*.xml)", "All Files (*.*)" } );
String filepath = dialog.open();
filepath = dialog.open();
if (filepath != null)
{
filepathText.setText(filepath);
Expand All @@ -83,7 +85,19 @@ public void widgetSelected(SelectionEvent e)
}
});


refreshButton = new Button(composite, SWT.NONE);
refreshButton.setText("refresh");
refreshButton.addSelectionListener(new SelectionAdapter()
{
@Override
public void widgetSelected(SelectionEvent e)
{
if (filepath != null) {
fireFixatdlFileSelectedEvent(filepath);
}
}
});

return composite;
}

Expand Down

0 comments on commit c1e762c

Please sign in to comment.