Skip to content

Commit

Permalink
Adds SpacerUpdater support for Escalator (#16644)
Browse files Browse the repository at this point in the history
Change-Id: I9d73a3fc36e94e36c35859a4ae456002c75df2f5
  • Loading branch information
Henrik Paul committed Feb 16, 2015
1 parent 556c1aa commit c72967b
Show file tree
Hide file tree
Showing 8 changed files with 275 additions and 90 deletions.
Expand Up @@ -16,8 +16,6 @@

package com.vaadin.client.widget.escalator;

import com.vaadin.client.widgets.Escalator;

/**
* An interface that allows client code to define how a certain row in Escalator
* will be displayed. The contents of an escalator's header, body and footer are
Expand Down
1 change: 0 additions & 1 deletion client/src/com/vaadin/client/widget/escalator/Row.java
Expand Up @@ -17,7 +17,6 @@
package com.vaadin.client.widget.escalator;

import com.google.gwt.dom.client.TableRowElement;
import com.vaadin.client.widgets.Escalator;

/**
* A representation of a row in an {@link Escalator}.
Expand Down
27 changes: 27 additions & 0 deletions client/src/com/vaadin/client/widget/escalator/RowContainer.java
Expand Up @@ -44,6 +44,7 @@ public interface RowContainer {
* @see com.vaadin.client.widgets.Escalator#getBody()
*/
public interface BodyRowContainer extends RowContainer {

/**
* Marks a spacer and its height.
* <p>
Expand All @@ -61,6 +62,32 @@ public interface BodyRowContainer extends RowContainer {
*/
void setSpacer(int rowIndex, double height)
throws IllegalArgumentException;

/**
* Sets a new spacer updater.
* <p>
* Spacers that are currently visible will be updated, i.e.
* {@link SpacerUpdater#destroy(Spacer) destroyed} with the previous
* one, and {@link SpacerUpdater#init(Spacer) initialized} with the new
* one.
*
* @param spacerUpdater
* the new spacer updater
* @throws IllegalArgumentException
* if {@code spacerUpdater} is {@code null}
*/
void setSpacerUpdater(SpacerUpdater spacerUpdater)
throws IllegalArgumentException;

/**
* Gets the spacer updater currently in use.
* <p>
* {@link SpacerUpdater#NULL} is the default.
*
* @return the spacer updater currently in use. Never <code>null</code>
*/
SpacerUpdater getSpacerUpdater();

}

/**
Expand Down
41 changes: 41 additions & 0 deletions client/src/com/vaadin/client/widget/escalator/Spacer.java
@@ -0,0 +1,41 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.client.widget.escalator;

import com.google.gwt.dom.client.Element;

/**
* A representation of a spacer element in a {@link SpacerContainer}.
*
* @since
* @author Vaadin Ltd
*/
public interface Spacer {

/**
* Gets the root element for the spacer content.
*
* @return the root element for the spacer content
*/
Element getElement();

/**
* Gets the row index.
*
* @return the row index.
*/
int getRow();
}
62 changes: 62 additions & 0 deletions client/src/com/vaadin/client/widget/escalator/SpacerUpdater.java
@@ -0,0 +1,62 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.client.widget.escalator;

/**
* An interface that handles the display of content for spacers.
* <p>
* The updater is responsible for making sure all elements are properly
* constructed and cleaned up.
*
* @since
* @author Vaadin Ltd
* @see Spacer
* @see SpacerContainer
*/
public interface SpacerUpdater {

/** A spacer updater that does nothing. */
public static final SpacerUpdater NULL = new SpacerUpdater() {
@Override
public void init(Spacer spacer) {
// NOOP
}

@Override
public void destroy(Spacer spacer) {
// NOOP
}
};

/**
* Called whenever a spacer should be initialized with content.
*
* @param spacer
* the spacer reference that should be initialized
*/
void init(Spacer spacer);

/**
* Called whenever a spacer should be cleaned.
* <p>
* The structure to clean up is the same that has been constructed by
* {@link #init(Spacer)}.
*
* @param spacer
* the spacer reference that should be destroyed
*/
void destroy(Spacer spacer);
}

0 comments on commit c72967b

Please sign in to comment.