begin search method refactoring
This commit is contained in:
parent
4e7bd34b60
commit
bbfe792e9f
@ -29,6 +29,8 @@ public class TableView implements BusListener {
|
|||||||
|
|
||||||
private final Project project;
|
private final Project project;
|
||||||
|
|
||||||
|
private TableModelMapper currentMapper;
|
||||||
|
|
||||||
private JPanel rootPanel;
|
private JPanel rootPanel;
|
||||||
private JPanel containerPanel;
|
private JPanel containerPanel;
|
||||||
|
|
||||||
@ -73,7 +75,7 @@ public class TableView implements BusListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpdateData(@NotNull TranslationData data) {
|
public void onUpdateData(@NotNull TranslationData data) {
|
||||||
table.setModel(new TableModelMapper(data, update ->
|
table.setModel(this.currentMapper = new TableModelMapper(data, update ->
|
||||||
InstanceManager.get(project).processUpdate(update)));
|
InstanceManager.get(project).processUpdate(update)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,7 +89,7 @@ public class TableView implements BusListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (row > -1) { // Matched @scrollTo
|
if (row > -1) { // Matched @key
|
||||||
table.scrollRectToVisible(
|
table.scrollRectToVisible(
|
||||||
new Rectangle(0, (row * table.getRowHeight()) + table.getHeight(), 0, 0));
|
new Rectangle(0, (row * table.getRowHeight()) + table.getHeight(), 0, 0));
|
||||||
}
|
}
|
||||||
@ -96,6 +98,9 @@ public class TableView implements BusListener {
|
|||||||
@Override
|
@Override
|
||||||
public void onSearchQuery(@Nullable String query) {
|
public void onSearchQuery(@Nullable String query) {
|
||||||
// TODO: handle search functionality
|
// TODO: handle search functionality
|
||||||
|
if(this.currentMapper != null) {
|
||||||
|
this.currentMapper.onSearchQuery(query);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public JPanel getRootPanel() {
|
public JPanel getRootPanel() {
|
||||||
|
@ -12,6 +12,7 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import javax.swing.event.TableModelListener;
|
import javax.swing.event.TableModelListener;
|
||||||
import javax.swing.table.TableModel;
|
import javax.swing.table.TableModel;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
@ -19,7 +20,7 @@ import java.util.function.Consumer;
|
|||||||
* Mapping {@link TranslationData} to {@link TableModel}.
|
* Mapping {@link TranslationData} to {@link TableModel}.
|
||||||
* @author marhali
|
* @author marhali
|
||||||
*/
|
*/
|
||||||
public class TableModelMapper implements TableModel {
|
public class TableModelMapper implements TableModel, SearchQueryListener {
|
||||||
|
|
||||||
private final @NotNull TranslationData data;
|
private final @NotNull TranslationData data;
|
||||||
private final @NotNull List<String> locales;
|
private final @NotNull List<String> locales;
|
||||||
@ -27,7 +28,7 @@ public class TableModelMapper implements TableModel {
|
|||||||
|
|
||||||
private final @NotNull Consumer<TranslationUpdate> updater;
|
private final @NotNull Consumer<TranslationUpdate> updater;
|
||||||
|
|
||||||
public TableModelMapper(@NotNull TranslationData data, Consumer<TranslationUpdate> updater) {
|
public TableModelMapper(@NotNull TranslationData data, @NotNull Consumer<TranslationUpdate> updater) {
|
||||||
this.data = data;
|
this.data = data;
|
||||||
this.locales = new ArrayList<>(data.getLocales());
|
this.locales = new ArrayList<>(data.getLocales());
|
||||||
this.fullKeys = new ArrayList<>(data.getFullKeys());
|
this.fullKeys = new ArrayList<>(data.getFullKeys());
|
||||||
@ -35,6 +36,11 @@ public class TableModelMapper implements TableModel {
|
|||||||
this.updater = updater;
|
this.updater = updater;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSearchQuery(@Nullable String query) {
|
||||||
|
this.fullKeys = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRowCount() {
|
public int getRowCount() {
|
||||||
return this.fullKeys.size();
|
return this.fullKeys.size();
|
||||||
|
@ -7,7 +7,7 @@ action.add=Add Translation
|
|||||||
action.edit=Edit Translation
|
action.edit=Edit Translation
|
||||||
action.reload=Reload From Disk
|
action.reload=Reload From Disk
|
||||||
action.settings=Settings
|
action.settings=Settings
|
||||||
action.search=Search Key...
|
action.search=Search...
|
||||||
action.delete=Delete
|
action.delete=Delete
|
||||||
translation.key=Key
|
translation.key=Key
|
||||||
translation.locales=Locales
|
translation.locales=Locales
|
||||||
|
Loading…
x
Reference in New Issue
Block a user