Skip to content
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

Small refactoring in Importer package #2053

Merged
merged 8 commits into from
Oct 5, 2016

Conversation

tobiasdiez
Copy link
Member

  • Remove unused methods in ImportFormatPreferences
  • Rename interface ImportFormat to Importer (this probably requires that all custom importer have to be changed to)
  • Rewrite CustomImporter to implement Importer interface

(Localization tests fail due to rename, will fix this before merge)

  • Change in CHANGELOG.md described
  • Tests created for changes
  • Screenshots added (for bigger UI changes)
  • Manually tested changed features in running JabRef
  • Check documentation status (Issue created for outdated help page at help.jabref.org?)

@tobiasdiez tobiasdiez added status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers type: code-quality Issues related to code or architecture decisions labels Sep 24, 2016
Copy link
Member

@Siedlerchr Siedlerchr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice if you could take a look at the nio related stuff

@@ -79,21 +78,19 @@ public ImportCustomizationDialog(final JabRefFrame frame) {

JButton addFromFolderButton = new JButton(Localization.lang("Add from folder"));
addFromFolderButton.addActionListener(e -> {
CustomImporter importer = new CustomImporter();

FileDialog dialog = new FileDialog(frame).withExtension(FileExtensions.CLASS);
dialog.setDefaultExtension(FileExtensions.CLASS);
Optional<Path> selectedFile = dialog.showDialogAndGetSelectedFile();

if (selectedFile.isPresent() && (selectedFile.get().getParent() != null)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there it would actually make sense to use ifPresent or is there somehow a possible exception thrown?

String className = null;
File actualPath = path;
// remove leading basepath from path
while (!actualPath.equals(basePath)) {
while (!actualPath.equals(new File(basePath))) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this somehow be replaced with nio methods?

.replace("/", ".");
importer.setClassName(className);
String className = tempZipEntry.getName().substring(0, tempZipEntry.getName().lastIndexOf('.')).replace(
"/", ".");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really weird. Maybe can be replaced with sth from the nio paths

@Siedlerchr
Copy link
Member

I am not sure if I like that Custom Imports have to be changed as this is again breaking functionality for existing importers

@Siedlerchr
Copy link
Member

You have some check style errors...

@tobiasdiez
Copy link
Member Author

I decided against changing the File occurrences with nio.path since I don't understand the code in the gui good enough (and there are no unit tests as a backup because its gui code). But the logic code in now free of the old java File.

Will merge this now... you had enough time to protest 😆

@tobiasdiez tobiasdiez merged commit 8ed69d6 into JabRef:master Oct 5, 2016
@tobiasdiez tobiasdiez deleted the importerRefact branch October 5, 2016 18:23
Siedlerchr added a commit that referenced this pull request Oct 9, 2016
* upstream/master: (102 commits)
  Removed unused test code (#2140)
  Fix main table bug when creating a duplicate (#2135)
  Remove explicit author and add SPDX-License-Identifier
  Remove GPL from README.md and CONTRIBUTING.md
  fix preview update (#2125)
  Remove some UnicodeToLatex uses (#2132)
  Fix mixup in french/farsi localization
  FetcherException should extend JabRefException
  Fix exception when opening preference dialog (#2127)
  Unify ParserException and ParseException (#2124)
  Small refactoring in Importer package (#2053)
  Implement Datepicker "none"-button (#2122)
  revert change from 816d30c
  Change title/tooltip of source panel in biblatex mode (#2120)
  Refactoring: completey typed metadata and add detailed travis output (#2112)
  RTFchars fix (#2097)
  Fix NPE in Medline fetcher on missing ISSN (#2113)
  Ctrl-s parsing error message (#2114)
  Fix bad web search error messages (#2034)
  parse error freeze (#2106)
  ...

# Conflicts:
#	src/main/java/net/sf/jabref/collab/FileUpdateMonitor.java
#	src/main/java/net/sf/jabref/gui/externalfiles/DownloadExternalFile.java
#	src/main/java/net/sf/jabref/gui/externalfiles/DroppedFileHandler.java
#	src/main/java/net/sf/jabref/gui/externalfiles/MoveFileAction.java
#	src/main/java/net/sf/jabref/logic/cleanup/RenamePdfCleanup.java
#	src/main/java/net/sf/jabref/logic/exporter/FileSaveSession.java
#	src/main/java/net/sf/jabref/logic/util/io/FileUtil.java
#	src/main/java/net/sf/jabref/preferences/JabRefPreferences.java
zesaro pushed a commit to zesaro/jabref that referenced this pull request Nov 22, 2016
* Remove unused methods and mark some methods as deprecated in importformatpreferences

* Rename importformat to importer

* Move importer up in package

* Rename getFormatName -> getName

* Rewrite CustomImporter

* Optimize imports

* Add changelog entry

* Change localizaiton
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers type: code-quality Issues related to code or architecture decisions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants