Skip to content

Commit

Permalink
Application: Rename "Packfile view mode" -> "Archive view mode"
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadelessFox committed Jun 29, 2024
1 parent a09d10f commit 83343fe
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.shade.decima.ui.navigator;

import com.google.gson.annotations.SerializedName;
import com.shade.platform.model.Service;
import com.shade.platform.model.app.ApplicationManager;
import com.shade.platform.model.persistence.PersistableComponent;
Expand All @@ -11,14 +12,14 @@
@Service(NavigatorSettings.class)
@Persistent("NavigatorSettings")
public class NavigatorSettings implements PersistableComponent<NavigatorSettings> {
public enum PackfileView {
public enum ArchiveView {
DEFAULT("Default"),
GROUPED("Grouped"),
MERGED("Merged");

private final String label;

PackfileView(@NotNull String label) {
ArchiveView(@NotNull String label) {
this.label = label;
}

Expand All @@ -45,7 +46,8 @@ public String toString() {
}
}

public PackfileView packfileView = PackfileView.DEFAULT;
@SerializedName(value = "archiveView", alternate = "packfileView")
public ArchiveView archiveView = ArchiveView.DEFAULT;
public DirectoryView directoryView = DirectoryView.COMPACT;

@NotNull
Expand All @@ -61,7 +63,7 @@ public NavigatorSettings getState() {

@Override
public void loadState(@NotNull NavigatorSettings state) {
packfileView = state.packfileView;
archiveView = state.archiveView;
directoryView = state.directoryView;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

@SettingsPageRegistration(id = "navigator", name = "Navigator")
public class NavigatorSettingsPage implements SettingsPage {
private JComboBox<NavigatorSettings.PackfileView> packfileViewCombo;
private JComboBox<NavigatorSettings.ArchiveView> archiveViewCombo;
private JComboBox<NavigatorSettings.DirectoryView> directoryViewCombo;

@NotNull
Expand All @@ -25,8 +25,8 @@ public JComponent createComponent(@NotNull PropertyChangeListener listener) {
panel.setBorder(new LabeledBorder("Structure"));
panel.setLayout(new MigLayout("ins panel,wrap", "[fill][]"));

panel.add(new JLabel("Packfile view mode:"));
panel.add(packfileViewCombo = new JComboBox<>(NavigatorSettings.PackfileView.values()), "split 2");
panel.add(new JLabel("Archive view mode:"));
panel.add(archiveViewCombo = new JComboBox<>(NavigatorSettings.ArchiveView.values()), "split 2");
panel.add(UIUtils.createHelpToolTip("""
<html>
Depending on the choice, archives will be shown differently:<br>
Expand All @@ -49,7 +49,7 @@ public JComponent createComponent(@NotNull PropertyChangeListener listener) {

// FIXME Not fancy
final ItemListener adapter = e -> listener.propertyChange(new PropertyChangeEvent(this, InputValidator.PROPERTY_VALIDATION, null, null));
packfileViewCombo.addItemListener(adapter);
archiveViewCombo.addItemListener(adapter);
directoryViewCombo.addItemListener(adapter);

return panel;
Expand All @@ -58,21 +58,21 @@ public JComponent createComponent(@NotNull PropertyChangeListener listener) {
@Override
public void apply() {
final NavigatorSettings settings = NavigatorSettings.getInstance();
settings.packfileView = packfileViewCombo.getItemAt(packfileViewCombo.getSelectedIndex());
settings.archiveView = archiveViewCombo.getItemAt(archiveViewCombo.getSelectedIndex());
settings.directoryView = directoryViewCombo.getItemAt(directoryViewCombo.getSelectedIndex());
}

@Override
public void reset() {
final NavigatorSettings settings = NavigatorSettings.getInstance();
packfileViewCombo.setSelectedItem(settings.packfileView);
archiveViewCombo.setSelectedItem(settings.archiveView);
directoryViewCombo.setSelectedItem(settings.directoryView);
}

@Override
public boolean isModified() {
final NavigatorSettings settings = NavigatorSettings.getInstance();
return settings.packfileView != packfileViewCombo.getItemAt(packfileViewCombo.getSelectedIndex())
return settings.archiveView != archiveViewCombo.getItemAt(archiveViewCombo.getSelectedIndex())
|| settings.directoryView != directoryViewCombo.getItemAt(directoryViewCombo.getSelectedIndex());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public String getDescription() {
protected NavigatorNode[] loadChildren(@NotNull ProgressMonitor monitor) throws Exception {
open();

return switch (getPackfileView()) {
return switch (getArchiveView()) {
case GROUPED -> loadGroupedChildren(monitor);
case MERGED -> loadMergedChildren(monitor);
case DEFAULT -> loadDefaultChildren(monitor);
Expand Down Expand Up @@ -149,8 +149,8 @@ public Icon getIcon() {
}

@NotNull
public NavigatorSettings.PackfileView getPackfileView() {
return settings.packfileView;
public NavigatorSettings.ArchiveView getArchiveView() {
return settings.archiveView;
}

@NotNull
Expand Down

0 comments on commit 83343fe

Please sign in to comment.