72 |
*/ |
*/ |
73 |
public |
public |
74 |
InstrumentsDbTreeModel(final ActionListener l) { |
InstrumentsDbTreeModel(final ActionListener l) { |
75 |
|
// TODO: This shouldn't be done in the event-dispatcing thread |
76 |
|
CC.getClient().addInstrumentsDbListener(getHandler()); |
77 |
|
/////// |
78 |
|
|
79 |
|
initDb(l); |
80 |
|
} |
81 |
|
|
82 |
|
private void |
83 |
|
initDb(final ActionListener l) { |
84 |
final InstrumentsDb.GetDrectory gdi = new InstrumentsDb.GetDrectory("/"); |
final InstrumentsDb.GetDrectory gdi = new InstrumentsDb.GetDrectory("/"); |
85 |
final InstrumentsDb.GetDrectories gd = new InstrumentsDb.GetDrectories("/"); |
final InstrumentsDb.GetDrectories gd = new InstrumentsDb.GetDrectories("/"); |
86 |
final InstrumentsDb.GetInstruments gi = new InstrumentsDb.GetInstruments("/"); |
final InstrumentsDb.GetInstruments gi = new InstrumentsDb.GetInstruments("/"); |
92 |
root = new DbDirectoryTreeNode(gdi.getResult()); |
root = new DbDirectoryTreeNode(gdi.getResult()); |
93 |
fireNodeStructureChanged(root); |
fireNodeStructureChanged(root); |
94 |
|
|
|
// TODO: This shouldn't be done in the event-dispatcing thread |
|
|
CC.getClient().addInstrumentsDbListener(getHandler()); |
|
|
/////// |
|
95 |
CC.getTaskQueue().add(gd); |
CC.getTaskQueue().add(gd); |
96 |
CC.getTaskQueue().add(gi); |
CC.getTaskQueue().add(gi); |
97 |
} |
} |
413 |
String[] dirs = getDirectoryList(path); |
String[] dirs = getDirectoryList(path); |
414 |
if(dirs == null) return null; |
if(dirs == null) return null; |
415 |
if(dirs.length == 1) return root; |
if(dirs.length == 1) return root; |
416 |
|
if(root == null) return null; |
417 |
DbDirectoryTreeNode node = root; |
DbDirectoryTreeNode node = root; |
418 |
boolean found = false; |
boolean found = false; |
419 |
for(int i = 1; i < dirs.length; i++) { |
for(int i = 1; i < dirs.length; i++) { |
493 |
directoryCountChanged(final InstrumentsDbEvent e) { |
directoryCountChanged(final InstrumentsDbEvent e) { |
494 |
SwingUtilities.invokeLater(new Runnable() { |
SwingUtilities.invokeLater(new Runnable() { |
495 |
public void |
public void |
496 |
run() { |
run() { updateDirectoryCount(e); } |
|
DbDirectoryTreeNode node = getNodeByPath(e.getPathName()); |
|
|
if(node == null) { |
|
|
return; |
|
|
} |
|
|
if(!node.isConnected()) { |
|
|
return; |
|
|
} |
|
|
|
|
|
updateDirectoryContent(node, e.getPathName()); |
|
|
} |
|
497 |
}); |
}); |
498 |
} |
} |
499 |
|
|
500 |
|
private void |
501 |
|
updateDirectoryCount(InstrumentsDbEvent e) { |
502 |
|
if(e.getPathName().equals("/") && root == null) { |
503 |
|
/* |
504 |
|
* If the directory tree failed to load due to a database |
505 |
|
* corruption it may work now if the db has been formatted |
506 |
|
*/ |
507 |
|
initDb(null); |
508 |
|
} |
509 |
|
|
510 |
|
DbDirectoryTreeNode node = getNodeByPath(e.getPathName()); |
511 |
|
if(node == null) return; |
512 |
|
if(!node.isConnected()) return; |
513 |
|
|
514 |
|
updateDirectoryContent(node, e.getPathName()); |
515 |
|
} |
516 |
|
|
517 |
/** |
/** |
518 |
* Invoked when the settings of an instrument directory are changed. |
* Invoked when the settings of an instrument directory are changed. |
519 |
*/ |
*/ |