-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert PushToApp Settings to javafx #4891
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,15 @@ | ||
package org.jabref.gui.push; | ||
|
||
import javax.swing.JPanel; | ||
import javax.swing.JTextField; | ||
|
||
import javafx.scene.layout.GridPane; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.control.TextField; | ||
|
||
import org.jabref.Globals; | ||
import org.jabref.logic.l10n.Localization; | ||
import org.jabref.preferences.JabRefPreferences; | ||
|
||
public class PushToEmacsSettings extends PushToApplicationSettings { | ||
|
||
private final JTextField additionalParams = new JTextField(30); | ||
|
||
@Override | ||
public JPanel getSettingsPanel(int n) { | ||
additionalParams.setText(Globals.prefs.get(JabRefPreferences.EMACS_ADDITIONAL_PARAMETERS)); | ||
return super.getSettingsPanel(n); | ||
} | ||
|
||
@Override | ||
public GridPane getJFXSettingPane() { | ||
additionalParams.setText(Globals.prefs.get(JabRefPreferences.EMACS_ADDITIONAL_PARAMETERS)); | ||
return super.getJFXSettingPane(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would prefer if there is only one method that needs to be overriden to customize the settings pane. |
||
} | ||
private final TextField additionalParams = new TextField(); | ||
|
||
@Override | ||
public void storeSettings() { | ||
|
@@ -32,11 +18,10 @@ public void storeSettings() { | |
} | ||
|
||
@Override | ||
protected void initSettingsPanel() { | ||
super.initSettingsPanel(); | ||
builder.appendRows("2dlu, p, 2dlu, p"); | ||
builder.add(Localization.lang("Additional parameters") + ":").xy(1, 3); | ||
builder.add(additionalParams).xy(3, 3); | ||
settings = builder.build(); | ||
protected void initJFXSettingsPanel() { | ||
super.initJFXSettingsPanel(); | ||
jfxSettings.add(new Label(Localization.lang("Additional parameters") + ":"), 0, 1); | ||
jfxSettings.add(additionalParams, 1, 1); | ||
additionalParams.setText(Globals.prefs.get(JabRefPreferences.EMACS_ADDITIONAL_PARAMETERS)); | ||
} | ||
} |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename path1 to path?