Skip to content

Commit 6c9f51b

Browse files
committed
Make minor tweaks, based on code review
1 parent 4658630 commit 6c9f51b

File tree

9 files changed

+33
-5
lines changed

9 files changed

+33
-5
lines changed

src/main/java/com/itextpdf/rups/controller/IRupsController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

src/main/java/com/itextpdf/rups/controller/RupsController.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ This file is part of the iText (R) project.
5555
import java.awt.Component;
5656
import java.awt.Dimension;
5757
import java.io.File;
58+
import java.util.Objects;
5859
import java.util.Observable;
5960
import java.util.Observer;
6061
import 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

src/main/java/com/itextpdf/rups/event/DisplayedTabChanged.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ This file is part of the iText (R) project.
4444

4545
import 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+
*/
4751
public class DisplayedTabChanged extends RupsEvent {
4852
private final IPdfFile displayedFile;
4953

src/main/java/com/itextpdf/rups/event/ReopenCurrentFileAsOwnerEvent.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ This file is part of the iText (R) project.
4343
package 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+
*/
4650
public class ReopenCurrentFileAsOwnerEvent extends RupsEvent {
4751
public ReopenCurrentFileAsOwnerEvent() {
4852
// Nothing to initialize

src/main/java/com/itextpdf/rups/event/RupsEvent.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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

src/main/java/com/itextpdf/rups/model/DialogPasswordProvider.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,34 @@ This file is part of the iText (R) project.
5353
import javax.swing.JOptionPane;
5454
import javax.swing.JPasswordField;
5555

56+
/**
57+
* Password provider implementation, which queries the user for a password via
58+
* an interactive GUI dialog.
59+
*/
5660
public 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
}

src/main/java/com/itextpdf/rups/view/Language.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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,

src/main/resources/bundles/rups-lang.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ ERROR_LOADING_IMAGE=Image can't be loaded.
6666
ERROR_LOADING_XFA=Can't load XFA.
6767
ERROR_LOOK_AND_FEEL=Error setting the look and feel.
6868
ERROR_MISSING_PASSWORD=The required password for this document was not provided.
69+
ERROR_NO_OPEN_DOCUMENT=There is no open document.
6970
ERROR_NO_OPEN_DOCUMENT_COMPARE=There is no open document. Nothing to compare with.
7071
ERROR_ONLY_OPEN_ONE_FILE=You can only open one file!
7172
ERROR_OPENING_FILE=Error opening file: %s

src/main/resources/bundles/rups-lang_en_US.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ ERROR_KEY_IS_NOT_NAME=Key value isn't value Name object.
5757
ERROR_LOADING_IMAGE=Image can't be loaded.
5858
ERROR_LOADING_XFA=Can't load XFA.
5959
ERROR_MISSING_PASSWORD=The required password for this document was not provided.
60+
ERROR_NO_OPEN_DOCUMENT=There is no open document.
6061
ERROR_NO_OPEN_DOCUMENT_COMPARE=There is no open document. Nothing to compare with.
6162
ERROR_ONLY_OPEN_ONE_FILE=You can only open one file!
6263
ERROR_OPENING_FILE=Error opening file: %s

0 commit comments

Comments
 (0)