Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package net.sourceforge.squirrel_sql.client.gui.desktopcontainer.docktabdesktop;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.*;
import java.awt.event.MouseEvent;
import javax.swing.Icon;
import javax.swing.*;
import javax.swing.plaf.metal.MetalTabbedPaneUI;

import net.sourceforge.squirrel_sql.client.IApplication;
import net.sourceforge.squirrel_sql.client.gui.builders.dndtabbedpane.DnDTabbedPane;
Expand All @@ -13,13 +13,32 @@

public class DesktopTabbedPane extends DnDTabbedPane
{
boolean _hideTabBar = false;
JLabel _titleLabel;

public DesktopTabbedPane(IApplication app)
{
super(app.getMultipleWindowsHandler().getOutwardDndTabbedPaneChanel());
_hideTabBar = app.getSquirrelPreferences().getUseNewFramePerConnection();
setPaintScrollArea(false);
setPaintGhost(true);

GUIUtils.listenToMouseWheelClickOnTab(this, (tabIndex, tabComponent) -> ((ButtonTabComponent)tabComponent).doClickClose());
setUI(new MetalTabbedPaneUI() {
@Override
protected void paintContentBorder(Graphics g, int tabPlacement, int selectedIndex) {
if (!_hideTabBar) {
super.paintContentBorder(g, tabPlacement, selectedIndex);
}
}
@Override
protected int calculateTabAreaHeight(int tab_placement, int run_count, int max_tab_height) {
if (_hideTabBar && DesktopTabbedPane.this.getTabCount() <= 1) {
return 0;
} else {
return super.calculateTabAreaHeight(tab_placement, run_count, max_tab_height);
}
}
});
GUIUtils.listenToMouseWheelClickOnTab(this, (tabIndex, tabComponent) -> ((ButtonTabComponent)tabComponent).doClickClose());
}


Expand All @@ -40,6 +59,7 @@ public void setTitleAt(int index, String title)
{
ButtonTabComponent btc = (ButtonTabComponent) getTabComponentAt(index);
btc.setTitle(title);
_titleLabel.setText(title.replaceAll("^[0-9]* - ", ""));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public enum TabClosingMode

private DockPanel _pnlDock = new DockPanel();

private JPanel _titlePanel = new JPanel(new BorderLayout());
private JLabel _titleLabel = new JLabel();
private DesktopTabbedPane _tabbedPane;

private JSplitPane _split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
Expand All @@ -58,10 +60,12 @@ public enum TabClosingMode
private DockTabDesktopManager _dockTabDesktopManager = new DockTabDesktopManager();

private ScrollableTabHandler _scrollableTabHandler;
private boolean _useNewFramePerConnection = false;

public DockTabDesktopPane(IApplication app, boolean belongsToMainApplicationWindow, DockTabDesktopPaneListener dockTabDesktopPaneListener)
{
_app = app;
_useNewFramePerConnection = app.getSquirrelPreferences().getUseNewFramePerConnection();
_belongsToMainApplicationWindow = belongsToMainApplicationWindow;
_dockTabDesktopPaneListener = dockTabDesktopPaneListener;

Expand All @@ -85,7 +89,15 @@ public void stateChanged(ChangeEvent e)
}
});

_split.setRightComponent(_tabbedPane);
_tabbedPane._titleLabel = _titleLabel;
if (_useNewFramePerConnection && !belongsToMainApplicationWindow) {
_titleLabel.setHorizontalAlignment(SwingConstants.CENTER);
_titlePanel.add(_tabbedPane, BorderLayout.CENTER);
_titlePanel.add(_titleLabel, BorderLayout.NORTH);
_split.setRightComponent(_titlePanel);
} else {
_split.setRightComponent(_tabbedPane);
}


add(_split, BorderLayout.CENTER);
Expand Down Expand Up @@ -216,6 +228,9 @@ public void actionPerformed(ActionEvent e)
_tabbedPane.setSelectedIndex(tabIx);
_scrollableTabHandler.tabAdded();

if (_belongsToMainApplicationWindow && _useNewFramePerConnection) {
onToWindow(tabHandle);
}
return tabHandle;
}

Expand All @@ -232,7 +247,7 @@ private void onToWindow(TabHandle tabHandle)
Dimension size = getSelectedHandle().getWidget().getContentPane().getSize();
//
////////////////////////////////////////////////////////////////////////////////////
TabWindowController tabWindowController = new TabWindowController(locationOnScreen, size, _app);
TabWindowController tabWindowController = new TabWindowController(_titleLabel.getText(), locationOnScreen, size, _app);


_app.getMultipleWindowsHandler().registerDesktop(tabWindowController);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,16 @@ public class TabWindowController implements DockTabDesktopPaneHolder
private IApplication _app;
private final JMenu _mnuSession;
private final JFrame _tabWindowFrame;
String _title;

private static class MoveTabBackToMainWinMarker {}

public TabWindowController(Point locationOnScreen, Dimension size, final IApplication app)
public TabWindowController(String title, Point locationOnScreen, Dimension size, final IApplication app)
{
// Kind of a hack, would be better if the title code was refactored
_title = title.replaceAll("^[0-9]* - ", "");
_app = app;
_tabWindowFrame = new JFrame(_app.getMainFrame().getTitle() + " " +s_stringMgr.getString("docktabdesktop.TabWindowController.titlePostFix"));
_tabWindowFrame = new JFrame(title);

_tabWindowFrame.setLocation(locationOnScreen);
_tabWindowFrame.setSize(size);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ final class GeneralPreferencesGUI extends JPanel
private static final StringManager s_stringMgr = StringManagerFactory.getStringManager(GeneralPreferencesGUI.class);

private JRadioButton _tabbedStyle = new JRadioButton(s_stringMgr.getString("GeneralPreferencesPanel.tabbedStyle"));
private JRadioButton _internalFrameStyle = new JRadioButton(s_stringMgr.getString("GeneralPreferencesPanel.internalFrameStyle"));
private JRadioButton _internalFrameStyle = new JRadioButton(s_stringMgr.getString("GeneralPreferencesPanel.internalFrameStyle"));
private JRadioButton _useNewFramePerConnection = new JRadioButton(s_stringMgr.getString("GeneralPreferencesPanel.useNewFramePerConnection"));
private JCheckBox _useScrollableTabbedPanesForSessionTabs = new JCheckBox(s_stringMgr.getString("GeneralPreferencesPanel.useScrollableTabbedPanesForSessionTabs"));
private JCheckBox _showContents = new JCheckBox(s_stringMgr.getString("GeneralPreferencesPanel.showwindowcontents"));
private JCheckBox _maximimizeSessionSheet = new JCheckBox(s_stringMgr.getString("GeneralPreferencesPanel.maxonopen"));
Expand Down Expand Up @@ -82,9 +83,18 @@ final class GeneralPreferencesGUI extends JPanel

void loadData(SquirrelPreferences prefs)
{
_tabbedStyle.setSelected(prefs.getTabbedStyle());
if (prefs.getUseNewFramePerConnection())
{
_useNewFramePerConnection.setSelected(true);
_tabbedStyle.setSelected(false);
_internalFrameStyle.setSelected(false);
}
else {
_tabbedStyle.setSelected(prefs.getTabbedStyle());
_internalFrameStyle.setSelected(!prefs.getTabbedStyle());
_useNewFramePerConnection.setSelected(false);
}
_useScrollableTabbedPanesForSessionTabs.setSelected(prefs.getUseScrollableTabbedPanesForSessionTabs());
_internalFrameStyle.setSelected(!prefs.getTabbedStyle());
onStyleChanged();
_showTabbedStyleHint.setSelected(prefs.getShowTabbedStyleHint());

Expand Down Expand Up @@ -122,8 +132,8 @@ void loadData(SquirrelPreferences prefs)
LocaleWrapper.setSelectedLocalePrefsString(_localeChooser, prefs.getPreferredLocale());

_tabbedStyle.addActionListener(e -> onStyleChanged());

_internalFrameStyle.addActionListener(e -> onStyleChanged());
_useNewFramePerConnection.addActionListener(e -> onStyleChanged());

_messagePrefsCtrl.loadData(prefs);

Expand All @@ -142,7 +152,13 @@ private void onStyleChanged()

void applyChanges(SquirrelPreferences prefs)
{
prefs.setTabbedStyle(_tabbedStyle.isSelected());
if (_useNewFramePerConnection.isSelected()) {
prefs.setUseNewFramePerConnection(true);
prefs.setTabbedStyle(true);
} else {
prefs.setUseNewFramePerConnection(false);
prefs.setTabbedStyle(_tabbedStyle.isSelected());
}
prefs.setUseScrollableTabbedPanesForSessionTabs(_useScrollableTabbedPanesForSessionTabs.isSelected());
prefs.setShowContentsWhenDragging(_showContents.isSelected());
prefs.setShowTabbedStyleHint(_showTabbedStyleHint.isSelected());
Expand Down Expand Up @@ -211,6 +227,7 @@ private JPanel createAppearancePanel()

g.add(_tabbedStyle);
g.add(_internalFrameStyle);
g.add(_useNewFramePerConnection);
final GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(2, 4, 2, 4);
Expand All @@ -225,6 +242,9 @@ private JPanel createAppearancePanel()
_internalFrameStyle.setName("internalFrameStyleRadioButton");
pnl.add(_internalFrameStyle, gbc);
++gbc.gridy;
_useNewFramePerConnection.setName("useNewFramePerConnectionRadioButton");
pnl.add(_useNewFramePerConnection, gbc);
++gbc.gridy;

_useScrollableTabbedPanesForSessionTabs.setName("useScrollableTabbedPanes");
pnl.add(_useScrollableTabbedPanesForSessionTabs, gbc);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ GeneralPreferencesPanel.tabbedStyle=Use tabbed layout (needs restart)
GeneralPreferencesPanel.useScrollableTabbedPanesForSessionTabs=Use scrollable tabbed panes for Session tabs (needs restart)
GeneralPreferencesPanel.internalFrameStyle=Use MDI/Internal Frame layout (needs restart)
GeneralPreferencesPanel.showTabbedStyleHint=Warn MDI/Internal Frame layout is deprecated
GeneralPreferencesPanel.useNewFramePerConnection=Use new Frame per connection (needs restart)

GeneralPreferencesPanel.savePreferencesImmediatelyWarning_new=Warning:\nSaving Aliases and Drivers immediately may significantly slow down\nediting Aliases and Drivers if many Aliases or Drivers exist.\nSaving Preferences immediately may significantly slow down SQL execution\nif multiple statements are executed or if SQL history size is big\n(see menu 'New Session Properties' --> tab 'SQL' --> SQL History).

Expand All @@ -153,4 +154,4 @@ SQLPreferencesPanel.reload.changetrack.hint=Note: When the change tracking toolb

SQLPreferencesPanel.notify.external.file.changes=Notify external file changes (requires application restart)

SQLPreferencesPanel.use.statement.separator.as.current.bounds=Use statement separator (instead of empty line) as bounds of current SQL
SQLPreferencesPanel.use.statement.separator.as.current.bounds=Use statement separator (instead of empty line) as bounds of current SQL
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public interface IPropertyNames
String SHOW_ALIASES_TOOL_BAR = "showAliasesToolBar";
String SHOW_CONTENTS_WHEN_DRAGGING = "showContentsWhenDragging";
String TABBED_STYLE = "tabbedStyle";
String USE_NEW_FRAME_PER_CONNECTION = "useNewFramePerConnection";
String USE_SCROLLABLE_TABBED_PANES_FOR_SESSION_TABS = "useScrollableTabbedPanesForSessionTabs";
String SHOW_TABBED_STYLE_HINT = "showTabbedStyleHint";
String SHOW_DRIVERS_TOOL_BAR = "showDriversToolBar";
Expand Down Expand Up @@ -188,6 +189,8 @@ public interface IJdbcDebugTypes

private boolean _tabbedStyle = true;

private boolean _useNewFramePerConnection = false;

private boolean _useScrollableTabbedPanesForSessionTabs;

private boolean _showTabbedStyleHint = true;
Expand Down Expand Up @@ -424,7 +427,12 @@ public boolean getTabbedStyle()
return _tabbedStyle;
}

public synchronized void setTabbedStyle(boolean data)
public boolean getUseNewFramePerConnection()
{
return _useNewFramePerConnection;
}

public synchronized void setTabbedStyle(boolean data)
{
if (data != _tabbedStyle)
{
Expand All @@ -435,6 +443,17 @@ public synchronized void setTabbedStyle(boolean data)
}
}

public synchronized void setUseNewFramePerConnection(boolean data)
{
if (data != _useNewFramePerConnection)
{
final boolean oldValue = _useNewFramePerConnection;
_useNewFramePerConnection = data;
getPropertyChangeReporter().firePropertyChange(IPropertyNames.USE_NEW_FRAME_PER_CONNECTION,
oldValue, _useNewFramePerConnection);
}
}

public boolean getUseScrollableTabbedPanesForSessionTabs()
{
return _useScrollableTabbedPanesForSessionTabs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public PropertyDescriptor[] getPropertyDescriptors()
prop(SHOW_CONTENTS_WHEN_DRAGGING, SquirrelPreferences.class, "getShowContentsWhenDragging", "setShowContentsWhenDragging"),

prop(TABBED_STYLE, SquirrelPreferences.class, "getTabbedStyle", "setTabbedStyle"),
prop(USE_NEW_FRAME_PER_CONNECTION, SquirrelPreferences.class, "getUseNewFramePerConnection", "setUseNewFramePerConnection"),
prop(USE_SCROLLABLE_TABBED_PANES_FOR_SESSION_TABS, SquirrelPreferences.class, "getUseScrollableTabbedPanesForSessionTabs", "setUseScrollableTabbedPanesForSessionTabs"),
prop(SHOW_TABBED_STYLE_HINT, SquirrelPreferences.class, "getShowTabbedStyleHint", "setShowTabbedStyleHint"),

Expand Down