Ignore:
Timestamp:
2010-09-19T11:55:14+02:00 (15 years ago)
Author:
stoecker
Message:

remove tabs - please follow josm formatting styles when developing for josm

Location:
applications/editors/josm/plugins/smed/src/smed
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/smed/src/smed/Smed.java

    r23244 r23261  
    4242        String pluginDirName = pluginDir.getAbsolutePath();
    4343        SmedFile splugDir = new SmedFile(pluginDirName + "/splug");
    44        
     44
    4545        if(!splugDir.exists()) splugDir.mkdir();
    4646
    4747        File[] jars = splugDir.listFiles(new JARFileFilter());
    48        
     48
    4949        // build smed_ifc.jar from smed.jar
    5050        JarEntry e = null;
     
    5959            JarOutputStream jos = new JarOutputStream(fos);
    6060            BufferedOutputStream oos = new BufferedOutputStream( jos);
    61            
     61
    6262            // extract *.jar to splug
    6363            Enumeration<JarEntry> ent = file.entries();
    6464            while(ent.hasMoreElements()) {
    65                 e = ent.nextElement();
    66                 eName = e.getName(); 
    67                 if(eName.endsWith(".jar")) {
    68                         if(splugDir.needUpdate(jars,eName)) {
    69                                 FileOutputStream pfos = new FileOutputStream(pluginDirName + "/splug/" + eName);
    70                                 BufferedOutputStream pos = new BufferedOutputStream(pfos);
    71                                 inp = new BufferedInputStream(file.getInputStream( e ));
    72                        
    73                                 while ((len = inp.read(buffer)) > 0) {
    74                                         pos.write(buffer, 0, len);
    75                                 }
    76                        
    77                                 pos.flush();
    78                                 pos.close();
    79                                 inp.close();
    80                                 pfos.close();
    81                         }
    82                 }
     65                e = ent.nextElement();
     66                eName = e.getName();
     67                if(eName.endsWith(".jar")) {
     68                    if(splugDir.needUpdate(jars,eName)) {
     69                        FileOutputStream pfos = new FileOutputStream(pluginDirName + "/splug/" + eName);
     70                        BufferedOutputStream pos = new BufferedOutputStream(pfos);
     71                        inp = new BufferedInputStream(file.getInputStream( e ));
     72
     73                        while ((len = inp.read(buffer)) > 0) {
     74                            pos.write(buffer, 0, len);
     75                        }
     76
     77                        pos.flush();
     78                        pos.close();
     79                        inp.close();
     80                        pfos.close();
     81                    }
     82                }
    8383            }
    84            
    8584
    86            
     85
     86
    8787            // write smed_ifc.jar to splug
    8888            e = file.getJarEntry("smed/plug/ifc/SmedPluggable.class");
  • applications/editors/josm/plugins/smed/src/smed/SmedFile.java

    r23244 r23261  
    77public class SmedFile extends File{
    88
    9         /**
    10         *
    11         */
    12         private static final long serialVersionUID = 1L;
     9    /**
     10    *
     11    */
     12    private static final long serialVersionUID = 1L;
    1313
    14         public SmedFile(String pathname) {
    15                 super(pathname);
    16         }
     14    public SmedFile(String pathname) {
     15        super(pathname);
     16    }
    1717
    18         public boolean needUpdate(File[] jars, String name) {
    19                
    20                 for(File j : jars) {
    21                         String jName = j.getName();
    22                        
    23                         if(jName.length() > 15) { // < 16 isn'nt a SmedFile
     18    public boolean needUpdate(File[] jars, String name) {
     19       
     20        for(File j : jars) {
     21            String jName = j.getName();
     22           
     23            if(jName.length() > 15) { // < 16 isn'nt a SmedFile
    2424
    25                                 if (jName.substring(16).equals(name.substring(16))) {
    26                                         if(jName.substring(0, 15).compareTo(name.substring(0, 15)) < 0) { // obsolet
    27                                                 j.delete();
    28                                                 return true;                   
    29                                         } else return false;    // no update needed
    30                                 }
    31                         }
    32                 }
     25                if (jName.substring(16).equals(name.substring(16))) {
     26                    if(jName.substring(0, 15).compareTo(name.substring(0, 15)) < 0) { // obsolet
     27                        j.delete();
     28                        return true;           
     29                    } else return false;    // no update needed
     30                }
     31            }
     32        }
    3333
    34                 // nothing found -> extract
    35                 return true;
    36         }
     34        // nothing found -> extract
     35        return true;
     36    }
    3737}
  • applications/editors/josm/plugins/smed/src/smed/menu/SmedMenuBar.java

    r23259 r23261  
    99public class SmedMenuBar extends JMenuBar {
    1010
    11         /**
    12          *
    13         */
    14         private static final long serialVersionUID = 1L;
    15        
    16         JMenuBar menuBar;
    17         JMenu menu, submenu;
    18         JMenuItem menuItem;
    19        
    20         public SmedMenuBar() {
    21                 menuBar = new JMenuBar();
    22                
     11    /**
     12     *
     13    */
     14    private static final long serialVersionUID = 1L;
     15
     16    JMenuBar menuBar;
     17    JMenu menu, submenu;
     18    JMenuItem menuItem;
     19
     20    public SmedMenuBar() {
     21        menuBar = new JMenuBar();
     22
    2323        menu = new JMenu("File");
    2424        menu.setMnemonic(KeyEvent.VK_F);
    2525        menu.getAccessibleContext().setAccessibleDescription(
    2626                "The only menu in this program that has menu items");
    27        
     27
    2828        menuItem = new JMenuItem("Hide",
    2929                KeyEvent.VK_H);
    30        
     30
    3131        menuItem.addActionListener(new java.awt.event.ActionListener() {
    32                         public void actionPerformed(java.awt.event.ActionEvent e) {
    33                                 System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
    34                         }
    35                 });
     32            public void actionPerformed(java.awt.event.ActionEvent e) {
     33                System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
     34            }
     35        });
    3636
    37        
     37
    3838        menu.add(menuItem);
    3939
    4040        menuBar.add(menu);
    41                
    42                 add(menuBar);
    43         }
     41
     42        add(menuBar);
     43    }
    4444
    4545}
  • applications/editors/josm/plugins/smed/src/smed/plug/ifc/SmedPluggable.java

    r23244 r23261  
    66public interface SmedPluggable {
    77
    8         boolean start();
    9         boolean stop();
    10         String getName();
    11         String getInfo();
    12         JComponent getComponent();
    13        
    14         void setPluginManager(SmedPluginManager manager);
     8    boolean start();
     9    boolean stop();
     10    String getName();
     11    String getInfo();
     12    JComponent getComponent();
     13   
     14    void setPluginManager(SmedPluginManager manager);
    1515
    1616}
  • applications/editors/josm/plugins/smed/src/smed/plug/util/SmedPluginLoader.java

    r23236 r23261  
    2121
    2222
    23         public static List<SmedPluggable> loadPlugins(File plugDir) throws IOException {
    24                 File[] plugJars = plugDir.listFiles(new JARFileFilter());
    25                 Arrays.sort(plugJars);
    26                
    27                 URL[] urls = fileArrayToURLArray(plugJars);
    28                 if(urls == null) return null;
    29                
    30                 ClassLoader cl = new URLClassLoader(urls);
    31                 List<Class<SmedPluggable>> plugClasses = extractClassesFromJARs(plugJars, cl);
    32                
    33                 if(plugClasses == null) return null;
    34                 else return createPluggableObjects(plugClasses);
    35         }
     23    public static List<SmedPluggable> loadPlugins(File plugDir) throws IOException {
     24        File[] plugJars = plugDir.listFiles(new JARFileFilter());
     25        Arrays.sort(plugJars);
     26       
     27        URL[] urls = fileArrayToURLArray(plugJars);
     28        if(urls == null) return null;
     29       
     30        ClassLoader cl = new URLClassLoader(urls);
     31        List<Class<SmedPluggable>> plugClasses = extractClassesFromJARs(plugJars, cl);
     32       
     33        if(plugClasses == null) return null;
     34        else return createPluggableObjects(plugClasses);
     35    }
    3636
    3737    private static List<SmedPluggable> createPluggableObjects(List<Class<SmedPluggable>> pluggables) {
  • applications/editors/josm/plugins/smed/src/smed/tabs/SmedTabbedPane.java

    r23236 r23261  
    2424    private static final long serialVersionUID = 1L;
    2525
    26         public SmedTabbedPane() {
    27                 super(new GridLayout(1, 1));
    28                
    29                 List<SmedPluggable> plugins = null;
    30                 String pluginDirName = Main.pref.getPluginsDirectory().getAbsolutePath();
    31                 try {
    32                         plugins = SmedPluginLoader.loadPlugins(new File(pluginDirName + "/splug"));
    33                 } catch (IOException e) {
    34                         e.printStackTrace();
    35                 }
    36                
    37                 if(plugins != null) {
    38                         Icon icon = null;
    39                         JTabbedPane tabbedPane = new JTabbedPane();
     26    public SmedTabbedPane() {
     27        super(new GridLayout(1, 1));
    4028
    41                         JComponent panel;
    42                         int i = 0;
    43                         for(SmedPluggable p : plugins) {
    44                                 panel = p.getComponent();
    45                                 tabbedPane.addTab(p.getName(),icon, panel, p.getInfo());
    46                                 tabbedPane.setMnemonicAt(i, KeyEvent.VK_1 + i);
    47                        
    48                                 i++;
    49                         }
     29        List<SmedPluggable> plugins = null;
     30        String pluginDirName = Main.pref.getPluginsDirectory().getAbsolutePath();
     31        try {
     32            plugins = SmedPluginLoader.loadPlugins(new File(pluginDirName + "/splug"));
     33        } catch (IOException e) {
     34            e.printStackTrace();
     35        }
    5036
    51                         //Add the tabbed pane to this panel.
    52                         add(tabbedPane);
     37        if(plugins != null) {
     38            Icon icon = null;
     39            JTabbedPane tabbedPane = new JTabbedPane();
    5340
    54                         //The following line enables to use scrolling tabs.
    55                         tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
    56                 }
     41            JComponent panel;
     42            int i = 0;
     43            for(SmedPluggable p : plugins) {
     44                panel = p.getComponent();
     45                tabbedPane.addTab(p.getName(),icon, panel, p.getInfo());
     46                tabbedPane.setMnemonicAt(i, KeyEvent.VK_1 + i);
     47
     48                i++;
     49            }
     50
     51            //Add the tabbed pane to this panel.
     52            add(tabbedPane);
     53
     54            //The following line enables to use scrolling tabs.
     55            tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
     56        }
    5757    }
    5858}
Note: See TracChangeset for help on using the changeset viewer.