Ignore:
Timestamp:
2010-09-16T21:39:21+02:00 (14 years ago)
Author:
postfix
Message:

Konflikt solved

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/toms/src/toms/Toms.java

    r23193 r23227  
    44package toms;
    55
    6 import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
    7 import static org.openstreetmap.josm.tools.I18n.marktr;
    8 
    9 import java.awt.event.KeyEvent;
    10 import java.io.BufferedInputStream;
    11 import java.io.BufferedOutputStream;
    12 import java.io.File;
    13 import java.io.FileInputStream;
    14 import java.io.FileNotFoundException;
    15 import java.io.FileOutputStream;
    16 import java.io.IOException;
    17 import java.io.InputStream;
    18 import java.io.ObjectOutputStream;
    19 import java.lang.reflect.Method;
    20 import java.net.URL;
    21 import java.net.URLClassLoader;
    22 import java.util.ArrayList;
    23 import java.util.List;
    24 import java.util.Properties;
    25 import java.util.Set;
    26 import java.util.jar.JarEntry;
    27 import java.util.jar.JarFile;
    28 import java.util.jar.JarInputStream;
    29 import java.util.jar.JarOutputStream;
    30 import java.util.zip.ZipEntry;
    316
    327import javax.swing.JMenuItem;
    33 import javax.swing.SwingUtilities;
     8
    349
    3510import org.openstreetmap.josm.Main;
    36 import org.openstreetmap.josm.gui.MainMenu;
    37 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;
    38 import org.openstreetmap.josm.gui.layer.Layer;
    3911import org.openstreetmap.josm.plugins.Plugin;
    4012import org.openstreetmap.josm.plugins.PluginInformation;
     
    4214
    4315import toms.dialogs.SmpDialogAction;
    44 import toms.plug.PluginApp;
    45 import toms.plug.ifc.Pluggable;
    46 import toms.plug.util.PluginLoader;
    47 import toms.seamarks.SeaMark;
    4816
    4917// Kommentar zum Ausprobieren von svn
     
    5321public class Toms extends Plugin {
    5422
    55     private JMenuItem Smp;
    56     private SmpDialogAction SmpDialog;
     23        private JMenuItem Smp;
     24        private SmpDialogAction SmpDialog;
    5725
    58     public Toms(PluginInformation info) {
    59         super(info);
     26        public Toms(PluginInformation info) {
     27                super(info);
    6028
    61         String os = ""; //$NON-NLS-1$
    62         String userHome = ""; //$NON-NLS-1$
     29                String os = ""; //$NON-NLS-1$
     30                String userHome = ""; //$NON-NLS-1$
    6331
    64         SmpDialog = new SmpDialogAction();
    65         Smp = Main.main.menu.toolsMenu.add(SmpDialog);
    66         // Smp = MainMenu.add(Main.main.menu.toolsMenu, SmpDialog);
     32                SmpDialog = new SmpDialogAction();
     33                Smp = Main.main.menu.toolsMenu.add(SmpDialog);
     34                // Smp = MainMenu.add(Main.main.menu.toolsMenu, SmpDialog);
    6735
    68         SmpDialog.setSmpItem(Smp);
    69         SmpDialog.setOs(os);
    70         SmpDialog.setUserHome(userHome);
    71         Smp.setEnabled(false);
    72 
    73         File pluginDir = Main.pref.getPluginsDirectory();
    74         String pluginDirName = pluginDir.getAbsolutePath();
    75         File tplug = new File(pluginDirName + "/tplug");
    76         if(!tplug.exists()) tplug.mkdir();
    77        
    78         // build ifc.jar from toms.jar
    79         JarEntry ent = null;
    80         BufferedInputStream inp = null;
    81         String entName = null;
    82         byte[] buffer = new byte[16384];
    83         int len;
    84 
    85         try {
    86             JarFile file = new JarFile(pluginDirName  + "/toms.jar");           
    87             FileOutputStream fos = new FileOutputStream(pluginDirName + "/tplug/ifc.jar");         
    88             JarOutputStream jos = new JarOutputStream(fos);
    89             BufferedOutputStream oos = new BufferedOutputStream( jos);
    90 
    91             ent = file.getJarEntry("toms/plug/ifc/Pluggable.class");
    92             inp = new BufferedInputStream(file.getInputStream( ent ));
    93             entName = ent.getName();
    94 
    95             jos.putNextEntry(new JarEntry(entName));
    96            
    97             while ((len = inp.read(buffer)) > 0) {
    98                 oos.write(buffer, 0, len);
    99             }
    100 
    101             oos.flush();
    102             inp.close();
    103        
    104             ent = file.getJarEntry("toms/plug/ifc/PluginManager.class");
    105             inp = new BufferedInputStream(file.getInputStream( ent ));
    106             entName = ent.getName();
    107             jos.putNextEntry(new JarEntry(entName));
    108            
    109             while ((len = inp.read(buffer)) > 0) {
    110                 oos.write(buffer, 0, len);
    111             }
    112 
    113             oos.flush();
    114             oos.close();
    115             fos.flush();
    116             fos.close();
    117             inp.close();
    118            
    119         } catch (Exception e) {
    120             e.printStackTrace();
    121         }
    122        
    123        
    124         // add ifc.jar to classpath (josm need this archive, or perhaps only the interface)
    125         File f = new java.io.File(pluginDirName + "/tplug/ifc.jar");
    126         ClassLoader myClassLoader = Thread.currentThread().getContextClassLoader();
    127 
    128         try {
    129             Method addUrlMethod = URLClassLoader.class.getDeclaredMethod("addURL", new Class[]{URL.class});
    130             addUrlMethod.setAccessible(true);
    131             addUrlMethod.invoke(myClassLoader, f.toURI().toURL());
    132         } catch (Exception e) {
    133             e.printStackTrace();
    134         }
    135 
    136        
    137         try {
    138             PluginApp.runPlugins();
    139         } catch (Exception e) {
    140             e.printStackTrace();
    141         }
    142 
    143     }
     36                SmpDialog.setSmpItem(Smp);
     37                SmpDialog.setOs(os);
     38                SmpDialog.setUserHome(userHome);
     39                Smp.setEnabled(false);
     40        }
    14441
    14542
    146     @Override
    147     public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
    148         if (oldFrame == null && newFrame != null) {
    149             Smp.setEnabled(true);
    150         } else {
    151             Smp.setEnabled(false);
    152             SmpDialog.CloseDialog();
    153         }
    154     }
     43        @Override
     44        public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
     45                if (oldFrame == null && newFrame != null) {
     46                        Smp.setEnabled(true);
     47                } else {
     48                        Smp.setEnabled(false);
     49                        SmpDialog.CloseDialog();
     50                }
     51        }
    15552
    15653}
Note: See TracChangeset for help on using the changeset viewer.