Repository navigation
Expand file tree
/
Copy pathExportDialog.java
More file actions
1144 lines (1085 loc) · 56.2 KB
/
Copy pathExportDialog.java
File metadata and controls
1144 lines (1085 loc) · 56.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright 2023-2026 Fred Feng
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.sqljam.face.view;
import java.io.File;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import com.github.sqljam.face.model.ConnectionProfile;
import com.github.sqljam.face.model.TableInfo;
import com.github.sqljam.face.model.TransferRequest;
import com.github.sqljam.face.service.DatabaseSession;
import com.github.sqljam.impexp.DataFileStrategy;
import com.github.sqljam.impexp.CsvExporter;
import com.github.sqljam.impexp.CsvOptions;
import com.github.sqljam.impexp.DuckDBWorkspace;
import com.github.sqljam.impexp.DataFormat;
import com.github.sqljam.impexp.DbType;
import com.github.sqljam.impexp.Dialect;
import com.github.sqljam.impexp.ExportMode;
import com.github.sqljam.impexp.Exporter;
import com.github.sqljam.impexp.IdentifierCase;
import com.github.sqljam.impexp.ParquetExporter;
import com.github.sqljam.impexp.TableQuery;
import com.github.sqljam.impexp.WriteMode;
import javafx.beans.InvalidationListener;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.collections.transformation.FilteredList;
import javafx.event.ActionEvent;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonType;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Dialog;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.control.RadioButton;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.Spinner;
import javafx.scene.control.SpinnerValueFactory;
import javafx.scene.control.TextField;
import javafx.scene.control.ToggleGroup;
import javafx.scene.control.Tooltip;
import javafx.scene.control.cell.CheckBoxListCell;
import javafx.scene.layout.ColumnConstraints;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
import javafx.stage.DirectoryChooser;
import javafx.stage.Window;
import javafx.util.StringConverter;
/**
* @Description: ExportDialog collects an export to sql scripts or an import into another database
* @Author: Fred Feng
* @Date: 26/03/2023
* @Version 1.0.0
*/
public class ExportDialog extends Dialog<TransferRequest> {
private static final long MB = 1024L * 1024L;
/**
* Default name of the table of a free query
*/
static final String DEFAULT_QUERY_TABLE = "query_result";
private static final Map<DbType, List<String>> VERSION_PRESETS = new EnumMap<>(DbType.class);
static {
VERSION_PRESETS.put(DbType.MYSQL, List.of("", "5.6", "5.7", "8.0"));
VERSION_PRESETS.put(DbType.MARIADB, List.of("", "10.6", "10.11", "11.4", "11.8"));
VERSION_PRESETS.put(DbType.POSTGRESQL, List.of("", "9.6", "10", "12", "16"));
VERSION_PRESETS.put(DbType.ORACLE, List.of("", "11.2", "12.1", "19", "23"));
VERSION_PRESETS.put(DbType.SQLSERVER, List.of("", "2008", "2012", "2016", "2019", "2022"));
VERSION_PRESETS.put(DbType.DB2, List.of("", "11.1", "11.5", "12.1"));
VERSION_PRESETS.put(DbType.H2, List.of("", "2.2"));
VERSION_PRESETS.put(DbType.SQLITE, List.of("", "3"));
// Access 2007, 2010 and 2016
VERSION_PRESETS.put(DbType.ACCESS, List.of("", "12", "14", "16"));
}
private final AppContext context;
// Source
private final ComboBox<ConnectionProfile> sourceCombo = new ComboBox<>();
private final ComboBox<String> catalogCombo = new ComboBox<>();
private final ComboBox<String> schemaCombo = new ComboBox<>();
private final ObservableList<TableChoice> tableChoices = FXCollections.observableArrayList();
private final FilteredList<TableChoice> filteredChoices = new FilteredList<>(tableChoices, choice -> true);
private final ListView<TableChoice> tableList = new ListView<>(filteredChoices);
private final Label tableCountLabel = new Label();
// Content and options
private final ToggleGroup modeGroup = new ToggleGroup();
private final CheckBox recreateCheck = new CheckBox(Messages.get("export.option.recreate"));
private final CheckBox idReusedCheck = new CheckBox(Messages.get("export.option.idReused"));
private final CheckBox indexCheck = new CheckBox(Messages.get("export.option.indexes"));
private final CheckBox foreignKeyCheck = new CheckBox(Messages.get("export.option.foreignKeys"));
private final CheckBox commentCheck = new CheckBox(Messages.get("export.option.comments"));
private final CheckBox sequenceCheck = new CheckBox(Messages.get("export.option.sequences"));
private final CheckBox failFastCheck = new CheckBox(Messages.get("export.option.failFast"));
private final Spinner<Integer> pageSizeSpinner = new Spinner<>(10, 100000, Exporter.DEFAULT_PAGE_SIZE, 500);
private final ComboBox<IdentifierCase> identifierCaseCombo = new ComboBox<>();
// Target
private final ToggleGroup targetGroup = new ToggleGroup();
private final RadioButton scriptRadio = new RadioButton(Messages.get("export.target.script"));
private final RadioButton databaseRadio = new RadioButton(Messages.get("export.target.database"));
private final TextField directoryField = new TextField();
private final ComboBox<DbType> scriptDbTypeCombo = new ComboBox<>();
private final ComboBox<String> scriptVersionCombo = new ComboBox<>();
private final TextField scriptSchemaField = new TextField();
private final ToggleGroup strategyGroup = new ToggleGroup();
private final RadioButton singleFileRadio = new RadioButton(Messages.get("export.script.singleFile"));
private final RadioButton perTableRadio = new RadioButton(Messages.get("export.script.perTable"));
private final Spinner<Integer> maxFileSizeSpinner = new Spinner<>(0, 100000, 10, 10);
private final CheckBox lobSeparatedCheck = new CheckBox(Messages.get("export.script.lobSeparated"));
private final ToggleGroup formatGroup = new ToggleGroup();
private final RadioButton sqlFormatRadio = new RadioButton(Messages.get("export.format.sql"));
private final RadioButton parquetFormatRadio = new RadioButton(Messages.get("export.format.parquet"));
private final RadioButton csvFormatRadio = new RadioButton(Messages.get("export.format.csv"));
private final ComboBox<String> compressionCombo = new ComboBox<>();
private CsvOptionsPane csvOptionsPane;
private TransactionOption transactionOption;
private final RadioButton insertRadio = new RadioButton(Messages.get("export.writeMode.insert"));
private final RadioButton upsertRadio = new RadioButton(Messages.get("export.writeMode.upsert"));
private final RadioButton skipExistingRadio = new RadioButton(Messages.get("export.writeMode.skip"));
private final Button keyColumnsButton = new Button(Messages.get("export.writeMode.keys"));
/**
* Chosen key columns of upserts by table, the primary key of the other tables
*/
private Map<String, List<String>> keyColumnNames = new HashMap<>();
/**
* Max file size of the shown format in MB: sql scripts and CSV files share one, Parquet has its own
*/
private long textMaxFileSize;
private long parquetMaxFileSize;
private final Label layoutHint = new Label();
private final ComboBox<ConnectionProfile> targetCombo = new ComboBox<>();
private final ComboBox<String> targetCatalogCombo = new ComboBox<>();
private final ComboBox<String> targetSchemaCombo = new ComboBox<>();
private final TextField tableNamePatternField = new TextField();
private final Label queryLabel = new Label();
private TableQuery tableQuery;
private String queryTableName;
/**
* SQL of a free query exported as a table (the SQL editor), null for tables of the schema
*/
private final String freeQuery;
private final DbNode queryNode;
private final TextField queryTableField = new TextField(DEFAULT_QUERY_TABLE);
private VBox tablesBox;
private Label tableNamePatternLabel;
private final CheckBox createSchemaCheck = new CheckBox(Messages.get("export.database.createSchema"));
private final Label errorLabel = new Label();
private Button startButton;
/**
* Table of the checklist
*/
private static class TableChoice {
private final TableInfo table;
private final BooleanProperty selected = new SimpleBooleanProperty();
TableChoice(TableInfo table, boolean selected) {
this.table = table;
this.selected.set(selected);
}
}
public ExportDialog(Window owner, AppContext context, DbNode node) {
this(owner, context, node, null);
}
/**
* Export of a table narrowed by a query of the data viewer: selected columns, condition and order
*/
public ExportDialog(Window owner, AppContext context, DbNode node, TableQuery query) {
this(owner, context, node, query, null);
}
/**
* Export of the rows of a free query as a table of the given name, e.g. of the SQL editor. The source is the
* data source, catalog and schema of the node.
*/
public static ExportDialog forQuery(Window owner, AppContext context, DbNode node, String sql) {
return new ExportDialog(owner, context, node, null, sql);
}
private ExportDialog(Window owner, AppContext context, DbNode node, TableQuery query, String sql) {
this.context = context;
this.freeQuery = StringUtils.trimToNull(sql);
this.queryNode = freeQuery != null ? node : null;
this.tableQuery = query != null && !query.isEmpty() && node != null && node.getTable() != null ? query : null;
this.queryTableName = tableQuery != null ? node.getTable().getName() : null;
Dialogs.initOwner(this, owner);
Branding.applyIcons(this);
setTitle(Messages.get("export.title"));
setHeaderText(Messages.get("export.header"));
setResizable(true);
sourceCombo.setId("sourceCombo");
catalogCombo.setId("catalogCombo");
schemaCombo.setId("schemaCombo");
tableList.setId("tableList");
tableCountLabel.setId("tableCountLabel");
pageSizeSpinner.setId("pageSizeSpinner");
identifierCaseCombo.setId("identifierCaseCombo");
scriptRadio.setId("scriptRadio");
databaseRadio.setId("databaseRadio");
directoryField.setId("directoryField");
scriptDbTypeCombo.setId("scriptDbTypeCombo");
scriptVersionCombo.setId("scriptVersionCombo");
scriptSchemaField.setId("scriptSchemaField");
singleFileRadio.setId("singleFileRadio");
perTableRadio.setId("perTableRadio");
maxFileSizeSpinner.setId("maxFileSizeSpinner");
lobSeparatedCheck.setId("lobSeparatedCheck");
sqlFormatRadio.setId("sqlFormatRadio");
parquetFormatRadio.setId("parquetFormatRadio");
compressionCombo.setId("compressionCombo");
csvFormatRadio.setId("csvFormatRadio");
layoutHint.setId("layoutHint");
targetCombo.setId("targetCombo");
targetCatalogCombo.setId("targetCatalogCombo");
targetSchemaCombo.setId("targetSchemaCombo");
tableNamePatternField.setId("tableNamePatternField");
createSchemaCheck.setId("createSchemaCheck");
errorLabel.setId("errorLabel");
recreateCheck.setId("recreateCheck");
idReusedCheck.setId("idReusedCheck");
indexCheck.setId("indexCheck");
foreignKeyCheck.setId("foreignKeyCheck");
commentCheck.setId("commentCheck");
sequenceCheck.setId("sequenceCheck");
failFastCheck.setId("failFastCheck");
VBox content = new VBox(16, section("export.section.source", createSourcePane()),
section("export.section.content", createContentPane()),
section("export.section.options", createOptionsPane()),
section("export.section.target", createTargetPane()));
content.setPadding(new Insets(4, 8, 4, 4));
errorLabel.getStyleClass().add("status-error");
errorLabel.setWrapText(true);
ScrollPane scrollPane = new ScrollPane(content);
scrollPane.setFitToWidth(true);
scrollPane.setPrefSize(760, 660);
VBox root = new VBox(8, scrollPane, errorLabel);
VBox.setVgrow(scrollPane, Priority.ALWAYS);
getDialogPane().setContent(root);
getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
startButton = (Button) getDialogPane().lookupButton(ButtonType.OK);
startButton.setId("startButton");
startButton.setText(Messages.get("export.start"));
startButton.setGraphic(Icons.of(Icons.START));
startButton.addEventFilter(ActionEvent.ACTION, event -> {
String error = validate();
if (error != null) {
errorLabel.setText(error);
event.consume();
}
});
setResultConverter(buttonType -> buttonType == ButtonType.OK ? buildRequest() : null);
registerValidation();
targetGroup.selectedToggleProperty().addListener((obs, oldToggle, toggle) -> updateWriteModes());
targetCombo.valueProperty().addListener((obs, oldProfile, profile) -> updateWriteModes());
scriptDbTypeCombo.valueProperty().addListener((obs, oldType, type) -> updateWriteModes());
preselect(node);
if (freeQuery != null) {
applyQueryMode();
}
if (tableQuery != null) {
queryLabel.setText(Messages.format("export.query", queryTableName, tableQuery));
queryLabel.setVisible(true);
queryLabel.setManaged(true);
}
updateValidation();
}
/**
* Start is enabled only when the inputs are valid, the reason is shown below the form
*/
private void registerValidation() {
InvalidationListener listener = observable -> updateValidation();
sourceCombo.valueProperty().addListener(listener);
targetGroup.selectedToggleProperty().addListener(listener);
directoryField.textProperty().addListener(listener);
targetCombo.valueProperty().addListener(listener);
targetCatalogCombo.valueProperty().addListener(listener);
targetSchemaCombo.valueProperty().addListener(listener);
targetSchemaCombo.getEditor().textProperty().addListener(listener);
tableNamePatternField.textProperty().addListener(listener);
catalogCombo.valueProperty().addListener(listener);
schemaCombo.valueProperty().addListener(listener);
scriptVersionCombo.getEditor().textProperty().addListener(listener);
scriptVersionCombo.valueProperty().addListener(listener);
pageSizeSpinner.getEditor().textProperty().addListener(listener);
maxFileSizeSpinner.getEditor().textProperty().addListener(listener);
tableChoices.addListener(listener);
}
void updateValidation() {
String error = validate();
errorLabel.setText(StringUtils.defaultString(error));
startButton.setDisable(error != null);
}
private static Node section(String key, Node body) {
Label title = new Label(Messages.get(key));
title.getStyleClass().add("section-title");
VBox box = new VBox(8, title, body);
box.getStyleClass().add("form-section");
return box;
}
private static GridPane grid() {
GridPane grid = new GridPane();
grid.setHgap(10);
grid.setVgap(8);
ColumnConstraints labelColumn = new ColumnConstraints();
labelColumn.setMinWidth(150);
ColumnConstraints fieldColumn = new ColumnConstraints();
fieldColumn.setHgrow(Priority.ALWAYS);
grid.getColumnConstraints().addAll(labelColumn, fieldColumn);
return grid;
}
private Node createSourcePane() {
DbTypeCells.setupProfileCombo(sourceCombo);
sourceCombo.getItems().setAll(context.getProfileRegistry().getProfiles());
sourceCombo.setMaxWidth(Double.MAX_VALUE);
catalogCombo.setMaxWidth(Double.MAX_VALUE);
schemaCombo.setMaxWidth(Double.MAX_VALUE);
sourceCombo.valueProperty().addListener((obs, oldProfile, profile) -> loadCatalogs(profile, null, null,
null));
catalogCombo.valueProperty().addListener((obs, oldCatalog, catalog) -> {
if (catalog != null && !catalogCombo.isDisabled()) {
loadSchemas(catalog, null, null);
}
});
schemaCombo.valueProperty().addListener((obs, oldSchema, schema) -> {
if (schema != null) {
loadTables(catalogCombo.getValue(), schema, null);
}
});
TextField filterField = new TextField();
filterField.setPromptText(Messages.get("export.tables.filter"));
filterField.textProperty().addListener((obs, oldText, text) -> filteredChoices.setPredicate(choice ->
StringUtils.isBlank(text) || StringUtils.containsIgnoreCase(choice.table.getName(), text)));
filterField.setId("tableFilterField");
Button allButton = new Button(Messages.get("export.tables.all"));
allButton.setId("selectAllButton");
allButton.setOnAction(event -> filteredChoices.forEach(choice -> choice.selected.set(true)));
Button noneButton = new Button(Messages.get("export.tables.none"));
noneButton.setId("selectNoneButton");
noneButton.setOnAction(event -> filteredChoices.forEach(choice -> choice.selected.set(false)));
HBox filterBox = new HBox(8, filterField, allButton, noneButton, tableCountLabel);
filterBox.setAlignment(Pos.CENTER_LEFT);
HBox.setHgrow(filterField, Priority.ALWAYS);
StringConverter<TableChoice> names = new StringConverter<>() {
@Override
public String toString(TableChoice choice) {
return choice != null ? choice.table.getName() : "";
}
@Override
public TableChoice fromString(String text) {
return null;
}
};
tableList.setCellFactory(view -> new CheckBoxListCell<>(choice -> choice.selected, names) {
@Override
public void updateItem(TableChoice choice, boolean empty) {
super.updateItem(choice, empty);
Label badge = empty || choice == null ? null : ConnectionTree.partitionBadge(choice.table);
// Partitioned tables show the badge of their partitioning after the name, like the tree
if (badge != null) {
HBox graphic = new HBox(6, getGraphic(), ConnectionTree.tableIcon(choice.table),
new Label(choice.table.getName()), badge);
graphic.setAlignment(Pos.CENTER_LEFT);
setGraphic(graphic);
setText(null);
}
}
});
tableList.setPrefHeight(200);
tableList.setPlaceholder(new Label(Messages.get("export.tables.empty")));
GridPane grid = grid();
grid.addRow(0, new Label(Messages.get("export.source.connection")), sourceCombo);
grid.addRow(1, new Label(Messages.get("export.source.catalog")), catalogCombo);
grid.addRow(2, new Label(Messages.get("export.source.schema")), schemaCombo);
tablesBox = new VBox(8, new Label(Messages.get("export.tables.hint")), filterBox, tableList);
VBox box = new VBox(8, grid, tablesBox);
// Rows of the table narrowed in the data viewer
queryLabel.setId("queryLabel");
queryLabel.getStyleClass().add("muted");
queryLabel.setWrapText(true);
queryLabel.setVisible(false);
queryLabel.setManaged(false);
box.getChildren().add(queryLabel);
return box;
}
private Node createContentPane() {
RadioButton ddlRadio = new RadioButton(Messages.get("export.mode.ddl"));
ddlRadio.setUserData(ExportMode.DDL);
RadioButton ddlDataRadio = new RadioButton(Messages.get("export.mode.ddlData"));
ddlDataRadio.setUserData(ExportMode.DDL_DATA);
RadioButton dataRadio = new RadioButton(Messages.get("export.mode.data"));
dataRadio.setUserData(ExportMode.DATA);
ddlRadio.setId("ddlRadio");
ddlDataRadio.setId("ddlDataRadio");
dataRadio.setId("dataRadio");
ddlRadio.setToggleGroup(modeGroup);
ddlDataRadio.setToggleGroup(modeGroup);
dataRadio.setToggleGroup(modeGroup);
ddlDataRadio.setSelected(true);
return new HBox(16, ddlRadio, ddlDataRadio, dataRadio);
}
private Node createOptionsPane() {
recreateCheck.setSelected(true);
idReusedCheck.setSelected(true);
indexCheck.setSelected(true);
foreignKeyCheck.setSelected(true);
commentCheck.setSelected(true);
sequenceCheck.setSelected(true);
failFastCheck.setSelected(true);
pageSizeSpinner.setEditable(true);
pageSizeSpinner.getValueFactory().setValue(Math.max(10, context.getSettings().getTransferPageSize()));
identifierCaseCombo.getItems().addAll(IdentifierCase.values());
identifierCaseCombo.setValue(IdentifierCase.AUTO);
identifierCaseCombo.setConverter(new StringConverter<>() {
@Override
public String toString(IdentifierCase value) {
return value != null ? Messages.get("identifierCase." + value.name()) : "";
}
@Override
public IdentifierCase fromString(String text) {
return null;
}
});
GridPane checks = new GridPane();
checks.setHgap(24);
checks.setVgap(8);
checks.addRow(0, recreateCheck, idReusedCheck, indexCheck);
checks.addRow(1, foreignKeyCheck, commentCheck, sequenceCheck);
checks.addRow(2, failFastCheck);
GridPane grid = grid();
grid.addRow(0, new Label(Messages.get("export.option.pageSize")), pageSizeSpinner);
insertRadio.setId("insertRadio");
upsertRadio.setId("upsertRadio");
skipExistingRadio.setId("skipExistingRadio");
keyColumnsButton.setId("keyColumnsButton");
ToggleGroup writeModeGroup = new ToggleGroup();
insertRadio.setToggleGroup(writeModeGroup);
upsertRadio.setToggleGroup(writeModeGroup);
skipExistingRadio.setToggleGroup(writeModeGroup);
insertRadio.setSelected(true);
keyColumnsButton.disableProperty().bind(insertRadio.selectedProperty());
keyColumnsButton.setOnAction(event -> chooseKeyColumns());
insertRadio.selectedProperty().addListener((obs, oldValue, insert) -> {
// Rows of kept tables are matched by key, tables are not dropped
if (!insert) {
recreateCheck.setSelected(false);
}
recreateCheck.setDisable(!insert);
});
// Wraps in narrow windows
FlowPane writeModeBox = new FlowPane(16, 6, insertRadio, upsertRadio, skipExistingRadio, keyColumnsButton);
writeModeBox.setAlignment(Pos.CENTER_LEFT);
grid.addRow(1, new Label(Messages.get("export.option.identifierCase")), identifierCaseCombo);
grid.addRow(2, new Label(Messages.get("export.writeMode")), writeModeBox);
return new VBox(12, checks, grid);
}
private Node createTargetPane() {
scriptRadio.setToggleGroup(targetGroup);
databaseRadio.setToggleGroup(targetGroup);
scriptRadio.setSelected(true);
// Script target
String lastDirectory = context.getSettings().getLastExportDirectory();
directoryField.setText(StringUtils.defaultString(lastDirectory));
directoryField.setPromptText(Messages.get("export.script.directory.prompt"));
Button browseButton = new Button(null, Icons.of(Icons.FOLDER));
browseButton.setOnAction(event -> chooseDirectory());
HBox directoryBox = new HBox(8, directoryField, browseButton);
HBox.setHgrow(directoryField, Priority.ALWAYS);
scriptDbTypeCombo.getItems().addAll(DbTypeCells.getDbTypesByCategory());
DbTypeCells.setupDbTypeCombo(scriptDbTypeCombo);
scriptDbTypeCombo.valueProperty().addListener((obs, oldType, type) -> {
scriptVersionCombo.getItems().setAll(VERSION_PRESETS.getOrDefault(type, List.of("")));
scriptVersionCombo.setValue("");
});
scriptVersionCombo.setEditable(true);
scriptVersionCombo.setPromptText(Messages.get("export.script.version.prompt"));
scriptSchemaField.setPromptText(Messages.get("export.script.schema.prompt"));
singleFileRadio.setToggleGroup(strategyGroup);
perTableRadio.setToggleGroup(strategyGroup);
singleFileRadio.setSelected(true);
maxFileSizeSpinner.setEditable(true);
long maxFileSize = context.getSettings().getMaxDataFileSize();
textMaxFileSize = maxFileSize > 0 ? Math.max(1, maxFileSize / MB) : 0;
long parquetSize = context.getSettings().getParquetMaxFileSize();
parquetMaxFileSize = parquetSize > 0 ? Math.max(1, parquetSize / MB) : 0;
maxFileSizeSpinner.getValueFactory().setValue((int) textMaxFileSize);
lobSeparatedCheck.setSelected(true);
sqlFormatRadio.setToggleGroup(formatGroup);
parquetFormatRadio.setToggleGroup(formatGroup);
csvFormatRadio.setToggleGroup(formatGroup);
sqlFormatRadio.setSelected(true);
compressionCombo.getItems().setAll(ParquetExporter.COMPRESSIONS);
compressionCombo.setValue(ParquetExporter.DEFAULT_COMPRESSION);
// Options of CSV files, the delimiter of the last export
CsvOptions csvOptions = new CsvOptions();
csvOptions.setDelimiter(context.getSettings().getCsvDelimiter());
csvOptionsPane = new CsvOptionsPane(csvOptions, false);
// Options of sql scripts do not apply to data files, each data file format has its own options
compressionCombo.disableProperty().bind(parquetFormatRadio.selectedProperty().not());
csvOptionsPane.getNode().disableProperty().bind(csvFormatRadio.selectedProperty().not());
singleFileRadio.disableProperty().bind(sqlFormatRadio.selectedProperty().not());
perTableRadio.disableProperty().bind(sqlFormatRadio.selectedProperty().not());
lobSeparatedCheck.disableProperty().bind(sqlFormatRadio.selectedProperty().not());
formatGroup.selectedToggleProperty().addListener((obs, oldToggle, toggle) -> {
// Parquet files are split at their own size, sql scripts and CSV files share one
boolean wasParquet = oldToggle == parquetFormatRadio;
boolean parquet = toggle == parquetFormatRadio;
if (wasParquet != parquet) {
commitSpinner(maxFileSizeSpinner);
long current = maxFileSizeSpinner.getValue();
if (wasParquet) {
parquetMaxFileSize = current;
} else {
textMaxFileSize = current;
}
maxFileSizeSpinner.getValueFactory().setValue((int) (parquet ? parquetMaxFileSize
: textMaxFileSize));
}
updateLayoutHint();
});
layoutHint.getStyleClass().addAll("muted", "mono");
layoutHint.setWrapText(true);
strategyGroup.selectedToggleProperty().addListener((obs, oldToggle, toggle) -> updateLayoutHint());
lobSeparatedCheck.selectedProperty().addListener((obs, oldValue, value) -> updateLayoutHint());
maxFileSizeSpinner.valueProperty().addListener((obs, oldValue, value) -> updateLayoutHint());
updateLayoutHint();
GridPane scriptGrid = grid();
int row = 0;
scriptGrid.addRow(row++, new Label(Messages.get("export.script.directory")), directoryBox);
scriptGrid.addRow(row++, new Label(Messages.get("export.script.dbType")), scriptDbTypeCombo);
scriptGrid.addRow(row++, new Label(Messages.get("export.script.version")), scriptVersionCombo);
scriptGrid.addRow(row++, new Label(Messages.get("export.script.schema")), scriptSchemaField);
scriptGrid.addRow(row++, new Label(Messages.get("export.format")), new HBox(16, sqlFormatRadio,
parquetFormatRadio, csvFormatRadio));
scriptGrid.addRow(row++, new Label(Messages.get("export.format.compression")), compressionCombo);
scriptGrid.addRow(row++, new Label(Messages.get("csv.options")), csvOptionsPane.getNode());
scriptGrid.addRow(row++, new Label(Messages.get("export.script.strategy")), new HBox(16, singleFileRadio,
perTableRadio));
scriptGrid.addRow(row++, new Label(Messages.get("export.script.maxFileSize")), new HBox(8,
maxFileSizeSpinner, new Label(Messages.get("export.script.maxFileSize.unit"))));
scriptGrid.add(lobSeparatedCheck, 1, row++);
scriptGrid.add(layoutHint, 1, row);
VBox scriptPane = new VBox(scriptGrid);
scriptPane.getStyleClass().add("target-pane");
// Database target
DbTypeCells.setupProfileCombo(targetCombo);
targetCombo.getItems().setAll(context.getProfileRegistry().getProfiles());
targetCombo.setMaxWidth(Double.MAX_VALUE);
targetCatalogCombo.setMaxWidth(Double.MAX_VALUE);
targetSchemaCombo.setMaxWidth(Double.MAX_VALUE);
targetSchemaCombo.setEditable(true);
createSchemaCheck.setSelected(true);
targetCombo.valueProperty().addListener((obs, oldProfile, profile) -> loadTargetCatalogs(profile));
targetCatalogCombo.valueProperty().addListener((obs, oldCatalog, catalog) -> {
ConnectionProfile profile = targetCombo.getValue();
if (catalog != null && profile != null && profile.getDbType().isSchemaSupported()) {
loadTargetSchemas(profile, catalog);
}
});
GridPane databaseGrid = grid();
databaseGrid.addRow(0, new Label(Messages.get("export.database.connection")), ConnectionDialog.targetField(
targetCombo, context, profile -> {
targetCombo.getItems().setAll(context.getProfileRegistry().getProfiles());
ConnectionDialog.selectProfile(targetCombo, profile);
}));
databaseGrid.addRow(1, new Label(Messages.get("export.database.catalog")), targetCatalogCombo);
databaseGrid.addRow(2, new Label(Messages.get("export.database.schema")), targetSchemaCombo);
databaseGrid.add(createSchemaCheck, 1, 3);
tableNamePatternField.setPromptText(Dialect.TABLE_PLACEHOLDER);
Label tableNameHint = new Label(Messages.get("export.database.tableName.hint"));
tableNameHint.getStyleClass().add("muted");
tableNameHint.setWrapText(true);
tableNamePatternLabel = new Label(Messages.get("export.database.tableName"));
databaseGrid.addRow(4, tableNamePatternLabel, tableNamePatternField);
databaseGrid.add(tableNameHint, 1, 5);
// The name of the query table is the target name
tableNameHint.visibleProperty().bind(tableNamePatternField.visibleProperty());
tableNameHint.managedProperty().bind(tableNamePatternField.managedProperty());
transactionOption = new TransactionOption(context, targetCombo.valueProperty(), pageSizeSpinner.getValue());
// Errors of an import into a database are skipped or not by the transaction option
failFastCheck.visibleProperty().bind(scriptRadio.selectedProperty());
failFastCheck.managedProperty().bind(scriptRadio.selectedProperty());
// Rows are committed page by page: the rows per commit and the page size are the same value
pageSizeSpinner.getValueFactory().valueProperty().bindBidirectional(transactionOption.commitRowsProperty());
// The rows per commit follow the page size while it is typed, the values follow when it is committed
pageSizeSpinner.getEditor().textProperty().addListener((obs, oldText, text) -> {
String rows = StringUtils.trim(text);
if (StringUtils.isNumeric(rows) && !rows.isEmpty() && rows.length() < 9) {
transactionOption.showCommitRows(Integer.parseInt(rows));
}
});
databaseGrid.addRow(6, new Label(Messages.get("import.transaction")), transactionOption.getNode());
VBox databasePane = new VBox(databaseGrid);
databasePane.getStyleClass().add("target-pane");
databasePane.visibleProperty().bind(databaseRadio.selectedProperty());
databasePane.managedProperty().bind(databaseRadio.selectedProperty());
scriptPane.visibleProperty().bind(scriptRadio.selectedProperty());
scriptPane.managedProperty().bind(scriptRadio.selectedProperty());
return new VBox(10, new HBox(16, scriptRadio, databaseRadio), scriptPane, databasePane);
}
/**
* Name of a CSV delimiter, a tab has no visible character
*/
static String delimiterName(String delimiter) {
return CsvOptionsPane.delimiterName(delimiter);
}
private void updateLayoutHint() {
boolean split = maxFileSizeSpinner.getValue() != null && maxFileSizeSpinner.getValue() > 0;
if (!sqlFormatRadio.isSelected()) {
String extension = parquetFormatRadio.isSelected() ? ParquetExporter.PARQUET_EXTENSION
: CsvExporter.CSV_EXTENSION;
layoutHint.setText("schema.sql\ndata/<table>" + extension + (split ? ", <table>_2" + extension + " ..."
: "") + "\nconstraints.sql\nmanifest.json");
return;
}
boolean perTable = perTableRadio.isSelected();
StringBuilder hint = new StringBuilder();
hint.append("schema.sql\n");
if (perTable) {
hint.append("data/<table>.sql").append(split ? ", <table>_2.sql ..." : "").append('\n');
} else {
hint.append("data.sql").append(split ? ", data_2.sql ..." : "").append('\n');
}
if (lobSeparatedCheck.isSelected()) {
hint.append("lob/<table>/000001_<column>.clob|blob\nlob-manifest.json\n");
}
hint.append("constraints.sql\nmanifest.json");
layoutHint.setText(hint.toString());
}
private void chooseDirectory() {
DirectoryChooser chooser = new DirectoryChooser();
chooser.setTitle(Messages.get("export.script.directory"));
File current = new File(StringUtils.defaultString(directoryField.getText()));
if (current.isDirectory()) {
chooser.setInitialDirectory(current);
} else if (current.getParentFile() != null && current.getParentFile().isDirectory()) {
chooser.setInitialDirectory(current.getParentFile());
}
File directory = chooser.showDialog(getDialogPane().getScene().getWindow());
if (directory != null) {
directoryField.setText(directory.getAbsolutePath());
}
}
/**
* A free query is exported as one table: the source is fixed, the table list is replaced by the name of the
* table, options of tables which a query has not (indexes, keys, comments, sequences) are hidden
*/
private void applyQueryMode() {
queryTableField.setId("queryTableField");
Label sqlLabel = new Label(StringUtils.abbreviate(freeQuery.replaceAll("\\s+", " "), 300));
sqlLabel.setId("querySqlLabel");
sqlLabel.getStyleClass().add("muted");
sqlLabel.setWrapText(true);
GridPane queryGrid = grid();
queryGrid.addRow(0, new Label(Messages.get("export.query.table")), queryTableField);
queryGrid.addRow(1, new Label(Messages.get("export.query.sql")), sqlLabel);
tablesBox.getChildren().setAll(queryGrid);
for (Node control : new Node[]{sourceCombo, catalogCombo, schemaCombo}) {
// Shown but not changed, a disabled catalog or schema means none
control.setMouseTransparent(true);
control.setFocusTraversable(false);
}
for (Node option : new Node[]{idReusedCheck, indexCheck, foreignKeyCheck, commentCheck, sequenceCheck,
keyColumnsButton, tableNamePatternField, tableNamePatternLabel}) {
option.setVisible(false);
option.setManaged(false);
}
queryTableField.textProperty().addListener(observable -> updateValidation());
}
private void preselect(DbNode node) {
if (node == null || node.getProfile() == null) {
if (!sourceCombo.getItems().isEmpty()) {
sourceCombo.getSelectionModel().selectFirst();
}
return;
}
ConnectionProfile profile = sourceCombo.getItems().stream()
.filter(item -> item.getId().equals(node.getProfile().getId())).findFirst()
.orElse(node.getProfile());
String table = node.getTable() != null ? node.getTable().getName() : null;
// Selecting the profile triggers loading, the node path is passed to keep the selection
sourceCombo.setValue(null);
sourceCombo.getSelectionModel().select(profile);
loadCatalogs(profile, node.getCatalog(), node.getSchema(), table);
}
/**
* Chooses key columns of the selected tables (all tables of the schema if none is selected)
*/
private void chooseKeyColumns() {
ConnectionProfile source = sourceCombo.getValue();
if (source == null) {
return;
}
List<String> tables = tableChoices.stream().filter(choice -> choice.selected.get())
.map(choice -> choice.table.getName()).collect(Collectors.toList());
if (tables.isEmpty()) {
tables = tableChoices.stream().map(choice -> choice.table.getName()).collect(Collectors.toList());
}
new KeyColumnsDialog(getDialogPane().getScene().getWindow(), getSession(source), catalogCombo.isDisabled()
? null : catalogCombo.getValue(), schemaCombo.isDisabled() ? null : schemaCombo.getValue(), tables,
keyColumnNames).showAndWait().ifPresent(keys -> keyColumnNames = new HashMap<>(keys));
}
/**
* Rows are not matched by key for targets which can not do it, e.g. ClickHouse
*/
private void updateWriteModes() {
DbType target = databaseRadio.isSelected() ? (targetCombo.getValue() != null ? targetCombo.getValue()
.getDbType() : null) : scriptDbTypeCombo.getValue();
boolean supported = target == null || target.createDialect().isUpsertSupported();
if (!supported) {
insertRadio.setSelected(true);
}
for (RadioButton radio : new RadioButton[]{upsertRadio, skipExistingRadio}) {
radio.setDisable(!supported);
radio.setTooltip(supported ? null : new Tooltip(Messages.format("export.writeMode.unsupported",
target.getDisplayName())));
}
}
private DatabaseSession getSession(ConnectionProfile profile) {
return context.getSessionManager().getSession(profile);
}
private void loadCatalogs(ConnectionProfile profile, String catalog, String schema, String table) {
catalogCombo.getItems().clear();
schemaCombo.getItems().clear();
tableChoices.clear();
if (profile == null) {
return;
}
scriptDbTypeCombo.setValue(profile.getDbType());
DatabaseSession session = getSession(profile);
int generation = ++loadGeneration;
TaskRunner.run(session::getCatalogs, catalogs -> {
if (generation != loadGeneration || !profile.equals(sourceCombo.getValue())) {
return;
}
catalogCombo.setDisable(catalogs.isEmpty());
if (catalogs.isEmpty()) {
loadSchemas(null, schema, table);
return;
}
catalogCombo.getItems().setAll(catalogs);
String selected = catalog != null && catalogs.contains(catalog) ? catalog
: catalogs.contains(profile.getDatabase()) ? profile.getDatabase() : catalogs.get(0);
// Value listener loads schemas without the preselected path
catalogCombo.setDisable(true);
catalogCombo.setValue(selected);
catalogCombo.setDisable(false);
loadSchemas(selected, schema, table);
}, this::showError);
}
private void loadSchemas(String catalog, String schema, String table) {
ConnectionProfile profile = sourceCombo.getValue();
schemaCombo.getItems().clear();
tableChoices.clear();
if (profile == null) {
return;
}
if (!profile.getDbType().isSchemaSupported()) {
schemaCombo.setDisable(true);
loadTables(catalog, null, table);
return;
}
int generation = ++loadGeneration;
TaskRunner.run(() -> getSession(profile).getSchemas(catalog), schemas -> {
if (generation != loadGeneration) {
return;
}
schemaCombo.setDisable(schemas.isEmpty());
schemaCombo.getItems().setAll(schemas);
if (schemas.isEmpty()) {
loadTables(catalog, null, table);
return;
}
String selected = schema != null && schemas.contains(schema) ? schema : getDefaultSchema(profile,
schemas);
if (StringUtils.equals(selected, schemaCombo.getValue())) {
loadTables(catalog, selected, table);
} else {
// Value listener loads tables, the preselected table is applied after loading
pendingTable = table;
schemaCombo.setValue(selected);
}
}, this::showError);
}
private String pendingTable;
/**
* Each loading of catalogs, schemas or tables increases the generation, results of stale loadings (e.g. the
* source changed again before the loading finished) are discarded
*/
private int loadGeneration;
private static String getDefaultSchema(ConnectionProfile profile, List<String> schemas) {
List<String> candidates = new ArrayList<>();
if (StringUtils.isNotBlank(profile.getUsername())) {
candidates.add(profile.getUsername());
}
candidates.addAll(List.of("public", "dbo", "PUBLIC"));
for (String candidate : candidates) {
for (String schema : schemas) {
if (schema.equalsIgnoreCase(candidate)) {
return schema;
}
}
}
return schemas.get(0);
}
private void loadTables(String catalog, String schema, String table) {
ConnectionProfile profile = sourceCombo.getValue();
tableChoices.clear();
if (profile == null) {
return;
}
String preselected = table != null ? table : pendingTable;
pendingTable = null;
int generation = ++loadGeneration;
TaskRunner.run(() -> getSession(profile).getTables(catalog, schema), tables -> {
if (generation != loadGeneration) {
return;
}
List<TableChoice> choices = tables.stream().filter(info -> !info.isPartition())
.map(info -> new TableChoice(info, preselected == null || info.getName().equals(preselected)))
.collect(Collectors.toList());
choices.forEach(choice -> choice.selected.addListener((obs, oldValue, value) -> {
updateTableCount();
updateValidation();
}));
tableChoices.setAll(choices);
updateTableCount();
if (preselected != null) {
choices.stream().filter(choice -> choice.selected.get()).findFirst().ifPresent(tableList::scrollTo);
}
}, this::showError);
}
private void updateTableCount() {
long selected = tableChoices.stream().filter(choice -> choice.selected.get()).count();
tableCountLabel.setText(Messages.format("export.tables.count", selected, tableChoices.size()));
}
private void loadTargetCatalogs(ConnectionProfile profile) {
targetCatalogCombo.getItems().clear();
targetSchemaCombo.getItems().clear();
if (profile == null) {
return;
}
TaskRunner.run(() -> getSession(profile).getCatalogs(), catalogs -> {
targetCatalogCombo.setDisable(catalogs.isEmpty());
targetCatalogCombo.getItems().setAll(catalogs);
if (catalogs.isEmpty()) {
if (profile.getDbType().isSchemaSupported()) {
loadTargetSchemas(profile, null);
} else {
targetSchemaCombo.setDisable(true);
}
return;
}
targetCatalogCombo.setValue(catalogs.contains(profile.getDatabase()) ? profile.getDatabase()
: catalogs.get(0));
targetSchemaCombo.setDisable(!profile.getDbType().isSchemaSupported());
}, this::showError);
}
private void loadTargetSchemas(ConnectionProfile profile, String catalog) {
targetSchemaCombo.setDisable(false);
TaskRunner.run(() -> getSession(profile).getSchemas(catalog), schemas -> {
targetSchemaCombo.getItems().setAll(schemas);
if (StringUtils.isBlank(targetSchemaCombo.getEditor().getText()) && !schemas.isEmpty()) {
targetSchemaCombo.setValue(getDefaultSchema(profile, schemas));
}
}, this::showError);
}
/**
* Errors of loading after the dialog is closed are not shown
*/
private void showError(Throwable e) {
if (isShowing()) {
Dialogs.showError(getDialogPane().getScene().getWindow(), Messages.get("export.loadError"), e);
}
}
String validate() {
if (sourceCombo.getValue() == null) {
return Messages.get("export.error.source");
}
if (freeQuery != null && !StringUtils.trimToEmpty(queryTableField.getText()).matches(
"[\\p{L}_][\\p{L}\\p{N}_$]*")) {
return Messages.get("export.error.queryTable");
}
if (freeQuery == null && !tableChoices.isEmpty() && tableChoices.stream().noneMatch(choice -> choice.selected
.get())) {
return Messages.get("export.error.tables");
}
if (!isSpinnerTextValid(pageSizeSpinner)) {
return Messages.format("export.error.pageSize", String.valueOf(getMin(pageSizeSpinner)),
String.valueOf(getMax(pageSizeSpinner)));
}
if (scriptRadio.isSelected()) {
if (!isSpinnerTextValid(maxFileSizeSpinner)) {
return Messages.format("export.error.maxFileSize", String.valueOf(getMax(maxFileSizeSpinner)));
}
String version = StringUtils.trimToEmpty(scriptVersionCombo.getEditor().getText());
if (!version.isEmpty() && !version.matches("\\d{1,4}(\\.\\d{1,3})?")) {
return Messages.format("export.error.version", version);
}
if (StringUtils.isBlank(directoryField.getText())) {
return Messages.get("export.error.directory");
}
File directory = new File(directoryField.getText().trim());
if (directory.exists() && !directory.isDirectory()) {
return Messages.get("export.error.directory");
}
} else if (targetCombo.getValue() == null) {
return Messages.get("export.error.target");
} else if (freeQuery == null) {
return validateTableNames();
}
return null;
}
/**
* Tables are not imported into themselves, tables copied in the same schema need another name. A name without
* {table} is the name of a single table.
*/
private String validateTableNames() {
String pattern = StringUtils.trimToEmpty(tableNamePatternField.getText());
boolean renamed = !pattern.isEmpty() && !Dialect.TABLE_PLACEHOLDER.equals(pattern);
if (renamed && !pattern.contains(Dialect.TABLE_PLACEHOLDER) && getSelectedTableCount() != 1) {
return Messages.format("export.error.tableName", Dialect.TABLE_PLACEHOLDER);
}
ConnectionProfile source = sourceCombo.getValue();
ConnectionProfile target = targetCombo.getValue();
if (!renamed && source != null && target != null && Objects.equals(source.getId(), target.getId())
&& isSameName(catalogCombo.isDisabled() ? null : catalogCombo.getValue(),
targetCatalogCombo.isDisabled() ? null : targetCatalogCombo.getValue())
&& isSameName(schemaCombo.isDisabled() ? null : schemaCombo.getValue(),