• R/O
  • SSH
  • HTTPS

jpki: Commit


Commit MetaInfo

Revisão66 (tree)
Hora2023-01-08 17:37:44
Autorhirukawa_ryo

Mensagem de Log

JPKI PDF SIGNER 1.2.7
依存ライブラリ
pdfbox 2.0.26 -> 2.0.27
jackson-databind 2.13.3 -> 2.14.1
bouncycastle bcpkix jdk15on 1.70 -> jdk18on 1.72
fx-util 0.4.5 -> 0.5.0
jpki-wrapper 0.3.7 -> 0.3.8
gradle 7.5.1 -> 7.6
exewrap 1.6.5 -> 1.6.6

Mudança Sumário

Diff

Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
--- jpki-pdf-signer/trunk/src/main/java/net/osdn/jpki/pdf_signer/Datastore.java (revision 65)
+++ jpki-pdf-signer/trunk/src/main/java/net/osdn/jpki/pdf_signer/Datastore.java (revision 66)
@@ -127,13 +127,6 @@
127127 return version;
128128 }
129129
130- public static boolean isRunningAsUWP() {
131- if(isRunningAsUWP == null) {
132- isRunningAsUWP = Files.exists(Datastore.getApplicationDirectory().resolve("AppxManifest.xml"));
133- }
134- return isRunningAsUWP;
135- }
136-
137130 public static String getLicense() throws IOException {
138131 if(license == null) {
139132 InputStream is = null;
--- jpki-pdf-signer/trunk/src/main/java/net/osdn/jpki/pdf_signer/MainApp.css (revision 65)
+++ jpki-pdf-signer/trunk/src/main/java/net/osdn/jpki/pdf_signer/MainApp.css (revision 66)
@@ -1,6 +1,6 @@
11 .root {
22 -fx-font-family: "Meiryo";
3- -fx-font-size: 12px;
3+ -fx-font-size: 12;
44 }
55
66 FontIcon {
@@ -16,7 +16,7 @@
1616 -fx-background-insets: 0;
1717 }
1818 .list-cell {
19- -fx-padding: 0px;
19+ -fx-padding: 0;
2020 }
2121 .list-cell:selected {
2222 -fx-background-color: -fx-accent;
@@ -30,15 +30,16 @@
3030 }
3131 #buttonBox > .label {
3232 -fx-alignment: center;
33- -fx-min-width: 80px;
34- -fx-font-size: 14px;
33+ -fx-min-width: 80;
34+ -fx-font-size: 12;
3535 -fx-text-fill: #F2F2F2;
3636 }
3737 #buttonBox .button {
38- -fx-padding: 0 10px 0 7px;
39- -fx-min-height: 25px;
40- -fx-pref-height: 25px;
41- -fx-min-width: 40px;
38+ -fx-font-size: 12;
39+ -fx-padding: 0 16 0 12;
40+ -fx-min-height: 25;
41+ -fx-pref-height: 25;
42+ -fx-min-width: 40;
4243 -fx-background-insets: 0;
4344 -fx-background-radius: 0;
4445 -fx-background-color: transparent;
--- jpki-pdf-signer/trunk/src/main/java/net/osdn/jpki/pdf_signer/MainApp.java (revision 65)
+++ jpki-pdf-signer/trunk/src/main/java/net/osdn/jpki/pdf_signer/MainApp.java (revision 66)
@@ -33,9 +33,11 @@
3333 import net.osdn.jpki.pdf_signer.control.Toast;
3434 import net.osdn.jpki.wrapper.JpkiException;
3535 import net.osdn.jpki.wrapper.JpkiWrapper;
36+import net.osdn.util.javafx.Unchecked;
3637 import net.osdn.util.javafx.application.SingletonApplication;
37-import net.osdn.util.javafx.concurrent.Async;
38+import net.osdn.util.javafx.concurrent.AsyncTask;
3839 import net.osdn.util.javafx.fxml.Fxml;
40+import net.osdn.util.javafx.scene.SceneUtil;
3941 import net.osdn.util.javafx.scene.control.Dialogs;
4042 import net.osdn.util.javafx.scene.control.pdf.Pager;
4143 import net.osdn.util.javafx.scene.control.pdf.PdfView;
@@ -65,6 +67,8 @@
6567 import java.nio.file.StandardCopyOption;
6668 import java.util.List;
6769 import java.util.ResourceBundle;
70+import java.util.concurrent.ExecutorService;
71+import java.util.concurrent.Executors;
6872 import java.util.prefs.Preferences;
6973
7074 public class MainApp extends SingletonApplication implements Initializable {
@@ -72,6 +76,8 @@
7276 public static final String APPLICATION_NAME = "JPKI PDF SIGNER";
7377 public static final String APPLICATION_VERSION;
7478
79+ public static ExecutorService serialExecutor = Executors.newSingleThreadExecutor();
80+
7581 static {
7682 System.setProperty(
7783 "org.apache.commons.logging.LogFactory", "net.osdn.jpki.pdf_signer.LogFilter");
@@ -117,12 +123,18 @@
117123 Parent root = Fxml.load(this);
118124
119125 Scene scene = new Scene(root);
120- scene.setOnDragOver(wrap(this::scene_onDragOver));
121- scene.setOnDragDropped(wrap(this::scene_onDragDropped));
126+ scene.setOnDragOver(event -> Unchecked.execute(() -> {
127+ scene_onDragOver(event);
128+ }));
129+ scene.setOnDragDropped(event -> Unchecked.execute(() -> {
130+ scene_onDragDropped(event);
131+ }));
122132 scene.getAccelerators().putAll(pager.createDefaultAccelerators());
123133
124134 StageUtil.setRestorable(primaryStage, Preferences.userNodeForPackage(getClass()));
125- primaryStage.setOnShown(event -> { Platform.runLater(wrap(this::stage_onReady)); });
135+ primaryStage.setOnShown(event -> SceneUtil.invokeAfterLayout(root, Unchecked.runnable(() -> {
136+ stage_onReady();
137+ })));
126138 primaryStage.setMinWidth(448.0);
127139 primaryStage.setMinHeight(396.0);
128140 primaryStage.setOpacity(0.0);
@@ -153,7 +165,7 @@
153165 if(message != null) {
154166 message = message.trim();
155167 }
156- toast.show(Toast.RED, title, message, null);
168+ toast.show(Toast.COLOR_ERROR, title, message);
157169 };
158170 if(Platform.isFxApplicationThread()) {
159171 r.run();
@@ -187,15 +199,33 @@
187199 //
188200 // event handlers
189201 //
190- menuFileOpen.setOnAction(wrap(this::menuFileOpen_onAction));
191- menuFileSave.setOnAction(wrap(this::menuFileSave_onAction));
192- menuFileExit.setOnAction(wrap(this::menuFileExit_onAction));
193- menuHelpAbout.setOnAction(wrap(this::menuHelpAbout_onAction));
194- pdfView.setOnMouseMoved(wrap(this::pdfView_onMouseMoved));
195- pdfView.setOnMouseClicked(wrap(this::pdfView_onMouseClicked));
196- btnRemoveSignature.setOnAction(wrap(this::btnRemoveSignature_onAction));
197- btnEditSignature.setOnAction(wrap(this::btnEditSignature_onAction));
198- btnAddSignature.setOnAction(wrap(this::btnAddSignature_onAction));
202+ menuFileOpen.setOnAction(event -> Unchecked.execute(() -> {
203+ menuFileOpen_onAction(event);
204+ }));
205+ menuFileSave.setOnAction(event -> Unchecked.execute(() -> {
206+ menuFileSave_onAction(event);
207+ }));
208+ menuFileExit.setOnAction(event -> Unchecked.execute(() -> {
209+ menuFileExit_onAction(event);
210+ }));
211+ menuHelpAbout.setOnAction(event -> Unchecked.execute(() -> {
212+ menuHelpAbout_onAction(event);
213+ }));
214+ pdfView.setOnMouseMoved(event -> Unchecked.execute(() -> {
215+ pdfView_onMouseMoved(event);
216+ }));
217+ pdfView.setOnMouseClicked(event -> Unchecked.execute(() -> {
218+ pdfView_onMouseClicked(event);
219+ }));
220+ btnRemoveSignature.setOnAction(event -> Unchecked.execute(() -> {
221+ btnRemoveSignature_onAction(event);
222+ }));
223+ btnEditSignature.setOnAction(event -> Unchecked.execute(() -> {
224+ btnEditSignature_onAction(event);
225+ }));
226+ btnAddSignature.setOnAction(event -> Unchecked.execute(() -> {
227+ btnAddSignature_onAction(event);
228+ }));
199229
200230 //
201231 // bindings
@@ -242,18 +272,16 @@
242272
243273 lvSignature.getItems().clear();
244274 lvSignature.getItems().add(Signature.INVISIBLE);
245- Async.execute(() -> {
275+ MainApp.serialExecutor.execute(AsyncTask.create(() -> {
246276 return Datastore.loadSignatures();
247277 }).onSucceeded(signatures -> {
248278 for (Signature signature : signatures) {
249279 lvSignature.getItems().add(signature);
250280 }
251- Platform.runLater(() -> {
252- checkJpkiAvailability();
253- });
281+ checkJpkiAvailability();
254282 }).onFailed(exception -> {
255283 showException(exception);
256- });
284+ }));
257285 }
258286
259287 void scene_onDragOver(DragEvent event) {
@@ -321,7 +349,7 @@
321349 File file = fc.showSaveDialog(getPrimaryStage());
322350 if(file != null) {
323351 Files.copy(signedTemporaryFileProperty.get().toPath(), file.toPath(), StandardCopyOption.REPLACE_EXISTING);
324- toast.show(Toast.GREEN, "保存しました", file.getPath(), Toast.LONG);
352+ toast.show(Toast.COLOR_SUCCESS, "保存しました", file.getPath());
325353 }
326354 }
327355
@@ -400,7 +428,7 @@
400428 if(!event.isPrimaryButtonDown()) {
401429 return;
402430 } else if(pdfView.getDocument() == null) {
403- toast.show(Toast.GREEN,
431+ toast.show(Toast.COLOR_SUCCESS,
404432 "はじめに",
405433 "PDFファイルをこのウィンドウにドラッグ&ドロップして表示しましょう。");
406434 } else if(checkJpkiAvailability()) {
@@ -413,21 +441,23 @@
413441 SignatureOptions options = null;
414442
415443 busyProperty.set(true);
416- Async.execute(() -> sign(document, null, APPLICATION_NAME, APPLICATION_VERSION))
417- .onSucceeded(tmpFile -> {
418- if(tmpFile != null) {
419- signedTemporaryFileProperty.set(tmpFile);
420- pdfView.load(tmpFile, pageIndex);
421- busyProperty.set(false);
444+ MainApp.serialExecutor.execute(AsyncTask.create(() -> {
445+ return sign(document, null, APPLICATION_NAME, APPLICATION_VERSION);
446+ }).onSucceeded(tmpFile -> {
447+ if(tmpFile != null) {
448+ signedTemporaryFileProperty.set(tmpFile);
449+ pdfView.load(tmpFile, pageIndex);
450+ busyProperty.set(false);
422451
423- if(ButtonType.YES == Dialogs.showConfirmation(getPrimaryStage(),
424- APPLICATION_NAME + " " + APPLICATION_VERSION,
425- "署名が完了しました。\nファイルに名前を付けて保存しますか?")) {
426- menuFileSave.fire();
427- }
452+ if(ButtonType.YES == Dialogs.showConfirmation(getPrimaryStage(),
453+ APPLICATION_NAME + " " + APPLICATION_VERSION,
454+ "署名が完了しました。\nファイルに名前を付けて保存しますか?")) {
455+ menuFileSave.fire();
428456 }
429- })
430- .onCompleted(state -> busyProperty.set(false));
457+ }
458+ }).onFinished(state -> {
459+ busyProperty.set(false);
460+ }));
431461 }
432462 }
433463 } finally {
@@ -568,21 +598,23 @@
568598
569599 lvSignature.getSelectionModel().clearSelection();
570600 busyProperty.set(true);
571- Async.execute(() -> sign(document, options, APPLICATION_NAME, APPLICATION_VERSION))
572- .onSucceeded(tmpFile -> {
573- if(tmpFile != null) {
574- signedTemporaryFileProperty.set(tmpFile);
575- pdfView.load(tmpFile, pageIndex);
576- busyProperty.set(false);
601+ MainApp.serialExecutor.execute(AsyncTask.create(() -> {
602+ return sign(document, options, APPLICATION_NAME, APPLICATION_VERSION);
603+ }).onSucceeded(tmpFile -> {
604+ if(tmpFile != null) {
605+ signedTemporaryFileProperty.set(tmpFile);
606+ pdfView.load(tmpFile, pageIndex);
607+ busyProperty.set(false);
577608
578- if(ButtonType.YES == Dialogs.showConfirmation(getPrimaryStage(), APPLICATION_NAME + " " + APPLICATION_VERSION,
579- "署名が完了しました。\nファイルに名前を付けて保存しますか?")) {
580- menuFileSave.fire();
581- }
582- lvSignature.getSelectionModel().clearSelection();
609+ if(ButtonType.YES == Dialogs.showConfirmation(getPrimaryStage(), APPLICATION_NAME + " " + APPLICATION_VERSION,
610+ "署名が完了しました。\nファイルに名前を付けて保存しますか?")) {
611+ menuFileSave.fire();
583612 }
584- })
585- .onCompleted(state -> busyProperty.set(false));
613+ lvSignature.getSelectionModel().clearSelection();
614+ }
615+ }).onFinished(state -> {
616+ busyProperty.set(false);
617+ }));
586618 }
587619
588620 protected File getFile(DragEvent event) {
@@ -602,23 +634,15 @@
602634 protected boolean checkJpkiAvailability() {
603635 boolean isAvailable = JpkiWrapper.isAvailable();
604636 if(!isAvailable) {
605- // JPKI 利用者クライアントソフトがインストールされていない場合、
606- // インストールを促すために、クリックで公的個人認証サービスのウェブサイトが開くようにします。
607- // ただし、Microsoft Storeアプリではストア以外でのアプリインストールを促すことが禁止されているため
608- // UWPとして実行されている場合にはウェブサイトを開く機能を提供せずメッセージ表示のみに留めています。
609- if(Datastore.isRunningAsUWP()) {
610- toast.show(Toast.GREEN, "構成", "JPKI 利用者クライアントソフトが見つかりません。");
611- } else {
612- Runnable actionOnClick = wrap(() -> {
613- toast.hide();
614- Desktop.getDesktop().browse(URI.create("https://www.jpki.go.jp/download/win.html"));
615- });
616- toast.show(Toast.GREEN, "事前準備", ""
617- + "JPKI 利用者クライアントソフトをインストールしてください。\n"
618- + "ここをクリックするとブラウザーでダウンロードサイトを開きます。",
619- null,
620- actionOnClick);
621- }
637+ toast.show(
638+ Toast.COLOR_SUCCESS,
639+ "事前準備",
640+ "JPKI 利用者クライアントソフトをインストールしてください。\n" +
641+ "ここをクリックするとブラウザーでダウンロードサイトを開きます。",
642+ Unchecked.runnable(() -> {
643+ toast.hide();
644+ Desktop.getDesktop().browse(URI.create("https://www.jpki.go.jp/download/win.html"));
645+ }));
622646 }
623647 return isAvailable;
624648 }
--- jpki-pdf-signer/trunk/src/main/java/net/osdn/jpki/pdf_signer/SignatureDialog.css (revision 65)
+++ jpki-pdf-signer/trunk/src/main/java/net/osdn/jpki/pdf_signer/SignatureDialog.css (revision 66)
@@ -1,6 +1,9 @@
11 .dialog-pane > .content {
2+ -fx-font-family: "Meiryo";
3+ -fx-font-size: 12;
24 -fx-padding: 0.833em 0.833em 0 0.833em;
35 }
6+
47 #ivImage {
58 -fx-background-color: white;
69 }
--- jpki-pdf-signer/trunk/src/main/java/net/osdn/jpki/pdf_signer/SignatureDialog.java (revision 65)
+++ jpki-pdf-signer/trunk/src/main/java/net/osdn/jpki/pdf_signer/SignatureDialog.java (revision 66)
@@ -1,22 +1,14 @@
11 package net.osdn.jpki.pdf_signer;
22
33 import javafx.beans.binding.DoubleBinding;
4-import javafx.beans.binding.ObjectBinding;
54 import javafx.beans.property.DoubleProperty;
6-import javafx.beans.value.ChangeListener;
7-import javafx.beans.value.ObservableValue;
85 import javafx.event.ActionEvent;
9-import javafx.event.Event;
10-import javafx.event.EventHandler;
116 import javafx.fxml.FXML;
127 import javafx.fxml.Initializable;
13-import javafx.geometry.Bounds;
148 import javafx.geometry.Dimension2D;
15-import javafx.geometry.Rectangle2D;
169 import javafx.scene.Node;
1710 import javafx.scene.control.Button;
1811 import javafx.scene.control.ButtonType;
19-import javafx.scene.control.Dialog;
2012 import javafx.scene.control.DialogEvent;
2113 import javafx.scene.control.TextField;
2214 import javafx.scene.image.Image;
@@ -25,9 +17,9 @@
2517 import javafx.stage.Stage;
2618 import javafx.stage.Window;
2719 import javafx.util.Callback;
28-import net.osdn.util.javafx.event.SilentCallback;
29-import net.osdn.util.javafx.event.SilentEventHandler;
20+import net.osdn.util.javafx.Unchecked;
3021 import net.osdn.util.javafx.fxml.Fxml;
22+import net.osdn.util.javafx.scene.SceneUtil;
3123 import net.osdn.util.javafx.scene.control.DialogEx;
3224
3325 import java.io.ByteArrayInputStream;
@@ -40,6 +32,7 @@
4032 import java.security.NoSuchAlgorithmException;
4133 import java.util.Arrays;
4234 import java.util.ResourceBundle;
35+import java.util.concurrent.Callable;
4336 import java.util.prefs.Preferences;
4437
4538 public class SignatureDialog extends DialogEx<Signature> implements Initializable {
@@ -60,8 +53,12 @@
6053 Node content = Fxml.load(this);
6154 getDialogPane().setContent(content);
6255 getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
63- setOnShowing(wrap(this::dialog_onShowing));
64- setResultConverter(wrap(this::dialog_onResult));
56+ setOnShowing(event -> SceneUtil.invokeAfterLayout(getDialogPane(), Unchecked.runnable(() -> {
57+ dialog_onShowing(event);
58+ })));
59+ setResultConverter(param -> Unchecked.execute(() -> {
60+ return dialog_onResult(param);
61+ }));
6562
6663 if(signature != null) {
6764 ivImage.setImage(signature.getImage());
@@ -71,6 +68,14 @@
7168 } else {
7269 btnBrowse.requestFocus();
7370 }
71+
72+ Node btn;
73+ if((btn = getDialogPane().lookupButton(ButtonType.OK)) != null) {
74+ btn.setStyle("-fx-font-family: Meiryo; -fx-font-size: 12; -fx-min-width: 96");
75+ }
76+ if((btn = getDialogPane().lookupButton(ButtonType.CANCEL)) != null) {
77+ btn.setStyle("-fx-font-family: Meiryo; -fx-font-size: 12; -fx-min-width: 96");
78+ }
7479 }
7580
7681 @FXML Button btnBrowse;
@@ -111,10 +116,18 @@
111116 }
112117 });
113118
114- btnBrowse.setOnAction(wrap(this::tfBrowse_onAction));
115- tfTitle.setOnAction(wrap(this::tfTitle_onAction));
116- tfWidthMillis.setOnAction(wrap(this::tfWidthMillis_onAction));
117- tfHeightMillis.setOnAction(wrap(this::tfHeightMillis_onAction));
119+ btnBrowse.setOnAction(event -> Unchecked.execute(() -> {
120+ tfBrowse_onAction(event);
121+ }));
122+ tfTitle.setOnAction(event -> Unchecked.execute(() -> {
123+ tfTitle_onAction(event);
124+ }));
125+ tfWidthMillis.setOnAction(event -> Unchecked.execute(() -> {
126+ tfWidthMillis_onAction(event);
127+ }));
128+ tfHeightMillis.setOnAction(event -> Unchecked.execute(() -> {
129+ tfHeightMillis_onAction(event);
130+ }));
118131 }
119132
120133 void dialog_onShowing(DialogEvent event) {
@@ -234,14 +247,4 @@
234247 }
235248 return new Dimension2D(prefWidth, prefHeight);
236249 }
237-
238- @SuppressWarnings("overloads")
239- protected <T extends Event> EventHandler<T> wrap(SilentEventHandler<T> handler) {
240- return SilentEventHandler.wrap(handler);
241- }
242-
243- @SuppressWarnings("overloads")
244- protected <P, R> Callback<P, R> wrap(SilentCallback<P, R> callback) {
245- return SilentCallback.wrap(callback);
246- }
247250 }
--- jpki-pdf-signer/trunk/src/main/java/net/osdn/jpki/pdf_signer/SignatureListCell.css (revision 65)
+++ jpki-pdf-signer/trunk/src/main/java/net/osdn/jpki/pdf_signer/SignatureListCell.css (revision 66)
@@ -1,3 +1,4 @@
11 .label {
2- -fx-font: 13px 'Meiryo';
2+ -fx-font-family: "Meiryo";
3+ -fx-font-size: 14;
34 }
--- jpki-pdf-signer/trunk/src/main/java/net/osdn/jpki/pdf_signer/SignatureListCell.java (revision 65)
+++ jpki-pdf-signer/trunk/src/main/java/net/osdn/jpki/pdf_signer/SignatureListCell.java (revision 66)
@@ -9,7 +9,7 @@
99 import javafx.scene.control.MenuItem;
1010 import javafx.scene.image.ImageView;
1111 import javafx.util.Callback;
12-import net.osdn.util.javafx.event.SilentEventHandler;
12+import net.osdn.util.javafx.Unchecked;
1313 import net.osdn.util.javafx.fxml.Fxml;
1414
1515 public class SignatureListCell extends ListCell<Signature> {
@@ -27,8 +27,12 @@
2727 Node node = Fxml.load(this);
2828 setText(null);
2929 setGraphic(node);
30- setOnMousePressed(SilentEventHandler.wrap(factory.mainApp::lvSignature_cell_onMousePressed));
31- setOnMouseClicked(SilentEventHandler.wrap(factory.mainApp::lvSignature_cell_onMouseClicked));
30+ setOnMousePressed(event -> Unchecked.execute(() -> {
31+ this.factory.mainApp.lvSignature_cell_onMousePressed(event);
32+ }));
33+ setOnMouseClicked(event -> Unchecked.execute(() -> {
34+ this.factory.mainApp.lvSignature_cell_onMouseClicked(event);
35+ }));
3236 }
3337
3438 @Override
@@ -72,9 +76,15 @@
7276
7377 public Factory(MainApp mainApp) {
7478 this.mainApp = mainApp;
75- menuAddSignature.setOnAction(SilentEventHandler.wrap(mainApp::btnAddSignature_onAction));
76- menuEditSignature.setOnAction(SilentEventHandler.wrap(mainApp::btnEditSignature_onAction));
77- menuRemoveSignature.setOnAction(SilentEventHandler.wrap(mainApp::btnRemoveSignature_onAction));
79+ menuAddSignature.setOnAction(event -> Unchecked.execute(() -> {
80+ this.mainApp.btnAddSignature_onAction(event);
81+ }));
82+ menuEditSignature.setOnAction(event -> Unchecked.execute(() -> {
83+ this.mainApp.btnEditSignature_onAction(event);
84+ }));
85+ menuRemoveSignature.setOnAction(event -> Unchecked.execute(() -> {
86+ this.mainApp.btnRemoveSignature_onAction(event);
87+ }));
7888 }
7989
8090 @Override
--- jpki-pdf-signer/trunk/src/main/java/net/osdn/jpki/pdf_signer/control/LicenseDialog.css (revision 65)
+++ jpki-pdf-signer/trunk/src/main/java/net/osdn/jpki/pdf_signer/control/LicenseDialog.css (revision 66)
@@ -1,7 +1,7 @@
11 TextFlow {
2- -fx-padding: 15px;
2+ -fx-padding: 15;
33 -fx-font-family: "Meiryo";
4- -fx-font-size: 12px;
4+ -fx-font-size: 12;
55 -fx-background-color: #FAFAFA;
66 }
77 TextFlow Text {
--- jpki-pdf-signer/trunk/src/main/java/net/osdn/jpki/pdf_signer/control/LicenseDialog.java (revision 65)
+++ jpki-pdf-signer/trunk/src/main/java/net/osdn/jpki/pdf_signer/control/LicenseDialog.java (revision 66)
@@ -12,7 +12,9 @@
1212 import javafx.scene.text.Text;
1313 import javafx.scene.text.TextFlow;
1414 import javafx.stage.Window;
15+import net.osdn.util.javafx.Unchecked;
1516 import net.osdn.util.javafx.fxml.Fxml;
17+import net.osdn.util.javafx.scene.SceneUtil;
1618 import net.osdn.util.javafx.scene.control.DialogEx;
1719
1820 import java.awt.Desktop;
@@ -39,12 +41,19 @@
3941 getDialogPane().getButtonTypes().addAll(ButtonType.CLOSE);
4042 scrollPane.prefViewportWidthProperty().bind(textFlow.widthProperty());
4143 scrollPane.prefViewportHeightProperty().bind(textFlow.heightProperty());
42- setOnShown(event -> { Platform.runLater(wrap(this::dialog_onReady)); });
44+ setOnShown(event -> SceneUtil.invokeAfterLayout(getDialogPane(), Unchecked.runnable(() -> {
45+ dialog_onReady();
46+ })));
4347 getDialogPane().getContent().setOpacity(0.0);
4448
4549 Node[] nodes = build(license);
4650 textFlow.getChildren().addAll(nodes);
4751
52+ Node btn;
53+ if((btn = getDialogPane().lookupButton(ButtonType.CLOSE)) != null) {
54+ btn.setStyle("-fx-font-family: Meiryo; -fx-font-size: 12");
55+ }
56+
4857 // ダイアログが表示されるまで「閉じる」ボタンを無効にしておきます。
4958 // これでtextFlowに初期フォーカスが当たるようになります。
5059 getDialogPane().lookupButton(ButtonType.CLOSE).disableProperty().bind(
--- jpki-pdf-signer/trunk/src/main/java/net/osdn/jpki/pdf_signer/control/Toast.css (revision 65)
+++ jpki-pdf-signer/trunk/src/main/java/net/osdn/jpki/pdf_signer/control/Toast.css (revision 66)
@@ -1,73 +1,18 @@
1-#background {
1+.container {
22 -fx-background-color: rgb(39, 40, 34);
33 -fx-background-radius: 5;
4- -fx-effect: dropshadow(three-pass-box, black, 10, 0, 1, 1);
4+ -fx-effect: dropshadow(two-pass-box, black, 10, 0, 1, 1);
55 }
66
7-#btnClose {
7+.label.title {
8+ -fx-padding: 7 12 0 12;
89 -fx-font-size: 16;
9- -fx-padding: 1 8 0 0;
10- -fx-min-width: 0;
11- -fx-min-height: 0;
12- -fx-background-color: transparent;
13- -fx-background-radius: 0;
14- -fx-background-insets: 0;
15- -fx-text-fill: #808080;
16-}
17-#btnClose:hover {
18- -fx-text-fill: #F0F0F0;
19-}
20-#btnClose:pressed {
21- -fx-text-fill: #C0C0C0;
22-}
23-
24-#lblTitle {
25- -fx-font-size: 12;
2610 -fx-wrap-text: false;
27- -fx-padding: 0 18 0 0;
2811 }
2912
30-#lblMessage {
31- -fx-font-size: 12;
13+.label.message {
14+ -fx-padding: 0 12 7 12;
15+ -fx-font-size: 14;
3216 -fx-wrap-text: true;
17+ -fx-text-fill: #f0f0f0;
3318 }
34-
35-.scroll-pane {
36- -fx-min-height: 0;
37- -fx-hbar-policy: never;
38- -fx-vbar-policy: as-needed;
39- -fx-background-color: transparent;
40-}
41-.scroll-pane .viewport {
42- -fx-background-color: transparent;
43-}
44-.scroll-bar:vertical {
45- -fx-background-color: transparent;
46- -fx-padding: 0;
47-}
48-.scroll-bar:vertical .track {
49- -fx-background-color: transparent;
50-}
51-.scroll-bar:vertical .thumb {
52- -fx-background-color: #474844;
53- -fx-background-insets: 0;
54- -fx-background-radius: 0;
55-}
56-.scroll-bar:vertical .thumb:hover {
57- -fx-background-color: #525250;
58-}
59-.scroll-bar:vertical .thumb:pressed {
60- -fx-background-color: #636460;
61-}
62-.scroll-bar:vertical .increment-button,
63-.scroll-bar:vertical .decrement-button {
64- -fx-padding: 0px;
65-}
66-.scroll-bar:vertical .increment-arrow,
67-.scroll-bar:vertical .decrement-arrow {
68- -fx-padding: 0 5 0 5;
69-}
70-.scroll-bar:horizontal .increment-arrow,
71-.scroll-bar:horizontal .decrement-arrow {
72- -fx-padding: 5 0 5 0;
73-}
--- jpki-pdf-signer/trunk/src/main/java/net/osdn/jpki/pdf_signer/control/Toast.java (revision 65)
+++ jpki-pdf-signer/trunk/src/main/java/net/osdn/jpki/pdf_signer/control/Toast.java (revision 66)
@@ -7,38 +7,26 @@
77 import javafx.animation.TranslateTransition;
88 import javafx.application.Platform;
99 import javafx.beans.binding.Bindings;
10-import javafx.event.ActionEvent;
11-import javafx.geometry.Insets;
12-import javafx.scene.Cursor;
13-import javafx.scene.control.Button;
10+import javafx.fxml.FXML;
1411 import javafx.scene.control.Label;
15-import javafx.scene.control.ScrollPane;
16-import javafx.scene.layout.AnchorPane;
17-import javafx.scene.layout.BorderPane;
18-import javafx.scene.layout.StackPane;
12+import javafx.scene.layout.Pane;
1913 import javafx.scene.paint.Color;
2014 import javafx.util.Duration;
15+import net.osdn.util.javafx.Unchecked;
16+import net.osdn.util.javafx.fxml.Fxml;
2117
22-public class Toast extends StackPane {
23-
24- public static final Color RED = Color.rgb(249, 38, 114);
25- public static final Color GREEN = Color.rgb(166, 226, 46);
26- public static final Color BLUE = Color.rgb(102, 217, 239);
27-
28- public static final Duration SHORT_PERSISTENT = Duration.millis(2001);
29- public static final Duration SHORT = Duration.millis(2000);
30- public static final Duration LONG = Duration.millis(3500);
31-
32- private static final Color DEFAULT_COLOR = Color.rgb(240, 240, 240);
18+public class Toast extends Pane {
3319
34- private final Data EMPTY_DATA = new Data(null, null, null, null, null);
35-
36- private BorderPane borderPane;
37- private Button btnClose;
38- private Label lblTitle;
39- private Label lblMessage;
40- private Runnable actionOnClick;
41-
20+ public static final Color COLOR_ERROR = Color.rgb(249, 38, 114);
21+ public static final Color COLOR_SUCCESS = Color.rgb(166, 226, 46);
22+ private static final Duration DURATION = Duration.millis(5000);
23+
24+ private final Data EMPTY_DATA = new Data(null, null, null, null);
25+
26+ @FXML private Label lblTitle;
27+ @FXML private Label lblMessage;
28+ private Runnable action;
29+
4230 private TranslateTransition SHOW_ANIMATION;
4331 private TranslateTransition HIDE_ANIMATION;
4432 private TranslateTransition currentTransition;
@@ -46,55 +34,21 @@
4634 private Data nextData;
4735
4836 public Toast() {
49- getStylesheets().add(Toast.class.getResource("Toast.css").toExternalForm());
37+ Fxml.load(this, this);
5038
51- btnClose = new Button("×");
52- btnClose.setId("btnClose");
53- btnClose.setOnAction(event-> {
54- btnClose_onAction(event);
55- });
56-
57- lblTitle = new Label();
58- lblTitle.setId("lblTitle");
59- lblTitle.setWrapText(false);
60-
61- lblMessage = new Label();
62- lblMessage.setId("lblMessage");
63- lblMessage.setWrapText(true);
64-
65- ScrollPane scrollPane = new ScrollPane(lblMessage);
66- scrollPane.prefViewportHeightProperty().bind(lblMessage.heightProperty());
67-
68- borderPane = new BorderPane();
69- borderPane.setId("background");
70- borderPane.centerProperty().set(scrollPane);
71- borderPane.paddingProperty().bind(Bindings
72- .when(Bindings.isNull(borderPane.topProperty()))
73- .then(new Insets(3, 25, 3, 10))
74- .otherwise(new Insets(3, 8, 3, 10)));
75-
76- AnchorPane layer = new AnchorPane(btnClose);
77- layer.setPickOnBounds(false);
78- AnchorPane.setTopAnchor(btnClose, 0.0);
79- AnchorPane.setRightAnchor(btnClose, 0.0);
39+ //
40+ // bindings
41+ //
8042
81- getChildren().addAll(borderPane, layer);
82- setVisible(false);
83-
84- maxWidthProperty().addListener((observable, oldValue, newValue)-> {
85- double width = newValue.doubleValue()
86- - borderPane.getPadding().getLeft()
87- - borderPane.getPadding().getRight();
88- lblTitle.setMaxWidth(width);
89- lblMessage.setMaxWidth(width);
90- scrollPane.setMaxWidth(width);
91- });
92-
43+ //
44+ // event handlers
45+ //
46+
9347 // SHOW_ANIMATION
9448 SHOW_ANIMATION = new TranslateTransition();
9549 SHOW_ANIMATION.setNode(this);
9650 SHOW_ANIMATION.setInterpolator(Interpolator.EASE_OUT);
97- SHOW_ANIMATION.fromYProperty().bind(Bindings.add(heightProperty(), 40.0));
51+ SHOW_ANIMATION.fromYProperty().bind(Bindings.add(heightProperty(), 80.0));
9852 SHOW_ANIMATION.durationProperty().bind(Bindings.createObjectBinding(()-> {
9953 return Duration.millis(SHOW_ANIMATION.getFromY() * 5.0);
10054 }, SHOW_ANIMATION.fromYProperty()));
@@ -103,12 +57,12 @@
10357 currentTransition = (nextData != null) ? getTransition(nextData) : null;
10458 if(currentTransition != null) {
10559 currentTransition.play();
106- } else if(currentData.duration != null && currentData.duration.toMillis() > 0.0) {
60+ } else {
10761 Data data = currentData;
108- new Timeline(new KeyFrame(data.duration, onFinished -> {
62+ new Timeline(new KeyFrame(DURATION, onFinished -> {
10963 if(data == currentData) {
11064 //hide
111- show(null, null, null, null);
65+ show(null,null, null);
11266 }
11367 })).play();
11468 }
@@ -121,11 +75,11 @@
12175 });
12276
12377 // HIDE_ANIMATION
124- HIDE_ANIMATION = new TranslateTransition(Duration.millis(3000));
78+ HIDE_ANIMATION = new TranslateTransition(Duration.millis(5000));
12579 HIDE_ANIMATION.setNode(this);
12680 HIDE_ANIMATION.setInterpolator(Interpolator.EASE_IN);
12781 HIDE_ANIMATION.setFromY(0);
128- HIDE_ANIMATION.toYProperty().bind(Bindings.add(heightProperty(), 40.0));
82+ HIDE_ANIMATION.toYProperty().bind(Bindings.add(heightProperty(), 80.0));
12983 HIDE_ANIMATION.durationProperty().bind(Bindings.createObjectBinding(()-> {
13084 return Duration.millis(HIDE_ANIMATION.getToY() * 5.0);
13185 }, HIDE_ANIMATION.toYProperty()));
@@ -144,56 +98,37 @@
14498 });
14599
146100 // CLICK ACTION
147- setOnMouseClicked(event -> {
148- if(actionOnClick != null) {
149- actionOnClick.run();
101+ setOnMouseClicked(event -> Unchecked.execute(() -> {
102+ if(action != null) {
103+ action.run();
150104 }
151- });
105+ }));
152106 }
153-
154- protected void btnClose_onAction(ActionEvent event) {
155- show(null, null, null, null, null);
156- }
157-
107+
158108 public void hide() {
159- if(currentData != null && currentData.isPersistent) {
160- return;
161- }
162- show(null, null, null, null, null);
109+ show(null, null, null);
163110 }
164111
165- public void show(String message) {
166- show(null, null, message, null);
167- }
168-
169112 public void show(String title, String message) {
170- show(null, title, message, null);
113+ show(null, title, message);
171114 }
172-
115+
116+ public void showError(String title, String message) {
117+ show(COLOR_ERROR, title, message);
118+ }
119+
173120 public void show(Color color, String title, String message) {
174121 show(color, title, message, null);
175122 }
176-
177- public void show(String title, String message, Duration duration) {
178- show(null, title, message, duration);
179- }
180-
181- public void show(Color color, String message, Duration duration) {
182- show(color, null, message, duration);
183- }
184123
185- public void show(Color color, String title, String message, Duration duration) {
186- show(color, title, message, duration, null);
187- }
188-
189- public void show(Color color, String title, String message, Duration duration, Runnable actionOnClick) {
124+ public void show(Color color, String title, String message, Runnable action) {
190125 if(!Platform.isFxApplicationThread()) {
191126 Platform.runLater(()-> {
192- show(color, title, message, duration);
127+ show(color, title, message, action);
193128 });
194129 return;
195130 }
196- Data data = new Data(color, title, message, duration, actionOnClick);
131+ Data data = new Data(color, title, message, action);
197132 if(currentTransition == null) {
198133 if(isVisible()) {
199134 currentTransition = getTransition(EMPTY_DATA);
@@ -209,50 +144,43 @@
209144 nextData = data;
210145 }
211146 }
212-
147+
213148 protected TranslateTransition getTransition(Data data) {
214149 currentData = data;
150+ action = data.action;
215151 if(data.isEmpty) {
216152 return HIDE_ANIMATION;
217153 } else {
154+ if(data.color == null) {
155+ lblTitle.setTextFill(COLOR_SUCCESS);
156+ } else {
157+ lblTitle.setTextFill(data.color);
158+ }
218159 if(data.title == null || data.title.length() == 0) {
219160 lblTitle.setText("");
220161 } else {
221162 lblTitle.setText(data.title);
222- lblTitle.setTextFill(data.color != null ? data.color : DEFAULT_COLOR);
223163 }
224- if(lblTitle.getText().isEmpty() && borderPane.getChildren().contains(lblTitle)) {
225- borderPane.setTop(null);
226- } else if(!lblTitle.getText().isEmpty() && !borderPane.getChildren().contains(lblTitle)) {
227- borderPane.setTop(lblTitle);
228- }
229- lblMessage.setTextFill(lblTitle.getText().isEmpty() ? data.color : DEFAULT_COLOR);
230164 lblMessage.setText(data.message != null ? data.message : "");
231- lblMessage.setCursor(data.actionOnClick != null ? Cursor.HAND : Cursor.DEFAULT);
232165 layout();
233- actionOnClick = data.actionOnClick;
234166 return SHOW_ANIMATION;
235167 }
236168 }
237-
169+
238170 private class Data {
239-
171+
240172 public Color color;
241173 public String title;
242174 public String message;
243- public Duration duration;
244- public Runnable actionOnClick;
175+ public Runnable action;
245176 public boolean isEmpty;
246- public boolean isPersistent;
247-
248- public Data(Color color, String title, String message, Duration duration, Runnable actionOnClick) {
177+
178+ public Data(Color color, String title, String message, Runnable action) {
249179 this.color = color;
250180 this.title = title;
251181 this.message = message;
252- this.duration = duration;
253- this.actionOnClick = actionOnClick;
254182 this.isEmpty = (title == null || title.isEmpty()) && (message == null || message.isEmpty());
255- this.isPersistent = (duration == SHORT_PERSISTENT);
183+ this.action = this.isEmpty ? null : action;
256184 }
257185 }
258186 }
Show on old repository browser