Skip to content

Commit

Permalink
Introduction of the "ConnectionType" concept. First steps.
Browse files Browse the repository at this point in the history
  • Loading branch information
Wisser committed Nov 3, 2023
1 parent 195badc commit 4801019
Show file tree
Hide file tree
Showing 11 changed files with 451 additions and 34 deletions.
9 changes: 8 additions & 1 deletion src/main/engine/net/sf/jailer/JailerVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class JailerVersion {
/**
* The Jailer version.
*/
public static final String VERSION = "15.2.5.2";
public static final String VERSION = "15.2.5.3";

/**
* The Jailer working tables version.
Expand All @@ -45,3 +45,10 @@ public static void main(String[] args) {
}

}


// TODO
// TODO DBConDialog: copy/import creditials mit "Verbindungstyp"

// TODO
// TODO DBConDialog: copy/import creditials: 1. tooltip + "connection-credentials"? 2. tooltip: "paste here"? ???
31 changes: 26 additions & 5 deletions src/main/gui/net/sf/jailer/ui/DataModelManagerDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,7 @@ private void initRestoreLastSessionButton() {
}

List<String> model = new ArrayList<String>();
Map<String, String> ttipSuffix = new HashMap<>();
List<ImageIcon> logos = new ArrayList<ImageIcon>();
List<ActionListener> actions = new ArrayList<ActionListener>();

Expand Down Expand Up @@ -929,7 +930,17 @@ private void initRestoreLastSessionButton() {
logos.add(UIUtil.scaleIcon(new JLabel(), UIUtil.readImage(dbmsLogoURL, false), 1.0));
}

model.add("<html><nobr>" +
String bgc = "";
if (connectionInfo != null && connectionInfo.getConnectionType().getBg1() != null) {
bgc = Integer.toHexString(connectionInfo.getConnectionType().getBg1().getRGB() & 0xffffff);
while (bgc.length() < 6) {
bgc = "0" + bgc;
}
bgc = "<font bgcolor=\"#" + bgc + "\" color=\"#000000\">" + connectionInfo.getConnectionType().displayName + "</font>";
}

String v;
model.add(v = "<html><nobr>" +
UIUtil.toHTMLFragment(UIUtil.toDateAsString(lastSession.date.getTime()), 0) + "&nbsp;-&nbsp;" +
(module.equals("S")?
"<font color=\"#0000ff\"><b>" +
Expand All @@ -940,12 +951,12 @@ private void initRestoreLastSessionButton() {
("<font color=\"#006600\">" +
UIUtil.toHTMLFragment(((details != null? details.a : lastSession.datamodelFolder)), 0) +
"</font>&nbsp;-&nbsp;<font color=\"#663300\">" +
(connectionInfo == null? "<i><font color=\"#888888\">offline</font></i>" : UIUtil.toHTMLFragment(connectionInfo.alias, 0) + "&nbsp;-&nbsp;<font color=\"#000000\">" + UIUtil.toHTMLFragment(((userName + " - ") + connectionInfo.url), 0, false) + "</font>") +
(connectionInfo == null? "<i><font color=\"#888888\">offline</font></i>" : UIUtil.toHTMLFragment(connectionInfo.alias, 0) + "&nbsp;-&nbsp;<font color=\"#000000\">" + UIUtil.toHTMLFragment(((userName + " - ")), 0, false) + UIUtil.toHTML(connectionInfo.url, 0) + "</font>") +
"</font></nobr></html>")
:
(
"<font color=\"#006600\">" +
(connectionInfo == null? "<i><font color=\"#888888\">offline</font></i>" : ("<b>" + UIUtil.toHTMLFragment(connectionInfo.alias, 0) + "</b>") + "&nbsp;-&nbsp;<font color=\"#000000\">" +
(connectionInfo == null? "<i><font color=\"#888888\">offline</font></i>" : ("<b>" + UIUtil.toHTML(connectionInfo.alias, 0) + "</b>") + "&nbsp;-&nbsp;<font color=\"#000000\">" +
"<font color=\"#0000ff\">" +
(lastSession.getContentInfo() != null? UIUtil.toHTMLFragment(lastSession.getContentInfo().replaceFirst("^\\d+ Table$", "$0s"), 0) + "&nbsp;-&nbsp;" : "") +
"</font>" +
Expand All @@ -955,6 +966,8 @@ private void initRestoreLastSessionButton() {
"</font>")
) +
"</nobr></html>");
ttipSuffix.put(v, "<br>" + bgc);

final ConnectionInfo finalConnectionInfo = connectionInfo;
actions.add(new ActionListener() {
@Override
Expand Down Expand Up @@ -1035,7 +1048,11 @@ public Component getListCellRendererComponent(JList<?> list, Object value, int i
Component render = renderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
String tooltip = null;
if (render instanceof JLabel) {
((JLabel) render).setToolTipText(tooltip = ((JLabel) render).getText().replace("&nbsp;-&nbsp;", "<br>"));
tooltip = ((JLabel) render).getText().replace("&nbsp;-&nbsp;", "<br>");
if (ttipSuffix.containsKey(((JLabel) render).getText())) {
tooltip = tooltip.replaceFirst("</nobr></html>", ttipSuffix.get(((JLabel) render).getText()) + "</nobr></html>").replace("</font>", "");
}
((JLabel) render).setToolTipText(tooltip);
if (isSelected) {
((JLabel) render).setText(((JLabel) render).getText().replaceAll("<.?font[^>]*>", ""));
}
Expand Down Expand Up @@ -1080,7 +1097,11 @@ public Component getListCellRendererComponent(JList<?> list, Object value, int i
return render;
}
});
recentSessionsComboBox.setToolTipText(model.get(0).replace("&nbsp;-&nbsp;", "<br>"));
String tooltip = model.get(0).replace("&nbsp;-&nbsp;", "<br>");
if (ttipSuffix.containsKey(model.get(0))) {
tooltip = tooltip.replaceFirst("</nobr></html>", ttipSuffix.get(model.get(0)) + "</nobr></html>").replace("</font>", "");
}
recentSessionsComboBox.setToolTipText(tooltip);
}

private void hideRecentSessionsPanel() {
Expand Down
32 changes: 31 additions & 1 deletion src/main/gui/net/sf/jailer/ui/DbConnectionDetailsEditor.form
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-6,0,0,1,-91"/>
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,95,0,0,1,-91"/>
</AuxValues>

<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
Expand Down Expand Up @@ -622,6 +622,36 @@
</Container>
</SubComponents>
</Container>
<Component class="javax.swing.JLabel" name="jLabel13">
<Properties>
<Property name="text" type="java.lang.String" value=" Type"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="81" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="2" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JComboBox" name="typeComboBox">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="4">
<StringItem index="0" value="Item 1"/>
<StringItem index="1" value="Item 2"/>
<StringItem index="2" value="Item 3"/>
<StringItem index="3" value="Item 4"/>
</StringArray>
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;String&gt;"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="2" gridY="81" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="2" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
</Container>
</SubComponents>
Expand Down
50 changes: 50 additions & 0 deletions src/main/gui/net/sf/jailer/ui/DbConnectionDetailsEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
Expand All @@ -83,7 +84,9 @@

import net.sf.jailer.ExecutionContext;
import net.sf.jailer.ui.DbConnectionDialog.ConnectionInfo;
import net.sf.jailer.ui.DbConnectionDialog.ConnectionType;
import net.sf.jailer.ui.UIUtil.PLAF;
import net.sf.jailer.ui.databrowser.DBConditionEditor;
import net.sf.jailer.ui.util.ConcurrentTaskControl;
import net.sf.jailer.ui.util.HttpDownload;
import net.sf.jailer.ui.util.LightBorderSmallButton;
Expand Down Expand Up @@ -235,6 +238,7 @@ public void setDetails(ConnectionInfo ci) {
user.setText(ci.user);
password.setText(ci.password);
driverClass.setText(ci.driverClass);
typeComboBox.setSelectedItem(ci.getConnectionType());
jar1.setText(ci.jar1);
jar2.setText(ci.jar2);
jar3.setText(ci.jar3);
Expand Down Expand Up @@ -323,6 +327,31 @@ public DbConnectionDetailsEditor(Window parent, final String jdbcHelpURL, boolea
this.needsTest = needsTest;
this.dataModelAware = dataModelAware;
initComponents(); UIUtil.initComponents(this);

typeComboBox.setModel(new DefaultComboBoxModel(DbConnectionDialog.ConnectionType.values()));
Color dbg = typeComboBox.getBackground();
typeComboBox.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected,
boolean cellHasFocus) {
Component render = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof ConnectionType && render instanceof JLabel) {
if (!isSelected) {
Color b1 = ((ConnectionType) value).getBg1();
render.setBackground(b1 == null? dbg : b1);
render.setForeground(Color.black);
}
}
return render;
}
});
typeComboBox.addItemListener(e -> {
if (typeComboBox.getSelectedItem() != null) {
Color b1 = ((ConnectionType) typeComboBox.getSelectedItem()).getBg1();
typeComboBox.setBackground(b1 == null? dbg : b1);
}
});

newDataModelButton.setVisible(!dataModelAware);
ImageIcon scaledWarnIcon = UIUtil.scaleIcon(jtdsWarnLabel, warnIcon, 1);
jtdsWarnLabel.setIcon(scaledWarnIcon);
Expand Down Expand Up @@ -898,6 +927,8 @@ private void initComponents() {
dataModelComboBox = new javax.swing.JComboBox<>();
newDataModelButton = new javax.swing.JButton();
jPanel11 = new javax.swing.JPanel();
jLabel13 = new javax.swing.JLabel();
typeComboBox = new javax.swing.JComboBox<>();

helpjdbc.setText("help");

Expand Down Expand Up @@ -1404,6 +1435,22 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
gridBagConstraints.insets = new java.awt.Insets(2, 0, 0, 0);
jPanel1.add(jPanel10, gridBagConstraints);

jLabel13.setText(" Type");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 81;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(2, 0, 0, 0);
jPanel1.add(jLabel13, gridBagConstraints);

typeComboBox.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 81;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(2, 0, 0, 0);
jPanel1.add(typeComboBox, gridBagConstraints);

gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 1;
Expand Down Expand Up @@ -1468,6 +1515,7 @@ private boolean fillConnectionInfo() {
ci.user = user.getText().trim();
ci.password = password.getText().trim();
ci.dataModelFolder = (String) dataModelComboBox.getSelectedItem();
ci.setConnectionType((ConnectionType) typeComboBox.getSelectedItem());
}
return ok;
}
Expand Down Expand Up @@ -1816,6 +1864,7 @@ protected void onSelect() {
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
Expand Down Expand Up @@ -1853,6 +1902,7 @@ protected void onSelect() {
private javax.swing.JButton renameButton;
private javax.swing.JButton selectConnectionButton;
private javax.swing.JButton testConnectionButton;
private javax.swing.JComboBox<String> typeComboBox;
public javax.swing.JTextField user;
// End of variables declaration//GEN-END:variables

Expand Down
Loading

0 comments on commit 4801019

Please sign in to comment.