Skip to content

Commit

Permalink
fix update i18n error.
Browse files Browse the repository at this point in the history
  • Loading branch information
GitHubNull committed Jun 11, 2023
1 parent 8b98e4d commit dc80db3
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
20 changes: 18 additions & 2 deletions src/main/java/models/CommandLineTableModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@
import java.util.ArrayList;
import java.util.List;

import static utils.GlobalStaticVariables.COMMANDLINE_TABLE_MODEL_COLUMNS_NAME;
import static utils.GlobalStaticVariables.EX_MSG;

public class CommandLineTableModel extends AbstractTableModel {
List<OptionsCommandLine> optionsCommandLineList = new ArrayList<>();
static final int STATIC_COLUMN_COUNT = 4;

private static String[] commandlineColumnsName = new String[]{EX_MSG.getMsg("index"),
EX_MSG.getMsg("wasDefault"), EX_MSG.getMsg("tag"),
EX_MSG.getMsg("commandLine")};

public void setScanTaskArgsList(List<OptionsCommandLine> optionsCommandLineList) {
this.optionsCommandLineList = optionsCommandLineList;
}
Expand Down Expand Up @@ -55,7 +59,7 @@ public String getColumnName(int column) {
return null;
}

return COMMANDLINE_TABLE_MODEL_COLUMNS_NAME[column];
return commandlineColumnsName[column];
}

@Override
Expand Down Expand Up @@ -201,4 +205,16 @@ public boolean isTagExist(String tagStr) {
}


public void updateI18n() {
commandlineColumnsName = new String[]{
EX_MSG.getMsg("index"),
EX_MSG.getMsg("wasDefault"),
EX_MSG.getMsg("tag"),
EX_MSG.getMsg("commandLine")};

SwingUtilities.invokeLater(() -> {
fireTableStructureChanged();
});
}

}
17 changes: 10 additions & 7 deletions src/main/java/ui/panel/subPanel/CommandLineManagerPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,15 @@ public void mouseClicked(MouseEvent e) {
}


if (null == optionsCommandLine0) {
return;
}

Boolean tmp = optionsCommandLine0.getWasDefault();
if (null == tmp) {
return;
}

if (Boolean.FALSE.equals(optionsCommandLine0.getWasDefault())) {
int cnt = 0;
for (int i = 0; i < tableModel.getRowCount(); i++) {
Expand Down Expand Up @@ -403,13 +412,7 @@ private void actionPerformed(ActionEvent e) {

public void updateI18n(MessageUtil messageUtil) {
// todo reset table columns name or we say headers name
GlobalStaticVariables.COMMANDLINE_TABLE_MODEL_COLUMNS_NAME = new String[]{EX_MSG.getMsg("index"),
EX_MSG.getMsg("wasDefault"), EX_MSG.getMsg("tag"),
EX_MSG.getMsg("commandLine")};

SwingUtilities.invokeLater(() -> {
tableModel.fireTableStructureChanged();
});
tableModel.updateI18n();


tagLabel.setText(messageUtil.getMsg("tag"));
Expand Down
6 changes: 1 addition & 5 deletions src/main/java/utils/GlobalStaticVariables.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,14 @@ public class GlobalStaticVariables {
public static String DEFAULT_COMMAND_LINE_STR = "-threads 5"; // default_command_line_str
public static MessageUtil EX_MSG = new MessageUtil();

public static String[] COMMANDLINE_TABLE_MODEL_COLUMNS_NAME = new String[]{EX_MSG.getMsg("index"),
EX_MSG.getMsg("wasDefault"), EX_MSG.getMsg("tag"),
EX_MSG.getMsg("commandLine")};

static {
STR_TO_SCAN_TASK_STATUS_MAP.put("not running", ScanTaskStatus.NOT_STARTED);
STR_TO_SCAN_TASK_STATUS_MAP.put("running", ScanTaskStatus.RUNNING);
STR_TO_SCAN_TASK_STATUS_MAP.put("terminated", ScanTaskStatus.FINISHED);

STR_TO_SCAN_TASK_STATUS_MAP.put("stopped", ScanTaskStatus.STOPPED);
STR_TO_SCAN_TASK_STATUS_MAP.put("killed", ScanTaskStatus.KILLED);
STR_TO_SCAN_TASK_STATUS_MAP.put("unkonwError", ScanTaskStatus.ERROR);
STR_TO_SCAN_TASK_STATUS_MAP.put("unknownError", ScanTaskStatus.ERROR);

// SCAN_OPTIONS = new Options();

Expand Down

0 comments on commit dc80db3

Please sign in to comment.