Changes between Initial Version and Version 1 of Ru:Help/Preferences/ImportExport


Ignore:
Timestamp:
2017-11-17T11:39:31+01:00 (8 years ago)
Author:
ak099
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Ru:Help/Preferences/ImportExport

    v1 v1  
     1[[TranslatedPages(revision=1)]]
     2= Пользовательские конфигурационные XML-файлы для JOSM =
     3== Примеры (см. комментарии в XML) ==
     4* Примеры по категориям [attachment:scripts.zip:ticket:4421 scripts.zip]
     5* Установка заготовок и стилей: [attachment:seamap.xml:ticket:4421 seamap.xml],
     6 [attachment:seamap_ForOfflineInstallation.zip:ticket:4421 seamap_ForOfflineInstallation.zip]
     7* Слой подложек, модуль и настройка параметров (пока только на русском языке): [attachment:forestMapping.xml:ticket:4421 forestMapping.xml]
     8
     9=== Команды добавления или замены настроек ===
     10
     11Следующий код добавляет ещё одну подложку в список:
     12{{{#!xml
     13<config>
     14<preferences operation="append">
     15    <!-- Любой фрагмент preferences.xml может быть использован здесь -->
     16    <tag key="download.autorun" value="true"/> <!-- пример простого изменения настройки - download.autorun := true -->
     17    <maps key="imagery.entries">
     18      <map>
     19        <tag key="name" value="ScanEx IRS"/>
     20        <tag key="type" value="scanex"/>
     21        <tag key="url" value="IRS"/>
     22        <tag key="attribution-text" value="IRS"/>
     23        <tag key="attribution-url" value="http://irs.gis-lab.info/"/>
     24      </map>
     25    </maps>
     26</preferences>
     27</config>
     28}}}
     29
     30Если взамен исплользуется '''<preferences operation="replace">''', то все другие элементы <map> будут  __удалены__ из '''imagery.entries''' !
     31
     32Ещё один пример:
     33{{{#!xml
     34<config>
     35  <preferences operation="replace"> <!-- старое содержимое draw.anglesnap.angles будет удалено -->
     36     <list key="draw.anglesnap.angles">
     37       <entry value="30"/>
     38       <entry value="45"/>
     39       <entry value="60"/>
     40     </list>
     41   </preferences>
     42</config>
     43}}}
     44
     45=== Операции с файлами - скачивание удаление, распаковка из zip-архива ===
     46{{{#!xml
     47<config>
     48  <delete path="plugins/tmp"/>
     49  <!-- рекурсивное удаление plugins/tmp из каталога настроек -->
     50  <!-- base="prefs" - удалить из папки настроек; base="plugins" - удалить из папки plugins; base ="cache" - удалить из папке кэша -->
     51 
     52  <delete path="splug" base="plugins"/>
     53  <!-- рекурсивное удаление папки splug из каталога настроек -->
     54 
     55  <!--<delete path="." base="cache"/> удалить папку кэша -->
     56
     57  <download url="http://svn.openstreetmap.org/applications/editors/josm/dist/buildings_tools.jar" path="plugins/tmp/bt.jar" mkdir="true" unzip="true"/>
     58  <!-- скачать файл из url и поместить как "path"; если mkdir="true", то все необходимые каталоги будут созданы; если unzip="true", то файл zip/jar будет распакован и затем удалён -->
     59
     60  <download url="http://wiki.openstreetmap.org/w/images/7/79/Public-images-osm_logo.svg" path="1/logo.svg" mkdir="true" base="cache"/>
     61
     62  <download url="file://localhost/e:/a.zip" path="qqq/a.zip" unzip="true" mkdir="true"/>
     63  <!-- копировать из локальной папки и распаковать архив -->
     64</config>
     65}}}
     66
     67=== Операции с модулями: установка, отключение, удаление ===
     68{{{#!xml
     69<config>
     70<!-- установить модули и убрать их без удаления  plastic_laf.jar -->
     71   <plugin install="buildings_tools;wayselector" remove="plastic_laf"/>
     72   <plugin delete="proj4j"/> <!-- отключить модуль и удалить jar -->
     73</config>
     74}}}
     75
     76=== Переменные, окна сообщений и запрос пользователя ===
     77{{{#!xml
     78<config>
     79  <ask var="r" text="Choose something, please!" options="0;1;2"/>
     80  <messagebox text="You choose ${r}" type="i"/>
     81  <if test="${r==0}">
     82     <messagebox text="r=0!"/>
     83  </if>
     84  <else>
     85     <messagebox text="no, r!=0 - r=${r} actually!"/>
     86  </else>
     87  <if test="${r==1 || r==2}">
     88     <messagebox text="r=1 or 2!"/>
     89  </if>
     90  <if test="${r!=2 && r!=0}">
     91    <messagebox text="It is not 0, it is not 2 , so it is = 1!"/>
     92  </if>
     93  <if test="${r!=2}">
     94    <break/>
     95  </if>
     96  <ask var="r" text="Choose something, please!" options="A;B"/>
     97  <messagebox text="You choose button number ${r}" type="i"/>
     98</config>
     99}}}
     100
     101=== JavaScript API ===
     102{{{#!xml
     103<config>
     104<script><![CDATA[
     105  API.messageBox('i','Hello!');
     106  txt = API.askText("Enter something...");
     107  i = API.askOption("Select background color","red;green;black");
     108  if (i==0) API.pref['color.background']="#770000";
     109  if (i==1) API.pref['color.background']="#007700";
     110  if (i==2) API.pref['color.background']="#000000";
     111  color = API.pref['color.background'];
     112  API.messageBox('i',"<html><span color='"+color+"'> You entered "+txt+"</span></html>");
     113  if ( API.askOption("Do you want to test downloading and plugins?","") == 0 ) {
     114     // "" in askOption means Yes/No dialog
     115     API.downloadFile("http://svn.openstreetmap.org/applications/editors/josm/dist/buildings_tools.jar",
     116          "1/2/a.jar","cache");
     117     API.downloadAndUnpackFile("http://svn.openstreetmap.org/applications/editors/josm/dist/buildings_tools.jar",
     118          "1/2a/a.jar","cache");
     119     if( API.askOption("Do you want to delete downloaded files?","") == 0) {
     120        API.deleteFile("1","cache");
     121     }
     122     API.pluginInstall("AlignWays");
     123     if( API.askOption("Do you want to uninstall utilsplugin2","") == 0) {
     124        API.pluginUninstall("utilsplugin2");
     125        }
     126   }
     127   importPackage(org.openstreetmap.josm.data);
     128   CustomConfigurator.exportPreferencesKeysByPatternToFile ("e:/config.xml", true, ".*");
     129   //println(JSON.stringify(API.prefs)); // JSON works only on JDK1.7 //println(JSON.stringify(API.fragments)); // JSON works only on JDK1.7 ]]>
     130</script>
     131</config>
     132}}}
     133
     134== Смотрите также ==
     135* Обсуждение разработки: #4421
     136
     137----
     138Назад к [wiki:Ru:Help Основной странице справки]