Skip to content

Commit 29bd306

Browse files
committed
Feature: #54
Object Tree: Content tabs now show the number of rows. If the number of rows is limited, the display indicates this, and the limited number of rows is written in red. To configure the row limit for content tabs see menu File --> New Session Properties --> tab "Object Tree"
1 parent 492e8a3 commit 29bd306

File tree

11 files changed

+227
-127
lines changed

11 files changed

+227
-127
lines changed

sql12/core/doc/changes.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ Not yet released, available in our GIT repository, snapshots and future releases
66

77
Enhancements:
88

9+
https://github.com/squirrel-sql-client/squirrel-sql-code/issues/54
10+
Object Tree: Content tabs now show the number of rows.
11+
If the number of rows is limited, the display indicates this,
12+
and the limited number of rows is written in red.
13+
To configure the row limit for content tabs see menu File --> New Session Properties --> tab "Object Tree"
14+
915
Updated the following Look and Feels to their latest versions:
1016
FlatLaf, Radiance, JTattoo, Nimrod, Kunstoff
1117

sql12/core/src/net/sourceforge/squirrel_sql/client/session/mainpanel/objecttree/ObjectTreeTabbedPane.java

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@
1717
* License along with this library; if not, write to the Free Software
1818
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1919
*/
20-
import java.awt.Dimension;
21-
import java.util.ArrayList;
22-
import java.util.Iterator;
23-
import java.util.List;
24-
25-
import javax.swing.JTabbedPane;
2620

2721
import net.sourceforge.squirrel_sql.client.IApplication;
2822
import net.sourceforge.squirrel_sql.client.gui.builders.UIFactory;
@@ -32,6 +26,14 @@
3226
import net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo;
3327
import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
3428
import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
29+
30+
import javax.swing.JPanel;
31+
import javax.swing.JTabbedPane;
32+
import java.awt.BorderLayout;
33+
import java.awt.Dimension;
34+
import java.util.ArrayList;
35+
import java.util.Iterator;
36+
import java.util.List;
3537
/**
3638
* This is the tabbed panel displayed when a node is selected in the
3739
* object tree.
@@ -102,38 +104,43 @@ IObjectTab getSelectedTab() {
102104
IObjectTab tab = _tabs.get(_tabPnl.getSelectedIndex());
103105
return tab;
104106
}
105-
107+
106108
synchronized void addObjectPanelTab(IObjectTab tab)
107109
{
108-
if (tab == null)
110+
if(tab == null)
109111
{
110112
throw new IllegalArgumentException("Null IObjectTab passed");
111113
}
112-
// For some reason, when the Oracle plugin adds details tabs for
113-
// triggers, the _tabPnl's first tab ends up being the trigger details
114-
// tab and not the generic database object info tab. This causes the
115-
// _tabs length to be 1 tab greater than the tabs that are actually in
116-
// the _tabPnl. This throws off the selection such that the tab
117-
// selected in the tab panel doesn't get rendered until the tab to the
118-
// right of the selected tab is selected. This is a work-around for
119-
// this problem until I can determine why the DatabaseObjectInfoTab
120-
// never makes it into the _tabPnl in the first place.
121-
if (_tabs.size() == 1 && _tabPnl.getTabCount() == 0) {
122-
log.debug(
123-
"addObjectPanelTab: _tabs.size() == 1, but " +
124-
"_tabPnl.getTabCount() == 0 - adding first tab component to " +
125-
"the tabbed page");
126-
IObjectTab firstTab = _tabs.get(0);
127-
_tabPnl.addTab(firstTab.getTitle(),
128-
null,
129-
firstTab.getComponent(),
130-
firstTab.getHint());
131-
}
132-
133-
tab.setSession(_app.getSessionManager().getSession(_sessionId));
134-
final String title = tab.getTitle();
135-
_tabPnl.addTab(title, null, tab.getComponent(), tab.getHint());
136-
_tabs.add(tab);
114+
// For some reason, when the Oracle plugin adds details tabs for
115+
// triggers, the _tabPnl's first tab ends up being the trigger details
116+
// tab and not the generic database object info tab. This causes the
117+
// _tabs length to be 1 tab greater than the tabs that are actually in
118+
// the _tabPnl. This throws off the selection such that the tab
119+
// selected in the tab panel doesn't get rendered until the tab to the
120+
// right of the selected tab is selected. This is a work-around for
121+
// this problem until I can determine why the DatabaseObjectInfoTab
122+
// never makes it into the _tabPnl in the first place.
123+
if(_tabs.size() == 1 && _tabPnl.getTabCount() == 0)
124+
{
125+
log.debug( "addObjectPanelTab: _tabs.size() == 1, but _tabPnl.getTabCount() == 0 - adding first tab component to the tabbed page");
126+
IObjectTab firstTab = _tabs.get(0);
127+
_tabPnl.addTab(firstTab.getTitle(), null,firstTab.getComponent(),firstTab.getHint());
128+
}
129+
130+
tab.setSession(_app.getSessionManager().getSession(_sessionId));
131+
final String title = tab.getTitle();
132+
if(null == tab.getHeaderComponent())
133+
{
134+
_tabPnl.addTab(title, null, tab.getComponent(), tab.getHint());
135+
}
136+
else
137+
{
138+
JPanel pnlIncludingHeader = new JPanel(new BorderLayout());
139+
pnlIncludingHeader.add(tab.getHeaderComponent(), BorderLayout.NORTH);
140+
pnlIncludingHeader.add(tab.getComponent(), BorderLayout.CENTER);
141+
_tabPnl.addTab(title, null, pnlIncludingHeader);
142+
}
143+
_tabs.add(tab);
137144
}
138145

139146
void selectCurrentTab()

sql12/core/src/net/sourceforge/squirrel_sql/client/session/mainpanel/objecttree/tabs/BaseDataSetTab.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* License along with this library; if not, write to the Free Software
1818
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1919
*/
20+
import net.sourceforge.squirrel_sql.client.Main;
2021
import net.sourceforge.squirrel_sql.client.session.DataModelImplementationDetails;
2122
import net.sourceforge.squirrel_sql.client.session.ISession;
2223
import net.sourceforge.squirrel_sql.fw.datasetviewer.DataSetException;
@@ -26,6 +27,8 @@
2627
import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
2728
import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
2829

30+
import java.awt.Component;
31+
2932
public abstract class BaseDataSetTab extends BaseObjectTab
3033
{
3134
/** Logger for this class. */
@@ -37,7 +40,6 @@ public abstract class BaseDataSetTab extends BaseObjectTab
3740

3841
public BaseDataSetTab()
3942
{
40-
super();
4143
}
4244

4345
/**
@@ -89,6 +91,12 @@ public synchronized DataSetScrollingPanel getComponent()
8991
return _comp;
9092
}
9193

94+
@Override
95+
public Component getHeaderComponent()
96+
{
97+
return null;
98+
}
99+
92100
/**
93101
* Rebuild the tab. This usually means that some kind of configuration
94102
* data has changed (I.E. the output type has changed from text to table).
@@ -121,7 +129,7 @@ public synchronized void refreshComponent() throws DataSetException
121129
throw new IllegalStateException("Null ISession");
122130
}
123131

124-
super._app.getThreadPool().addTask(() -> {
132+
Main.getApplication().getThreadPool().addTask(() -> {
125133
try
126134
{
127135
getComponent().load(createDataSet(), new DataModelImplementationDetails(session));

sql12/core/src/net/sourceforge/squirrel_sql/client/session/mainpanel/objecttree/tabs/BaseObjectTab.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1919
*/
2020

21-
import net.sourceforge.squirrel_sql.client.IApplication;
21+
import net.sourceforge.squirrel_sql.client.Main;
2222
import net.sourceforge.squirrel_sql.client.session.ISession;
2323
import net.sourceforge.squirrel_sql.fw.datasetviewer.DataSetException;
2424
import net.sourceforge.squirrel_sql.fw.dialects.DialectFactory;
@@ -35,12 +35,7 @@
3535
*/
3636
public abstract class BaseObjectTab implements IObjectTab
3737
{
38-
/** Logger for this class. */
39-
private static final ILogger s_log =
40-
LoggerController.createLogger(BaseObjectTab.class);
41-
42-
/** Application API. */
43-
protected IApplication _app;
38+
private static final ILogger s_log = LoggerController.createLogger(BaseObjectTab.class);
4439

4540
/** Current session. */
4641
// private ISession _session;
@@ -71,7 +66,6 @@ public void setSession(ISession session) throws IllegalArgumentException
7166
{
7267
throw new IllegalArgumentException("Null ISession passed");
7368
}
74-
_app = session.getApplication();
7569
_sessionId = session.getIdentifier();
7670
}
7771

@@ -82,7 +76,7 @@ public void setSession(ISession session) throws IllegalArgumentException
8276
*/
8377
public final ISession getSession()
8478
{
85-
return _app.getSessionManager().getSession(_sessionId);
79+
return Main.getApplication().getSessionManager().getSession(_sessionId);
8680
}
8781

8882
/**

sql12/core/src/net/sourceforge/squirrel_sql/client/session/mainpanel/objecttree/tabs/BasePreparedStatementTab.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ public Component getComponent()
114114
return _comp;
115115
}
116116

117+
@Override
118+
public Component getHeaderComponent()
119+
{
120+
return null;
121+
}
122+
117123
protected void refreshComponent() throws DataSetException
118124
{
119125
if(getDatabaseObjectInfo().getDatabaseObjectType().isContainerNode())

sql12/core/src/net/sourceforge/squirrel_sql/client/session/mainpanel/objecttree/tabs/BaseSourceTab.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
2828
import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
2929

30-
import javax.swing.*;
30+
import javax.swing.JScrollPane;
3131
import javax.swing.text.JTextComponent;
32-
import java.awt.*;
32+
import java.awt.Component;
3333
import java.sql.PreparedStatement;
3434
import java.sql.ResultSet;
3535
import java.sql.SQLException;
@@ -129,6 +129,12 @@ public Component getComponent()
129129
return _textFindCtrl.getContainerPanel();
130130
}
131131

132+
@Override
133+
public Component getHeaderComponent()
134+
{
135+
return null;
136+
}
137+
132138
protected void refreshComponent()
133139
{
134140
ISession session = getSession();

sql12/core/src/net/sourceforge/squirrel_sql/client/session/mainpanel/objecttree/tabs/IObjectTab.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
* License along with this library; if not, write to the Free Software
1818
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1919
*/
20-
import java.awt.Component;
2120

21+
import net.sourceforge.squirrel_sql.client.session.ISession;
2222
import net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo;
2323

24-
import net.sourceforge.squirrel_sql.client.session.ISession;
24+
import java.awt.Component;
2525
/**
2626
* This interface defines the behaviour for a tab in one of the object panels.
2727
*
@@ -50,6 +50,8 @@ public interface IObjectTab
5050
*/
5151
Component getComponent();
5252

53+
Component getHeaderComponent();
54+
5355
/**
5456
* Set the current session.
5557
*

0 commit comments

Comments
 (0)