mirror of
https://github.com/Wisser/Jailer.git
synced 2026-05-24 11:39:31 -05:00
"recent session" button in DataModelManagerDialog
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
Layout; MEDIUM
|
||||
1; ; ; 0; 240; 476; 460; 500; true; T; CUSTOMER; ; false;
|
||||
2; 1; ; 586; 240; 476; 460; 500; true; T; RENTAL; inverse-FK_RENTAL_CUSTOMER; false;
|
||||
1; ; ; 0; 6; 476; 460; 500; true; T; CUSTOMER; ; false;
|
||||
2; 1; ; 586; 6; 476; 460; 500; true; T; RENTAL; inverse-FK_RENTAL_CUSTOMER; false;
|
||||
3; 2; ; 1172; 6; 476; 460; 500; true; T; INVENTORY; FK_RENTAL_INVENTORY; true;
|
||||
4; 3; ; 1172; 6; 476; 460; 500; true; T; FILM; FK_INVENTORY_FILM; false;
|
||||
5; 2; ; 1172; 474; 476; 460; 500; true; T; PAYMENT; inverse-FK_PAYMENT_RENTAL; false;
|
||||
4; 3; ; 1172; 6; 476; 460; 500; true; T; FILM; FK_INVENTORY_FILM; false;
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
Layout; MEDIUM
|
||||
1; ; A.EMPNO=7900; 0; 6; 476; 460; 500; true; T; EMPLOYEE; ; false;
|
||||
2; 1; ; 586; 6; 476; 460; 500; true; T; PROJECT_PARTICIPATION; inverse-EMPLOYEE; false;
|
||||
3; 2; ; 1172; 6; 476; 460; 500; false; T; PROJECT; PROJECT; false;
|
||||
4; 2; ; 1172; 474; 476; 460; 500; false; T; ROLE; ROLE; false;
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package net.sf.jailer.util;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* An ordered pair of objects (a, b).
|
||||
@@ -27,7 +28,7 @@ package net.sf.jailer.util;
|
||||
*
|
||||
* @author Ralf Wisser
|
||||
*/
|
||||
public class Pair<A, B> {
|
||||
public class Pair<A, B> implements Serializable {
|
||||
|
||||
/**
|
||||
* The <b>a</b> object.
|
||||
@@ -102,4 +103,6 @@ public class Pair<A, B> {
|
||||
return "Pair(" + a + ", " + b + ")";
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = -4954459907998487933L;
|
||||
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.text.DateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
@@ -116,6 +115,7 @@ public abstract class DataModelManagerDialog extends javax.swing.JFrame {
|
||||
private InfoBar infoBarBookmark;
|
||||
private InfoBar infoBarRecUsedBookmark;
|
||||
private final String tabPropertyName;
|
||||
private final String module; // TODO define module enum
|
||||
|
||||
private Font font = new JLabel("normal").getFont();
|
||||
private Font normal = new Font(font.getName(), font.getStyle() & ~Font.BOLD, font.getSize());
|
||||
@@ -127,6 +127,7 @@ public abstract class DataModelManagerDialog extends javax.swing.JFrame {
|
||||
public DataModelManagerDialog(String applicationName, boolean withLoadJMButton, String module) {
|
||||
this.applicationName = applicationName;
|
||||
this.tabPropertyName = "DMMDPropTab" + module;
|
||||
this.module = module;
|
||||
initComponents();
|
||||
|
||||
InfoBar infoBar = new InfoBar("Data Model Configuration",
|
||||
@@ -167,7 +168,6 @@ public abstract class DataModelManagerDialog extends javax.swing.JFrame {
|
||||
} else {
|
||||
jTabbedPane1.remove(bookmarkPanel);
|
||||
jTabbedPane1.remove(recentlyUsedBookmarkPanel);
|
||||
restoreLastSessionButton.setVisible(false);
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -341,13 +341,11 @@ public abstract class DataModelManagerDialog extends javax.swing.JFrame {
|
||||
|
||||
setLocation(70, 130);
|
||||
pack();
|
||||
setSize(Math.max(740, getWidth()), 490);
|
||||
setSize(Math.max(840, getWidth()), 490);
|
||||
refresh();
|
||||
UIUtil.initPeer();
|
||||
|
||||
if (!withLoadJMButton) {
|
||||
initRestoreLastSessionButton();
|
||||
}
|
||||
initRestoreLastSessionButton();
|
||||
|
||||
try {
|
||||
Object tab = UISettings.restore(tabPropertyName);
|
||||
@@ -384,12 +382,13 @@ public abstract class DataModelManagerDialog extends javax.swing.JFrame {
|
||||
}
|
||||
|
||||
private void initRestoreLastSessionButton() {
|
||||
final BookmarkId lastSession = UISettings.restoreLastSession();
|
||||
final boolean forEMEditor = "S".equals(module);
|
||||
final BookmarkId lastSession = UISettings.restoreLastSession(module);
|
||||
if (lastSession == null) {
|
||||
restoreLastSessionButton.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
Date date = DataBrowser.getLastSessionDate();
|
||||
Date date = forEMEditor? lastSession.date : DataBrowser.getLastSessionDate();
|
||||
if (date == null || !modelList.contains(lastSession.datamodelFolder)) {
|
||||
restoreLastSessionButton.setEnabled(false);
|
||||
return;
|
||||
@@ -401,21 +400,21 @@ public abstract class DataModelManagerDialog extends javax.swing.JFrame {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (connectionInfo == null) {
|
||||
if (connectionInfo == null && !forEMEditor) {
|
||||
restoreLastSessionButton.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
Pair<String, Long> details = modelDetails.get(lastSession.datamodelFolder);
|
||||
restoreLastSessionButton.setToolTipText(
|
||||
UIUtil.toHTML(
|
||||
(details != null? details.a : lastSession.datamodelFolder) + "\n" +
|
||||
connectionInfo.alias + " (" + connectionInfo.user + "@" + connectionInfo.url + ")\n" +
|
||||
toDateAsString(date.getTime()), 0));
|
||||
(lastSession.bookmark != null? (new File(lastSession.bookmark).getName()) : ((details != null? details.a : lastSession.datamodelFolder))) + "\n" +
|
||||
(connectionInfo == null? "offline\n" : (connectionInfo.alias + " (" + connectionInfo.user + "@" + connectionInfo.url + ")\n")) +
|
||||
UIUtil.toDateAsString(date.getTime()), 0));
|
||||
final ConnectionInfo finalConnectionInfo = connectionInfo;
|
||||
restoreLastSessionButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
openBookmark(new BookmarkId("", lastSession.datamodelFolder, lastSession.connectionAlias, lastSession.rawSchemaMapping), finalConnectionInfo);
|
||||
openBookmark(new BookmarkId(forEMEditor? lastSession.bookmark : "", lastSession.datamodelFolder, lastSession.connectionAlias, lastSession.rawSchemaMapping), finalConnectionInfo);
|
||||
setVisible(false);
|
||||
dispose();
|
||||
}
|
||||
@@ -473,15 +472,28 @@ public abstract class DataModelManagerDialog extends javax.swing.JFrame {
|
||||
BookmarkId bookmark = bookmarksListModel.get(i);
|
||||
Pair<String, Long> details = modelDetails.get(bookmark.datamodelFolder);
|
||||
ConnectionInfo ci = ciOfBookmark.get(bookmark);
|
||||
data[i] = new Object[] {
|
||||
bookmark.bookmark,
|
||||
details.a,
|
||||
bookmark.connectionAlias,
|
||||
ci.user,
|
||||
ci.url };
|
||||
data[i] = onlyRecentlyUsed?
|
||||
new Object[] {
|
||||
bookmark.bookmark,
|
||||
details.a,
|
||||
bookmark.connectionAlias,
|
||||
ci.user,
|
||||
ci.url,
|
||||
UIUtil.toDateAsString(bookmark.date)
|
||||
} :
|
||||
new Object[] {
|
||||
bookmark.bookmark,
|
||||
details.a,
|
||||
bookmark.connectionAlias,
|
||||
ci.user,
|
||||
ci.url
|
||||
};
|
||||
}
|
||||
|
||||
DefaultTableModel tableModel = new DefaultTableModel(data, new String[] { "Bookmark", "Data Model", "Connection", "User", "URL" }) {
|
||||
DefaultTableModel tableModel = new DefaultTableModel(data,
|
||||
onlyRecentlyUsed?
|
||||
new String[] {"Bookmark", "Data Model", "Connection", "User", "URL", "Time"}
|
||||
: new String[] { "Bookmark", "Data Model", "Connection", "User", "URL" }) {
|
||||
@Override
|
||||
public boolean isCellEditable(int row, int column) {
|
||||
return false;
|
||||
@@ -536,7 +548,7 @@ public abstract class DataModelManagerDialog extends javax.swing.JFrame {
|
||||
if (i >= 0 && i < bookmarksListModel.size()) {
|
||||
BookmarkId bookmark = bookmarksListModel.get(i);
|
||||
ConnectionInfo ci = ciOfBookmark.get(bookmark);
|
||||
openBookmark(bookmark, ci);
|
||||
openBookmark(new BookmarkId(bookmark.bookmark, bookmark.datamodelFolder, bookmark.connectionAlias, bookmark.rawSchemaMapping), ci);
|
||||
setVisible(false);
|
||||
dispose();
|
||||
}
|
||||
@@ -559,14 +571,17 @@ public abstract class DataModelManagerDialog extends javax.swing.JFrame {
|
||||
|
||||
for (int i = 0; i < jTable.getColumnCount(); i++) {
|
||||
TableColumn column = jTable.getColumnModel().getColumn(i);
|
||||
int width = i == 0? 200 : 1;
|
||||
int width = i == 0? 100 : 1;
|
||||
Component comp = jTable.getDefaultRenderer(String.class).getTableCellRendererComponent(jTable, column.getHeaderValue(), false, false, 0, i);
|
||||
width = Math.max(width, comp.getPreferredSize().width);
|
||||
|
||||
for (int line = 0; line < data.length; ++line) {
|
||||
comp = jTable.getDefaultRenderer(String.class).getTableCellRendererComponent(jTable,
|
||||
data[line][i],false, false, line, i);
|
||||
width = Math.max(width, Math.min(150, comp.getPreferredSize().width));
|
||||
width = Math.max(width, Math.min(250, comp.getPreferredSize().width));
|
||||
}
|
||||
if (onlyRecentlyUsed && i == jTable.getColumnCount() - 1) {
|
||||
width = Math.max(width, 150);
|
||||
}
|
||||
column.setPreferredWidth(width);
|
||||
}
|
||||
@@ -577,8 +592,12 @@ public abstract class DataModelManagerDialog extends javax.swing.JFrame {
|
||||
private final List<File> fileList = new ArrayList<File>();
|
||||
|
||||
private void initJMTable() {
|
||||
Map<File, Date> timestamps = new HashMap<File, Date>();
|
||||
try {
|
||||
fileList.addAll(UISettings.loadRecentFiles());
|
||||
for (Pair<File, Date> file: UISettings.loadRecentFiles()) {
|
||||
fileList.add(file.a);
|
||||
timestamps.put(file.a, file.b);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
@@ -587,13 +606,13 @@ public abstract class DataModelManagerDialog extends javax.swing.JFrame {
|
||||
for (File file: fileList) {
|
||||
try {
|
||||
if (file.exists()) {
|
||||
data[i++] = new Object[] { file.getName(), file.getAbsoluteFile().getParent() };
|
||||
data[i++] = new Object[] { file.getName(), file.getAbsoluteFile().getParent(), UIUtil.toDateAsString(timestamps.get(file)) };
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
DefaultTableModel tableModel = new DefaultTableModel(data, new String[] { "Name", "Path" }) {
|
||||
DefaultTableModel tableModel = new DefaultTableModel(data, new String[] { "Name", "Path", "Time" }) {
|
||||
@Override
|
||||
public boolean isCellEditable(int row, int column) {
|
||||
return false;
|
||||
@@ -638,6 +657,19 @@ public abstract class DataModelManagerDialog extends javax.swing.JFrame {
|
||||
jmOkButton.setEnabled(jmFilesTable.getSelectedRow() >= 0);
|
||||
}
|
||||
});
|
||||
for (i = 0; i < jmFilesTable.getColumnCount(); i++) {
|
||||
TableColumn column = jmFilesTable.getColumnModel().getColumn(i);
|
||||
int width = i == 0? 200 : 1;
|
||||
Component comp = jmFilesTable.getDefaultRenderer(String.class).getTableCellRendererComponent(jmFilesTable, column.getHeaderValue(), false, false, 0, i);
|
||||
width = Math.max(width, comp.getPreferredSize().width);
|
||||
|
||||
for (int line = 0; line < data.length; ++line) {
|
||||
comp = jmFilesTable.getDefaultRenderer(String.class).getTableCellRendererComponent(jmFilesTable,
|
||||
data[line][i],false, false, line, i);
|
||||
width = Math.max(width, Math.min(150, comp.getPreferredSize().width));
|
||||
}
|
||||
column.setPreferredWidth(width);
|
||||
}
|
||||
jmFilesTable.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(MouseEvent me) {
|
||||
@@ -666,7 +698,9 @@ public abstract class DataModelManagerDialog extends javax.swing.JFrame {
|
||||
} else {
|
||||
DataModelManager.setCurrentModelSubfolder(currentConnection.dataModelFolder, executionContext);
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
onSelect(this, executionContext);
|
||||
dbConnectionDialog.currentConnection = currentConnection;
|
||||
dbConnectionDialog.isConnected = true;
|
||||
onSelect(dbConnectionDialog, executionContext);
|
||||
UISettings.store(tabPropertyName, jTabbedPane1.getSelectedIndex());
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
||||
DataModelManagerDialog.this.setVisible(false);
|
||||
@@ -727,7 +761,7 @@ public abstract class DataModelManagerDialog extends javax.swing.JFrame {
|
||||
int i = 0;
|
||||
for (String model: modelList) {
|
||||
Pair<String, Long> details = modelDetails.get(model);
|
||||
data[i++] = new Object[] { details == null? "" : details.a, model == null || model.length() == 0? "." : model, details == null? "" : toDateAsString(details.b) };
|
||||
data[i++] = new Object[] { details == null? "" : details.a, model == null || model.length() == 0? "." : model, details == null? "" : UIUtil.toDateAsString(details.b) };
|
||||
}
|
||||
DefaultTableModel tableModel = new DefaultTableModel(data, new String[] { "Data Model", "Subfolder", "Last Modified" }) {
|
||||
@Override
|
||||
@@ -740,13 +774,6 @@ public abstract class DataModelManagerDialog extends javax.swing.JFrame {
|
||||
return data;
|
||||
}
|
||||
|
||||
private String toDateAsString(Long time) {
|
||||
if (time == null) {
|
||||
return "";
|
||||
}
|
||||
return DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Environment.initialLocal).format(new Date(time));
|
||||
}
|
||||
|
||||
private boolean inRefresh = false;
|
||||
|
||||
/**
|
||||
@@ -1642,19 +1669,25 @@ public abstract class DataModelManagerDialog extends javax.swing.JFrame {
|
||||
try {
|
||||
CommandLineInstance.getInstance().bookmark = bookmark.bookmark;
|
||||
CommandLineInstance.getInstance().rawschemamapping = bookmark.rawSchemaMapping;
|
||||
CommandLineInstance.getInstance().alias = ci.alias;
|
||||
CommandLineInstance.getInstance().driver = ci.driverClass;
|
||||
CommandLineInstance.getInstance().jdbcjar = ci.jar1;
|
||||
CommandLineInstance.getInstance().jdbcjar2 = ci.jar2;
|
||||
CommandLineInstance.getInstance().jdbcjar3 = ci.jar3;
|
||||
CommandLineInstance.getInstance().jdbcjar4 = ci.jar4;
|
||||
CommandLineInstance.getInstance().password = ci.password;
|
||||
CommandLineInstance.getInstance().url = ci.url;
|
||||
CommandLineInstance.getInstance().user = ci.user;
|
||||
if (ci != null) {
|
||||
CommandLineInstance.getInstance().alias = ci.alias;
|
||||
CommandLineInstance.getInstance().driver = ci.driverClass;
|
||||
CommandLineInstance.getInstance().jdbcjar = ci.jar1;
|
||||
CommandLineInstance.getInstance().jdbcjar2 = ci.jar2;
|
||||
CommandLineInstance.getInstance().jdbcjar3 = ci.jar3;
|
||||
CommandLineInstance.getInstance().jdbcjar4 = ci.jar4;
|
||||
CommandLineInstance.getInstance().password = ci.password;
|
||||
CommandLineInstance.getInstance().url = ci.url;
|
||||
CommandLineInstance.getInstance().user = ci.user;
|
||||
}
|
||||
onSelect(null, executionContext);
|
||||
UISettings.store(tabPropertyName, jTabbedPane1.getSelectedIndex());
|
||||
UISettings.addRecentConnectionAliases(ci.alias);
|
||||
UISettings.addRecentBookmarks(bookmark);
|
||||
if (ci != null) {
|
||||
UISettings.addRecentConnectionAliases(ci.alias);
|
||||
}
|
||||
if ("B".equals(module)) {
|
||||
UISettings.addRecentBookmarks(bookmark);
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
CommandLineInstance.getInstance().bookmark = oldBookmark;
|
||||
CommandLineInstance.getInstance().rawschemamapping = oldRawSchemaMapping;
|
||||
|
||||
@@ -35,6 +35,8 @@ import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -157,7 +159,8 @@ public class DbConnectionDialog extends javax.swing.JDialog {
|
||||
private Font font = new JLabel("normal").getFont();
|
||||
private Font normal = new Font(font.getName(), font.getStyle() & ~Font.BOLD, font.getSize());
|
||||
private Font bold = new Font(font.getName(), font.getStyle() | Font.BOLD, font.getSize());
|
||||
|
||||
private Map<String, Date> aliasTimestamp = new HashMap<String, Date>();
|
||||
|
||||
/**
|
||||
* Gets connection to DB.
|
||||
*
|
||||
@@ -368,9 +371,13 @@ public class DbConnectionDialog extends javax.swing.JDialog {
|
||||
int i = 0;
|
||||
for (ConnectionInfo ci: connectionList) {
|
||||
Pair<String, Long> modelDetails = DataModelManager.getModelDetails(ci.dataModelFolder, executionContext);
|
||||
data[i++] = new Object[] { ci.alias, ci.user, ci.url, ci.dataModelFolder == null? "Default" : modelDetails == null? "" : modelDetails.a };
|
||||
if (showOnlyRecentyUsedConnections) {
|
||||
data[i++] = new Object[] { ci.alias, ci.user, ci.url, ci.dataModelFolder == null? "Default" : modelDetails == null? "" : modelDetails.a, UIUtil.toDateAsString(aliasTimestamp.get(ci.alias)) };
|
||||
} else {
|
||||
data[i++] = new Object[] { ci.alias, ci.user, ci.url, ci.dataModelFolder == null? "Default" : modelDetails == null? "" : modelDetails.a };
|
||||
}
|
||||
}
|
||||
DefaultTableModel tableModel = new DefaultTableModel(data, new String[] { "Alias", "User", "URL", "Data Model" }) {
|
||||
DefaultTableModel tableModel = new DefaultTableModel(data, !showOnlyRecentyUsedConnections? new String[] { "Alias", "User", "URL", "Data Model" } : new String[] { "Alias", "User", "URL", "Data Model", "Time" }) {
|
||||
@Override
|
||||
public boolean isCellEditable(int row, int column) {
|
||||
return false;
|
||||
@@ -588,10 +595,11 @@ public class DbConnectionDialog extends javax.swing.JDialog {
|
||||
if (showOnlyRecentyUsedConnections) {
|
||||
List<ConnectionInfo> recUsedConnectionList = new ArrayList<ConnectionInfo>();
|
||||
|
||||
for (String alias: UISettings.loadRecentConnectionAliases()) {
|
||||
for (Pair<String, Date> alias: UISettings.loadRecentConnectionAliases()) {
|
||||
for (ConnectionInfo ci: connectionList) {
|
||||
if (ci.alias != null && ci.alias.equals(alias)) {
|
||||
if (ci.alias != null && ci.alias.equals(alias.a)) {
|
||||
recUsedConnectionList.add(ci);
|
||||
aliasTimestamp.put(alias.a, alias.b);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ public class Environment {
|
||||
} catch (Throwable t) {
|
||||
if (active) {
|
||||
active = false;
|
||||
UIUtil.showException(null, "Error", t);
|
||||
UIUtil.showException(null, "Error", t, "AWT");
|
||||
} else {
|
||||
throw t;
|
||||
}
|
||||
|
||||
@@ -79,6 +79,7 @@ import net.sf.jailer.subsetting.ScriptFormat;
|
||||
import net.sf.jailer.ui.associationproposer.AssociationProposerView;
|
||||
import net.sf.jailer.ui.commandline.CommandLineInstance;
|
||||
import net.sf.jailer.ui.commandline.UICommandLine;
|
||||
import net.sf.jailer.ui.databrowser.BookmarksPanel.BookmarkId;
|
||||
import net.sf.jailer.ui.databrowser.DataBrowser;
|
||||
import net.sf.jailer.ui.progress.ExportAndDeleteStageProgressListener;
|
||||
import net.sf.jailer.ui.util.AnimationController;
|
||||
@@ -133,6 +134,12 @@ public class ExtractionModelFrame extends javax.swing.JFrame {
|
||||
this(extractionModelFile, isHorizonal, null, executionContext);
|
||||
}
|
||||
|
||||
private void storeLastSession() {
|
||||
BookmarkId bookmark;
|
||||
bookmark = new BookmarkId(extractionModelEditor.extractionModelFile, ExtractionModelFrame.this.executionContext.getCurrentModelSubfolder(), ExtractionModelFrame.this.executionContext.getCurrentConnectionAlias(), null);
|
||||
UISettings.storeLastSession(bookmark, "S");
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates new form ExtractionModelFrame.
|
||||
*
|
||||
@@ -198,6 +205,17 @@ public class ExtractionModelFrame extends javax.swing.JFrame {
|
||||
}
|
||||
dbConnectionDialog.autoConnect();
|
||||
|
||||
final String bmFile = CommandLineInstance.getInstance().bookmark;
|
||||
if (bmFile != null && !"".equals(bmFile) && new File(bmFile).exists()) {
|
||||
showWizzard = false;
|
||||
UIUtil.invokeLater(4, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
load(bmFile);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
updateMenuItems();
|
||||
|
||||
cycleViewDialog = new CyclesView(this);
|
||||
@@ -209,6 +227,8 @@ public class ExtractionModelFrame extends javax.swing.JFrame {
|
||||
}, executionContext);
|
||||
}
|
||||
|
||||
private boolean showWizzard = true;
|
||||
|
||||
private void initMenu() {
|
||||
int mask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
|
||||
if (mask != InputEvent.CTRL_MASK) {
|
||||
@@ -1683,10 +1703,12 @@ public class ExtractionModelFrame extends javax.swing.JFrame {
|
||||
"",
|
||||
JOptionPane.YES_NO_OPTION,
|
||||
JOptionPane.QUESTION_MESSAGE)) {
|
||||
storeLastSession();
|
||||
dispose();
|
||||
UIUtil.checkTermination();
|
||||
}
|
||||
} else {
|
||||
storeLastSession();
|
||||
dispose();
|
||||
UIUtil.checkTermination();
|
||||
}
|
||||
@@ -2137,7 +2159,7 @@ public class ExtractionModelFrame extends javax.swing.JFrame {
|
||||
} catch (Exception e) {
|
||||
UIUtil.showException(finalExtractionModelFrame, "Error", e);
|
||||
}
|
||||
if (withStartupWizzard) {
|
||||
if (withStartupWizzard && finalExtractionModelFrame.showWizzard) {
|
||||
new StartupWizzardDialog(finalExtractionModelFrame) {
|
||||
@Override
|
||||
protected void onClose() {
|
||||
|
||||
@@ -54,6 +54,7 @@ import java.io.StringWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.text.DateFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
@@ -769,7 +770,8 @@ public class UIUtil {
|
||||
contextDesc += "\nMail: rwisser@users.sourceforge.net\n";
|
||||
contextDesc += "\n" + JailerVersion.APPLICATION_NAME + " " + JailerVersion.VERSION + "\n\n" + sw.toString();
|
||||
|
||||
String iMsg = msg.toString() + "\n" + JailerVersion.APPLICATION_NAME + " " + JailerVersion.VERSION + "\n\n" + sw.toString();
|
||||
String iMsg = (context != null && "AWT".equals(context)? context : "") +
|
||||
msg.toString() + "\n" + JailerVersion.APPLICATION_NAME + " " + JailerVersion.VERSION + "\n\n" + sw.toString();
|
||||
iMsg = iMsg
|
||||
.replaceAll("\\bat [^\\n]*/", "at ")
|
||||
.replaceAll("\\bat java.", "atj..")
|
||||
@@ -1258,6 +1260,21 @@ public class UIUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static String toDateAsString(Long time) {
|
||||
if (time == null) {
|
||||
return "";
|
||||
}
|
||||
return DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Environment.initialLocal).format(new Date(time));
|
||||
}
|
||||
|
||||
public static Object toDateAsString(Date date) {
|
||||
if (date != null) {
|
||||
return toDateAsString(date.getTime());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static Font defaultFont = null;
|
||||
|
||||
public static Font defaultTitleFont() {
|
||||
|
||||
@@ -26,6 +26,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -460,12 +461,14 @@ public class BookmarksPanel extends javax.swing.JPanel {
|
||||
public final String datamodelFolder;
|
||||
public final String connectionAlias;
|
||||
public final String rawSchemaMapping;
|
||||
public final Date date;
|
||||
|
||||
public BookmarkId(String bookmark, String datamodelFolder, String connectionAlias, String rawSchemaMapping) {
|
||||
this.bookmark = bookmark;
|
||||
this.datamodelFolder = datamodelFolder;
|
||||
this.connectionAlias = connectionAlias;
|
||||
this.rawSchemaMapping = rawSchemaMapping;
|
||||
this.date = new Date();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2549,6 +2549,8 @@ public class DataBrowser extends javax.swing.JFrame {
|
||||
} else if (bmFile != null) {
|
||||
dataBrowser.desktop.restoreSession(null, bmFile);
|
||||
BookmarksPanel.setLastUsedBookmark(bmFile.getName(), dataBrowser.executionContext);
|
||||
bmFile.setLastModified(System.currentTimeMillis());
|
||||
new BookmarksPanel(dataBrowser, dataBrowser.bookmarkMenu, dataBrowser.desktop, dataBrowser.executionContext).updateBookmarksMenu();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -4138,7 +4140,7 @@ public class DataBrowser extends javax.swing.JFrame {
|
||||
} catch (IOException e) {
|
||||
bookmark = null;
|
||||
}
|
||||
UISettings.storeLastSession(bookmark);
|
||||
UISettings.storeLastSession(bookmark, "B");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,9 @@ import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -32,6 +34,7 @@ import net.sf.jailer.datamodel.Table;
|
||||
import net.sf.jailer.ui.Environment;
|
||||
import net.sf.jailer.ui.databrowser.BookmarksPanel;
|
||||
import net.sf.jailer.ui.databrowser.BookmarksPanel.BookmarkId;
|
||||
import net.sf.jailer.util.Pair;
|
||||
|
||||
/**
|
||||
* Persists UI settings.
|
||||
@@ -190,14 +193,25 @@ public class UISettings {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static List<File> loadRecentFiles() {
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public static List<Pair<File, Date>> loadRecentFiles() {
|
||||
Object files = restore(RECENT_FILES);
|
||||
List<File> result = new ArrayList<File>();
|
||||
List<Pair<File, Date>> result = new ArrayList<Pair<File,Date>>();
|
||||
if (files instanceof List) {
|
||||
for (File file: (List<File>) files) {
|
||||
if (!isSbeModel(file) && !Configuration.getInstance().isTempFile(file)) {
|
||||
result.add(file);
|
||||
for (Object file: (List) files) {
|
||||
Pair<File, Date> p;
|
||||
if (file instanceof Pair) {
|
||||
p = (Pair) file;
|
||||
if (!(p.a instanceof File && p.b instanceof Date)) {
|
||||
continue;
|
||||
}
|
||||
} else if (file instanceof File) {
|
||||
p = new Pair<File, Date>((File) file, null);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
if (!isSbeModel(p.a) && !Configuration.getInstance().isTempFile(p.a)) {
|
||||
result.add(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -206,9 +220,13 @@ public class UISettings {
|
||||
|
||||
public static void addRecentFile(File file) {
|
||||
if (!isSbeModel(file) && !Configuration.getInstance().isTempFile(file)) {
|
||||
List<File> files = loadRecentFiles();
|
||||
files.remove(file);
|
||||
files.add(0, file);
|
||||
List<Pair<File, Date>> files = loadRecentFiles();
|
||||
for (Iterator<Pair<File, Date>> i = files.iterator(); i.hasNext(); ) {
|
||||
if (i.next().a.equals(file)); {
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
files.add(0, new Pair<File, Date>(file, new Date()));
|
||||
if (MAX_RECENT_LIST_SIZE < files.size()) {
|
||||
files.remove(files.size() - 1);
|
||||
}
|
||||
@@ -216,36 +234,49 @@ public class UISettings {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static List<String> loadRecentConnectionAliases() {
|
||||
Object files = restore(RECENT_ALIASES);
|
||||
List<String> result = new ArrayList<String>();
|
||||
if (files instanceof List) {
|
||||
for (String alias: (List<String>) files) {
|
||||
result.add(alias);
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public static List<Pair<String, Date>> loadRecentConnectionAliases() {
|
||||
Object aliases = restore(RECENT_ALIASES);
|
||||
List<Pair<String, Date>> result = new ArrayList<Pair<String,Date>>();
|
||||
if (aliases instanceof List) {
|
||||
for (Object alias: (List) aliases) {
|
||||
if (alias instanceof String) {
|
||||
result.add(new Pair<String, Date>((String) alias, null));
|
||||
} else if (alias instanceof Pair) {
|
||||
Pair p = (Pair) alias;
|
||||
if (p.a instanceof String && p.b instanceof Date) {
|
||||
result.add(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void addRecentConnectionAliases(String alias) {
|
||||
List<String> aliases = loadRecentConnectionAliases();
|
||||
aliases.remove(alias);
|
||||
aliases.add(0, alias);
|
||||
List<Pair<String, Date>> aliases = loadRecentConnectionAliases();
|
||||
for (Iterator<Pair<String, Date>> i = aliases.iterator(); i.hasNext(); ) {
|
||||
Pair<String, Date> next = i.next();
|
||||
if (next.a.equals(alias)) {
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
aliases.add(0, new Pair<String, Date>(alias, new Date()));
|
||||
if (MAX_RECENT_LIST_SIZE < aliases.size()) {
|
||||
aliases.remove(aliases.size() - 1);
|
||||
}
|
||||
store(RECENT_ALIASES, aliases);
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings({ "rawtypes" })
|
||||
public static List<BookmarkId> loadRecentBookmarks() {
|
||||
Object bookmarks = restore(RECENT_BOOKMARKS);
|
||||
List<BookmarkId> result = new ArrayList<BookmarkId>();
|
||||
if (bookmarks instanceof List) {
|
||||
for (BookmarkId bm: (List<BookmarkId>) bookmarks) {
|
||||
result.add(bm);
|
||||
for (Object bm: (List) bookmarks) {
|
||||
if (bm instanceof BookmarkId) {
|
||||
result.add((BookmarkId) bm);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -263,12 +294,12 @@ public class UISettings {
|
||||
}
|
||||
}
|
||||
|
||||
public static void storeLastSession(BookmarkId bookmark) {
|
||||
store(LAST_SESSION, bookmark);
|
||||
public static void storeLastSession(BookmarkId bookmark, String module) {
|
||||
store(LAST_SESSION + module, bookmark);
|
||||
}
|
||||
|
||||
public static BookmarkId restoreLastSession() {
|
||||
Object lastSession = restore(LAST_SESSION);
|
||||
public static BookmarkId restoreLastSession(String module) {
|
||||
Object lastSession = restore(LAST_SESSION + module);
|
||||
if (lastSession instanceof BookmarkId) {
|
||||
return (BookmarkId) lastSession;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user