Open NPAPi, Open PPAPI buttons in Sol editor

This commit is contained in:
Jindra Petřík
2024-11-09 08:37:42 +01:00
parent 45bf4795a7
commit f55983fd08
3 changed files with 32 additions and 1 deletions

View File

@@ -2,6 +2,8 @@ dialog.title = Sol editor
button.new = New
button.open = Open...
button.open.npapi = Open NPAPI...
button.open.ppapi = Open PPAPI...
button.save = Save
button.saveAs = Save as...

View File

@@ -1,6 +1,8 @@
dialog.title = \u5b58\u6863\u7f16\u8f91\u5668
button.new = \u65b0\u5efa
button.open = \u6253\u5f00...
button.open.npapi = \u6253\u5f00 NPAPI...
button.open.ppapi = \u6253\u5f00 PPAPI...
button.save = \u4fdd\u5b58
button.saveAs = \u53e6\u5b58\u4e3a...
filter.sol = SOL\u6587\u4ef6 (*.sol)

View File

@@ -111,7 +111,13 @@ public class SolEditorFrame extends AppFrame {
JButton openButton = new JButton(translate("button.open"), View.getIcon("open16"));
openButton.addActionListener(this::openActionPerformed);
JButton openNpApiButton = new JButton(translate("button.open.npapi"), View.getIcon("open16"));
openNpApiButton.addActionListener(this::openNpApiActionPerformed);
JButton openPpApiButton = new JButton(translate("button.open.ppapi"), View.getIcon("open16"));
openPpApiButton.addActionListener(this::openPpApiActionPerformed);
saveButton = new JButton(translate("button.save"), View.getIcon("save16"));
saveButton.addActionListener(this::saveActionPerformed);
saveButton.setEnabled(false);
@@ -121,6 +127,15 @@ public class SolEditorFrame extends AppFrame {
topPanel.add(newButton);
topPanel.add(openButton);
File npApiDirectory = SharedObjectsStorage.getNpApiDirectory();
if (npApiDirectory != null && npApiDirectory.exists()) {
topPanel.add(openNpApiButton);
}
File ppApiDirectory = SharedObjectsStorage.getPpApiDirectory();
if (ppApiDirectory != null && ppApiDirectory.exists()) {
topPanel.add(openPpApiButton);
}
topPanel.add(saveButton);
topPanel.add(saveAsButton);
@@ -175,6 +190,18 @@ public class SolEditorFrame extends AppFrame {
}
private void openActionPerformed(ActionEvent e) {
openDirectory(new File(Configuration.lastSolEditorDirectory.get()));
}
private void openNpApiActionPerformed(ActionEvent e) {
openDirectory(SharedObjectsStorage.getNpApiDirectory());
}
private void openPpApiActionPerformed(ActionEvent e) {
openDirectory(SharedObjectsStorage.getPpApiDirectory());
}
private void openDirectory(File directory) {
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileHidingEnabled(false);
fileChooser.setFileFilter(new FileFilter() {
@@ -188,7 +215,7 @@ public class SolEditorFrame extends AppFrame {
return translate("filter.sol");
}
});
fileChooser.setCurrentDirectory(new File(Configuration.lastSolEditorDirectory.get()));
fileChooser.setCurrentDirectory(directory);
if (fileChooser.showOpenDialog(this) != JFileChooser.APPROVE_OPTION) {
return;
}