Skip to content

Commit

Permalink
Show mod version uids and filter by them (fixes #97)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brutus5000 committed Jul 25, 2019
1 parent f1d8d3d commit 2f6ea49
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public List<Mod> findModsByName(@NotNull String pattern, boolean excludeHidden)
return findModsByAttribute("displayName", pattern, excludeHidden);
}

public List<Mod> findModsByModVersionUid(@NotNull String pattern, boolean excludeHidden) {
return findModsByAttribute("versions.uid", pattern, excludeHidden);
}

public List<Mod> findModsByAuthorId(@NotNull String pattern, boolean excludeHidden) {
return findModsByAttribute("uploader.id", pattern, excludeHidden);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,12 @@ public static void buildModVersionTableView(TableView<ModVersionFX> tableView, O
tableView.getColumns().add(nameColumn);
extractors.put(nameColumn, ModVersionFX::getVersion);

TableColumn<ModVersionFX, String> uidColumn = new TableColumn<>("UID");
uidColumn.setCellValueFactory(o -> o.getValue().uidProperty());
uidColumn.setMinWidth(280);
tableView.getColumns().add(uidColumn);
extractors.put(uidColumn, ModVersionFX::getUid);

TableColumn<ModVersionFX, Boolean> rankedCheckBoxColumn = new TableColumn<>("Ranked");
rankedCheckBoxColumn.setCellValueFactory(param -> param.getValue().rankedProperty());
rankedCheckBoxColumn.setCellFactory(CheckBoxTableCell.forTableColumn(rankedCheckBoxColumn));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
import org.apache.maven.artifact.versioning.ComparableVersion;

import java.net.URL;
import java.util.UUID;

public class ModVersionFX extends AbstractEntityFX {
private final ObjectProperty<UUID> uuid;
private final ObjectProperty<String> uid;
private final ObjectProperty<ModType> type;
private final ObjectProperty<String> description;
private final ObjectProperty<ComparableVersion> version;
Expand All @@ -26,7 +25,7 @@ public class ModVersionFX extends AbstractEntityFX {


public ModVersionFX() {
uuid = new SimpleObjectProperty<>();
uid = new SimpleObjectProperty<>();
type = new SimpleObjectProperty<>();
description = new SimpleObjectProperty<>();
version = new SimpleObjectProperty<>();
Expand All @@ -39,16 +38,16 @@ public ModVersionFX() {
mod = new SimpleObjectProperty<>();
}

public UUID getUuid() {
return uuid.get();
public String getUid() {
return uid.get();
}

public void setUuid(UUID uuid) {
this.uuid.set(uuid);
public void setUid(String uid) {
this.uid.set(uid);
}

public ObjectProperty<UUID> uuidProperty() {
return uuid;
public ObjectProperty<String> uidProperty() {
return uid;
}

public ModType getType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class ModVaultController implements Controller<SplitPane> {
private final ModVersionMapper modVersionMapper;
public SplitPane root;
public RadioButton searchModByModNameRadioButton;
public RadioButton searchModByModVersionUidRadioButton;
public RadioButton searchModByAuthorIdRadioButton;
public RadioButton searchModByAuthorNameRadioButton;
public TextField modSearchTextField;
Expand Down Expand Up @@ -83,6 +84,8 @@ public void onSearchMods() {
String searchPattern = modSearchTextField.getText();
if (searchModByModNameRadioButton.isSelected()) {
modsFound = modService.findModsByName(searchPattern, excludeHiddenModVersionsCheckbox.isSelected());
} else if (searchModByModVersionUidRadioButton.isSelected()) {
modsFound = modService.findModsByModVersionUid(searchPattern, excludeHiddenModVersionsCheckbox.isSelected());
} else if (searchModByAuthorIdRadioButton.isSelected()) {
modsFound = modService.findModsByAuthorId(searchPattern, excludeHiddenModVersionsCheckbox.isSelected());
} else if (searchModByAuthorNameRadioButton.isSelected()) {
Expand Down
8 changes: 7 additions & 1 deletion src/main/resources/ui/main_window/modVault.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.Font?>
<SplitPane xmlns:fx="http://javafx.com/fxml/1" fx:id="root" dividerPositions="0.5" orientation="VERTICAL"
xmlns="http://javafx.com/javafx/8.0.141"
xmlns="http://javafx.com/javafx/8.0.171"
fx:controller="com.faforever.moderatorclient.ui.main_window.ModVaultController">
<items>
<TabPane tabClosingPolicy="UNAVAILABLE">
Expand All @@ -26,6 +26,12 @@
<ToggleGroup fx:id="modSearch"/>
</toggleGroup>
</RadioButton>
<RadioButton fx:id="searchModByModVersionUidRadioButton" mnemonicParsing="false"
text="search by uid" toggleGroup="$modSearch">
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
</padding>
</RadioButton>
<RadioButton fx:id="searchModByAuthorIdRadioButton" mnemonicParsing="false"
text="search by uploader id" toggleGroup="$modSearch">
<padding>
Expand Down

0 comments on commit 2f6ea49

Please sign in to comment.