キャラクターなんとかJの本体
Revision | c2f484e8955f938c47c7c23e72f16ccbe494563f (tree) |
---|---|
Time | 2019-02-06 02:02:02 |
Author | seraphy <seraphy@user...> |
Commiter | seraphy |
プロファイル作成時にデフォルトのキャラクターデータのダウンロードを問い合わせる
および、HiDPI対応、リソース文字列漏れ、リファクタなど。
@@ -1559,4 +1559,37 @@ public final class AppConfig { | ||
1559 | 1559 | propChangeSupport.firePropertyChange(USE_RLE_COMPRESSION_FOR_PSD, old, useRLECompressionForPSD); |
1560 | 1560 | } |
1561 | 1561 | } |
1562 | + | |
1563 | + private String impersonateUserAgent = "curl/7.58.0"; | |
1564 | + | |
1565 | + private static final String IMPERSONATE_USER_AGENT = "impersonateUserAgent"; | |
1566 | + | |
1567 | + public String getImpersonateUserAgent() { | |
1568 | + return impersonateUserAgent; | |
1569 | + } | |
1570 | + | |
1571 | + public void setImpersonateUserAgent(String impersonateUserAgent) { | |
1572 | + String old = this.impersonateUserAgent; | |
1573 | + this.impersonateUserAgent = impersonateUserAgent; | |
1574 | + if (old == null ? impersonateUserAgent != null : !old.equals(impersonateUserAgent)) { | |
1575 | + this.impersonateUserAgent = impersonateUserAgent; | |
1576 | + propChangeSupport.firePropertyChange(IMPERSONATE_USER_AGENT, old, impersonateUserAgent); | |
1577 | + } | |
1578 | + } | |
1579 | + | |
1580 | + private boolean deleteDownloadFileOnExit = true; | |
1581 | + | |
1582 | + private static final String DELETE_DOWNLOAD_FILE_ON_EXIT = "deleteDownloadFileOnExit"; | |
1583 | + | |
1584 | + public boolean isDeleteDownloadFileOnExit() { | |
1585 | + return deleteDownloadFileOnExit; | |
1586 | + } | |
1587 | + | |
1588 | + public void setDeleteDownloadFileOnExit(boolean deleteDownloadFileOnExit) { | |
1589 | + boolean old = this.deleteDownloadFileOnExit; | |
1590 | + if (old != deleteDownloadFileOnExit) { | |
1591 | + this.deleteDownloadFileOnExit = deleteDownloadFileOnExit; | |
1592 | + propChangeSupport.firePropertyChange(DELETE_DOWNLOAD_FILE_ON_EXIT, old, deleteDownloadFileOnExit); | |
1593 | + } | |
1594 | + } | |
1562 | 1595 | } |
@@ -770,6 +770,21 @@ public class CharacterData implements PartsSpecResolver { | ||
770 | 770 | } |
771 | 771 | |
772 | 772 | /** |
773 | + * 全カテゴリー中のパーツデータの個数を取得する。 | |
774 | + * @return パーツの個数 | |
775 | + */ | |
776 | + public int getPartsCount() { | |
777 | + int cnt = 0; | |
778 | + for (PartsCategory category : partsCategories.asList()) { | |
779 | + Map<PartsIdentifier, PartsSpec> partsMap = images.get(category); | |
780 | + if (partsMap != null) { | |
781 | + cnt += partsMap.size(); | |
782 | + } | |
783 | + } | |
784 | + return cnt; | |
785 | + } | |
786 | + | |
787 | + /** | |
773 | 788 | * パーツデータをリロードする.<br> |
774 | 789 | * ロード時に使用したローダーを使ってパーツを再ロードします.<br> |
775 | 790 | * まだ一度もロードしていない場合はIllegalStateException例外が発生します.<br> |
@@ -80,6 +80,11 @@ public class IndependentWorkingSet { | ||
80 | 80 | */ |
81 | 81 | private Rectangle windowRect; |
82 | 82 | |
83 | + /** | |
84 | + * ダウンロード不要フラグ | |
85 | + */ | |
86 | + private boolean noNeedDataDownload; | |
87 | + | |
83 | 88 | |
84 | 89 | public void setCharacterDocBase(URI characterDocBase) { |
85 | 90 | this.characterDocBase = characterDocBase; |
@@ -178,6 +183,14 @@ public class IndependentWorkingSet { | ||
178 | 183 | this.lastUsePresetParts = lastUsePresetParts; |
179 | 184 | } |
180 | 185 | |
186 | + public boolean isNoNeedDataDownload() { | |
187 | + return noNeedDataDownload; | |
188 | + } | |
189 | + | |
190 | + public void setNoNeedDataDownload(boolean noNeedDataDownload) { | |
191 | + this.noNeedDataDownload = noNeedDataDownload; | |
192 | + } | |
193 | + | |
181 | 194 | /** |
182 | 195 | * キャラクターデータを指定して、指定されたキャラクターデータ上のインスタンスと関連づけられた |
183 | 196 | * カテゴリおよびパーツ名などのインスタンスで構成されるパーツ識別名とカラー情報を、 引数で指定したマップに出力する. |
@@ -229,6 +242,7 @@ public class IndependentWorkingSet { | ||
229 | 242 | buf.append(", currentPartsSet=").append(currentPartsSet); |
230 | 243 | buf.append(", lastUsedSaveDir=").append(lastUsedSaveDir); |
231 | 244 | buf.append(", lastUsedExportDir=").append(lastUsedExportDir); |
245 | + buf.append(", noNeedDataDownload=").append(noNeedDataDownload); | |
232 | 246 | buf.append(")"); |
233 | 247 | return buf.toString(); |
234 | 248 | } |
@@ -58,6 +58,11 @@ public class WorkingSet { | ||
58 | 58 | */ |
59 | 59 | private Rectangle windowRect; |
60 | 60 | |
61 | + /** | |
62 | + * データのダウンロードが不要である | |
63 | + */ | |
64 | + private boolean noNeedDataDownload; | |
65 | + | |
61 | 66 | public void setCharacterDataRev(String characterDataRev) { |
62 | 67 | this.characterDataRev = characterDataRev; |
63 | 68 | } |
@@ -200,6 +205,14 @@ public class WorkingSet { | ||
200 | 205 | this.windowRect = windowRect; |
201 | 206 | } |
202 | 207 | |
208 | + public boolean isNoNeedDataDownload() { | |
209 | + return noNeedDataDownload; | |
210 | + } | |
211 | + | |
212 | + public void setNoNeedDataDownload(boolean noNeedDataDownload) { | |
213 | + this.noNeedDataDownload = noNeedDataDownload; | |
214 | + } | |
215 | + | |
203 | 216 | @Override |
204 | 217 | public String toString() { |
205 | 218 | return "docBase:" + characterDocBase + "/rev:" + characterDataRev; |
@@ -12,11 +12,11 @@ public class CharacterDataFileReaderWriterFactory { | ||
12 | 12 | private CharacterDataFileReaderWriterFactory() { |
13 | 13 | super(); |
14 | 14 | } |
15 | - | |
15 | + | |
16 | 16 | public static CharacterDataFileReaderWriterFactory getInstance() { |
17 | 17 | return singleton; |
18 | 18 | } |
19 | - | |
19 | + | |
20 | 20 | /** |
21 | 21 | * ファイルの拡張子に応じてzip/cmj形式でのライターを構築して帰します.<br> |
22 | 22 | * 拡張子がjarとcmjは同じ意味で、ともにjarファイル形式となります.<br> |
@@ -29,7 +29,7 @@ public class CharacterDataFileReaderWriterFactory { | ||
29 | 29 | if (outfile == null) { |
30 | 30 | throw new IllegalArgumentException(); |
31 | 31 | } |
32 | - | |
32 | + | |
33 | 33 | String name = outfile.getName().toLowerCase(); |
34 | 34 | if (name.endsWith(".jar") || name.endsWith(".cmj")) { |
35 | 35 | return new CharacterDataJarFileWriter(outfile); |
@@ -37,10 +37,10 @@ public class CharacterDataFileReaderWriterFactory { | ||
37 | 37 | } else if (name.endsWith(".zip")) { |
38 | 38 | return new CharacterDataZipFileWriter(outfile); |
39 | 39 | } |
40 | - | |
40 | + | |
41 | 41 | throw new IOException("unsupported file type: " + name); |
42 | 42 | } |
43 | - | |
43 | + | |
44 | 44 | public CharacterDataArchiveFile openArchive(URI archiveFile) throws IOException { |
45 | 45 | if (archiveFile == null) { |
46 | 46 | throw new IllegalArgumentException(); |
@@ -55,8 +55,8 @@ public class CharacterDataFileReaderWriterFactory { | ||
55 | 55 | // file以外は現在のところサポートしない。 |
56 | 56 | throw new UnsupportedOperationException(); |
57 | 57 | } |
58 | - | |
59 | - | |
58 | + | |
59 | + | |
60 | 60 | public CharacterDataArchiveFile openArchive(File archiveFile) throws IOException { |
61 | 61 | if (archiveFile == null) { |
62 | 62 | throw new IllegalArgumentException(); |
@@ -66,7 +66,7 @@ public class CharacterDataFileReaderWriterFactory { | ||
66 | 66 | // ディレクトリの場合 |
67 | 67 | return new CharacterDataDirectoryFile(archiveFile); |
68 | 68 | } |
69 | - | |
69 | + | |
70 | 70 | // zipまたはcmjファイルの場合 |
71 | 71 | String name = archiveFile.getName().toLowerCase(); |
72 | 72 | if (name.endsWith(".jar") || name.endsWith(".cmj")) { |
@@ -75,8 +75,20 @@ public class CharacterDataFileReaderWriterFactory { | ||
75 | 75 | } else if (name.endsWith(".zip")) { |
76 | 76 | return new CharacterDataZipArchiveFile(archiveFile); |
77 | 77 | } |
78 | - | |
78 | + | |
79 | 79 | throw new IOException("unsupported file type: " + name); |
80 | 80 | } |
81 | - | |
81 | + | |
82 | + /** | |
83 | + * ファイルの拡張子からアーカイブとしてサポートされているタイプであるか判断する | |
84 | + * @param fileName ファイル名 | |
85 | + * @return サポートされている場合はtrue、そうでなければfalse | |
86 | + */ | |
87 | + public boolean isSupportedFile(String fileName) { | |
88 | + if (fileName != null) { | |
89 | + fileName = fileName.toLowerCase(); | |
90 | + return fileName.endsWith(".zip") || fileName.endsWith(".jar") || fileName.endsWith(".cmj"); | |
91 | + } | |
92 | + return false; | |
93 | + } | |
82 | 94 | } |
@@ -210,6 +210,8 @@ public class WorkingSetPersist { | ||
210 | 210 | ws.setZoomFactor(workingSet2.getZoomFactor()); |
211 | 211 | ws.setViewPosition(workingSet2.getViewPosition()); |
212 | 212 | ws.setWindowRect(workingSet2.getWindowRect()); |
213 | + | |
214 | + ws.setNoNeedDataDownload(workingSet2.isNoNeedDataDownload()); | |
213 | 215 | |
214 | 216 | return ws; |
215 | 217 | } |
@@ -229,6 +229,15 @@ public class WorkingSetXMLReader { | ||
229 | 229 | break; // 最初の一要素のみ |
230 | 230 | } |
231 | 231 | |
232 | + // ダウンロード不要フラグ | |
233 | + boolean noNeedDataDownload = false; | |
234 | + for (Element noNeedDataDownloadElm : getChildElements(docElm, | |
235 | + "noNeedDataDownload")) { | |
236 | + noNeedDataDownload = Boolean.parseBoolean(noNeedDataDownloadElm.getTextContent()); | |
237 | + break; // 最初の一要素のみ | |
238 | + } | |
239 | + workingSet.setNoNeedDataDownload(noNeedDataDownload); | |
240 | + | |
232 | 241 | return workingSet; |
233 | 242 | |
234 | 243 | } catch (RuntimeException ex) { |
@@ -206,6 +206,13 @@ public class WorkingSetXMLWriter { | ||
206 | 206 | // ズーム情報等 |
207 | 207 | root.appendChild(writeViewSettings(doc, ws.getZoomFactor(), ws.getViewPosition(), ws.getWindowRect())); |
208 | 208 | |
209 | + // データダウンロード不要フラグ | |
210 | + if (ws.isNoNeedDataDownload()) { | |
211 | + Element noNeedDataDownloadElm = doc.createElement("noNeedDataDownload"); | |
212 | + noNeedDataDownloadElm.setTextContent(Boolean.toString(ws.isNoNeedDataDownload())); | |
213 | + root.appendChild(noNeedDataDownloadElm); | |
214 | + } | |
215 | + | |
209 | 216 | doc.appendChild(root); |
210 | 217 | return doc; |
211 | 218 | } |
@@ -156,12 +156,15 @@ public class ExportWizardDialog extends JDialog { | ||
156 | 156 | |
157 | 157 | // メインパネル |
158 | 158 | |
159 | + ScaleSupport scaleSupport = ScaleSupport.getInstance(this); | |
160 | + | |
159 | 161 | Container contentPane = getContentPane(); |
160 | 162 | contentPane.setLayout(new BorderLayout()); |
161 | 163 | |
162 | 164 | final JPanel mainPanel = new JPanel(); |
163 | 165 | mainPanel.setBorder(BorderFactory.createEtchedBorder()); |
164 | - final CardLayout mainPanelLayout = new CardLayout(5, 5); | |
166 | + int mergin = (int)(5 * scaleSupport.getManualScaleX()); | |
167 | + final CardLayout mainPanelLayout = new CardLayout(mergin, mergin); | |
165 | 168 | mainPanel.setLayout(mainPanelLayout); |
166 | 169 | contentPane.add(mainPanel, BorderLayout.CENTER); |
167 | 170 |
@@ -212,14 +215,14 @@ public class ExportWizardDialog extends JDialog { | ||
212 | 215 | }; |
213 | 216 | |
214 | 217 | // panel1 : basic |
215 | - this.basicPanel = new ExportInformationPanel(characterData, samplePicture); | |
218 | + this.basicPanel = new ExportInformationPanel(characterData, samplePicture, scaleSupport); | |
216 | 219 | this.basicPanel.addComponentListener(componentListener); |
217 | 220 | this.basicPanel.addChangeListener(actChangeValue); |
218 | 221 | this.basicPanel.addChangeListener(actPanelEnabler); |
219 | 222 | mainPanel.add(this.basicPanel, "basicPanel"); |
220 | 223 | |
221 | 224 | // panel2 : panelSelectPanel |
222 | - this.partsSelectPanel = new ExportPartsSelectPanel(characterData); | |
225 | + this.partsSelectPanel = new ExportPartsSelectPanel(characterData, scaleSupport); | |
223 | 226 | this.partsSelectPanel.addComponentListener(componentListener); |
224 | 227 | this.partsSelectPanel.addChangeListener(actChangeValue); |
225 | 228 | mainPanel.add(this.partsSelectPanel, "partsSelectPanel"); |
@@ -229,7 +232,8 @@ public class ExportWizardDialog extends JDialog { | ||
229 | 232 | this.partsSelectPanel, |
230 | 233 | this.basicPanel, |
231 | 234 | characterData.getPartsSets().values(), |
232 | - characterData.getDefaultPartsSetId()); | |
235 | + characterData.getDefaultPartsSetId(), | |
236 | + scaleSupport); | |
233 | 237 | this.presetSelectPanel.addComponentListener(componentListener); |
234 | 238 | this.presetSelectPanel.addChangeListener(actChangeValue); |
235 | 239 | mainPanel.add(this.presetSelectPanel, "presetSelectPanel"); |
@@ -238,7 +242,8 @@ public class ExportWizardDialog extends JDialog { | ||
238 | 242 | // button panel |
239 | 243 | |
240 | 244 | JPanel btnPanel = new JPanel(); |
241 | - btnPanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 45)); | |
245 | + int gap = (int)(3 * scaleSupport.getManualScaleX()); | |
246 | + btnPanel.setBorder(BorderFactory.createEmptyBorder(gap, gap, gap, gap * 15)); // 3, 3, 3, 45 | |
242 | 247 | GridBagLayout btnPanelLayout = new GridBagLayout(); |
243 | 248 | btnPanel.setLayout(btnPanelLayout); |
244 | 249 |
@@ -256,7 +261,7 @@ public class ExportWizardDialog extends JDialog { | ||
256 | 261 | gbc.fill = GridBagConstraints.BOTH; |
257 | 262 | gbc.ipadx = 0; |
258 | 263 | gbc.ipady = 0; |
259 | - gbc.insets = new Insets(3, 3, 3, 3); | |
264 | + gbc.insets = new Insets(gap, gap, gap, gap); | |
260 | 265 | gbc.weightx = 1.; |
261 | 266 | gbc.weighty = 0.; |
262 | 267 | btnPanel.add(Box.createHorizontalGlue(), gbc); |
@@ -297,13 +302,8 @@ public class ExportWizardDialog extends JDialog { | ||
297 | 302 | |
298 | 303 | // 表示 |
299 | 304 | |
300 | - Dimension dim = new Dimension(500, 500); | |
301 | - ScaleSupport scaleSupport = ScaleSupport.getInstance(this); | |
302 | - if (scaleSupport != null) { | |
303 | - // HiDpi環境でのスケールを考慮したウィンドウサイズに補正する | |
304 | - dim = scaleSupport.manualScaled(dim); | |
305 | - } | |
306 | - setSize(dim); | |
305 | + // HiDpi環境でのスケールを考慮したウィンドウサイズに補正する | |
306 | + setSize(scaleSupport.manualScaled(new Dimension(500, 500))); | |
307 | 307 | setLocationRelativeTo(parent); |
308 | 308 | |
309 | 309 | mainPanelLayout.first(mainPanel); |
@@ -587,7 +587,8 @@ class ExportInformationPanel extends AbstractImportPanel implements ExportInform | ||
587 | 587 | |
588 | 588 | |
589 | 589 | |
590 | - protected ExportInformationPanel(final CharacterData characterData, final BufferedImage samplePicture) { | |
590 | + protected ExportInformationPanel(final CharacterData characterData, final BufferedImage samplePicture, | |
591 | + ScaleSupport scaleSupport) { | |
591 | 592 | if (characterData == null) { |
592 | 593 | throw new IllegalArgumentException(); |
593 | 594 | } |
@@ -603,8 +604,9 @@ class ExportInformationPanel extends AbstractImportPanel implements ExportInform | ||
603 | 604 | setLayout(basicPanelLayout); |
604 | 605 | |
605 | 606 | JPanel contentsSpecPanel = new JPanel(); |
607 | + int mergin = (int)(5 * scaleSupport.getManualScaleX()); | |
606 | 608 | contentsSpecPanel.setBorder(BorderFactory.createCompoundBorder( |
607 | - BorderFactory.createEmptyBorder(5, 5, 5, 5), | |
609 | + BorderFactory.createEmptyBorder(mergin, mergin, mergin, mergin), | |
608 | 610 | BorderFactory.createTitledBorder(strings.getProperty("basic.contentsSpec")))); |
609 | 611 | BoxLayout contentsSpecPanelLayout = new BoxLayout(contentsSpecPanel, BoxLayout.PAGE_AXIS); |
610 | 612 | contentsSpecPanel.setLayout(contentsSpecPanelLayout); |
@@ -625,11 +627,11 @@ class ExportInformationPanel extends AbstractImportPanel implements ExportInform | ||
625 | 627 | /// |
626 | 628 | |
627 | 629 | JPanel commentPanel = new JPanel(); |
628 | - Dimension archiveInfoPanelMinSize = new Dimension(300, 200); | |
630 | + Dimension archiveInfoPanelMinSize = scaleSupport.manualScaled(new Dimension(300, 200)); | |
629 | 631 | commentPanel.setMinimumSize(archiveInfoPanelMinSize); |
630 | 632 | commentPanel.setPreferredSize(archiveInfoPanelMinSize); |
631 | 633 | commentPanel.setBorder(BorderFactory.createCompoundBorder( |
632 | - BorderFactory.createEmptyBorder(5, 5, 5, 5), | |
634 | + BorderFactory.createEmptyBorder(mergin, mergin, mergin, mergin), | |
633 | 635 | BorderFactory.createTitledBorder(strings.getProperty("basic.comment")))); |
634 | 636 | GridBagLayout commentPanelLayout = new GridBagLayout(); |
635 | 637 | commentPanel.setLayout(commentPanelLayout); |
@@ -640,7 +642,8 @@ class ExportInformationPanel extends AbstractImportPanel implements ExportInform | ||
640 | 642 | gbc.gridwidth = 1; |
641 | 643 | gbc.weightx = 0.; |
642 | 644 | gbc.weighty = 0.; |
643 | - gbc.insets = new Insets(3, 3, 3, 3); | |
645 | + int gap = (int)(3 * scaleSupport.getManualScaleX()); | |
646 | + gbc.insets = new Insets(gap, gap, gap, gap); | |
644 | 647 | gbc.anchor = GridBagConstraints.WEST; |
645 | 648 | gbc.fill = GridBagConstraints.BOTH; |
646 | 649 | commentPanel.add(new JLabel(strings.getProperty("author"), JLabel.RIGHT), gbc); |
@@ -674,7 +677,7 @@ class ExportInformationPanel extends AbstractImportPanel implements ExportInform | ||
674 | 677 | |
675 | 678 | sampleImagePanel = new SamplePicturePanel(samplePicture); |
676 | 679 | sampleImagePanel.setBorder(BorderFactory.createCompoundBorder( |
677 | - BorderFactory.createEmptyBorder(5, 5, 5, 5), | |
680 | + BorderFactory.createEmptyBorder(mergin, mergin, mergin, mergin), | |
678 | 681 | BorderFactory.createTitledBorder(strings.getProperty("basic.sampleImage")))); |
679 | 682 | |
680 | 683 |
@@ -809,7 +812,7 @@ class ExportPartsSelectPanel extends AbstractImportPanel implements ExportPartsR | ||
809 | 812 | |
810 | 813 | private Action actSortByTimestamp; |
811 | 814 | |
812 | - protected ExportPartsSelectPanel(PartsSpecResolver partsSpecResolver) { | |
815 | + protected ExportPartsSelectPanel(PartsSpecResolver partsSpecResolver, ScaleSupport scaleSupport) { | |
813 | 816 | if (partsSpecResolver == null) { |
814 | 817 | throw new IllegalArgumentException(); |
815 | 818 | } |
@@ -854,7 +857,6 @@ class ExportPartsSelectPanel extends AbstractImportPanel implements ExportPartsR | ||
854 | 857 | }; |
855 | 858 | partsTable.setShowGrid(true); |
856 | 859 | partsTable.setGridColor(appConfig.getGridColor()); |
857 | - partsTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); | |
858 | 860 | partsTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); |
859 | 861 | partsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); |
860 | 862 | partsTable.setRowSelectionAllowed(true); |
@@ -862,6 +864,10 @@ class ExportPartsSelectPanel extends AbstractImportPanel implements ExportPartsR | ||
862 | 864 | // 行の高さをフォントの高さにする |
863 | 865 | partsTable.setRowHeight((int)(partsTable.getFont().getSize() * 1.2)); |
864 | 866 | |
867 | + // 列幅を調整する | |
868 | + partsTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); | |
869 | + partsTableModel.adjustColumnModel(partsTable.getColumnModel(), scaleSupport.getManualScaleX()); | |
870 | + | |
865 | 871 | Action actPartsSetCheck = new AbstractAction(strings.getProperty("parts.popup.check")) { |
866 | 872 | private static final long serialVersionUID = 1L; |
867 | 873 | public void actionPerformed(ActionEvent e) { |
@@ -923,7 +929,8 @@ class ExportPartsSelectPanel extends AbstractImportPanel implements ExportPartsR | ||
923 | 929 | gbc.gridwidth = 1; |
924 | 930 | gbc.anchor = GridBagConstraints.EAST; |
925 | 931 | gbc.fill = GridBagConstraints.BOTH; |
926 | - gbc.insets = new Insets(3, 3, 3, 3); | |
932 | + int gap = (int)(3 * scaleSupport.getManualScaleX()); | |
933 | + gbc.insets = new Insets(gap, gap, gap, gap); | |
927 | 934 | gbc.ipadx = 0; |
928 | 935 | gbc.ipady = 0; |
929 | 936 | JButton btnSelectAll = new JButton(actSelectAll); |
@@ -952,13 +959,6 @@ class ExportPartsSelectPanel extends AbstractImportPanel implements ExportPartsR | ||
952 | 959 | add(btnPanel, BorderLayout.SOUTH); |
953 | 960 | } |
954 | 961 | |
955 | - @Override | |
956 | - public void addNotify() { | |
957 | - super.addNotify(); | |
958 | - ScaleSupport scaleSupport = ScaleSupport.getInstance(this); | |
959 | - partsTableModel.adjustColumnModel(partsTable.getColumnModel(), scaleSupport.getManualScaleX()); | |
960 | - } | |
961 | - | |
962 | 962 | protected void loadPartsInfo(PartsSpecResolver partsSpecResolver) { |
963 | 963 | partsTableModel.clear(); |
964 | 964 | for (PartsCategory partsCategory : partsSpecResolver.getPartsCategories()) { |
@@ -1049,7 +1049,8 @@ class ExportPresetSelectPanel extends AbstractImportPanel implements ExportPrese | ||
1049 | 1049 | protected ExportPresetSelectPanel( |
1050 | 1050 | final ExportPartsResolver exportPartsResolver, |
1051 | 1051 | final ExportInformationResolver exportInfoResolver, |
1052 | - Collection<PartsSet> partsSets, String defaultPresetId) { | |
1052 | + Collection<PartsSet> partsSets, String defaultPresetId, | |
1053 | + ScaleSupport scaleSupport) { | |
1053 | 1054 | |
1054 | 1055 | this.exportPartsResolver = exportPartsResolver; |
1055 | 1056 |
@@ -1123,6 +1124,10 @@ class ExportPresetSelectPanel extends AbstractImportPanel implements ExportPrese | ||
1123 | 1124 | // 行の高さをフォントの高さにする |
1124 | 1125 | presetTable.setRowHeight((int)(presetTable.getFont().getSize() * 1.2)); |
1125 | 1126 | |
1127 | + // 列幅を調整する | |
1128 | + presetTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); | |
1129 | + presetTableModel.adjustColumnModel(presetTable.getColumnModel(), scaleSupport.getManualScaleX()); | |
1130 | + | |
1126 | 1131 | final Action actSelectUsedParts = new AbstractAction( |
1127 | 1132 | strings.getProperty("preset.popup.selectUsedParts")) { |
1128 | 1133 | private static final long serialVersionUID = 1L; |
@@ -1137,8 +1142,6 @@ class ExportPresetSelectPanel extends AbstractImportPanel implements ExportPrese | ||
1137 | 1142 | presetTable.setComponentPopupMenu(popupMenu); |
1138 | 1143 | |
1139 | 1144 | |
1140 | - presetTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); | |
1141 | - | |
1142 | 1145 | add(new JScrollPane(presetTable), BorderLayout.CENTER); |
1143 | 1146 | |
1144 | 1147 | actSelectAll = new AbstractAction(strings.getProperty("parts.btn.selectAll")) { |
@@ -1173,7 +1176,8 @@ class ExportPresetSelectPanel extends AbstractImportPanel implements ExportPrese | ||
1173 | 1176 | gbc.gridwidth = 1; |
1174 | 1177 | gbc.anchor = GridBagConstraints.EAST; |
1175 | 1178 | gbc.fill = GridBagConstraints.BOTH; |
1176 | - gbc.insets = new Insets(3, 3, 3, 3); | |
1179 | + int gap = (int)(3 * scaleSupport.getManualScaleX()); | |
1180 | + gbc.insets = new Insets(gap, gap, gap, gap); | |
1177 | 1181 | gbc.ipadx = 0; |
1178 | 1182 | gbc.ipady = 0; |
1179 | 1183 | JButton btnSelectAll = new JButton(actSelectAll); |
@@ -1197,13 +1201,6 @@ class ExportPresetSelectPanel extends AbstractImportPanel implements ExportPrese | ||
1197 | 1201 | add(btnPanel, BorderLayout.SOUTH); |
1198 | 1202 | } |
1199 | 1203 | |
1200 | - @Override | |
1201 | - public void addNotify() { | |
1202 | - super.addNotify(); | |
1203 | - ScaleSupport scaleSupport = ScaleSupport.getInstance(this); | |
1204 | - presetTableModel.adjustColumnModel(presetTable.getColumnModel(), scaleSupport.getManualScaleX()); | |
1205 | - } | |
1206 | - | |
1207 | 1204 | protected void loadPresetInfo(Collection<PartsSet> partsSets, String defaultPresetId) { |
1208 | 1205 | presetTableModel.clear(); |
1209 | 1206 | for (PartsSet orgPartsSet : partsSets) { |
@@ -24,6 +24,7 @@ import java.awt.event.WindowAdapter; | ||
24 | 24 | import java.awt.event.WindowEvent; |
25 | 25 | import java.awt.image.BufferedImage; |
26 | 26 | import java.io.File; |
27 | +import java.io.FileNotFoundException; | |
27 | 28 | import java.io.IOException; |
28 | 29 | import java.net.URI; |
29 | 30 | import java.sql.Timestamp; |
@@ -93,6 +94,7 @@ import charactermanaj.model.PartsSet; | ||
93 | 94 | import charactermanaj.model.PartsSpec; |
94 | 95 | import charactermanaj.model.io.AbstractCharacterDataArchiveFile.CategoryLayerPair; |
95 | 96 | import charactermanaj.model.io.AbstractCharacterDataArchiveFile.PartsImageContent; |
97 | +import charactermanaj.model.io.CharacterDataFileReaderWriterFactory; | |
96 | 98 | import charactermanaj.model.io.CharacterDataPersistent; |
97 | 99 | import charactermanaj.model.io.ImportModel; |
98 | 100 | import charactermanaj.ui.model.AbstractTableModelWithComboBoxModel; |
@@ -102,6 +104,8 @@ import charactermanaj.ui.progress.WorkerException; | ||
102 | 104 | import charactermanaj.ui.progress.WorkerWithProgessDialog; |
103 | 105 | import charactermanaj.ui.util.FileDropTarget; |
104 | 106 | import charactermanaj.ui.util.ScaleSupport; |
107 | +import charactermanaj.util.DownloadUtils; | |
108 | +import charactermanaj.util.DownloadUtils.HeadResponse; | |
105 | 109 | import charactermanaj.util.ErrorMessageHelper; |
106 | 110 | import charactermanaj.util.LocalizedResourcePropertyLoader; |
107 | 111 |
@@ -172,14 +176,10 @@ public class ImportWizardDialog extends JDialog { | ||
172 | 176 | * 親フレーム |
173 | 177 | * @param current |
174 | 178 | * 更新対象となる現在のプロファイル(新規インポートの場合はnull) |
175 | - * @param initFiles | |
176 | - * アーカイブファィルまたはディレクトリの初期選択、なければnullまたは空 | |
177 | 179 | */ |
178 | - public ImportWizardDialog(JFrame parent, CharacterData current, List<File> initFiles) { | |
180 | + public ImportWizardDialog(JFrame parent, CharacterData current) { | |
179 | 181 | super(parent, true); |
180 | 182 | initComponent(parent, current); |
181 | - | |
182 | - importFileSelectPanel.setSelectFile(initFiles); | |
183 | 183 | } |
184 | 184 | |
185 | 185 | /** |
@@ -196,6 +196,18 @@ public class ImportWizardDialog extends JDialog { | ||
196 | 196 | } |
197 | 197 | |
198 | 198 | /** |
199 | + * @param initFiles | |
200 | + * アーカイブファィルまたはディレクトリの初期選択、なければnullまたは空 | |
201 | + */ | |
202 | + public void initSelectFile(File initFile) { | |
203 | + importFileSelectPanel.setSelectFile(initFile); | |
204 | + } | |
205 | + | |
206 | + public void initSelectURL(String url) { | |
207 | + importFileSelectPanel.initSelectURL(url); | |
208 | + } | |
209 | + | |
210 | + /** | |
199 | 211 | * ウィザードダイアログのコンポーネントを初期化します.<br> |
200 | 212 | * currentがnullの場合は新規インポート、そうでない場合は更新インポートとります。 |
201 | 213 | * |
@@ -227,12 +239,15 @@ public class ImportWizardDialog extends JDialog { | ||
227 | 239 | |
228 | 240 | // メインパネル |
229 | 241 | |
242 | + ScaleSupport scaleSupport = ScaleSupport.getInstance(this); | |
243 | + | |
230 | 244 | Container contentPane = getContentPane(); |
231 | 245 | contentPane.setLayout(new BorderLayout()); |
232 | 246 | |
233 | 247 | final JPanel mainPanel = new JPanel(); |
234 | 248 | mainPanel.setBorder(BorderFactory.createEtchedBorder()); |
235 | - this.mainPanelLayout = new CardLayout(5, 5); | |
249 | + int gap = (int)(5 * scaleSupport.getManualScaleX()); | |
250 | + this.mainPanelLayout = new CardLayout(gap, gap); | |
236 | 251 | mainPanel.setLayout(mainPanelLayout); |
237 | 252 | contentPane.add(mainPanel, BorderLayout.CENTER); |
238 | 253 |
@@ -291,25 +306,25 @@ public class ImportWizardDialog extends JDialog { | ||
291 | 306 | }; |
292 | 307 | |
293 | 308 | // ImportFileSelectPanel |
294 | - this.importFileSelectPanel = new ImportFileSelectPanel(); | |
309 | + this.importFileSelectPanel = new ImportFileSelectPanel(scaleSupport); | |
295 | 310 | this.importFileSelectPanel.addComponentListener(componentListener); |
296 | 311 | this.importFileSelectPanel.addChangeListener(changeListener); |
297 | 312 | mainPanel.add(this.importFileSelectPanel, ImportFileSelectPanel.PANEL_NAME); |
298 | 313 | |
299 | 314 | // ImportTypeSelectPanel |
300 | - this.importTypeSelectPanel = new ImportTypeSelectPanel(); | |
315 | + this.importTypeSelectPanel = new ImportTypeSelectPanel(scaleSupport); | |
301 | 316 | this.importTypeSelectPanel.addComponentListener(componentListener); |
302 | 317 | this.importTypeSelectPanel.addChangeListener(changeListener); |
303 | 318 | mainPanel.add(this.importTypeSelectPanel, ImportTypeSelectPanel.PANEL_NAME); |
304 | 319 | |
305 | 320 | // ImportPartsSelectPanel |
306 | - this.importPartsSelectPanel = new ImportPartsSelectPanel(); | |
321 | + this.importPartsSelectPanel = new ImportPartsSelectPanel(scaleSupport); | |
307 | 322 | this.importPartsSelectPanel.addComponentListener(componentListener); |
308 | 323 | this.importPartsSelectPanel.addChangeListener(changeListener); |
309 | 324 | mainPanel.add(this.importPartsSelectPanel, ImportPartsSelectPanel.PANEL_NAME); |
310 | 325 | |
311 | 326 | // ImportPresetSelectPanel |
312 | - this.importPresetSelectPanel = new ImportPresetSelectPanel(); | |
327 | + this.importPresetSelectPanel = new ImportPresetSelectPanel(scaleSupport); | |
313 | 328 | this.importPresetSelectPanel.addComponentListener(componentListener); |
314 | 329 | this.importPresetSelectPanel.addChangeListener(changeListener); |
315 | 330 | mainPanel.add(this.importPresetSelectPanel, ImportPresetSelectPanel.PANEL_NAME); |
@@ -318,7 +333,8 @@ public class ImportWizardDialog extends JDialog { | ||
318 | 333 | // button panel |
319 | 334 | |
320 | 335 | JPanel btnPanel = new JPanel(); |
321 | - btnPanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 45)); | |
336 | + int mergin = (int)(3 * scaleSupport.getManualScaleX()); | |
337 | + btnPanel.setBorder(BorderFactory.createEmptyBorder(mergin, mergin, mergin, mergin * 15)); // 3,3,3,45 | |
322 | 338 | GridBagLayout btnPanelLayout = new GridBagLayout(); |
323 | 339 | btnPanel.setLayout(btnPanelLayout); |
324 | 340 |
@@ -336,7 +352,7 @@ public class ImportWizardDialog extends JDialog { | ||
336 | 352 | gbc.fill = GridBagConstraints.BOTH; |
337 | 353 | gbc.ipadx = 0; |
338 | 354 | gbc.ipady = 0; |
339 | - gbc.insets = new Insets(3, 3, 3, 3); | |
355 | + gbc.insets = new Insets(mergin, mergin, mergin, mergin); | |
340 | 356 | gbc.weightx = 1.; |
341 | 357 | gbc.weighty = 0.; |
342 | 358 | btnPanel.add(Box.createHorizontalGlue(), gbc); |
@@ -378,11 +394,8 @@ public class ImportWizardDialog extends JDialog { | ||
378 | 394 | // 表示 |
379 | 395 | |
380 | 396 | Dimension dim = new Dimension(500, 500); |
381 | - ScaleSupport scaleSupport = ScaleSupport.getInstance(this); | |
382 | - if (scaleSupport != null) { | |
383 | - // HiDpi環境でのスケールを考慮したウィンドウサイズに補正する | |
384 | - dim = scaleSupport.manualScaled(dim); | |
385 | - } | |
397 | + // HiDpi環境でのスケールを考慮したウィンドウサイズに補正する | |
398 | + dim = scaleSupport.manualScaled(dim); | |
386 | 399 | setSize(dim); |
387 | 400 | setLocationRelativeTo(parent); |
388 | 401 |
@@ -778,11 +791,21 @@ class ImportFileSelectPanel extends ImportWizardCardPanel { | ||
778 | 791 | private Action actChooseDirectory; |
779 | 792 | |
780 | 793 | |
794 | + /** | |
795 | + * URLを指定してインポート | |
796 | + */ | |
797 | + private JRadioButton radioURL; | |
798 | + | |
799 | + /** | |
800 | + * URL入力ボックス | |
801 | + */ | |
802 | + private JTextField txtURL; | |
803 | + | |
781 | 804 | |
782 | 805 | /* 以下、対象ファイルの読み取り結果 */ |
783 | 806 | |
784 | 807 | |
785 | - public ImportFileSelectPanel() { | |
808 | + public ImportFileSelectPanel(ScaleSupport scaleSupport) { | |
786 | 809 | setLayout(new BorderLayout()); |
787 | 810 | |
788 | 811 | Properties strings = LocalizedResourcePropertyLoader.getCachedInstance() |
@@ -805,9 +828,11 @@ class ImportFileSelectPanel extends ImportWizardCardPanel { | ||
805 | 828 | |
806 | 829 | txtArchiveFile = new JTextField(); |
807 | 830 | txtDirectory = new JTextField(); |
831 | + txtURL = new JTextField(); | |
808 | 832 | |
809 | 833 | txtArchiveFile.getDocument().addDocumentListener(documentListener); |
810 | 834 | txtDirectory.getDocument().addDocumentListener(documentListener); |
835 | + txtURL.getDocument().addDocumentListener(documentListener); | |
811 | 836 | |
812 | 837 | actChooseFile = new AbstractAction(strings.getProperty("browse")) { |
813 | 838 | private static final long serialVersionUID = 1L; |
@@ -830,6 +855,7 @@ class ImportFileSelectPanel extends ImportWizardCardPanel { | ||
830 | 855 | |
831 | 856 | radioArchiveFile = new JRadioButton(strings.getProperty("importingArchiveFile")); |
832 | 857 | radioDirectory = new JRadioButton(strings.getProperty("importingDirectory")); |
858 | + radioURL = new JRadioButton(strings.getProperty("importingURL")); | |
833 | 859 | |
834 | 860 | ChangeListener radioChangeListener = new ChangeListener() { |
835 | 861 | public void stateChanged(ChangeEvent e) { |
@@ -839,27 +865,32 @@ class ImportFileSelectPanel extends ImportWizardCardPanel { | ||
839 | 865 | }; |
840 | 866 | radioArchiveFile.addChangeListener(radioChangeListener); |
841 | 867 | radioDirectory.addChangeListener(radioChangeListener); |
868 | + radioURL.addChangeListener(radioChangeListener); | |
842 | 869 | |
843 | 870 | ButtonGroup btnGroup = new ButtonGroup(); |
844 | 871 | btnGroup.add(radioArchiveFile); |
845 | 872 | btnGroup.add(radioDirectory); |
873 | + btnGroup.add(radioURL); | |
846 | 874 | |
847 | 875 | // アーカイブからのインポートをデフォルトとする |
848 | 876 | radioArchiveFile.setSelected(true); |
849 | 877 | |
850 | 878 | GridBagConstraints gbc = new GridBagConstraints(); |
851 | 879 | |
880 | + gbc.ipadx = 0; | |
881 | + gbc.ipady = 0; | |
882 | + int gap = (int)(3 * scaleSupport.getManualScaleX()); | |
883 | + gbc.insets = new Insets(gap, gap, gap, gap); | |
884 | + gbc.anchor = GridBagConstraints.WEST; | |
885 | + gbc.fill = GridBagConstraints.BOTH; | |
886 | + | |
887 | + // アーカイブ | |
852 | 888 | gbc.gridx = 0; |
853 | 889 | gbc.gridy = 0; |
854 | 890 | gbc.weightx = 1.; |
855 | 891 | gbc.weighty = 0.; |
856 | 892 | gbc.gridheight = 1; |
857 | 893 | gbc.gridwidth = 3; |
858 | - gbc.ipadx = 0; | |
859 | - gbc.ipady = 0; | |
860 | - gbc.insets = new Insets(3, 3, 3, 3); | |
861 | - gbc.anchor = GridBagConstraints.WEST; | |
862 | - gbc.fill = GridBagConstraints.BOTH; | |
863 | 894 | fileChoosePanel.add(radioArchiveFile, gbc); |
864 | 895 | |
865 | 896 | gbc.gridx = 0; |
@@ -881,6 +912,7 @@ class ImportFileSelectPanel extends ImportWizardCardPanel { | ||
881 | 912 | gbc.weightx = 0.; |
882 | 913 | fileChoosePanel.add(new JButton(actChooseFile), gbc); |
883 | 914 | |
915 | + // ディレクトり | |
884 | 916 | gbc.gridx = 0; |
885 | 917 | gbc.gridy = 2; |
886 | 918 | gbc.ipadx = 0; |
@@ -907,8 +939,31 @@ class ImportFileSelectPanel extends ImportWizardCardPanel { | ||
907 | 939 | gbc.weightx = 0.; |
908 | 940 | fileChoosePanel.add(new JButton(actChooseDirectory), gbc); |
909 | 941 | |
942 | + // URL | |
943 | + gbc.gridx = 0; | |
944 | + gbc.gridy = 4; | |
945 | + gbc.weightx = 1.; | |
946 | + gbc.weighty = 0.; | |
947 | + gbc.gridheight = 1; | |
948 | + gbc.gridwidth = 3; | |
949 | + fileChoosePanel.add(radioURL, gbc); | |
950 | + | |
910 | 951 | gbc.gridx = 0; |
911 | 952 | gbc.gridy = 4; |
953 | + gbc.gridwidth = 1; | |
954 | + gbc.ipadx = 45; | |
955 | + gbc.weightx = 0; | |
956 | + fileChoosePanel.add(Box.createHorizontalGlue(), gbc); | |
957 | + | |
958 | + gbc.gridx = 1; | |
959 | + gbc.gridy = 5; | |
960 | + gbc.ipadx = 0; | |
961 | + gbc.weightx = 1.; | |
962 | + fileChoosePanel.add(txtURL, gbc); | |
963 | + | |
964 | + // パディング | |
965 | + gbc.gridx = 0; | |
966 | + gbc.gridy = 6; | |
912 | 967 | gbc.ipadx = 0; |
913 | 968 | gbc.gridwidth = 3; |
914 | 969 | gbc.weightx = 1.; |
@@ -924,7 +979,8 @@ class ImportFileSelectPanel extends ImportWizardCardPanel { | ||
924 | 979 | if (dropFiles == null || dropFiles.isEmpty()) { |
925 | 980 | return; |
926 | 981 | } |
927 | - setSelectFile(dropFiles); | |
982 | + File dropFile = dropFiles.get(0); | |
983 | + setSelectFile(dropFile); | |
928 | 984 | } |
929 | 985 | |
930 | 986 | @Override |
@@ -943,19 +999,15 @@ class ImportFileSelectPanel extends ImportWizardCardPanel { | ||
943 | 999 | * @param dropFile |
944 | 1000 | * アーカイブファイルまたはディレクトリ、もしくはnull |
945 | 1001 | */ |
946 | - public void setSelectFile(List<File> dropFiles) { | |
947 | - | |
948 | - File dropFile = null; | |
949 | - if (dropFiles != null && dropFiles.size() > 0) { | |
950 | - dropFile = dropFiles.get(0); | |
951 | - } | |
952 | - | |
1002 | + public void setSelectFile(File dropFile) { | |
953 | 1003 | if (dropFile == null) { |
954 | 1004 | // 選択なしの場合 |
955 | 1005 | txtDirectory.setText(""); |
956 | 1006 | txtArchiveFile.setText(""); |
1007 | + txtURL.setText(""); | |
957 | 1008 | radioDirectory.setSelected(false); |
958 | 1009 | radioArchiveFile.setSelected(false); |
1010 | + radioURL.setSelected(false); | |
959 | 1011 | |
960 | 1012 | } else if (dropFile.isDirectory()) { |
961 | 1013 | // ディレクトリの場合 |
@@ -969,15 +1021,39 @@ class ImportFileSelectPanel extends ImportWizardCardPanel { | ||
969 | 1021 | } |
970 | 1022 | } |
971 | 1023 | |
1024 | + /** | |
1025 | + * URL入力を選択状態とする | |
1026 | + * @param url URL | |
1027 | + */ | |
1028 | + public void initSelectURL(String url) { | |
1029 | + if (url != null && (url.startsWith("http://") || url.startsWith("https://"))) { | |
1030 | + // URL指定の場合 | |
1031 | + txtURL.setText(url); | |
1032 | + radioURL.setSelected(true); | |
1033 | + | |
1034 | + } else { | |
1035 | + // 選択なしの場合 | |
1036 | + txtDirectory.setText(""); | |
1037 | + txtArchiveFile.setText(""); | |
1038 | + txtURL.setText(""); | |
1039 | + radioDirectory.setSelected(false); | |
1040 | + radioArchiveFile.setSelected(false); | |
1041 | + radioURL.setSelected(false); | |
1042 | + } | |
1043 | + } | |
1044 | + | |
972 | 1045 | protected void updateUIState() { |
973 | 1046 | boolean enableArchiveFile = radioArchiveFile.isSelected(); |
974 | 1047 | boolean enableDirectory = radioDirectory.isSelected(); |
1048 | + boolean enableURL = radioURL.isSelected(); | |
975 | 1049 | |
976 | 1050 | txtArchiveFile.setEnabled(enableArchiveFile); |
977 | 1051 | actChooseFile.setEnabled(enableArchiveFile); |
978 | 1052 | |
979 | 1053 | txtDirectory.setEnabled(enableDirectory); |
980 | 1054 | actChooseDirectory.setEnabled(enableDirectory); |
1055 | + | |
1056 | + txtURL.setEnabled(enableURL); | |
981 | 1057 | } |
982 | 1058 | |
983 | 1059 | protected void onChooseFile() { |
@@ -1019,6 +1095,11 @@ class ImportFileSelectPanel extends ImportWizardCardPanel { | ||
1019 | 1095 | if (directoryTxt != null && directoryTxt.trim().length() > 0) { |
1020 | 1096 | return true; |
1021 | 1097 | } |
1098 | + } else if (radioURL.isSelected()) { | |
1099 | + String url = txtURL.getText(); | |
1100 | + if (url != null && (url.startsWith("http://") || url.startsWith("https://"))) { | |
1101 | + return true; | |
1102 | + } | |
1022 | 1103 | } |
1023 | 1104 | return false; |
1024 | 1105 | } |
@@ -1076,6 +1157,15 @@ class ImportFileSelectPanel extends ImportWizardCardPanel { | ||
1076 | 1157 | } |
1077 | 1158 | importArchive = file.toURI(); |
1078 | 1159 | |
1160 | + } else if (radioURL.isSelected()) { | |
1161 | + // URLからダウンロード | |
1162 | + File tmpFile = loadTemporaryFromURL(txtURL.getText()); | |
1163 | + if (tmpFile == null) { | |
1164 | + // エラーメッセージは表示済みのため、単にnullでnextを拒否する | |
1165 | + return null; | |
1166 | + } | |
1167 | + importArchive = tmpFile.toURI(); | |
1168 | + | |
1079 | 1169 | } else { |
1080 | 1170 | // それ以外はサポートしていない. |
1081 | 1171 | return null; |
@@ -1085,16 +1175,14 @@ class ImportFileSelectPanel extends ImportWizardCardPanel { | ||
1085 | 1175 | parent.importModel.openImportSource(importArchive, parent.current); |
1086 | 1176 | |
1087 | 1177 | // ワーカースレッドでアーカイブの読み込みを行う. |
1088 | - Worker<Object> worker = new Worker<Object>() { | |
1178 | + Worker<Void> worker = new Worker<Void>() { | |
1089 | 1179 | public Void doWork(ProgressHandle progressHandle) throws IOException { |
1090 | 1180 | parent.importModel.loadContents(progressHandle); |
1091 | 1181 | return null; |
1092 | 1182 | } |
1093 | 1183 | }; |
1094 | 1184 | |
1095 | - WorkerWithProgessDialog<Object> dlg | |
1096 | - = new WorkerWithProgessDialog<Object>(parent, worker); | |
1097 | - | |
1185 | + WorkerWithProgessDialog<Void> dlg = new WorkerWithProgessDialog<Void>(parent, worker); | |
1098 | 1186 | dlg.startAndWait(); |
1099 | 1187 | |
1100 | 1188 | // 読み込めたら次ページへ |
@@ -1109,6 +1197,70 @@ class ImportFileSelectPanel extends ImportWizardCardPanel { | ||
1109 | 1197 | |
1110 | 1198 | return null; |
1111 | 1199 | } |
1200 | + | |
1201 | + /** | |
1202 | + * 指定されたURLからテンポラリにダウンロードして、そのファイルを返す。 | |
1203 | + * URLが適切でない場合、もしくはエラーが発生した場合はnullを返す。 | |
1204 | + * @param url URL | |
1205 | + * @return ダウンロードしたファイル | |
1206 | + */ | |
1207 | + private File loadTemporaryFromURL(final String url) { | |
1208 | + final Properties strings = LocalizedResourcePropertyLoader.getCachedInstance() | |
1209 | + .getLocalizedProperties(ImportWizardDialog.STRINGS_RESOURCE); | |
1210 | + final AppConfig appConfig = AppConfig.getInstance(); | |
1211 | + final DownloadUtils downloader = new DownloadUtils(); | |
1212 | + downloader.setImpersonateUserAgent(appConfig.getImpersonateUserAgent()); | |
1213 | + downloader.setDeleteDownloadFileOnExit(appConfig.isDeleteDownloadFileOnExit()); | |
1214 | + | |
1215 | + try { | |
1216 | + // ワーカースレッドでアーカイブの読み込みを行う. | |
1217 | + Worker<File> worker = new Worker<File>() { | |
1218 | + public File doWork(ProgressHandle progressHandle) throws IOException { | |
1219 | + progressHandle.setIndeterminate(true); | |
1220 | + progressHandle.setCaption(strings.getProperty("downloading.checkhead")); | |
1221 | + | |
1222 | + HeadResponse headResponse = downloader.getHead(url); | |
1223 | + | |
1224 | + String contentType = headResponse.getContentType(); | |
1225 | + String ext = headResponse.getDotExtension(); | |
1226 | + CharacterDataFileReaderWriterFactory archiveRdWrFactory = | |
1227 | + CharacterDataFileReaderWriterFactory.getInstance(); | |
1228 | + if (contentType == null || !contentType.startsWith("application/") || | |
1229 | + !archiveRdWrFactory.isSupportedFile(ext)) { | |
1230 | + // コンテンツタイプが不明、もしくはバイナリではない | |
1231 | + // あるいは、ファイル名がzip, jar, cmjのいずれでもない場合 | |
1232 | + return null; | |
1233 | + } | |
1234 | + | |
1235 | + progressHandle.setCaption(strings.getProperty("downloading.waitForDownload")); | |
1236 | + return downloader.downloadTemporary(headResponse); | |
1237 | + } | |
1238 | + }; | |
1239 | + | |
1240 | + WorkerWithProgessDialog<File> dlg = new WorkerWithProgessDialog<File>(parent, worker); | |
1241 | + try { | |
1242 | + File tempFile = dlg.startAndWait(); | |
1243 | + if (tempFile != null) { | |
1244 | + return tempFile; | |
1245 | + } | |
1246 | + JOptionPane.showMessageDialog(this, strings.getProperty("downloading.invalidFileType"), | |
1247 | + "ERROR", JOptionPane.ERROR_MESSAGE); | |
1248 | + return null; | |
1249 | + | |
1250 | + } catch (WorkerException ex) { | |
1251 | + Throwable iex = ex.getCause(); | |
1252 | + throw (iex == null) ? ex : (Exception) iex; | |
1253 | + } | |
1254 | + | |
1255 | + } catch (FileNotFoundException ex) { | |
1256 | + JOptionPane.showMessageDialog(this, strings.getProperty("downloading.notFound"), | |
1257 | + "ERROR", JOptionPane.ERROR_MESSAGE); | |
1258 | + | |
1259 | + } catch (Exception ex) { | |
1260 | + ErrorMessageHelper.showErrorDialog(this, ex); | |
1261 | + } | |
1262 | + return null; | |
1263 | + } | |
1112 | 1264 | } |
1113 | 1265 | |
1114 | 1266 | class URLTableRow { |
@@ -1145,7 +1297,7 @@ class URLTableModel extends AbstractTableModelWithComboBoxModel<URLTableRow> { | ||
1145 | 1297 | |
1146 | 1298 | static { |
1147 | 1299 | COLUMN_NAMES = new String[] { |
1148 | -"作者", | |
1300 | + "作者", | |
1149 | 1301 | "URL", |
1150 | 1302 | }; |
1151 | 1303 | COLUMN_WIDTHS = new int[] { |
@@ -1268,7 +1420,7 @@ class ImportTypeSelectPanel extends ImportWizardCardPanel { | ||
1268 | 1420 | |
1269 | 1421 | /* 以下、選択結果 */ |
1270 | 1422 | |
1271 | - public ImportTypeSelectPanel() { | |
1423 | + public ImportTypeSelectPanel(ScaleSupport scaleSupport) { | |
1272 | 1424 | Properties strings = LocalizedResourcePropertyLoader.getCachedInstance() |
1273 | 1425 | .getLocalizedProperties(ImportWizardDialog.STRINGS_RESOURCE); |
1274 | 1426 |
@@ -1277,9 +1429,10 @@ class ImportTypeSelectPanel extends ImportWizardCardPanel { | ||
1277 | 1429 | setLayout(basicPanelLayout); |
1278 | 1430 | |
1279 | 1431 | JPanel contentsSpecPanel = new JPanel(); |
1432 | + int mergin = (int)(5 * scaleSupport.getManualScaleX()); | |
1280 | 1433 | contentsSpecPanel.setBorder(BorderFactory.createCompoundBorder( |
1281 | - BorderFactory.createEmptyBorder(5, 5, 5, 5), BorderFactory | |
1282 | - .createTitledBorder(strings.getProperty("basic.contentsSpec")))); | |
1434 | + BorderFactory.createEmptyBorder(mergin, mergin, mergin, mergin), | |
1435 | + BorderFactory.createTitledBorder(strings.getProperty("basic.contentsSpec")))); | |
1283 | 1436 | BoxLayout contentsSpecPanelLayout = new BoxLayout(contentsSpecPanel, BoxLayout.PAGE_AXIS); |
1284 | 1437 | contentsSpecPanel.setLayout(contentsSpecPanelLayout); |
1285 | 1438 |
@@ -1295,9 +1448,9 @@ class ImportTypeSelectPanel extends ImportWizardCardPanel { | ||
1295 | 1448 | |
1296 | 1449 | JPanel archiveInfoPanel = new JPanel(); |
1297 | 1450 | archiveInfoPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory |
1298 | - .createEmptyBorder(5, 5, 5, 5), BorderFactory | |
1299 | - .createTitledBorder(strings.getProperty("basic.archiveInfo")))); | |
1300 | - Dimension archiveInfoPanelMinSize = new Dimension(300, 200); | |
1451 | + .createEmptyBorder(mergin, mergin, mergin, mergin), | |
1452 | + BorderFactory.createTitledBorder(strings.getProperty("basic.archiveInfo")))); | |
1453 | + Dimension archiveInfoPanelMinSize = scaleSupport.manualScaled(new Dimension(300, 200)); | |
1301 | 1454 | archiveInfoPanel.setMinimumSize(archiveInfoPanelMinSize); |
1302 | 1455 | archiveInfoPanel.setPreferredSize(archiveInfoPanelMinSize); |
1303 | 1456 | GridBagLayout commentPanelLayout = new GridBagLayout(); |
@@ -1309,7 +1462,8 @@ class ImportTypeSelectPanel extends ImportWizardCardPanel { | ||
1309 | 1462 | gbc.gridwidth = 2; |
1310 | 1463 | gbc.weightx = 0.; |
1311 | 1464 | gbc.weighty = 0.; |
1312 | - gbc.insets = new Insets(3, 3, 3, 3); | |
1465 | + int gap = (int)(3 * scaleSupport.getManualScaleX()); | |
1466 | + gbc.insets = new Insets(gap, gap, gap, gap); | |
1313 | 1467 | gbc.anchor = GridBagConstraints.WEST; |
1314 | 1468 | gbc.fill = GridBagConstraints.BOTH; |
1315 | 1469 |
@@ -1420,9 +1574,8 @@ class ImportTypeSelectPanel extends ImportWizardCardPanel { | ||
1420 | 1574 | JPanel samplePictureTitledPanel = new JPanel(new BorderLayout()); |
1421 | 1575 | samplePictureTitledPanel.add(samplePicturePanelSP, BorderLayout.CENTER); |
1422 | 1576 | samplePictureTitledPanel.setBorder(BorderFactory.createCompoundBorder( |
1423 | - BorderFactory.createEmptyBorder(5, 5, 5, 5), BorderFactory | |
1424 | - .createTitledBorder(strings | |
1425 | - .getProperty("basic.sampleImage")))); | |
1577 | + BorderFactory.createEmptyBorder(mergin, mergin, mergin, mergin), | |
1578 | + BorderFactory.createTitledBorder(strings.getProperty("basic.sampleImage")))); | |
1426 | 1579 | |
1427 | 1580 | // / |
1428 | 1581 |
@@ -1719,7 +1872,7 @@ class ImportPartsSelectPanel extends ImportWizardCardPanel { | ||
1719 | 1872 | private Action actSortByTimestamp; |
1720 | 1873 | |
1721 | 1874 | |
1722 | - public ImportPartsSelectPanel() { | |
1875 | + public ImportPartsSelectPanel(ScaleSupport scaleSupport) { | |
1723 | 1876 | Properties strings = LocalizedResourcePropertyLoader.getCachedInstance() |
1724 | 1877 | .getLocalizedProperties(ImportWizardDialog.STRINGS_RESOURCE); |
1725 | 1878 |
@@ -1728,8 +1881,7 @@ class ImportPartsSelectPanel extends ImportWizardCardPanel { | ||
1728 | 1881 | profileSizePanel = new JPanel(); |
1729 | 1882 | GridBagLayout profileSizePanelLayout = new GridBagLayout(); |
1730 | 1883 | profileSizePanel.setLayout(profileSizePanelLayout); |
1731 | - profileSizePanel.setBorder(BorderFactory | |
1732 | - .createTitledBorder("プロファイルのサイズ")); | |
1884 | + profileSizePanel.setBorder(BorderFactory.createTitledBorder(strings.getProperty("sizeOfProfile"))); | |
1733 | 1885 | |
1734 | 1886 | GridBagConstraints gbc = new GridBagConstraints(); |
1735 | 1887 |
@@ -1739,12 +1891,13 @@ class ImportPartsSelectPanel extends ImportWizardCardPanel { | ||
1739 | 1891 | gbc.gridwidth = 1; |
1740 | 1892 | gbc.anchor = GridBagConstraints.EAST; |
1741 | 1893 | gbc.fill = GridBagConstraints.BOTH; |
1742 | - gbc.insets = new Insets(3, 3, 3, 3); | |
1894 | + int gap = (int)(3 * scaleSupport.getManualScaleX()); | |
1895 | + gbc.insets = new Insets(gap, gap, gap, gap); | |
1743 | 1896 | gbc.weightx = 0.; |
1744 | 1897 | gbc.weighty = 0.; |
1745 | 1898 | gbc.ipadx = 0; |
1746 | 1899 | gbc.ipady = 0; |
1747 | - profileSizePanel.add(new JLabel("幅:", JLabel.RIGHT), gbc); | |
1900 | + profileSizePanel.add(new JLabel(strings.getProperty("widthOfProfile"), JLabel.RIGHT), gbc); | |
1748 | 1901 | |
1749 | 1902 | txtProfileWidth = new JTextField(); |
1750 | 1903 | txtProfileWidth.setEditable(false); |
@@ -1754,7 +1907,7 @@ class ImportPartsSelectPanel extends ImportWizardCardPanel { | ||
1754 | 1907 | |
1755 | 1908 | gbc.gridx = 2; |
1756 | 1909 | gbc.gridy = 0; |
1757 | - profileSizePanel.add(new JLabel("高さ:", JLabel.RIGHT), gbc); | |
1910 | + profileSizePanel.add(new JLabel(strings.getProperty("heightOfProfile"), JLabel.RIGHT), gbc); | |
1758 | 1911 | |
1759 | 1912 | txtProfileHeight = new JTextField(); |
1760 | 1913 | txtProfileHeight.setEditable(false); |
@@ -1847,7 +2000,6 @@ class ImportPartsSelectPanel extends ImportWizardCardPanel { | ||
1847 | 2000 | return comp; |
1848 | 2001 | } |
1849 | 2002 | }; |
1850 | - partsTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); | |
1851 | 2003 | partsTable.setShowGrid(true); |
1852 | 2004 | partsTable.setGridColor(appConfig.getGridColor()); |
1853 | 2005 | partsTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); |
@@ -1857,6 +2009,10 @@ class ImportPartsSelectPanel extends ImportWizardCardPanel { | ||
1857 | 2009 | // 行の高さをフォントの高さにする |
1858 | 2010 | partsTable.setRowHeight((int)(partsTable.getFont().getSize() * 1.2)); |
1859 | 2011 | |
2012 | + // 列幅の調整 | |
2013 | + partsTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); | |
2014 | + partsTableModel.adjustColumnModel(partsTable.getColumnModel(), scaleSupport.getManualScaleX()); | |
2015 | + | |
1860 | 2016 | Action actPartsSetCheck = new AbstractAction(strings.getProperty("parts.popup.check")) { |
1861 | 2017 | private static final long serialVersionUID = 1L; |
1862 | 2018 | public void actionPerformed(ActionEvent e) { |
@@ -1929,7 +2085,7 @@ class ImportPartsSelectPanel extends ImportWizardCardPanel { | ||
1929 | 2085 | gbc.gridwidth = 1; |
1930 | 2086 | gbc.anchor = GridBagConstraints.EAST; |
1931 | 2087 | gbc.fill = GridBagConstraints.BOTH; |
1932 | - gbc.insets = new Insets(3, 3, 3, 3); | |
2088 | + gbc.insets = new Insets(gap, gap, gap, gap); | |
1933 | 2089 | gbc.ipadx = 0; |
1934 | 2090 | gbc.ipady = 0; |
1935 | 2091 | JButton btnSelectAll = new JButton(actSelectAll); |
@@ -1959,13 +2115,6 @@ class ImportPartsSelectPanel extends ImportWizardCardPanel { | ||
1959 | 2115 | } |
1960 | 2116 | |
1961 | 2117 | @Override |
1962 | - public void addNotify() { | |
1963 | - super.addNotify(); | |
1964 | - ScaleSupport scaleSupport = ScaleSupport.getInstance(this); | |
1965 | - partsTableModel.adjustColumnModel(partsTable.getColumnModel(), scaleSupport.getDefaultScaleX()); | |
1966 | - } | |
1967 | - | |
1968 | - @Override | |
1969 | 2118 | public void onActive(ImportWizardDialog parent, ImportWizardCardPanel previousPanel) { |
1970 | 2119 | this.parent = parent; |
1971 | 2120 | if (previousPanel == parent.importPresetSelectPanel) { |
@@ -2022,6 +2171,7 @@ class ImportPartsSelectPanel extends ImportWizardCardPanel { | ||
2022 | 2171 | |
2023 | 2172 | String defaultPartsSetId; |
2024 | 2173 | CharacterData presetImportTarget; |
2174 | + boolean selectAllPreset; | |
2025 | 2175 | if (parent.current == null) { |
2026 | 2176 | presetImportTarget = null; |
2027 | 2177 | CharacterData cd = parent.importModel.getCharacterData(); |
@@ -2030,12 +2180,14 @@ class ImportPartsSelectPanel extends ImportWizardCardPanel { | ||
2030 | 2180 | } else { |
2031 | 2181 | defaultPartsSetId = null; |
2032 | 2182 | } |
2183 | + selectAllPreset = true; // 新規プロファイルの場合はプリセットをインポートする | |
2033 | 2184 | } else { |
2034 | 2185 | presetImportTarget = parent.current; |
2035 | 2186 | defaultPartsSetId = null; // 既存の場合はデフォルトのパーツセットであるかは表示する必要ないのでnullにする. |
2187 | + selectAllPreset = (parent.current.getPartsCount() == 0); // パーツが空の場合はプリセットをインポートする | |
2036 | 2188 | } |
2037 | 2189 | |
2038 | - parent.importPresetSelectPanel.initModel(partsSets, defaultPartsSetId, presetImportTarget); | |
2190 | + parent.importPresetSelectPanel.initModel(partsSets, defaultPartsSetId, presetImportTarget, selectAllPreset); | |
2039 | 2191 | } |
2040 | 2192 | |
2041 | 2193 | @Override |
@@ -2739,7 +2891,7 @@ class ImportPartsTableModel extends AbstractTableModelWithComboBoxModel<ImportPa | ||
2739 | 2891 | public void adjustColumnModel(TableColumnModel columnModel, double scale) { |
2740 | 2892 | int mx = columnModel.getColumnCount(); |
2741 | 2893 | for (int idx = 0; idx < mx; idx++) { |
2742 | - columnModel.getColumn(idx).setWidth((int)(COLUMN_WIDTHS[idx] * scale)); | |
2894 | + columnModel.getColumn(idx).setPreferredWidth((int)(COLUMN_WIDTHS[idx] * scale)); | |
2743 | 2895 | } |
2744 | 2896 | } |
2745 | 2897 |
@@ -2870,7 +3022,7 @@ class ImportPresetSelectPanel extends ImportWizardCardPanel { | ||
2870 | 3022 | |
2871 | 3023 | private Action actSelectUsedParts; |
2872 | 3024 | |
2873 | - public ImportPresetSelectPanel() { | |
3025 | + public ImportPresetSelectPanel(ScaleSupport scaleSupport) { | |
2874 | 3026 | Properties strings = LocalizedResourcePropertyLoader.getCachedInstance() |
2875 | 3027 | .getLocalizedProperties(ImportWizardDialog.STRINGS_RESOURCE); |
2876 | 3028 |
@@ -2948,7 +3100,10 @@ class ImportPresetSelectPanel extends ImportWizardCardPanel { | ||
2948 | 3100 | popupMenu.add(actSelectUsedParts); |
2949 | 3101 | |
2950 | 3102 | presetTable.setComponentPopupMenu(popupMenu); |
3103 | + | |
3104 | + // 列幅の調整 | |
2951 | 3105 | presetTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); |
3106 | + presetTableModel.adjustColumnModel(presetTable.getColumnModel(), scaleSupport.getManualScaleX()); | |
2952 | 3107 | |
2953 | 3108 | add(new JScrollPane(presetTable), BorderLayout.CENTER); |
2954 | 3109 |
@@ -2987,7 +3142,8 @@ class ImportPresetSelectPanel extends ImportWizardCardPanel { | ||
2987 | 3142 | gbc.gridwidth = 1; |
2988 | 3143 | gbc.anchor = GridBagConstraints.EAST; |
2989 | 3144 | gbc.fill = GridBagConstraints.BOTH; |
2990 | - gbc.insets = new Insets(3, 3, 3, 3); | |
3145 | + int gap = (int)(3 * scaleSupport.getManualScaleX()); | |
3146 | + gbc.insets = new Insets(gap, gap, gap, gap); | |
2991 | 3147 | gbc.ipadx = 0; |
2992 | 3148 | gbc.ipady = 0; |
2993 | 3149 | JButton btnSelectAll = new JButton(actSelectAll); |
@@ -3012,13 +3168,6 @@ class ImportPresetSelectPanel extends ImportWizardCardPanel { | ||
3012 | 3168 | } |
3013 | 3169 | |
3014 | 3170 | @Override |
3015 | - public void addNotify() { | |
3016 | - super.addNotify(); | |
3017 | - ScaleSupport scaleSupport = ScaleSupport.getInstance(this); | |
3018 | - presetTableModel.adjustColumnModel(presetTable.getColumnModel(), scaleSupport.getManualScaleX()); | |
3019 | - } | |
3020 | - | |
3021 | - @Override | |
3022 | 3171 | public void onActive(ImportWizardDialog parent, |
3023 | 3172 | ImportWizardCardPanel previousPanel) { |
3024 | 3173 | this.parent= parent; |
@@ -3123,8 +3272,12 @@ class ImportPresetSelectPanel extends ImportWizardCardPanel { | ||
3123 | 3272 | return defaultPartsSetId; |
3124 | 3273 | } |
3125 | 3274 | |
3126 | - public void initModel(Collection<PartsSet> partsSets, String defaultPartsSetId, CharacterData presetImportTarget) { | |
3275 | + public void initModel(Collection<PartsSet> partsSets, String defaultPartsSetId, CharacterData presetImportTarget, | |
3276 | + boolean selectAll) { | |
3127 | 3277 | presetTableModel.initModel(partsSets, defaultPartsSetId, presetImportTarget); |
3278 | + if (selectAll) { | |
3279 | + presetTableModel.selectAll(); | |
3280 | + } | |
3128 | 3281 | } |
3129 | 3282 | } |
3130 | 3283 |
@@ -3328,7 +3481,7 @@ class ImportPresetTableModel extends AbstractTableModelWithComboBoxModel<ImportP | ||
3328 | 3481 | public void adjustColumnModel(TableColumnModel columnModel, double scale) { |
3329 | 3482 | int mx = columnModel.getColumnCount(); |
3330 | 3483 | for (int idx = 0; idx < mx; idx++) { |
3331 | - columnModel.getColumn(idx).setWidth((int)(COLUMN_WIDTHS[idx] * scale)); | |
3484 | + columnModel.getColumn(idx).setPreferredWidth((int)(COLUMN_WIDTHS[idx] * scale)); | |
3332 | 3485 | } |
3333 | 3486 | } |
3334 | 3487 |
@@ -43,16 +43,19 @@ import java.util.logging.Logger; | ||
43 | 43 | |
44 | 44 | import javax.swing.Box; |
45 | 45 | import javax.swing.BoxLayout; |
46 | +import javax.swing.ButtonGroup; | |
46 | 47 | import javax.swing.JCheckBox; |
47 | 48 | import javax.swing.JCheckBoxMenuItem; |
48 | 49 | import javax.swing.JColorChooser; |
49 | 50 | import javax.swing.JFrame; |
51 | +import javax.swing.JLabel; | |
50 | 52 | import javax.swing.JMenu; |
51 | 53 | import javax.swing.JMenuBar; |
52 | 54 | import javax.swing.JMenuItem; |
53 | 55 | import javax.swing.JOptionPane; |
54 | 56 | import javax.swing.JPanel; |
55 | 57 | import javax.swing.JPopupMenu; |
58 | +import javax.swing.JRadioButton; | |
56 | 59 | import javax.swing.JScrollBar; |
57 | 60 | import javax.swing.JScrollPane; |
58 | 61 | import javax.swing.JSeparator; |
@@ -95,6 +98,7 @@ import charactermanaj.model.PartsIdentifier; | ||
95 | 98 | import charactermanaj.model.PartsSet; |
96 | 99 | import charactermanaj.model.RecommendationURL; |
97 | 100 | import charactermanaj.model.WorkingSet; |
101 | +import charactermanaj.model.io.CharacterDataFileReaderWriterFactory; | |
98 | 102 | import charactermanaj.model.io.CharacterDataPersistent; |
99 | 103 | import charactermanaj.model.io.CustomLayerOrderPersist; |
100 | 104 | import charactermanaj.model.io.CustomLayerOrderPersist.CustomLayerOrderPersistListener; |
@@ -129,6 +133,8 @@ import charactermanaj.ui.util.FileDropTarget; | ||
129 | 133 | import charactermanaj.ui.util.ScaleSupport; |
130 | 134 | import charactermanaj.ui.util.WindowAdjustLocationSupport; |
131 | 135 | import charactermanaj.util.DesktopUtilities; |
136 | +import charactermanaj.util.DownloadUtils; | |
137 | +import charactermanaj.util.DownloadUtils.HeadResponse; | |
132 | 138 | import charactermanaj.util.ErrorMessageHelper; |
133 | 139 | import charactermanaj.util.LocalizedResourcePropertyLoader; |
134 | 140 | import charactermanaj.util.SystemUtil; |
@@ -285,6 +291,11 @@ public class MainFrame extends JFrame | ||
285 | 291 | private final ActiveCustomLayerPatternMgr customLayerPatternMgr = new ActiveCustomLayerPatternMgr(); |
286 | 292 | |
287 | 293 | /** |
294 | + * ダウンロード不要フラグ | |
295 | + */ | |
296 | + private boolean noNeedDataDownload; | |
297 | + | |
298 | + /** | |
288 | 299 | * アクティブなメインフレームを設定する. |
289 | 300 | * |
290 | 301 | * @param mainFrame |
@@ -457,6 +468,18 @@ public class MainFrame extends JFrame | ||
457 | 468 | // アプリケーション設定の変更で画面の再表示を試行する |
458 | 469 | AppConfig.getInstance().addPropertyChangeListener(appConfigChangeListener); |
459 | 470 | |
471 | + // パーツがひとつも登録されていない場合 | |
472 | + // (ただし、すでにダウンロード不要フラグを設定してあればスキップする) | |
473 | + // (データ構造変更時の再ロードでは、この処理は行わない。一時的にパーツ数が0になるため) | |
474 | + if (characterData.getPartsCount() == 0 && !noNeedDataDownload) { | |
475 | + SwingUtilities.invokeLater(new Runnable() { | |
476 | + @Override | |
477 | + public void run() { | |
478 | + confirmDefaultCharacterDataDownload(); | |
479 | + } | |
480 | + }); | |
481 | + } | |
482 | + | |
460 | 483 | } catch (RuntimeException ex) { |
461 | 484 | logger.log(Level.SEVERE, "メインフレームの構築中に予期せぬ例外が発生しました。", ex); |
462 | 485 | dispose(); // コンストラクタが呼ばれた時点でJFrameは構築済みなのでdisposeの必要がある. |
@@ -875,12 +898,19 @@ public class MainFrame extends JFrame | ||
875 | 898 | if (dropFiles == null || dropFiles.isEmpty()) { |
876 | 899 | return; |
877 | 900 | } |
901 | + final File dropFile = dropFiles.get(0); | |
902 | + | |
878 | 903 | // インポートダイアログを開く. |
879 | 904 | // ドロップソースの処理がブロッキングしないように、 |
880 | 905 | // ドロップハンドラの処理を終了してからインポートダイアログが開くようにする. |
881 | 906 | SwingUtilities.invokeLater(new Runnable() { |
882 | 907 | public void run() { |
883 | - onImport(dropFiles); | |
908 | + onImport(new ImportSourceCallback() { | |
909 | + @Override | |
910 | + public void onInit(ImportWizardDialog dlg) { | |
911 | + dlg.initSelectFile(dropFile); | |
912 | + } | |
913 | + }); | |
884 | 914 | } |
885 | 915 | }); |
886 | 916 | } |
@@ -924,6 +954,94 @@ public class MainFrame extends JFrame | ||
924 | 954 | } |
925 | 955 | |
926 | 956 | /** |
957 | + * おすすめURLの表示名がアスタリスクで始まっている、urlがzipの最初の定義を | |
958 | + * デフォルトのキャラクターセットのダウンロードurlとしてインポートするか問い合わせる | |
959 | + */ | |
960 | + private void confirmDefaultCharacterDataDownload() { | |
961 | + List<RecommendationURL> recommendations = characterData.getRecommendationURLList(); | |
962 | + List<RecommendationURL> downloadUrls = new ArrayList<RecommendationURL>(); | |
963 | + if (recommendations != null) { | |
964 | + CharacterDataFileReaderWriterFactory archiveRdWrFactory = | |
965 | + CharacterDataFileReaderWriterFactory.getInstance(); | |
966 | + for (RecommendationURL recommendation : recommendations) { | |
967 | + String name = recommendation.getDisplayName(); | |
968 | + String url = recommendation.getUrl(); | |
969 | + if (name.startsWith("*") && archiveRdWrFactory.isSupportedFile(url)) { | |
970 | + downloadUrls.add(recommendation); | |
971 | + } | |
972 | + } | |
973 | + } | |
974 | + if (downloadUrls.isEmpty()) { | |
975 | + // デフォルトのキャラクターデータが定義されていない場合 | |
976 | + return; | |
977 | + } | |
978 | + | |
979 | + Properties strings = LocalizedResourcePropertyLoader.getCachedInstance() | |
980 | + .getLocalizedProperties(STRINGS_RESOURCE); | |
981 | + | |
982 | + Box box = Box.createVerticalBox(); | |
983 | + box.add(new JLabel(strings.getProperty("defaultdatadownload.confirm.message"))); | |
984 | + | |
985 | + ButtonGroup grp = new ButtonGroup(); | |
986 | + for (RecommendationURL recommendation : downloadUrls) { | |
987 | + String name = recommendation.getDisplayName(); | |
988 | + String url = recommendation.getUrl(); | |
989 | + if (name.startsWith("*")) { | |
990 | + name = name.substring(1); | |
991 | + } | |
992 | + JRadioButton radio = new JRadioButton(name); | |
993 | + radio.setToolTipText(url); | |
994 | + radio.setActionCommand(url); | |
995 | + if (grp.getButtonCount() == 0) { | |
996 | + // 最初のアイテムを選択状態にする | |
997 | + radio.setSelected(true); | |
998 | + } | |
999 | + grp.add(radio); | |
1000 | + box.add(radio); | |
1001 | + } | |
1002 | + | |
1003 | + JRadioButton chkNoAskAgain = new JRadioButton(strings.getProperty("noDownloadAndDoNotAskAgain")); | |
1004 | + grp.add(chkNoAskAgain); | |
1005 | + box.add(chkNoAskAgain); | |
1006 | + | |
1007 | + int ret = JOptionPane.showConfirmDialog(MainFrame.this, box, | |
1008 | + strings.getProperty("defaultdatadownload.confirm.title"), JOptionPane.YES_NO_OPTION); | |
1009 | + if (ret != JOptionPane.YES_OPTION) { | |
1010 | + return; | |
1011 | + } | |
1012 | + | |
1013 | + if (chkNoAskAgain.isSelected()) { | |
1014 | + // ダウンロードしないし、今後、この問い合わせは不要 | |
1015 | + noNeedDataDownload = true; | |
1016 | + return; | |
1017 | + } | |
1018 | + | |
1019 | + // リダイレクト先の実際のURLを取得する | |
1020 | + String downloadUrl = grp.getSelection().getActionCommand(); | |
1021 | + final String actualDownloadUrl; | |
1022 | + try { | |
1023 | + AppConfig appConfig = AppConfig.getInstance(); | |
1024 | + DownloadUtils downloader = new DownloadUtils(); | |
1025 | + downloader.setImpersonateUserAgent(appConfig.getImpersonateUserAgent()); | |
1026 | + HeadResponse response = downloader.getHead(downloadUrl); | |
1027 | + actualDownloadUrl = response.getLocation(); | |
1028 | + | |
1029 | + } catch (Exception ex) { | |
1030 | + // アクセスできなかった場合はエラーを表示してインポートはしない | |
1031 | + ErrorMessageHelper.showErrorDialog(this, ex); | |
1032 | + return; | |
1033 | + } | |
1034 | + | |
1035 | + // リダイレクト先URLをインポートダイアログに表示する | |
1036 | + onImport(new ImportSourceCallback() { | |
1037 | + @Override | |
1038 | + public void onInit(ImportWizardDialog dlg) { | |
1039 | + dlg.initSelectURL(actualDownloadUrl); | |
1040 | + } | |
1041 | + }); | |
1042 | + } | |
1043 | + | |
1044 | + /** | |
927 | 1045 | * パーツが変更されたことを検知した場合.<br> |
928 | 1046 | * パーツデータをリロードし、各カテゴリのパーツ一覧を再表示させ、プレビューを更新する.<br> |
929 | 1047 | */ |
@@ -1395,6 +1513,10 @@ public class MainFrame extends JFrame | ||
1395 | 1513 | for (RecommendationURL recommendation : recommendations) { |
1396 | 1514 | String displayName = recommendation.getDisplayName(); |
1397 | 1515 | String url = recommendation.getUrl(); |
1516 | + if (displayName.startsWith("*") && url.endsWith(".zip")) { | |
1517 | + // デフォルトのデータダウンロードURLはメニューには表示しない | |
1518 | + continue; | |
1519 | + } | |
1398 | 1520 | |
1399 | 1521 | JMenuItem mnuItem = menuBuilder.createJMenuItem(); |
1400 | 1522 | mnuItem.setText(displayName); |
@@ -2027,7 +2149,7 @@ public class MainFrame extends JFrame | ||
2027 | 2149 | |
2028 | 2150 | try { |
2029 | 2151 | // インポートウィザードの実行(新規モード) |
2030 | - ImportWizardDialog importWizDialog = new ImportWizardDialog(this, null, null); | |
2152 | + ImportWizardDialog importWizDialog = new ImportWizardDialog(this, null); | |
2031 | 2153 | importWizDialog.setVisible(true); |
2032 | 2154 | int exitCode = importWizDialog.getExitCode(); |
2033 | 2155 | if (exitCode == ImportWizardDialog.EXIT_PROFILE_CREATED) { |
@@ -2050,15 +2172,20 @@ public class MainFrame extends JFrame | ||
2050 | 2172 | } |
2051 | 2173 | } |
2052 | 2174 | |
2175 | + private interface ImportSourceCallback { | |
2176 | + | |
2177 | + void onInit(ImportWizardDialog dlg); | |
2178 | + } | |
2179 | + | |
2053 | 2180 | /** |
2054 | 2181 | * 現在のプロファイルに対するインポートウィザードを実行する.<br> |
2055 | 2182 | * インポートが実行された場合は、パーツをリロードする.<br> |
2056 | 2183 | * インポートウィザード表示中は監視スレッドは停止される.<br> |
2057 | 2184 | * |
2058 | - * @param initFile | |
2059 | - * アーカイブファィルまたはディレクトリ、指定がなければnull | |
2185 | + * @param initCallback | |
2186 | + * アーカイブファィルまたはディレクトリを初期設定するコールバック | |
2060 | 2187 | */ |
2061 | - protected void onImport(List<File> initFiles) { | |
2188 | + protected void onImport(ImportSourceCallback initCallback) { | |
2062 | 2189 | if (!characterData.isValid()) { |
2063 | 2190 | Toolkit tk = Toolkit.getDefaultToolkit(); |
2064 | 2191 | tk.beep(); |
@@ -2069,7 +2196,10 @@ public class MainFrame extends JFrame | ||
2069 | 2196 | watchAgent.suspend(); |
2070 | 2197 | try { |
2071 | 2198 | // インポートウィザードの実行 |
2072 | - ImportWizardDialog importWizDialog = new ImportWizardDialog(this, characterData, initFiles); | |
2199 | + ImportWizardDialog importWizDialog = new ImportWizardDialog(this, characterData); | |
2200 | + if (initCallback != null) { | |
2201 | + initCallback.onInit(importWizDialog); | |
2202 | + } | |
2073 | 2203 | importWizDialog.setVisible(true); |
2074 | 2204 | |
2075 | 2205 | if (importWizDialog.getExitCode() == ImportWizardDialog.EXIT_PROFILE_UPDATED) { |
@@ -2272,6 +2402,8 @@ public class MainFrame extends JFrame | ||
2272 | 2402 | Rectangle windowRect = new Rectangle(windowPos, windowSize); |
2273 | 2403 | workingSet.setWindowRect(windowRect); |
2274 | 2404 | |
2405 | + workingSet.setNoNeedDataDownload(noNeedDataDownload); | |
2406 | + | |
2275 | 2407 | // XML形式でのワーキングセットの保存 |
2276 | 2408 | WorkingSetPersist workingSetPersist = WorkingSetPersist |
2277 | 2409 | .getInstance(); |
@@ -2387,6 +2519,9 @@ public class MainFrame extends JFrame | ||
2387 | 2519 | } |
2388 | 2520 | } |
2389 | 2521 | |
2522 | + // ダウンロード不要フラグ | |
2523 | + noNeedDataDownload = workingSet.isNoNeedDataDownload(); | |
2524 | + | |
2390 | 2525 | return true; |
2391 | 2526 | |
2392 | 2527 | } catch (Exception ex) { |
@@ -47,6 +47,7 @@ import charactermanaj.model.CharacterData; | ||
47 | 47 | import charactermanaj.model.PartsCategory; |
48 | 48 | import charactermanaj.model.PartsIdentifier; |
49 | 49 | import charactermanaj.model.PartsSet; |
50 | +import charactermanaj.ui.util.ScaleSupport; | |
50 | 51 | import charactermanaj.util.LocalizedResourcePropertyLoader; |
51 | 52 | |
52 | 53 | /** |
@@ -195,6 +196,8 @@ public class PartsRandomChooserDialog extends JDialog { | ||
195 | 196 | |
196 | 197 | setTitle(strings.getProperty("partsRandomChooser")); |
197 | 198 | |
199 | + ScaleSupport scaleSupport = ScaleSupport.getInstance(this); | |
200 | + | |
198 | 201 | Container contentPane = getContentPane(); |
199 | 202 | contentPane.setLayout(new BorderLayout()); |
200 | 203 |
@@ -232,7 +235,8 @@ public class PartsRandomChooserDialog extends JDialog { | ||
232 | 235 | int idx = centerPnl.getComponentCount(); |
233 | 236 | RandomChooserPanel pnl = addPartsChooserPanel(centerPnl, |
234 | 237 | idx, category, lastInCategory, |
235 | - changePartsIdentifierListener); | |
238 | + changePartsIdentifierListener, | |
239 | + scaleSupport); | |
236 | 240 | |
237 | 241 | // 未選択の場合、もしくは複数選択カテゴリの場合はランダムはディセーブルとする |
238 | 242 | pnl.setEnableRandom(enable |
@@ -290,7 +294,8 @@ public class PartsRandomChooserDialog extends JDialog { | ||
290 | 294 | JButton btnBack = new JButton(actBack); |
291 | 295 | |
292 | 296 | Box btnPanel = Box.createHorizontalBox(); |
293 | - btnPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 42)); | |
297 | + int mergin = (int)(5 * scaleSupport.getManualScaleX()); | |
298 | + btnPanel.setBorder(BorderFactory.createEmptyBorder(mergin, mergin, mergin, mergin * 8)); // 5, 5, 5, 40 | |
294 | 299 | |
295 | 300 | btnPanel.add(btnRandomAll); |
296 | 301 | btnPanel.add(btnBack); |
@@ -493,16 +498,18 @@ public class PartsRandomChooserDialog extends JDialog { | ||
493 | 498 | private JToggleButton btnReject; |
494 | 499 | |
495 | 500 | public RandomChooserPanel(final PartsCategory category, |
496 | - final boolean lastInCategory) { | |
501 | + final boolean lastInCategory, | |
502 | + final ScaleSupport scaleSupport) { | |
497 | 503 | Properties strings = LocalizedResourcePropertyLoader |
498 | 504 | .getCachedInstance().getLocalizedProperties( |
499 | 505 | STRINGS_RESOURCE); |
500 | 506 | |
507 | + int gap = (int)(3 * scaleSupport.getManualScaleX()); | |
501 | 508 | setBorder(BorderFactory.createCompoundBorder( |
502 | - BorderFactory.createEmptyBorder(3, 3, 3, 3), | |
509 | + BorderFactory.createEmptyBorder(gap, gap, gap, gap), | |
503 | 510 | BorderFactory.createCompoundBorder( |
504 | 511 | BorderFactory.createEtchedBorder(), |
505 | - BorderFactory.createEmptyBorder(3, 3, 3, 3)))); | |
512 | + BorderFactory.createEmptyBorder(gap, gap, gap, gap)))); | |
506 | 513 | setLayout(new GridBagLayout()); |
507 | 514 | |
508 | 515 | GridBagConstraints gbc = new GridBagConstraints(); |
@@ -696,9 +703,10 @@ public class PartsRandomChooserDialog extends JDialog { | ||
696 | 703 | final int addPos, |
697 | 704 | final PartsCategory category, |
698 | 705 | final boolean lastInCategory, |
699 | - final ActionListener changePartsIdentifierListener) { | |
706 | + final ActionListener changePartsIdentifierListener, | |
707 | + final ScaleSupport scaleSupport) { | |
700 | 708 | RandomChooserPanel pnl = new RandomChooserPanel(category, |
701 | - lastInCategory) { | |
709 | + lastInCategory, scaleSupport) { | |
702 | 710 | private static final long serialVersionUID = 1L; |
703 | 711 | |
704 | 712 | @Override |
@@ -709,7 +717,8 @@ public class PartsRandomChooserDialog extends JDialog { | ||
709 | 717 | if (comp.equals(this)) { |
710 | 718 | // 同じカテゴリのものを追加する |
711 | 719 | addPartsChooserPanel(centerPnl, idx + 1, category, |
712 | - lastInCategory, changePartsIdentifierListener); | |
720 | + lastInCategory, changePartsIdentifierListener, | |
721 | + scaleSupport); | |
713 | 722 | centerPnl.validate(); |
714 | 723 | // Addボタンを非表示にする. |
715 | 724 | ((JButton) e.getSource()).setVisible(false); |
@@ -406,29 +406,46 @@ public final class ProfileListManager { | ||
406 | 406 | * @param characterData |
407 | 407 | */ |
408 | 408 | public static void prepare(CharacterData characterData) { |
409 | - if (characterData.isEnableCustonLayerPattern()) { | |
410 | - CustomLayerOrderPersist customLayerOrderPersist = CustomLayerOrderPersist.newInstance(characterData); | |
411 | - if (!customLayerOrderPersist.exist()) { | |
412 | - // まだカスタムレイヤーが登録されていない場合(空ファイルの登録は無視する) | |
413 | - // カスタムレイヤーをまだ使ったことがないキャラクターデータを最初に開いた場合 | |
414 | - String structureSig = characterData.toStructureString(); | |
415 | - | |
416 | - // 既定は空のパターン | |
417 | - Map<CustomLayerOrderKey, List<CustomLayerOrder>> map = Collections.emptyMap(); | |
409 | + if (characterData.isEnableCustonLayerPattern() || | |
410 | + characterData.getRecommendationURLList() == null) { | |
411 | + String structureSig = characterData.toStructureString(); | |
412 | + CharacterDataDefaultProvider defProv = new CharacterDataDefaultProvider(); | |
413 | + CharacterData v3 = defProv.createDefaultCharacterData(DefaultCharacterDataVersion.V3); | |
414 | + | |
415 | + if (characterData.isEnableCustonLayerPattern()) { | |
416 | + CustomLayerOrderPersist customLayerOrderPersist = CustomLayerOrderPersist.newInstance(characterData); | |
417 | + if (!customLayerOrderPersist.exist()) { | |
418 | + // まだカスタムレイヤーが登録されていない場合(空ファイルの登録は無視する) | |
419 | + // カスタムレイヤーをまだ使ったことがないキャラクターデータを最初に開いた場合 | |
420 | + | |
421 | + // 既定は空のパターン | |
422 | + Map<CustomLayerOrderKey, List<CustomLayerOrder>> map = Collections.emptyMap(); | |
423 | + | |
424 | + if (v3.toStructureString().equals(structureSig)) { | |
425 | + // デフォルトのキャラクターセット(v3)と同一構造であれば、 | |
426 | + // V3デフォルト用のカスタムレイヤー定義をセットする。 | |
427 | + map = defProv.createDefaultCustomLayerOrderMap(characterData, DefaultCharacterDataVersion.V3); | |
428 | + } | |
418 | 429 | |
419 | - CharacterDataDefaultProvider defProv = new CharacterDataDefaultProvider(); | |
420 | - CharacterData v3 = defProv.createDefaultCharacterData(DefaultCharacterDataVersion.V3); | |
421 | - if (v3.toStructureString().equals(structureSig)) { | |
422 | - // デフォルトのキャラクターセット(v3)と同一構造であれば、 | |
423 | - // V3デフォルト用のカスタムレイヤー定義をセットする。 | |
424 | - map = defProv.createDefaultCustomLayerOrderMap(characterData, DefaultCharacterDataVersion.V3); | |
430 | + // カスタムレイヤーパターンをファイルに保存する | |
431 | + try { | |
432 | + customLayerOrderPersist.save(map); | |
433 | + } catch (Exception ex) { | |
434 | + logger.log(Level.WARNING, "failed to save the custom layer mapping.", ex); | |
435 | + } | |
425 | 436 | } |
437 | + } | |
426 | 438 | |
427 | - // カスタムレイヤーパターンをファイルに保存する | |
428 | - try { | |
429 | - customLayerOrderPersist.save(map); | |
430 | - } catch (Exception ex) { | |
431 | - logger.log(Level.WARNING, "failed to save the custom layer mapping.", ex); | |
439 | + // お薦めリンクがnullの場合 | |
440 | + // (旧形式、またはお薦めリンクの定義がデフォルト定義と同一である場合はnullになる。) | |
441 | + // rev:c587663f3dda3a4a874ef6810a336126f07d482c まではMainFrameのお薦めリンクメニュー構築時に補完していた。 | |
442 | + // キャラクターデータのダウンロード問い合わせ対応のため、ここで先に補完しておく。 | |
443 | + if (characterData.getRecommendationURLList() == null) { | |
444 | + CharacterData v2 = defProv.createDefaultCharacterData(DefaultCharacterDataVersion.V3); | |
445 | + if (v2.toStructureString().equals(structureSig) || v3.toStructureString().equals(structureSig)) { | |
446 | + // デフォルトのキャラクターセット(v2, v3)と同一構造であれば、デフォルトで補完する | |
447 | + final CharacterDataPersistent persistent = CharacterDataPersistent.getInstance(); | |
448 | + persistent.compensateRecommendationList(characterData); | |
432 | 449 | } |
433 | 450 | } |
434 | 451 | } |
@@ -517,8 +517,9 @@ public class ProfileSelectorDialog extends JDialog { | ||
517 | 517 | |
518 | 518 | JSplitPane centerPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true); |
519 | 519 | centerPane.setResizeWeight(1.f); // ウィンドウサイズ変更時に上を可変とする. |
520 | - centerPane.setDividerLocation(Integer.parseInt(strings | |
521 | - .getProperty("dividerLocation"))); | |
520 | + int divLocation = Integer.parseInt(strings.getProperty("dividerLocation")); | |
521 | + divLocation = (int)(scaleSupport.getManualScaleY() * divLocation); | |
522 | + centerPane.setDividerLocation(divLocation); | |
522 | 523 | |
523 | 524 | centerPane.add(pnlProfilesGroup); |
524 | 525 | centerPane.add(infoPanel); |
@@ -1,6 +1,5 @@ | ||
1 | 1 | package charactermanaj.ui; |
2 | 2 | |
3 | -import java.awt.Container; | |
4 | 3 | import java.awt.Dimension; |
5 | 4 | import java.awt.Font; |
6 | 5 | import java.awt.GraphicsEnvironment; |
@@ -211,11 +210,13 @@ public class SelectCharatersDirDialog extends JDialog { | ||
211 | 210 | btnCancel.addFocusListener(focusAdapter); |
212 | 211 | btnBroseForDir.addFocusListener(focusAdapter); |
213 | 212 | |
214 | - Container contentPane = getContentPane(); | |
215 | - contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS)); | |
216 | - | |
217 | 213 | ScaleSupport scaleSupport = ScaleSupport.getInstance(this); |
218 | 214 | |
215 | + JPanel contentPane = (JPanel) getContentPane(); | |
216 | + int borderSize = (int)(5 * scaleSupport.getManualScaleX()); | |
217 | + contentPane.setBorder(BorderFactory.createEmptyBorder(0, borderSize, borderSize, borderSize)); | |
218 | + contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS)); | |
219 | + | |
219 | 220 | { |
220 | 221 | JLabel lbl = new JLabel(strings.getProperty("caption")); |
221 | 222 | lbl.setFont(lbl.getFont().deriveFont(Font.BOLD)); |
@@ -274,6 +275,14 @@ public class SelectCharatersDirDialog extends JDialog { | ||
274 | 275 | btnsBox.add(btnRemoveWorkingSets); |
275 | 276 | btnsBox.add(Box.createHorizontalGlue()); |
276 | 277 | |
278 | + // OK, CANCELボタンのサイズを合わせる | |
279 | + Dimension dim = btnOK.getPreferredSize(); | |
280 | + int btnWidth = Math.max(btnOK.getPreferredSize().width, | |
281 | + btnCancel.getPreferredSize().width); | |
282 | + dim.setSize(btnWidth, dim.height); | |
283 | + btnOK.setPreferredSize(dim); | |
284 | + btnCancel.setPreferredSize(dim); | |
285 | + | |
277 | 286 | if (!Main.isLinuxOrMacOSX()) { |
278 | 287 | btnsBox.add(btnOK); |
279 | 288 | btnsBox.add(btnCancel); |
@@ -35,32 +35,32 @@ public class WorkerWithProgessDialog<T> extends JDialog { | ||
35 | 35 | * ワーカースレッドが停止したことを示すフラグ |
36 | 36 | */ |
37 | 37 | private volatile boolean exitThread; |
38 | - | |
38 | + | |
39 | 39 | /** |
40 | 40 | * ワーカースレッドの戻り値 |
41 | 41 | */ |
42 | 42 | private volatile T result; |
43 | - | |
43 | + | |
44 | 44 | /** |
45 | 45 | * ワーカースレッドが例外により終了した場合の例外 |
46 | 46 | */ |
47 | 47 | private volatile Throwable occuredException; |
48 | - | |
48 | + | |
49 | 49 | /** |
50 | 50 | * ワーカースレッド |
51 | 51 | */ |
52 | 52 | private Thread thread; |
53 | - | |
53 | + | |
54 | 54 | /** |
55 | 55 | * ワーカースレッドの状態を監視しプログレスに反映させるタイマー |
56 | 56 | */ |
57 | 57 | private Timer timer; |
58 | - | |
58 | + | |
59 | 59 | /** |
60 | 60 | * プログレスの更新頻度(タイマーのインターバル) |
61 | 61 | */ |
62 | 62 | private static int interval = 200; |
63 | - | |
63 | + | |
64 | 64 | |
65 | 65 | /** |
66 | 66 | * 親フレームとワーカーを指定して構築する.<br> |
@@ -73,15 +73,15 @@ public class WorkerWithProgessDialog<T> extends JDialog { | ||
73 | 73 | if (worker == null) { |
74 | 74 | throw new IllegalArgumentException(); |
75 | 75 | } |
76 | - | |
76 | + | |
77 | 77 | initComponent(parent, worker); |
78 | - | |
78 | + | |
79 | 79 | } catch (RuntimeException ex) { |
80 | 80 | dispose(); |
81 | 81 | throw ex; |
82 | 82 | } |
83 | 83 | } |
84 | - | |
84 | + | |
85 | 85 | /** |
86 | 86 | * 親ダイアログとワーカーを指定して構築する.<br> |
87 | 87 | * @param parent 親フレーム |
@@ -93,9 +93,9 @@ public class WorkerWithProgessDialog<T> extends JDialog { | ||
93 | 93 | if (worker == null) { |
94 | 94 | throw new IllegalArgumentException(); |
95 | 95 | } |
96 | - | |
96 | + | |
97 | 97 | initComponent(parent, worker); |
98 | - | |
98 | + | |
99 | 99 | } catch (RuntimeException ex) { |
100 | 100 | dispose(); |
101 | 101 | throw ex; |
@@ -122,10 +122,10 @@ public class WorkerWithProgessDialog<T> extends JDialog { | ||
122 | 122 | final JProgressBar progressBar = new JProgressBar(); |
123 | 123 | progressBar.setIndeterminate(true); |
124 | 124 | progressBar.setStringPainted(false); |
125 | - | |
125 | + | |
126 | 126 | container.add(progressBar, BorderLayout.SOUTH); |
127 | - | |
128 | - // デフォルトのラベル表示 | |
127 | + | |
128 | + // デフォルトのラベル表示 | |
129 | 129 | String title = "please wait for a while."; |
130 | 130 | final JLabel lblCaption = new JLabel(title); |
131 | 131 | container.add(lblCaption, BorderLayout.NORTH); |
@@ -144,7 +144,7 @@ public class WorkerWithProgessDialog<T> extends JDialog { | ||
144 | 144 | |
145 | 145 | // パックする. |
146 | 146 | pack(); |
147 | - | |
147 | + | |
148 | 148 | // 親の中央に表示 |
149 | 149 | setLocationRelativeTo(parent); |
150 | 150 |
@@ -178,11 +178,11 @@ public class WorkerWithProgessDialog<T> extends JDialog { | ||
178 | 178 | } |
179 | 179 | }); |
180 | 180 | } |
181 | - | |
181 | + | |
182 | 182 | super.flush(); |
183 | 183 | } |
184 | 184 | }; |
185 | - | |
185 | + | |
186 | 186 | // プログレスダイアログに状態を反映させるためのタイマー |
187 | 187 | timer = new Timer(interval, new ActionListener() { |
188 | 188 | public void actionPerformed(ActionEvent e) { |
@@ -210,7 +210,7 @@ public class WorkerWithProgessDialog<T> extends JDialog { | ||
210 | 210 | } |
211 | 211 | }); |
212 | 212 | } |
213 | - | |
213 | + | |
214 | 214 | /** |
215 | 215 | * プログレスの表示間隔を取得する |
216 | 216 | * @return 表示間隔 |
@@ -239,7 +239,7 @@ public class WorkerWithProgessDialog<T> extends JDialog { | ||
239 | 239 | public void run() { |
240 | 240 | try { |
241 | 241 | try { |
242 | - worker.doWork(progressHandle); | |
242 | + result = worker.doWork(progressHandle); | |
243 | 243 | |
244 | 244 | } catch (Throwable ex) { |
245 | 245 | occuredException = ex; |
@@ -251,7 +251,7 @@ public class WorkerWithProgessDialog<T> extends JDialog { | ||
251 | 251 | } |
252 | 252 | }; |
253 | 253 | } |
254 | - | |
254 | + | |
255 | 255 | /** |
256 | 256 | * ワーカースレッドより、スレッドが終了したことを通知される.<br> |
257 | 257 | * ワーカースレッド自身か、ワーカースレッドの例外ハンドラか、 |
@@ -269,18 +269,18 @@ public class WorkerWithProgessDialog<T> extends JDialog { | ||
269 | 269 | } |
270 | 270 | }); |
271 | 271 | } |
272 | - | |
272 | + | |
273 | 273 | /** |
274 | 274 | * ワーカースレッドを開始し、プログレスダイアログを表示し、 |
275 | 275 | * ワーカースレッドの完了まで待機する.<br> |
276 | 276 | * @throws WorkerException ワーカースレッドが例外により終了した場合 |
277 | 277 | */ |
278 | - public void startAndWait() throws WorkerException { | |
278 | + public T startAndWait() throws WorkerException { | |
279 | 279 | // 初期化 |
280 | 280 | result = null; |
281 | 281 | occuredException = null; |
282 | 282 | exitThread = false; |
283 | - | |
283 | + | |
284 | 284 | // ワーカースレッドの開始 |
285 | 285 | thread.start(); |
286 | 286 | try { |
@@ -316,6 +316,8 @@ public class WorkerWithProgessDialog<T> extends JDialog { | ||
316 | 316 | occuredException |
317 | 317 | ); |
318 | 318 | } |
319 | + | |
320 | + return getResult(); | |
319 | 321 | } |
320 | 322 | |
321 | 323 | /** |
@@ -0,0 +1,401 @@ | ||
1 | +package charactermanaj.util; | |
2 | + | |
3 | +import java.io.BufferedOutputStream; | |
4 | +import java.io.File; | |
5 | +import java.io.FileNotFoundException; | |
6 | +import java.io.FileOutputStream; | |
7 | +import java.io.IOException; | |
8 | +import java.io.InputStream; | |
9 | +import java.io.OutputStream; | |
10 | +import java.io.UnsupportedEncodingException; | |
11 | +import java.net.HttpURLConnection; | |
12 | +import java.net.URL; | |
13 | +import java.net.URLDecoder; | |
14 | +import java.util.ArrayList; | |
15 | +import java.util.List; | |
16 | +import java.util.Map; | |
17 | +import java.util.TreeMap; | |
18 | +import java.util.logging.Level; | |
19 | +import java.util.logging.Logger; | |
20 | + | |
21 | +/** | |
22 | + * ダウンロードをサポートする | |
23 | + */ | |
24 | +public final class DownloadUtils { | |
25 | + | |
26 | + /** | |
27 | + * ロガー | |
28 | + */ | |
29 | + private static final Logger logger = Logger.getLogger(DownloadUtils.class.getName()); | |
30 | + | |
31 | + /** | |
32 | + * 偽装するユーザーエージェント名(nullまたは空文字の場合は偽装しない) | |
33 | + */ | |
34 | + private String impersonateUserAgent; | |
35 | + | |
36 | + /** | |
37 | + * 最大ホップ数 | |
38 | + */ | |
39 | + private int maxHop = 10; | |
40 | + | |
41 | + /** | |
42 | + * ダウンロードファイルを終了時に削除するか? | |
43 | + */ | |
44 | + private boolean deleteDownloadFileOnExit = true; | |
45 | + | |
46 | + public void setImpersonateUserAgent(String impersonateUserAgent) { | |
47 | + this.impersonateUserAgent = impersonateUserAgent; | |
48 | + } | |
49 | + | |
50 | + public String getImpersonateUserAgent() { | |
51 | + return impersonateUserAgent; | |
52 | + } | |
53 | + | |
54 | + public void setMaxHop(int maxHop) { | |
55 | + this.maxHop = maxHop; | |
56 | + } | |
57 | + | |
58 | + public int getMaxHop() { | |
59 | + return maxHop; | |
60 | + } | |
61 | + | |
62 | + public void setDeleteDownloadFileOnExit(boolean deleteOnExit) { | |
63 | + deleteDownloadFileOnExit = deleteOnExit; | |
64 | + } | |
65 | + | |
66 | + public boolean isDeleteDownloadFileOnExit() { | |
67 | + return deleteDownloadFileOnExit; | |
68 | + } | |
69 | + | |
70 | + /** | |
71 | + * ヘッドレスポンス | |
72 | + */ | |
73 | + public static final class HeadResponse { | |
74 | + | |
75 | + String location; | |
76 | + | |
77 | + String contentType; | |
78 | + | |
79 | + String fileName; | |
80 | + | |
81 | + public String getLocation() { | |
82 | + return location; | |
83 | + } | |
84 | + | |
85 | + public String getContentType() { | |
86 | + return contentType; | |
87 | + } | |
88 | + | |
89 | + public String getFileName() { | |
90 | + return fileName; | |
91 | + } | |
92 | + | |
93 | + /** | |
94 | + * ファイルの拡張子、なければ空。 | |
95 | + * 返される拡張子はドットを含む。 | |
96 | + * @return ドットで始まる拡張子、もしくは空 | |
97 | + */ | |
98 | + public String getDotExtension() { | |
99 | + String name = fileName; | |
100 | + int pos = name.lastIndexOf('/'); | |
101 | + if (pos >= 0) { | |
102 | + name = name.substring(pos + 1); | |
103 | + } | |
104 | + pos = name.lastIndexOf('\\'); | |
105 | + if (pos >= 0) { | |
106 | + name = name.substring(pos + 1); | |
107 | + } | |
108 | + | |
109 | + int extPos = name.lastIndexOf("."); | |
110 | + String ext = ""; | |
111 | + if (extPos > 0) { | |
112 | + // ドットから始まる拡張子に切り取る | |
113 | + ext = name.substring(extPos).toLowerCase(); | |
114 | + } | |
115 | + return ext; | |
116 | + } | |
117 | + | |
118 | + @Override | |
119 | + public String toString() { | |
120 | + return "location=" + location + ", contentType=" + contentType + ", fileName=" + fileName; | |
121 | + } | |
122 | + } | |
123 | + | |
124 | + /** | |
125 | + * 指定したURLのコンテンツをダウンロードする | |
126 | + * @param location URL | |
127 | + * @param os 出力先 | |
128 | + * @throws IOException 失敗した場合 | |
129 | + */ | |
130 | + public void loadContents(String location, OutputStream os) throws IOException { | |
131 | + loadContents(getHead(location), os); | |
132 | + } | |
133 | + | |
134 | + public void loadContents(HeadResponse headResponse, OutputStream os) throws IOException { | |
135 | + String realLoction = headResponse.getLocation(); | |
136 | + | |
137 | + URL url = new URL(realLoction); | |
138 | + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); | |
139 | + if (impersonateUserAgent != null && impersonateUserAgent.length() > 0) { | |
140 | + conn.setRequestProperty("User-Agent", impersonateUserAgent); | |
141 | + } | |
142 | + conn.connect(); | |
143 | + try { | |
144 | + int status = conn.getResponseCode(); | |
145 | + if (status == HttpURLConnection.HTTP_NOT_FOUND) { // 404 | |
146 | + throw new FileNotFoundException("Failed to load contents. status=" + status + ", url=" + url); | |
147 | + } | |
148 | + if (status < HttpURLConnection.HTTP_OK || status >= HttpURLConnection.HTTP_MULT_CHOICE) { // 200未満、300以上 | |
149 | + throw new IOException("Failed to load contents. status=" + status + ", url=" + url); | |
150 | + } | |
151 | + | |
152 | + byte[] buf = new byte[4096]; | |
153 | + InputStream is = conn.getInputStream(); | |
154 | + try { | |
155 | + for (;;) { | |
156 | + int rd = is.read(buf); | |
157 | + if (rd < 0) { | |
158 | + break; | |
159 | + } | |
160 | + os.write(buf, 0, rd); | |
161 | + } | |
162 | + os.flush(); | |
163 | + } finally { | |
164 | + is.close(); | |
165 | + } | |
166 | + } finally { | |
167 | + conn.disconnect(); | |
168 | + } | |
169 | + } | |
170 | + | |
171 | + /** | |
172 | + * テンポラリディレクトりにコンテンツをダウンロードする | |
173 | + * @param headResponse | |
174 | + * @return テンポラリファイル | |
175 | + * @throws IOException | |
176 | + */ | |
177 | + public File downloadTemporary(HeadResponse headResponse) throws IOException { | |
178 | + String ext = headResponse.getDotExtension(); | |
179 | + if (ext == null || ext.length() == 0) { | |
180 | + ext = ".tmp"; | |
181 | + } | |
182 | + File tmpFile = File.createTempFile("cmj-", ext); | |
183 | + | |
184 | + if (isDeleteDownloadFileOnExit()) { | |
185 | + tmpFile.deleteOnExit(); // 終了時にファイルを消す。(気休め程度) | |
186 | + } | |
187 | + | |
188 | + logger.log(Level.INFO, "Create temporary file: " + tmpFile); | |
189 | + try { | |
190 | + OutputStream bos = new BufferedOutputStream(new FileOutputStream(tmpFile)); | |
191 | + try { | |
192 | + loadContents(headResponse, bos); | |
193 | + | |
194 | + } finally { | |
195 | + bos.close(); | |
196 | + } | |
197 | + | |
198 | + } catch (RuntimeException ex) { | |
199 | + tmpFile.delete(); | |
200 | + logger.log(Level.INFO, "Delete temporary file: " + tmpFile); | |
201 | + throw ex; | |
202 | + | |
203 | + } catch (IOException ex) { | |
204 | + logger.log(Level.INFO, "Delete temporary file: " + tmpFile); | |
205 | + tmpFile.delete(); | |
206 | + throw ex; | |
207 | + } | |
208 | + return tmpFile; | |
209 | + } | |
210 | + | |
211 | + /** | |
212 | + * URLを指定してリダイレクトがある場合はリダイレクトでなくなるまで探索した最後のURLを返す。 | |
213 | + * @param location 開始するURL | |
214 | + * @return 探索されたURL | |
215 | + * @throws IOException 読み込みに失敗した場合、もしくは最大ホップ数を超えた場合 | |
216 | + */ | |
217 | + public HeadResponse getHead(String location) throws IOException { | |
218 | + String initLocation = location; | |
219 | + int hopCount = 0; | |
220 | + for (;;) { | |
221 | + logger.log(Level.INFO, "Connect to " + location); | |
222 | + URL url = new URL(location); | |
223 | + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); | |
224 | + | |
225 | + int status; | |
226 | + conn.setRequestMethod("HEAD"); | |
227 | + conn.setInstanceFollowRedirects(false); // 自動リダイレクトはしない | |
228 | + if (impersonateUserAgent != null && impersonateUserAgent.length() > 0) { | |
229 | + conn.setRequestProperty("User-Agent", impersonateUserAgent); | |
230 | + } | |
231 | + conn.connect(); | |
232 | + try { | |
233 | + status = conn.getResponseCode(); | |
234 | + | |
235 | + } finally { | |
236 | + conn.disconnect(); | |
237 | + } | |
238 | + | |
239 | + if (status == HttpURLConnection.HTTP_MOVED_TEMP || // 302 | |
240 | + status == HttpURLConnection.HTTP_MOVED_PERM || // 301 | |
241 | + status == HttpURLConnection.HTTP_SEE_OTHER) { // 303 | |
242 | + if (hopCount > maxHop) { | |
243 | + // 転送回数が多すぎる! | |
244 | + throw new IOException("too many hops! " + hopCount); | |
245 | + } | |
246 | + location = conn.getHeaderField("Location"); | |
247 | + if (location == null || location.isEmpty()) { | |
248 | + // locationヘッダがない | |
249 | + throw new IOException("bad response. location not found."); | |
250 | + } | |
251 | + hopCount++; | |
252 | + logger.log(Level.INFO, "Location to " + location); | |
253 | + continue; | |
254 | + } | |
255 | + | |
256 | + if (status >= HttpURLConnection.HTTP_OK && status < HttpURLConnection.HTTP_MULT_CHOICE) { // 200以上 300未満 | |
257 | + HeadResponse response = new HeadResponse(); | |
258 | + response.location = location; | |
259 | + response.contentType = conn.getContentType(); | |
260 | + | |
261 | + String contentDisposition = conn.getHeaderField("Content-Disposition"); | |
262 | + String fileName = null; | |
263 | + if (contentDisposition != null && contentDisposition.length() > 0) { | |
264 | + fileName = parseAttachmentFileName(contentDisposition); | |
265 | + } | |
266 | + if (fileName == null || fileName.length() == 0) { | |
267 | + fileName = initLocation; // ファイル名の指定がない場合は最初のロケーション名を使用する | |
268 | + } | |
269 | + response.fileName = fileName; | |
270 | + logger.log(Level.INFO, "response success. " + response); | |
271 | + return response; | |
272 | + } | |
273 | + | |
274 | + if (status == HttpURLConnection.HTTP_NOT_FOUND) { // 404 | |
275 | + // ファイルが見つからない場合 | |
276 | + throw new FileNotFoundException("Failed to load contents. status=" + status + ", url=" + url); | |
277 | + } | |
278 | + | |
279 | + // 何らかのエラー | |
280 | + logger.log(Level.WARNING, "response failed. status=" + status); | |
281 | + throw new IOException("response failed. status=" + status); | |
282 | + } | |
283 | + } | |
284 | + | |
285 | + /** | |
286 | + * セミコロンで行を区切る。 | |
287 | + * (ダブルクォートがある場合は、閉じられるまではセミコロンは無視する。) | |
288 | + * @param line | |
289 | + * @return | |
290 | + */ | |
291 | + private static List<String> splitSemicolon(String line) { | |
292 | + List<String> lines = new ArrayList<String>(); | |
293 | + StringBuilder buf = new StringBuilder(); | |
294 | + int mode = 0; | |
295 | + for (char ch : line.toCharArray()) { | |
296 | + if (mode == 0) { | |
297 | + if (ch == '"') { | |
298 | + // ダブルクォートがある場合は閉じるまでセミコロンを無視する | |
299 | + buf.append((char) ch); | |
300 | + mode = 1; | |
301 | + | |
302 | + } else if (ch == ';') { | |
303 | + lines.add(buf.toString()); | |
304 | + buf.setLength(0); | |
305 | + | |
306 | + } else { | |
307 | + buf.append((char) ch); | |
308 | + } | |
309 | + } else if (mode == 1) { | |
310 | + if (ch == '"') { | |
311 | + buf.append((char) ch); | |
312 | + mode = 0; | |
313 | + | |
314 | + } else { | |
315 | + buf.append((char) ch); | |
316 | + } | |
317 | + } | |
318 | + } | |
319 | + if (buf.length() > 0) { | |
320 | + lines.add(buf.toString()); | |
321 | + } | |
322 | + return lines; | |
323 | + } | |
324 | + | |
325 | + /** | |
326 | + * key=value形式の文字列のリストからマップを生成する。 | |
327 | + * valueがダブルクォートで囲まれている場合はダブルクォートを除去する。 | |
328 | + * @param lines | |
329 | + * @return | |
330 | + */ | |
331 | + private static Map<String, String> parseKeyValuePair(List<String> lines) { | |
332 | + Map<String, String> keyValueMap = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER); | |
333 | + for (String line : lines) { | |
334 | + line = line.trim(); | |
335 | + if (!line.isEmpty()) { | |
336 | + int pos = line.indexOf("="); | |
337 | + String key, value; | |
338 | + if (pos >= 0) { | |
339 | + key = line.substring(0, pos); | |
340 | + value = line.substring(pos + 1); | |
341 | + value = value.trim(); | |
342 | + if (value.startsWith("\"") && value.endsWith("\"")) { | |
343 | + // ダブルクォートで囲まれている場合は外す | |
344 | + value = value.substring(1, value.length() - 1); | |
345 | + } | |
346 | + } else { | |
347 | + key = line; | |
348 | + value = ""; | |
349 | + } | |
350 | + keyValueMap.put(key, value); | |
351 | + } | |
352 | + } | |
353 | + return keyValueMap; | |
354 | + } | |
355 | + | |
356 | + /** | |
357 | + * Content-Dispositionのヘッダーパラメータからファイル名を取得する。 | |
358 | + * @param contentDisposition | |
359 | + * @return | |
360 | + */ | |
361 | + private static String parseAttachmentFileName(String contentDisposition) { | |
362 | + List<String> lines = splitSemicolon(contentDisposition); | |
363 | + logger.log(Level.FINE, "content-dispotion: " + lines); | |
364 | + Map<String, String> kv = parseKeyValuePair(lines); | |
365 | + | |
366 | + String fileName = null; | |
367 | + | |
368 | + // 文字コードつきファイル名パラメータがあれば、それを解析・取得する | |
369 | + String encodedFileName = kv.get("filename*"); | |
370 | + if (encodedFileName != null && encodedFileName.length() > 0) { | |
371 | + // 文字コードの取得(空の場合もありえる) | |
372 | + int pos = encodedFileName.indexOf('\''); | |
373 | + String encoding = encodedFileName.substring(0, pos); | |
374 | + if (encoding.isEmpty()) { | |
375 | + encoding = "utf-8"; // UTF-8をデフォルトとみなす | |
376 | + } | |
377 | + | |
378 | + // 言語の取得(空の場合もありえる) | |
379 | + int pos2 = encodedFileName.indexOf('\'', pos + 1); | |
380 | + String language = encodedFileName.substring(pos + 1, pos2); | |
381 | + | |
382 | + // ファイル名 | |
383 | + try { | |
384 | + fileName = URLDecoder.decode(encodedFileName.substring(pos2 + 1), encoding); | |
385 | + | |
386 | + } catch (UnsupportedEncodingException ex) { | |
387 | + logger.log(Level.WARNING, "url encoding error: " + encodedFileName, ex); | |
388 | + fileName = null; | |
389 | + } | |
390 | + logger.log(Level.INFO, "attachment filename*=" + encoding + "," + language + "," + fileName); | |
391 | + } | |
392 | + | |
393 | + // 文字コードつきファイル名がなければ、文字コードなしファイル名を取得する | |
394 | + if (fileName == null || fileName.length() == 0) { | |
395 | + fileName = kv.get("filename"); | |
396 | + logger.log(Level.INFO, "attachment filename=" + fileName); | |
397 | + } | |
398 | + | |
399 | + return fileName; | |
400 | + } | |
401 | +} |
@@ -73,6 +73,8 @@ If the file already exists, the file is overwritten.]]></entry> | ||
73 | 73 | |
74 | 74 | <entry key="jarTransferBufferSize">90;Jar File Buffer</entry> |
75 | 75 | <entry key="fileTransferBufferSize">91;File Buffer</entry> |
76 | +<entry key="impersonateUserAgent">92;Impersonation of user agent name for download</entry> | |
77 | +<entry key="deleteDownloadFileOnExit">93;Delete the downloaded file in temporary directory upon termination</entry> | |
76 | 78 | |
77 | 79 | <entry key="drawGridMask">A0;Draw grid on preview</entry> |
78 | 80 | <entry key="previewGridColor">A1;Grid color (ARGB)</entry> |
@@ -73,6 +73,8 @@ | ||
73 | 73 | |
74 | 74 | <entry key="jarTransferBufferSize">90;JARファイル用バッファサイズ</entry> |
75 | 75 | <entry key="fileTransferBufferSize">91;ファイル転送用バッファサイズ</entry> |
76 | +<entry key="impersonateUserAgent">92;ダウンロード時に偽装するユーザーエージェント名</entry> | |
77 | +<entry key="deleteDownloadFileOnExit">93;終了時にテンポラリディレクトり上にダウンロードしたファイルを消す</entry> | |
76 | 78 | |
77 | 79 | <entry key="drawGridMask">A0;グリッドを描画する確認モードのビットマスク(0-3, 0は無効にする場合)</entry> |
78 | 80 | <entry key="previewGridColor">A1;プレビュー画面のグリッドカラー(ARGB)</entry> |
@@ -72,6 +72,8 @@ | ||
72 | 72 | |
73 | 73 | <entry key="jarTransferBufferSize">90;Jar文件缓存</entry> |
74 | 74 | <entry key="fileTransferBufferSize">91;文件缓存</entry> |
75 | +<entry key="impersonateUserAgent">92;模拟用户代理名称以供下载</entry> | |
76 | +<entry key="deleteDownloadFileOnExit">93;终止后,在临时目录中删除下载的文件</entry> | |
75 | 77 | |
76 | 78 | <entry key="drawGridMask">A0;预览时显示网格</entry> |
77 | 79 | <entry key="previewGridColor">A1;网格颜色(ARGB)</entry> |
@@ -10,9 +10,15 @@ | ||
10 | 10 | <entry key="browse">Browse</entry> |
11 | 11 | <entry key="importingArchiveFile">Import archived File (zip, cmj)</entry> |
12 | 12 | <entry key="importingDirectory">Import from Directory</entry> |
13 | + <entry key="importingURL">Import from URL</entry> | |
13 | 14 | <entry key="fileNotFound">File not found.</entry> |
14 | 15 | <entry key="directoryNotFound">Directory not found.</entry> |
15 | 16 | |
17 | + <entry key="downloading.checkhead">checking...</entry> | |
18 | + <entry key="downloading.waitForDownload">Downloading...</entry> | |
19 | + <entry key="downloading.invalidFileType">Unsupported file type.</entry> | |
20 | + <entry key="downloading.notFound">File not found.</entry> | |
21 | + | |
16 | 22 | <entry key="confirm.close">Are you sure you want to cancel?</entry> |
17 | 23 | <entry key="confirm">Confirm</entry> |
18 | 24 |
@@ -28,12 +34,16 @@ | ||
28 | 34 | <entry key="description">Note</entry> |
29 | 35 | <entry key="basic.sampleImage">Sample picture</entry> |
30 | 36 | <entry key="appendDescription">Append this description to the profile.</entry> |
31 | - | |
37 | + | |
32 | 38 | <entry key="noContents">No contents.</entry> |
33 | 39 | <entry key="notFormalArchive">This is not a formal archive, but may be containing some picture.</entry> |
34 | 40 | <entry key="unmatchedProfileId">Profile ID mismatch. id="{0}"</entry> |
35 | 41 | <entry key="unmatchedProfileRev">Profile REV mismatch. rev="{0}"</entry> |
36 | 42 | |
43 | + <entry key="sizeOfProfile">Profile Size</entry> | |
44 | + <entry key="widthOfProfile">Width: </entry> | |
45 | + <entry key="heightOfProfile">Height: </entry> | |
46 | + | |
37 | 47 | <entry key="parts.title">Import parts</entry> |
38 | 48 | <entry key="parts.btn.selectAll">select All</entry> |
39 | 49 | <entry key="parts.btn.deselectAll">deselect All</entry> |
@@ -75,8 +85,8 @@ | ||
75 | 85 | <entry key="preset.column.check.size">50</entry> |
76 | 86 | <entry key="preset.column.name.size">100</entry> |
77 | 87 | <entry key="preset.column.missings.size">200</entry> |
78 | - | |
88 | + | |
79 | 89 | <entry key="complete">Complete</entry> |
80 | - | |
90 | + | |
81 | 91 | </properties> |
82 | 92 |
@@ -10,10 +10,16 @@ | ||
10 | 10 | <entry key="browse">参照...</entry> |
11 | 11 | <entry key="importingArchiveFile">アーカイブファイル(zip,cmj)からインポート</entry> |
12 | 12 | <entry key="importingDirectory">フォルダからインポート</entry> |
13 | + <entry key="importingURL">URLからダウンロードしてインポート</entry> | |
13 | 14 | <entry key="file">ファイル:</entry> |
14 | 15 | <entry key="fileNotFound">ファイルがありません。</entry> |
15 | 16 | <entry key="directoryNotFound">フォルダがありません。</entry> |
16 | 17 | |
18 | + <entry key="downloading.checkhead">確認中...</entry> | |
19 | + <entry key="downloading.waitForDownload">ダウンロード中...</entry> | |
20 | + <entry key="downloading.invalidFileType">サポートされていない形式です</entry> | |
21 | + <entry key="downloading.notFound">ファイルがみつかりません</entry> | |
22 | + | |
17 | 23 | <entry key="confirm.close">キャンセルしますか?</entry> |
18 | 24 | <entry key="confirm">確認</entry> |
19 | 25 |
@@ -35,12 +41,16 @@ | ||
35 | 41 | <entry key="unmatchedProfileId">プロファイルIDが一致しません。 id="{0}"</entry> |
36 | 42 | <entry key="unmatchedProfileRev">プロファイルIDは一致しますが、リビジョンが一致しません。 rev="{0}"</entry> |
37 | 43 | |
44 | + <entry key="sizeOfProfile">プロファイルのサイズ</entry> | |
45 | + <entry key="widthOfProfile">幅: </entry> | |
46 | + <entry key="heightOfProfile">高さ: </entry> | |
47 | + | |
38 | 48 | <entry key="parts.title">インポートするパーツ</entry> |
39 | 49 | <entry key="parts.btn.selectAll">全て選択</entry> |
40 | 50 | <entry key="parts.btn.deselectAll">全て解除</entry> |
41 | 51 | <entry key="parts.btn.sort">名前順で整列</entry> |
42 | 52 | <entry key="parts.btn.sortByTimestamp">日付順で整列</entry> |
43 | - | |
53 | + | |
44 | 54 | <entry key="parts.popup.check">チェックする</entry> |
45 | 55 | <entry key="parts.popup.uncheck">チェックを外す</entry> |
46 | 56 |
@@ -67,7 +77,7 @@ | ||
67 | 77 | <entry key="parts.column.org-author.size">80</entry> |
68 | 78 | <entry key="parts.column.version.size">50</entry> |
69 | 79 | <entry key="parts.column.org-version.size">50</entry> |
70 | - | |
80 | + | |
71 | 81 | <entry key="preset.title">インポートするお気に入り</entry> |
72 | 82 | <entry key="preset.popup.selectUsedParts">使用しているパーツのインポート</entry> |
73 | 83 | <entry key="preset.column.check">選択</entry> |
@@ -78,6 +88,6 @@ | ||
78 | 88 | <entry key="preset.column.missings.size">200</entry> |
79 | 89 | |
80 | 90 | <entry key="complete">インポートが完了しました。</entry> |
81 | - | |
91 | + | |
82 | 92 | </properties> |
83 | 93 |
@@ -10,9 +10,15 @@ | ||
10 | 10 | <entry key="browse">浏览</entry> |
11 | 11 | <entry key="importingArchiveFile">导入压缩文件(zip,cmj)</entry> |
12 | 12 | <entry key="importingDirectory">从文件夹导入</entry> |
13 | + <entry key="importingURL">通过指定URL导入</entry> | |
13 | 14 | <entry key="fileNotFound">找不到文件</entry> |
14 | 15 | <entry key="directoryNotFound">找不到文件夹</entry> |
15 | 16 | |
17 | + <entry key="downloading.checkhead">检查...</entry> | |
18 | + <entry key="downloading.waitForDownload">在下载...</entry> | |
19 | + <entry key="downloading.invalidFileType">不支持的格式</entry> | |
20 | + <entry key="downloading.notFound">找不到档案</entry> | |
21 | + | |
16 | 22 | <entry key="confirm.close">你确认要取消么?</entry> |
17 | 23 | <entry key="confirm">确认</entry> |
18 | 24 |
@@ -75,8 +81,8 @@ | ||
75 | 81 | <entry key="preset.column.check.size">50</entry> |
76 | 82 | <entry key="preset.column.name.size">100</entry> |
77 | 83 | <entry key="preset.column.missings.size">200</entry> |
78 | - | |
84 | + | |
79 | 85 | <entry key="complete">完成</entry> |
80 | - | |
86 | + | |
81 | 87 | </properties> |
82 | 88 |
@@ -15,4 +15,9 @@ | ||
15 | 15 | <entry key="help.reportbugs.url">http://osdn.net/projects/charactermanaj/ticket/</entry> |
16 | 16 | <entry key="help.forum.description">Forum</entry> |
17 | 17 | <entry key="help.forum.url">http://osdn.net/projects/charactermanaj/forums/</entry> |
18 | + | |
19 | + <entry key="defaultdatadownload.confirm.message">There is default character data. Do you want to download it?</entry> | |
20 | + <entry key="defaultdatadownload.confirm.title">Default character data download</entry> | |
21 | + <entry key="noDownloadAndDoNotAskAgain">I do not want to download, and do not ask me again.</entry> | |
18 | 22 | </properties> |
23 | + |
@@ -15,4 +15,8 @@ | ||
15 | 15 | <entry key="help.reportbugs.url">http://osdn.net/projects/charactermanaj/ticket/</entry> |
16 | 16 | <entry key="help.forum.description">フォーラムは以下のURLにあります。</entry> |
17 | 17 | <entry key="help.forum.url">http://osdn.net/projects/charactermanaj/forums/</entry> |
18 | + | |
19 | + <entry key="defaultdatadownload.confirm.message">デフォルトのキャラクターデータがあります。ダウンロードしますか?</entry> | |
20 | + <entry key="defaultdatadownload.confirm.title">キャラクターデータのダウンロード</entry> | |
21 | + <entry key="noDownloadAndDoNotAskAgain">ダウンロードしない。今後の確認も不要である。</entry> | |
18 | 22 | </properties> |
@@ -15,4 +15,8 @@ | ||
15 | 15 | <entry key="help.reportbugs.url">http://osdn.net/projects/charactermanaj/ticket/</entry> |
16 | 16 | <entry key="help.forum.description">论坛(日)</entry> |
17 | 17 | <entry key="help.forum.url">http://osdn.net/projects/charactermanaj/forums/</entry> |
18 | + | |
19 | + <entry key="defaultdatadownload.confirm.message">有默认数据。你想下载吗?</entry> | |
20 | + <entry key="defaultdatadownload.confirm.title">下载默认数据</entry> | |
21 | + <entry key="noDownloadAndDoNotAskAgain">我不想下载,也不要再问我了</entry> | |
18 | 22 | </properties> |
@@ -313,6 +313,11 @@ | ||
313 | 313 | <description xml:lang="zh_TW">パーツ保管庫 (零件的保管庫)</description> |
314 | 314 | <URL xml:lang="en">https://charactermanaj.osdn.jp/upload.html</URL> |
315 | 315 | </recommendation> |
316 | + <recommendation> | |
317 | + <description xml:lang="en">*Default PartsSet (K.Hmix 1st Edition)</description> | |
318 | + <description xml:lang="ja">*キャラクターなんとか機のパーツデータをダウンロードする (K.Hmix 1st Edition)</description> | |
319 | + <URL xml:lang="en">http://charactermanaj.osdn.jp/ext/default_characterset_v3.zip</URL> | |
320 | + </recommendation> | |
316 | 321 | </recommendations> |
317 | 322 | |
318 | 323 | </character> |