Skip to content

Commit

Permalink
Add Properties for binding
Browse files Browse the repository at this point in the history
  • Loading branch information
Siedlerchr committed Jul 31, 2017
1 parent b6d43dc commit b3d7641
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.Optional;

import javax.inject.Inject;
Expand All @@ -18,6 +19,7 @@
import org.jabref.gui.StateManager;
import org.jabref.gui.externalfiletype.ExternalFileType;
import org.jabref.gui.util.FileDialogConfiguration;
import org.jabref.logic.util.io.FileUtil;
import org.jabref.model.util.FileHelper;
import org.jabref.preferences.JabRefPreferences;
import org.jabref.preferences.PreferencesService;
Expand All @@ -36,6 +38,7 @@ public class FileListDialogController extends AbstractController<FileListDialogV
@Inject private PreferencesService preferences;
@Inject private DialogService dialogService;
@Inject private StateManager stateManager;

private boolean showSaveDialog;

@FXML
Expand All @@ -61,6 +64,18 @@ void browseFileDialog(ActionEvent event) {
} else {
path = dialogService.showFileOpenDialog(fileDialogConfiguration);
}
path.ifPresent(newFile -> {
// Store the directory for next time:
Globals.prefs.put(JabRefPreferences.WORKING_DIRECTORY, newFile.toString());

// If the file is below the file directory, make the path relative:
List<Path> fileDirectories = this.stateManager.getActiveDatabase().get()
.getFileDirectoriesAsPaths(Globals.prefs.getFileDirectoryPreferences());
newFile = FileUtil.shortenFileName(newFile, fileDirectories);

tfLink.setText(newFile.toString());
tfLink.requestFocus();
});
}

@FXML
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/org/jabref/gui/filelist/FileListDialogViewModel.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
package org.jabref.gui.filelist;

import javafx.beans.property.ListProperty;
import javafx.beans.property.SimpleListProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.collections.FXCollections;

import org.jabref.gui.AbstractViewModel;
import org.jabref.gui.externalfiletype.ExternalFileType;

public class FileListDialogViewModel extends AbstractViewModel {

private final StringProperty linkProperty = new SimpleStringProperty();
private final StringProperty descriptionProperty = new SimpleStringProperty();
private final ListProperty<ExternalFileType> externalfilesTypes = new SimpleListProperty<>(FXCollections.emptyObservableList());

public FileListDialogViewModel() {


}
//
}

0 comments on commit b3d7641

Please sign in to comment.