├── .config ├── checkstyle │ ├── checkstyle.xml │ └── suppressions.xml └── pmd │ └── ruleset.xml ├── .gitattributes ├── .github ├── .lycheeignore ├── ISSUE_TEMPLATE │ ├── bug_report.yml │ ├── config.yml │ ├── enhancement.yml │ └── question.yml ├── labels.yml └── workflows │ ├── broken-links.yml │ ├── check-build.yml │ ├── release.yml │ ├── sonar.yml │ ├── sync-labels.yml │ ├── test-deploy.yml │ └── update-from-template.yml ├── .gitignore ├── .idea ├── checkstyle-idea.xml ├── codeStyles │ ├── Project.xml │ └── codeStyleConfig.xml ├── externalDependencies.xml ├── inspectionProfiles │ └── Project_Default.xml └── saveactions_settings.xml ├── .mvn └── wrapper │ └── maven-wrapper.properties ├── .run └── Run Demo.run.xml ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── SECURITY.md ├── assets ├── demo.avif └── demo.png ├── mvnw ├── mvnw.cmd ├── pom.xml ├── renovate.json5 ├── vaadin-editable-label-demo ├── pom.xml └── src │ └── main │ ├── java │ └── software │ │ └── xdev │ │ └── vaadin │ │ ├── Application.java │ │ └── editable_label │ │ └── HomeView.java │ └── resources │ └── application.yml └── vaadin-editable-label ├── pom.xml └── src └── main ├── java └── software │ └── xdev │ └── vaadin │ └── editable_label │ ├── AbstractEditableLabel.java │ ├── EditableLabel.java │ ├── EditableLabelStyles.java │ └── predefined │ ├── EditableLabelBigDecimalField.java │ ├── EditableLabelComboBox.java │ ├── EditableLabelDatePicker.java │ ├── EditableLabelNumberField.java │ ├── EditableLabelTextArea.java │ └── EditableLabelTextField.java └── resources └── META-INF └── resources └── frontend └── styles └── editableLabel.css /.config/checkstyle/checkstyle.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 148 | 149 | 150 | 151 | -------------------------------------------------------------------------------- /.config/checkstyle/suppressions.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /.config/pmd/ruleset.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | This ruleset checks the code for discouraged programming constructs. 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 202 | 203 | Do not used native HTML! Use Vaadin layouts and components to create required structure. 204 | If you are 100% sure that you escaped the value properly and you have no better options you can suppress this. 205 | 206 | 2 207 | 208 | 209 | 210 | 214 | 215 | 216 | 217 | 218 | 219 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Force sh files to have LF 5 | *.sh text eol=lf 6 | 7 | # Force MVN Wrapper Linux files LF 8 | mvnw text eol=lf 9 | .mvn/wrapper/maven-wrapper.properties text eol=lf 10 | -------------------------------------------------------------------------------- /.github/.lycheeignore: -------------------------------------------------------------------------------- 1 | # Ignorefile for broken link check 2 | localhost 3 | mvnrepository.com 4 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.yml: -------------------------------------------------------------------------------- 1 | name: 🐞 Bug 2 | description: Create a bug report for something that is broken 3 | labels: [bug] 4 | type: bug 5 | body: 6 | - type: markdown 7 | attributes: 8 | value: | 9 | Thank you for reporting a bug. 10 | 11 | Please fill in as much information as possible about your bug so that we don't have to play "information ping-pong" and can help you immediately. 12 | 13 | - type: checkboxes 14 | id: checklist 15 | attributes: 16 | label: "Checklist" 17 | options: 18 | - label: "I am able to reproduce the bug with the [latest version](https://github.com/xdev-software/vaadin-editable-label/releases/latest)" 19 | required: true 20 | - label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/vaadin-editable-label/issues) or [closed](https://github.com/xdev-software/vaadin-editable-label/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to." 21 | required: true 22 | - label: "I have taken the time to fill in all the required details. I understand that the bug report will be dismissed otherwise." 23 | required: true 24 | - label: "This issue contains only one bug." 25 | required: true 26 | 27 | - type: input 28 | id: app-version 29 | attributes: 30 | label: Affected version 31 | description: "In which version did you encounter the bug?" 32 | placeholder: "x.x.x" 33 | validations: 34 | required: true 35 | 36 | - type: textarea 37 | id: description 38 | attributes: 39 | label: Description of the problem 40 | description: | 41 | Describe as exactly as possible what is not working. 42 | validations: 43 | required: true 44 | 45 | - type: textarea 46 | id: steps-to-reproduce 47 | attributes: 48 | label: Steps to reproduce the bug 49 | description: | 50 | What did you do for the bug to show up? 51 | 52 | If you can't cause the bug to show up again reliably (and hence don't have a proper set of steps to give us), please still try to give as many details as possible on how you think you encountered the bug. 53 | placeholder: | 54 | 1. Use '...' 55 | 2. Do '...' 56 | validations: 57 | required: true 58 | 59 | - type: textarea 60 | id: additional-information 61 | attributes: 62 | label: Additional information 63 | description: | 64 | Any other relevant information you'd like to include 65 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | contact_links: 2 | - name: 💬 Contact support 3 | url: https://xdev.software/en/services/support 4 | about: "If you need support as soon as possible or/and you can't wait for any pull request" 5 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/enhancement.yml: -------------------------------------------------------------------------------- 1 | name: ✨ Feature/Enhancement 2 | description: Suggest a new feature or enhancement 3 | labels: [enhancement] 4 | type: feature 5 | body: 6 | - type: markdown 7 | attributes: 8 | value: | 9 | Thank you for suggesting a new feature/enhancement. 10 | 11 | - type: checkboxes 12 | id: checklist 13 | attributes: 14 | label: "Checklist" 15 | options: 16 | - label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/vaadin-editable-label/issues) or [closed](https://github.com/xdev-software/vaadin-editable-label/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to." 17 | required: true 18 | - label: "I have taken the time to fill in all the required details. I understand that the feature request will be dismissed otherwise." 19 | required: true 20 | - label: "This issue contains only one feature request/enhancement." 21 | required: true 22 | 23 | - type: textarea 24 | id: description 25 | attributes: 26 | label: Description 27 | validations: 28 | required: true 29 | 30 | - type: textarea 31 | id: additional-information 32 | attributes: 33 | label: Additional information 34 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/question.yml: -------------------------------------------------------------------------------- 1 | name: ❓ Question 2 | description: Ask a question 3 | labels: [question] 4 | body: 5 | - type: markdown 6 | attributes: 7 | value: | 8 | Thanks for taking the time to fill out this form! 9 | 10 | - type: checkboxes 11 | id: checklist 12 | attributes: 13 | label: "Checklist" 14 | options: 15 | - label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/vaadin-editable-label/issues) or [closed](https://github.com/xdev-software/vaadin-editable-label/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to." 16 | required: true 17 | - label: "I have taken the time to fill in all the required details. I understand that the question will be dismissed otherwise." 18 | required: true 19 | 20 | - type: textarea 21 | id: what-is-the-question 22 | attributes: 23 | label: What is/are your question(s)? 24 | validations: 25 | required: true 26 | 27 | - type: textarea 28 | id: additional-information 29 | attributes: 30 | label: Additional information 31 | description: "Any other information you'd like to include - for instance logs, screenshots, etc." 32 | -------------------------------------------------------------------------------- /.github/labels.yml: -------------------------------------------------------------------------------- 1 | # Default 2 | ## Required for template 3 | - name: bug 4 | description: "Something isn't working" 5 | color: 'd73a4a' 6 | - name: enhancement 7 | description: New feature or request 8 | color: '#a2eeef' 9 | - name: question 10 | description: Information is requested 11 | color: '#d876e3' 12 | ## Others 13 | - name: duplicate 14 | description: This already exists 15 | color: '#cfd3d7' 16 | - name: good first issue 17 | description: Good for newcomers 18 | color: '#7057ff' 19 | - name: help wanted 20 | description: Extra attention is needed 21 | color: '#008672' 22 | - name: invalid 23 | description: "This doesn't seem right" 24 | color: '#e4e669' 25 | # Custom 26 | - name: automated 27 | description: Created by an automation 28 | color: '#000000' 29 | - name: "can't reproduce" 30 | color: '#e95f2c' 31 | - name: customer-requested 32 | description: Was requested by a customer of us 33 | color: '#068374' 34 | - name: stale 35 | color: '#ededed' 36 | - name: waiting-for-response 37 | description: If no response is received after a certain time the issue will be closed 38 | color: '#202020' 39 | -------------------------------------------------------------------------------- /.github/workflows/broken-links.yml: -------------------------------------------------------------------------------- 1 | name: Broken links 2 | 3 | on: 4 | workflow_dispatch: 5 | schedule: 6 | - cron: "23 23 * * 0" 7 | 8 | permissions: 9 | issues: write 10 | 11 | jobs: 12 | link-checker: 13 | runs-on: ubuntu-latest 14 | timeout-minutes: 15 15 | steps: 16 | - uses: actions/checkout@v4 17 | 18 | - run: mv .github/.lycheeignore .lycheeignore 19 | 20 | - name: Link Checker 21 | id: lychee 22 | uses: lycheeverse/lychee-action@82202e5e9c2f4ef1a55a3d02563e1cb6041e5332 # v2 23 | with: 24 | fail: false # Don't fail on broken links, create an issue instead 25 | 26 | - name: Find already existing issue 27 | id: find-issue 28 | run: | 29 | echo "number=$(gh issue list -l 'bug' -l 'automated' -L 1 -S 'in:title \"Link Checker Report\"' -s 'open' --json 'number' --jq '.[].number')" >> $GITHUB_OUTPUT 30 | env: 31 | GH_TOKEN: ${{ github.token }} 32 | 33 | - name: Close issue if everything is fine 34 | if: env.lychee_exit_code == 0 && steps.find-issue.outputs.number != '' 35 | run: gh issue close -r 'not planned' ${{ steps.find-issue.outputs.number }} 36 | env: 37 | GH_TOKEN: ${{ github.token }} 38 | 39 | - name: Create Issue From File 40 | if: env.lychee_exit_code != 0 41 | uses: peter-evans/create-issue-from-file@e8ef132d6df98ed982188e460ebb3b5d4ef3a9cd # v5 42 | with: 43 | issue-number: ${{ steps.find-issue.outputs.number }} 44 | title: Link Checker Report 45 | content-filepath: ./lychee/out.md 46 | labels: bug, automated 47 | -------------------------------------------------------------------------------- /.github/workflows/check-build.yml: -------------------------------------------------------------------------------- 1 | name: Check Build 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: [ develop ] 7 | paths-ignore: 8 | - '**.md' 9 | - '.config/**' 10 | - '.github/**' 11 | - '.idea/**' 12 | - 'assets/**' 13 | pull_request: 14 | branches: [ develop ] 15 | paths-ignore: 16 | - '**.md' 17 | - '.config/**' 18 | - '.github/**' 19 | - '.idea/**' 20 | - 'assets/**' 21 | 22 | env: 23 | PRIMARY_MAVEN_MODULE: ${{ github.event.repository.name }} 24 | DEMO_MAVEN_MODULE: ${{ github.event.repository.name }}-demo 25 | 26 | jobs: 27 | build: 28 | runs-on: ubuntu-latest 29 | timeout-minutes: 30 30 | 31 | strategy: 32 | matrix: 33 | java: [17, 21] 34 | distribution: [temurin] 35 | 36 | steps: 37 | - uses: actions/checkout@v4 38 | 39 | - name: Set up JDK 40 | uses: actions/setup-java@v4 41 | with: 42 | distribution: ${{ matrix.distribution }} 43 | java-version: ${{ matrix.java }} 44 | cache: 'maven' 45 | 46 | - name: Build with Maven 47 | run: ./mvnw -B clean package -Pproduction 48 | 49 | - name: Check for uncommited changes 50 | run: | 51 | if [[ "$(git status --porcelain)" != "" ]]; then 52 | echo ---------------------------------------- 53 | echo git status 54 | echo ---------------------------------------- 55 | git status 56 | echo ---------------------------------------- 57 | echo git diff 58 | echo ---------------------------------------- 59 | git diff 60 | echo ---------------------------------------- 61 | echo Troubleshooting 62 | echo ---------------------------------------- 63 | echo "::error::Unstaged changes detected. Locally try running: git clean -ffdx && ./mvnw -B clean package -Pproduction" 64 | exit 1 65 | fi 66 | 67 | - name: Upload demo files 68 | uses: actions/upload-artifact@v4 69 | with: 70 | name: demo-files-java-${{ matrix.java }} 71 | path: ${{ env.DEMO_MAVEN_MODULE }}/target/${{ env.DEMO_MAVEN_MODULE }}.jar 72 | if-no-files-found: error 73 | 74 | checkstyle: 75 | runs-on: ubuntu-latest 76 | if: ${{ github.event_name != 'pull_request' || !startsWith(github.head_ref, 'renovate/') }} 77 | timeout-minutes: 15 78 | 79 | strategy: 80 | matrix: 81 | java: [17] 82 | distribution: [temurin] 83 | 84 | steps: 85 | - uses: actions/checkout@v4 86 | 87 | - name: Set up JDK 88 | uses: actions/setup-java@v4 89 | with: 90 | distribution: ${{ matrix.distribution }} 91 | java-version: ${{ matrix.java }} 92 | cache: 'maven' 93 | 94 | - name: Run Checkstyle 95 | run: ./mvnw -B checkstyle:check -P checkstyle -T2C 96 | 97 | pmd: 98 | runs-on: ubuntu-latest 99 | if: ${{ github.event_name != 'pull_request' || !startsWith(github.head_ref, 'renovate/') }} 100 | timeout-minutes: 15 101 | 102 | strategy: 103 | matrix: 104 | java: [17] 105 | distribution: [temurin] 106 | 107 | steps: 108 | - uses: actions/checkout@v4 109 | 110 | - name: Set up JDK 111 | uses: actions/setup-java@v4 112 | with: 113 | distribution: ${{ matrix.distribution }} 114 | java-version: ${{ matrix.java }} 115 | cache: 'maven' 116 | 117 | - name: Run PMD 118 | run: ./mvnw -B test pmd:aggregate-pmd-no-fork pmd:check -P pmd -DskipTests -T2C 119 | 120 | - name: Run CPD (Copy Paste Detector) 121 | run: ./mvnw -B pmd:aggregate-cpd pmd:cpd-check -P pmd -DskipTests -T2C 122 | 123 | - name: Upload report 124 | if: always() 125 | uses: actions/upload-artifact@v4 126 | with: 127 | name: pmd-report 128 | if-no-files-found: ignore 129 | path: | 130 | target/reports/** 131 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | 7 | env: 8 | PRIMARY_MAVEN_MODULE: ${{ github.event.repository.name }} 9 | 10 | permissions: 11 | contents: write 12 | pull-requests: write 13 | 14 | jobs: 15 | check-code: 16 | runs-on: ubuntu-latest 17 | timeout-minutes: 30 18 | steps: 19 | - uses: actions/checkout@v4 20 | 21 | - name: Set up JDK 22 | uses: actions/setup-java@v4 23 | with: 24 | java-version: '17' 25 | distribution: 'temurin' 26 | cache: 'maven' 27 | 28 | - name: Build with Maven 29 | run: ./mvnw -B clean package -Pproduction -T2C 30 | 31 | - name: Check for uncommited changes 32 | run: | 33 | if [[ "$(git status --porcelain)" != "" ]]; then 34 | echo ---------------------------------------- 35 | echo git status 36 | echo ---------------------------------------- 37 | git status 38 | echo ---------------------------------------- 39 | echo git diff 40 | echo ---------------------------------------- 41 | git diff 42 | echo ---------------------------------------- 43 | echo Troubleshooting 44 | echo ---------------------------------------- 45 | echo "::error::Unstaged changes detected. Locally try running: git clean -ffdx && ./mvnw -B clean package -Pproduction" 46 | exit 1 47 | fi 48 | 49 | prepare-release: 50 | runs-on: ubuntu-latest 51 | needs: [check-code] 52 | timeout-minutes: 10 53 | outputs: 54 | upload_url: ${{ steps.create_release.outputs.upload_url }} 55 | steps: 56 | - uses: actions/checkout@v4 57 | 58 | - name: Configure Git 59 | run: | 60 | git config --global user.email "actions@github.com" 61 | git config --global user.name "GitHub Actions" 62 | 63 | - name: Un-SNAP 64 | run: | 65 | mvnwPath=$(readlink -f ./mvnw) 66 | modules=("") # root 67 | modules+=($(grep -oP '(?<=)[^<]+' 'pom.xml')) 68 | for i in "${modules[@]}" 69 | do 70 | echo "Processing $i/pom.xml" 71 | (cd "$i" && $mvnwPath -B versions:set -DremoveSnapshot -DgenerateBackupPoms=false) 72 | done 73 | 74 | - name: Get version 75 | id: version 76 | run: | 77 | version=$(../mvnw help:evaluate -Dexpression=project.version -q -DforceStdout) 78 | echo "release=$version" >> $GITHUB_OUTPUT 79 | echo "releasenumber=${version//[!0-9]/}" >> $GITHUB_OUTPUT 80 | working-directory: ${{ env.PRIMARY_MAVEN_MODULE }} 81 | 82 | - name: Commit and Push 83 | run: | 84 | git add -A 85 | git commit -m "Release ${{ steps.version.outputs.release }}" 86 | git push origin 87 | git tag v${{ steps.version.outputs.release }} 88 | git push origin --tags 89 | 90 | - name: Create Release 91 | id: create_release 92 | uses: shogo82148/actions-create-release@e5f206451d4ace2da9916d01f1aef279997f8659 # v1 93 | with: 94 | tag_name: v${{ steps.version.outputs.release }} 95 | release_name: v${{ steps.version.outputs.release }} 96 | commitish: master 97 | body: | 98 | ## [Changelog](https://github.com/${{ github.repository }}/blob/develop/CHANGELOG.md#${{ steps.version.outputs.releasenumber }}) 99 | See [Changelog#v${{ steps.version.outputs.release }}](https://github.com/${{ github.repository }}/blob/develop/CHANGELOG.md#${{ steps.version.outputs.releasenumber }}) for more information. 100 | 101 | ## Installation 102 | Add the following lines to your pom: 103 | ```XML 104 | 105 | software.xdev 106 | ${{ env.PRIMARY_MAVEN_MODULE }} 107 | ${{ steps.version.outputs.release }} 108 | 109 | ``` 110 | 111 | ### Additional notes 112 | * [Spring-Boot] You may have to include ``software/xdev`` inside [``vaadin.allowed-packages``](https://vaadin.com/docs/latest/integrations/spring/configuration#configure-the-scanning-of-packages) 113 | 114 | publish-maven: 115 | runs-on: ubuntu-latest 116 | needs: [prepare-release] 117 | timeout-minutes: 60 118 | steps: 119 | - uses: actions/checkout@v4 120 | 121 | - name: Init Git and pull 122 | run: | 123 | git config --global user.email "actions@github.com" 124 | git config --global user.name "GitHub Actions" 125 | git pull 126 | 127 | - name: Set up JDK 128 | uses: actions/setup-java@v4 129 | with: # running setup-java again overwrites the settings.xml 130 | java-version: '17' 131 | distribution: 'temurin' 132 | server-id: sonatype-central-portal 133 | server-username: MAVEN_CENTRAL_USERNAME 134 | server-password: MAVEN_CENTRAL_TOKEN 135 | gpg-passphrase: MAVEN_GPG_PASSPHRASE 136 | gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} 137 | 138 | - name: Publish to Central Portal 139 | run: ../mvnw -B deploy -P publish-sonatype-central-portal -DskipTests 140 | env: 141 | MAVEN_CENTRAL_USERNAME: ${{ secrets.SONATYPE_MAVEN_CENTRAL_PORTAL_USERNAME }} 142 | MAVEN_CENTRAL_TOKEN: ${{ secrets.SONATYPE_MAVEN_CENTRAL_PORTAL_TOKEN }} 143 | MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} 144 | working-directory: ${{ env.PRIMARY_MAVEN_MODULE }} 145 | 146 | publish-pages: 147 | runs-on: ubuntu-latest 148 | needs: [prepare-release] 149 | timeout-minutes: 15 150 | steps: 151 | - uses: actions/checkout@v4 152 | 153 | - name: Init Git and pull 154 | run: | 155 | git config --global user.email "actions@github.com" 156 | git config --global user.name "GitHub Actions" 157 | git pull 158 | 159 | - name: Setup - Java 160 | uses: actions/setup-java@v4 161 | with: 162 | java-version: '17' 163 | distribution: 'temurin' 164 | cache: 'maven' 165 | 166 | - name: Build site 167 | run: ../mvnw -B compile site -DskipTests -T2C 168 | working-directory: ${{ env.PRIMARY_MAVEN_MODULE }} 169 | 170 | - name: Deploy to Github pages 171 | uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4 172 | with: 173 | github_token: ${{ secrets.GITHUB_TOKEN }} 174 | publish_dir: ./${{ env.PRIMARY_MAVEN_MODULE }}/target/site 175 | force_orphan: true 176 | 177 | after-release: 178 | runs-on: ubuntu-latest 179 | needs: [publish-maven] 180 | timeout-minutes: 10 181 | steps: 182 | - uses: actions/checkout@v4 183 | 184 | - name: Init Git and pull 185 | run: | 186 | git config --global user.email "actions@github.com" 187 | git config --global user.name "GitHub Actions" 188 | git pull 189 | 190 | - name: Inc Version and SNAP 191 | run: | 192 | mvnwPath=$(readlink -f ./mvnw) 193 | modules=("") # root 194 | modules+=($(grep -oP '(?<=)[^<]+' 'pom.xml')) 195 | for i in "${modules[@]}" 196 | do 197 | echo "Processing $i/pom.xml" 198 | (cd "$i" && $mvnwPath -B build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion} -DgenerateBackupPoms=false -DnextSnapshot=true -DupdateMatchingVersions=false) 199 | done 200 | 201 | - name: Git Commit and Push 202 | run: | 203 | git add -A 204 | git commit -m "Preparing for next development iteration" 205 | git push origin 206 | 207 | - name: pull-request 208 | env: 209 | GH_TOKEN: ${{ github.token }} 210 | run: | 211 | gh_pr_up() { 212 | gh pr create "$@" || gh pr edit "$@" 213 | } 214 | gh_pr_up -B "develop" \ 215 | --title "Sync back" \ 216 | --body "An automated PR to sync changes back" 217 | -------------------------------------------------------------------------------- /.github/workflows/sonar.yml: -------------------------------------------------------------------------------- 1 | name: Sonar 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: [ develop ] 7 | paths-ignore: 8 | - '**.md' 9 | - '.config/**' 10 | - '.github/**' 11 | - '.idea/**' 12 | - 'assets/**' 13 | pull_request: 14 | branches: [ develop ] 15 | paths-ignore: 16 | - '**.md' 17 | - '.config/**' 18 | - '.github/**' 19 | - '.idea/**' 20 | - 'assets/**' 21 | 22 | env: 23 | SONARCLOUD_ORG: ${{ github.event.organization.login }} 24 | SONARCLOUD_HOST: https://sonarcloud.io 25 | 26 | jobs: 27 | token-check: 28 | runs-on: ubuntu-latest 29 | if: ${{ !(github.event_name == 'pull_request' && startsWith(github.head_ref, 'renovate/')) }} 30 | timeout-minutes: 5 31 | outputs: 32 | hasToken: ${{ steps.check-token.outputs.has }} 33 | steps: 34 | - id: check-token 35 | run: | 36 | [ -z $SONAR_TOKEN ] && echo "has=false" || echo "has=true" >> "$GITHUB_OUTPUT" 37 | env: 38 | SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} 39 | 40 | sonar-scan: 41 | runs-on: ubuntu-latest 42 | needs: token-check 43 | if: ${{ needs.token-check.outputs.hasToken }} 44 | timeout-minutes: 30 45 | steps: 46 | - uses: actions/checkout@v4 47 | with: 48 | fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis 49 | 50 | - name: Set up JDK 51 | uses: actions/setup-java@v4 52 | with: 53 | distribution: 'temurin' 54 | java-version: 17 55 | 56 | - name: Cache SonarCloud packages 57 | uses: actions/cache@v4 58 | with: 59 | path: ~/.sonar/cache 60 | key: ${{ runner.os }}-sonar 61 | restore-keys: ${{ runner.os }}-sonar 62 | 63 | - name: Cache Maven packages 64 | uses: actions/cache@v4 65 | with: 66 | path: ~/.m2 67 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} 68 | restore-keys: ${{ runner.os }}-m2 69 | 70 | - name: Build with Maven 71 | run: | 72 | ./mvnw -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \ 73 | -DskipTests \ 74 | -Dsonar.projectKey=${{ env.SONARCLOUD_ORG }}_${{ github.event.repository.name }} \ 75 | -Dsonar.organization=${{ env.SONARCLOUD_ORG }} \ 76 | -Dsonar.host.url=${{ env.SONARCLOUD_HOST }} 77 | env: 78 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any 79 | SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} 80 | -------------------------------------------------------------------------------- /.github/workflows/sync-labels.yml: -------------------------------------------------------------------------------- 1 | name: Sync labels 2 | 3 | on: 4 | push: 5 | branches: develop 6 | paths: 7 | - .github/labels.yml 8 | 9 | workflow_dispatch: 10 | 11 | permissions: 12 | issues: write 13 | 14 | jobs: 15 | labels: 16 | runs-on: ubuntu-latest 17 | timeout-minutes: 10 18 | steps: 19 | - uses: actions/checkout@v4 20 | with: 21 | sparse-checkout: .github/labels.yml 22 | 23 | - uses: EndBug/label-sync@52074158190acb45f3077f9099fea818aa43f97a # v2 24 | with: 25 | config-file: .github/labels.yml 26 | -------------------------------------------------------------------------------- /.github/workflows/test-deploy.yml: -------------------------------------------------------------------------------- 1 | name: Test Deployment 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | env: 7 | PRIMARY_MAVEN_MODULE: ${{ github.event.repository.name }} 8 | 9 | jobs: 10 | publish-maven: 11 | runs-on: ubuntu-latest 12 | timeout-minutes: 60 13 | steps: 14 | - uses: actions/checkout@v4 15 | 16 | - name: Set up JDK 17 | uses: actions/setup-java@v4 18 | with: # running setup-java again overwrites the settings.xml 19 | distribution: 'temurin' 20 | java-version: '17' 21 | server-id: sonatype-central-portal 22 | server-username: MAVEN_CENTRAL_USERNAME 23 | server-password: MAVEN_CENTRAL_TOKEN 24 | gpg-passphrase: MAVEN_GPG_PASSPHRASE 25 | gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} 26 | 27 | - name: Publish to Central Portal 28 | run: ../mvnw -B deploy -P publish-sonatype-central-portal -DskipTests 29 | working-directory: ${{ env.PRIMARY_MAVEN_MODULE }} 30 | env: 31 | MAVEN_CENTRAL_USERNAME: ${{ secrets.SONATYPE_MAVEN_CENTRAL_PORTAL_USERNAME }} 32 | MAVEN_CENTRAL_TOKEN: ${{ secrets.SONATYPE_MAVEN_CENTRAL_PORTAL_TOKEN }} 33 | MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} 34 | -------------------------------------------------------------------------------- /.github/workflows/update-from-template.yml: -------------------------------------------------------------------------------- 1 | name: Update from Template 2 | 3 | # This workflow keeps the repo up to date with changes from the template repo (REMOTE_URL) 4 | # It duplicates the REMOTE_BRANCH (into UPDATE_BRANCH) and tries to merge it into 5 | # this repos default branch (which is checked out here) 6 | # Note that this requires a PAT (Personal Access Token) - at best from a servicing account 7 | # PAT permissions: read:discussion, read:org, repo, workflow 8 | # Also note that you should have at least once merged the template repo into the current repo manually 9 | # otherwise a "refusing to merge unrelated histories" error might occur. 10 | 11 | on: 12 | schedule: 13 | - cron: '55 2 * * 1' 14 | workflow_dispatch: 15 | inputs: 16 | no_automatic_merge: 17 | type: boolean 18 | description: 'No automatic merge' 19 | default: false 20 | 21 | env: 22 | UPDATE_BRANCH: update-from-template 23 | UPDATE_BRANCH_MERGED: update-from-template-merged 24 | REMOTE_URL: https://github.com/xdev-software/vaadin-addon-template.git 25 | REMOTE_BRANCH: master 26 | 27 | permissions: 28 | contents: write 29 | pull-requests: write 30 | 31 | jobs: 32 | update: 33 | runs-on: ubuntu-latest 34 | timeout-minutes: 60 35 | outputs: 36 | update_branch_merged_commit: ${{ steps.manage-branches.outputs.update_branch_merged_commit }} 37 | create_update_branch_merged_pr: ${{ steps.manage-branches.outputs.create_update_branch_merged_pr }} 38 | steps: 39 | - uses: actions/checkout@v4 40 | with: 41 | # Required because otherwise there are always changes detected when executing diff/rev-list 42 | fetch-depth: 0 43 | # If no PAT is used the following error occurs on a push: 44 | # refusing to allow a GitHub App to create or update workflow `.github/workflows/xxx.yml` without `workflows` permission 45 | token: ${{ secrets.UPDATE_FROM_TEMPLATE_PAT }} 46 | 47 | - name: Init Git 48 | run: | 49 | git config --global user.email "111048771+xdev-gh-bot@users.noreply.github.com" 50 | git config --global user.name "XDEV Bot" 51 | 52 | - name: Manage branches 53 | id: manage-branches 54 | run: | 55 | echo "Adding remote template-repo" 56 | git remote add template ${{ env.REMOTE_URL }} 57 | 58 | echo "Fetching remote template repo" 59 | git fetch template 60 | 61 | echo "Deleting local branches that will contain the updates - if present" 62 | git branch -D ${{ env.UPDATE_BRANCH }} || true 63 | git branch -D ${{ env.UPDATE_BRANCH_MERGED }} || true 64 | 65 | echo "Checking if the remote template repo has new commits" 66 | git rev-list ..template/${{ env.REMOTE_BRANCH }} 67 | 68 | if [ $(git rev-list --count ..template/${{ env.REMOTE_BRANCH }}) -eq 0 ]; then 69 | echo "There are no commits new commits on the template repo" 70 | 71 | echo "Deleting origin branch(es) that contain the updates - if present" 72 | git push -f origin --delete ${{ env.UPDATE_BRANCH }} || true 73 | git push -f origin --delete ${{ env.UPDATE_BRANCH_MERGED }} || true 74 | 75 | echo "create_update_branch_pr=0" >> $GITHUB_OUTPUT 76 | echo "create_update_branch_merged_pr=0" >> $GITHUB_OUTPUT 77 | exit 0 78 | fi 79 | 80 | echo "Found new commits on the template repo" 81 | 82 | echo "Creating update branch" 83 | git branch ${{ env.UPDATE_BRANCH }} template/${{ env.REMOTE_BRANCH }} 84 | git branch --unset-upstream ${{ env.UPDATE_BRANCH }} 85 | 86 | echo "Pushing update branch" 87 | git push -f -u origin ${{ env.UPDATE_BRANCH }} 88 | 89 | echo "Getting base branch" 90 | base_branch=$(git branch --show-current) 91 | echo "Base branch is $base_branch" 92 | echo "base_branch=$base_branch" >> $GITHUB_OUTPUT 93 | 94 | echo "Trying to create auto-merged branch ${{ env.UPDATE_BRANCH_MERGED }}" 95 | git branch ${{ env.UPDATE_BRANCH_MERGED }} ${{ env.UPDATE_BRANCH }} 96 | git checkout ${{ env.UPDATE_BRANCH_MERGED }} 97 | 98 | echo "Merging branch $base_branch into ${{ env.UPDATE_BRANCH_MERGED }}" 99 | git merge $base_branch && merge_exit_code=$? || merge_exit_code=$? 100 | if [ $merge_exit_code -ne 0 ]; then 101 | echo "Auto merge failed! Manual merge required" 102 | echo "::notice ::Auto merge failed - Manual merge required" 103 | 104 | echo "Cleaning up failed merge" 105 | git merge --abort 106 | git checkout $base_branch 107 | git branch -D ${{ env.UPDATE_BRANCH_MERGED }} || true 108 | 109 | echo "Deleting auto-merge branch - if present" 110 | git push -f origin --delete ${{ env.UPDATE_BRANCH_MERGED }} || true 111 | 112 | echo "create_update_branch_pr=1" >> $GITHUB_OUTPUT 113 | echo "create_update_branch_merged_pr=0" >> $GITHUB_OUTPUT 114 | exit 0 115 | fi 116 | 117 | echo "Post processing: Trying to automatically fill in template variables" 118 | find . -type f \ 119 | -not -path "./.git/**" \ 120 | -not -path "./.github/workflows/update-from-template.yml" -print0 \ 121 | | xargs -0 sed -i "s/template-placeholder/${GITHUB_REPOSITORY#*/}/g" 122 | 123 | git status 124 | git add --all 125 | 126 | if [[ "$(git status --porcelain)" != "" ]]; then 127 | echo "Filled in template; Committing" 128 | 129 | git commit -m "Fill in template" 130 | fi 131 | 132 | echo "Pushing auto-merged branch" 133 | git push -f -u origin ${{ env.UPDATE_BRANCH_MERGED }} 134 | 135 | echo "update_branch_merged_commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT 136 | 137 | echo "Restoring base branch $base_branch" 138 | git checkout $base_branch 139 | 140 | echo "create_update_branch_pr=0" >> $GITHUB_OUTPUT 141 | echo "create_update_branch_merged_pr=1" >> $GITHUB_OUTPUT 142 | echo "try_close_update_branch_pr=1" >> $GITHUB_OUTPUT 143 | 144 | - name: Create/Update PR update_branch 145 | if: steps.manage-branches.outputs.create_update_branch_pr == 1 146 | env: 147 | GH_TOKEN: ${{ secrets.UPDATE_FROM_TEMPLATE_PAT }} 148 | run: | 149 | gh_pr_up() { 150 | gh pr create -H "${{ env.UPDATE_BRANCH }}" "$@" || (git checkout "${{ env.UPDATE_BRANCH }}" && gh pr edit "$@") 151 | } 152 | gh_pr_up -B "${{ steps.manage-branches.outputs.base_branch }}" \ 153 | --title "Update from template" \ 154 | --body "An automated PR to sync changes from the template into this repo" 155 | 156 | # Ensure that only a single PR is open (otherwise confusion and spam) 157 | - name: Close PR update_branch 158 | if: steps.manage-branches.outputs.try_close_update_branch_pr == 1 159 | env: 160 | GH_TOKEN: ${{ secrets.UPDATE_FROM_TEMPLATE_PAT }} 161 | run: | 162 | gh pr close "${{ env.UPDATE_BRANCH }}" || true 163 | 164 | - name: Create/Update PR update_branch_merged 165 | if: steps.manage-branches.outputs.create_update_branch_merged_pr == 1 166 | env: 167 | GH_TOKEN: ${{ secrets.UPDATE_FROM_TEMPLATE_PAT }} 168 | run: | 169 | gh_pr_up() { 170 | gh pr create -H "${{ env.UPDATE_BRANCH_MERGED }}" "$@" || (git checkout "${{ env.UPDATE_BRANCH_MERGED }}" && gh pr edit "$@") 171 | } 172 | gh_pr_up -B "${{ steps.manage-branches.outputs.base_branch }}" \ 173 | --title "Update from template (auto-merged)" \ 174 | --body "An automated PR to sync changes from the template into this repo" 175 | 176 | # Wait a moment so that checks of PR have higher prio than following job 177 | sleep 3 178 | 179 | # Split into two jobs to help with executor starvation 180 | auto-merge: 181 | needs: [update] 182 | if: needs.update.outputs.create_update_branch_merged_pr == 1 183 | runs-on: ubuntu-latest 184 | timeout-minutes: 60 185 | steps: 186 | - uses: actions/checkout@v4 187 | with: 188 | # Required because otherwise there are always changes detected when executing diff/rev-list 189 | fetch-depth: 0 190 | # If no PAT is used the following error occurs on a push: 191 | # refusing to allow a GitHub App to create or update workflow `.github/workflows/xxx.yml` without `workflows` permission 192 | token: ${{ secrets.UPDATE_FROM_TEMPLATE_PAT }} 193 | 194 | - name: Init Git 195 | run: | 196 | git config --global user.email "111048771+xdev-gh-bot@users.noreply.github.com" 197 | git config --global user.name "XDEV Bot" 198 | 199 | - name: Checking if auto-merge for PR update_branch_merged can be done 200 | id: auto-merge-check 201 | env: 202 | GH_TOKEN: ${{ secrets.UPDATE_FROM_TEMPLATE_PAT }} 203 | run: | 204 | not_failed_conclusion="skipped|neutral|success" 205 | not_relevant_app_slug="dependabot|github-pages|sonarqubecloud" 206 | 207 | echo "Waiting for checks to start..." 208 | sleep 40s 209 | 210 | for i in {1..20}; do 211 | echo "Checking if PR can be auto-merged. Try: $i" 212 | 213 | echo "Checking if update-branch-merged exists" 214 | git fetch 215 | if [[ $(git ls-remote --heads origin refs/heads/${{ env.UPDATE_BRANCH_MERGED }}) ]]; then 216 | echo "Branch still exists; Continuing..." 217 | else 218 | echo "Branch origin/${{ env.UPDATE_BRANCH_MERGED }} is missing" 219 | exit 0 220 | fi 221 | 222 | echo "Fetching checks" 223 | cs_response=$(curl -sL \ 224 | --fail-with-body \ 225 | --connect-timeout 60 \ 226 | --max-time 120 \ 227 | -H "Accept: application/vnd.github+json" \ 228 | -H "Authorization: Bearer $GH_TOKEN" \ 229 | -H "X-GitHub-Api-Version: 2022-11-28" \ 230 | https://api.github.com/repos/${{ github.repository }}/commits/${{ needs.update.outputs.update_branch_merged_commit }}/check-suites) 231 | 232 | cs_data=$(echo $cs_response | jq '.check_suites[] | { conclusion: .conclusion, slug: .app.slug, check_runs_url: .check_runs_url }') 233 | echo $cs_data 234 | 235 | if [[ -z "$cs_data" ]]; then 236 | echo "No check suite data - Assuming that there are no checks to run" 237 | 238 | echo "perform=1" >> $GITHUB_OUTPUT 239 | exit 0 240 | fi 241 | 242 | cs_failed=$(echo $cs_data | jq --arg x "$not_failed_conclusion" 'select ((.conclusion == null or (.conclusion | test($x))) | not)') 243 | if [[ -z "$cs_failed" ]]; then 244 | echo "No check failed so far; Checking if relevant checks are still running" 245 | 246 | cs_relevant_still_running=$(echo $cs_data | jq --arg x "$not_relevant_app_slug" 'select (.conclusion == null and (.slug | test($x) | not))') 247 | if [[ -z $cs_relevant_still_running ]]; then 248 | echo "All relevant checks finished - PR can be merged" 249 | 250 | echo "perform=1" >> $GITHUB_OUTPUT 251 | exit 0 252 | else 253 | echo "Relevant checks are still running" 254 | echo $cs_relevant_still_running 255 | fi 256 | else 257 | echo "Detected failed check" 258 | echo $cs_failed 259 | 260 | echo "perform=0" >> $GITHUB_OUTPUT 261 | exit 0 262 | fi 263 | 264 | echo "Waiting before next run..." 265 | sleep 30s 266 | done 267 | 268 | echo "Timed out - Assuming executor starvation - Forcing merge" 269 | echo "perform=1" >> $GITHUB_OUTPUT 270 | 271 | - name: Auto-merge update_branch_merged 272 | if: steps.auto-merge-check.outputs.perform == 1 273 | run: | 274 | echo "Getting base branch" 275 | base_branch=$(git branch --show-current) 276 | echo "Base branch is $base_branch" 277 | 278 | echo "Fetching..." 279 | git fetch 280 | if [[ $(git rev-parse origin/${{ env.UPDATE_BRANCH_MERGED }}) ]]; then 281 | echo "Branch still exists; Continuing..." 282 | else 283 | echo "Branch origin/${{ env.UPDATE_BRANCH_MERGED }} is missing" 284 | exit 0 285 | fi 286 | 287 | expected_commit="${{ needs.update.outputs.update_branch_merged_commit }}" 288 | actual_commit=$(git rev-parse origin/${{ env.UPDATE_BRANCH_MERGED }}) 289 | if [[ "$expected_commit" != "$actual_commit" ]]; then 290 | echo "Branch ${{ env.UPDATE_BRANCH_MERGED }} contains unexpected commit $actual_commit" 291 | echo "Expected: $expected_commit" 292 | 293 | exit 0 294 | fi 295 | 296 | echo "Ensuring that current branch $base_branch is up-to-date" 297 | git pull 298 | 299 | echo "Merging origin/${{ env.UPDATE_BRANCH_MERGED }} into $base_branch" 300 | git merge origin/${{ env.UPDATE_BRANCH_MERGED }} && merge_exit_code=$? || merge_exit_code=$? 301 | if [ $merge_exit_code -ne 0 ]; then 302 | echo "Unexpected merge failure $merge_exit_code - Requires manual resolution" 303 | 304 | exit 0 305 | fi 306 | 307 | if [[ "${{ inputs.no_automatic_merge }}" == "true" ]]; then 308 | echo "Exiting due no_automatic_merge" 309 | 310 | exit 0 311 | fi 312 | 313 | echo "Pushing" 314 | git push 315 | 316 | echo "Cleaning up" 317 | git branch -D ${{ env.UPDATE_BRANCH }} || true 318 | git branch -D ${{ env.UPDATE_BRANCH_MERGED }} || true 319 | git push -f origin --delete ${{ env.UPDATE_BRANCH }} || true 320 | git push -f origin --delete ${{ env.UPDATE_BRANCH_MERGED }} || true 321 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Maven 2 | target/ 3 | pom.xml.tag 4 | pom.xml.releaseBackup 5 | pom.xml.versionsBackup 6 | pom.xml.next 7 | release.properties 8 | dependency-reduced-pom.xml 9 | buildNumber.properties 10 | .mvn/timing.properties 11 | # https://github.com/takari/maven-wrapper#usage-without-binary-jar 12 | .mvn/wrapper/maven-wrapper.jar 13 | 14 | 15 | # Compiled class file 16 | *.class 17 | 18 | # Log file 19 | *.log 20 | 21 | # BlueJ files 22 | *.ctxt 23 | 24 | # Mobile Tools for Java (J2ME) 25 | .mtj.tmp/ 26 | 27 | # Package/Binary Files don't belong into a git repo 28 | *.jar 29 | *.war 30 | *.nar 31 | *.ear 32 | *.zip 33 | *.tar.gz 34 | *.rar 35 | *.dll 36 | *.exe 37 | *.bin 38 | 39 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 40 | hs_err_pid* 41 | 42 | # JRebel 43 | **/resources/rebel.xml 44 | **/resources/rebel-remote.xml 45 | 46 | # eclispe stuff for root 47 | /.settings/ 48 | /.classpath 49 | /.project 50 | 51 | 52 | # eclispe stuff for modules 53 | /*/.metadata/ 54 | /*/.apt_generated_tests/ 55 | /*/.settings/ 56 | /*/.classpath 57 | /*/.project 58 | /*/RemoteSystemsTempFiles/ 59 | 60 | 61 | #vaadin/node webpack/frontend stuff 62 | # Ignore Node 63 | node/ 64 | 65 | # The following files are generated/updated by vaadin-maven-plugin 66 | node_modules/ 67 | 68 | # Vaadin 69 | package.json 70 | package-lock.json 71 | webpack.generated.js 72 | webpack.config.js 73 | tsconfig.json 74 | types.d.ts 75 | vite.config.ts 76 | vite.generated.ts 77 | /*/src/main/frontend/generated/ 78 | /*/src/main/frontend/index.html 79 | /*/src/main/dev-bundle/ 80 | /*/src/main/bundles/ 81 | *.lock 82 | 83 | #custom 84 | .flattened-pom.xml 85 | .tern-project 86 | 87 | # == IntelliJ == 88 | *.iml 89 | *.ipr 90 | 91 | # Some files are user/installation independent and are used for configuring the IDE 92 | # See also https://stackoverflow.com/a/35279076 93 | 94 | .idea/* 95 | !.idea/saveactions_settings.xml 96 | !.idea/checkstyle-idea.xml 97 | !.idea/externalDependencies.xml 98 | 99 | !.idea/inspectionProfiles/ 100 | .idea/inspectionProfiles/* 101 | !.idea/inspectionProfiles/Project_Default.xml 102 | 103 | !.idea/codeStyles/ 104 | .idea/codeStyles/* 105 | !.idea/codeStyles/codeStyleConfig.xml 106 | !.idea/codeStyles/Project.xml 107 | 108 | .run/* 109 | -------------------------------------------------------------------------------- /.idea/checkstyle-idea.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10.21.0 5 | JavaOnlyWithTests 6 | true 7 | true 8 | 12 | 19 | 20 | -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 99 | 100 | -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/externalDependencies.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.idea/saveactions_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip 18 | -------------------------------------------------------------------------------- /.run/Run Demo.run.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 2.1.2 2 | * Migrated deployment to _Sonatype Maven Central Portal_ [#155](https://github.com/xdev-software/standard-maven-template/issues/155) 3 | * Updated dependencies 4 | 5 | # 2.1.1 6 | * Fix naming so that Vaadin Directory sync works [#318](https://github.com/xdev-software/vaadin-addon-template/issues/318) 7 | * Updated dependencies 8 | 9 | # 2.1.0 10 | * Updated to Vaadin 24.4 11 | 12 | # 2.0.1 13 | * ⚠️ GroupId changed from ``com.xdev-software`` to ``software.xdev`` 14 | * Replaced deprecated ``Label``-Vaadin component with ``Span`` 15 | * Updated dependencies 16 | 17 | # 2.0.0 18 | ⚠️This release contains breaking changes 19 | 20 | * Adds support for Vaadin 24+, drops support for Vaadin 23
21 | If you are still using Vaadin 23, use the ``1.x`` versions. 22 | * Requires Java 17+ 23 | * Updated dependencies 24 | 25 | 26 | # 1.0.1 27 | * Updated dependencies 28 | 29 | # 1.0.0 30 | Initial release 31 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Contributing 2 | 3 | We would absolutely love to get the community involved, and we welcome any form of contributions – comments and questions on different communication channels, issues and pull request and anything that you build and share using our components. 4 | 5 | ### Communication channels 6 | * Communication is primarily done using issues. 7 | * If you need support as soon as possible and you can't wait for any pull request, feel free to use [our support](https://xdev.software/en/services/support). 8 | * As a last resort measure or on otherwise important matter you may also [contact us directly](https://xdev.software/en/about-us/contact). 9 | 10 | ### Ways to help 11 | * **Report bugs**
Create an issue or send a pull request 12 | * **Send pull requests**
If you want to contribute code, check out the development instructions below. 13 | * However when contributing larger new features, please first discuss the change you wish to make via issue with the owners of this repository before making it.
Otherwise your work might be rejected and your effort was pointless. 14 | 15 | We also encourage you to read the [contribution instructions by GitHub](https://docs.github.com/en/get-started/quickstart/contributing-to-projects). 16 | 17 | ## Developing 18 | 19 | ### Software Requirements 20 | You should have the following things installed: 21 | * Git 22 | * Java 21 - should be as unmodified as possible (Recommended: [Eclipse Adoptium](https://adoptium.net/temurin/releases/)) 23 | * Maven (Note that the [Maven Wrapper](https://maven.apache.org/wrapper/) is shipped with the repo) 24 | 25 | ### Recommended setup 26 | * Install ``IntelliJ`` (Community Edition is sufficient) 27 | * Install the following plugins: 28 | * [Save Actions](https://plugins.jetbrains.com/plugin/22113) - Provides save actions, like running the formatter or adding ``final`` to fields 29 | * [SonarLint](https://plugins.jetbrains.com/plugin/7973-sonarlint) - CodeStyle/CodeAnalysis 30 | * You may consider disabling telemetry in the settings under ``Tools > Sonarlint -> About`` 31 | * [Checkstyle-IDEA](https://plugins.jetbrains.com/plugin/1065-checkstyle-idea) - CodeStyle/CodeAnalysis 32 | * Import the project 33 | * Ensure that everything is encoded in ``UTF-8`` 34 | * Ensure that the JDK/Java-Version is correct 35 | * To enable AUTOMATIC reloading/restarting while developing and running the app do this (further information in " 36 | SpringBoot-Devtools" section below; [Source](https://stackoverflow.com/q/33349456)): 37 | * ``Settings > Build, Execution, Deployment > Compiler``:
38 | Enable [``Build project automatically``](https://www.jetbrains.com/help/idea/compiling-applications.html#auto-build) 39 | * ``Settings > Advanced Settings``:
40 | Enable [``Allow auto-make to start even if developed application is currently running``](https://www.jetbrains.com/help/idea/advanced-settings.html#advanced_compiler) 41 | * To launch the Demo execute the predefined (launch) configuration ``Run Demo`` 42 | 43 | #### [SpringBoot-Developer-Tools](https://docs.spring.io/spring-boot/docs/current/reference/html/using.html#using.devtools) 44 | ... should automatically be enabled.
45 | If you are changing a file and build the project, parts of the app get restarted.
46 | Bigger changes may require a complete restart. 47 | * [Vaadin automatically reloads the UI on each restart](https://vaadin.com/docs/latest/configuration/live-reload/spring-boot).
48 | You can control this behavior with the ``vaadin.devmode.liveReload.enabled`` property (default: ``true``). 49 | 50 | ## Releasing [![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/vaadin-editable-label/release.yml?branch=master)](https://github.com/xdev-software/vaadin-editable-label/actions/workflows/release.yml) 51 | 52 | Before releasing: 53 | * Consider doing a [test-deployment](https://github.com/xdev-software/vaadin-editable-label/actions/workflows/test-deploy.yml?query=branch%3Adevelop) before actually releasing. 54 | * Check the [changelog](CHANGELOG.md) 55 | 56 | If the ``develop`` is ready for release, create a pull request to the ``master``-Branch and merge the changes 57 | 58 | When the release is finished do the following: 59 | * Merge the auto-generated PR (with the incremented version number) back into the ``develop`` 60 | * Ensure that [Vaadin Directory](https://vaadin.com/directory) syncs the update and maybe update the component / version there 61 | 62 | ### Release failures 63 | 64 | There are 2 modes of release failure: 65 | 1. The remote server was e.g. down and non of the artifacts got published 66 | 2. There was a build failure during release and only parts of the artifacts got released 67 | 68 | In case 1 we can re-release the existing version,
in case 2 we have to release a new version when we can't get the artifacts deleted (as is the case with Maven Central) 69 | 70 | #### How-to: Re-Releasing an existing version 71 | 72 | 1. Delete the release on GitHub 73 | 2. Delete the release Git tag from the repo (locally and remote!) 74 | 3. Delete the ``master``-Branch and re-create it from the ``develop`` branch (or reset it to the state before the release-workflow commits have been done) 75 | * This requires __temporarily__ removing the branch protection 76 | * Once this was done a new release is triggered immediately! 77 | 78 | #### How-to: Releasing a new version 79 | 80 | 1. Merge the ``master`` branch back into ``develop`` (or another temporary branch) 81 | 2. Make sure all master branch versions are prepared for a new release
e.g. if the broken release was ``1.0.0`` the version should now be at ``1.0.1-SNAPSHOT`` - the ``SNAPSHOT`` is important for the workflow! 82 | 3. Mark the broken release as broken e.g. inside the Changelog, GitHub Release page, etc.
83 | You can use something like this: 84 | ``` 85 | > [!WARNING] 86 | > This release is broken as my cat accidentally clicked the abort button during the process 87 | ``` 88 | 4. Merge the changes back into the ``master`` branch to trigger a new release 89 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2024 XDEV Software 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Published on Vaadin Directory](https://img.shields.io/badge/Vaadin%20Directory-published-00b4f0?logo=vaadin)](https://vaadin.com/directory/component/editable-labels-for-vaadin) 2 | [![Latest version](https://img.shields.io/maven-central/v/software.xdev/vaadin-editable-label?logo=apache%20maven)](https://mvnrepository.com/artifact/software.xdev/vaadin-editable-label) 3 | [![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/vaadin-editable-label/check-build.yml?branch=develop)](https://github.com/xdev-software/vaadin-editable-label/actions/workflows/check-build.yml?query=branch%3Adevelop) 4 | [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=xdev-software_vaadin-editable-label&metric=alert_status)](https://sonarcloud.io/dashboard?id=xdev-software_vaadin-editable-label) 5 | ![Vaadin 24+](https://img.shields.io/badge/Vaadin%20Platform/Flow-24+-00b4f0) 6 | 7 | # Editable Labels for Vaadin 8 | A Vaadin Flow implementation for editable labels 9 | 10 | ![demo](assets/demo.png) 11 | 12 | This component provides a couple of elements that are displayed as simple read-only components, but can be edited with a 13 | simple click. 14 | Following components are available: 15 | 16 | * [EditableLabelTextField](./vaadin-editable-label/src/main/java/software/xdev/vaadin/editable_label/predefined/EditableLabelTextField.java) 17 | * [EditableLabelTextArea](./vaadin-editable-label/src/main/java/software/xdev/vaadin/editable_label/predefined/EditableLabelTextArea.java) 18 | * [EditableLabelComboBox](./vaadin-editable-label/src/main/java/software/xdev/vaadin/editable_label/predefined/EditableLabelComboBox.java) 19 | * [EditableLabelDatePicker](./vaadin-editable-label/src/main/java/software/xdev/vaadin/editable_label/predefined/EditableLabelDatePicker.java) 20 | * [EditableLabelNumberField](./vaadin-editable-label/src/main/java/software/xdev/vaadin/editable_label/predefined/EditableLabelNumberField.java) 21 | * [EditableLabelBigDecimalField](./vaadin-editable-label/src/main/java/software/xdev/vaadin/editable_label/predefined/EditableLabelBigDecimalField.java) 22 | 23 | It's also possible to create a custom element: 24 | 25 | ```java 26 | final EditableLabel emailLabel = new EditableLabel<>(new EmailField()).withValue(defaultValue); 27 | ``` 28 | 29 | ## Installation 30 | [Installation guide for the latest release](https://github.com/xdev-software/vaadin-editable-label/releases/latest#Installation) 31 | 32 | #### Compatibility with Vaadin 33 | | Vaadin version | Editable label version | 34 | | --- | --- | 35 | | Vaadin 24+ (latest) | ``2+`` | 36 | | Vaadin 23 | ``1.x`` | 37 | 38 | ### Spring-Boot 39 | * You may have to include ``software/xdev`` inside [``vaadin.allowed-packages``](https://vaadin.com/docs/latest/integrations/spring/configuration#configure-the-scanning-of-packages) 40 | 41 | ## Run the Demo 42 | * Checkout the repo 43 | * Run ``mvn install && mvn -f vaadin-editable-label-demo spring-boot:run`` 44 | * Open http://localhost:8080 45 | 46 |
47 | Show example 48 | 49 | ![demo](assets/demo.avif) 50 |
51 | 52 | ## Support 53 | If you need support as soon as possible and you can't wait for any pull request, feel free to use [our support](https://xdev.software/en/services/support). 54 | 55 | ## Contributing 56 | See the [contributing guide](./CONTRIBUTING.md) for detailed instructions on how to get started with our project. 57 | 58 | ## Dependencies and Licenses 59 | View the [license of the current project](LICENSE) or the [summary including all dependencies](https://xdev-software.github.io/vaadin-editable-label/dependencies) 60 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Reporting a Vulnerability 4 | 5 | Please report a security vulnerability [on GitHub Security Advisories](https://github.com/xdev-software/vaadin-editable-label/security/advisories/new). 6 | -------------------------------------------------------------------------------- /assets/demo.avif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdev-software/vaadin-editable-label/15207ae54417247903b8af9c7cb129230b085b6a/assets/demo.avif -------------------------------------------------------------------------------- /assets/demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdev-software/vaadin-editable-label/15207ae54417247903b8af9c7cb129230b085b6a/assets/demo.png -------------------------------------------------------------------------------- /mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Apache Maven Wrapper startup batch script, version 3.3.0 23 | # 24 | # Optional ENV vars 25 | # ----------------- 26 | # JAVA_HOME - location of a JDK home dir, required when download maven via java source 27 | # MVNW_REPOURL - repo url base for downloading maven distribution 28 | # MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven 29 | # MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output 30 | # ---------------------------------------------------------------------------- 31 | 32 | set -euf 33 | [ "${MVNW_VERBOSE-}" != debug ] || set -x 34 | 35 | # OS specific support. 36 | native_path() { printf %s\\n "$1"; } 37 | case "$(uname)" in 38 | CYGWIN* | MINGW*) 39 | [ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")" 40 | native_path() { cygpath --path --windows "$1"; } 41 | ;; 42 | esac 43 | 44 | # set JAVACMD and JAVACCMD 45 | set_java_home() { 46 | # For Cygwin and MinGW, ensure paths are in Unix format before anything is touched 47 | if [ -n "${JAVA_HOME-}" ]; then 48 | if [ -x "$JAVA_HOME/jre/sh/java" ]; then 49 | # IBM's JDK on AIX uses strange locations for the executables 50 | JAVACMD="$JAVA_HOME/jre/sh/java" 51 | JAVACCMD="$JAVA_HOME/jre/sh/javac" 52 | else 53 | JAVACMD="$JAVA_HOME/bin/java" 54 | JAVACCMD="$JAVA_HOME/bin/javac" 55 | 56 | if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then 57 | echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2 58 | echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2 59 | return 1 60 | fi 61 | fi 62 | else 63 | JAVACMD="$( 64 | 'set' +e 65 | 'unset' -f command 2>/dev/null 66 | 'command' -v java 67 | )" || : 68 | JAVACCMD="$( 69 | 'set' +e 70 | 'unset' -f command 2>/dev/null 71 | 'command' -v javac 72 | )" || : 73 | 74 | if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then 75 | echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2 76 | return 1 77 | fi 78 | fi 79 | } 80 | 81 | # hash string like Java String::hashCode 82 | hash_string() { 83 | str="${1:-}" h=0 84 | while [ -n "$str" ]; do 85 | char="${str%"${str#?}"}" 86 | h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296)) 87 | str="${str#?}" 88 | done 89 | printf %x\\n $h 90 | } 91 | 92 | verbose() { :; } 93 | [ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; } 94 | 95 | die() { 96 | printf %s\\n "$1" >&2 97 | exit 1 98 | } 99 | 100 | # parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties 101 | while IFS="=" read -r key value; do 102 | case "${key-}" in 103 | distributionUrl) distributionUrl="${value-}" ;; 104 | distributionSha256Sum) distributionSha256Sum="${value-}" ;; 105 | esac 106 | done <"${0%/*}/.mvn/wrapper/maven-wrapper.properties" 107 | [ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in ${0%/*}/.mvn/wrapper/maven-wrapper.properties" 108 | 109 | case "${distributionUrl##*/}" in 110 | maven-mvnd-*bin.*) 111 | MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ 112 | case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in 113 | *AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;; 114 | :Darwin*x86_64) distributionPlatform=darwin-amd64 ;; 115 | :Darwin*arm64) distributionPlatform=darwin-aarch64 ;; 116 | :Linux*x86_64*) distributionPlatform=linux-amd64 ;; 117 | *) 118 | echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2 119 | distributionPlatform=linux-amd64 120 | ;; 121 | esac 122 | distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip" 123 | ;; 124 | maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;; 125 | *) MVN_CMD="mvn${0##*/mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;; 126 | esac 127 | 128 | # apply MVNW_REPOURL and calculate MAVEN_HOME 129 | # maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ 130 | [ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}" 131 | distributionUrlName="${distributionUrl##*/}" 132 | distributionUrlNameMain="${distributionUrlName%.*}" 133 | distributionUrlNameMain="${distributionUrlNameMain%-bin}" 134 | MAVEN_HOME="$HOME/.m2/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")" 135 | 136 | exec_maven() { 137 | unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || : 138 | exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD" 139 | } 140 | 141 | if [ -d "$MAVEN_HOME" ]; then 142 | verbose "found existing MAVEN_HOME at $MAVEN_HOME" 143 | exec_maven "$@" 144 | fi 145 | 146 | case "${distributionUrl-}" in 147 | *?-bin.zip | *?maven-mvnd-?*-?*.zip) ;; 148 | *) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;; 149 | esac 150 | 151 | # prepare tmp dir 152 | if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then 153 | clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; } 154 | trap clean HUP INT TERM EXIT 155 | else 156 | die "cannot create temp dir" 157 | fi 158 | 159 | mkdir -p -- "${MAVEN_HOME%/*}" 160 | 161 | # Download and Install Apache Maven 162 | verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." 163 | verbose "Downloading from: $distributionUrl" 164 | verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" 165 | 166 | # select .zip or .tar.gz 167 | if ! command -v unzip >/dev/null; then 168 | distributionUrl="${distributionUrl%.zip}.tar.gz" 169 | distributionUrlName="${distributionUrl##*/}" 170 | fi 171 | 172 | # verbose opt 173 | __MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR='' 174 | [ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v 175 | 176 | # normalize http auth 177 | case "${MVNW_PASSWORD:+has-password}" in 178 | '') MVNW_USERNAME='' MVNW_PASSWORD='' ;; 179 | has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;; 180 | esac 181 | 182 | if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then 183 | verbose "Found wget ... using wget" 184 | wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl" 185 | elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then 186 | verbose "Found curl ... using curl" 187 | curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl" 188 | elif set_java_home; then 189 | verbose "Falling back to use Java to download" 190 | javaSource="$TMP_DOWNLOAD_DIR/Downloader.java" 191 | targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName" 192 | cat >"$javaSource" <<-END 193 | public class Downloader extends java.net.Authenticator 194 | { 195 | protected java.net.PasswordAuthentication getPasswordAuthentication() 196 | { 197 | return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() ); 198 | } 199 | public static void main( String[] args ) throws Exception 200 | { 201 | setDefault( new Downloader() ); 202 | java.nio.file.Files.copy( new java.net.URL( args[0] ).openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() ); 203 | } 204 | } 205 | END 206 | # For Cygwin/MinGW, switch paths to Windows format before running javac and java 207 | verbose " - Compiling Downloader.java ..." 208 | "$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java" 209 | verbose " - Running Downloader.java ..." 210 | "$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")" 211 | fi 212 | 213 | # If specified, validate the SHA-256 sum of the Maven distribution zip file 214 | if [ -n "${distributionSha256Sum-}" ]; then 215 | distributionSha256Result=false 216 | if [ "$MVN_CMD" = mvnd.sh ]; then 217 | echo "Checksum validation is not supported for maven-mvnd." >&2 218 | echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 219 | exit 1 220 | elif command -v sha256sum >/dev/null; then 221 | if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c >/dev/null 2>&1; then 222 | distributionSha256Result=true 223 | fi 224 | elif command -v shasum >/dev/null; then 225 | if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then 226 | distributionSha256Result=true 227 | fi 228 | else 229 | echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2 230 | echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 231 | exit 1 232 | fi 233 | if [ $distributionSha256Result = false ]; then 234 | echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2 235 | echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2 236 | exit 1 237 | fi 238 | fi 239 | 240 | # unzip and move 241 | if command -v unzip >/dev/null; then 242 | unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip" 243 | else 244 | tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar" 245 | fi 246 | printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/mvnw.url" 247 | mv -- "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME" 248 | 249 | clean || : 250 | exec_maven "$@" 251 | -------------------------------------------------------------------------------- /mvnw.cmd: -------------------------------------------------------------------------------- 1 | <# : batch portion 2 | @REM ---------------------------------------------------------------------------- 3 | @REM Licensed to the Apache Software Foundation (ASF) under one 4 | @REM or more contributor license agreements. See the NOTICE file 5 | @REM distributed with this work for additional information 6 | @REM regarding copyright ownership. The ASF licenses this file 7 | @REM to you under the Apache License, Version 2.0 (the 8 | @REM "License"); you may not use this file except in compliance 9 | @REM with the License. You may obtain a copy of the License at 10 | @REM 11 | @REM http://www.apache.org/licenses/LICENSE-2.0 12 | @REM 13 | @REM Unless required by applicable law or agreed to in writing, 14 | @REM software distributed under the License is distributed on an 15 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | @REM KIND, either express or implied. See the License for the 17 | @REM specific language governing permissions and limitations 18 | @REM under the License. 19 | @REM ---------------------------------------------------------------------------- 20 | 21 | @REM ---------------------------------------------------------------------------- 22 | @REM Apache Maven Wrapper startup batch script, version 3.3.0 23 | @REM 24 | @REM Optional ENV vars 25 | @REM MVNW_REPOURL - repo url base for downloading maven distribution 26 | @REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven 27 | @REM MVNW_VERBOSE - true: enable verbose log; others: silence the output 28 | @REM ---------------------------------------------------------------------------- 29 | 30 | @IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) 31 | @SET __MVNW_CMD__= 32 | @SET __MVNW_ERROR__= 33 | @SET __MVNW_PSMODULEP_SAVE=%PSModulePath% 34 | @SET PSModulePath= 35 | @FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( 36 | IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) 37 | ) 38 | @SET PSModulePath=%__MVNW_PSMODULEP_SAVE% 39 | @SET __MVNW_PSMODULEP_SAVE= 40 | @SET __MVNW_ARG0_NAME__= 41 | @SET MVNW_USERNAME= 42 | @SET MVNW_PASSWORD= 43 | @IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*) 44 | @echo Cannot start maven from wrapper >&2 && exit /b 1 45 | @GOTO :EOF 46 | : end batch / begin powershell #> 47 | 48 | $ErrorActionPreference = "Stop" 49 | if ($env:MVNW_VERBOSE -eq "true") { 50 | $VerbosePreference = "Continue" 51 | } 52 | 53 | # calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties 54 | $distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl 55 | if (!$distributionUrl) { 56 | Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" 57 | } 58 | 59 | switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { 60 | "maven-mvnd-*" { 61 | $USE_MVND = $true 62 | $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" 63 | $MVN_CMD = "mvnd.cmd" 64 | break 65 | } 66 | default { 67 | $USE_MVND = $false 68 | $MVN_CMD = $script -replace '^mvnw','mvn' 69 | break 70 | } 71 | } 72 | 73 | # apply MVNW_REPOURL and calculate MAVEN_HOME 74 | # maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ 75 | if ($env:MVNW_REPOURL) { 76 | $MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" } 77 | $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')" 78 | } 79 | $distributionUrlName = $distributionUrl -replace '^.*/','' 80 | $distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' 81 | $MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain" 82 | $MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' 83 | $MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" 84 | 85 | if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { 86 | Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" 87 | Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" 88 | exit $? 89 | } 90 | 91 | if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { 92 | Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" 93 | } 94 | 95 | # prepare tmp dir 96 | $TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile 97 | $TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" 98 | $TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null 99 | trap { 100 | if ($TMP_DOWNLOAD_DIR.Exists) { 101 | try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } 102 | catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } 103 | } 104 | } 105 | 106 | New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null 107 | 108 | # Download and Install Apache Maven 109 | Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." 110 | Write-Verbose "Downloading from: $distributionUrl" 111 | Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" 112 | 113 | $webclient = New-Object System.Net.WebClient 114 | if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { 115 | $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) 116 | } 117 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 118 | $webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null 119 | 120 | # If specified, validate the SHA-256 sum of the Maven distribution zip file 121 | $distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum 122 | if ($distributionSha256Sum) { 123 | if ($USE_MVND) { 124 | Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." 125 | } 126 | Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash 127 | if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { 128 | Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." 129 | } 130 | } 131 | 132 | # unzip and move 133 | Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null 134 | Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null 135 | try { 136 | Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null 137 | } catch { 138 | if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { 139 | Write-Error "fail to move MAVEN_HOME" 140 | } 141 | } finally { 142 | try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } 143 | catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } 144 | } 145 | 146 | Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" 147 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | software.xdev 8 | vaadin-editable-label-root 9 | 2.1.3-SNAPSHOT 10 | pom 11 | 12 | 13 | XDEV Software 14 | https://xdev.software 15 | 16 | 17 | 18 | vaadin-editable-label 19 | vaadin-editable-label-demo 20 | 21 | 22 | 23 | UTF-8 24 | UTF-8 25 | 26 | 27 | 28 | 29 | Apache-2.0 30 | https://www.apache.org/licenses/LICENSE-2.0.txt 31 | repo 32 | 33 | 34 | 35 | 36 | 37 | checkstyle 38 | 39 | 40 | 41 | org.apache.maven.plugins 42 | maven-checkstyle-plugin 43 | 3.6.0 44 | 45 | 46 | com.puppycrawl.tools 47 | checkstyle 48 | 10.24.0 49 | 50 | 51 | 52 | .config/checkstyle/checkstyle.xml 53 | true 54 | 55 | 56 | 57 | 58 | check 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | pmd 68 | 69 | 70 | 71 | org.apache.maven.plugins 72 | maven-pmd-plugin 73 | 3.26.0 74 | 75 | true 76 | true 77 | 78 | .config/pmd/ruleset.xml 79 | 80 | 81 | 82 | 83 | net.sourceforge.pmd 84 | pmd-core 85 | 7.13.0 86 | 87 | 88 | net.sourceforge.pmd 89 | pmd-java 90 | 7.13.0 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | org.apache.maven.plugins 101 | maven-jxr-plugin 102 | 3.6.0 103 | 104 | 105 | 106 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /renovate.json5: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "rebaseWhen": "behind-base-branch", 4 | "packageRules": [ 5 | { 6 | "description": "Ignore project internal dependencies", 7 | "packagePattern": "^software.xdev:vaadin-editable-label", 8 | "datasources": [ 9 | "maven" 10 | ], 11 | "enabled": false 12 | }, 13 | { 14 | "description": "Group net.sourceforge.pmd", 15 | "matchPackagePatterns": [ 16 | "^net.sourceforge.pmd" 17 | ], 18 | "datasources": [ 19 | "maven" 20 | ], 21 | "groupName": "net.sourceforge.pmd" 22 | } 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /vaadin-editable-label-demo/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | software.xdev 9 | vaadin-editable-label-root 10 | 2.1.3-SNAPSHOT 11 | 12 | 13 | vaadin-editable-label-demo 14 | 2.1.3-SNAPSHOT 15 | jar 16 | 17 | 18 | XDEV Software 19 | https://xdev.software 20 | 21 | 22 | 23 | 17 24 | ${javaVersion} 25 | 26 | UTF-8 27 | UTF-8 28 | 29 | software.xdev.vaadin.Application 30 | 31 | 32 | 24.7.4 33 | 34 | 3.4.5 35 | 36 | 37 | 38 | 39 | 40 | com.vaadin 41 | vaadin-bom 42 | pom 43 | import 44 | ${vaadin.version} 45 | 46 | 47 | 48 | 49 | 50 | 51 | org.springframework.boot 52 | spring-boot-dependencies 53 | ${org.springframework.boot.version} 54 | pom 55 | import 56 | 57 | 58 | 59 | 60 | 61 | 62 | com.vaadin 63 | vaadin-core 64 | 65 | 66 | com.vaadin 67 | hilla-dev 68 | 69 | 70 | 71 | 72 | software.xdev 73 | vaadin-editable-label 74 | ${project.version} 75 | 76 | 77 | 78 | 79 | com.vaadin 80 | vaadin-spring-boot-starter 81 | 82 | 83 | com.vaadin 84 | hilla 85 | 86 | 87 | 88 | 89 | 90 | org.yaml 91 | snakeyaml 92 | 93 | 94 | org.springframework.boot 95 | spring-boot-devtools 96 | true 97 | 98 | 99 | 100 | 101 | ${project.artifactId} 102 | 103 | 104 | 105 | 106 | org.springframework.boot 107 | spring-boot-maven-plugin 108 | ${org.springframework.boot.version} 109 | 110 | 111 | 112 | 113 | 114 | 115 | com.vaadin 116 | vaadin-maven-plugin 117 | ${vaadin.version} 118 | 119 | 120 | 121 | prepare-frontend 122 | 123 | 124 | 125 | 126 | 127 | org.apache.maven.plugins 128 | maven-compiler-plugin 129 | 3.14.0 130 | 131 | ${maven.compiler.release} 132 | 133 | -proc:none 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | production 143 | 144 | 145 | 146 | com.vaadin 147 | vaadin-core 148 | 149 | 150 | com.vaadin 151 | vaadin-dev 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | com.vaadin 160 | vaadin-maven-plugin 161 | ${vaadin.version} 162 | 163 | 164 | 165 | prepare-frontend 166 | build-frontend 167 | 168 | 169 | 170 | 171 | 172 | org.springframework.boot 173 | spring-boot-maven-plugin 174 | 175 | ${mainClass} 176 | 177 | 178 | 179 | repackage 180 | 181 | repackage 182 | 183 | package 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | -------------------------------------------------------------------------------- /vaadin-editable-label-demo/src/main/java/software/xdev/vaadin/Application.java: -------------------------------------------------------------------------------- 1 | package software.xdev.vaadin; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; 6 | 7 | import com.vaadin.flow.component.page.AppShellConfigurator; 8 | import com.vaadin.flow.component.page.Push; 9 | import com.vaadin.flow.spring.annotation.EnableVaadin; 10 | 11 | 12 | @SuppressWarnings({"checkstyle:HideUtilityClassConstructor", "PMD.UseUtilityClass"}) 13 | @SpringBootApplication 14 | @EnableVaadin 15 | @Push 16 | public class Application extends SpringBootServletInitializer implements AppShellConfigurator 17 | { 18 | public static void main(final String[] args) 19 | { 20 | SpringApplication.run(Application.class, args); 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /vaadin-editable-label-demo/src/main/java/software/xdev/vaadin/editable_label/HomeView.java: -------------------------------------------------------------------------------- 1 | package software.xdev.vaadin.editable_label; 2 | 3 | import static java.util.Map.entry; 4 | 5 | import java.math.BigDecimal; 6 | import java.text.NumberFormat; 7 | import java.time.LocalDate; 8 | import java.util.Map; 9 | import java.util.concurrent.Executors; 10 | import java.util.concurrent.ScheduledExecutorService; 11 | import java.util.concurrent.TimeUnit; 12 | 13 | import org.slf4j.Logger; 14 | import org.slf4j.LoggerFactory; 15 | 16 | import com.vaadin.flow.component.Composite; 17 | import com.vaadin.flow.component.button.Button; 18 | import com.vaadin.flow.component.datepicker.DatePicker; 19 | import com.vaadin.flow.component.formlayout.FormLayout; 20 | import com.vaadin.flow.component.html.H4; 21 | import com.vaadin.flow.component.orderedlayout.FlexComponent; 22 | import com.vaadin.flow.component.orderedlayout.HorizontalLayout; 23 | import com.vaadin.flow.component.orderedlayout.VerticalLayout; 24 | import com.vaadin.flow.component.textfield.EmailField; 25 | import com.vaadin.flow.component.textfield.TextArea; 26 | import com.vaadin.flow.component.textfield.TextAreaVariant; 27 | import com.vaadin.flow.router.PageTitle; 28 | import com.vaadin.flow.router.Route; 29 | 30 | import software.xdev.vaadin.editable_label.predefined.EditableLabelBigDecimalField; 31 | import software.xdev.vaadin.editable_label.predefined.EditableLabelComboBox; 32 | import software.xdev.vaadin.editable_label.predefined.EditableLabelDatePicker; 33 | import software.xdev.vaadin.editable_label.predefined.EditableLabelNumberField; 34 | import software.xdev.vaadin.editable_label.predefined.EditableLabelTextArea; 35 | import software.xdev.vaadin.editable_label.predefined.EditableLabelTextField; 36 | 37 | 38 | @PageTitle("Editable Label Examples") 39 | @Route("") 40 | public class HomeView extends Composite 41 | { 42 | private static final Logger LOG = LoggerFactory.getLogger(HomeView.class); 43 | private final TextArea valueChangeEventTa = new TextArea(); 44 | 45 | public HomeView() 46 | { 47 | this.initUI(); 48 | } 49 | 50 | private void initUI() 51 | { 52 | this.valueChangeEventTa.setReadOnly(true); 53 | this.valueChangeEventTa.addThemeVariants(TextAreaVariant.LUMO_SMALL); 54 | this.valueChangeEventTa.setWidthFull(); 55 | 56 | this.getContent().setSpacing(false); 57 | this.getContent().add( 58 | new H4("Predefined components"), 59 | this.getPredefinedComponents(), 60 | new H4("Custom Component"), 61 | this.getCustomComponent(), 62 | new H4("Event"), 63 | this.valueChangeEventTa); 64 | } 65 | 66 | @SuppressWarnings("checkstyle:MagicNumber") 67 | private FormLayout getPredefinedComponents() 68 | { 69 | final FormLayout formLayout = new FormLayout(); 70 | formLayout.setResponsiveSteps( 71 | new FormLayout.ResponsiveStep( 72 | "0", 73 | 1, 74 | FormLayout.ResponsiveStep.LabelsPosition.TOP), 75 | new FormLayout.ResponsiveStep( 76 | "800px", 77 | 2, 78 | FormLayout.ResponsiveStep.LabelsPosition.TOP)); 79 | 80 | // Types are required here otherwise a compile error occurs (see https://github.com/vaadin/flow/issues/7920) 81 | Map.>ofEntries( 82 | entry( 83 | "TextField", 84 | new EditableLabelTextField() 85 | .withValue("Some text")), 86 | entry( 87 | "TextField with empty value", 88 | new EditableLabelTextField()), 89 | entry( 90 | "Textarea", 91 | new EditableLabelTextArea() 92 | .withValue( 93 | "Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut " 94 | + "labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation " 95 | + "ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure " 96 | + "reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.")), 97 | entry( 98 | "NumberField", 99 | new EditableLabelNumberField() 100 | .withValue(123.45)), 101 | entry( 102 | "BigDecimalField", 103 | new EditableLabelBigDecimalField() 104 | .withValue(BigDecimal.ONE)), 105 | entry( 106 | "BigDecimalField with currency", 107 | new EditableLabelBigDecimalField() 108 | .withValue(BigDecimal.TEN) 109 | .withNumberFormat(NumberFormat.getCurrencyInstance())), 110 | entry( 111 | "ComboBox", 112 | new EditableLabelComboBox() 113 | .withItems(Vehicle.values()) 114 | .withValue(Vehicle.PLANE) 115 | .withLabelGenerator(Vehicle::getEmoji)), 116 | entry( 117 | "ComboBox with empty value 🚲", 118 | new EditableLabelComboBox(el -> el.getEditor().setClearButtonVisible(true)) 119 | .withItems(Vehicle.values()) 120 | .withLabelGenerator(Vehicle::getEmoji, "🚲")), 121 | entry( 122 | "DatePicker", 123 | new EditableLabelDatePicker() 124 | ), 125 | entry( 126 | "DatePicker with I18N", 127 | new EditableLabelDatePicker(getDatepickerWithI18N()) 128 | .withValue(LocalDate.of(2000, 1, 1)) 129 | .withTryUseI18NFormat() 130 | ) 131 | ).entrySet() 132 | .stream() 133 | .sorted(Map.Entry.comparingByKey()) 134 | .forEach(e -> { 135 | this.registerValueChangeEvent(e.getKey(), e.getValue()); 136 | formLayout.addFormItem(e.getValue(), e.getKey()); 137 | }); 138 | 139 | return formLayout; 140 | } 141 | 142 | private HorizontalLayout getCustomComponent() 143 | { 144 | final String defaultValue = "example@example.com"; 145 | final EditableLabel emailLabel = new EditableLabel<>(new EmailField()) 146 | .withValue(defaultValue); 147 | 148 | this.registerValueChangeEvent("Custom-Component", emailLabel); 149 | 150 | final Button btnRestoreDefault = new Button("Restore default", ev -> emailLabel.setValue(defaultValue)); 151 | 152 | final ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(); 153 | final Button btnRestoreDefaultIn5s = 154 | new Button( 155 | "Restore default in 5s", 156 | ev -> scheduledExecutorService.schedule( 157 | () -> ev.getSource().getUI().ifPresent(ui -> { 158 | try 159 | { 160 | ui.access(() -> 161 | { 162 | emailLabel.setValue(defaultValue); 163 | ev.getSource().setEnabled(true); 164 | }); 165 | } 166 | catch(final Exception ex) 167 | { 168 | // Ignore 169 | } 170 | }), 171 | 5, 172 | TimeUnit.SECONDS)); 173 | btnRestoreDefaultIn5s.setDisableOnClick(true); 174 | 175 | final HorizontalLayout hlButtons = new HorizontalLayout(); 176 | hlButtons.add(btnRestoreDefault, btnRestoreDefaultIn5s); 177 | 178 | final HorizontalLayout hl = new HorizontalLayout(); 179 | hl.add(emailLabel, hlButtons); 180 | hl.setJustifyContentMode(FlexComponent.JustifyContentMode.BETWEEN); 181 | hl.setWidthFull(); 182 | return hl; 183 | } 184 | 185 | private void registerValueChangeEvent(final String source, final AbstractEditableLabel ael) 186 | { 187 | ael.addValueChangeListener(ev -> { 188 | final String header = "Source '" + source + "' - ValueChangeEvent"; 189 | final String text = "value: " + ev.getValue() + "\n" 190 | + "oldValue: " + ev.getOldValue() + "\n" 191 | + "isFromClient: " + ev.isFromClient(); 192 | LOG.info("{}\n{}", header, text); 193 | 194 | this.valueChangeEventTa.setLabel(header); 195 | this.valueChangeEventTa.setValue(text); 196 | }); 197 | } 198 | 199 | private static DatePicker getDatepickerWithI18N() 200 | { 201 | final DatePicker datePicker = new DatePicker(); 202 | datePicker.setI18n(new DatePicker.DatePickerI18n() 203 | .setDateFormat("yyyy⏰MM⏰dd")); 204 | return datePicker; 205 | } 206 | 207 | enum Vehicle 208 | { 209 | CAR("🚗"), 210 | TRAIN("🚂"), 211 | PLANE("✈"); 212 | 213 | private final String emoji; 214 | 215 | Vehicle(final String emoji) 216 | { 217 | this.emoji = emoji; 218 | } 219 | 220 | public String getEmoji() 221 | { 222 | return this.emoji; 223 | } 224 | } 225 | } 226 | -------------------------------------------------------------------------------- /vaadin-editable-label-demo/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | vaadin: 2 | allowed-packages: software/xdev,com/vaadin/flow 3 | devmode: 4 | usageStatistics: 5 | enabled: false 6 | 7 | spring: 8 | devtools: 9 | restart: 10 | poll-interval: 2s 11 | quiet-period: 1s 12 | -------------------------------------------------------------------------------- /vaadin-editable-label/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | software.xdev 8 | vaadin-editable-label 9 | 2.1.3-SNAPSHOT 10 | jar 11 | 12 | Editable Labels for Vaadin 13 | Editable Labels for Vaadin 14 | https://github.com/xdev-software/vaadin-editable-label 15 | 16 | 17 | https://github.com/xdev-software/vaadin-editable-label 18 | scm:git:https://github.com/xdev-software/vaadin-editable-label.git 19 | 20 | 21 | 2023 22 | 23 | 24 | XDEV Software 25 | https://xdev.software 26 | 27 | 28 | 29 | 30 | XDEV Software 31 | XDEV Software 32 | https://xdev.software 33 | 34 | 35 | 36 | 37 | 38 | Apache-2.0 39 | https://www.apache.org/licenses/LICENSE-2.0.txt 40 | repo 41 | 42 | 43 | 44 | 45 | 17 46 | ${javaVersion} 47 | 48 | UTF-8 49 | UTF-8 50 | 51 | 52 | 24.7.4 53 | 54 | 55 | 56 | 57 | 58 | com.vaadin 59 | vaadin-bom 60 | pom 61 | import 62 | ${vaadin.version} 63 | 64 | 65 | 66 | 67 | 68 | 69 | com.vaadin 70 | vaadin-core 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | org.apache.maven.plugins 80 | maven-site-plugin 81 | 4.0.0-M16 82 | 83 | 84 | org.apache.maven.plugins 85 | maven-project-info-reports-plugin 86 | 3.9.0 87 | 88 | 89 | 90 | 91 | 92 | com.mycila 93 | license-maven-plugin 94 | 5.0.0 95 | 96 | 97 | ${project.organization.url} 98 | 99 | 100 | 101 |
com/mycila/maven/plugin/license/templates/APACHE-2.txt
102 | 103 | src/main/java/** 104 | src/test/java/** 105 | 106 |
107 |
108 |
109 | 110 | 111 | first 112 | 113 | format 114 | 115 | process-sources 116 | 117 | 118 |
119 | 120 | 122 | 123 | com.vaadin 124 | vaadin-maven-plugin 125 | ${vaadin.version} 126 | 127 | 128 | 129 | prepare-frontend 130 | 131 | 132 | 133 | 134 | 135 | 136 | org.apache.maven.plugins 137 | maven-compiler-plugin 138 | 3.14.0 139 | 140 | ${maven.compiler.release} 141 | 142 | -proc:none 143 | 144 | 145 | 146 | 147 | org.apache.maven.plugins 148 | maven-javadoc-plugin 149 | 3.11.2 150 | 151 | 152 | attach-javadocs 153 | package 154 | 155 | jar 156 | 157 | 158 | 159 | 160 | true 161 | none 162 | 163 | 164 | 165 | org.apache.maven.plugins 166 | maven-source-plugin 167 | 3.3.1 168 | 169 | 170 | attach-sources 171 | package 172 | 173 | jar-no-fork 174 | 175 | 176 | 177 | 178 | 179 | org.apache.maven.plugins 180 | maven-jar-plugin 181 | 3.4.2 182 | 183 | 184 | true 185 | 186 | false 187 | true 188 | 189 | 190 | 191 | 1 192 | 193 | 194 | 195 | 196 | 197 | META-INF/VAADIN/ 198 | 199 | 200 | 201 | 202 |
203 |
204 | 205 | 206 | publish-sonatype-central-portal 207 | 208 | 209 | 210 | org.codehaus.mojo 211 | flatten-maven-plugin 212 | 1.7.0 213 | 214 | ossrh 215 | 216 | 217 | 218 | flatten 219 | process-resources 220 | 221 | flatten 222 | 223 | 224 | 225 | 226 | 227 | org.apache.maven.plugins 228 | maven-gpg-plugin 229 | 3.2.7 230 | 231 | 232 | sign-artifacts 233 | verify 234 | 235 | sign 236 | 237 | 238 | 239 | 240 | 241 | --pinentry-mode 242 | loopback 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | org.sonatype.central 251 | central-publishing-maven-plugin 252 | 0.7.0 253 | true 254 | 255 | sonatype-central-portal 256 | true 257 | 258 | 259 | 260 | 261 | 262 | 263 | checkstyle 264 | 265 | 266 | 267 | org.apache.maven.plugins 268 | maven-checkstyle-plugin 269 | 3.6.0 270 | 271 | 272 | com.puppycrawl.tools 273 | checkstyle 274 | 10.24.0 275 | 276 | 277 | 278 | ../.config/checkstyle/checkstyle.xml 279 | true 280 | 281 | 282 | 283 | 284 | check 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | pmd 294 | 295 | 296 | 297 | org.apache.maven.plugins 298 | maven-pmd-plugin 299 | 3.26.0 300 | 301 | true 302 | true 303 | 304 | ../.config/pmd/ruleset.xml 305 | 306 | 307 | 308 | 309 | net.sourceforge.pmd 310 | pmd-core 311 | 7.13.0 312 | 313 | 314 | net.sourceforge.pmd 315 | pmd-java 316 | 7.13.0 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | org.apache.maven.plugins 327 | maven-jxr-plugin 328 | 3.6.0 329 | 330 | 331 | 332 | 333 | 334 |
335 | -------------------------------------------------------------------------------- /vaadin-editable-label/src/main/java/software/xdev/vaadin/editable_label/AbstractEditableLabel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2023 XDEV Software (https://xdev.software) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package software.xdev.vaadin.editable_label; 17 | 18 | import java.util.Objects; 19 | import java.util.function.Consumer; 20 | import java.util.function.Supplier; 21 | import java.util.stream.Stream; 22 | 23 | import com.vaadin.flow.component.AbstractCompositeField; 24 | import com.vaadin.flow.component.ClickEvent; 25 | import com.vaadin.flow.component.Component; 26 | import com.vaadin.flow.component.ComponentEvent; 27 | import com.vaadin.flow.component.ComponentEventListener; 28 | import com.vaadin.flow.component.Focusable; 29 | import com.vaadin.flow.component.HasSize; 30 | import com.vaadin.flow.component.HasStyle; 31 | import com.vaadin.flow.component.HasValue; 32 | import com.vaadin.flow.component.ItemLabelGenerator; 33 | import com.vaadin.flow.component.Key; 34 | import com.vaadin.flow.component.button.Button; 35 | import com.vaadin.flow.component.button.ButtonVariant; 36 | import com.vaadin.flow.component.dependency.CssImport; 37 | import com.vaadin.flow.component.html.Div; 38 | import com.vaadin.flow.component.html.Span; 39 | import com.vaadin.flow.component.icon.VaadinIcon; 40 | import com.vaadin.flow.shared.Registration; 41 | 42 | 43 | /** 44 | * Describes a label which is editable. 45 | *

46 | * The default implementation is {@link EditableLabel} 47 | * 48 | * @param own extending class (self). 49 | * @param value type which is handled through this component 50 | * @param Vaadin-{@link Component} to edit the value 51 | * 52 | * @author AB 53 | * @author JR 54 | */ 55 | @CssImport(value = EditableLabelStyles.LOCATION) 56 | public abstract class AbstractEditableLabel< 57 | S extends AbstractEditableLabel, 58 | C extends Component & HasSize & HasStyle & HasValue, 59 | V> 60 | extends AbstractCompositeField // Using div because shadow root causes otherwise styling issues 61 | implements 62 | HasStyle, 63 | HasSize 64 | { 65 | /* 66 | * UI-Components 67 | */ 68 | protected final Button btnEdit = new Button(VaadinIcon.PENCIL.create()); 69 | protected final Button btnSave = new Button(VaadinIcon.CHECK.create()); 70 | protected final Button btnClose = new Button(VaadinIcon.CLOSE.create()); 71 | protected final Span label = new Span(); 72 | 73 | protected final C editor; 74 | 75 | /* 76 | * Suppliers / Configuration 77 | */ 78 | protected ItemLabelGenerator nativeLabelGenerator; 79 | protected String emptyLabelValue = ""; 80 | 81 | protected AbstractEditableLabel(final C editor, final Consumer additionalInitActions) 82 | { 83 | super(editor.getEmptyValue()); 84 | 85 | this.editor = editor; 86 | 87 | this.initUI(); 88 | this.registerListeners(); 89 | 90 | if(additionalInitActions != null) 91 | { 92 | additionalInitActions.accept(this.self()); 93 | } 94 | 95 | // initial UI state 96 | this.disableEditMode(); 97 | this.withLabelGenerator(Object::toString); 98 | } 99 | 100 | protected void initUI() 101 | { 102 | this.addClassName(EditableLabelStyles.CONTAINER); 103 | 104 | this.label.addClassName(EditableLabelStyles.LABEL); 105 | 106 | this.btnEdit.addClassName(EditableLabelStyles.EDIT_BUTTON); 107 | 108 | this.btnSave.addClickShortcut(Key.ENTER); 109 | 110 | this.btnClose.addClickShortcut(Key.ESCAPE); 111 | 112 | Stream.of(this.btnEdit, this.btnSave, this.btnClose) 113 | .forEach(btn -> { 114 | btn.addClassName(EditableLabelStyles.BUTTON); 115 | btn.addThemeVariants(ButtonVariant.LUMO_SMALL, ButtonVariant.LUMO_TERTIARY); 116 | }); 117 | 118 | this.getEditor().addClassName(EditableLabelStyles.EDITOR); 119 | this.getEditor().setWidthFull(); 120 | 121 | this.getContent().add(this.label, this.editor, this.btnEdit, this.btnSave, this.btnClose); 122 | } 123 | 124 | // region Listeners 125 | 126 | protected void registerListeners() 127 | { 128 | this.btnEdit.addClickListener(this::onEdit); 129 | this.btnSave.addClickListener(this::onSave); 130 | this.btnClose.addClickListener(this::onClose); 131 | } 132 | 133 | protected void onEdit(final ClickEvent