forked from pcorless/icepdf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:pcorless/icepdf
- Loading branch information
Showing
24 changed files
with
4,002 additions
and
4,429 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
...r/viewer-awt/src/main/java/org/icepdf/ri/common/preferences/ExImportPreferencesPanel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
package org.icepdf.ri.common.preferences; | ||
|
||
import org.icepdf.ri.common.views.Controller; | ||
import org.icepdf.ri.util.ViewerPropertiesManager; | ||
|
||
import javax.swing.*; | ||
import javax.swing.border.EtchedBorder; | ||
import javax.swing.border.TitledBorder; | ||
import java.awt.*; | ||
import java.io.File; | ||
import java.util.ResourceBundle; | ||
|
||
public class ExImportPreferencesPanel extends JPanel { | ||
|
||
private final GridBagConstraints constraints; | ||
|
||
public ExImportPreferencesPanel(Controller controller, ViewerPropertiesManager propertiesManager, | ||
ResourceBundle messageBundle, Dialog parent) { | ||
super(new GridBagLayout()); | ||
setAlignmentY(JPanel.TOP_ALIGNMENT); | ||
final JButton exportButton = new JButton(messageBundle.getString( | ||
"viewer.dialog.viewerPreferences.section.eximport.export.button.label")); | ||
final JButton importButton = new JButton(messageBundle.getString( | ||
"viewer.dialog.viewerPreferences.section.eximport.import.button.label")); | ||
|
||
final JPanel panel = new JPanel(new GridBagLayout()); | ||
panel.setAlignmentY(JPanel.TOP_ALIGNMENT); | ||
panel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED), | ||
messageBundle.getString("viewer.dialog.viewerPreferences.section.eximport.border.label"), | ||
TitledBorder.LEFT, | ||
TitledBorder.DEFAULT_POSITION)); | ||
|
||
constraints = new GridBagConstraints(); | ||
constraints.fill = GridBagConstraints.NONE; | ||
constraints.weightx = 1; | ||
constraints.weighty = 0; | ||
constraints.anchor = GridBagConstraints.CENTER; | ||
constraints.insets = new Insets(5, 5, 5, 5); | ||
|
||
exportButton.addActionListener(actionEvent -> { | ||
final FileDialog chooser = new FileDialog(parent); | ||
chooser.setMultipleMode(false); | ||
chooser.setMode(FileDialog.SAVE); | ||
chooser.setVisible(true); | ||
final String dir = chooser.getDirectory(); | ||
final String file = chooser.getFile(); | ||
if (dir != null && file != null) { | ||
if (ViewerPropertiesManager.exportProperties(new File(dir + file))) { | ||
showSuccess(messageBundle, "export"); | ||
} else { | ||
showFailure(messageBundle, "export"); | ||
} | ||
} | ||
}); | ||
importButton.addActionListener(actionEvent -> { | ||
final FileDialog chooser = new FileDialog(parent); | ||
chooser.setMultipleMode(false); | ||
chooser.setMode(FileDialog.LOAD); | ||
chooser.setVisible(true); | ||
final String dir = chooser.getDirectory(); | ||
final String file = chooser.getFile(); | ||
if (dir != null && file != null) { | ||
if (ViewerPropertiesManager.importProperties(new File(dir + file))) { | ||
showSuccess(messageBundle, "import"); | ||
} else { | ||
showFailure(messageBundle, "import"); | ||
} | ||
} | ||
}); | ||
addGB(panel, exportButton, 0, 0, 1, 1); | ||
addGB(panel, importButton, 1, 0, 1, 1); | ||
constraints.anchor = GridBagConstraints.NORTHWEST; | ||
constraints.fill = GridBagConstraints.BOTH; | ||
addGB(this, panel, 0, 0, 1, 1); | ||
constraints.weighty = 1.0; | ||
addGB(this, new JLabel(" "), 0, 1, 1, 1); | ||
} | ||
|
||
private void showSuccess(ResourceBundle messageBundle, String action) { | ||
JOptionPane.showMessageDialog(this, | ||
messageBundle.getString("viewer.dialog.viewerPreferences.section.eximport." + action + ".success.label"), | ||
messageBundle.getString("viewer.dialog.viewerPreferences.section.eximport." + action + ".success.title"), | ||
JOptionPane.INFORMATION_MESSAGE); | ||
} | ||
|
||
private void showFailure(ResourceBundle messageBundle, String action) { | ||
JOptionPane.showMessageDialog(this, | ||
messageBundle.getString("viewer.dialog.viewerPreferences.section.eximport." + action + ".fail.label"), | ||
messageBundle.getString("viewer.dialog.viewerPreferences.section.eximport." + action + ".fail.title"), | ||
JOptionPane.ERROR_MESSAGE); | ||
} | ||
|
||
private void addGB(JPanel layout, Component component, | ||
int x, int y, | ||
int rowSpan, int colSpan) { | ||
constraints.gridx = x; | ||
constraints.gridy = y; | ||
constraints.gridwidth = rowSpan; | ||
constraints.gridheight = colSpan; | ||
layout.add(component, constraints); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.