-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert PushToApp Settings to javafx (#4891)
* Convert PushToApp Settings to javafx Replace Runnable with BackgroundThread in Push * Remove old swing code Rename variable Only overwrite one method
- Loading branch information
1 parent
e230a95
commit 3414ac6
Showing
10 changed files
with
84 additions
and
192 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
59 changes: 10 additions & 49 deletions
59
src/main/java/org/jabref/gui/push/PushToApplicationSettingsDialog.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 |
---|---|---|
@@ -1,61 +1,22 @@ | ||
package org.jabref.gui.push; | ||
|
||
import java.awt.BorderLayout; | ||
import java.awt.event.ActionEvent; | ||
import javafx.scene.control.ButtonType; | ||
import javafx.scene.control.DialogPane; | ||
|
||
import javax.swing.AbstractAction; | ||
import javax.swing.ActionMap; | ||
import javax.swing.BorderFactory; | ||
import javax.swing.InputMap; | ||
import javax.swing.JButton; | ||
import javax.swing.JComponent; | ||
import javax.swing.JDialog; | ||
import javax.swing.JFrame; | ||
import javax.swing.JPanel; | ||
|
||
import org.jabref.Globals; | ||
import org.jabref.gui.keyboard.KeyBinding; | ||
import org.jabref.gui.DialogService; | ||
import org.jabref.logic.l10n.Localization; | ||
|
||
import com.jgoodies.forms.builder.ButtonBarBuilder; | ||
|
||
public class PushToApplicationSettingsDialog { | ||
public static void showSettingsDialog(JFrame parent, PushToApplicationSettings toApp, int n) { | ||
final JDialog diag = new JDialog(parent, Localization.lang("Settings"), true); | ||
JPanel options = toApp.getSettingsPanel(n); | ||
options.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); | ||
diag.getContentPane().add(options, BorderLayout.CENTER); | ||
ButtonBarBuilder bb = new ButtonBarBuilder(); | ||
JButton ok = new JButton(Localization.lang("OK")); | ||
JButton cancel = new JButton(Localization.lang("Cancel")); | ||
bb.addGlue(); | ||
bb.addButton(ok); | ||
bb.addButton(cancel); | ||
bb.addGlue(); | ||
bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); | ||
diag.getContentPane().add(bb.getPanel(), BorderLayout.SOUTH); | ||
ok.addActionListener(e -> { | ||
// If the user pressed Ok, ask the PushToApplication implementation to store its settings: | ||
toApp.storeSettings(); | ||
diag.dispose(); | ||
}); | ||
cancel.addActionListener(e -> diag.dispose()); | ||
|
||
// Key bindings: | ||
ActionMap am = bb.getPanel().getActionMap(); | ||
InputMap im = bb.getPanel().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); | ||
im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE), "close"); | ||
am.put("close", new AbstractAction() { | ||
public static void showSettingsDialog(DialogService dialogService, PushToApplicationSettings toApp, int n) { | ||
|
||
@Override | ||
public void actionPerformed(ActionEvent e) { | ||
diag.dispose(); | ||
DialogPane dialogPane = new DialogPane(); | ||
dialogPane.setContent(toApp.getJFXSettingPane(n)); | ||
|
||
dialogService.showCustomDialogAndWait(Localization.lang("App settings"), dialogPane, ButtonType.OK, ButtonType.CANCEL).ifPresent(btn -> { | ||
if (btn == ButtonType.OK) { | ||
toApp.storeSettings(); | ||
} | ||
}); | ||
diag.pack(); | ||
diag.setLocationRelativeTo(parent); | ||
|
||
// Show the dialog: | ||
diag.setVisible(true); | ||
} | ||
} |
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.