Skip to content

Commit

Permalink
CSVTable UTF-8 CSV now required
Browse files Browse the repository at this point in the history
  • Loading branch information
JuicyDragon committed Jun 18, 2024
1 parent 0351ee9 commit 6c65ee2
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 5 deletions.
24 changes: 24 additions & 0 deletions Examples/CsvTableTestUTF8.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Bootstrap the library
require_relative "NxBootstrap.rb"

# ==================================================
# Example of CSVTable control in TabbedCustom Dialog
# ==================================================

# Create tabbed dialog and tab
dialog = TabbedCustomDialog.new("CSV Table")
main_tab = dialog.addTab("main_tab","Main")

# Add CSV table (table which can import CSV)
main_tab.appendCsvTable("csv_data",["English","Spanish","Chinese","Japanese"])

# Display dialog
dialog.display

# Display what was in the table
dialog.toMap["csv_data"].each_with_index do |record,record_index|
puts "Record #{record_index}"
record.each do |k,v|
puts "#{k} => #{v}"
end
end
16 changes: 14 additions & 2 deletions Examples/TabbedCustomDialog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
# dialog in your script
# ==========================================================================

case_directory ||= "FALLBACK_VALUE"
case_directory = java.io.File.new(File.join(File.dirname(__FILE__),"TestCase_#{Time.now.to_i}"))
if case_directory.exists
case_directory.delete
end

# Open a test case, change this to a case on your system
# Open a test case
$current_case = $utilities.getCaseFactory.create(case_directory,{})

# Tell the library what the current case is
Expand Down Expand Up @@ -111,6 +114,15 @@
choice_table_tab = dialog.addTab("choice_table_tab","Choice Table")
choice_table_tab.appendStringChoiceTable("choices001","Tags",$current_case.getAllTags)

# ===============================
# Add a tab and test choice table
# ===============================
string_list_tab = dialog.addTab("string_list_tab","String List Table")
string_list_tab.appendStringList("string_list_001")
string_list_tab.appendStringList("string_list_002", true)
string_list_tab.appendStringList("string_list_003",["Alpha","Beta","Gamma"])
string_list_tab.appendStringList("string_list_004",["Alpha","Beta","Gamma"],true)

# =========
# CSV Table
# =========
Expand Down
8 changes: 8 additions & 0 deletions Examples/Utf8Sample.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
English,Spanish,Chinese,Japanese
I asked for no sardines on my pizza,No pedí sardinas en mi pizza.,"我要求披萨上不要放沙丁鱼
Wǒ yāoqiú pīsà shàng bùyào fàng shādīngyú","ピザにはイワシは入れないと頼んだ
Piza ni wa iwashi wa hairenai to tanonda"
Yes that bike is imbued with the light house keeper's dreams.,"Sí, esa bicicleta está imbuida de los sueños del farero.","是的,这辆自行车充满了灯塔守护者的梦想。
Shì de, zhè liàng zìxíngchē chōngmǎnle dēngtǎ shǒuhù zhě de mèngxiǎng.","
そう、その自転車には灯台守の夢が込められているのです。
Sō, sono jitensha ni wa tōdaimori no yume ga kome rarete iru nodesu."
2 changes: 1 addition & 1 deletion Nx/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ if (versionProperty == "unspecified") {
}

group = findProperty("group") ?: "com.nuix.nx"
version = versionProperty ?: "1.19.0"
version = versionProperty ?: "1.20.0"

val sourceCompatibility = findProperty("targetJreVersion") ?: 11
val targetCompatibility = findProperty("targetJreVersion") ?: 11
Expand Down
5 changes: 3 additions & 2 deletions Nx/src/main/java/com/nuix/nx/controls/CsvTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.*;

Expand Down Expand Up @@ -106,7 +107,7 @@ public void actionPerformed(ActionEvent arg0) {
add(scrollPane, gbc_scrollPane);

recordsTable = new JTable(recordsTableModel);
recordsTable.setFont(new Font("Consolas", Font.PLAIN, 14));
recordsTable.setFont(new Font("Arial MS Unicode", Font.PLAIN, 14));
recordsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
recordsTable.setFillsViewportHeight(true);
scrollPane.setViewportView(recordsTable);
Expand All @@ -118,7 +119,7 @@ public void actionPerformed(ActionEvent arg0) {
}

private void importCsv(File csvFile) {
try (BufferedReader br = new BufferedReader(new FileReader(csvFile))) {
try (BufferedReader br = new BufferedReader(new FileReader(csvFile, StandardCharsets.UTF_8))) {
CSVFormat csvFormat = CSVFormat.EXCEL.builder()
.setSkipHeaderRecord(false)
.build();
Expand Down

0 comments on commit 6c65ee2

Please sign in to comment.