Skip to content

Commit

Permalink
Add an item types tab.
Browse files Browse the repository at this point in the history
  • Loading branch information
io7m committed May 26, 2024
1 parent 145cac6 commit 4114f79
Show file tree
Hide file tree
Showing 13 changed files with 234 additions and 50 deletions.
Binary file modified com.io7m.cardant_gui.ui/src/main/images/images.xcf
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.io7m.cardant.model.CALocationID;
import com.io7m.cardant.model.CALocationSummary;
import com.io7m.cardant.model.CAMetadataType;
import com.io7m.cardant.model.CATypeRecordIdentifier;
import com.io7m.cardant.model.type_package.CATypePackageIdentifier;
import com.io7m.cardant.model.type_package.CATypePackageSearchParameters;
import com.io7m.cardant.model.type_package.CATypePackageSummary;
Expand Down Expand Up @@ -119,6 +120,9 @@ public final class CAGController implements CAGControllerType
private final SimpleObjectProperty<CAGPageRange> locationPages;
private final SimpleObjectProperty<CALocationSummary> locationSelected;
private final SimpleObjectProperty<TreeItem<CALocationSummary>> locationTree;
private final ObservableList<CATypeRecordIdentifier> itemSelectedTypes;
private final SortedList<CATypeRecordIdentifier> itemSelectedTypesSorted;
private final SimpleObjectProperty<CATypePackageIdentifier> typePackageSelected;

private CAGController(
final CAGClientServiceType inClientService)
Expand All @@ -145,6 +149,11 @@ private CAGController(
this.itemSelectedAttachments =
FXCollections.observableArrayList();

this.itemSelectedTypes =
FXCollections.observableArrayList();
this.itemSelectedTypesSorted =
new SortedList<>(this.itemSelectedTypes);

this.filePages =
new SimpleObjectProperty<>(new CAGPageRange(0L, 0L));
this.files =
Expand All @@ -169,6 +178,8 @@ private CAGController(

this.typePackageTextSelected =
new SimpleStringProperty();
this.typePackageSelected =
new SimpleObjectProperty<CATypePackageIdentifier>();

this.locationSelectedMeta =
FXCollections.observableArrayList();
Expand Down Expand Up @@ -285,6 +296,8 @@ public void itemGet(
.sorted(Comparator.comparing(o -> o.key().fileID()))
.collect(Collectors.toList())
);

this.itemSelectedTypes.setAll(item.types());
});
});
}
Expand All @@ -301,6 +314,12 @@ public ObservableValue<CAItemSummary> itemSelected()
return this.itemSelected;
}

@Override
public SortedList<CATypeRecordIdentifier> itemSelectedTypes()
{
return this.itemSelectedTypesSorted;
}

@Override
public void typePackageGet(
final CATypePackageIdentifier id)
Expand All @@ -312,6 +331,7 @@ public void typePackageGet(
final String formatted = formatXML(response.data());

Platform.runLater(() -> {
this.typePackageSelected.set(id);
this.typePackageTextSelected.set(formatted);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.io7m.cardant.model.CAItemSearchParameters;
import com.io7m.cardant.model.CAItemSummary;
import com.io7m.cardant.model.CAMetadataType;
import com.io7m.cardant.model.CATypeRecordIdentifier;
import com.io7m.cardant.protocol.inventory.CAICommandItemAttachmentAdd;
import com.io7m.repetoir.core.RPServiceType;
import javafx.beans.value.ObservableValue;
Expand Down Expand Up @@ -102,4 +103,10 @@ void itemAttachmentAdd(
*/

ObservableValue<CAItemSummary> itemSelected();

/**
* @return The currently assigned types
*/

SortedList<CATypeRecordIdentifier> itemSelectedTypes();
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.io7m.cardant.model.CAAttachmentRelations;
import com.io7m.cardant.model.CAItemSummary;
import com.io7m.cardant.model.CAMetadataType;
import com.io7m.cardant.model.CATypeRecordIdentifier;
import com.io7m.lanark.core.RDottedName;
import com.io7m.repetoir.core.RPServiceDirectoryType;
import javafx.application.Platform;
Expand Down Expand Up @@ -65,12 +66,23 @@ public final class CAGMainItemDetailsView
@FXML private TextField nameField;
@FXML private ImageView thumbnail;
@FXML private ProgressBar thumbnailLoading;
@FXML private TableView<CAMetadataType> meta;
@FXML private ListView<CAAttachment> attachments;
@FXML private Button metaAdd;
@FXML private Button metaRemove;
@FXML private Button attachmentAdd;
@FXML private Button attachmentRemove;
@FXML private Button typeAssign;
@FXML private Button typeUnassign;

@FXML private TableView<CATypeRecordIdentifier> types;
@FXML private TableColumn<CATypeRecordIdentifier, String> typesColPkg;
@FXML private TableColumn<CATypeRecordIdentifier, String> typesColType;

@FXML private TableView<CAMetadataType> meta;
@FXML private TableColumn<CAMetadataType, RDottedName> metaColPkg;
@FXML private TableColumn<CAMetadataType, RDottedName> metaColType;
@FXML private TableColumn<CAMetadataType, RDottedName> metaColField;
@FXML private TableColumn<CAMetadataType, String> metaColValue;

/**
* The main item details view.
Expand Down Expand Up @@ -99,48 +111,50 @@ public void initialize(
this.thumbnail.setVisible(false);
this.thumbnailLoading.setVisible(false);

final var tableColumns =
this.meta.getColumns();

final var tablePkgColumn =
(TableColumn<CAMetadataType, RDottedName>) tableColumns.get(0);
final var tableTypeColumn =
(TableColumn<CAMetadataType, RDottedName>) tableColumns.get(1);
final var tableFieldColumn =
(TableColumn<CAMetadataType, RDottedName>) tableColumns.get(2);
final var tableValueColumn =
(TableColumn<CAMetadataType, String>) tableColumns.get(3);

tablePkgColumn.setSortable(true);
tablePkgColumn.setReorderable(false);
tablePkgColumn.setCellValueFactory(
this.typesColPkg.setSortable(true);
this.typesColPkg.setReorderable(false);
this.typesColPkg.setCellValueFactory(
param -> {
return new SimpleStringProperty(param.getValue().packageName().value());
});

this.typesColType.setSortable(true);
this.typesColType.setReorderable(false);
this.typesColType.setCellValueFactory(
param -> {
return new SimpleStringProperty(param.getValue().typeName().value());
});

this.metaColPkg.setSortable(true);
this.metaColPkg.setReorderable(false);
this.metaColPkg.setCellValueFactory(
param -> {
return new SimpleObjectProperty<>(
param.getValue().name().typeName().packageName()
);
});

tableTypeColumn.setSortable(true);
tableTypeColumn.setReorderable(false);
tableTypeColumn.setCellValueFactory(
this.metaColType.setSortable(true);
this.metaColType.setReorderable(false);
this.metaColType.setCellValueFactory(
param -> {
return new SimpleObjectProperty<>(
param.getValue().name().typeName().typeName()
);
});

tableFieldColumn.setSortable(true);
tableFieldColumn.setReorderable(false);
tableFieldColumn.setCellValueFactory(
this.metaColField.setSortable(true);
this.metaColField.setReorderable(false);
this.metaColField.setCellValueFactory(
param -> {
return new SimpleObjectProperty<>(
param.getValue().name().fieldName()
);
});

tableValueColumn.setSortable(true);
tableValueColumn.setReorderable(false);
tableValueColumn.setCellValueFactory(
this.metaColValue.setSortable(true);
this.metaColValue.setReorderable(false);
this.metaColValue.setCellValueFactory(
param -> {
return new SimpleStringProperty(
param.getValue().valueString()
Expand All @@ -151,7 +165,13 @@ public void initialize(
.comparatorProperty()
.bind(this.meta.comparatorProperty());

this.meta.setItems(this.controller.itemSelectedMetadata());
this.meta.setItems(
this.controller.itemSelectedMetadata()
);

this.types.setItems(
this.controller.itemSelectedTypes()
);

this.attachments.setCellFactory(
new CAGItemAttachmentCellFactory(this.strings)
Expand All @@ -169,6 +189,24 @@ public void initialize(
.addListener((ListChangeListener<? super CAAttachment>) c -> {
this.loadThumbnail();
});

this.types.getSelectionModel()
.getSelectedItems()
.addListener((ListChangeListener<? super CATypeRecordIdentifier>)
this::itemTypeSelectionChanged);
}

private void itemTypeSelectionChanged(
final ListChangeListener.Change<? extends CATypeRecordIdentifier> c)
{
this.typeUnassign.setDisable(true);

final var selected = c.getList();
if (selected.isEmpty()) {
return;
}

this.typeUnassign.setDisable(false);
}

private void itemSelectionChanged(
Expand Down Expand Up @@ -288,4 +326,16 @@ private void onItemNameSetSelected()
{

}

@FXML
private void onTypeAssignSelected()
{

}

@FXML
private void onTypeUnassignSelected()
{

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@

package com.io7m.cardant_gui.ui.internal;

import com.io7m.cardant.model.CATypeField;
import com.io7m.cardant.model.CATypeRecordIdentifier;
import com.io7m.repetoir.core.RPServiceDirectoryType;
import javafx.fxml.FXML;
import javafx.scene.control.ListView;
import javafx.scene.control.TextArea;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.net.URL;
import java.util.ResourceBundle;
Expand All @@ -33,14 +34,14 @@
public final class CAGMainTypePackageDetailsView
implements CAGViewType
{
private static final Logger LOG =
LoggerFactory.getLogger(CAGMainTypePackageDetailsView.class);

private final CAGControllerType controller;
private final CAGStringsType strings;

@FXML private TextArea text;

@FXML private ListView<CATypeRecordIdentifier> types;
@FXML private ListView<CATypeField> fields;

/**
* The main type package details view.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public void initialize(

this.typePackageTable.setItems(
this.controller.typePackagesViewSorted());

this.controller.typePackagesViewSorted()
.comparatorProperty()
.bind(this.typePackageTable.comparatorProperty());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ cardant.exact.any=Is anything.
cardant.exact.equalTo=Is equal to:
cardant.exact.notEqualTo=Is not equal to:
cardant.field=Field
cardant.fields=Fields
cardant.file.connect=Connect...
cardant.file.exit=Exit
cardant.fileCreate.description=Description
Expand Down Expand Up @@ -154,6 +155,9 @@ cardant.tooltip.typePackages.packageRemove=Remove the selected type packages.
cardant.type=Type
cardant.typePackages=Type Packages
cardant.types=Types
cardant.tooltip.typeAssign=Assign a type.
cardant.tooltip.typeUnassign=Unassign a type.
cardant.ui.boot=Cardant initialized.
cardant.value=Value
cardant.version=Version
cardant.text=Text
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 4114f79

Please sign in to comment.