Skip to content

Commit

Permalink
Convert OO/LO SidePanel to javafx (#4341)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Siedlerchr authored Jan 25, 2019
1 parent 48c5a20 commit 18aba35
Show file tree
Hide file tree
Showing 34 changed files with 1,443 additions and 1,571 deletions.
8 changes: 4 additions & 4 deletions src/main/java/org/jabref/gui/DialogService.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ default void showErrorDialogAndWait(Exception exception) {
* @return true if the use clicked "YES" otherwise false
*/
boolean showConfirmationDialogWithOptOutAndWait(String title, String content,
String optOutMessage, Consumer<Boolean> optOutAction);
String optOutMessage, Consumer<Boolean> optOutAction);

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

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

/**
* This will create and display a new dialog showing a custom {@link DialogPane}
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/org/jabref/gui/FXDialogService.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private static FXDialog createDialog(AlertType type, String title, String conten
}

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

@Override
public boolean showConfirmationDialogAndWait(String title, String content,
String okButtonLabel, String cancelButtonLabel) {
String okButtonLabel, String cancelButtonLabel) {
FXDialog alert = createDialog(AlertType.CONFIRMATION, title, content);
ButtonType okButtonType = new ButtonType(okButtonLabel, ButtonBar.ButtonData.OK_DONE);
ButtonType cancelButtonType = new ButtonType(cancelButtonLabel, ButtonBar.ButtonData.NO);
Expand All @@ -190,16 +190,16 @@ public boolean showConfirmationDialogAndWait(String title, String content,

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

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

@Override
public Optional<ButtonType> showCustomButtonDialogAndWait(AlertType type, String title, String content,
ButtonType... buttonTypes) {
ButtonType... buttonTypes) {
FXDialog alert = createDialog(type, title, content);
alert.getButtonTypes().setAll(buttonTypes);
return alert.showAndWait();
}

@Override
public Optional<ButtonType> showCustomDialogAndWait(String title, DialogPane contentPane,
ButtonType... buttonTypes) {
ButtonType... buttonTypes) {
FXDialog alert = new FXDialog(AlertType.NONE, title);
alert.setDialogPane(contentPane);
alert.getButtonTypes().setAll(buttonTypes);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jabref/gui/SidePaneManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public SidePaneManager(JabRefPreferences preferences, JabRefFrame frame) {
Stream.of(
new FileUpdatePanel(this),
new GroupSidePane(this, preferences, frame.getDialogService()),
new WebSearchPane(this, preferences, frame),
new OpenOfficeSidePanel(this, openOfficePreferences, frame))
new WebSearchPane(this, preferences, frame),
new OpenOfficeSidePanel(this, preferences, frame))
.forEach(pane -> components.put(pane.getType(), pane));

if (preferences.getBoolean(JabRefPreferences.GROUP_SIDEPANE_VISIBLE)) {
Expand Down
30 changes: 30 additions & 0 deletions src/main/java/org/jabref/gui/openoffice/AdvancedCiteDialog.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.ButtonType?>
<?import javafx.scene.control.DialogPane?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.RadioButton?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.control.ToggleGroup?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>

<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">
<content>
<VBox>
<fx:define>
<ToggleGroup fx:id="citeToggleGroup" />
</fx:define>
<children>
<RadioButton fx:id="inPar" minWidth="-Infinity" mnemonicParsing="false" text="%Cite selected entries between parenthesis" toggleGroup="$citeToggleGroup" />
<RadioButton fx:id="inText" minWidth="-Infinity" mnemonicParsing="false" text="%Cite selected entries with in-text citation" toggleGroup="$citeToggleGroup" />
<Label minWidth="-Infinity" text="%Extra information (e.g. page number)" />
<TextField fx:id="pageInfo" />
</children>
</VBox>
</content>
<buttonTypes>
<ButtonType fx:constant="CANCEL" />
<ButtonType fx:constant="OK" />
</buttonTypes>
</DialogPane>
113 changes: 0 additions & 113 deletions src/main/java/org/jabref/gui/openoffice/AdvancedCiteDialog.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package org.jabref.gui.openoffice;

import javafx.fxml.FXML;
import javafx.scene.control.ButtonType;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextField;
import javafx.scene.control.ToggleGroup;

import org.jabref.gui.util.BaseDialog;
import org.jabref.logic.l10n.Localization;

import com.airhacks.afterburner.views.ViewLoader;

public class AdvancedCiteDialogView extends BaseDialog<AdvancedCiteDialogViewModel> {

@FXML private TextField pageInfo;
@FXML private RadioButton inPar;
@FXML private RadioButton inText;
@FXML private ToggleGroup citeToggleGroup;
private AdvancedCiteDialogViewModel viewModel;

public AdvancedCiteDialogView() {

ViewLoader.view(this)
.load()
.setAsDialogPane(this);
setResultConverter(btn -> {
if (btn == ButtonType.OK) {
return viewModel;
}
return null;
});

setTitle(Localization.lang("Cite special"));
}

@FXML
private void initialize() {
viewModel = new AdvancedCiteDialogViewModel();

inPar.selectedProperty().bindBidirectional(viewModel.citeInParProperty());
inText.selectedProperty().bindBidirectional(viewModel.citeInTextProperty());
pageInfo.textProperty().bindBidirectional(viewModel.pageInfoProperty());

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.jabref.gui.openoffice;

import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;

public class AdvancedCiteDialogViewModel {

private final StringProperty pageInfo = new SimpleStringProperty("");
private final BooleanProperty citeInPar = new SimpleBooleanProperty();
private final BooleanProperty citeInText = new SimpleBooleanProperty();

public StringProperty pageInfoProperty() {
return pageInfo;
}

public BooleanProperty citeInParProperty() {
return citeInPar;
}

public BooleanProperty citeInTextProperty() {
return citeInText;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ class BibEntryNotFoundException extends Exception {

private final String bibtexKey;


public BibEntryNotFoundException(String bibtexKey, String message) {
super(message);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package org.jabref.gui.openoffice;

import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;

import org.jabref.logic.openoffice.CitationEntry;

public class CitationEntryViewModel {

private final StringProperty citation = new SimpleStringProperty("");
private final StringProperty extraInformation = new SimpleStringProperty("");
private final String refMarkName;

public CitationEntryViewModel(String refMarkName, String citation, String extraInfo) {
this.refMarkName = refMarkName;
this.citation.setValue(citation);
this.extraInformation.setValue(extraInfo);
}

public CitationEntryViewModel(CitationEntry citationEntry) {
this(citationEntry.getRefMarkName(), citationEntry.getContext(), citationEntry.getPageInfo().orElse(""));
}

public CitationEntry toCitationEntry() {
return new CitationEntry(refMarkName, citation.getValue(), extraInformation.getValue());
}

public StringProperty citationProperty() {
return citation;
}

public StringProperty extraInformationProperty() {
return extraInformation;
}

public void setExtraInfo(String extraInfo) {
extraInformation.setValue(extraInfo);
}

}
Loading

0 comments on commit 18aba35

Please sign in to comment.