diff --git a/build.gradle b/build.gradle index 1e55cfe71cc..9a7e49aafea 100644 --- a/build.gradle +++ b/build.gradle @@ -167,7 +167,7 @@ dependencies { testRuntime 'org.apache.logging.log4j:log4j-core:2.11.1' testRuntime 'org.apache.logging.log4j:log4j-jul:2.11.2' - testCompile 'org.mockito:mockito-core:2.24.0' + testCompile 'org.mockito:mockito-core:2.24.5' testCompile 'com.github.tomakehurst:wiremock:2.21.0' testCompile 'org.assertj:assertj-swing-junit:3.9.2' testCompile 'org.reflections:reflections:0.9.11' diff --git a/src/main/java/org/jabref/gui/BasePanel.java b/src/main/java/org/jabref/gui/BasePanel.java index ef5e2875994..8c99cc4a68a 100644 --- a/src/main/java/org/jabref/gui/BasePanel.java +++ b/src/main/java/org/jabref/gui/BasePanel.java @@ -43,7 +43,6 @@ import org.jabref.gui.bibtexkeypattern.SearchFixDuplicateLabels; import org.jabref.gui.collab.DatabaseChangeMonitor; import org.jabref.gui.collab.FileUpdatePanel; -import org.jabref.gui.contentselector.ContentSelectorDialog; import org.jabref.gui.desktop.JabRefDesktop; import org.jabref.gui.edit.ReplaceStringAction; import org.jabref.gui.entryeditor.EntryEditor; @@ -399,11 +398,6 @@ private void setupActions() { actions.put(Actions.NEXT_PREVIEW_STYLE, this::nextPreviewStyle); actions.put(Actions.PREVIOUS_PREVIEW_STYLE, this::previousPreviewStyle); - actions.put(Actions.MANAGE_SELECTORS, () -> { - ContentSelectorDialog csd = new ContentSelectorDialog(frame, BasePanel.this, false, null); - csd.setVisible(true); - }); - actions.put(Actions.SEND_AS_EMAIL, new SendAsEMailAction(frame)); actions.put(Actions.WRITE_XMP, new WriteXMPAction(this)::execute); diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java index 169e1b9ed0c..1250bc28128 100644 --- a/src/main/java/org/jabref/gui/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/JabRefFrame.java @@ -64,6 +64,7 @@ import org.jabref.gui.actions.ErrorConsoleAction; import org.jabref.gui.actions.LibraryPropertiesAction; import org.jabref.gui.actions.LookupIdentifierAction; +import org.jabref.gui.actions.ManageContentSelectorAction; import org.jabref.gui.actions.ManageCustomExportsAction; import org.jabref.gui.actions.ManageCustomImportsAction; import org.jabref.gui.actions.ManageJournalsAction; @@ -941,7 +942,7 @@ private MenuBar createMenu() { new SeparatorMenuItem(), - factory.createMenuItem(StandardActions.MANAGE_CONTENT_SELECTORS, new OldDatabaseCommandWrapper(Actions.MANAGE_SELECTORS, this, Globals.stateManager)), + factory.createMenuItem(StandardActions.MANAGE_CONTENT_SELECTORS, new ManageContentSelectorAction(this)), factory.createMenuItem(StandardActions.CUSTOMIZE_ENTRY_TYPES, new CustomizeEntryAction(this)), factory.createMenuItem(StandardActions.MANAGE_CITE_KEY_PATTERNS, new BibtexKeyPatternAction(this))); diff --git a/src/main/java/org/jabref/gui/actions/ManageContentSelectorAction.java b/src/main/java/org/jabref/gui/actions/ManageContentSelectorAction.java new file mode 100644 index 00000000000..31e2b1e1149 --- /dev/null +++ b/src/main/java/org/jabref/gui/actions/ManageContentSelectorAction.java @@ -0,0 +1,29 @@ +package org.jabref.gui.actions; + +import org.jabref.gui.BasePanel; +import org.jabref.gui.JabRefFrame; +import org.jabref.gui.contentselector.ContentSelectorDialogView; +import org.jabref.logic.l10n.Localization; + +public class ManageContentSelectorAction extends SimpleCommand { + + private final JabRefFrame jabRefFrame; + + public ManageContentSelectorAction(JabRefFrame jabRefFrame) { + this.jabRefFrame = jabRefFrame; + } + + @Override + public void execute() { + BasePanel basePanel = jabRefFrame.getCurrentBasePanel(); + if (noActiveConnectionExists(basePanel)) { + jabRefFrame.getDialogService().showErrorDialogAndWait(Localization.lang("Active database connection do not exists!")); + return; + } + new ContentSelectorDialogView(basePanel).showAndWait(); + } + + private boolean noActiveConnectionExists(BasePanel basePanel) { + return basePanel == null || basePanel.getBibDatabaseContext() == null; + } +} diff --git a/src/main/java/org/jabref/gui/contentselector/ContentSelectorDialog.fxml b/src/main/java/org/jabref/gui/contentselector/ContentSelectorDialog.fxml new file mode 100644 index 00000000000..94744038b42 --- /dev/null +++ b/src/main/java/org/jabref/gui/contentselector/ContentSelectorDialog.fxml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/org/jabref/gui/contentselector/ContentSelectorDialog.java b/src/main/java/org/jabref/gui/contentselector/ContentSelectorDialog.java deleted file mode 100644 index a188c1fca8a..00000000000 --- a/src/main/java/org/jabref/gui/contentselector/ContentSelectorDialog.java +++ /dev/null @@ -1,499 +0,0 @@ -package org.jabref.gui.contentselector; - -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.FocusAdapter; -import java.awt.event.FocusEvent; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; - -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.BorderFactory; -import javax.swing.DefaultListModel; -import javax.swing.JButton; -import javax.swing.JList; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTextField; - -import org.jabref.gui.BasePanel; -import org.jabref.gui.JabRefDialog; -import org.jabref.gui.JabRefFrame; -import org.jabref.gui.help.HelpAction; -import org.jabref.gui.keyboard.KeyBinder; -import org.jabref.logic.help.HelpFile; -import org.jabref.logic.l10n.Localization; -import org.jabref.model.entry.FieldName; -import org.jabref.model.metadata.ContentSelector; -import org.jabref.model.metadata.ContentSelectors; -import org.jabref.model.metadata.MetaData; - -import com.jgoodies.forms.builder.ButtonBarBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ContentSelectorDialog extends JabRefDialog { - - private static final String WORD_FIRSTLINE_TEXT = Localization.lang(" Abbreviate\ journal\ names\ of\ the\ selected\ entries\ (ISO\ abbreviation)=Abbreviate journal names of the selected entries (ISO abbreviation) Abbreviate\ journal\ names\ of\ the\ selected\ entries\ (MEDLINE\ abbreviation)=Abbreviate journal names of the selected entries (MEDLINE abbreviation) @@ -1470,7 +1467,6 @@ Move\ to\ group=Move to group Clear\ read\ status=Clear read status Convert\ to\ biblatex\ format\ (for\ example,\ move\ the\ value\ of\ the\ 'journal'\ field\ to\ 'journaltitle')=Convert to biblatex format (for example, move the value of the 'journal' field to 'journaltitle') -Could\ not\ apply\ changes.=Could not apply changes. Deprecated\ fields=Deprecated fields No\ read\ status\ information=No read status information Printed=Printed @@ -2175,4 +2171,17 @@ Error\ adding\ discovered\ CitationStyles=Error adding discovered CitationStyles Add\ new\ String=Add new String Remove\ selected\ Strings=Remove selected Strings Must\ not\ be\ empty\!=Must not be empty\! -Open\ Help\ page=Open Help page \ No newline at end of file +Open\ Help\ page=Open Help page + +Active\ database\ connection\ do\ not\ exists\!=Active database connection do not exists! +Add\ new\ field\ name=Add new field name +Field\ name\:=Field name: +Field\ name\ \"%0\"\ already\ exists=Field name "%0" already exists +No\ field\ name\ selected\!=No field name selected! +Remove\ field\ name=Remove field name +Are\ you\ sure\ you\ want\ to\ remove\ field\ name\:\ \"%0\"?=Are you sure you want to remove field name: "%0"? +Add\ new\ keyword=Add new keyword +Keyword\:=Keyword: +Keyword\ \"%0\"\ already\ exists=Keyword "%0" already exists +Remove\ keyword=Remove keyword +Are\ you\ sure\ you\ want\ to\ remove\ keyword\:\ \"%0\"?=Are you sure you want to remove keyword: "%0"?