OSDN Git Service

ファイル名の禁則文字置換ルールをコンフィグへ定義
authoryuki <yuki@bdf3b611-c98c-6041-8292-703d9c9adbe7>
Mon, 19 Apr 2010 12:41:46 +0000 (12:41 +0000)
committeryuki <yuki@bdf3b611-c98c-6041-8292-703d9c9adbe7>
Mon, 19 Apr 2010 12:41:46 +0000 (12:41 +0000)
git-svn-id: http://192.168.11.7/svn/repository/NicoBrowser/branches/dev20100419_filename@310 bdf3b611-c98c-6041-8292-703d9c9adbe7

src/nicobrowser/Config.java
src/nicobrowser/gui/config/ConfigFrame.form
src/nicobrowser/gui/config/ConfigFrame.java

index fd11219..d5c895e 100644 (file)
@@ -57,7 +57,9 @@ public final class Config {
     private static final File FEEDURL_FILE = new File(APP_HOME, FEEDURL_NAME);
     public static final String P_PATH_DB = "path.db";
     public static final String P_PATH_SAVEFILE = "path.savefile";
-    public static final String P_SAVEFILE_PATTERN = "savefile.pattern";
+    public static final String P_SAVEFILE_PATTERN = "savefilename.pattern";
+    public static final String P_SAVEFILE_REPLACE_FROM = "savefilename.replace.from";
+    public static final String P_SAVEFILE_REPLACE_TO = "savefilename.replace.to";
     public static final String P_FILE_ENCODING = "encoding";
     public static final String P_NICOVIDEO_MAIL = "nicovideo.mail";
     public static final String P_NICOVIDEO_PASSWORD = "nicovideo.password";
@@ -110,6 +112,8 @@ public final class Config {
         updatePropertyValue(p, P_PATH_DB);
         updatePropertyValue(p, P_PATH_SAVEFILE);
         updatePropertyValue(p, P_SAVEFILE_PATTERN);
+        updatePropertyValue(p, P_SAVEFILE_REPLACE_FROM);
+        updatePropertyValue(p, P_SAVEFILE_REPLACE_TO);
 
         updatePropertyValue(p, P_DOWNLOAD_RETRY);
         updatePropertyValue(p, P_DOWNLOAD_WAIT);
@@ -159,6 +163,8 @@ public final class Config {
         props.add(savepath);
 
         props.add(P_SAVEFILE_PATTERN + "={title}");
+        props.add(P_SAVEFILE_REPLACE_FROM + "=\\/\\\\:*?\"<>|.");
+        props.add(P_SAVEFILE_REPLACE_TO + "=_");
 
         props.add(P_FILE_ENCODING + "=" + System.getProperty("file.encoding"));
 
@@ -237,6 +243,14 @@ public final class Config {
         return properties.getString(P_SAVEFILE_PATTERN, "{title}");
     }
 
+    public String getFileNameReplaceFrom(){
+        return properties.getString(P_SAVEFILE_REPLACE_FROM, "=\\/\\\\:*?\"<>|.");
+    }
+
+    public String getFileNameReplaceTo(){
+        return properties.getString(P_SAVEFILE_REPLACE_TO, "_");
+    }
+
     /** @return feedurl.txtの文字エンコーディング. */
     public String getEncoding() {
         String res = properties.getString(P_FILE_ENCODING, System.getProperty("file.encoding"));
index bd403e1..794f58e 100644 (file)
       <Layout>
         <DimensionLayout dim="0">
           <Group type="103" groupAlignment="0" attributes="0">
-              <Group type="102" alignment="1" attributes="0">
-                  <Group type="103" groupAlignment="1" attributes="0">
-                      <Component id="jScrollPane1" alignment="0" pref="452" max="32767" attributes="0"/>
-                      <Component id="fileNamePatternField" alignment="1" pref="452" max="32767" attributes="0"/>
+              <Group type="102" attributes="0">
+                  <Group type="103" groupAlignment="0" attributes="0">
+                      <Component id="namePatternScroll" alignment="0" pref="452" max="32767" attributes="0"/>
+                      <Group type="102" alignment="1" attributes="0">
+                          <Component id="namePatternLabel" min="-2" max="-2" attributes="0"/>
+                          <EmptySpace max="-2" attributes="0"/>
+                          <Component id="namePatternField" pref="399" max="32767" attributes="0"/>
+                      </Group>
+                      <Group type="102" alignment="0" attributes="0">
+                          <Group type="103" groupAlignment="0" attributes="0">
+                              <Component id="replaceToLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+                              <Component id="replaceFromLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+                          </Group>
+                          <EmptySpace max="-2" attributes="0"/>
+                          <Group type="103" groupAlignment="0" attributes="0">
+                              <Component id="replaceFromField" alignment="0" pref="371" max="32767" attributes="0"/>
+                              <Component id="replaceToField" alignment="0" pref="371" max="32767" attributes="0"/>
+                          </Group>
+                      </Group>
                   </Group>
                   <EmptySpace max="-2" attributes="0"/>
               </Group>
         <DimensionLayout dim="1">
           <Group type="103" groupAlignment="0" attributes="0">
               <Group type="102" alignment="0" attributes="0">
-                  <Component id="fileNamePatternField" min="-2" max="-2" attributes="0"/>
+                  <Group type="103" groupAlignment="3" attributes="0">
+                      <Component id="namePatternField" alignment="3" min="-2" max="-2" attributes="0"/>
+                      <Component id="namePatternLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+                  </Group>
+                  <EmptySpace max="-2" attributes="0"/>
+                  <Component id="namePatternScroll" min="-2" pref="71" max="-2" attributes="0"/>
+                  <EmptySpace max="-2" attributes="0"/>
+                  <Group type="103" groupAlignment="3" attributes="0">
+                      <Component id="replaceFromLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+                      <Component id="replaceFromField" alignment="3" min="-2" max="-2" attributes="0"/>
+                  </Group>
                   <EmptySpace max="-2" attributes="0"/>
-                  <Component id="jScrollPane1" min="-2" pref="71" max="-2" attributes="0"/>
+                  <Group type="103" groupAlignment="3" attributes="0">
+                      <Component id="replaceToLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+                      <Component id="replaceToField" alignment="3" min="-2" max="-2" attributes="0"/>
+                  </Group>
+                  <EmptySpace max="32767" attributes="0"/>
               </Group>
           </Group>
         </DimensionLayout>
       </Layout>
       <SubComponents>
-        <Component class="javax.swing.JTextField" name="fileNamePatternField">
+        <Component class="javax.swing.JTextField" name="namePatternField">
         </Component>
-        <Container class="javax.swing.JScrollPane" name="jScrollPane1">
+        <Container class="javax.swing.JScrollPane" name="namePatternScroll">
           <AuxValues>
             <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
           </AuxValues>
 
           <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
           <SubComponents>
-            <Component class="javax.swing.JTextArea" name="jTextArea1">
+            <Component class="javax.swing.JTextArea" name="namePatternArea">
               <Properties>
                 <Property name="columns" type="int" value="20"/>
                 <Property name="editable" type="boolean" value="false"/>
             </Component>
           </SubComponents>
         </Container>
+        <Component class="javax.swing.JLabel" name="namePatternLabel">
+          <Properties>
+            <Property name="text" type="java.lang.String" value="&#x547d;&#x540d;&#x898f;&#x5247;"/>
+          </Properties>
+        </Component>
+        <Component class="javax.swing.JLabel" name="replaceFromLabel">
+          <Properties>
+            <Property name="text" type="java.lang.String" value="&#x7f6e;&#x63db;&#x5bfe;&#x8c61;&#x6587;&#x5b57;"/>
+          </Properties>
+        </Component>
+        <Component class="javax.swing.JLabel" name="replaceToLabel">
+          <Properties>
+            <Property name="text" type="java.lang.String" value="&#x3053;&#x306e;&#x6587;&#x5b57;&#x306b;&#x7f6e;&#x63db;"/>
+          </Properties>
+        </Component>
+        <Component class="javax.swing.JTextField" name="replaceFromField">
+        </Component>
+        <Component class="javax.swing.JTextField" name="replaceToField">
+        </Component>
       </SubComponents>
     </Container>
   </SubComponents>
index 90416fd..7021404 100644 (file)
@@ -44,8 +44,12 @@ public class ConfigFrame extends javax.swing.JFrame {
 
         // ファイル名 命名規則
         String filePattern = config.getFileNamePattern();
-        fileNamePatternField.setText(filePattern);
-        jTextArea1.setCaretPosition(0);
+        namePatternField.setText(filePattern);
+        namePatternArea.setCaretPosition(0);
+        String replaceFrom = config.getFileNameReplaceFrom();
+        replaceFromField.setText(replaceFrom);
+        String replaceTo = config.getFileNameReplaceTo();
+        replaceToField.setText(replaceTo);
 
         // 動作
         waitSpinner.setValue(config.getWaitTime());
@@ -89,9 +93,14 @@ public class ConfigFrame extends javax.swing.JFrame {
         jPanel5 = new javax.swing.JPanel();
         savaButton = new javax.swing.JButton();
         jPanel6 = new javax.swing.JPanel();
-        fileNamePatternField = new javax.swing.JTextField();
-        jScrollPane1 = new javax.swing.JScrollPane();
-        jTextArea1 = new javax.swing.JTextArea();
+        namePatternField = new javax.swing.JTextField();
+        namePatternScroll = new javax.swing.JScrollPane();
+        namePatternArea = new javax.swing.JTextArea();
+        namePatternLabel = new javax.swing.JLabel();
+        replaceFromLabel = new javax.swing.JLabel();
+        replaceToLabel = new javax.swing.JLabel();
+        replaceFromField = new javax.swing.JTextField();
+        replaceToField = new javax.swing.JTextField();
 
         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
         setTitle("NicoBrowser - コンフィグ設定");
@@ -285,28 +294,56 @@ public class ConfigFrame extends javax.swing.JFrame {
 
         jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder("ファイル名規則"));
 
-        jTextArea1.setColumns(20);
-        jTextArea1.setEditable(false);
-        jTextArea1.setRows(5);
-        jTextArea1.setText("{title}: 動画タイトル\n{id}: ニコニコ動画ID\n{low}: エコノミー動画であれば\"low\"の文字列、通常動画は空文字列\n【具体例】\n[{id}]{title} (さきゅばす互換)\n{id}{low}_{title} (NicoCache互換)");
-        jScrollPane1.setViewportView(jTextArea1);
+        namePatternArea.setColumns(20);
+        namePatternArea.setEditable(false);
+        namePatternArea.setRows(5);
+        namePatternArea.setText("{title}: 動画タイトル\n{id}: ニコニコ動画ID\n{low}: エコノミー動画であれば\"low\"の文字列、通常動画は空文字列\n【具体例】\n[{id}]{title} (さきゅばす互換)\n{id}{low}_{title} (NicoCache互換)");
+        namePatternScroll.setViewportView(namePatternArea);
+
+        namePatternLabel.setText("命名規則");
+
+        replaceFromLabel.setText("置換対象文字");
+
+        replaceToLabel.setText("この文字に置換");
 
         org.jdesktop.layout.GroupLayout jPanel6Layout = new org.jdesktop.layout.GroupLayout(jPanel6);
         jPanel6.setLayout(jPanel6Layout);
         jPanel6Layout.setHorizontalGroup(
             jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel6Layout.createSequentialGroup()
-                .add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
-                    .add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 452, Short.MAX_VALUE)
-                    .add(fileNamePatternField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 452, Short.MAX_VALUE))
+            .add(jPanel6Layout.createSequentialGroup()
+                .add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                    .add(namePatternScroll, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 452, Short.MAX_VALUE)
+                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel6Layout.createSequentialGroup()
+                        .add(namePatternLabel)
+                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                        .add(namePatternField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 399, Short.MAX_VALUE))
+                    .add(jPanel6Layout.createSequentialGroup()
+                        .add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                            .add(replaceToLabel)
+                            .add(replaceFromLabel))
+                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                        .add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                            .add(replaceFromField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 371, Short.MAX_VALUE)
+                            .add(replaceToField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 371, Short.MAX_VALUE))))
                 .addContainerGap())
         );
         jPanel6Layout.setVerticalGroup(
             jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
             .add(jPanel6Layout.createSequentialGroup()
-                .add(fileNamePatternField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+                    .add(namePatternField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                    .add(namePatternLabel))
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(namePatternScroll, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 71, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 71, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+                .add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+                    .add(replaceFromLabel)
+                    .add(replaceFromField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+                    .add(replaceToLabel)
+                    .add(replaceToField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
         );
 
         org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
@@ -359,6 +396,9 @@ public class ConfigFrame extends javax.swing.JFrame {
 
         p.setProperty(Config.P_PATH_DB, dbPathField.getText());
         p.setProperty(Config.P_PATH_SAVEFILE, flvPathField.getText());
+        p.setProperty(Config.P_SAVEFILE_PATTERN, namePatternField.getText());
+        p.setProperty(Config.P_SAVEFILE_REPLACE_FROM, replaceFromField.getText());
+        p.setProperty(Config.P_SAVEFILE_REPLACE_TO, replaceToField.getText());
 
         p.setProperty(Config.P_DOWNLOAD_WAIT, waitSpinner.getValue().toString());
         p.setProperty(Config.P_DOWNLOAD_RETRY, retrySpinner.getValue().toString());
@@ -411,7 +451,6 @@ public class ConfigFrame extends javax.swing.JFrame {
     private javax.swing.JTextField dbPathField;
     private javax.swing.JTextField feedFileField;
     private javax.swing.JLabel feedFileLabel;
-    private javax.swing.JTextField fileNamePatternField;
     private javax.swing.JButton flvPathButton;
     private javax.swing.JTextField flvPathField;
     private javax.swing.JTextField idField;
@@ -427,11 +466,17 @@ public class ConfigFrame extends javax.swing.JFrame {
     private javax.swing.JPanel jPanel4;
     private javax.swing.JPanel jPanel5;
     private javax.swing.JPanel jPanel6;
-    private javax.swing.JScrollPane jScrollPane1;
-    private javax.swing.JTextArea jTextArea1;
     private javax.swing.JCheckBox lowDownloadCheckBox;
+    private javax.swing.JTextArea namePatternArea;
+    private javax.swing.JTextField namePatternField;
+    private javax.swing.JLabel namePatternLabel;
+    private javax.swing.JScrollPane namePatternScroll;
     private javax.swing.JPasswordField passField;
     private javax.swing.JLabel passLabel;
+    private javax.swing.JTextField replaceFromField;
+    private javax.swing.JLabel replaceFromLabel;
+    private javax.swing.JTextField replaceToField;
+    private javax.swing.JLabel replaceToLabel;
     private javax.swing.JSpinner retrySpinner;
     private javax.swing.JButton savaButton;
     private javax.swing.JSpinner waitSpinner;