Skip to content

Commit

Permalink
add buttons for important but difficult to find directories
Browse files Browse the repository at this point in the history
  • Loading branch information
prof7bit committed May 22, 2014
1 parent 2abf48e commit b82b94a
Showing 1 changed file with 32 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class WalletPanel extends JPanel{
addChoosableFileFilter(new FileNameExtensionFilter("Bitcoin-core 'dumpwallet' file (*.txt)", "txt"))
addChoosableFileFilter(new FileNameExtensionFilter("Bitcoin-core wallet.dat (*.dat)", "dat"))
setFileFilter(new FileNameExtensionFilter("Multibit wallet (*.wallet)", "wallet"))
preferredSize = new Dimension(600, 500)
preferredSize = new Dimension(800, 500)
accessory = createAccessoryPanel(it)
]

Expand All @@ -187,11 +187,10 @@ class WalletPanel extends JPanel{
addChoosableFileFilter(new FileNameExtensionFilter("Multibit key export file (*.key)", "key"))
addChoosableFileFilter(new FileNameExtensionFilter("Bitcoin-core 'dumpwallet' file (*.txt)", "txt"))
setFileFilter(new FileNameExtensionFilter("Multibit wallet (*.wallet)", "wallet"))
preferredSize = new Dimension(600, 500)
preferredSize = new Dimension(800, 500)
accessory = createAccessoryPanel(it)
]


val status_label = new JLabel("ready")
val progress_bar = new JProgressBar => [
minimum = 0
Expand All @@ -206,16 +205,44 @@ class WalletPanel extends JPanel{

def createAccessoryPanel(JFileChooser c){
return new JPanel => [panel|
panel.layout = new MigLayout("fillx")
new JCheckBox("show hidden files") => [
panel.add(it)
panel.add(it, "pushx, growx, wrap")
selected = false
addActionListener [evt|
c.fileHidingEnabled = !selected
]
]
addDirButton(panel, c, "home", System.getProperty("user.home"))
addDirButton(panel, c, "APPDATA", System.getenv("APPDATA"))
addDirButton(panel, c, "~/Library/Application Support",
System.getProperty("user.home") + "/Library/Application Support"
)
]
}

def addDirButton(JPanel panel, JFileChooser c, String label, String path){
val f = getFileOrNull(path)
if (f != null){
new JButton(label) => [
panel.add(it, "pushx, growx, wrap")
addActionListener [
c.currentDirectory = f
]
]
}
}

def getFileOrNull(String path){
if (path != null){
val f = new File(path)
if (f.exists){
return f
}
}
return null
}

new(Frame parentFrame) {
super()
this.parentFrame = parentFrame
Expand Down Expand Up @@ -409,5 +436,6 @@ class WalletPanel extends JPanel{
return ret.get(0)
}
}

}

0 comments on commit b82b94a

Please sign in to comment.