|
47 | 47 | import java.io.File;
|
48 | 48 | import java.io.IOException;
|
49 | 49 | import java.util.ArrayList;
|
50 |
| -import java.util.Collections; |
| 50 | +import java.util.Arrays; |
51 | 51 | import java.util.List;
|
52 | 52 | import java.util.TimerTask;
|
53 | 53 |
|
@@ -589,30 +589,42 @@ private void loadModeSettings() {
|
589 | 589 | private List<AndroidTool> loadAndroidTools() {
|
590 | 590 | // This gets called before assigning mode to androidMode...
|
591 | 591 | ArrayList<AndroidTool> outgoing = new ArrayList<AndroidTool>();
|
592 |
| - File toolPath = new File(androidMode.getFolder(), "tools/SDKUpdater"); |
593 |
| - AndroidTool tool = null; |
594 | 592 |
|
595 |
| -// List<Mode> modes = base.getModeList(); |
596 |
| -// Mode defMode = modes.get(0); |
597 |
| - |
598 |
| - try { |
599 |
| - |
600 |
| - tool = new AndroidTool(toolPath, androidMode); |
601 |
| - tool.init(base); |
602 |
| - outgoing.add(tool); |
603 |
| - } catch (Throwable e) { |
604 |
| - e.printStackTrace(); |
605 |
| - } |
606 |
| - Collections.sort(outgoing); |
| 593 | + File folder = new File(androidMode.getFolder(), "tools"); |
| 594 | + String[] list = folder.list(); |
| 595 | + if (list == null) { |
| 596 | + return outgoing; |
| 597 | + } |
| 598 | + |
| 599 | + Arrays.sort(list, String.CASE_INSENSITIVE_ORDER); |
| 600 | + for (String name : list) { |
| 601 | + if (name.charAt(0) == '.') { |
| 602 | + continue; |
| 603 | + } |
| 604 | + |
| 605 | + File toolPath = new File(folder, name); |
| 606 | + if (toolPath.isDirectory()) { |
| 607 | + File jarPath = new File(toolPath, "tool" + File.separator + name + ".jar"); |
| 608 | + if (jarPath.exists()) { |
| 609 | + try { |
| 610 | + AndroidTool tool = new AndroidTool(toolPath, androidMode); |
| 611 | + tool.init(base); |
| 612 | + outgoing.add(tool); |
| 613 | + } catch (Throwable e) { |
| 614 | + e.printStackTrace(); |
| 615 | + } |
| 616 | + } |
| 617 | + } |
| 618 | + } |
| 619 | + |
607 | 620 | return outgoing;
|
608 | 621 | }
|
609 | 622 |
|
610 | 623 | private void addToolsToMenu() {
|
611 | 624 | JMenuItem item;
|
612 | 625 |
|
613 | 626 | for (final Tool tool : androidTools) {
|
614 |
| -// item = new JMenuItem(AndroidMode.getTextString(tool.getMenuTitle())); |
615 |
| - item = new JMenuItem(tool.getMenuTitle()); |
| 627 | + item = new JMenuItem(AndroidMode.getTextString(tool.getMenuTitle())); |
616 | 628 | item.addActionListener(new ActionListener() {
|
617 | 629 | public void actionPerformed(ActionEvent e) {
|
618 | 630 | tool.run();
|
|
0 commit comments