-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add collapsable interface and implementation example (#906)
Introduces the concept of a Collapsable element, harmonizing and paving the way for future elements we want to be collapsed / expanded. The example implementation addresses #904 and improves the objective display. --------- Co-authored-by: Tobias Koch <tobias.koch@qbic.uni-tuebingen.de>
- Loading branch information
Showing
5 changed files
with
112 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
27 changes: 27 additions & 0 deletions
27
user-interface/src/main/java/life/qbic/datamanager/views/general/Collapsible.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package life.qbic.datamanager.views.general; | ||
|
||
/** | ||
* <b>Collapsable Element Interface</b> | ||
* | ||
* <p>Collapsable elements can be collapsed into a concise view representation of an element, | ||
* such as e.g. a large text box with information.</p> | ||
* | ||
* @since 1.7.0 | ||
*/ | ||
public interface Collapsible { | ||
|
||
/** | ||
* Collapse the element into its concise view format | ||
* | ||
* @since 1.7.0 | ||
*/ | ||
void collapse(); | ||
|
||
/** | ||
* Expand the element into its expanded view format | ||
* | ||
* @since 1.7.0 | ||
*/ | ||
void expand(); | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
user-interface/src/main/java/life/qbic/datamanager/views/general/CollapsibleDetails.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package life.qbic.datamanager.views.general; | ||
|
||
import com.vaadin.flow.component.details.Details; | ||
import com.vaadin.flow.component.html.Div; | ||
import java.util.Objects; | ||
|
||
/** | ||
* <b>Collapsable Details</b> | ||
* | ||
* <p>Implementation of the {@link Collapsible} interface for the Vaadin component | ||
* {@link Details}.</p> | ||
* <p> | ||
* For the Vaadin {@link Details} component, it would not be necessary to provide a wrapper object. However | ||
* the interface gives a lot of flexibility to add collapsable elements wrapping other custom | ||
* components while exposing a unified behaviour. | ||
* <p> | ||
* Also we favor a more declarative and readable object API, like {@link #collapse()} or {@link #expand() } over | ||
* e.g. {@link Details#setOpened(boolean)}. | ||
* | ||
* @since 1.7.0 | ||
*/ | ||
public class CollapsibleDetails extends Div implements Collapsible { | ||
|
||
private final Details details; | ||
|
||
public CollapsibleDetails(Details details) { | ||
this.details = Objects.requireNonNull(details); | ||
add(details); | ||
} | ||
|
||
@Override | ||
public void collapse() { | ||
this.details.setOpened(false); | ||
} | ||
|
||
@Override | ||
public void expand() { | ||
this.details.setOpened(true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters