summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorMarcel Schneider2013-05-06 12:37:43 (EDT)
committer Jeremie Bresson2013-05-06 12:38:12 (EDT)
commit55e08e22ab119f4afab52abe7aac4f534077f610 (patch)
treeba12605319724f949a73e938991546fe9566fae0
parent3fd1fabcd003baf8b1bc03f90a941c48c52e1fdb (diff)
downloadorg.eclipse.scout.rt-55e08e22ab119f4afab52abe7aac4f534077f610.zip
org.eclipse.scout.rt-55e08e22ab119f4afab52abe7aac4f534077f610.tar.gz
org.eclipse.scout.rt-55e08e22ab119f4afab52abe7aac4f534077f610.tar.bz2
Bug 406059: Swing: hard-wirded SwingScoutColumn instantiationrefs/changes/61/12061/5
https://bugs.eclipse.org/bugs/show_bug.cgi?id=406059 Change-Id: I2cda0b79a20bd83fde7ec15c81f7d7ed6f84c44f
-rw-r--r--org.eclipse.scout.rt.ui.swing.test/src/org/eclipse/scout/rt/ui/swing/form/fields/tablefield/SwingScoutTableFieldUiTest.java41
-rw-r--r--org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/AbstractSwingEnvironment.java7
-rw-r--r--org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/ISwingEnvironment.java17
-rw-r--r--org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/basic/table/SwingTableColumn.java8
-rw-r--r--org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/basic/table/SwingTableColumnModel.java2
5 files changed, 69 insertions, 6 deletions
diff --git a/org.eclipse.scout.rt.ui.swing.test/src/org/eclipse/scout/rt/ui/swing/form/fields/tablefield/SwingScoutTableFieldUiTest.java b/org.eclipse.scout.rt.ui.swing.test/src/org/eclipse/scout/rt/ui/swing/form/fields/tablefield/SwingScoutTableFieldUiTest.java
index 47c24ca..6b9a501 100644
--- a/org.eclipse.scout.rt.ui.swing.test/src/org/eclipse/scout/rt/ui/swing/form/fields/tablefield/SwingScoutTableFieldUiTest.java
+++ b/org.eclipse.scout.rt.ui.swing.test/src/org/eclipse/scout/rt/ui/swing/form/fields/tablefield/SwingScoutTableFieldUiTest.java
@@ -17,15 +17,18 @@ import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
import org.easymock.EasyMock;
+import org.eclipse.scout.commons.annotations.Order;
import org.eclipse.scout.rt.client.ui.action.keystroke.IKeyStroke;
import org.eclipse.scout.rt.client.ui.basic.table.AbstractTable;
-import org.eclipse.scout.rt.client.ui.basic.table.ITable;
+import org.eclipse.scout.rt.client.ui.basic.table.columns.AbstractIntegerColumn;
+import org.eclipse.scout.rt.client.ui.basic.table.columns.AbstractStringColumn;
import org.eclipse.scout.rt.client.ui.form.IForm;
import org.eclipse.scout.rt.client.ui.form.fields.GridData;
import org.eclipse.scout.rt.client.ui.form.fields.IFormField;
import org.eclipse.scout.rt.client.ui.form.fields.tablefield.ITableField;
import org.eclipse.scout.rt.ui.swing.ISwingEnvironment;
import org.eclipse.scout.rt.ui.swing.basic.table.SwingScoutTable;
+import org.eclipse.scout.rt.ui.swing.basic.table.SwingTableColumn;
import org.eclipse.scout.rt.ui.swing.ext.JStatusLabelEx;
import org.junit.Test;
@@ -47,7 +50,7 @@ public class SwingScoutTableFieldUiTest {
form.getOuterForm();
expectLastCall().andReturn(form);
- ITable scoutTable = new P_Table();
+ P_Table scoutTable = new P_Table();
ITableField<?> scoutObject = createNiceMock(ITableField.class);
scoutObject.getGridData();
@@ -68,6 +71,10 @@ public class SwingScoutTableFieldUiTest {
expectLastCall().andReturn(100).anyTimes();
environment.createTable(scoutTable); //Bug 405354: creation of the table is delegated to ISwingEnvironment
expectLastCall().andReturn(new SwingScoutTable());
+ environment.createColumn(0, scoutTable.getFirstColumn()); //Bug 406059: creation of the column is delegated to ISwingEnvironment
+ expectLastCall().andReturn(new SwingTableColumn(0, scoutTable.getFirstColumn()));
+ environment.createColumn(1, scoutTable.getSecondColumn()); //Bug 406059: creation of the column is delegated to ISwingEnvironment
+ expectLastCall().andReturn(new SwingTableColumn(1, scoutTable.getSecondColumn()));
replay(form, scoutObject, environment);
@@ -78,5 +85,35 @@ public class SwingScoutTableFieldUiTest {
}
public static class P_Table extends AbstractTable {
+
+ public FirstColumn getFirstColumn() {
+ return getColumnSet().getColumnByClass(FirstColumn.class);
+ }
+
+ public SecondColumn getSecondColumn() {
+ return getColumnSet().getColumnByClass(SecondColumn.class);
+ }
+
+ @Order(10)
+ public class FirstColumn extends AbstractStringColumn {
+ @Override
+ protected boolean getConfiguredSummary() {
+ return true;
+ }
+
+ @Override
+ protected int getConfiguredWidth() {
+ return 60;
+ }
+ }
+
+ @Order(20)
+ public class SecondColumn extends AbstractIntegerColumn {
+
+ @Override
+ protected int getConfiguredWidth() {
+ return 40;
+ }
+ }
}
}
diff --git a/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/AbstractSwingEnvironment.java b/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/AbstractSwingEnvironment.java
index a24ba74..4644cf0 100644
--- a/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/AbstractSwingEnvironment.java
+++ b/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/AbstractSwingEnvironment.java
@@ -58,6 +58,7 @@ import org.eclipse.scout.rt.client.ui.ClientUIPreferences;
import org.eclipse.scout.rt.client.ui.action.IAction;
import org.eclipse.scout.rt.client.ui.basic.filechooser.IFileChooser;
import org.eclipse.scout.rt.client.ui.basic.table.ITable;
+import org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn;
import org.eclipse.scout.rt.client.ui.desktop.DesktopEvent;
import org.eclipse.scout.rt.client.ui.desktop.DesktopListener;
import org.eclipse.scout.rt.client.ui.desktop.IDesktop;
@@ -72,6 +73,7 @@ import org.eclipse.scout.rt.ui.swing.action.ISwingScoutAction;
import org.eclipse.scout.rt.ui.swing.basic.SwingScoutComposite;
import org.eclipse.scout.rt.ui.swing.basic.table.ISwingScoutTable;
import org.eclipse.scout.rt.ui.swing.basic.table.SwingScoutTable;
+import org.eclipse.scout.rt.ui.swing.basic.table.SwingTableColumn;
import org.eclipse.scout.rt.ui.swing.concurrency.SwingScoutSynchronizer;
import org.eclipse.scout.rt.ui.swing.ext.IEmbeddedFrameProviderService;
import org.eclipse.scout.rt.ui.swing.ext.JDialogEx;
@@ -1198,4 +1200,9 @@ public abstract class AbstractSwingEnvironment implements ISwingEnvironment {
return new SwingScoutTable();
}
+ @Override
+ public SwingTableColumn createColumn(int swingModelIndex, IColumn scoutColumn) {
+ return new SwingTableColumn(swingModelIndex, scoutColumn);
+ }
+
}
diff --git a/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/ISwingEnvironment.java b/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/ISwingEnvironment.java
index f57d513..440c113 100644
--- a/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/ISwingEnvironment.java
+++ b/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/ISwingEnvironment.java
@@ -28,6 +28,7 @@ import org.eclipse.scout.rt.client.IClientSession;
import org.eclipse.scout.rt.client.ui.action.IAction;
import org.eclipse.scout.rt.client.ui.basic.filechooser.IFileChooser;
import org.eclipse.scout.rt.client.ui.basic.table.ITable;
+import org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn;
import org.eclipse.scout.rt.client.ui.desktop.IDesktop;
import org.eclipse.scout.rt.client.ui.form.FormEvent;
import org.eclipse.scout.rt.client.ui.form.IForm;
@@ -36,6 +37,7 @@ import org.eclipse.scout.rt.client.ui.form.fields.groupbox.IGroupBox;
import org.eclipse.scout.rt.client.ui.messagebox.IMessageBox;
import org.eclipse.scout.rt.ui.swing.action.ISwingScoutAction;
import org.eclipse.scout.rt.ui.swing.basic.table.ISwingScoutTable;
+import org.eclipse.scout.rt.ui.swing.basic.table.SwingTableColumn;
import org.eclipse.scout.rt.ui.swing.ext.JDialogEx;
import org.eclipse.scout.rt.ui.swing.ext.JStatusLabelEx;
import org.eclipse.scout.rt.ui.swing.form.ISwingScoutForm;
@@ -403,8 +405,21 @@ public interface ISwingEnvironment {
* @param table
* Table model
* @return
- * @since 3.9.0 (Bug 405354)
+ * @since 3.9.0
*/
ISwingScoutTable createTable(ITable table);
+ /**
+ * Creates a swing scout table column instance for the given column model. The default implementation returns a
+ * SwingTableColumn instance.
+ *
+ * @param swingModelIndex
+ * modelIndex used to create the swing {@link javax.swing.table.TableColumn TableColumn}
+ * @param scoutColumn
+ * the corresponding scout table column
+ * @return
+ * @since 3.9.0
+ */
+ SwingTableColumn createColumn(int swingModelIndex, IColumn scoutColumn);
+
}
diff --git a/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/basic/table/SwingTableColumn.java b/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/basic/table/SwingTableColumn.java
index cebaf34..e8a06dc 100644
--- a/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/basic/table/SwingTableColumn.java
+++ b/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/basic/table/SwingTableColumn.java
@@ -4,7 +4,7 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* BSI Business Systems Integration AG - initial API and implementation
******************************************************************************/
@@ -23,7 +23,7 @@ public class SwingTableColumn extends TableColumn {
public SwingTableColumn(int swingModelIndex, IColumn scoutColumn) {
super(swingModelIndex);
m_scoutColumn = scoutColumn;
- int w = m_scoutColumn.getWidth();
+ int w = getScoutColumnWidth();
setMinWidth(0);
setPreferredWidth(w);
setWidth(w);
@@ -33,6 +33,10 @@ public class SwingTableColumn extends TableColumn {
}
}
+ protected int getScoutColumnWidth() {
+ return m_scoutColumn.getWidth();
+ }
+
public IColumn getScoutColumn() {
return m_scoutColumn;
}
diff --git a/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/basic/table/SwingTableColumnModel.java b/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/basic/table/SwingTableColumnModel.java
index a98196e..0991bb8 100644
--- a/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/basic/table/SwingTableColumnModel.java
+++ b/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/basic/table/SwingTableColumnModel.java
@@ -91,7 +91,7 @@ public class SwingTableColumnModel extends DefaultTableColumnModel implements Pr
}
IColumn[] scoutCols = m_swingScoutTable.getScoutObject().getColumnSet().getVisibleColumns();
for (int i = 0; i < scoutCols.length; i++) {
- SwingTableColumn swingColumn = new SwingTableColumn(i, scoutCols[i]);
+ SwingTableColumn swingColumn = m_env.createColumn(i, scoutCols[i]);
// add column
addColumn(swingColumn);
}