You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.5 KiB
61 lines
1.5 KiB
package de.srsoftware.belegscanner.gui; |
|
|
|
import java.awt.Desktop; |
|
import java.awt.event.MouseAdapter; |
|
import java.awt.event.MouseEvent; |
|
import java.io.File; |
|
import java.io.IOException; |
|
|
|
import javax.swing.BoxLayout; |
|
import javax.swing.JLabel; |
|
import javax.swing.JPanel; |
|
import javax.swing.border.EmptyBorder; |
|
|
|
import de.srsoftware.belegscanner.Worker; |
|
import org.slf4j.Logger; |
|
import org.slf4j.LoggerFactory; |
|
|
|
import de.srsoftware.belegscanner.Application; |
|
|
|
/** |
|
* Simple status barwith updateable text. |
|
* This class may be extended to show more status information. |
|
* @author Stephan Richter <s.richter@srsoftware.de> |
|
* |
|
*/ |
|
public class StatusBar extends JPanel { |
|
|
|
private static final Logger LOG = LoggerFactory.getLogger(StatusBar.class); |
|
|
|
private static final long serialVersionUID = 8102800846089594705L; |
|
private JLabel path; |
|
|
|
public StatusBar(Worker worker) { |
|
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); |
|
add(path = new JLabel("Kein Pfad gewält.")); |
|
path.setBorder(new EmptyBorder(5,5,5,5)); |
|
path.setToolTipText(Application.t("Click here to open directory")); |
|
path.addMouseListener(new MouseAdapter() { |
|
@Override |
|
public void mouseClicked(MouseEvent e) { |
|
openDir(); |
|
} |
|
}); |
|
worker.setStatusBar(this); |
|
} |
|
|
|
protected void openDir() { |
|
try { |
|
File dir = new File(path.getText()); |
|
if (dir.exists()) Desktop.getDesktop().open(dir); |
|
} catch (IOException e) { |
|
e.printStackTrace(); |
|
} |
|
} |
|
|
|
public StatusBar setPath(String path) { |
|
LOG.debug("setPath({})",path); |
|
this.path.setText(path); |
|
return this; |
|
} |
|
}
|
|
|