48 |
import org.linuxsampler.lscp.event.InstrumentsDbEvent; |
import org.linuxsampler.lscp.event.InstrumentsDbEvent; |
49 |
import org.linuxsampler.lscp.event.InstrumentsDbListener; |
import org.linuxsampler.lscp.event.InstrumentsDbListener; |
50 |
|
|
51 |
|
import static org.linuxsampler.lscp.Parser.*; |
52 |
|
|
53 |
|
|
54 |
/** |
/** |
55 |
* |
* |
56 |
* @author Grigor Iliev |
* @author Grigor Iliev |
101 |
for(int i = 0; i < root.getChildCount(); i++) { |
for(int i = 0; i < root.getChildCount(); i++) { |
102 |
DbDirectoryTreeNode node = root.getChildAt(i); |
DbDirectoryTreeNode node = root.getChildAt(i); |
103 |
node.setConnected(true); |
node.setConnected(true); |
104 |
updateDirectoryContent(node, "/" + node.toString()); |
updateDirectoryContent(node, "/" + toEscapedFileName(node)); |
105 |
} |
} |
106 |
|
|
107 |
if(l != null) l.actionPerformed(null); |
if(l != null) l.actionPerformed(null); |
134 |
child.setConnected(true); |
child.setConnected(true); |
135 |
String pathName = getPathName(path.getPath()); |
String pathName = getPathName(path.getPath()); |
136 |
if(pathName.length() > 1) pathName += "/"; |
if(pathName.length() > 1) pathName += "/"; |
137 |
updateDirectoryContent(child, pathName + child.toString()); |
updateDirectoryContent(child, pathName + toEscapedFileName(child)); |
138 |
} |
} |
139 |
} |
} |
140 |
|
|
353 |
|
|
354 |
StringBuffer sb = new StringBuffer(); |
StringBuffer sb = new StringBuffer(); |
355 |
for(int i = 1; i < objs.length; i++) { |
for(int i = 1; i < objs.length; i++) { |
356 |
sb.append('/').append(objs[i].toString()); |
sb.append('/').append(toEscapedFileName(objs[i])); |
357 |
} |
} |
358 |
|
|
359 |
return sb.toString(); |
return sb.toString(); |
404 |
|
|
405 |
public DbDirectoryTreeNode |
public DbDirectoryTreeNode |
406 |
getNodeByPath(String path) { |
getNodeByPath(String path) { |
407 |
String[] dirs = getDirectoryPath(path); |
String[] dirs = getDirectoryList(path); |
408 |
if(dirs == null) return null; |
if(dirs == null) return null; |
409 |
if(dirs.length == 1) return root; |
if(dirs.length == 1) return root; |
410 |
|
|
412 |
boolean found = false; |
boolean found = false; |
413 |
for(int i = 1; i < dirs.length; i++) { |
for(int i = 1; i < dirs.length; i++) { |
414 |
for(int k = 0; k < node.getChildCount(); k++) { |
for(int k = 0; k < node.getChildCount(); k++) { |
415 |
if(dirs[i].equals(node.getChildAt(k).toString())) { |
String s = toNonEscapedFileName(dirs[i]); |
416 |
|
if(s.equals(node.getChildAt(k).toString())) { |
417 |
node = node.getChildAt(k); |
node = node.getChildAt(k); |
418 |
found = true; |
found = true; |
419 |
break; |
break; |
433 |
return getPathName(getPathToRoot(node)); |
return getPathName(getPathToRoot(node)); |
434 |
} |
} |
435 |
|
|
|
private String[] |
|
|
getDirectoryPath(String path) { |
|
|
if(path == null || path.length() == 0) return null; |
|
|
if(path.charAt(0) != '/') return null; |
|
|
Vector<String> v = new Vector<String>(); |
|
|
v.add("/"); |
|
|
if(path.length() == 1) return v.toArray(new String[v.size()]); |
|
|
|
|
|
if(path.charAt(path.length() - 1) != '/') path += "/"; |
|
|
int i = 1; |
|
|
int j = path.indexOf('/', i); |
|
|
|
|
|
while(j != -1) { |
|
|
v.add(path.substring(i, j)); |
|
|
|
|
|
i = j + 1; |
|
|
if(i >= path.length()) return v.toArray(new String[v.size()]); |
|
|
j = path.indexOf('/', i); |
|
|
} |
|
|
|
|
|
return null; |
|
|
} |
|
|
|
|
|
public static String |
|
|
getParentDirectory(String path) { |
|
|
if(path == null || path.length() == 0) return null; |
|
|
if(path.charAt(0) != '/') return null; |
|
|
if(path.length() == 1) return null; |
|
|
|
|
|
if(path.charAt(path.length() - 1) == '/') { |
|
|
path = path.substring(0, path.length() - 1); |
|
|
} |
|
|
|
|
|
int i = path.lastIndexOf('/'); |
|
|
if(i == 0) return "/"; |
|
|
return path.substring(0, i); |
|
|
} |
|
|
|
|
436 |
/** |
/** |
437 |
* @param l A listener which will be notified when the operation is completed. |
* @param l A listener which will be notified when the operation is completed. |
438 |
*/ |
*/ |
439 |
public void |
public void |
440 |
loadPath(String path, final ActionListener l) { |
loadPath(String path, final ActionListener l) { |
441 |
// TODO: This method is lazily implemented. Should be optimized. |
// TODO: This method is lazily implemented. Should be optimized. |
442 |
final String[] dirs = getDirectoryPath(path); |
final String[] dirs = getDirectoryList(path); |
443 |
if(dirs == null) { |
if(dirs == null) { |
444 |
l.actionPerformed(null); |
l.actionPerformed(null); |
445 |
return; |
return; |
552 |
// If the directory is renamed by this frontend the |
// If the directory is renamed by this frontend the |
553 |
// directory should already be with the new name |
// directory should already be with the new name |
554 |
String s = getParentDirectory(e.getPathName()); |
String s = getParentDirectory(e.getPathName()); |
555 |
if(s.length() == 1) s += e.getNewName(); |
if(s.length() == 1) s += toEscapedFileName(e.getNewName()); |
556 |
else s += "/" + e.getNewName(); |
else s += "/" + toEscapedFileName(e.getNewName()); |
557 |
node = getNodeByPath(s); |
node = getNodeByPath(s); |
558 |
} |
} |
559 |
if(node == null || node.getParent() == null) { |
if(node == null || node.getParent() == null) { |
643 |
DbDirectoryTreeNode node = getNodeByPath(dir); |
DbDirectoryTreeNode node = getNodeByPath(dir); |
644 |
if(node == null) return; |
if(node == null) return; |
645 |
|
|
646 |
String instr = e.getPathName(); |
String instr = getFileName(e.getPathName()); |
647 |
int i = instr.lastIndexOf('/'); |
if(instr == null) return; |
|
if(i != -1 && i < instr.length() - 1) instr = instr.substring(i + 1); |
|
|
else return; |
|
648 |
|
|
649 |
DbInstrumentInfo info = node.getInstrument(instr); |
DbInstrumentInfo info = node.getInstrument(instr); |
650 |
|
|