Index: /applications/editors/josm/plugins/seachartedit/.checkstyle
===================================================================
--- /applications/editors/josm/plugins/seachartedit/.checkstyle	(revision 33030)
+++ /applications/editors/josm/plugins/seachartedit/.checkstyle	(revision 33030)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false">
+  <local-check-config name="JOSM" location="/JOSM/tools/checkstyle/josm_checks.xml" type="project" description="">
+    <additional-data name="protect-config-file" value="false"/>
+  </local-check-config>
+  <fileset name="all" enabled="true" check-config-name="JOSM" local="true">
+    <file-match-pattern match-pattern="." include-pattern="true"/>
+  </fileset>
+  <filter name="DerivedFiles" enabled="true"/>
+  <filter name="FilesFromPackage" enabled="true">
+    <filter-data value=".svn"/>
+    <filter-data value="data"/>
+    <filter-data value="images"/>
+    <filter-data value="resources"/>
+    <filter-data value="styles"/>
+    <filter-data value="scripts"/>
+  </filter>
+</fileset-config>
Index: /applications/editors/josm/plugins/seachartedit/.project
===================================================================
--- /applications/editors/josm/plugins/seachartedit/.project	(revision 33029)
+++ /applications/editors/josm/plugins/seachartedit/.project	(revision 33030)
@@ -16,7 +16,13 @@
 			</arguments>
 		</buildCommand>
+		<buildCommand>
+			<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
 	</buildSpec>
 	<natures>
 		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
 	</natures>
 </projectDescription>
Index: /applications/editors/josm/plugins/seachartedit/.settings/org.eclipse.jdt.ui.prefs
===================================================================
--- /applications/editors/josm/plugins/seachartedit/.settings/org.eclipse.jdt.ui.prefs	(revision 33030)
+++ /applications/editors/josm/plugins/seachartedit/.settings/org.eclipse.jdt.ui.prefs	(revision 33030)
@@ -0,0 +1,59 @@
+eclipse.preferences.version=1
+editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
+sp_cleanup.add_default_serial_version_id=true
+sp_cleanup.add_generated_serial_version_id=false
+sp_cleanup.add_missing_annotations=true
+sp_cleanup.add_missing_deprecated_annotations=true
+sp_cleanup.add_missing_methods=false
+sp_cleanup.add_missing_nls_tags=false
+sp_cleanup.add_missing_override_annotations=true
+sp_cleanup.add_missing_override_annotations_interface_methods=true
+sp_cleanup.add_serial_version_id=false
+sp_cleanup.always_use_blocks=true
+sp_cleanup.always_use_parentheses_in_expressions=false
+sp_cleanup.always_use_this_for_non_static_field_access=false
+sp_cleanup.always_use_this_for_non_static_method_access=false
+sp_cleanup.convert_functional_interfaces=false
+sp_cleanup.convert_to_enhanced_for_loop=false
+sp_cleanup.correct_indentation=false
+sp_cleanup.format_source_code=false
+sp_cleanup.format_source_code_changes_only=false
+sp_cleanup.insert_inferred_type_arguments=false
+sp_cleanup.make_local_variable_final=true
+sp_cleanup.make_parameters_final=false
+sp_cleanup.make_private_fields_final=true
+sp_cleanup.make_type_abstract_if_missing_method=false
+sp_cleanup.make_variable_declarations_final=false
+sp_cleanup.never_use_blocks=false
+sp_cleanup.never_use_parentheses_in_expressions=true
+sp_cleanup.on_save_use_additional_actions=true
+sp_cleanup.organize_imports=true
+sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
+sp_cleanup.remove_private_constructors=true
+sp_cleanup.remove_redundant_type_arguments=true
+sp_cleanup.remove_trailing_whitespaces=true
+sp_cleanup.remove_trailing_whitespaces_all=true
+sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
+sp_cleanup.remove_unnecessary_casts=true
+sp_cleanup.remove_unnecessary_nls_tags=false
+sp_cleanup.remove_unused_imports=true
+sp_cleanup.remove_unused_local_variables=false
+sp_cleanup.remove_unused_private_fields=true
+sp_cleanup.remove_unused_private_members=false
+sp_cleanup.remove_unused_private_methods=true
+sp_cleanup.remove_unused_private_types=true
+sp_cleanup.sort_members=false
+sp_cleanup.sort_members_all=false
+sp_cleanup.use_anonymous_class_creation=false
+sp_cleanup.use_blocks=false
+sp_cleanup.use_blocks_only_for_return_and_throw=false
+sp_cleanup.use_lambda=true
+sp_cleanup.use_parentheses_in_expressions=false
+sp_cleanup.use_this_for_non_static_field_access=false
+sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+sp_cleanup.use_this_for_non_static_method_access=false
+sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
Index: /applications/editors/josm/plugins/seachartedit/src/messages/Messages.java
===================================================================
--- /applications/editors/josm/plugins/seachartedit/src/messages/Messages.java	(revision 33029)
+++ /applications/editors/josm/plugins/seachartedit/src/messages/Messages.java	(revision 33030)
@@ -13,18 +13,18 @@
 import java.util.ResourceBundle;
 
-public class Messages {
-	private static final String BUNDLE_NAME = "resources/msg.messages";
+public final class Messages {
+    private static final String BUNDLE_NAME = "resources/msg.messages";
 
-	private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
+    private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
 
-	private Messages() {
-	}
+    private Messages() {
+    }
 
-	public static String getString(String key) {
-		try {
-			return RESOURCE_BUNDLE.getString(key);
-		} catch (MissingResourceException e) {
-			return '!' + key + '!';
-		}
-	}
+    public static String getString(String key) {
+        try {
+            return RESOURCE_BUNDLE.getString(key);
+        } catch (MissingResourceException e) {
+            return '!' + key + '!';
+        }
+    }
 }
Index: /applications/editors/josm/plugins/seachartedit/src/panels/PanelMain.java
===================================================================
--- /applications/editors/josm/plugins/seachartedit/src/panels/PanelMain.java	(revision 33029)
+++ /applications/editors/josm/plugins/seachartedit/src/panels/PanelMain.java	(revision 33030)
@@ -18,94 +18,102 @@
 import java.awt.event.ActionListener;
 import java.awt.image.BufferedImage;
-import java.io.*;
+import java.io.IOException;
 import java.util.ArrayList;
 
-import javax.swing.*;
+import javax.swing.ImageIcon;
+import javax.swing.JButton;
+import javax.swing.JFileChooser;
+import javax.swing.JPanel;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+
+import org.openstreetmap.josm.Main;
 
 import messages.Messages;
-
-import org.openstreetmap.josm.Main;
-
+import s57.S57att.Att;
+import s57.S57map.AttMap;
+import s57.S57map.Feature;
+import s57.S57obj.Obj;
 import s57.S57val.AttVal;
-import s57.S57att.*;
-import s57.S57obj.*;
-import s57.S57map.*;
 import scedit.SCeditAction;
 
 public class PanelMain extends JPanel {
 
-	BufferedImage img;
-	int w, h, z, f;
-	JTextField wt, ht, zt, ft;
-	public static JTextArea decode = null;
-	public static JTextField messageBar = null;
-	public JButton saveButton = null;
-	private ActionListener alSave = new ActionListener() {
-		public void actionPerformed(java.awt.event.ActionEvent e) {
-		}
-	};
-	private JButton importButton = null;
-	JFileChooser ifc = new JFileChooser(Main.pref.get("nceditplugin.encinpfile"));
-	private ActionListener alImport = new ActionListener() {
-		public void actionPerformed(java.awt.event.ActionEvent e) {
-			if (e.getSource() == importButton) {
-				SCeditAction.panelS57.setVisible(true);
+    BufferedImage img;
+    int w, h, z, f;
+    JTextField wt, ht, zt, ft;
+    public static JTextArea decode = null;
+    public static JTextField messageBar = null;
+    public JButton saveButton = null;
+    private ActionListener alSave = new ActionListener() {
+        @Override
+        public void actionPerformed(java.awt.event.ActionEvent e) {
+        }
+    };
+    private JButton importButton = null;
+    JFileChooser ifc = new JFileChooser(Main.pref.get("nceditplugin.encinpfile"));
+    private ActionListener alImport = new ActionListener() {
+        @Override
+        public void actionPerformed(java.awt.event.ActionEvent e) {
+            if (e.getSource() == importButton) {
+                SCeditAction.panelS57.setVisible(true);
         setStatus("Select S-57 ENC file for import", Color.yellow);
-				int returnVal = ifc.showOpenDialog(Main.parent);
-				if (returnVal == JFileChooser.APPROVE_OPTION) {
-					try {
-						Main.pref.put("smed2plugin.encinpfile", ifc.getSelectedFile().getPath());
-						SCeditAction.panelS57.startImport(ifc.getSelectedFile());
-					} catch (IOException e1) {
-						SCeditAction.panelS57.setVisible(false);
-						setStatus("IO Exception", Color.red);
-					}
-				} else {
-					SCeditAction.panelS57.setVisible(false);
-					clrStatus();
-				}
-			}
-		}
-	};
-
-	private JButton exportButton = null;
-	final JFileChooser efc = new JFileChooser();
-	private ActionListener alExport = new ActionListener() {
-		public void actionPerformed(java.awt.event.ActionEvent e) {
-			if (e.getSource() == exportButton) {
-				SCeditAction.panelS57.setVisible(true);
+                int returnVal = ifc.showOpenDialog(Main.parent);
+                if (returnVal == JFileChooser.APPROVE_OPTION) {
+                    try {
+                        Main.pref.put("smed2plugin.encinpfile", ifc.getSelectedFile().getPath());
+                        SCeditAction.panelS57.startImport(ifc.getSelectedFile());
+                    } catch (IOException e1) {
+                        SCeditAction.panelS57.setVisible(false);
+                        setStatus("IO Exception", Color.red);
+                    }
+                } else {
+                    SCeditAction.panelS57.setVisible(false);
+                    clrStatus();
+                }
+            }
+        }
+    };
+
+    private JButton exportButton = null;
+    final JFileChooser efc = new JFileChooser();
+    private ActionListener alExport = new ActionListener() {
+        @Override
+        public void actionPerformed(java.awt.event.ActionEvent e) {
+            if (e.getSource() == exportButton) {
+                SCeditAction.panelS57.setVisible(true);
         setStatus("Select S-57 ENC file for export", Color.yellow);
         int returnVal = efc.showOpenDialog(Main.parent);
         if (returnVal == JFileChooser.APPROVE_OPTION) {
-        	try {
-						SCeditAction.panelS57.startExport(efc.getSelectedFile());
-					} catch (IOException e1) {
-						SCeditAction.panelS57.setVisible(false);
-						setStatus("IO Exception", Color.red);
-					}
+            try {
+                        SCeditAction.panelS57.startExport(efc.getSelectedFile());
+                    } catch (IOException e1) {
+                        SCeditAction.panelS57.setVisible(false);
+                        setStatus("IO Exception", Color.red);
+                    }
          } else {
- 					SCeditAction.panelS57.setVisible(false);
-					clrStatus();
+                     SCeditAction.panelS57.setVisible(false);
+                    clrStatus();
          }
       }
-		}
-	};
-
-	public PanelMain() {
-		setLayout(null);
-		setSize(new Dimension(480, 480));
-		
-		w = h = z = f = 0;
-		wt = new JTextField("0");
-		wt.setBounds(10, 400, 40, 20);
+        }
+    };
+
+    public PanelMain() {
+        setLayout(null);
+        setSize(new Dimension(480, 480));
+
+        w = h = z = f = 0;
+        wt = new JTextField("0");
+        wt.setBounds(10, 400, 40, 20);
     add(wt);
-		ht = new JTextField("0");
-		ht.setBounds(60, 400, 40, 20);
+        ht = new JTextField("0");
+        ht.setBounds(60, 400, 40, 20);
     add(ht);
-		zt = new JTextField("0");
-		zt.setBounds(110, 400, 40, 20);
+        zt = new JTextField("0");
+        zt.setBounds(110, 400, 40, 20);
     add(zt);
-		ft = new JTextField("0");
-		ft.setBounds(160, 400, 40, 20);
+        ft = new JTextField("0");
+        ft.setBounds(160, 400, 40, 20);
     add(ft);
 
@@ -115,84 +123,85 @@
     messageBar.setBackground(Color.WHITE);
     add(messageBar);
-		importButton = new JButton(new ImageIcon(getClass().getResource("/images/importButton.png")));
-		importButton.setBounds(10, 430, 20, 20);
-		add(importButton);
-		importButton.addActionListener(alImport);
-		exportButton = new JButton(new ImageIcon(getClass().getResource("/images/exportButton.png")));
-		exportButton.setBounds(40, 430, 20, 20);
-		add(exportButton);
-		exportButton.addActionListener(alExport);
-		saveButton = new JButton();
-		saveButton.setBounds(370, 430, 100, 20);
-		saveButton.setText(tr("Save"));
-		add(saveButton);
-		saveButton.addActionListener(alSave);
-
-		decode = new JTextArea();
-		decode.setBounds(0, 0, 480, 420);
-		decode.setTabSize(1);
-		add(decode);
-	}
-	
-	public void paintComponent(Graphics g){
-		super.paintComponent(g);
-		Graphics2D g2 = (Graphics2D) g;
-		g2.setBackground(new Color(0xb5d0d0));
-		if (img != null) g2.clearRect(0, 0, img.getWidth(), img.getHeight());
-		g2.drawImage(img, 0, 0, null);
-	}
-	
-	public static void setStatus(String text, Color bg) {
-		messageBar.setBackground(bg);
-		messageBar.setText(text);
-	}
-	
-	public static void clrStatus() {
-		messageBar.setBackground(Color.white);
-		messageBar.setText("");
-	}
-	
-	public void parseMark(Feature feature) {
-		decode.setText("Selected object:\n");
-		decode.append("\t" + tr("Type") + ": " + Messages.getString(feature.type.name()) + "\n");
-		if (feature.atts.get(Att.OBJNAM) != null) {
-			decode.append("\t" + tr("Name") + ": " + feature.atts.get(Att.OBJNAM).val + "\n");
-		}
-		decode.append("\tObjects:\n");
-		for (Obj obj : feature.objs.keySet()) {
-			decode.append("\t\t" + Messages.getString(obj.name()) + "\n");
-			if (feature.objs.get(obj).size() != 0) {
-				for (AttMap atts : feature.objs.get(obj).values()) {
-					for (Att att : atts.keySet()) {
-						AttVal<?> item = atts.get(att);
-						switch (item.conv) {
-						case E:
-							decode.append("\t\t\t" + Messages.getString(att.name()) + ": " + Messages.getString(((Enum<?>)((ArrayList<?>)item.val).get(0)).name()) + "\n");
-							break;
-						case L:
-							decode.append("\t\t\t" + Messages.getString(att.name()) + ": ");
-							boolean first = true;
-							for (Object val : (ArrayList<?>)item.val) {
-								if (!first) {
-									decode.append(", ");
-								} else {
-									first = false;
-								}
-								decode.append(Messages.getString(((Enum<?>)val).name()));
-							}
-							decode.append("\n");
-							break;
-						default:
-							decode.append("\t\t\t" + Messages.getString(att.name()) + ": " + item.val + "\n");
-						}
-					}
-				}
-			}
-		}
-	}
-	
-	public void clearMark() {
-		decode.setText(tr("No object selected"));
-	}
-	
+        importButton = new JButton(new ImageIcon(getClass().getResource("/images/importButton.png")));
+        importButton.setBounds(10, 430, 20, 20);
+        add(importButton);
+        importButton.addActionListener(alImport);
+        exportButton = new JButton(new ImageIcon(getClass().getResource("/images/exportButton.png")));
+        exportButton.setBounds(40, 430, 20, 20);
+        add(exportButton);
+        exportButton.addActionListener(alExport);
+        saveButton = new JButton();
+        saveButton.setBounds(370, 430, 100, 20);
+        saveButton.setText(tr("Save"));
+        add(saveButton);
+        saveButton.addActionListener(alSave);
+
+        decode = new JTextArea();
+        decode.setBounds(0, 0, 480, 420);
+        decode.setTabSize(1);
+        add(decode);
+    }
+
+    @Override
+    public void paintComponent(Graphics g) {
+        super.paintComponent(g);
+        Graphics2D g2 = (Graphics2D) g;
+        g2.setBackground(new Color(0xb5d0d0));
+        if (img != null) g2.clearRect(0, 0, img.getWidth(), img.getHeight());
+        g2.drawImage(img, 0, 0, null);
+    }
+
+    public static void setStatus(String text, Color bg) {
+        messageBar.setBackground(bg);
+        messageBar.setText(text);
+    }
+
+    public static void clrStatus() {
+        messageBar.setBackground(Color.white);
+        messageBar.setText("");
+    }
+
+    public void parseMark(Feature feature) {
+        decode.setText("Selected object:\n");
+        decode.append("\t" + tr("Type") + ": " + Messages.getString(feature.type.name()) + "\n");
+        if (feature.atts.get(Att.OBJNAM) != null) {
+            decode.append("\t" + tr("Name") + ": " + feature.atts.get(Att.OBJNAM).val + "\n");
+        }
+        decode.append("\tObjects:\n");
+        for (Obj obj : feature.objs.keySet()) {
+            decode.append("\t\t" + Messages.getString(obj.name()) + "\n");
+            if (feature.objs.get(obj).size() != 0) {
+                for (AttMap atts : feature.objs.get(obj).values()) {
+                    for (Att att : atts.keySet()) {
+                        AttVal<?> item = atts.get(att);
+                        switch (item.conv) {
+                        case E:
+                            decode.append("\t\t\t" + Messages.getString(att.name()) + ": " +
+                                    Messages.getString(((Enum<?>) ((ArrayList<?>) item.val).get(0)).name()) + "\n");
+                            break;
+                        case L:
+                            decode.append("\t\t\t" + Messages.getString(att.name()) + ": ");
+                            boolean first = true;
+                            for (Object val : (ArrayList<?>) item.val) {
+                                if (!first) {
+                                    decode.append(", ");
+                                } else {
+                                    first = false;
+                                }
+                                decode.append(Messages.getString(((Enum<?>) val).name()));
+                            }
+                            decode.append("\n");
+                            break;
+                        default:
+                            decode.append("\t\t\t" + Messages.getString(att.name()) + ": " + item.val + "\n");
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    public void clearMark() {
+        decode.setText(tr("No object selected"));
+    }
 }
Index: /applications/editors/josm/plugins/seachartedit/src/panels/PanelS57.java
===================================================================
--- /applications/editors/josm/plugins/seachartedit/src/panels/PanelS57.java	(revision 33029)
+++ /applications/editors/josm/plugins/seachartedit/src/panels/PanelS57.java	(revision 33030)
@@ -12,5 +12,7 @@
 import java.awt.Color;
 import java.awt.Dimension;
-import java.io.*;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -24,213 +26,227 @@
 import org.openstreetmap.josm.data.Bounds;
 import org.openstreetmap.josm.data.coor.LatLon;
-import org.openstreetmap.josm.data.osm.*;
+import org.openstreetmap.josm.data.osm.DataSet;
+import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
+import org.openstreetmap.josm.data.osm.Relation;
+import org.openstreetmap.josm.data.osm.RelationMember;
+import org.openstreetmap.josm.data.osm.Way;
 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
 
 import s57.S57att;
+import s57.S57att.Att;
 import s57.S57dec;
+import s57.S57map;
+import s57.S57map.AttMap;
+import s57.S57map.Feature;
+import s57.S57map.GeomIterator;
+import s57.S57map.ObjTab;
+import s57.S57map.Pflag;
+import s57.S57map.Prim;
+import s57.S57map.Rflag;
+import s57.S57map.Snode;
 import s57.S57obj;
-import s57.S57map;
+import s57.S57obj.Obj;
 import s57.S57val;
-import s57.S57att.Att;
-import s57.S57map.*;
-import s57.S57obj.*;
 import s57.S57val.AttVal;
 
 public class PanelS57 extends JPanel {
 
-	ArrayList<Obj> types = new ArrayList<Obj>();
-	S57map map;
-	HashMap<Long, Long> uids = new HashMap<Long, Long>();
-	
-	public PanelS57() {
-		setLayout(null);
-		setSize(new Dimension(480, 480));
-		setVisible(false);
-	}
-
-	public void startImport(File inf) throws IOException {
-		FileInputStream in = new FileInputStream(inf);
-		PanelMain.setStatus("Select OSM types file", Color.yellow);
-		JFileChooser ifc = new JFileChooser(Main.pref.get("smed2plugin.typesfile"));
-		ifc.setSelectedFile(new File(Main.pref.get("smed2plugin.typesfile")));
-		int returnVal = ifc.showOpenDialog(Main.parent);
-		if (returnVal == JFileChooser.APPROVE_OPTION) {
-			Main.pref.put("smed2plugin.typesfile", ifc.getSelectedFile().getPath());
-			Scanner tin = new Scanner(new FileInputStream(ifc.getSelectedFile()));
-			while (tin.hasNext()) {
-				Obj type = S57obj.enumType(tin.next());
-				if (type != Obj.UNKOBJ)
-					types.add(type);
-			}
-			tin.close();
-		}
-		map = new S57map(true);
-		S57dec.decodeChart(in, map);
-
-		in.close();
-		
-		DataSet data = new DataSet();
-		data.setUploadDiscouraged(true);
-		
-		for (long id : map.index.keySet()) {
-			Feature feature = map.index.get(id);
-			String type = S57obj.stringType(feature.type);
-			if (!type.isEmpty() && (types.isEmpty() || types.contains(feature.type))) {
-				if (feature.reln == Rflag.MASTER) {
-					if (feature.geom.prim == Pflag.POINT) {
-						for (Prim prim : feature.geom.elems) {
-							long ref = prim.id;
-							Snode snode;
-							while ((snode = map.nodes.get(ref)) != null) {
-								if (!uids.containsKey(ref)) {
-									Node node = new Node(0, 1);
-									node.setCoor((new LatLon(Math.toDegrees(snode.lat), Math.toDegrees(snode.lon))));
-									data.addPrimitive(node);
-									addKeys(node, feature, type);
-									uids.put(ref, node.getUniqueId());
-								}
-								ref++;
-							}
-						}
-					}
-				}
-			}
-		}
-		for (long id : map.index.keySet()) {
-			Feature feature = map.index.get(id);
-			String type = S57obj.stringType(feature.type);
-			if (!type.isEmpty() && (types.isEmpty() || types.contains(feature.type))) {
-				if (feature.reln == Rflag.MASTER) {
-					if ((feature.geom.prim == Pflag.LINE) || ((feature.geom.prim == Pflag.AREA) && (feature.geom.outers == 1) && (feature.geom.inners == 0))) {
-						GeomIterator git = map.new GeomIterator(feature.geom);
-						while (git.hasComp()) {
-							git.nextComp();
-							while (git.hasEdge()) {
-								git.nextEdge();
-								while (git.hasNode()) {
-									long ref = git.nextRef();
-									Snode snode = map.nodes.get(ref);
-									if (!uids.containsKey(ref)) {
-										Node node = new Node(0, 1);
-										node.setCoor((new LatLon(Math.toDegrees(snode.lat), Math.toDegrees(snode.lon))));
-										data.addPrimitive(node);
-										uids.put(ref, node.getUniqueId());
-									}
-								}
-							}
-						}
-						git = map.new GeomIterator(feature.geom);
-						while (git.hasComp()) {
-							git.nextComp();
-							Way way = new Way(0, 1);
-							data.addPrimitive(way);
-							while (git.hasEdge()) {
-								git.nextEdge();
-								while (git.hasNode()) {
-									long ref = git.nextRef();
-									way.addNode((Node)data.getPrimitiveById(uids.get(ref), OsmPrimitiveType.NODE));
-								}
-							}
-							addKeys(way, feature, type);
-						}
-					} else if (feature.geom.prim == Pflag.AREA) {
-						GeomIterator git = map.new GeomIterator(feature.geom);
-						while (git.hasComp()) {
-							git.nextComp();
-							while (git.hasEdge()) {
-								git.nextEdge();
-								while (git.hasNode()) {
-									long ref = git.nextRef();
-									Snode snode = map.nodes.get(ref);
-									if (!uids.containsKey(ref)) {
-										Node node = new Node(0, 1);
-										node.setCoor((new LatLon(Math.toDegrees(snode.lat), Math.toDegrees(snode.lon))));
-										data.addPrimitive(node);
-										uids.put(ref, node.getUniqueId());
-									}
-								}
-							}
-						}
-						git = map.new GeomIterator(feature.geom);
-						while (git.hasComp()) {
-							long ref = git.nextComp();
-							Way way = new Way(0, 1);
-							uids.put(ref, way.getUniqueId());
-							data.addPrimitive(way);
-							while (git.hasEdge()) {
-								git.nextEdge();
-								while (git.hasNode()) {
-									ref = git.nextRef();
-									way.addNode((Node) data.getPrimitiveById(uids.get(ref), OsmPrimitiveType.NODE));
-								}
-							}
-						}
-						Relation rel = new Relation(0, 1);
-						data.addPrimitive(rel);
-						git = map.new GeomIterator(feature.geom);
-						int outers = feature.geom.outers;
-						while (git.hasComp()) {
-							long ref = git.nextComp();
-							if (outers-- > 0) {
-								rel.addMember(new RelationMember("outer", (Way) data.getPrimitiveById(uids.get(ref), OsmPrimitiveType.WAY)));
-							} else {
-								rel.addMember(new RelationMember("inner", (Way) data.getPrimitiveById(uids.get(ref), OsmPrimitiveType.WAY)));
-							}
-						}
-						addKeys(rel, feature, type);
-					}
-				}
-			}
-		}
-
-		OsmDataLayer layer = new OsmDataLayer(data, "S-57 Import", null);
-		Main.getLayerManager().addLayer(layer);
-		Main.map.mapView.zoomTo(new Bounds(Math.toDegrees(map.bounds.minlat), Math.toDegrees(map.bounds.minlon), Math.toDegrees(map.bounds.maxlat), Math.toDegrees(map.bounds.maxlon)));
-		PanelMain.setStatus("Import done", Color.green);
-	}
-
-	void addKeys(OsmPrimitive prim, Feature feature, String type) {
-		HashMap<String,String> keys = new HashMap<String,String>();
-		if (prim instanceof Relation) {
-			keys.put("type", "multipolygon");
-		}
-		keys.put("seamark:type", type);
-		if (feature.type == Obj.SOUNDG) {
-			Snode snode = map.nodes.get(feature.geom.elems.get(0).id);
-			if (snode.flg == S57map.Nflag.DPTH) {
-				keys.put("seamark:sounding:depth", ((Double)((Snode)snode).val).toString());
-			}
-		}
-		for (Map.Entry<Att, AttVal<?>> item : feature.atts.entrySet()) {
-			String attstr = S57att.stringAttribute(item.getKey());
-			String valstr = S57val.stringValue(item.getValue(), item.getKey());
-			if (!attstr.isEmpty() && !valstr.isEmpty()) {
-					keys.put(("seamark:" + type + ":" + attstr), valstr);
-			}
-		}
-		for (Obj obj : feature.objs.keySet()) {
-			ObjTab tab = feature.objs.get(obj);
-			for (int ix : tab.keySet()) {
-				type = S57obj.stringType(obj);
-				AttMap atts = tab.get(ix);
-				for (Map.Entry<Att, AttVal<?>> item : atts.entrySet()) {
-					String attstr = S57att.stringAttribute(item.getKey());
-					String valstr = S57val.stringValue(item.getValue(), item.getKey());
-					if (!attstr.isEmpty() && !valstr.isEmpty()) {
-						if ((ix == 0) && (tab.size() == 1)) {
-							keys.put(("seamark:" + type + ":" + attstr), valstr);
-						} else {
-							keys.put(("seamark:" + type + ":" + (ix+1) + ":" + attstr), valstr);
-						}
-					}
-				}
-			}
-		}
-		prim.setKeys(keys);
-	}
-
-	
-	public void startExport(File outf) throws IOException {
-		
-	}
+    ArrayList<Obj> types = new ArrayList<>();
+    S57map map;
+    HashMap<Long, Long> uids = new HashMap<>();
+
+    public PanelS57() {
+        setLayout(null);
+        setSize(new Dimension(480, 480));
+        setVisible(false);
+    }
+
+    public void startImport(File inf) throws IOException {
+        FileInputStream in = new FileInputStream(inf);
+        PanelMain.setStatus("Select OSM types file", Color.yellow);
+        JFileChooser ifc = new JFileChooser(Main.pref.get("smed2plugin.typesfile"));
+        ifc.setSelectedFile(new File(Main.pref.get("smed2plugin.typesfile")));
+        int returnVal = ifc.showOpenDialog(Main.parent);
+        if (returnVal == JFileChooser.APPROVE_OPTION) {
+            Main.pref.put("smed2plugin.typesfile", ifc.getSelectedFile().getPath());
+            Scanner tin = new Scanner(new FileInputStream(ifc.getSelectedFile()));
+            while (tin.hasNext()) {
+                Obj type = S57obj.enumType(tin.next());
+                if (type != Obj.UNKOBJ)
+                    types.add(type);
+            }
+            tin.close();
+        }
+        map = new S57map(true);
+        S57dec.decodeChart(in, map);
+
+        in.close();
+
+        DataSet data = new DataSet();
+        data.setUploadDiscouraged(true);
+
+        for (long id : map.index.keySet()) {
+            Feature feature = map.index.get(id);
+            String type = S57obj.stringType(feature.type);
+            if (!type.isEmpty() && (types.isEmpty() || types.contains(feature.type))) {
+                if (feature.reln == Rflag.MASTER) {
+                    if (feature.geom.prim == Pflag.POINT) {
+                        for (Prim prim : feature.geom.elems) {
+                            long ref = prim.id;
+                            Snode snode;
+                            while ((snode = map.nodes.get(ref)) != null) {
+                                if (!uids.containsKey(ref)) {
+                                    Node node = new Node(0, 1);
+                                    node.setCoor((new LatLon(Math.toDegrees(snode.lat), Math.toDegrees(snode.lon))));
+                                    data.addPrimitive(node);
+                                    addKeys(node, feature, type);
+                                    uids.put(ref, node.getUniqueId());
+                                }
+                                ref++;
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        for (long id : map.index.keySet()) {
+            Feature feature = map.index.get(id);
+            String type = S57obj.stringType(feature.type);
+            if (!type.isEmpty() && (types.isEmpty() || types.contains(feature.type))) {
+                if (feature.reln == Rflag.MASTER) {
+                    if ((feature.geom.prim == Pflag.LINE) || ((feature.geom.prim == Pflag.AREA)
+                            && (feature.geom.outers == 1) && (feature.geom.inners == 0))) {
+                        GeomIterator git = map.new GeomIterator(feature.geom);
+                        while (git.hasComp()) {
+                            git.nextComp();
+                            while (git.hasEdge()) {
+                                git.nextEdge();
+                                while (git.hasNode()) {
+                                    long ref = git.nextRef();
+                                    Snode snode = map.nodes.get(ref);
+                                    if (!uids.containsKey(ref)) {
+                                        Node node = new Node(0, 1);
+                                        node.setCoor((new LatLon(Math.toDegrees(snode.lat), Math.toDegrees(snode.lon))));
+                                        data.addPrimitive(node);
+                                        uids.put(ref, node.getUniqueId());
+                                    }
+                                }
+                            }
+                        }
+                        git = map.new GeomIterator(feature.geom);
+                        while (git.hasComp()) {
+                            git.nextComp();
+                            Way way = new Way(0, 1);
+                            data.addPrimitive(way);
+                            while (git.hasEdge()) {
+                                git.nextEdge();
+                                while (git.hasNode()) {
+                                    long ref = git.nextRef();
+                                    way.addNode((Node) data.getPrimitiveById(uids.get(ref), OsmPrimitiveType.NODE));
+                                }
+                            }
+                            addKeys(way, feature, type);
+                        }
+                    } else if (feature.geom.prim == Pflag.AREA) {
+                        GeomIterator git = map.new GeomIterator(feature.geom);
+                        while (git.hasComp()) {
+                            git.nextComp();
+                            while (git.hasEdge()) {
+                                git.nextEdge();
+                                while (git.hasNode()) {
+                                    long ref = git.nextRef();
+                                    Snode snode = map.nodes.get(ref);
+                                    if (!uids.containsKey(ref)) {
+                                        Node node = new Node(0, 1);
+                                        node.setCoor((new LatLon(Math.toDegrees(snode.lat), Math.toDegrees(snode.lon))));
+                                        data.addPrimitive(node);
+                                        uids.put(ref, node.getUniqueId());
+                                    }
+                                }
+                            }
+                        }
+                        git = map.new GeomIterator(feature.geom);
+                        while (git.hasComp()) {
+                            long ref = git.nextComp();
+                            Way way = new Way(0, 1);
+                            uids.put(ref, way.getUniqueId());
+                            data.addPrimitive(way);
+                            while (git.hasEdge()) {
+                                git.nextEdge();
+                                while (git.hasNode()) {
+                                    ref = git.nextRef();
+                                    way.addNode((Node) data.getPrimitiveById(uids.get(ref), OsmPrimitiveType.NODE));
+                                }
+                            }
+                        }
+                        Relation rel = new Relation(0, 1);
+                        data.addPrimitive(rel);
+                        git = map.new GeomIterator(feature.geom);
+                        int outers = feature.geom.outers;
+                        while (git.hasComp()) {
+                            long ref = git.nextComp();
+                            if (outers-- > 0) {
+                                rel.addMember(new RelationMember("outer", data.getPrimitiveById(uids.get(ref), OsmPrimitiveType.WAY)));
+                            } else {
+                                rel.addMember(new RelationMember("inner", data.getPrimitiveById(uids.get(ref), OsmPrimitiveType.WAY)));
+                            }
+                        }
+                        addKeys(rel, feature, type);
+                    }
+                }
+            }
+        }
+
+        OsmDataLayer layer = new OsmDataLayer(data, "S-57 Import", null);
+        Main.getLayerManager().addLayer(layer);
+        Main.map.mapView.zoomTo(new Bounds(Math.toDegrees(map.bounds.minlat), Math.toDegrees(map.bounds.minlon),
+                                           Math.toDegrees(map.bounds.maxlat), Math.toDegrees(map.bounds.maxlon)));
+        PanelMain.setStatus("Import done", Color.green);
+    }
+
+    void addKeys(OsmPrimitive prim, Feature feature, String type) {
+        HashMap<String, String> keys = new HashMap<>();
+        if (prim instanceof Relation) {
+            keys.put("type", "multipolygon");
+        }
+        keys.put("seamark:type", type);
+        if (feature.type == Obj.SOUNDG) {
+            Snode snode = map.nodes.get(feature.geom.elems.get(0).id);
+            if (snode.flg == S57map.Nflag.DPTH) {
+                keys.put("seamark:sounding:depth", ((Double) snode.val).toString());
+            }
+        }
+        for (Map.Entry<Att, AttVal<?>> item : feature.atts.entrySet()) {
+            String attstr = S57att.stringAttribute(item.getKey());
+            String valstr = S57val.stringValue(item.getValue(), item.getKey());
+            if (!attstr.isEmpty() && !valstr.isEmpty()) {
+                    keys.put(("seamark:" + type + ":" + attstr), valstr);
+            }
+        }
+        for (Obj obj : feature.objs.keySet()) {
+            ObjTab tab = feature.objs.get(obj);
+            for (int ix : tab.keySet()) {
+                type = S57obj.stringType(obj);
+                AttMap atts = tab.get(ix);
+                for (Map.Entry<Att, AttVal<?>> item : atts.entrySet()) {
+                    String attstr = S57att.stringAttribute(item.getKey());
+                    String valstr = S57val.stringValue(item.getValue(), item.getKey());
+                    if (!attstr.isEmpty() && !valstr.isEmpty()) {
+                        if ((ix == 0) && (tab.size() == 1)) {
+                            keys.put(("seamark:" + type + ":" + attstr), valstr);
+                        } else {
+                            keys.put(("seamark:" + type + ":" + (ix+1) + ":" + attstr), valstr);
+                        }
+                    }
+                }
+            }
+        }
+        prim.setKeys(keys);
+    }
+
+    public void startExport(File outf) throws IOException {
+
+    }
 }
Index: /applications/editors/josm/plugins/seachartedit/src/panels/ShowFrame.java
===================================================================
--- /applications/editors/josm/plugins/seachartedit/src/panels/ShowFrame.java	(revision 33029)
+++ /applications/editors/josm/plugins/seachartedit/src/panels/ShowFrame.java	(revision 33030)
@@ -25,75 +25,79 @@
 import render.Renderer;
 import s57.S57map;
-import s57.S57map.*;
+import s57.S57map.Feature;
+import s57.S57map.Snode;
 
 public class ShowFrame extends JFrame {
-	
-	S57map showMap;
-	Picture picture;
 
-	class Picture extends JPanel implements ChartContext {
+    S57map showMap;
+    Picture picture;
 
-		public void drawPicture(OsmPrimitive osm, S57map map) {
-			long id;
-			Feature feature;
-			
-			id = osm.getUniqueId();
-			feature = map.index.get(id);
-			showMap = new S57map(true);
-			showMap.nodes = map.nodes;
-			showMap.edges = map.edges;
-			showMap.index = map.index;
-			if (feature != null) {
-				showMap.features.put(feature.type, new ArrayList<Feature>());
-				showMap.features.get(feature.type).add(feature);
-			}
-			repaint();
-		}
-		
-		public void paintComponent(Graphics g) {
-			Graphics2D g2 = (Graphics2D)g;
-			g2.setBackground(new Color(0xb5d0d0));
-			Rectangle rect =  new Rectangle(0, 0, 300, 300);
-			g2.clearRect(rect.x, rect.y, rect.width, rect.height);
-			Renderer.reRender(g2, rect, 16, 32, showMap, this);
-		}
+    class Picture extends JPanel implements ChartContext {
 
-		public Point2D getPoint(Snode coord) {
-			return new Point2D.Double(150, 150);
-		}
+        public void drawPicture(OsmPrimitive osm, S57map map) {
+            long id;
+            Feature feature;
 
-		public double mile(Feature feature) {
-			return 1000;
-		}
+            id = osm.getUniqueId();
+            feature = map.index.get(id);
+            showMap = new S57map(true);
+            showMap.nodes = map.nodes;
+            showMap.edges = map.edges;
+            showMap.index = map.index;
+            if (feature != null) {
+                showMap.features.put(feature.type, new ArrayList<Feature>());
+                showMap.features.get(feature.type).add(feature);
+            }
+            repaint();
+        }
 
-		@Override
-		public boolean clip() {
-			// TODO Auto-generated method stub
-			return false;
-		}
+        @Override
+        public void paintComponent(Graphics g) {
+            Graphics2D g2 = (Graphics2D) g;
+            g2.setBackground(new Color(0xb5d0d0));
+            Rectangle rect = new Rectangle(0, 0, 300, 300);
+            g2.clearRect(rect.x, rect.y, rect.width, rect.height);
+            Renderer.reRender(g2, rect, 16, 32, showMap, this);
+        }
 
-		@Override
-		public Color background(S57map map) {
-			// TODO Auto-generated method stub
-			return null;
-		}
+        @Override
+        public Point2D getPoint(Snode coord) {
+            return new Point2D.Double(150, 150);
+        }
 
-		@Override
-		public RuleSet ruleset() {
-			// TODO Auto-generated method stub
-			return null;
-		}
-	}
+        @Override
+        public double mile(Feature feature) {
+            return 1000;
+        }
 
-	public ShowFrame(String title) {
-		super(title);
-		picture = new Picture();
-		picture.setVisible(true);
-		add(picture);
-		pack();
-	}
-	
-	public void showFeature(OsmPrimitive osm, S57map map) {
-		picture.drawPicture(osm, map);
-	}
+        @Override
+        public boolean clip() {
+            // TODO Auto-generated method stub
+            return false;
+        }
+
+        @Override
+        public Color background(S57map map) {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        @Override
+        public RuleSet ruleset() {
+            // TODO Auto-generated method stub
+            return null;
+        }
+    }
+
+    public ShowFrame(String title) {
+        super(title);
+        picture = new Picture();
+        picture.setVisible(true);
+        add(picture);
+        pack();
+    }
+
+    public void showFeature(OsmPrimitive osm, S57map map) {
+        picture.drawPicture(osm, map);
+    }
 }
Index: /applications/editors/josm/plugins/seachartedit/src/scedit/SCedit.java
===================================================================
--- /applications/editors/josm/plugins/seachartedit/src/scedit/SCedit.java	(revision 33029)
+++ /applications/editors/josm/plugins/seachartedit/src/scedit/SCedit.java	(revision 33030)
@@ -17,5 +17,5 @@
 public class SCedit extends Plugin {
 
-	public SCedit(PluginInformation info) {
+    public SCedit(PluginInformation info) {
         super(info);
         MainMenu.add(Main.main.menu.toolsMenu, new SCeditAction());
Index: /applications/editors/josm/plugins/seachartedit/src/scedit/SCeditAction.java
===================================================================
--- /applications/editors/josm/plugins/seachartedit/src/scedit/SCeditAction.java	(revision 33029)
+++ /applications/editors/josm/plugins/seachartedit/src/scedit/SCeditAction.java	(revision 33030)
@@ -54,231 +54,233 @@
 
 public class SCeditAction extends JosmAction implements ActiveLayerChangeListener, SelectionChangedListener {
-	private static String title = tr("SeaChart Editor");
-	public static JFrame editFrame = null;
-	public static ShowFrame showFrame = null;
-	private boolean isOpen = false;
-	public static PanelMain panelMain = null;
-	public static PanelS57 panelS57 = null;
-	public static S57map map = null;
-	public DataSet data = null;
-
-	private final DataSetListener dataSetListener = new DataSetListener() {
-
-		@Override
-		public void dataChanged(DataChangedEvent e) {
-			makeMap();
-		}
-
-		@Override
-		public void nodeMoved(NodeMovedEvent e) {
-			makeMap();
-		}
-
-		@Override
-		public void otherDatasetChange(AbstractDatasetChangedEvent e) {
-			makeMap();
-		}
-
-		@Override
-		public void primitivesAdded(PrimitivesAddedEvent e) {
-			makeMap();
-		}
-
-		@Override
-		public void primitivesRemoved(PrimitivesRemovedEvent e) {
-			makeMap();
-		}
-
-		@Override
-		public void relationMembersChanged(RelationMembersChangedEvent e) {
-			makeMap();
-		}
-
-		@Override
-		public void tagsChanged(TagsChangedEvent e) {
-			makeMap();
-		}
-
-		@Override
-		public void wayNodesChanged(WayNodesChangedEvent e) {
-			makeMap();
-		}
-	};
-
-	public SCeditAction() {
-		super(title, "SC", title, null, true);
-	}
-
-	@Override
-	public void actionPerformed(ActionEvent arg0) {
-		SwingUtilities.invokeLater(new Runnable() {
-			public void run() {
-				if (!isOpen)
-					createFrame();
-				else
-					editFrame.toFront();
-				isOpen = true;
-			}
-		});
-	}
-
-	protected void createFrame() {
-		editFrame = new JFrame(title);
-		editFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
-		editFrame.addWindowListener(new java.awt.event.WindowAdapter() {
-			public void windowClosing(java.awt.event.WindowEvent e) {
-				closeDialog();
-			}
-		});
-		editFrame.setSize(new Dimension(480, 480));
-		editFrame.setLocation(100, 200);
-		editFrame.setResizable(true);
-		editFrame.setAlwaysOnTop(true);
-		editFrame.setVisible(true);
-		panelMain = new PanelMain();
-		editFrame.add(panelMain);
-
-		panelS57 = new PanelS57();
-		editFrame.add(panelS57);
-
-		showFrame = new ShowFrame(tr("Seamark Inspector"));
-		showFrame.setSize(new Dimension(300, 300));
-		showFrame.setLocation(50, 400);
-		showFrame.setResizable(false);
-		showFrame.setAlwaysOnTop(true);
-		showFrame.setEnabled(true);
-		showFrame.setVisible(false);
-
-		Main.getLayerManager().addAndFireActiveLayerChangeListener(this);
-		DataSet.addSelectionListener(this);
-	}
-
-	public void closeDialog() {
-		if (isOpen) {
-		        Main.getLayerManager().removeActiveLayerChangeListener(this);
-			editFrame.setVisible(false);
-			editFrame.dispose();
-			data = null;
-			map = null;
-		}
-		isOpen = false;
-	}
-
-	@Override
-	public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) {
-		if (e.getPreviousEditLayer() != null) {
-		    e.getPreviousEditLayer().data.removeDataSetListener(dataSetListener);
-		}
-		OsmDataLayer newLayer = Main.getLayerManager().getEditLayer();
-		if (newLayer != null) {
-			newLayer.data.addDataSetListener(dataSetListener);
-			data = newLayer.data;
-			makeMap();
-		} else {
-			data = null;
-			map = null;
-		}
-	}
-
-	@Override
-	public void selectionChanged(Collection<? extends OsmPrimitive> selection) {
-		OsmPrimitive nextFeature = null;
-		OsmPrimitive feature = null;
-
-		showFrame.setVisible(false);
-		panelMain.clearMark();
-		if (map != null) {
-			for (OsmPrimitive osm : selection) {
-				nextFeature = osm;
-				if (selection.size() == 1) {
-					if (nextFeature.compareTo(feature) != 0) {
-						feature = nextFeature;
-						Feature id = map.index.get(feature.getUniqueId());
-						if (id != null) {
-							panelMain.parseMark(id);
-							showFrame.setVisible(true);
-							showFrame.showFeature(feature, map);
-						}
-					}
-				} else {
-					showFrame.setVisible(false);
-					PanelMain.setStatus(tr("Select only one object"), Color.orange);
-				}
-			}
-			if (nextFeature == null) {
-				feature = null;
-				panelMain.clearMark();
-				showFrame.setVisible(false);
-				PanelMain.setStatus(tr("Select a map object"), Color.yellow);
-			}
-		}
-	}
-
-	void makeMap() {
-		map = new S57map(true);
-		if (data != null) {
-			double minlat = 90;
-			double maxlat = -90;
-			double minlon = 180;
-			double maxlon = -180;
-			for (Bounds bounds : data.getDataSourceBounds()) {
-				if (bounds.getMinLat() < minlat) {
-					minlat = bounds.getMinLat();
-				}
-				if (bounds.getMaxLat() > maxlat) {
-					maxlat = bounds.getMaxLat();
-				}
-				if (bounds.getMinLon() < minlon) {
-					minlon = bounds.getMinLon();
-				}
-				if (bounds.getMaxLon() > maxlon) {
-					maxlon = bounds.getMaxLon();
-				}
-			}
-			map.addNode(1, maxlat, minlon);
-			map.addNode(2, minlat, minlon);
-			map.addNode(3, minlat, maxlon);
-			map.addNode(4, maxlat, maxlon);
-			map.bounds.minlat = Math.toRadians(minlat);
-			map.bounds.maxlat = Math.toRadians(maxlat);
-			map.bounds.minlon = Math.toRadians(minlon);
-			map.bounds.maxlon = Math.toRadians(maxlon);
-			for (Node node : data.getNodes()) {
-				LatLon coor = node.getCoor();
-				if (coor != null) {
-					map.addNode(node.getUniqueId(), coor.lat(), coor.lon());
-					for (Entry<String, String> entry : node.getKeys().entrySet()) {
-						map.addTag(entry.getKey(), entry.getValue());
-					}
-					map.tagsDone(node.getUniqueId());
-				}
-			}
-			for (Way way : data.getWays()) {
-				if (way.getNodesCount() > 0) {
-					map.addEdge(way.getUniqueId());
-					for (Node node : way.getNodes()) {
-						map.addToEdge((node.getUniqueId()));
-					}
-					for (Entry<String, String> entry : way.getKeys().entrySet()) {
-						map.addTag(entry.getKey(), entry.getValue());
-					}
-					map.tagsDone(way.getUniqueId());
-				}
-			}
-			for (Relation rel : data.getRelations()) {
-				if (rel.isMultipolygon() && (rel.getMembersCount() > 0)) {
-					map.addArea(rel.getUniqueId());
-					for (RelationMember mem : rel.getMembers()) {
-						if (mem.getType() == OsmPrimitiveType.WAY)
-							map.addToArea(mem.getUniqueId(), (mem.getRole().equals("outer")));
-					}
-					for (Entry<String, String> entry : rel.getKeys().entrySet()) {
-						map.addTag(entry.getKey(), entry.getValue());
-					}
-					map.tagsDone(rel.getUniqueId());
-				}
-			}
-			map.mapDone();
-		}
-	}
+    private static String title = tr("SeaChart Editor");
+    public static JFrame editFrame = null;
+    public static ShowFrame showFrame = null;
+    private boolean isOpen = false;
+    public static PanelMain panelMain = null;
+    public static PanelS57 panelS57 = null;
+    public static S57map map = null;
+    public DataSet data = null;
+
+    private final DataSetListener dataSetListener = new DataSetListener() {
+
+        @Override
+        public void dataChanged(DataChangedEvent e) {
+            makeMap();
+        }
+
+        @Override
+        public void nodeMoved(NodeMovedEvent e) {
+            makeMap();
+        }
+
+        @Override
+        public void otherDatasetChange(AbstractDatasetChangedEvent e) {
+            makeMap();
+        }
+
+        @Override
+        public void primitivesAdded(PrimitivesAddedEvent e) {
+            makeMap();
+        }
+
+        @Override
+        public void primitivesRemoved(PrimitivesRemovedEvent e) {
+            makeMap();
+        }
+
+        @Override
+        public void relationMembersChanged(RelationMembersChangedEvent e) {
+            makeMap();
+        }
+
+        @Override
+        public void tagsChanged(TagsChangedEvent e) {
+            makeMap();
+        }
+
+        @Override
+        public void wayNodesChanged(WayNodesChangedEvent e) {
+            makeMap();
+        }
+    };
+
+    public SCeditAction() {
+        super(title, "SC", title, null, true);
+    }
+
+    @Override
+    public void actionPerformed(ActionEvent arg0) {
+        SwingUtilities.invokeLater(new Runnable() {
+            @Override
+            public void run() {
+                if (!isOpen)
+                    createFrame();
+                else
+                    editFrame.toFront();
+                isOpen = true;
+            }
+        });
+    }
+
+    protected void createFrame() {
+        editFrame = new JFrame(title);
+        editFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
+        editFrame.addWindowListener(new java.awt.event.WindowAdapter() {
+            @Override
+            public void windowClosing(java.awt.event.WindowEvent e) {
+                closeDialog();
+            }
+        });
+        editFrame.setSize(new Dimension(480, 480));
+        editFrame.setLocation(100, 200);
+        editFrame.setResizable(true);
+        editFrame.setAlwaysOnTop(true);
+        editFrame.setVisible(true);
+        panelMain = new PanelMain();
+        editFrame.add(panelMain);
+
+        panelS57 = new PanelS57();
+        editFrame.add(panelS57);
+
+        showFrame = new ShowFrame(tr("Seamark Inspector"));
+        showFrame.setSize(new Dimension(300, 300));
+        showFrame.setLocation(50, 400);
+        showFrame.setResizable(false);
+        showFrame.setAlwaysOnTop(true);
+        showFrame.setEnabled(true);
+        showFrame.setVisible(false);
+
+        Main.getLayerManager().addAndFireActiveLayerChangeListener(this);
+        DataSet.addSelectionListener(this);
+    }
+
+    public void closeDialog() {
+        if (isOpen) {
+                Main.getLayerManager().removeActiveLayerChangeListener(this);
+            editFrame.setVisible(false);
+            editFrame.dispose();
+            data = null;
+            map = null;
+        }
+        isOpen = false;
+    }
+
+    @Override
+    public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) {
+        if (e.getPreviousEditLayer() != null) {
+            e.getPreviousEditLayer().data.removeDataSetListener(dataSetListener);
+        }
+        OsmDataLayer newLayer = Main.getLayerManager().getEditLayer();
+        if (newLayer != null) {
+            newLayer.data.addDataSetListener(dataSetListener);
+            data = newLayer.data;
+            makeMap();
+        } else {
+            data = null;
+            map = null;
+        }
+    }
+
+    @Override
+    public void selectionChanged(Collection<? extends OsmPrimitive> selection) {
+        OsmPrimitive nextFeature = null;
+        OsmPrimitive feature = null;
+
+        showFrame.setVisible(false);
+        panelMain.clearMark();
+        if (map != null) {
+            for (OsmPrimitive osm : selection) {
+                nextFeature = osm;
+                if (selection.size() == 1) {
+                    if (nextFeature.compareTo(feature) != 0) {
+                        feature = nextFeature;
+                        Feature id = map.index.get(feature.getUniqueId());
+                        if (id != null) {
+                            panelMain.parseMark(id);
+                            showFrame.setVisible(true);
+                            showFrame.showFeature(feature, map);
+                        }
+                    }
+                } else {
+                    showFrame.setVisible(false);
+                    PanelMain.setStatus(tr("Select only one object"), Color.orange);
+                }
+            }
+            if (nextFeature == null) {
+                feature = null;
+                panelMain.clearMark();
+                showFrame.setVisible(false);
+                PanelMain.setStatus(tr("Select a map object"), Color.yellow);
+            }
+        }
+    }
+
+    void makeMap() {
+        map = new S57map(true);
+        if (data != null) {
+            double minlat = 90;
+            double maxlat = -90;
+            double minlon = 180;
+            double maxlon = -180;
+            for (Bounds bounds : data.getDataSourceBounds()) {
+                if (bounds.getMinLat() < minlat) {
+                    minlat = bounds.getMinLat();
+                }
+                if (bounds.getMaxLat() > maxlat) {
+                    maxlat = bounds.getMaxLat();
+                }
+                if (bounds.getMinLon() < minlon) {
+                    minlon = bounds.getMinLon();
+                }
+                if (bounds.getMaxLon() > maxlon) {
+                    maxlon = bounds.getMaxLon();
+                }
+            }
+            map.addNode(1, maxlat, minlon);
+            map.addNode(2, minlat, minlon);
+            map.addNode(3, minlat, maxlon);
+            map.addNode(4, maxlat, maxlon);
+            map.bounds.minlat = Math.toRadians(minlat);
+            map.bounds.maxlat = Math.toRadians(maxlat);
+            map.bounds.minlon = Math.toRadians(minlon);
+            map.bounds.maxlon = Math.toRadians(maxlon);
+            for (Node node : data.getNodes()) {
+                LatLon coor = node.getCoor();
+                if (coor != null) {
+                    map.addNode(node.getUniqueId(), coor.lat(), coor.lon());
+                    for (Entry<String, String> entry : node.getKeys().entrySet()) {
+                        map.addTag(entry.getKey(), entry.getValue());
+                    }
+                    map.tagsDone(node.getUniqueId());
+                }
+            }
+            for (Way way : data.getWays()) {
+                if (way.getNodesCount() > 0) {
+                    map.addEdge(way.getUniqueId());
+                    for (Node node : way.getNodes()) {
+                        map.addToEdge((node.getUniqueId()));
+                    }
+                    for (Entry<String, String> entry : way.getKeys().entrySet()) {
+                        map.addTag(entry.getKey(), entry.getValue());
+                    }
+                    map.tagsDone(way.getUniqueId());
+                }
+            }
+            for (Relation rel : data.getRelations()) {
+                if (rel.isMultipolygon() && (rel.getMembersCount() > 0)) {
+                    map.addArea(rel.getUniqueId());
+                    for (RelationMember mem : rel.getMembers()) {
+                        if (mem.getType() == OsmPrimitiveType.WAY)
+                            map.addToArea(mem.getUniqueId(), (mem.getRole().equals("outer")));
+                    }
+                    for (Entry<String, String> entry : rel.getKeys().entrySet()) {
+                        map.addTag(entry.getKey(), entry.getValue());
+                    }
+                    map.tagsDone(rel.getUniqueId());
+                }
+            }
+            map.mapDone();
+        }
+    }
 }
