Skip to content

Commit

Permalink
Moved select/collapse buttons in unlinked files dialog to a context m…
Browse files Browse the repository at this point in the history
…enu (#7748)

* Added context menu

* Smaller rewordings and changes to size proportions

* CHANGELOG.md

* Removed whitespaces
  • Loading branch information
calixtus authored May 17, 2021
1 parent f3264af commit 65a672a
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 59 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- The export to MS Office XML now uses the month name for the field `Month` instead of the two digit number [forum#2685](https://discourse.jabref.org/t/export-month-as-text-not-number/2685)
- We reintroduced missing default keybindings for new entries. [#7346](https://github.com/JabRef/jabref/issues/7346) [#7439](https://github.com/JabRef/jabref/issues/7439)
- Lists of available fields are now sorted alphabetically. [#7716](https://github.com/JabRef/jabref/issues/7716)
- We moved the select/collapse buttons in the unlinked files dialog into a context menu. [#7383](https://github.com/JabRef/jabref/issues/7383)

### Fixed

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/jabref/gui/actions/StandardActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ public enum StandardActions implements Action {
NEXT_PREVIEW_STYLE(Localization.lang("Next preview style"), KeyBinding.NEXT_PREVIEW_LAYOUT),
PREVIOUS_PREVIEW_STYLE(Localization.lang("Previous preview style"), KeyBinding.PREVIOUS_PREVIEW_LAYOUT),
SELECT_ALL(Localization.lang("Select all"), KeyBinding.SELECT_ALL),
UNSELECT_ALL(Localization.lang("Unselect all")),

EXPAND_ALL(Localization.lang("Expand all")),
COLLAPSE_ALL(Localization.lang("Collapse all")),

NEW_ENTRY(Localization.lang("New entry"), IconTheme.JabRefIcons.ADD_ENTRY, KeyBinding.NEW_ENTRY),
NEW_ARTICLE(Localization.lang("New article"), IconTheme.JabRefIcons.ADD_ARTICLE),
Expand Down
66 changes: 30 additions & 36 deletions src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialog.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
<?import javafx.scene.control.TextField?>
<?import javafx.scene.control.TitledPane?>
<?import javafx.scene.control.Tooltip?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.layout.VBox?>
Expand All @@ -28,16 +28,16 @@
<content>
<VBox spacing="10.0">
<GridPane hgap="10.0" vgap="4.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES"/>
<ColumnConstraints hgrow="ALWAYS"/>
<ColumnConstraints hgrow="SOMETIMES"/>
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="20.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="20.0" vgrow="SOMETIMES"/>
</rowConstraints>
<Label text="%Start directory:" GridPane.columnIndex="0" GridPane.rowIndex="0"/>
<columnConstraints>
<ColumnConstraints minWidth="60.0" hgrow="SOMETIMES"/>
<ColumnConstraints hgrow="ALWAYS"/>
<ColumnConstraints minWidth="60.0" hgrow="SOMETIMES"/>
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="24.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="24.0" vgrow="SOMETIMES"/>
</rowConstraints>
<Label text="%Directory" GridPane.columnIndex="0" GridPane.rowIndex="0"/>
<TextField fx:id="directoryPathField" GridPane.columnIndex="1" GridPane.rowIndex="0"/>
<Button onAction="#browseFileDirectory" styleClass="icon-button,narrow"
GridPane.columnIndex="2" GridPane.rowIndex="0"
Expand All @@ -50,7 +50,7 @@
</tooltip>
</Button>

<Label text="%File type:" GridPane.columnIndex="0" GridPane.rowIndex="1"/>
<Label text="%File type" GridPane.columnIndex="0" GridPane.rowIndex="1"/>
<ComboBox fx:id="fileTypeCombo" maxWidth="Infinity" GridPane.columnIndex="1" GridPane.rowIndex="1"/>
<Button fx:id="scanButton" onAction="#scanFiles" text="%Search"
GridPane.columnIndex="2" GridPane.rowIndex="1">
Expand All @@ -60,19 +60,19 @@
</Button>
</GridPane>
<StackPane VBox.vgrow="ALWAYS">
<Accordion fx:id="accordion" minHeight="300.0" prefHeight="300.0" maxHeight="300.0">
<Accordion fx:id="accordion" prefHeight="300.0">
<panes>
<TitledPane fx:id="filePane" text="%Currently unlinked files">
<TitledPane fx:id="filePane" text="%Search results">
<ScrollPane fitToWidth="true">
<CheckTreeView fx:id="unlinkedFilesList"/>
</ScrollPane>
</TitledPane>
<TitledPane fx:id="resultPane" text="%Import result" disable="true">
<TableView fx:id="importResultTable">
<TableView fx:id="importResultTable" >
<columns>
<TableColumn fx:id="colStatus" prefWidth="100.0" text="%Status"/>
<TableColumn fx:id="colFile" prefWidth="500.0" text="%File"/>
<TableColumn fx:id="colMessage" prefWidth="300.0" text="%Message"/>
<TableColumn fx:id="colStatus" prefWidth="40.0" text="%Status"/>
<TableColumn fx:id="colFile" prefWidth="200.0" text="%File"/>
<TableColumn fx:id="colMessage" prefWidth="320.0" text="%Message"/>
</columns>
<columnResizePolicy>
<TableView fx:constant="UNCONSTRAINED_RESIZE_POLICY"/>
Expand All @@ -87,24 +87,18 @@
<Label fx:id="progressText" text="%Searching file system..."/>
</VBox>
</StackPane>
<ButtonBar buttonMinWidth="80.0" BorderPane.alignment="CENTER">
<buttons>
<Button onAction="#selectAll" text="%Select all" ButtonBar.buttonData="OTHER"/>
<Button onAction="#unselectAll" text="%Unselect all" ButtonBar.buttonData="OTHER"/>
<Button onAction="#collapseAll" text="%Collapse all" ButtonBar.buttonData="OTHER"/>
<Button onAction="#expandAll" text="%Expand all" ButtonBar.buttonData="OTHER"/>
<Button onAction="#exportSelected" text="%Export selected" fx:id="exportButton" ButtonBar.buttonData="OTHER">
<tooltip>
<Tooltip text="%Export to text file."/>
</tooltip>
</Button>
<Button onAction="#startImport" text="%Import" fx:id="importButton" ButtonBar.buttonData="APPLY">
<tooltip>
<Tooltip text="%Starts the import of BibTeX entries."/>
</tooltip>
</Button>
</buttons>
</ButtonBar>
<HBox alignment="CENTER_RIGHT" spacing="4.0">
<Button onAction="#exportSelected" text="%Export selected" fx:id="exportButton" ButtonBar.buttonData="OTHER">
<tooltip>
<Tooltip text="%Export to text file."/>
</tooltip>
</Button>
<Button onAction="#startImport" text="%Import" fx:id="importButton" ButtonBar.buttonData="APPLY">
<tooltip>
<Tooltip text="%Starts the import of BibTeX entries."/>
</tooltip>
</Button>
</HBox>
</VBox>
</content>
<ButtonType fx:constant="CLOSE"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import javafx.scene.control.ButtonType;
import javafx.scene.control.CheckBoxTreeItem;
import javafx.scene.control.ComboBox;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.Control;
import javafx.scene.control.Label;
import javafx.scene.control.ProgressIndicator;
Expand All @@ -27,6 +28,9 @@

import org.jabref.gui.DialogService;
import org.jabref.gui.StateManager;
import org.jabref.gui.actions.ActionFactory;
import org.jabref.gui.actions.SimpleCommand;
import org.jabref.gui.actions.StandardActions;
import org.jabref.gui.externalfiletype.ExternalFileTypes;
import org.jabref.gui.icon.JabRefIcon;
import org.jabref.gui.util.BaseDialog;
Expand Down Expand Up @@ -150,6 +154,8 @@ private void initUnlinkedFilesList() {
fileNode -> fileNode.map(fileNodeViewModel -> new RecursiveTreeItem<>(fileNodeViewModel, FileNodeViewModel::getChildren))
.orElse(null)));

unlinkedFilesList.setContextMenu(createSearchContextMenu());

EasyBind.subscribe(unlinkedFilesList.rootProperty(), root -> {
if (root != null) {
((CheckBoxTreeItem<FileNodeViewModel>) root).setSelected(true);
Expand Down Expand Up @@ -194,16 +200,6 @@ void browseFileDirectory() {
viewModel.browseFileDirectory();
}

@FXML
void collapseAll() {
expandTree(unlinkedFilesList.getRoot(), false);
}

@FXML
void expandAll() {
expandTree(unlinkedFilesList.getRoot(), true);
}

@FXML
void scanFiles() {
viewModel.startSearch();
Expand All @@ -214,16 +210,6 @@ void startImport() {
viewModel.startImport();
}

@FXML
void selectAll() {
unlinkedFilesList.getCheckModel().checkAll();
}

@FXML
void unselectAll() {
unlinkedFilesList.getCheckModel().clearChecks();
}

@FXML
void exportSelected() {
viewModel.startExport();
Expand All @@ -240,4 +226,37 @@ private void expandTree(TreeItem<?> item, boolean expand) {
}
}
}

private ContextMenu createSearchContextMenu() {
ContextMenu contextMenu = new ContextMenu();
ActionFactory factory = new ActionFactory(preferencesService.getKeyBindingRepository());

contextMenu.getItems().add(factory.createMenuItem(StandardActions.SELECT_ALL, new SearchContextAction(StandardActions.SELECT_ALL)));
contextMenu.getItems().add(factory.createMenuItem(StandardActions.UNSELECT_ALL, new SearchContextAction(StandardActions.UNSELECT_ALL)));
contextMenu.getItems().add(factory.createMenuItem(StandardActions.EXPAND_ALL, new SearchContextAction(StandardActions.EXPAND_ALL)));
contextMenu.getItems().add(factory.createMenuItem(StandardActions.COLLAPSE_ALL, new SearchContextAction(StandardActions.COLLAPSE_ALL)));

return contextMenu;
}

private class SearchContextAction extends SimpleCommand {

private final StandardActions command;

public SearchContextAction(StandardActions command) {
this.command = command;

this.executable.bind(unlinkedFilesList.rootProperty().isNotNull());
}

@Override
public void execute() {
switch (command) {
case SELECT_ALL -> unlinkedFilesList.getCheckModel().checkAll();
case UNSELECT_ALL -> unlinkedFilesList.getCheckModel().clearChecks();
case EXPAND_ALL -> expandTree(unlinkedFilesList.getRoot(), true);
case COLLAPSE_ALL -> expandTree(unlinkedFilesList.getRoot(), false);
}
}
}
}
5 changes: 2 additions & 3 deletions src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1097,9 +1097,8 @@ Expand\ all=Expand all
Collapse\ all=Collapse all
Searches\ the\ selected\ directory\ for\ unlinked\ files.=Searches the selected directory for unlinked files.
Starts\ the\ import\ of\ BibTeX\ entries.=Starts the import of BibTeX entries.
Start\ directory\:=Start directory:
File\ type\:=File type:
Currently\ unlinked\ files=Currently unlinked files
Directory=Directory
Search\ results=Search results
Import\ result=Import result
Searching\ file\ system...=Searching file system...
Citation\ key\ patterns=Citation key patterns
Expand Down

0 comments on commit 65a672a

Please sign in to comment.