.isTouchDevice()
&& !BrowserInfo.get().requiresTouchScrollDelegate();
+ private Set<String> noncollapsibleColumns;
+
/**
* Represents a select range of rows
*/
updateHeader(uidl.getStringArrayAttribute("vcolorder"));
updateFooter(uidl.getStringArrayAttribute("vcolorder"));
+ if (uidl.hasVariable("noncollapsiblecolumns")) {
+ noncollapsibleColumns = uidl
+ .getStringArrayVariableAsSet("noncollapsiblecolumns");
+ }
}
private void updateCollapsedColumns(UIDL uidl) {
String colKey;
private boolean collapsed;
+ private boolean noncollapsible = false;
private VScrollTableRow currentlyFocusedRow;
public VisibleColumnAction(String colKey) {
@Override
public void execute() {
+ if (noncollapsible) {
+ return;
+ }
client.getContextMenu().hide();
// toggle selected column
if (collapsedColumns.contains(colKey)) {
collapsed = b;
}
+ public void setNoncollapsible(boolean b) {
+ noncollapsible = b;
+ }
+
/**
* Override default method to distinguish on/off columns
*/
@Override
public String getHTML() {
final StringBuffer buf = new StringBuffer();
+ buf.append("<span class=\"");
if (collapsed) {
- buf.append("<span class=\"v-off\">");
+ buf.append("v-off");
} else {
- buf.append("<span class=\"v-on\">");
+ buf.append("v-on");
+ }
+ if (noncollapsible) {
+ buf.append(" v-disabled");
}
+ buf.append("\">");
+
buf.append(super.getHTML());
buf.append("</span>");
if (!c.isEnabled()) {
a.setCollapsed(true);
}
+ if (noncollapsibleColumns.contains(cid)) {
+ a.setNoncollapsible(true);
+ }
actions[i] = a;
}
return actions;
*/
private LinkedList<Object> visibleColumns = new LinkedList<Object>();
+ /**
+ * Holds noncollapsible columns.
+ */
+ private HashSet<Object> noncollapsibleColumns = new HashSet<Object>();
+
/**
* Holds propertyIds of currently collapsed columns.
*/
if (!isColumnCollapsingAllowed()) {
throw new IllegalStateException("Column collapsing not allowed!");
}
+ if (collapsed && noncollapsibleColumns.contains(propertyId)) {
+ throw new IllegalStateException("The column is noncollapsible!");
+ }
if (collapsed) {
collapsedColumns.add(propertyId);
refreshRenderedCells();
}
+ /**
+ * Sets whether a column can be collapsed or not.
+ *
+ * @param propertyId
+ * the propertyID identifying the column.
+ * @param collapsible
+ * the desired collapsibleness
+ */
+ public void setColumnNoncollapsible(Object propertyId,
+ boolean noncollapsible) {
+ if (noncollapsible) {
+ noncollapsibleColumns.add(propertyId);
+ collapsedColumns.remove(propertyId);
+ } else {
+ noncollapsibleColumns.remove(propertyId);
+ }
+ refreshRowCache();
+ }
+
+ /**
+ * Checks if the column can be collapsed.
+ *
+ * @return true if the column can be collapsed; false otherwise.
+ */
+ public boolean isColumnNoncollapsible(Object propertyId) {
+ return noncollapsibleColumns.contains(propertyId);
+ }
+
/**
* Checks if column reordering is allowed.
*
}
}
target.addVariable(this, "collapsedcolumns", collapsedKeys);
+
+ final String[] noncollapsibleKeys = new String[noncollapsibleColumns
+ .size()];
+ nextColumn = 0;
+ for (Object colId : noncollapsibleColumns) {
+ noncollapsibleKeys[nextColumn++] = columnIdMap.key(colId);
+ }
+ target.addVariable(this, "noncollapsiblecolumns",
+ noncollapsibleKeys);
}
+
}
private void paintActions(PaintTarget target, final Set<Action> actionSet)
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="" />
+<title>TableWithNoncollapsibleColumns</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">TableWithNoncollapsibleColumns</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.table.TableWithNoncollapsibleColumns?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableWithNoncollapsibleColumns::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>column-3-collapsed</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableWithNoncollapsibleColumns::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[4]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>column-3-noncollapsible</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableWithNoncollapsibleColumns::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableWithNoncollapsibleColumns::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableWithNoncollapsibleColumns::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableWithNoncollapsibleColumns::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[0]/domChild[1]</td>
+ <td>9,7</td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>column-menu-after-collapsing-all-columns</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableWithNoncollapsibleColumns::Root/VContextMenu[0]#option2</td>
+ <td>93,4</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableWithNoncollapsibleColumns::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[0]/domChild[1]</td>
+ <td>7,10</td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>column-menu-after-expanding-column-2</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
--- /dev/null
+package com.vaadin.tests.components.table;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.VerticalLayout;
+
+public class TableWithNoncollapsibleColumns extends TestBase {
+
+ @Override
+ protected void setup() {
+ VerticalLayout layout = new VerticalLayout();
+ layout.setSizeFull();
+ addComponent(layout);
+
+ final Table table = new Table();
+ table.setWidth("100%");
+ table.setHeight("300px");
+ table.setColumnCollapsingAllowed(true);
+
+ table.addContainerProperty("Column 1 - noncollapsible", String.class,
+ null);
+ table.addContainerProperty("Column 2 - collapsible", String.class, null);
+ table.addContainerProperty("Column 3 - toggle collapsing",
+ String.class, null);
+
+ table.setColumnNoncollapsible("Column 1 - noncollapsible", true);
+ layout.addComponent(table);
+
+ final Button button1 = new Button("Column 1: collapse/show",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ table.setColumnCollapsed(
+ "Column 1 - noncollapsible",
+ !table.isColumnCollapsed("Column 1 - noncollapsible"));
+ }
+ });
+ final Button button2 = new Button("Column 2: collapse/show",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ table.setColumnCollapsed(
+ "Column 2 - collapsible",
+ !table.isColumnCollapsed("Column 2 - collapsible"));
+ }
+ });
+
+ final Button button3 = new Button("Column 3: collapse/show",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ table.setColumnCollapsed(
+ "Column 3 - toggle collapsing",
+ !table.isColumnCollapsed("Column 3 - toggle collapsing"));
+ }
+ });
+ final Button button4 = new Button(
+ "Column 3: make noncollapsible/collapsible",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ table.setColumnNoncollapsible(
+ "Column 3 - toggle collapsing",
+ !table.isColumnNoncollapsible("Column 3 - toggle collapsing"));
+ }
+ });
+
+ layout.addComponent(button1);
+ layout.addComponent(button2);
+ layout.addComponent(button3);
+ layout.addComponent(button4);
+
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Often a table has one column that identifies the row better than any other and it would not make sense to collapse that one. Make it possible from the server side api to disable collapsing for some properties. These properties could appear as grayed out in the collapse drop down menu.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 7495;
+ }
+
+}
}
};
+ private Command<T, Boolean> columnNonCollapsibleCommand = new Command<T, Boolean>() {
+
+ public void execute(T c, Boolean noncollapsible, Object propertyId) {
+ c.setColumnNoncollapsible(propertyId, noncollapsible);
+
+ }
+ };
+
protected Command<T, Boolean> columnResizeListenerCommand = new Command<T, Boolean>() {
public void execute(Table c, Boolean value, Object data) {
createSelectAction("Expand ratio", category, expandOptions,
"- remove -", columnExpandRatioCommand, propertyId);
t.log("Expand");
+ createBooleanAction("Noncollapsible", category, false,
+ columnNonCollapsibleCommand, propertyId);
+
// Footer text (move)
// Header text (move)