Revision: 6276
http://squirrel-sql.svn.sourceforge.net/squirrel-sql/?rev=6276&view=rev
Author: wis775
Date: 2011-05-28 19:52:34 +0000 (Sat, 28 May 2011)
Log Message:
-----------
Feature Request: 3307812: Select an entire row via the table's pop-up menu.
Modified Paths:
--------------
trunk/sql12/doc/src/main/resources/changes.txt
trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/gui/TablePopupMenu.java
trunk/sql12/fw/src/main/resources/net/sourceforge/squirrel_sql/fw/gui/I18NStrings.properties
Added Paths:
-----------
trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/gui/action/AbstractTableDependedCommand.java
trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/gui/action/TableSelectEntireRowsCommand.java
trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/gui/action/TableSelectEntireRowsCommandTest.java
Modified: trunk/sql12/doc/src/main/resources/changes.txt
===================================================================
--- trunk/sql12/doc/src/main/resources/changes.txt 2011-05-28 19:01:17 UTC (rev 6275)
+++ trunk/sql12/doc/src/main/resources/changes.txt 2011-05-28 19:52:34 UTC (rev 6276)
@@ -7,9 +7,11 @@
Enhancements:
+Feature Request: 3307812: Select an entire row via the table's pop-up menu.
+
Oracle Plugin:
The DDL of a index could be displayed under the source tab.
-
+
New plugin "WIKI table configurations":
This plugin provides some pre-defined configurations for various WIKI engines. With this configurations, Squirrel knows, how to transform the selection
of a result table into a WIKI table. At the moment, configurations for the following WIKI's are provided:
Modified: trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/gui/TablePopupMenu.java
===================================================================
--- trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/gui/TablePopupMenu.java 2011-05-28 19:01:17 UTC (rev 6275)
+++ trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/gui/TablePopupMenu.java 2011-05-28 19:52:34 UTC (rev 6276)
@@ -64,7 +64,8 @@
int ALWAYS_ADJUST_ALL_COL_WIDTHS_ACTION = 10;
int SHOW_ROW_NUMBERS = 11;
int COPY_WIKI = 12;
- int LAST_ENTRY = 13;
+ int SELECT_ROWS = 13;
+ int LAST_ENTRY = 14;
}
private static final KeyStroke COPY_STROKE = KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.CTRL_DOWN_MASK);
@@ -95,6 +96,7 @@
private DeleteRowsAction _deleteRows = new DeleteRowsAction();
private InsertRowAction _insertRow = new InsertRowAction();
private SelectAllAction _select = new SelectAllAction();
+ private SelectRowsAction _selectRows = new SelectRowsAction();
private PrintAction _print = new PrintAction();
@@ -174,6 +176,9 @@
}
addSeparator();
_menuItems[IOptionTypes.SELECT_ALL] = add(_select);
+
+ _menuItems[IOptionTypes.SELECT_ROWS] = add(_selectRows);
+
// add entries for insert and delete rows
// only if table is updateable and already editable (ie. allowEditing is false)
@@ -612,7 +617,29 @@
}
}
+ /**
+ * Select the entire rows of the current selection.
+ * @author Stefan Willinger
+ *
+ */
+ private class SelectRowsAction extends BaseAction
+ {
+ SelectRowsAction()
+ {
+ super(s_stringMgr.getString("TablePopupMenu.selectEntireRows"));
+ }
+
+ public void actionPerformed(ActionEvent evt)
+ {
+ if (_table != null)
+ {
+ new TableSelectEntireRowsCommand(_table).execute();
+ }
+ }
+ }
+
+
private class PrintAction extends BaseAction
{
/**
Added: trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/gui/action/AbstractTableDependedCommand.java
===================================================================
--- trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/gui/action/AbstractTableDependedCommand.java (rev 0)
+++ trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/gui/action/AbstractTableDependedCommand.java 2011-05-28 19:52:34 UTC (rev 6276)
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2011 Stefan Willinger
+ * wi...@us...
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package net.sourceforge.squirrel_sql.fw.gui.action;
+
+import javax.swing.JTable;
+
+import net.sourceforge.squirrel_sql.fw.util.ICommand;
+
+/**
+ * Abstract base class for commands, which depends on a {@link JTable}
+ * @author Stefan Willinger
+ *
+ */
+public abstract class AbstractTableDependedCommand implements ICommand{
+ private JTable table;
+
+ public AbstractTableDependedCommand(JTable table)
+ {
+ super();
+ setTable(table);
+
+ }
+
+ /**
+ * @return the _table
+ */
+ public JTable getTable() {
+ return this.table;
+ }
+
+ /**
+ * @param _table the _table to set
+ */
+ public void setTable(JTable table) {
+ if (table == null)
+ {
+ throw new IllegalArgumentException("JTable == null");
+ }
+ this.table = table;
+ }
+}
Property changes on: trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/gui/action/AbstractTableDependedCommand.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/gui/action/TableSelectEntireRowsCommand.java
===================================================================
--- trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/gui/action/TableSelectEntireRowsCommand.java (rev 0)
+++ trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/gui/action/TableSelectEntireRowsCommand.java 2011-05-28 19:52:34 UTC (rev 6276)
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2011 Stefan Willinger
+ * wi...@us...
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package net.sourceforge.squirrel_sql.fw.gui.action;
+
+import javax.swing.JTable;
+
+/**
+ * Command to expand the current selection of a table to span the complete affected rows.
+ * @author Stefan Willinger
+ *
+ */
+/**
+ * @author Stefan Willinger
+ *
+ */
+public class TableSelectEntireRowsCommand extends AbstractTableDependedCommand{
+
+ public TableSelectEntireRowsCommand(JTable table) {
+ super(table);
+ }
+
+ @Override
+ public void execute(){
+ getTable().setColumnSelectionInterval(0, getTable().getColumnCount()-1);
+ }
+}
Property changes on: trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/gui/action/TableSelectEntireRowsCommand.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/sql12/fw/src/main/resources/net/sourceforge/squirrel_sql/fw/gui/I18NStrings.properties
===================================================================
--- trunk/sql12/fw/src/main/resources/net/sourceforge/squirrel_sql/fw/gui/I18NStrings.properties 2011-05-28 19:01:17 UTC (rev 6275)
+++ trunk/sql12/fw/src/main/resources/net/sourceforge/squirrel_sql/fw/gui/I18NStrings.properties 2011-05-28 19:52:34 UTC (rev 6276)
@@ -49,6 +49,7 @@
TablePopupMenu.insertrow=Insert Row
TablePopupMenu.paste=Paste
TablePopupMenu.selectall=Select All
+TablePopupMenu.selectEntireRows=Select entire row(s)
TablePopupMenu.print=Print
TextPopupMenu.copy=Copy
Added: trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/gui/action/TableSelectEntireRowsCommandTest.java
===================================================================
--- trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/gui/action/TableSelectEntireRowsCommandTest.java (rev 0)
+++ trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/gui/action/TableSelectEntireRowsCommandTest.java 2011-05-28 19:52:34 UTC (rev 6276)
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2011 Stefan Willinger
+ * wi...@us...
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package net.sourceforge.squirrel_sql.fw.gui.action;
+
+
+import static org.junit.Assert.assertEquals;
+
+import java.lang.reflect.Method;
+
+import javax.swing.JTable;
+
+import org.fest.assertions.AssertExtension;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+
+
+/**
+ * Tests the selection of a full row(s).
+ * @author Stefan Willinger
+ *
+ */
+public class TableSelectEntireRowsCommandTest {
+
+ private JTable table;
+
+ private TableSelectEntireRowsCommand classUnderTest = null;
+
+ @Before
+ public void setup() {
+ String[][] rowData = new String[][]{
+ {"Austria", "Vienna"},
+ {"Italy", "Rome"},
+ {"Germany", "Berlin"}
+ };
+
+ String[] columnNames = new String[]{"Country", "Capital"};
+
+ table = new JTable(rowData, columnNames);
+ classUnderTest = new TableSelectEntireRowsCommand(table);
+ }
+
+ @Test
+ public void testSelectSingleRow() throws Exception {
+ table.setRowSelectionInterval(0, 0);
+ table.setColumnSelectionInterval(0, 0);
+
+ classUnderTest.execute();
+
+ assertEquals(0, table.getSelectedRows()[0]);
+ assertEquals(2, table.getSelectedColumnCount());
+ assertEquals(1, table.getSelectedRowCount());
+ }
+
+ @Test
+ public void testSelectMultibleRows() throws Exception {
+ table.setRowSelectionInterval(1, 2);
+ table.setColumnSelectionInterval(1, 1);
+
+ classUnderTest.execute();
+
+ assertEquals(1, table.getSelectedRows()[0]);
+ assertEquals(2, table.getSelectedRows()[1]);
+ assertEquals(2, table.getSelectedColumnCount());
+ assertEquals(2, table.getSelectedRowCount());
+ }
+}
Property changes on: trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/gui/action/TableSelectEntireRowsCommandTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|