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

Fix for #4628 - cant save new content selectors #4658

Merged
merged 12 commits into from
Feb 18, 2019
6 changes: 0 additions & 6 deletions src/main/java/org/jabref/gui/BasePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import org.jabref.gui.actions.EditExternalFileTypesAction;
import org.jabref.gui.actions.ErrorConsoleAction;
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;
Expand Down Expand Up @@ -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)));

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ButtonType?>
<?import javafx.scene.control.DialogPane?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ListView?>
<?import javafx.scene.control.Separator?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>

<DialogPane minHeight="450.0" minWidth="375.0" prefHeight="450.0" prefWidth="407.0" xmlns="http://javafx.com/javafx/8.0.172-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.jabref.gui.contentselector.ContentSelectorDialogView">
<content>
<VBox>
<children>
<Label prefHeight="27.0" prefWidth="108.0" text="Field names" />
<HBox prefHeight="140.0" prefWidth="385.0">
<children>
<ListView fx:id="fieldNamesListView" prefHeight="140.0" prefWidth="297.0"/>
<VBox alignment="TOP_CENTER" prefHeight="200.0" prefWidth="100.0">
<children>
<Button fx:id="addFieldNameButton" alignment="CENTER" mnemonicParsing="false" prefHeight="26.0" prefWidth="72.0" text="%Add" onAction="#addNewFieldName">
<VBox.margin>
<Insets top="5.0" />
</VBox.margin>
</Button>
<Button fx:id="removeFieldNameButton" mnemonicParsing="false" text="%Remove" onAction="#removeFieldName">
<VBox.margin>
<Insets top="5.0" />
</VBox.margin>
</Button>
</children>
</VBox>
</children>
</HBox>
<Separator prefWidth="200.0">
<VBox.margin>
<Insets top="20.0" />
</VBox.margin>
</Separator>
<Label prefHeight="27.0" prefWidth="108.0" text="Keywords" />
<HBox prefHeight="140.0" prefWidth="385.0">
<children>
<ListView fx:id="keywordsListView" prefHeight="140.0" prefWidth="297.0" />
<VBox alignment="TOP_CENTER" prefHeight="200.0" prefWidth="100.0">
<children>
<Button fx:id="addKeywordButton" alignment="CENTER" mnemonicParsing="false" prefHeight="26.0" prefWidth="72.0" text="%Add" onAction="#addNewKeyword">
<VBox.margin>
<Insets top="5.0" />
</VBox.margin>
</Button>
<Button fx:id="removeKeywordButton" mnemonicParsing="false" text="%Remove" onAction="#removeKeyword">
<VBox.margin>
<Insets top="5.0" />
</VBox.margin>
</Button>
</children>
</VBox>
</children>
</HBox>
</children>
</VBox>
</content>
<ButtonType fx:id="saveButton" buttonData="OK_DONE" text="%Save" />
<ButtonType fx:constant="CANCEL" />
</DialogPane>
Loading