Revision 43099 trunk/org.gvsig.desktop/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/Launcher.java

View differences:

Launcher.java
1846 1846
        return menuItems;
1847 1847
    }
1848 1848

  
1849
    private List<ToolBar> getOrderedToolBars() {
1850
        Map<String, ToolBar> toolbars = new HashMap<>();
1851

  
1852
        Iterator<String> pluginNames = pluginsConfig.keySet().iterator();
1853
        while (pluginNames.hasNext()) { 
1854
            String pluginName = pluginNames.next();
1855
            String extensionName = "unknow";
1856
            try {
1857
                PluginConfig pc = pluginsConfig.get(pluginName);
1858
                Extension[] extensions = pc.getExtensions().getExtension();
1859
                for (Extension extension : extensions) {
1860
                    extensionName = extension.getClassName();
1861
                    ToolBar[] extensionToolbars = extension.getToolBar();
1862
                    for (ToolBar toolbar : extensionToolbars) {
1863
                        ToolBar x = toolbars.get(toolbar.getName());
1864
                        if ( x!=null ) {
1865
                            if( !x.hasPosition() && toolbar.hasPosition() ) {
1866
                                toolbars.put(toolbar.getName(), toolbar);
1867
                            }
1868
                        } else { 
1869
                            toolbars.put(toolbar.getName(), toolbar);
1870
                        }
1871
                    }
1872
                }
1873
            } catch (Exception ex) {
1874
                addError("Can't process tool-bars of extension '"+extensionName+"'.", ex);
1875
            }
1876
        }
1877
        List<ToolBar> toolBarsList = new ArrayList<>(toolbars.values());
1878
        Collections.sort(toolBarsList, new Comparator<ToolBar>() {
1879

  
1880
            @Override
1881
            public int compare(ToolBar o1, ToolBar o2) {
1882
                return Integer.compare(o1.getPosition(), o2.getPosition());
1883
            }
1884
        });
1885
        return toolBarsList;        
1886
    }
1887
    
1849 1888
    /**
1850 1889
     * Installs the menus, toolbars, actiontools, selectable toolbars and
1851 1890
     * combos. The order in which they are shown is determined here.
......
1853 1892
    private void installPluginsControls() {
1854 1893
        logger.info("installPluginsControls (toolbars)");
1855 1894

  
1856
        Iterator<String> i = pluginsConfig.keySet().iterator();
1895
        Iterator<String> pluginNames = pluginsConfig.keySet().iterator();
1857 1896

  
1858 1897
        Map<Extension, PluginServices> extensionPluginServices = new HashMap<Extension, PluginServices>();
1859 1898
        Map<Extension, PluginConfig> extensionPluginConfig = new HashMap<Extension, PluginConfig>();
......
1864 1903
        // We need to iterate on the plugins, and iterate on each plugin's
1865 1904
        // extensions
1866 1905
        // (each plugin may contain one or more extensions)
1867
        while (i.hasNext()) { // iterate on the plugins
1868
            String pName = i.next();
1906
        while (pluginNames.hasNext()) { // iterate on the plugins
1907
            String pluginName = pluginNames.next();
1869 1908
            try {
1870
                PluginConfig pc = pluginsConfig.get(pName);
1871
                PluginServices ps = pluginsServices.get(pName);
1909
                PluginConfig pc = pluginsConfig.get(pluginName);
1910
                PluginServices ps = pluginsServices.get(pluginName);
1872 1911

  
1873 1912
                Extension[] exts = pc.getExtensions().getExtension();
1874 1913

  
......
1893 1932
                        }
1894 1933
                    } catch (Throwable e) {
1895 1934
                        addError("Error initializing controls of plugin '"
1896
                                + pName + "' extension '" + cname + "'", e);
1935
                                + pluginName + "' extension '" + cname + "'", e);
1897 1936
                    }
1898 1937
                }
1899 1938
            } catch (Throwable e) {
1900
                addError("Error initializing controls of plugin '" + pName
1939
                addError("Error initializing controls of plugin '" + pluginName
1901 1940
                        + "'", e);
1902 1941
            }
1903 1942
        }
1904 1943

  
1944
        
1945
        // A?ade primero las toolbars ordenadas para garantizar el orden de estas
1946
        for( ToolBar toolbar : getOrderedToolBars() ) {
1947
            frame.addToolBar(toolbar.getName(), toolbar.getDescription(), toolbar.getPosition());
1948
        }
1949

  
1905 1950
        TreeSet<SortableTool> orderedTools = new TreeSet<SortableTool>(
1906 1951
                new ToolComparator());
1907 1952
        Iterator<Extension> e = orderedExtensions.iterator();
......
2039 2084

  
2040 2085
		// Add the tools from MDI extensions to the ordered tool-list, so that
2041 2086
        // we get a sorted list containing all the tools
2042
        i = pluginsConfig.keySet().iterator();
2043
        while (i.hasNext()) {
2044
            String pName = (String) i.next();
2087
        pluginNames = pluginsConfig.keySet().iterator();
2088
        while (pluginNames.hasNext()) {
2089
            String pName = (String) pluginNames.next();
2045 2090
            try {
2046 2091
                PluginConfig pc = (PluginConfig) pluginsConfig.get(pName);
2047 2092
                PluginServices ps = (PluginServices) pluginsServices.get(pName);

Also available in: Unified diff