Author: scabanovich
Date: 2010-10-22 06:08:39 -0400 (Fri, 22 Oct 2010)
New Revision: 25990
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/TableStructuredFieldEditor.java
Log:
JBIDE-7338
https://jira.jboss.org/browse/JBIDE-7338
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/TableStructuredFieldEditor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/TableStructuredFieldEditor.java 2010-10-22
09:30:16 UTC (rev 25989)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/TableStructuredFieldEditor.java 2010-10-22
10:08:39 UTC (rev 25990)
@@ -305,9 +305,45 @@
control.setLayoutData(gd);
}
}
+ updateTableLayoutData();
}
return tableButtonsControl;
}
+
+ public boolean updateTableLayoutData() {
+ if(tableField == null || tableField.isDisposed()) return false;
+ boolean isNew = false;
+ boolean changed = false;
+ GridData data = null;
+ if(tableButtonsControl.getLayoutData() instanceof GridData) {
+ data = (GridData)tableButtonsControl.getLayoutData();
+ } else {
+ data = new GridData(GridData.FILL_BOTH);
+ data.horizontalSpan = 2;
+ isNew = true;
+ changed = true;
+ }
+ int itemCount = tableField.getItemCount();
+ if(itemCount > 10) {
+ if(data.heightHint != 250 || data.verticalAlignment != GridData.BEGINNING) {
+ changed = true;
+ data.verticalAlignment = GridData.BEGINNING;
+ data.heightHint = 250;
+ }
+ } else {
+ if(data.heightHint != SWT.DEFAULT || data.verticalAlignment != GridData.FILL) {
+ changed = true;
+ data.verticalAlignment = GridData.FILL;
+ data.heightHint = SWT.DEFAULT;
+ }
+ }
+ if(changed) {
+ tableButtonsControl.setLayoutData(data);
+ }
+
+
+ return !isNew && changed;
+ }
public Control getControl() {
return this.tableControl;
@@ -338,6 +374,11 @@
if(i < 0) i = 0;
tableViewer.refresh();
int c = tableViewer.getTable().getItemCount();
+ if(updateTableLayoutData()) {
+ tableButtonsControl.layout();
+ tableButtonsControl.getParent().layout();
+ tableButtonsControl.getParent().getParent().layout();
+ }
while(i >= c) --i;
if(i >= 0) {
tableViewer.setSelection(new
StructuredSelection(tableViewer.getTable().getItem(i).getData()));