File tree Expand file tree Collapse file tree 9 files changed +33
-5
lines changed Expand file tree Collapse file tree 9 files changed +33
-5
lines changed Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ public interface IRupsController {
6363 /**
6464 * Returns the currently loaded File.
6565 *
66- * @return PdfFile
66+ * @return IPdfFile
6767 */
6868 IPdfFile getCurrentFile ();
6969
Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ This file is part of the iText (R) project.
5555import java .awt .Component ;
5656import java .awt .Dimension ;
5757import java .io .File ;
58+ import java .util .Objects ;
5859import java .util .Observable ;
5960import java .util .Observer ;
6061import javax .swing .event .ChangeEvent ;
@@ -136,8 +137,9 @@ public final void closeCurrentFile() {
136137 @ Override
137138 public void reopenAsOwner () {
138139 final IPdfFile file = this .getCurrentFile ();
139- // Should not happen (i.e. UI should not allow it), will silently ignore
140+ // Should not happen (i.e. UI should not allow it), will just noop
140141 if (file == null ) {
142+ LoggerHelper .warn (Language .ERROR_NO_OPEN_DOCUMENT .getString (), getClass ());
141143 return ;
142144 }
143145
@@ -172,7 +174,7 @@ public final void openNewFile(File file) {
172174 }
173175
174176 private void openNewFileAsOwner (File file ) {
175- assert file != null ;
177+ Objects . requireNonNull ( file ) ;
176178
177179 // We don't check here for duplicate files, as we don't want to close
178180 // the already opened file, if we fail here
Original file line number Diff line number Diff line change @@ -44,6 +44,10 @@ This file is part of the iText (R) project.
4444
4545import com .itextpdf .rups .model .IPdfFile ;
4646
47+ /**
48+ * Event to signify, that on the main window a different PDF file tab was
49+ * selected and displayed (i.e. the displayed file was changed).
50+ */
4751public class DisplayedTabChanged extends RupsEvent {
4852 private final IPdfFile displayedFile ;
4953
Original file line number Diff line number Diff line change @@ -43,6 +43,10 @@ This file is part of the iText (R) project.
4343package com .itextpdf .rups .event ;
4444
4545
46+ /**
47+ * Event to signify, that a user requested to reopen the currently displayed
48+ * protected PDF file as an owner.
49+ */
4650public class ReopenCurrentFileAsOwnerEvent extends RupsEvent {
4751 public ReopenCurrentFileAsOwnerEvent () {
4852 // Nothing to initialize
Original file line number Diff line number Diff line change @@ -65,8 +65,8 @@ public abstract class RupsEvent {
6565 public static final byte NEW_INDIRECT_OBJECT_EVENT = 15 ;
6666 public static final byte POST_NEW_INDIRECT_OBJECT_EVENT = 16 ;
6767 public static final byte ALL_FILES_CLOSED = 17 ;
68- public static final byte DISPLAYED_TAB_CHANGED = 19 ;
69- public static final byte REOPEN_CURRENT_FILE_AS_OWNER = 20 ;
68+ public static final byte DISPLAYED_TAB_CHANGED = 18 ;
69+ public static final byte REOPEN_CURRENT_FILE_AS_OWNER = 19 ;
7070
7171 public abstract int getType ();
7272
Original file line number Diff line number Diff line change @@ -53,19 +53,34 @@ This file is part of the iText (R) project.
5353import javax .swing .JOptionPane ;
5454import javax .swing .JPasswordField ;
5555
56+ /**
57+ * Password provider implementation, which queries the user for a password via
58+ * an interactive GUI dialog.
59+ */
5660public class DialogPasswordProvider implements IPasswordProvider {
5761 public static final int MAX_PASSWORD_BYTE_LENGTH = 127 ;
5862
63+ /**
64+ * Title for the interactive GUI dialog.
65+ */
5966 private final String title ;
6067
6168 public DialogPasswordProvider (String title ) {
6269 this .title = title ;
6370 }
6471
72+ /**
73+ * Creates a dialog password provider, which will ask the user for a
74+ * password without specifying a concrete type (user or owner).
75+ */
6576 public static DialogPasswordProvider anyPassword () {
6677 return new DialogPasswordProvider (Language .ENTER_ANY_PASSWORD .getString ());
6778 }
6879
80+ /**
81+ * Creates a dialog password provider, which will ask the user
82+ * specifically for an owner password.
83+ */
6984 public static DialogPasswordProvider ownerPassword () {
7085 return new DialogPasswordProvider (Language .ENTER_OWNER_PASSWORD .getString ());
7186 }
Original file line number Diff line number Diff line change @@ -116,6 +116,7 @@ public enum Language {
116116 ERROR_LOADING_XFA ,
117117 ERROR_LOOK_AND_FEEL ,
118118 ERROR_MISSING_PASSWORD ,
119+ ERROR_NO_OPEN_DOCUMENT ,
119120 ERROR_NO_OPEN_DOCUMENT_COMPARE ,
120121 ERROR_ONLY_OPEN_ONE_FILE ,
121122 ERROR_OPENING_FILE ,
Original file line number Diff line number Diff line change @@ -66,6 +66,7 @@ ERROR_LOADING_IMAGE=Image can't be loaded.
6666ERROR_LOADING_XFA =Can' t load XFA.
6767ERROR_LOOK_AND_FEEL=Error setting the look and feel.
6868ERROR_MISSING_PASSWORD=The required password for this document was not provided.
69+ ERROR_NO_OPEN_DOCUMENT=There is no open document.
6970ERROR_NO_OPEN_DOCUMENT_COMPARE=There is no open document. Nothing to compare with.
7071ERROR_ONLY_OPEN_ONE_FILE=You can only open one file!
7172ERROR_OPENING_FILE=Error opening file: %s
Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ ERROR_KEY_IS_NOT_NAME=Key value isn't value Name object.
5757ERROR_LOADING_IMAGE =Image can' t be loaded.
5858ERROR_LOADING_XFA=Can' t load XFA.
5959ERROR_MISSING_PASSWORD =The required password for this document was not provided.
60+ ERROR_NO_OPEN_DOCUMENT =There is no open document.
6061ERROR_NO_OPEN_DOCUMENT_COMPARE =There is no open document. Nothing to compare with.
6162ERROR_ONLY_OPEN_ONE_FILE =You can only open one file!
6263ERROR_OPENING_FILE =Error opening file: %s
You can’t perform that action at this time.
0 commit comments