mirror of
https://gitlab.kit.edu/uskyk/typicalc.git
synced 2024-11-08 18:30:42 +00:00
add ControlPanel(View)
This commit is contained in:
parent
836a9b1547
commit
6b70e3b9db
11
README.md
11
README.md
@ -1,11 +1,9 @@
|
|||||||
# Typicalc
|
# Typicalc
|
||||||
|
|
||||||
This is an example project that can be used as a starting point to create your own Vaadin application with Spring Boot.
|
|
||||||
It contains all the necessary configuration and some placeholder files to get you started.
|
|
||||||
|
|
||||||
The project is a standard Maven project, so you can import it to your IDE of choice. [Read more how to set up a development environment](https://vaadin.com/docs/v14/flow/installing/installing-overview.html) for Vaadin projects (Windows, Linux, macOS).
|
The project is a standard Maven project, so you can import it to your IDE of choice. [Read more how to set up a development environment](https://vaadin.com/docs/v14/flow/installing/installing-overview.html) for Vaadin projects (Windows, Linux, macOS).
|
||||||
|
|
||||||
This project was created from https://start.vaadin.com.
|
[To Vaadin documentation](https://vaadin.com/docs-beta/latest/flow/overview/)
|
||||||
|
|
||||||
|
|
||||||
## Running and debugging the applcation
|
## Running and debugging the applcation
|
||||||
|
|
||||||
@ -28,11 +26,6 @@ Do not worry if the debugger breaks at a `SilentExitException`. This is a Spring
|
|||||||
|
|
||||||
After the application has started, you can view your it at http://localhost:8080/ in your browser.
|
After the application has started, you can view your it at http://localhost:8080/ in your browser.
|
||||||
You can now also attach break points in code for debugging purposes, by clicking next to a line number in any source file.
|
You can now also attach break points in code for debugging purposes, by clicking next to a line number in any source file.
|
||||||
## Project structure
|
|
||||||
|
|
||||||
- `MainView.java` in `src/main/java` contains the navigation setup. It uses [App Layout](https://vaadin.com/components/vaadin-app-layout).
|
|
||||||
- `views` package in `src/main/java` contains the server-side Java views of your application.
|
|
||||||
- `views` folder in `frontend/src/` contains the client-side JavaScript views of your application.
|
|
||||||
|
|
||||||
## What next?
|
## What next?
|
||||||
|
|
||||||
|
3
pom.xml
3
pom.xml
@ -1,4 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>edu.kit.typicalc</groupId>
|
<groupId>edu.kit.typicalc</groupId>
|
||||||
<artifactId>typicalc</artifactId>
|
<artifactId>typicalc</artifactId>
|
||||||
|
@ -0,0 +1,77 @@
|
|||||||
|
package edu.kit.typicalc.view.content;
|
||||||
|
|
||||||
|
import com.vaadin.flow.component.Key;
|
||||||
|
import com.vaadin.flow.component.KeyModifier;
|
||||||
|
import com.vaadin.flow.component.button.Button;
|
||||||
|
import com.vaadin.flow.component.icon.Icon;
|
||||||
|
import com.vaadin.flow.component.icon.VaadinIcon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a GUI in form of buttons for the user to navigate through steps.
|
||||||
|
*/
|
||||||
|
public class ControlPanel {
|
||||||
|
|
||||||
|
private Button firstStep;
|
||||||
|
private Button lastStep;
|
||||||
|
private Button nextStep;
|
||||||
|
private Button previousStep;
|
||||||
|
private Button share;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets up buttons with click-listeners that call the corresponding method in the view.
|
||||||
|
* @param view the view that reacts to the button clicks
|
||||||
|
*/
|
||||||
|
public ControlPanel(ControlPanelView view) {
|
||||||
|
firstStep = new Button(new Icon(VaadinIcon.ANGLE_DOUBLE_LEFT), evt -> view.firstStepButton());
|
||||||
|
lastStep = new Button(new Icon(VaadinIcon.ANGLE_DOUBLE_RIGHT), evt -> view.lastStepButton());
|
||||||
|
nextStep = new Button(new Icon(VaadinIcon.ANGLE_DOUBLE_RIGHT), evt -> view.nextStepButton());
|
||||||
|
previousStep = new Button(new Icon(VaadinIcon.ANGLE_DOUBLE_LEFT), evt -> view.previousStepButton());
|
||||||
|
share = new Button(new Icon(VaadinIcon.CONNECT), evt -> view.shareButton());
|
||||||
|
|
||||||
|
// todo change shortcut scope
|
||||||
|
firstStep.addClickShortcut(Key.ARROW_LEFT, KeyModifier.CONTROL);
|
||||||
|
lastStep.addClickShortcut(Key.ARROW_RIGHT, KeyModifier.CONTROL);
|
||||||
|
nextStep.addClickShortcut(Key.ARROW_LEFT);
|
||||||
|
previousStep.addClickShortcut(Key.ARROW_LEFT);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables the firstStep-button if the parameter is true, disables it if hte parameter is false.
|
||||||
|
* @param setEnabled true to enable the button,false to disable it
|
||||||
|
*/
|
||||||
|
public void setEnabledFirstStep(boolean setEnabled) {
|
||||||
|
firstStep.setEnabled(setEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables the lastStep-button if the parameter is true, disables it if hte parameter is false.
|
||||||
|
* @param setEnabled true to enable the button,false to disable it
|
||||||
|
*/
|
||||||
|
public void setEnabledLastStep(boolean setEnabled) {
|
||||||
|
lastStep.setEnabled(setEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables the nextStep-button if the parameter is true, disables it if hte parameter is false.
|
||||||
|
* @param setEnabled true to enable the button,false to disable it
|
||||||
|
*/
|
||||||
|
public void setEnabledNextStep(boolean setEnabled) {
|
||||||
|
nextStep.setEnabled(setEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables the previousStep-button if the parameter is true, disables it if hte parameter is false.
|
||||||
|
* @param setEnabled true to enable the button,false to disable it
|
||||||
|
*/
|
||||||
|
public void setEnabledPreviousStep(boolean setEnabled) {
|
||||||
|
previousStep.setEnabled(setEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables the share-button if the parameter is true, disables it if hte parameter is false.
|
||||||
|
* @param setEnabled true to enable the button,false to disable it
|
||||||
|
*/
|
||||||
|
public void setEnabledShareButton(boolean setEnabled) {
|
||||||
|
share.setEnabled(setEnabled);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package edu.kit.typicalc.view.content;
|
||||||
|
|
||||||
|
public interface ControlPanelView {
|
||||||
|
/**
|
||||||
|
* Provides user with a way to share contents shown in the view, e.g. the URL orLaTeX-code.
|
||||||
|
*/
|
||||||
|
void shareButton();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Go to the first step.
|
||||||
|
*/
|
||||||
|
void firstStepButton();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Go to the last step.
|
||||||
|
*/
|
||||||
|
void lastStepButton();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Go to the next step.
|
||||||
|
*/
|
||||||
|
void nextStepButton();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Go to the previous step.
|
||||||
|
*/
|
||||||
|
void previousStepButton();
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package edu.kit.typicalc.view.info_content;
|
package edu.kit.typicalc.view.content.info_content;
|
||||||
|
|
||||||
import com.vaadin.flow.component.button.Button;
|
import com.vaadin.flow.component.button.Button;
|
||||||
import com.vaadin.flow.component.dependency.CssImport;
|
import com.vaadin.flow.component.dependency.CssImport;
|
Loading…
Reference in New Issue
Block a user