Skip to content

Commit

Permalink
reload preferences in connect
Browse files Browse the repository at this point in the history
fix passing of prefs
fix advanced cite dialog
  • Loading branch information
Siedlerchr committed Sep 23, 2018
1 parent 69e9fe5 commit b92445b
Show file tree
Hide file tree
Showing 7 changed files with 163 additions and 71 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/SidePaneManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public SidePaneManager(JabRefPreferences preferences, JabRefFrame frame) {
new FileUpdatePanel(this),
new GroupSidePane(this, preferences, frame.getDialogService()),
new WebSearchPane(this, preferences, frame),
new OpenOfficeSidePanel(this, openOfficePreferences, frame, preferences.getKeyBindingRepository()))
new OpenOfficeSidePanel(this, preferences, frame))
.forEach(pane -> components.put(pane.getType(), pane));

if (preferences.getBoolean(JabRefPreferences.GROUP_SIDEPANE_VISIBLE)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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;
Expand All @@ -9,22 +10,35 @@

import com.airhacks.afterburner.views.ViewLoader;

public class AdvancedCiteDialogView extends BaseDialog<Void> {
public class AdvancedCiteDialogView extends BaseDialog<AdvancedCiteDialogViewModel> {

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

public AdvancedCiteDialogView() {

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

}

@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 @@ -10,11 +10,7 @@
import javafx.scene.control.TextField;

import org.jabref.gui.DialogService;
import org.jabref.gui.desktop.JabRefDesktop;
import org.jabref.gui.desktop.os.NativeDesktop;
import org.jabref.gui.util.BaseDialog;
import org.jabref.gui.util.DirectoryDialogConfiguration;
import org.jabref.gui.util.FileDialogConfiguration;
import org.jabref.logic.openoffice.OpenOfficePreferences;
import org.jabref.logic.util.OS;
import org.jabref.preferences.PreferencesService;
Expand All @@ -35,10 +31,9 @@ public class ManualConnectDialogView extends BaseDialog<Boolean> {

@Inject private PreferencesService preferencesService;

private final DirectoryDialogConfiguration dirDialogConfiguration;
private final FileDialogConfiguration fileDialogConfiguration;
private final DialogService dialogService;
private OpenOfficePreferences preferences;
private ManualConnectDialogViewModel viewModel;

public ManualConnectDialogView(DialogService dialogService) {
this.dialogService = dialogService;
Expand All @@ -47,22 +42,14 @@ public ManualConnectDialogView(DialogService dialogService) {
.load()
.setAsDialogPane(this);

final NativeDesktop nativeDesktop = JabRefDesktop.getNativeDesktop();

dirDialogConfiguration = new DirectoryDialogConfiguration.Builder()
.withInitialDirectory(nativeDesktop.getApplicationDirectory())
.build();
fileDialogConfiguration = new FileDialogConfiguration.Builder()
.withInitialDirectory(nativeDesktop.getApplicationDirectory())
.build();

setResultConverter(button -> {
if (button == ButtonType.OK) {
if (OS.WINDOWS || OS.OS_X) {
preferences.updateConnectionParams(ooPath.getText(), ooPath.getText(), ooPath.getText());
preferences.updateConnectionParams(viewModel.ooPathProperty().getValue(), viewModel.ooPathProperty().getValue(), viewModel.ooPathProperty().getValue());
} else {
preferences.updateConnectionParams(ooPath.getText(), ooExec.getText(), ooJars.getText());
preferences.updateConnectionParams(viewModel.ooPathProperty().getValue(), viewModel.ooExecProperty().getValue(), viewModel.ooJarsProperty().getValue());
}

preferencesService.setOpenOfficePreferences(preferences);

return true;
Expand All @@ -74,22 +61,23 @@ public ManualConnectDialogView(DialogService dialogService) {

@FXML
private void initialize() {
this.preferences = preferencesService.getOpenOfficePreferences();

preferences = preferencesService.getOpenOfficePreferences();
ooPath.setText(preferences.getInstallationPath());
ooExec.setText(preferences.getExecutablePath());
ooJars.setText(preferences.getJarsPath());

ooExecLabel.managedProperty().bind(ooExec.visibleProperty());
ooExec.managedProperty().bind(ooExec.visibleProperty());
browseOOExec.managedProperty().bind(ooExec.visibleProperty());
viewModel = new ManualConnectDialogViewModel(preferencesService.getOpenOfficePreferences(), dialogService);

OOPathLabel.managedProperty().bind(ooPath.visibleProperty());
ooPath.managedProperty().bind(ooPath.visibleProperty());
ooPath.textProperty().bindBidirectional(viewModel.ooPathProperty());
browseOOPath.managedProperty().bind(ooPath.visibleProperty());

ooExecLabel.managedProperty().bind(ooExec.visibleProperty());
ooExec.managedProperty().bind(ooExec.visibleProperty());
ooExec.textProperty().bindBidirectional(viewModel.ooExecProperty());
browseOOExec.managedProperty().bind(ooExec.visibleProperty());

ooJarsLabel.managedProperty().bind(ooJars.visibleProperty());
ooJars.managedProperty().bind(ooJars.visibleProperty());
ooJars.textProperty().bind(viewModel.ooJarsProperty());
browseOOJars.managedProperty().bind(ooJars.visibleProperty());

if (OS.WINDOWS || OS.OS_X) {
Expand All @@ -106,19 +94,17 @@ private void initialize() {

@FXML
void browseOOPath(ActionEvent event) {
dialogService.showDirectorySelectionDialog(dirDialogConfiguration).ifPresent(f -> ooPath.setText(f.toAbsolutePath().toString()));
viewModel.browseOOPath();
}


@FXML
void browseOOExec(ActionEvent event) {
dialogService.showFileOpenDialog(fileDialogConfiguration).ifPresent(f -> ooExec.setText(f.toAbsolutePath().toString()));
viewModel.browseOOExec();
}

@FXML
void browseOOJars(ActionEvent event) {
dialogService.showDirectorySelectionDialog(dirDialogConfiguration).ifPresent(f -> ooJars.setText(f.toAbsolutePath().toString()));
viewModel.browseOOJars();
}


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

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

import org.jabref.gui.DialogService;
import org.jabref.gui.desktop.JabRefDesktop;
import org.jabref.gui.desktop.os.NativeDesktop;
import org.jabref.gui.util.DirectoryDialogConfiguration;
import org.jabref.gui.util.FileDialogConfiguration;
import org.jabref.logic.openoffice.OpenOfficePreferences;

public class ManualConnectDialogViewModel {

private final StringProperty ooPath = new SimpleStringProperty("");
private final StringProperty ooExec = new SimpleStringProperty("");
private final StringProperty ooJars = new SimpleStringProperty("");
private final DialogService dialogService;
private final NativeDesktop nativeDesktop = JabRefDesktop.getNativeDesktop();
private final FileDialogConfiguration fileDialogConfiguration;
private final DirectoryDialogConfiguration dirDialogConfiguration;

public ManualConnectDialogViewModel(OpenOfficePreferences preferences, DialogService dialogService) {
this.dialogService = dialogService;

ooPathProperty().setValue(preferences.getInstallationPath());
ooExecProperty().setValue(preferences.getExecutablePath());
ooJarsProperty().setValue(preferences.getJarsPath());

dirDialogConfiguration = new DirectoryDialogConfiguration.Builder()
.withInitialDirectory(nativeDesktop.getApplicationDirectory())
.build();
fileDialogConfiguration = new FileDialogConfiguration.Builder()
.withInitialDirectory(nativeDesktop.getApplicationDirectory())
.build();
}

public void browseOOPath() {
dialogService.showDirectorySelectionDialog(dirDialogConfiguration).ifPresent(path -> ooPath.setValue(path.toAbsolutePath().toString()));
}

public void browseOOExec() {
dialogService.showFileOpenDialog(fileDialogConfiguration).ifPresent(f -> ooExec.setValue(f.toAbsolutePath().toString()));

}

public void browseOOJars() {
dialogService.showDirectorySelectionDialog(dirDialogConfiguration).ifPresent(path -> ooJars.setValue(path.toAbsolutePath().toString()));
}

public StringProperty ooPathProperty() {
return ooPath;
}

public StringProperty ooExecProperty() {
return ooExec;
}

public StringProperty ooJarsProperty() {
return ooJars;
}

}
Loading

0 comments on commit b92445b

Please sign in to comment.