Skip to content

Commit

Permalink
Import/Export of connections and models, WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Wisser committed Nov 20, 2023
1 parent 1475928 commit 4f68d8a
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 20 deletions.
24 changes: 17 additions & 7 deletions src/main/engine/net/sf/jailer/configuration/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,23 @@ private synchronized static void loadConfigurationFile() {
String name = "jailer.xml";
try {
InputStream res;
File configFile;
if (applicationBase == null) {
configFile = new File(name);
// TODO
// TODO if .multi/.singleuser -> look in users home
} else {
configFile = new File(applicationBase, name);
File configFile = null;
if (new File(".singleuser").exists() // legacy
|| new File(".multiuser").exists() || applicationBase != null) {
File home = new File(System.getProperty("user.home"), ".jailer");
configFile = new File(home, name);
if (!configFile.exists()) {
configFile = null;
}
}
if (configFile == null) {
if (applicationBase == null) {
configFile = new File(name);
// TODO
// TODO if .multi/.singleuser -> look in users home
} else {
configFile = new File(applicationBase, name);
}
}
if (!configFile.exists()) {
res = Configuration.class.getResourceAsStream(name);
Expand Down
1 change: 1 addition & 0 deletions src/main/gui/net/sf/jailer/ui/Environment.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ public static String[] init(String[] args) {
copyIfNotExists("demo-scott-subset.mv.db");
copyIfNotExists("example");
copyIfNotExists("render");
copyIfNotExists("jailer.xml");
// TODO
// TODO jailer.xml

Expand Down
14 changes: 6 additions & 8 deletions src/main/gui/net/sf/jailer/ui/ExportPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@
*/
public class ExportPanel extends javax.swing.JPanel {

/**
private static final String EXPORT_MARKER = "JailerModelAndConnectionArchiv";
private static final String EXPORT_FILE_EXTENSION = ".jmac.zip";

/**
* Creates new form ExportPanel
*/
public ExportPanel() {
Expand All @@ -92,8 +95,6 @@ public ExportPanel() {
}
}

private static final String EXPORT_MARKER = "JailerModelExportArchiv";

private JDialog dialog;
private boolean ok = false;

Expand Down Expand Up @@ -471,7 +472,7 @@ protected void doExport() {
String cmsf = DataModelManager.getCurrentModelSubfolder(executionContext);
try {
DataModelManager.setCurrentModelSubfolder(null, executionContext);
String file = UIUtil.choseFile(null, ".", dialog.getTitle(), ".zip", ExportPanel.this, true, false);
String file = UIUtil.choseFile(null, ".", dialog.getTitle(), EXPORT_FILE_EXTENSION, ExportPanel.this, true, false, false);
UIUtil.setWaitCursor(this);
if (file != null) {
try {
Expand Down Expand Up @@ -505,7 +506,7 @@ public static Pair<Boolean, Pair<Integer, List<ConnectionInfo>>> openImportDialo
executionContext.setDatamodelFolder(tmpFile.getPath());
Path targetPath = tmpFile.toPath();

String file = UIUtil.choseFile(null, ".", "Import data models and connections", ".zip", owner, true, true);
String file = UIUtil.choseFile(null, ".", "Import data models and connections", EXPORT_FILE_EXTENSION, owner, true, true, false);
if (file != null) {
Pair<Boolean, Pair<Integer, List<ConnectionInfo>>> importTmp = doImport(owner, file, true, null, null, connectionDialog);
Set<String> tabuModels = new HashSet<>();
Expand Down Expand Up @@ -782,6 +783,3 @@ private void selectAllButtonActionPerformed(java.awt.event.ActionEvent evt) {//G

//TODO
//TODO file chooser: initial pattern: vorschlag dateiname? (? exakt 1 Ding -> danach benennen?)

//TODO
//TODO delete model folder before importing it (bc. exclude-associations.csv etc.)
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ private void update(String searchText, boolean setCurrentPosition) {
lastSearchText = searchText;

markedValues.clear();
tooltips.clear();
markedValuePerPosition.clear();
ordinalPerViewPosition.clear();
viewToModelPosition.clear();
Expand Down Expand Up @@ -489,11 +490,13 @@ public Component markOccurrence(JLabel render, int x, int y) {
String marked = markedValues.get(render.getText());
if (marked != null) {
render.setText(marked);
String toolTipText = render.getToolTipText();
if (toolTipText == null || toolTipText.length() < 5000) {
toolTipText = marked.replace("" + (char) 182, "<br>").replaceFirst("^<html>&nbsp;", "<html>");
// TODO
// TODO cache
String toolTipText = tooltips.get(marked);
if (toolTipText == null) {
toolTipText = render.getToolTipText();
if (toolTipText == null || toolTipText.length() < 5000) {
toolTipText = marked.replace("" + (char) 182, "<br>").replaceFirst("^<html>&nbsp;", "<html>");
tooltips.put(marked, toolTipText);
}
}
render.setToolTipText(toolTipText);
render.setBackground(new Color(190, 255, 180));
Expand Down Expand Up @@ -605,6 +608,7 @@ private void beep() {

private Color origBackground;
private Map<String, String> markedValues = new HashMap<String, String>();
private Map<String, String> tooltips = new HashMap<String, String>();
private NavigableMap<Integer, String> markedValuePerPosition = new TreeMap<Integer, String>();
private NavigableMap<Integer, Integer> ordinalPerViewPosition = new TreeMap<Integer, Integer>();
private Map<Integer, Integer> viewToModelPosition = new TreeMap<Integer, Integer>();
Expand Down

0 comments on commit 4f68d8a

Please sign in to comment.