Revision: 6639
http://squirrel-sql.svn.sourceforge.net/squirrel-sql/?rev=6639&view=rev
Author: gerdwagner
Date: 2012-07-03 21:56:59 +0000 (Tue, 03 Jul 2012)
Log Message:
-----------
Instead of displaying the file paths in Session tabs a small button is displayed when an open file exists.
Clicking the button will open a popup menu that gives access to several information and functions concerning the file.
Modified Paths:
--------------
trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/ITabDelegate.java
trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/InternalFrameDelegate.java
trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/SessionTabWidget.java
trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/TabDelegate.java
trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/TabWidget.java
trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/docktabdesktop/ButtonTabComponent.java
trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/docktabdesktop/DesktopTabbedPane.java
trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/docktabdesktop/DockTabDesktopPane.java
trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/docktabdesktop/TabHandle.java
trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/resources/SquirrelResources.java
trunk/sql12/app/src/main/resources/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/I18NStrings.properties
trunk/sql12/app/src/main/resources/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/docktabdesktop/I18NStrings.properties
trunk/sql12/app/src/main/resources/net/sourceforge/squirrel_sql/client/resources/squirrel.properties
trunk/sql12/doc/src/main/resources/changes.txt
Added Paths:
-----------
trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/TitleFilePathHandler.java
trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/TitleFilePathHandlerListener.java
trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/docktabdesktop/SmallTabButton.java
trunk/sql12/app/src/main/resources/net/sourceforge/squirrel_sql/client/resources/images/smallFile.gif
trunk/sql12/app/src/main/resources/net/sourceforge/squirrel_sql/client/resources/images/smallFileChanged.gif
Modified: trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/ITabDelegate.java
===================================================================
--- trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/ITabDelegate.java 2012-06-26 21:24:31 UTC (rev 6638)
+++ trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/ITabDelegate.java 2012-07-03 21:56:59 UTC (rev 6639)
@@ -1,7 +1,12 @@
package net.sourceforge.squirrel_sql.client.gui.desktopcontainer;
+import net.sourceforge.squirrel_sql.client.gui.desktopcontainer.docktabdesktop.SmallTabButton;
+
public interface ITabDelegate extends IDelegateBase
{
void addTabWidgetListener(WidgetListener widgetListener);
void removeTabWidgetListener(WidgetListener widgetListener);
+
+ void addSmallTabButton(SmallTabButton smallTabButton);
+ void removeSmallTabButton(SmallTabButton smallTabButton);
}
\ No newline at end of file
Modified: trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/InternalFrameDelegate.java
===================================================================
--- trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/InternalFrameDelegate.java 2012-06-26 21:24:31 UTC (rev 6638)
+++ trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/InternalFrameDelegate.java 2012-07-03 21:56:59 UTC (rev 6639)
@@ -1,5 +1,6 @@
package net.sourceforge.squirrel_sql.client.gui.desktopcontainer;
+import net.sourceforge.squirrel_sql.client.gui.desktopcontainer.docktabdesktop.SmallTabButton;
import net.sourceforge.squirrel_sql.fw.gui.GUIUtils;
import net.sourceforge.squirrel_sql.fw.gui.Dialogs;
@@ -197,7 +198,18 @@
_eventCaster.removeDialogWidgetListener(widgetListener);
}
+ @Override
+ public void addSmallTabButton(SmallTabButton fileMenuSmallButton)
+ {
+ // Not implemented
+ }
+ @Override
+ public void removeSmallTabButton(SmallTabButton smallTabButton)
+ {
+ // Not implemented
+ }
+
public void fireWidgetClosing()
{
_eventCaster.fireWidgetClosing(new WidgetEvent(new InternalFrameEvent(this, InternalFrameEvent.INTERNAL_FRAME_CLOSING), _widget));
Modified: trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/SessionTabWidget.java
===================================================================
--- trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/SessionTabWidget.java 2012-06-26 21:24:31 UTC (rev 6638)
+++ trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/SessionTabWidget.java 2012-07-03 21:56:59 UTC (rev 6639)
@@ -8,17 +8,13 @@
public abstract class SessionTabWidget extends TabWidget implements ISessionWidget
{
-
- /**
- * Internationalized strings for this class.
- */
private static final StringManager s_stringMgr =
StringManagerFactory.getStringManager(SessionTabWidget.class);
private ISession _session;
- private String _sqlFilePath;
private String _titleWithoutFile = "";
+ private TitleFilePathHandler _titleFileHandler;
public SessionTabWidget(String title, boolean resizeable, boolean closeable, boolean maximizeable, boolean iconifiable, ISession session)
{
@@ -26,6 +22,17 @@
_session = session;
_titleWithoutFile = title;
setupSheet();
+
+ TitleFilePathHandlerListener titleFilePathHandlerListener = new TitleFilePathHandlerListener()
+ {
+ @Override
+ public void refreshFileDisplay()
+ {
+ setTitle(_titleWithoutFile);
+ }
+ };
+
+ _titleFileHandler = new TitleFilePathHandler(_session.getApplication().getResources(), titleFilePathHandlerListener);
}
public SessionTabWidget(String title, boolean resizeable, ISession session)
@@ -70,30 +77,23 @@
_titleWithoutFile = title;
- if (null == _sqlFilePath)
+ if (_titleFileHandler.hasFile())
{
- super.setTitle(_titleWithoutFile);
+ String compositetitle = _titleWithoutFile + _titleFileHandler.getSqlFile();
+
+ super.setTitle(compositetitle);
+ super.addSmallTabButton(_titleFileHandler.getFileMenuSmallButton());
}
else
{
- String compositetitle =
- s_stringMgr.getString("SessionTabWidget.title",
- new String[]{_titleWithoutFile,
- _sqlFilePath});
- super.setTitle(compositetitle);
+ super.setTitle(_titleWithoutFile);
+ super.removeSmallTabButton(_titleFileHandler.getFileMenuSmallButton());
}
}
public void setSqlFile(File sqlFile)
{
- if (sqlFile == null)
- {
- _sqlFilePath = null;
- }
- else
- {
- _sqlFilePath = sqlFile.getAbsolutePath();
- }
+ _titleFileHandler.setSqlFile(sqlFile);
setTitle(_titleWithoutFile);
}
@@ -106,16 +106,17 @@
*/
public void setUnsavedEdits(boolean unsavedEdits)
{
- String title = super.getTitle();
-
- if (unsavedEdits && !title.endsWith("*"))
- {
- super.setTitle(title + "*");
- }
- if (!unsavedEdits && title.endsWith("*"))
- {
- super.setTitle(title.substring(0, title.length() - 1));
- }
+// String title = super.getTitle();
+//
+// if (unsavedEdits && !title.endsWith("*"))
+// {
+// super.setTitle(title + "*");
+// }
+// if (!unsavedEdits && title.endsWith("*"))
+// {
+// super.setTitle(title.substring(0, title.length() - 1));
+// }
+ _titleFileHandler.setUnsavedEdits(unsavedEdits);
}
/**
Modified: trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/TabDelegate.java
===================================================================
--- trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/TabDelegate.java 2012-06-26 21:24:31 UTC (rev 6638)
+++ trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/TabDelegate.java 2012-07-03 21:56:59 UTC (rev 6639)
@@ -1,9 +1,6 @@
package net.sourceforge.squirrel_sql.client.gui.desktopcontainer;
-import net.sourceforge.squirrel_sql.client.gui.desktopcontainer.docktabdesktop.TabHandle;
-import net.sourceforge.squirrel_sql.client.gui.desktopcontainer.docktabdesktop.TabHandleListener;
-import net.sourceforge.squirrel_sql.client.gui.desktopcontainer.docktabdesktop.TabHandleEvent;
-import net.sourceforge.squirrel_sql.client.gui.desktopcontainer.docktabdesktop.DockTabDesktopPane;
+import net.sourceforge.squirrel_sql.client.gui.desktopcontainer.docktabdesktop.*;
import javax.swing.*;
import javax.swing.border.Border;
@@ -161,6 +158,19 @@
}
}
+ @Override
+ public void addSmallTabButton(SmallTabButton smallTabButton)
+ {
+ _tabHandle.addSmallTabButton(smallTabButton);
+ }
+
+ @Override
+ public void removeSmallTabButton(SmallTabButton smallTabButton)
+ {
+ _tabHandle.removeSmallTabButton(smallTabButton);
+ }
+
+
public void _updateUI()
{
//To change body of implemented methods use File | Settings | File Templates.
Modified: trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/TabWidget.java
===================================================================
--- trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/TabWidget.java 2012-06-26 21:24:31 UTC (rev 6638)
+++ trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/TabWidget.java 2012-07-03 21:56:59 UTC (rev 6639)
@@ -1,6 +1,7 @@
package net.sourceforge.squirrel_sql.client.gui.desktopcontainer;
import net.sourceforge.squirrel_sql.client.IApplication;
+import net.sourceforge.squirrel_sql.client.gui.desktopcontainer.docktabdesktop.SmallTabButton;
import javax.swing.*;
import java.awt.*;
@@ -88,6 +89,17 @@
_delegate._setTitle(title);
}
+ public void addSmallTabButton(SmallTabButton fileMenuSmallButton)
+ {
+ _delegate.addSmallTabButton(fileMenuSmallButton);
+ }
+
+ public void removeSmallTabButton(SmallTabButton fileMenuSmallButton)
+ {
+ _delegate.removeSmallTabButton(fileMenuSmallButton);
+ }
+
+
public void updateUI()
{
_delegate._updateUI();
Added: trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/TitleFilePathHandler.java
===================================================================
--- trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/TitleFilePathHandler.java (rev 0)
+++ trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/TitleFilePathHandler.java 2012-07-03 21:56:59 UTC (rev 6639)
@@ -0,0 +1,219 @@
+package net.sourceforge.squirrel_sql.client.gui.desktopcontainer;
+
+import net.sourceforge.squirrel_sql.client.gui.desktopcontainer.docktabdesktop.SmallTabButton;
+import net.sourceforge.squirrel_sql.client.resources.SquirrelResources;
+import net.sourceforge.squirrel_sql.fw.util.StringManager;
+import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.datatransfer.Clipboard;
+import java.awt.datatransfer.StringSelection;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.File;
+import java.io.IOException;
+import java.util.prefs.Preferences;
+
+public class TitleFilePathHandler
+{
+ private static final StringManager s_stringMgr =
+ StringManagerFactory.getStringManager(TitleFilePathHandler.class);
+
+ private static final String PREF_KEY_TITLE_FILE_PATH_HANDLER_SHOW_FILE_NAME = "Squirrel.TitleFilePathHandler.showFileName";
+ private static final String PREF_KEY_TITLE_FILE_PATH_HANDLER_SHOW_PATH_NAME = "Squirrel.TitleFilePathHandler.showPathName";
+
+
+
+ private File _sqlFile;
+ private SquirrelResources _resources;
+ private TitleFilePathHandlerListener _titleFilePathHandlerListener;
+ private SmallTabButton _smallTabButton;
+ private JPopupMenu _popUp;
+ private JCheckBoxMenuItem _chkMnuShowFileName;
+ private JCheckBoxMenuItem _chkMnuShowFilePath;
+
+
+ public TitleFilePathHandler(SquirrelResources resources, TitleFilePathHandlerListener titleFilePathHandlerListener)
+ {
+ _resources = resources;
+ _titleFilePathHandlerListener = titleFilePathHandlerListener;
+ String msg = s_stringMgr.getString("desktopcontainer.TitleFilePathHandler.tooltip");
+ _smallTabButton = new SmallTabButton(msg, _resources.getIcon(SquirrelResources.IImageNames.SMALL_FILE));
+
+ _smallTabButton.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ showPopup();
+ }
+ });
+
+ _popUp = new JPopupMenu();
+
+ JMenuItem mnuOpenFilePath = new JMenuItem(s_stringMgr.getString("desktopcontainer.TitleFilePathHandler.openFilePath"));
+ _popUp.add(mnuOpenFilePath);
+ mnuOpenFilePath.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ onOpenFilePath();
+ }
+ });
+
+ JMenuItem mnuCopyFilePath = new JMenuItem(s_stringMgr.getString("desktopcontainer.TitleFilePathHandler.copyFilePath"));
+ _popUp.add(mnuCopyFilePath);
+ mnuCopyFilePath.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ onCopyFilePath();
+ }
+ });
+
+
+ _popUp.addSeparator();
+
+ _chkMnuShowFileName = new JCheckBoxMenuItem(s_stringMgr.getString("desktopcontainer.TitleFilePathHandler.showFileName"));
+ _popUp.add(_chkMnuShowFileName);
+ _chkMnuShowFileName.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ onChkMnuShowFileName();
+ }
+ });
+
+ _chkMnuShowFilePath = new JCheckBoxMenuItem(s_stringMgr.getString("desktopcontainer.TitleFilePathHandler.showFilePath"));
+ _popUp.add(_chkMnuShowFilePath);
+ _chkMnuShowFilePath.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ onChkMnuShowFilePath();
+ }
+ });
+
+
+ JMenuItem mnuRememberCheckboxes = new JMenuItem(s_stringMgr.getString("desktopcontainer.TitleFilePathHandler.rememberCheckBoxes"));
+ _popUp.add(mnuRememberCheckboxes);
+ mnuRememberCheckboxes.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ onRememberCheckboxes();
+ }
+ });
+
+ _chkMnuShowFileName.setSelected(Preferences.userRoot().getBoolean(PREF_KEY_TITLE_FILE_PATH_HANDLER_SHOW_FILE_NAME, false));
+ _chkMnuShowFilePath.setSelected(Preferences.userRoot().getBoolean(PREF_KEY_TITLE_FILE_PATH_HANDLER_SHOW_PATH_NAME, false));
+ }
+
+ private void onRememberCheckboxes()
+ {
+ Preferences.userRoot().putBoolean(PREF_KEY_TITLE_FILE_PATH_HANDLER_SHOW_FILE_NAME, _chkMnuShowFileName.isSelected());
+ Preferences.userRoot().putBoolean(PREF_KEY_TITLE_FILE_PATH_HANDLER_SHOW_PATH_NAME, _chkMnuShowFilePath.isSelected());
+ }
+
+ private void onChkMnuShowFilePath()
+ {
+ _chkMnuShowFileName.setSelected(false);
+ _titleFilePathHandlerListener.refreshFileDisplay();
+ }
+
+ private void onChkMnuShowFileName()
+ {
+ _chkMnuShowFilePath.setSelected(false);
+ _titleFilePathHandlerListener.refreshFileDisplay();
+ }
+
+ private void onCopyFilePath()
+ {
+ if(hasFile())
+ {
+ Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard();
+ StringSelection data = new StringSelection(_sqlFile.getAbsolutePath());
+ clip.setContents(data, data);
+ }
+ }
+
+ private void onOpenFilePath()
+ {
+ try
+ {
+ if(hasFile())
+ {
+ Desktop desktop = Desktop.getDesktop();
+ desktop.open(_sqlFile);
+ }
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private void showPopup()
+ {
+ _popUp.show(_smallTabButton, 0, 0);
+ }
+
+ public void setSqlFile(File sqlFile)
+ {
+ _sqlFile = sqlFile;
+ if(null == _sqlFile)
+ {
+ _smallTabButton.setIcon(_resources.getIcon(SquirrelResources.IImageNames.SMALL_FILE));
+ _smallTabButton.setToolTipText("");
+ }
+ else
+ {
+ _smallTabButton.setToolTipText(_sqlFile.getAbsolutePath());
+ }
+ }
+
+ public boolean hasFile()
+ {
+ return null != _sqlFile;
+ }
+
+ public String getSqlFile()
+ {
+
+ if (_chkMnuShowFilePath.isSelected())
+ {
+ return " " + s_stringMgr.getString("desktopcontainer.TitleFilePathHandler.pathDisplayPrefix", _sqlFile.getAbsolutePath());
+ }
+ else if (_chkMnuShowFileName.isSelected())
+ {
+ return " " + s_stringMgr.getString("desktopcontainer.TitleFilePathHandler.fileDisplayPrefix", _sqlFile.getName());
+ }
+ else
+ {
+ return "";
+ }
+ }
+
+ public SmallTabButton getFileMenuSmallButton()
+ {
+ return _smallTabButton;
+ }
+
+ public void setUnsavedEdits(boolean unsavedEdits)
+ {
+ if (unsavedEdits)
+ {
+ _smallTabButton.setIcon(_resources.getIcon(SquirrelResources.IImageNames.SMALL_FILE_CHANGED));
+ }
+ else
+ {
+ _smallTabButton.setIcon(_resources.getIcon(SquirrelResources.IImageNames.SMALL_FILE));
+ }
+ }
+}
Added: trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/TitleFilePathHandlerListener.java
===================================================================
--- trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/TitleFilePathHandlerListener.java (rev 0)
+++ trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/TitleFilePathHandlerListener.java 2012-07-03 21:56:59 UTC (rev 6639)
@@ -0,0 +1,6 @@
+package net.sourceforge.squirrel_sql.client.gui.desktopcontainer;
+
+public interface TitleFilePathHandlerListener
+{
+ void refreshFileDisplay();
+}
Modified: trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/docktabdesktop/ButtonTabComponent.java
===================================================================
--- trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/docktabdesktop/ButtonTabComponent.java 2012-06-26 21:24:31 UTC (rev 6638)
+++ trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/docktabdesktop/ButtonTabComponent.java 2012-07-03 21:56:59 UTC (rev 6639)
@@ -1,16 +1,22 @@
package net.sourceforge.squirrel_sql.client.gui.desktopcontainer.docktabdesktop;
+import net.sourceforge.squirrel_sql.fw.util.StringManager;
+import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
+
import javax.swing.*;
-import javax.swing.plaf.basic.BasicButtonUI;
import java.awt.*;
-import java.awt.event.*;
public class ButtonTabComponent extends JPanel
{
+ private static final StringManager s_stringMgr =
+ StringManagerFactory.getStringManager(ButtonTabComponent.class);
+
+
private final JTabbedPane _tabbedPane;
private JLabel _label = new JLabel();
- private TabButton _closeButton = new TabButton();
+ private CloseTabButton _closeButton = new CloseTabButton();
+ private JPanel _pnlSmallTabButtons;
public ButtonTabComponent(final JTabbedPane tabbedPane, String title, Icon icon)
{
@@ -27,17 +33,13 @@
//add more space between the label and the button
_label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
//add more space to the top of the component
- setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0));
- }
- JLabel getLabel()
- {
- return _label;
- }
+ _pnlSmallTabButtons = new JPanel(new FlowLayout(FlowLayout.LEFT, 2, 0));
+ _pnlSmallTabButtons.setOpaque(false);
- public JButton getButton()
- {
- return _closeButton;
+ add(_pnlSmallTabButtons);
+
+ setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0));
}
public JButton getClosebutton()
@@ -55,33 +57,29 @@
_label.setText(title);
}
- private class TabButton extends JButton //implements ActionListener
+ public void addSmallTabButton(SmallTabButton smallTabButton)
{
- public TabButton()
+ for (Component component : _pnlSmallTabButtons.getComponents())
{
- int size = 17;
- setPreferredSize(new Dimension(size, size));
- setToolTipText("close this tab");
- //Make the button looks the same for all Laf's
- setUI(new BasicButtonUI());
- //Make it transparent
- setContentAreaFilled(false);
- //No need to be focusable
- setFocusable(false);
- setBorder(BorderFactory.createEtchedBorder());
- setBorderPainted(false);
- //Making nice rollover effect
- //we use the same listener for all buttons
- addMouseListener(s_buttonMouseListener);
- setRolloverEnabled(true);
- //Close the proper tab by clicking the button
- //addActionListener(this);
+ if(component == smallTabButton)
+ {
+ return;
+ }
}
+ _pnlSmallTabButtons.add(smallTabButton);
+ }
- //we don't want to update UI for this button
- public void updateUI()
+ public void removeSmallTabButton(SmallTabButton smallTabButton)
+ {
+ _pnlSmallTabButtons.remove(smallTabButton);
+ }
+
+ private static class CloseTabButton extends SmallTabButton
+ {
+ private CloseTabButton()
{
+ super(s_stringMgr.getString("docktabdesktop.ButtonTabComponent.toolTip"), null);
}
//paint the cross
@@ -106,28 +104,5 @@
g2.dispose();
}
}
-
- private final static MouseListener s_buttonMouseListener = new MouseAdapter()
- {
- public void mouseEntered(MouseEvent e)
- {
- Component component = e.getComponent();
- if (component instanceof AbstractButton)
- {
- AbstractButton button = (AbstractButton) component;
- button.setBorderPainted(true);
- }
- }
-
- public void mouseExited(MouseEvent e)
- {
- Component component = e.getComponent();
- if (component instanceof AbstractButton)
- {
- AbstractButton button = (AbstractButton) component;
- button.setBorderPainted(false);
- }
- }
- };
}
Modified: trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/docktabdesktop/DesktopTabbedPane.java
===================================================================
--- trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/docktabdesktop/DesktopTabbedPane.java 2012-06-26 21:24:31 UTC (rev 6638)
+++ trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/docktabdesktop/DesktopTabbedPane.java 2012-07-03 21:56:59 UTC (rev 6639)
@@ -45,6 +45,18 @@
{
super.processMouseEvent(e);
}
+
+ public void addSmallTabButtonAt(int index, SmallTabButton smallTabButton)
+ {
+ ButtonTabComponent btc = (ButtonTabComponent) getTabComponentAt(index);
+ btc.addSmallTabButton(smallTabButton);
+ }
+
+ public void removeSmallTabButtonAt(int index, SmallTabButton smallTabButton)
+ {
+ ButtonTabComponent btc = (ButtonTabComponent) getTabComponentAt(index);
+ btc.removeSmallTabButton(smallTabButton);
+ }
}
Modified: trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/docktabdesktop/DockTabDesktopPane.java
===================================================================
--- trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/docktabdesktop/DockTabDesktopPane.java 2012-06-26 21:24:31 UTC (rev 6638)
+++ trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/docktabdesktop/DockTabDesktopPane.java 2012-07-03 21:56:59 UTC (rev 6639)
@@ -556,6 +556,18 @@
_tabbedPane.setTitleAt(getTabIndex(tabHandle), title);
}
+ public void addSmallTabButton(TabHandle tabHandle, SmallTabButton smallTabButton)
+ {
+ _tabbedPane.addSmallTabButtonAt(getTabIndex(tabHandle), smallTabButton);
+ }
+
+ public void removeSmallTabButton(TabHandle tabHandle, SmallTabButton smallTabButton)
+ {
+ _tabbedPane.removeSmallTabButtonAt(getTabIndex(tabHandle), smallTabButton);
+ }
+
+
+
public String getTabTitle(TabHandle tabHandle)
{
int index = getTabIndex(tabHandle);
Added: trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/docktabdesktop/SmallTabButton.java
===================================================================
--- trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/docktabdesktop/SmallTabButton.java (rev 0)
+++ trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/docktabdesktop/SmallTabButton.java 2012-07-03 21:56:59 UTC (rev 6639)
@@ -0,0 +1,113 @@
+package net.sourceforge.squirrel_sql.client.gui.desktopcontainer.docktabdesktop;
+
+import javax.swing.*;
+import javax.swing.plaf.basic.BasicButtonUI;
+import java.awt.*;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.image.BufferedImage;
+import java.awt.image.ImageObserver;
+
+
+public class SmallTabButton extends JButton
+{
+ private Icon _icon;
+
+ public SmallTabButton(String toolTipText, Icon icon)
+ {
+ _icon = icon;
+ int size = 17;
+ setPreferredSize(new Dimension(size, size));
+ setToolTipText(toolTipText);
+
+ //setIcon(icon);
+ //Make the button looks the same for all Laf's
+ setUI(new BasicButtonUI());
+ //Make it transparent
+ setContentAreaFilled(false);
+ //No need to be focusable
+ setFocusable(false);
+ setBorder(BorderFactory.createEtchedBorder());
+ setBorderPainted(false);
+ //Making nice rollover effect
+ //we use the same listener for all buttons
+ addMouseListener(s_buttonMouseListener);
+ setRolloverEnabled(true);
+ //Close the proper tab by clicking the button
+ //addActionListener(this);
+ setOpaque(false);
+ }
+
+
+ //we don't want to update UI for this button
+ public void updateUI()
+ {
+ }
+
+ private final static MouseListener s_buttonMouseListener = new MouseAdapter()
+ {
+ public void mouseEntered(MouseEvent e)
+ {
+ Component component = e.getComponent();
+ if (component instanceof AbstractButton)
+ {
+ AbstractButton button = (AbstractButton) component;
+ button.setBorderPainted(true);
+ }
+ }
+
+ public void mouseExited(MouseEvent e)
+ {
+ Component component = e.getComponent();
+ if (component instanceof AbstractButton)
+ {
+ AbstractButton button = (AbstractButton) component;
+ button.setBorderPainted(false);
+ }
+ }
+ };
+
+ protected void paintComponent(Graphics g)
+ {
+ super.paintComponent(g);
+
+ if(null == _icon)
+ {
+ return;
+ }
+
+
+ Graphics2D g2 = (Graphics2D) g.create();
+
+ if (getModel().isPressed())
+ {
+ g2.translate(1, 1);
+ }
+
+ int x = (getWidth() - _icon.getIconWidth()) / 2;
+ int y = (getHeight() - _icon.getIconHeight()) / 2;
+ g2.drawImage(iconToImage(_icon), x, y, null);
+
+
+ g2.dispose();
+ }
+
+ private Image iconToImage(Icon icon)
+ {
+ if(icon instanceof ImageIcon)
+ {
+ return ((ImageIcon) icon).getImage();
+ }
+ else
+ {
+ BufferedImage image = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_RGB);
+ icon.paintIcon(null, image.getGraphics(), 0, 0);
+ return image;
+ }
+ }
+
+
+
+
+}
Modified: trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/docktabdesktop/TabHandle.java
===================================================================
--- trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/docktabdesktop/TabHandle.java 2012-06-26 21:24:31 UTC (rev 6638)
+++ trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/docktabdesktop/TabHandle.java 2012-07-03 21:56:59 UTC (rev 6639)
@@ -8,7 +8,7 @@
public class TabHandle
{
- private JButton _closeButton;
+ //private JButton _closeButton;
private TabWidget _tabWidget;
private DockTabDesktopPane _dockTabDesktopPane;
private boolean _isSelected;
@@ -128,6 +128,17 @@
_dockTabDesktopPane.setTabTitle(this, title);
}
+ public void addSmallTabButton(SmallTabButton smallTabButton)
+ {
+ _dockTabDesktopPane.addSmallTabButton(this, smallTabButton);
+ }
+
+ public void removeSmallTabButton(SmallTabButton smallTabButton)
+ {
+ _dockTabDesktopPane.removeSmallTabButton(this, smallTabButton);
+ }
+
+
public String getTitle()
{
return _dockTabDesktopPane.getTabTitle(this);
Modified: trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/resources/SquirrelResources.java
===================================================================
--- trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/resources/SquirrelResources.java 2012-06-26 21:24:31 UTC (rev 6638)
+++ trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/resources/SquirrelResources.java 2012-07-03 21:56:59 UTC (rev 6639)
@@ -81,6 +81,9 @@
String NEXT_SCALE = "nextScale";
String RERUN = "rerun";
String CLOSE = "close";
+
+ String SMALL_FILE = "smallFile";
+ String SMALL_FILE_CHANGED = "smallFileChanged";
}
public SquirrelResources(String rsrcBundleBaseName)
Modified: trunk/sql12/app/src/main/resources/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/I18NStrings.properties
===================================================================
--- trunk/sql12/app/src/main/resources/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/I18NStrings.properties 2012-06-26 21:24:31 UTC (rev 6638)
+++ trunk/sql12/app/src/main/resources/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/I18NStrings.properties 2012-07-03 21:56:59 UTC (rev 6639)
@@ -1,4 +1,3 @@
-
SessionTabWidget.title={0} SQL file: {1}
TabbedStyleHintDlg.title=Classic User Interface layout
@@ -7,3 +6,15 @@
TabbedStyleHintDlg.dontShowAgain=Don't show this message again.
SessionStartupTimeHintDlg.yes=Yes
SessionStartupTimeHintDlg.no=No
+
+desktopcontainer.TitleFilePathHandler.tooltip=Click to to display file popup menu
+
+
+desktopcontainer.TitleFilePathHandler.openFilePath=Open file path in file manager
+desktopcontainer.TitleFilePathHandler.copyFilePath=Copy file path to clipboard
+desktopcontainer.TitleFilePathHandler.showFileName=Show file name
+desktopcontainer.TitleFilePathHandler.showFilePath=Show file path
+desktopcontainer.TitleFilePathHandler.rememberCheckBoxes=Remember checkboxes
+
+desktopcontainer.TitleFilePathHandler.fileDisplayPrefix=File: {0}
+desktopcontainer.TitleFilePathHandler.pathDisplayPrefix=Path: {0}
\ No newline at end of file
Modified: trunk/sql12/app/src/main/resources/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/docktabdesktop/I18NStrings.properties
===================================================================
--- trunk/sql12/app/src/main/resources/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/docktabdesktop/I18NStrings.properties 2012-06-26 21:24:31 UTC (rev 6638)
+++ trunk/sql12/app/src/main/resources/net/sourceforge/squirrel_sql/client/gui/desktopcontainer/docktabdesktop/I18NStrings.properties 2012-07-03 21:56:59 UTC (rev 6639)
@@ -1,2 +1,3 @@
DockFrame.autoHideToolTip=Auto hide
DockFrame.minimizeToolTip=Hide
+docktabdesktop.ButtonTabComponent.toolTip=Close this tab
\ No newline at end of file
Added: trunk/sql12/app/src/main/resources/net/sourceforge/squirrel_sql/client/resources/images/smallFile.gif
===================================================================
(Binary files differ)
Property changes on: trunk/sql12/app/src/main/resources/net/sourceforge/squirrel_sql/client/resources/images/smallFile.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/sql12/app/src/main/resources/net/sourceforge/squirrel_sql/client/resources/images/smallFileChanged.gif
===================================================================
(Binary files differ)
Property changes on: trunk/sql12/app/src/main/resources/net/sourceforge/squirrel_sql/client/resources/images/smallFileChanged.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/sql12/app/src/main/resources/net/sourceforge/squirrel_sql/client/resources/squirrel.properties
===================================================================
--- trunk/sql12/app/src/main/resources/net/sourceforge/squirrel_sql/client/resources/squirrel.properties 2012-06-26 21:24:31 UTC (rev 6638)
+++ trunk/sql12/app/src/main/resources/net/sourceforge/squirrel_sql/client/resources/squirrel.properties 2012-07-03 21:56:59 UTC (rev 6639)
@@ -68,7 +68,10 @@
rerun.image=eclipse/active/run_exc.gif
close.image=jc/close.gif
+smallFile.image=smallFile.gif
+smallFileChanged.image=smallFileChanged.gif
+
########
# icons displayed in the drivers list indicating whether
# or not driver could be loaded.
Modified: trunk/sql12/doc/src/main/resources/changes.txt
===================================================================
--- trunk/sql12/doc/src/main/resources/changes.txt 2012-06-26 21:24:31 UTC (rev 6638)
+++ trunk/sql12/doc/src/main/resources/changes.txt 2012-07-03 21:56:59 UTC (rev 6639)
@@ -9,6 +9,9 @@
Enhancements:
+Instead of displaying the file paths in Session tabs a small button is displayed when an open file exists.
+ Clicking the button will open a popup menu that gives access to several information and functions concerning the file.
+
3488629: SQL formatting can be configured. See menu File--> Global Preferences --> Tab SQL formatting
Installer: The DB Copy, DB Diff and Refactoring Plugin have been made standard Plugins.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|