Skip to content

Commit 18aba35

Browse files
authored
Convert OO/LO SidePanel to javafx (#4341)
* Convert OO/LO SidePanel to javafx First attempt at converting the OpenOffice side panel * rework first part of select style dialog * add icon to delete style add edit function implement rest of logic * store settings, show path load last selected style subscribe preview panel to changes * update from scence builder * fix ok button wrap preview panel in vbox * add title for canceable progess dialog rework manual connect rework settings popup initialize oo prefs to avoid NPE remove old style dialog * formatting * Create custom dialog which returns a dialog object fix preference storage fix manual path select * pass keybinding repo as dependency * add new dialog for advanced cite todo: find out how to change the values * reload preferences in connect fix passing of prefs fix advanced cite dialog * fix checkstyle add some dialog basics for manage citatiosn * further implement viewModel * implement viewModel fix l10n parts TODO: editing of extra info does not yet work * remove submodule * Display Manage citations as TextFlow in the table Allow editing of page info directly in the table Replace html bold with Text-Bold style * fix checkstyle * rework page info remove old dialog fix l10n set titles add tooltips * use flowpane instead of textflow to prevent table row height increasing * cleanup and fix codacy issues * rework dialogs rework future handling in detect OO installation * rework constructor and rename to CitationEntryViewModel move gui getText to view * fix checkstyle and l10n issues * fix order * fix style file select layout and inline variable' * Add Book as preview as well * change mac default settings to LO path * checkstyle * fix merge error * first part of refactoring * refactor and remove/fix obsolete tests put visible/managed bindings in fxml * Fixes #4576 Store show/hide info of panel in preferences * use progessbar from fxdialogs TODO: Fix execution in fx thread * Fix autodetecting open office paths in background thread Fix saving of settings after auto connect Add notification when connections are cleared remove custom dialog hack * fix checkstyle
1 parent 48c5a20 commit 18aba35

34 files changed

+1443
-1571
lines changed

src/main/java/org/jabref/gui/DialogService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ default void showErrorDialogAndWait(Exception exception) {
140140
* @return true if the use clicked "YES" otherwise false
141141
*/
142142
boolean showConfirmationDialogWithOptOutAndWait(String title, String content,
143-
String optOutMessage, Consumer<Boolean> optOutAction);
143+
String optOutMessage, Consumer<Boolean> optOutAction);
144144

145145
/**
146146
* Create and display a new confirmation dialog.
@@ -152,8 +152,8 @@ boolean showConfirmationDialogWithOptOutAndWait(String title, String content,
152152
* @return true if the use clicked "YES" otherwise false
153153
*/
154154
boolean showConfirmationDialogWithOptOutAndWait(String title, String content,
155-
String okButtonLabel, String cancelButtonLabel,
156-
String optOutMessage, Consumer<Boolean> optOutAction);
155+
String okButtonLabel, String cancelButtonLabel,
156+
String optOutMessage, Consumer<Boolean> optOutAction);
157157

158158
/**
159159
* This will create and display a new dialog of the specified
@@ -163,7 +163,7 @@ boolean showConfirmationDialogWithOptOutAndWait(String title, String content,
163163
* @return Optional with the pressed Button as ButtonType
164164
*/
165165
Optional<ButtonType> showCustomButtonDialogAndWait(Alert.AlertType type, String title, String content,
166-
ButtonType... buttonTypes);
166+
ButtonType... buttonTypes);
167167

168168
/**
169169
* This will create and display a new dialog showing a custom {@link DialogPane}

src/main/java/org/jabref/gui/FXDialogService.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ private static FXDialog createDialog(AlertType type, String title, String conten
7474
}
7575

7676
private static FXDialog createDialogWithOptOut(AlertType type, String title, String content,
77-
String optOutMessage, Consumer<Boolean> optOutAction) {
77+
String optOutMessage, Consumer<Boolean> optOutAction) {
7878
FXDialog alert = new FXDialog(type, title, true);
7979
// Need to force the alert to layout in order to grab the graphic as we are replacing the dialog pane with a custom pane
8080
alert.getDialogPane().applyCss();
@@ -180,7 +180,7 @@ public boolean showConfirmationDialogAndWait(String title, String content, Strin
180180

181181
@Override
182182
public boolean showConfirmationDialogAndWait(String title, String content,
183-
String okButtonLabel, String cancelButtonLabel) {
183+
String okButtonLabel, String cancelButtonLabel) {
184184
FXDialog alert = createDialog(AlertType.CONFIRMATION, title, content);
185185
ButtonType okButtonType = new ButtonType(okButtonLabel, ButtonBar.ButtonData.OK_DONE);
186186
ButtonType cancelButtonType = new ButtonType(cancelButtonLabel, ButtonBar.ButtonData.NO);
@@ -190,16 +190,16 @@ public boolean showConfirmationDialogAndWait(String title, String content,
190190

191191
@Override
192192
public boolean showConfirmationDialogWithOptOutAndWait(String title, String content,
193-
String optOutMessage, Consumer<Boolean> optOutAction) {
193+
String optOutMessage, Consumer<Boolean> optOutAction) {
194194
FXDialog alert = createDialogWithOptOut(AlertType.CONFIRMATION, title, content, optOutMessage, optOutAction);
195195
alert.getButtonTypes().setAll(ButtonType.YES, ButtonType.NO);
196196
return alert.showAndWait().filter(buttonType -> buttonType == ButtonType.YES).isPresent();
197197
}
198198

199199
@Override
200200
public boolean showConfirmationDialogWithOptOutAndWait(String title, String content,
201-
String okButtonLabel, String cancelButtonLabel,
202-
String optOutMessage, Consumer<Boolean> optOutAction) {
201+
String okButtonLabel, String cancelButtonLabel,
202+
String optOutMessage, Consumer<Boolean> optOutAction) {
203203
FXDialog alert = createDialogWithOptOut(AlertType.CONFIRMATION, title, content, optOutMessage, optOutAction);
204204
ButtonType okButtonType = new ButtonType(okButtonLabel, ButtonBar.ButtonData.YES);
205205
ButtonType cancelButtonType = new ButtonType(cancelButtonLabel, ButtonBar.ButtonData.NO);
@@ -209,15 +209,15 @@ public boolean showConfirmationDialogWithOptOutAndWait(String title, String cont
209209

210210
@Override
211211
public Optional<ButtonType> showCustomButtonDialogAndWait(AlertType type, String title, String content,
212-
ButtonType... buttonTypes) {
212+
ButtonType... buttonTypes) {
213213
FXDialog alert = createDialog(type, title, content);
214214
alert.getButtonTypes().setAll(buttonTypes);
215215
return alert.showAndWait();
216216
}
217217

218218
@Override
219219
public Optional<ButtonType> showCustomDialogAndWait(String title, DialogPane contentPane,
220-
ButtonType... buttonTypes) {
220+
ButtonType... buttonTypes) {
221221
FXDialog alert = new FXDialog(AlertType.NONE, title);
222222
alert.setDialogPane(contentPane);
223223
alert.getButtonTypes().setAll(buttonTypes);

src/main/java/org/jabref/gui/SidePaneManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ public SidePaneManager(JabRefPreferences preferences, JabRefFrame frame) {
3333
Stream.of(
3434
new FileUpdatePanel(this),
3535
new GroupSidePane(this, preferences, frame.getDialogService()),
36-
new WebSearchPane(this, preferences, frame),
37-
new OpenOfficeSidePanel(this, openOfficePreferences, frame))
36+
new WebSearchPane(this, preferences, frame),
37+
new OpenOfficeSidePanel(this, preferences, frame))
3838
.forEach(pane -> components.put(pane.getType(), pane));
3939

4040
if (preferences.getBoolean(JabRefPreferences.GROUP_SIDEPANE_VISIBLE)) {
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<?import javafx.scene.control.ButtonType?>
4+
<?import javafx.scene.control.DialogPane?>
5+
<?import javafx.scene.control.Label?>
6+
<?import javafx.scene.control.RadioButton?>
7+
<?import javafx.scene.control.TextField?>
8+
<?import javafx.scene.control.ToggleGroup?>
9+
<?import javafx.scene.layout.HBox?>
10+
<?import javafx.scene.layout.VBox?>
11+
12+
<DialogPane prefHeight="182.0" prefWidth="390.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.jabref.gui.openoffice.AdvancedCiteDialogView">
13+
<content>
14+
<VBox>
15+
<fx:define>
16+
<ToggleGroup fx:id="citeToggleGroup" />
17+
</fx:define>
18+
<children>
19+
<RadioButton fx:id="inPar" minWidth="-Infinity" mnemonicParsing="false" text="%Cite selected entries between parenthesis" toggleGroup="$citeToggleGroup" />
20+
<RadioButton fx:id="inText" minWidth="-Infinity" mnemonicParsing="false" text="%Cite selected entries with in-text citation" toggleGroup="$citeToggleGroup" />
21+
<Label minWidth="-Infinity" text="%Extra information (e.g. page number)" />
22+
<TextField fx:id="pageInfo" />
23+
</children>
24+
</VBox>
25+
</content>
26+
<buttonTypes>
27+
<ButtonType fx:constant="CANCEL" />
28+
<ButtonType fx:constant="OK" />
29+
</buttonTypes>
30+
</DialogPane>

src/main/java/org/jabref/gui/openoffice/AdvancedCiteDialog.java

Lines changed: 0 additions & 113 deletions
This file was deleted.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package org.jabref.gui.openoffice;
2+
3+
import javafx.fxml.FXML;
4+
import javafx.scene.control.ButtonType;
5+
import javafx.scene.control.RadioButton;
6+
import javafx.scene.control.TextField;
7+
import javafx.scene.control.ToggleGroup;
8+
9+
import org.jabref.gui.util.BaseDialog;
10+
import org.jabref.logic.l10n.Localization;
11+
12+
import com.airhacks.afterburner.views.ViewLoader;
13+
14+
public class AdvancedCiteDialogView extends BaseDialog<AdvancedCiteDialogViewModel> {
15+
16+
@FXML private TextField pageInfo;
17+
@FXML private RadioButton inPar;
18+
@FXML private RadioButton inText;
19+
@FXML private ToggleGroup citeToggleGroup;
20+
private AdvancedCiteDialogViewModel viewModel;
21+
22+
public AdvancedCiteDialogView() {
23+
24+
ViewLoader.view(this)
25+
.load()
26+
.setAsDialogPane(this);
27+
setResultConverter(btn -> {
28+
if (btn == ButtonType.OK) {
29+
return viewModel;
30+
}
31+
return null;
32+
});
33+
34+
setTitle(Localization.lang("Cite special"));
35+
}
36+
37+
@FXML
38+
private void initialize() {
39+
viewModel = new AdvancedCiteDialogViewModel();
40+
41+
inPar.selectedProperty().bindBidirectional(viewModel.citeInParProperty());
42+
inText.selectedProperty().bindBidirectional(viewModel.citeInTextProperty());
43+
pageInfo.textProperty().bindBidirectional(viewModel.pageInfoProperty());
44+
45+
}
46+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package org.jabref.gui.openoffice;
2+
3+
import javafx.beans.property.BooleanProperty;
4+
import javafx.beans.property.SimpleBooleanProperty;
5+
import javafx.beans.property.SimpleStringProperty;
6+
import javafx.beans.property.StringProperty;
7+
8+
public class AdvancedCiteDialogViewModel {
9+
10+
private final StringProperty pageInfo = new SimpleStringProperty("");
11+
private final BooleanProperty citeInPar = new SimpleBooleanProperty();
12+
private final BooleanProperty citeInText = new SimpleBooleanProperty();
13+
14+
public StringProperty pageInfoProperty() {
15+
return pageInfo;
16+
}
17+
18+
public BooleanProperty citeInParProperty() {
19+
return citeInPar;
20+
}
21+
22+
public BooleanProperty citeInTextProperty() {
23+
return citeInText;
24+
}
25+
}

src/main/java/org/jabref/gui/openoffice/BibEntryNotFoundException.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ class BibEntryNotFoundException extends Exception {
44

55
private final String bibtexKey;
66

7-
87
public BibEntryNotFoundException(String bibtexKey, String message) {
98
super(message);
109

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package org.jabref.gui.openoffice;
2+
3+
import javafx.beans.property.SimpleStringProperty;
4+
import javafx.beans.property.StringProperty;
5+
6+
import org.jabref.logic.openoffice.CitationEntry;
7+
8+
public class CitationEntryViewModel {
9+
10+
private final StringProperty citation = new SimpleStringProperty("");
11+
private final StringProperty extraInformation = new SimpleStringProperty("");
12+
private final String refMarkName;
13+
14+
public CitationEntryViewModel(String refMarkName, String citation, String extraInfo) {
15+
this.refMarkName = refMarkName;
16+
this.citation.setValue(citation);
17+
this.extraInformation.setValue(extraInfo);
18+
}
19+
20+
public CitationEntryViewModel(CitationEntry citationEntry) {
21+
this(citationEntry.getRefMarkName(), citationEntry.getContext(), citationEntry.getPageInfo().orElse(""));
22+
}
23+
24+
public CitationEntry toCitationEntry() {
25+
return new CitationEntry(refMarkName, citation.getValue(), extraInformation.getValue());
26+
}
27+
28+
public StringProperty citationProperty() {
29+
return citation;
30+
}
31+
32+
public StringProperty extraInformationProperty() {
33+
return extraInformation;
34+
}
35+
36+
public void setExtraInfo(String extraInfo) {
37+
extraInformation.setValue(extraInfo);
38+
}
39+
40+
}

0 commit comments

Comments
 (0)