Revision: 6396 http://sourceforge.net/p/jump-pilot/code/6396 Author: michaudm Date: 2020-08-29 20:11:25 +0000 (Sat, 29 Aug 2020) Log Message: ----------- Externalize ImportArcMapStylePlugIn
Added Paths: ----------- plug-ins/ImportArcMapStylePlugIn/ plug-ins/ImportArcMapStylePlugIn/trunk/ plug-ins/ImportArcMapStylePlugIn/trunk/build.xml plug-ins/ImportArcMapStylePlugIn/trunk/src/ plug-ins/ImportArcMapStylePlugIn/trunk/src/org/ plug-ins/ImportArcMapStylePlugIn/trunk/src/org/openjump/ plug-ins/ImportArcMapStylePlugIn/trunk/src/org/openjump/ext/ plug-ins/ImportArcMapStylePlugIn/trunk/src/org/openjump/ext/style/ plug-ins/ImportArcMapStylePlugIn/trunk/src/org/openjump/ext/style/ImportArcMapStyleExtension.java plug-ins/ImportArcMapStylePlugIn/trunk/src/org/openjump/ext/style/ImportArcMapStylePlugIn.java plug-ins/ImportArcMapStylePlugIn/trunk/src/org/openjump/ext/style/language/ plug-ins/ImportArcMapStylePlugIn/trunk/src/org/openjump/ext/style/language/jump.properties plug-ins/ImportArcMapStylePlugIn/trunk/src/org/openjump/ext/style/language/jump_de.properties plug-ins/ImportArcMapStylePlugIn/trunk/src/org/openjump/ext/style/language/jump_es.properties plug-ins/ImportArcMapStylePlugIn/trunk/src/org/openjump/ext/style/language/jump_fi.properties plug-ins/ImportArcMapStylePlugIn/trunk/src/org/openjump/ext/style/language/jump_fr.properties plug-ins/ImportArcMapStylePlugIn/trunk/src/org/openjump/ext/style/language/jump_it.properties Added: plug-ins/ImportArcMapStylePlugIn/trunk/build.xml =================================================================== --- plug-ins/ImportArcMapStylePlugIn/trunk/build.xml (rev 0) +++ plug-ins/ImportArcMapStylePlugIn/trunk/build.xml 2020-08-29 20:11:25 UTC (rev 6396) @@ -0,0 +1,79 @@ +<project name="import-arcmap-style" default="compile" basedir="."> + + <!--************************************************************************* + ***************************************************************************** + ** PROPERTIES ** + ***************************************************************************** + **************************************************************************--> + + <!-- PROPERTIES : MAIN ARCHITECTURE --> + <property name="src" value="src" /> + <property name="bin" value="bin" /> + <property name="lib" value="lib" /> + <property name="build" value="build" /> + <property name="dist" value="dist" /> + <property name="doc" value="doc" /> + <property name="resources" value="resources" /> + <property name="javadoc" value="javadoc" /> + + <property name="import-arcmap-style-version" value="0.1" /> + + <!-- =================================================================== --> + <!-- Defines the classpath used for compilation and test. --> + <!-- =================================================================== --> + <path id="classpath"> + <!--fileset dir="${lib}"> + <include name="**/*.jar"/> + </fileset--> + <fileset dir="../../openjump_lib"> + <include name="**/*.jar"/> + </fileset> + </path> + + <target name="clean" id="clean"> + <delete dir="build"/> + <delete dir="${javadoc}"/> + </target> + + <target name="compile" id="compile" depends="clean"> + <tstamp/> + <mkdir dir="build"/> + <javac srcdir="${src}" destdir="build" + debug="on" deprecation="false" nowarn="true" + source="1.8" target="1.8"> + <!--compilerarg value="-Xlint:unchecked"/--> + <classpath refid="classpath"/> + </javac> + <copy todir="build"> + <fileset dir="${src}" includes="**/*.txt"/> + <fileset dir="${src}" includes="**/*.properties"/> + <fileset dir="${src}" includes="**/*.png"/> + <fileset dir="${src}" includes="**/*.gif"/> + <fileset dir="${src}" includes="**/*.jpg"/> + </copy> + </target> + + + <target name="import-arcmap-style-jar" id="import-arcmap-style-jar" depends="compile"> + <mkdir dir="${dist}"/> + <jar jarfile="${dist}/import-arcmap-style-${import-arcmap-style-version}.jar"> + <fileset dir="build"> + <include name="org/openjump/ext/style/**/*.class"/> + <include name="org/openjump/ext/style/**/*.properties"/> + </fileset> + </jar> + </target> + + <target name="import-arcmap-style-src" id="import-arcmap-style-src" depends="import-arcmap-style-jar"> + <mkdir dir="${dist}"/> + <zip zipfile="${dist}/import-arcmap-style-src-${import-arcmap-style-version}.zip"> + <fileset dir="${dist}"> + <include name="import-arcmap-style-${import-arcmap-style-version}.jar"/> + </fileset> + <fileset dir="."> + <include name="${src}/org/openjump/ext/style/**/*.java"/> + </fileset> + </zip> + </target> + +</project> \ No newline at end of file Added: plug-ins/ImportArcMapStylePlugIn/trunk/src/org/openjump/ext/style/ImportArcMapStyleExtension.java =================================================================== --- plug-ins/ImportArcMapStylePlugIn/trunk/src/org/openjump/ext/style/ImportArcMapStyleExtension.java (rev 0) +++ plug-ins/ImportArcMapStylePlugIn/trunk/src/org/openjump/ext/style/ImportArcMapStyleExtension.java 2020-08-29 20:11:25 UTC (rev 6396) @@ -0,0 +1,64 @@ +/*---------------- FILE HEADER ------------------------------------------ + Copyright (C) 2001-2007 by: + Department of Geography, University of Bonn + http://www.giub.uni-bonn.de/deegree/ + lat/lon GmbH + http://www.lat-lon.de + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Contact: + + Andreas Poth + lat/lon GmbH + Aennchenstr. 19 + 53177 Bonn + Germany + E-Mail: p...@lat-lon.de + + Prof. Dr. Klaus Greve + Department of Geography + University of Bonn + Meckenheimer Allee 166 + 53115 Bonn + Germany + E-Mail: gr...@giub.uni-bonn.de + ---------------------------------------------------------------------------*/ + +package org.openjump.ext.style; + +import com.vividsolutions.jump.workbench.plugin.Extension; +import com.vividsolutions.jump.workbench.plugin.PlugInContext; + +/** + * ImportArcMapStyleExtension. + * Migrated from OpenJUMP core to this external extension on 2020-08 + * @author <a href="mailto:schm...@lat-lon.de">Andreas Schmitz</a> + * @author Michaël Michaud + * @version 0.1 (2020-08-29) + */ +//version 0.1.0 (2020-08-29) +public class ImportArcMapStyleExtension extends Extension { + + public String getName() { + return "Import ArcMap Style (Andreas Poth)"; + } + + public String getVersion() { + return "0.1 (2020-08-29)"; + } + + public void configure(PlugInContext context) throws Exception { + new ImportArcMapStylePlugIn().initialize(context); + } + +} \ No newline at end of file Added: plug-ins/ImportArcMapStylePlugIn/trunk/src/org/openjump/ext/style/ImportArcMapStylePlugIn.java =================================================================== --- plug-ins/ImportArcMapStylePlugIn/trunk/src/org/openjump/ext/style/ImportArcMapStylePlugIn.java (rev 0) +++ plug-ins/ImportArcMapStylePlugIn/trunk/src/org/openjump/ext/style/ImportArcMapStylePlugIn.java 2020-08-29 20:11:25 UTC (rev 6396) @@ -0,0 +1,193 @@ +//$HeadURL: https://svn.code.sf.net/p/jump-pilot/code/core/trunk/src/org/openjump/core/ui/plugin/style/ImportArcMapStylePlugIn.java $ +/*---------------- FILE HEADER ------------------------------------------ + This file is part of deegree. + Copyright (C) 2001-2007 by: + Department of Geography, University of Bonn + http://www.giub.uni-bonn.de/deegree/ + lat/lon GmbH + http://www.lat-lon.de + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Contact: + + Andreas Poth + lat/lon GmbH + Aennchenstr. 19 + 53177 Bonn + Germany + E-Mail: p...@lat-lon.de + + Prof. Dr. Klaus Greve + Department of Geography + University of Bonn + Meckenheimer Allee 166 + 53115 Bonn + Germany + E-Mail: gr...@giub.uni-bonn.de + ---------------------------------------------------------------------------*/ + +package org.openjump.ext.style; + +import static com.vividsolutions.jump.workbench.ui.MenuNames.LAYER; +import static com.vividsolutions.jump.workbench.ui.MenuNames.STYLE; +import static com.vividsolutions.jump.workbench.ui.plugin.PersistentBlackboardPlugIn.get; +import static java.io.File.createTempFile; +import static javax.swing.JFileChooser.APPROVE_OPTION; +import static javax.swing.JOptionPane.INFORMATION_MESSAGE; +import static javax.swing.JOptionPane.showMessageDialog; +import static javax.xml.parsers.DocumentBuilderFactory.newInstance; +import static org.openjump.core.ui.plugin.style.ImportSLDPlugIn.importSLD; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Locale; +import java.util.ResourceBundle; + +import javax.swing.JFileChooser; +import javax.xml.parsers.DocumentBuilderFactory; + +import org.w3c.dom.Document; + +import com.vividsolutions.jump.util.Blackboard; +import com.vividsolutions.jump.workbench.model.Layerable; +import com.vividsolutions.jump.workbench.plugin.AbstractPlugIn; +import com.vividsolutions.jump.workbench.plugin.EnableCheck; +import com.vividsolutions.jump.workbench.plugin.EnableCheckFactory; +import com.vividsolutions.jump.workbench.plugin.MultiEnableCheck; +import com.vividsolutions.jump.workbench.plugin.PlugInContext; +import com.vividsolutions.jump.workbench.ui.WorkbenchFrame; + +/** + * <code>ImportArcMapStylePlugIn</code> + * + * @author <a href="mailto:schm...@lat-lon.de">Andreas Schmitz</a> + * @author edso + * @author Michaël Michaud + */ +public class ImportArcMapStylePlugIn extends AbstractPlugIn { + + static ResourceBundle rb = + ResourceBundle.getBundle("org.openjump.ext.style.language.jump"); + + @Override + public void initialize(PlugInContext context) throws Exception { + EnableCheckFactory enableCheckFactory = new EnableCheckFactory(context.getWorkbenchContext()); + + EnableCheck enableCheck = new MultiEnableCheck().add( + enableCheckFactory.createWindowWithLayerManagerMustBeActiveCheck()).add( + enableCheckFactory.createExactlyNLayerablesMustBeSelectedCheck(1, Layerable.class)); + + context.getFeatureInstaller().addMainMenuItem(this, new String[] { LAYER, STYLE }, + rb.getString("ImportArcMapStylePlugIn.name"), false, null, enableCheck); + } + + private static File findArcMap2SLD(WorkbenchFrame wbframe, Blackboard bb) throws IOException, InterruptedException { + String arcmap2sld = (String) bb.get("ArcMapStylePlugin.toollocation"); + if (arcmap2sld == null) { + File tmp = createTempFile("amtsldreg", null); + ProcessBuilder pb = new ProcessBuilder("regedit", "/e", tmp.toString(), + "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion"); + pb.start().waitFor(); + BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(tmp), "UTF-16")); + String s; + while ((s = in.readLine()) != null) { + if (s.startsWith("\"ProgramFilesDir\"=\"")) { + s = s.split("=")[1]; + s = s.substring(1, s.length() - 1); + arcmap2sld = s + "\\i3mainz\\ArcMap2SLD_Full_Setup\\ArcGIS_SLD_Converter.exe"; + break; + } + } + in.close(); + tmp.delete(); + } + + JFileChooser chooser = new JFileChooser(); + + File am2sld = arcmap2sld == null ? null : new File(arcmap2sld); + if (am2sld == null || !am2sld.exists()) { + showMessageDialog(wbframe, + rb.getString("ImportArcMapStylePlugIn.Must-Select-Location-Of-Tool"), + rb.getString("ImportSLDPlugIn.Question"), INFORMATION_MESSAGE); + if (arcmap2sld != null) { + chooser.setSelectedFile(new File(arcmap2sld)); + } + + int res = chooser.showOpenDialog(wbframe); + if (res == APPROVE_OPTION) { + am2sld = chooser.getSelectedFile(); + if (!am2sld.exists()) { + return null; + } + bb.put("ArcMapStylePlugin.toollocation", am2sld.getAbsoluteFile().toString()); + } else { + return null; + } + } + + return am2sld; + } + + @Override + public boolean execute(PlugInContext context) throws Exception { + Blackboard bb = get(context.getWorkbenchContext()); + WorkbenchFrame wbframe = context.getWorkbenchFrame(); + + String fileName = (String) bb.get("ArcMapStylePlugin.filename"); + + File am2sld = findArcMap2SLD(wbframe, bb); + if (am2sld == null) { + return false; + } + + ProcessBuilder pb = new ProcessBuilder(am2sld.toString()); + pb.start().waitFor(); // unfortunately, the code seems to always be + // zero + + showMessageDialog(wbframe, + rb.getString("ImportArcMapStylePlugIn.Must-Select-Location-Of-SLD"), + rb.getString("ImportSLDPlugIn.Question"), INFORMATION_MESSAGE); + + JFileChooser chooser = new JFileChooser(); + + if (fileName != null) { + chooser.setCurrentDirectory(new File(fileName).getParentFile()); + } + + int res = chooser.showOpenDialog(context.getWorkbenchFrame()); + if (res == APPROVE_OPTION) { + File f = chooser.getSelectedFile(); + if (!f.exists()) { + return false; + } + bb.put("ArcMapStylePlugin.filename", f.getAbsoluteFile().toString()); + + DocumentBuilderFactory dbf = newInstance(); + dbf.setNamespaceAware(true); + Document doc = dbf.newDocumentBuilder().parse(f); + + importSLD(doc, context); + } + + return false; + } + + @Override + public String getName() { + return rb.getString("ImportArcMapStylePlugIn.name"); + } + +} Added: plug-ins/ImportArcMapStylePlugIn/trunk/src/org/openjump/ext/style/language/jump.properties =================================================================== --- plug-ins/ImportArcMapStylePlugIn/trunk/src/org/openjump/ext/style/language/jump.properties (rev 0) +++ plug-ins/ImportArcMapStylePlugIn/trunk/src/org/openjump/ext/style/language/jump.properties 2020-08-29 20:11:25 UTC (rev 6396) @@ -0,0 +1,6 @@ +ImportArcMapStylePlugIn.Must-Select-Location-Of-SLD = The next step is to select the SLD that was\n\ + \tgenerated by ArcMap2SLD. +ImportArcMapStylePlugIn.Must-Select-Location-Of-Tool = To be able to use the external program ArcMap2SLD,\n\ + \tplease specify its location in the following dialog. +ImportArcMapStylePlugIn.name = Import ArcMap Style +ImportSLDPlugIn.Question = Question \ No newline at end of file Added: plug-ins/ImportArcMapStylePlugIn/trunk/src/org/openjump/ext/style/language/jump_de.properties =================================================================== --- plug-ins/ImportArcMapStylePlugIn/trunk/src/org/openjump/ext/style/language/jump_de.properties (rev 0) +++ plug-ins/ImportArcMapStylePlugIn/trunk/src/org/openjump/ext/style/language/jump_de.properties 2020-08-29 20:11:25 UTC (rev 6396) @@ -0,0 +1,6 @@ +ImportArcMapStylePlugIn.Must-Select-Location-Of-SLD = Der n\u00E4chste Schritt ist, das von ArcMap2SLD generierte SLD\n\ + \tauszuw\u00E4hlen. +ImportArcMapStylePlugIn.Must-Select-Location-Of-Tool = Um das externe Programm ArcMap2SLD benutzen zu k\u00F6nnen,\n\ + \tgeben Sie im folgenden Dialog bitte dessen Ort an. +ImportArcMapStylePlugIn.name = ArcMap-Style importieren +ImportSLDPlugIn.Question = Frage \ No newline at end of file Added: plug-ins/ImportArcMapStylePlugIn/trunk/src/org/openjump/ext/style/language/jump_es.properties =================================================================== --- plug-ins/ImportArcMapStylePlugIn/trunk/src/org/openjump/ext/style/language/jump_es.properties (rev 0) +++ plug-ins/ImportArcMapStylePlugIn/trunk/src/org/openjump/ext/style/language/jump_es.properties 2020-08-29 20:11:25 UTC (rev 6396) @@ -0,0 +1,4 @@ +ImportArcMapStylePlugIn.Must-Select-Location-Of-SLD = El siguiente paso es seleccionar la SLD\nque se gener\u00f3 por ArcMap2SLD. +ImportArcMapStylePlugIn.Must-Select-Location-Of-Tool = Para poder utilizar el programa externo ArcMap2SLD, \npor favor, especificar su ubicaci\u00f3n en el siguiente cuadro de di\u00e1logo. +ImportArcMapStylePlugIn.name = Importaci\u00f3n ArcMap Estilo +ImportSLDPlugIn.Question = Question \ No newline at end of file Added: plug-ins/ImportArcMapStylePlugIn/trunk/src/org/openjump/ext/style/language/jump_fi.properties =================================================================== --- plug-ins/ImportArcMapStylePlugIn/trunk/src/org/openjump/ext/style/language/jump_fi.properties (rev 0) +++ plug-ins/ImportArcMapStylePlugIn/trunk/src/org/openjump/ext/style/language/jump_fi.properties 2020-08-29 20:11:25 UTC (rev 6396) @@ -0,0 +1,4 @@ +ImportArcMapStylePlugIn.Must-Select-Location-Of-SLD = Valitse seuraavaksi SLD-tyylitiedosto, joka on tehty ArcMap2SLD\:ll\u00e4. +ImportArcMapStylePlugIn.Must-Select-Location-Of-Tool = K\u00e4ytt\u00e4\u00e4ksesi ulkoista ArcMap2SLD-ohjelmaa,\n\tanna sen sijainti seuraavassa kyselyss\u00e4. +ImportArcMapStylePlugIn.name = Tuo ArcMap-tyylitiedosto +ImportSLDPlugIn.Question = Kysymys \ No newline at end of file Added: plug-ins/ImportArcMapStylePlugIn/trunk/src/org/openjump/ext/style/language/jump_fr.properties =================================================================== --- plug-ins/ImportArcMapStylePlugIn/trunk/src/org/openjump/ext/style/language/jump_fr.properties (rev 0) +++ plug-ins/ImportArcMapStylePlugIn/trunk/src/org/openjump/ext/style/language/jump_fr.properties 2020-08-29 20:11:25 UTC (rev 6396) @@ -0,0 +1,6 @@ +ImportArcMapStylePlugIn.Must-Select-Location-Of-SLD = L'étape suivante consiste à sélectionner le fichier SLD\n\ + \tgénéré par ArcMap2SLD. +ImportArcMapStylePlugIn.Must-Select-Location-Of-Tool = Pour utiliser le programme externe ArcMap2SLD,\n\ + \tindiquer son emplacement dans la boîte de dialogue suivante. +ImportArcMapStylePlugIn.name = Importer des styles ArcMap +ImportSLDPlugIn.Question = Question \ No newline at end of file Added: plug-ins/ImportArcMapStylePlugIn/trunk/src/org/openjump/ext/style/language/jump_it.properties =================================================================== --- plug-ins/ImportArcMapStylePlugIn/trunk/src/org/openjump/ext/style/language/jump_it.properties (rev 0) +++ plug-ins/ImportArcMapStylePlugIn/trunk/src/org/openjump/ext/style/language/jump_it.properties 2020-08-29 20:11:25 UTC (rev 6396) @@ -0,0 +1,4 @@ +ImportArcMapStylePlugIn.Must-Select-Location-Of-SLD = Il prossimo passo \u00e8 selezionare il SLD \ngenerato da ArcMap2SLD +ImportArcMapStylePlugIn.Must-Select-Location-Of-Tool = Per poter utilizzare il programma esterno ArcMap2SLD,\nper favore specifica la sua ubicazione nel dialogo succesivo. +ImportArcMapStylePlugIn.name = Importa stile ArcMap +ImportSLDPlugIn.Question = Question \ No newline at end of file _______________________________________________ Jump-pilot-devel mailing list Jump-pilot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel