Skip to content

Commit 99ab577

Browse files
add GridJs demo for Collabrative
1 parent 810ccab commit 99ab577

File tree

88 files changed

+14918
-9
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+14918
-9
lines changed
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
/*
2+
* Copyright 2007-present the original author or authors.
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+
* https://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+
17+
import java.net.*;
18+
import java.io.*;
19+
import java.nio.channels.*;
20+
import java.util.Properties;
21+
22+
public class MavenWrapperDownloader {
23+
24+
private static final String WRAPPER_VERSION = "0.5.6";
25+
/**
26+
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
27+
*/
28+
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
29+
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
30+
31+
/**
32+
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
33+
* use instead of the default one.
34+
*/
35+
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
36+
".mvn/wrapper/maven-wrapper.properties";
37+
38+
/**
39+
* Path where the maven-wrapper.jar will be saved to.
40+
*/
41+
private static final String MAVEN_WRAPPER_JAR_PATH =
42+
".mvn/wrapper/maven-wrapper.jar";
43+
44+
/**
45+
* Name of the property which should be used to override the default download url for the wrapper.
46+
*/
47+
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
48+
49+
public static void main(String args[]) {
50+
System.out.println("- Downloader started");
51+
File baseDirectory = new File(args[0]);
52+
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
53+
54+
// If the maven-wrapper.properties exists, read it and check if it contains a custom
55+
// wrapperUrl parameter.
56+
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
57+
String url = DEFAULT_DOWNLOAD_URL;
58+
if (mavenWrapperPropertyFile.exists()) {
59+
FileInputStream mavenWrapperPropertyFileInputStream = null;
60+
try {
61+
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
62+
Properties mavenWrapperProperties = new Properties();
63+
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
64+
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
65+
} catch (IOException e) {
66+
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
67+
} finally {
68+
try {
69+
if (mavenWrapperPropertyFileInputStream != null) {
70+
mavenWrapperPropertyFileInputStream.close();
71+
}
72+
} catch (IOException e) {
73+
// Ignore ...
74+
}
75+
}
76+
}
77+
System.out.println("- Downloading from: " + url);
78+
79+
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
80+
if (!outputFile.getParentFile().exists()) {
81+
if (!outputFile.getParentFile().mkdirs()) {
82+
System.out.println(
83+
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
84+
}
85+
}
86+
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
87+
try {
88+
downloadFileFromURL(url, outputFile);
89+
System.out.println("Done");
90+
System.exit(0);
91+
} catch (Throwable e) {
92+
System.out.println("- Error downloading");
93+
e.printStackTrace();
94+
System.exit(1);
95+
}
96+
}
97+
98+
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
99+
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
100+
String username = System.getenv("MVNW_USERNAME");
101+
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
102+
Authenticator.setDefault(new Authenticator() {
103+
@Override
104+
protected PasswordAuthentication getPasswordAuthentication() {
105+
return new PasswordAuthentication(username, password);
106+
}
107+
});
108+
}
109+
URL website = new URL(urlString);
110+
ReadableByteChannel rbc;
111+
rbc = Channels.newChannel(website.openStream());
112+
FileOutputStream fos = new FileOutputStream(destination);
113+
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
114+
fos.close();
115+
rbc.close();
116+
}
117+
118+
}
49.5 KB
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
2+
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
FROM maven:3.8.6-amazoncorretto-17 AS build
2+
# 设置工作目录
3+
WORKDIR /usr/src/app
4+
5+
# 将本地的 Maven 设置文件和环境变量设置文件复制到容器中
6+
COPY .mvn .mvn
7+
COPY pom.xml .
8+
COPY src src
9+
10+
RUN ls -l *
11+
# 使用 Maven 构建应用
12+
RUN mvn package -DskipTests
13+
14+
FROM eclipse/ubuntu_jdk8
15+
WORKDIR /app
16+
# 将构建的 jar 文件复制到新的容器中
17+
COPY --from=build /usr/src/app/target/*.jar /app/app.jar
18+
19+
20+
# web port
21+
EXPOSE 8080
22+
# Install Fonts because the SDK image contains very few fonts. The command copies font files from local to docker image. Make sure you have a local “fonts” directory that contains all the fonts you need to install. In this example, the local “fonts” directory is put in the same directory as the Dockerfile.
23+
# COPY fonts/* /usr/share/fonts/
24+
RUN mkdir -p /app/wb
25+
RUN mkdir -p /app/grid_cache/streamcache
26+
RUN mkdir -p /app/upload
27+
COPY wb/*.xlsx /app/wb/
28+
# RUN ls -l /app/
29+
# 启动应用
30+
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app/app.jar"]
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
[Product Page](https://products.aspose.com/cells/java) | [Docs](https://docs.aspose.com/cells/java/aspose-cells-gridjs/) | [API Reference](https://reference.aspose.com/cells/java/com.aspose.gridjs/) | [Demos](https://products.aspose.app/cells/family/) | [Blog](https://blog.aspose.com/category/cells/) | [Code Samples](https://github.com/aspose-cells/Aspose.Cells-for-Java/tree/master/Examples.GridJs) | [Free Support](https://forum.aspose.com/c/cells) | [Temporary License](https://purchase.aspose.com/temporary-license) | [EULA](https://company.aspose.com/legal/eula)
2+
3+
---
4+
5+
Try our [free online apps](https://products.aspose.app/cells/family) demonstrating some of the most popular Aspose.Cells functionality.
6+
7+
[Aspose.Cells.GridJs for Java](http://www.aspose.com/products/cells/java) is a lightweight, scalable, and customizable toolkit that provides cross-platform web applications. It enables developers to easily build Excel/Spreadsheet editors or viewers for the web with collaborative features, simple deployment, and easy-to-use APIs.
8+
9+
This repository contains a demo project showing how to implement a **Spreadsheet Editor in collaborative mode** using **GridJs**.
10+
11+
---
12+
13+
## Preview
14+
15+
<img alt="demo" src="https://unpkg.com/[email protected]/preview.gif" />
16+
17+
---
18+
19+
## Quick Start
20+
21+
1. **Clone the Repository**
22+
```bash
23+
git clone https://github.com/aspose-cells/Aspose.Cells-for-Java.git
24+
cd Examples.GridJs.Collabrative
25+
```
26+
27+
2. **Configure Application**
28+
- Update `src/main/resources/application.properties` with your environment.
29+
- Ensure MySQL is installed and running.
30+
31+
3. **Run the Demo**
32+
```bash
33+
mvn spring-boot:run
34+
```
35+
Open [http://localhost:8080/gridjsdemo/list](http://localhost:8080/gridjsdemo/list)
36+
37+
---
38+
39+
## Run the Example Locally
40+
41+
### 0. Install SQL Server
42+
You will need a database server (e.g., **MySQL**). Make sure it is running before you start the application.
43+
44+
### 1. Configure Application Properties
45+
Edit `src/main/resources/application.properties` according to your environment:
46+
47+
```properties
48+
# Directory containing spreadsheet files
49+
testconfig.ListDir=/app/wb
50+
51+
# Directory for storing cache files
52+
testconfig.CachePath=/app/grid_cache
53+
54+
# Aspose.Cells license file
55+
testconfig.AsposeLicensePath=/app/license
56+
57+
# Enable collaborative mode
58+
gridjs.iscollabrative=true
59+
60+
# Database connection (example: MySQL)
61+
spring.datasource.url=jdbc:mysql://localhost:3306/gridjsdemodb?createDatabaseIfNotExist=true&useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Jakarta&useSSL=false
62+
spring.datasource.username=root
63+
spring.datasource.password=root
64+
spring.sql.init.platform=mysql
65+
```
66+
67+
### 2. Run the Application
68+
Execute:
69+
70+
```
71+
src/main/java/com/aspose/gridjsdemo/usermanagement/UserManagementApplication.java
72+
```
73+
74+
Then open your browser and navigate to:
75+
[http://localhost:8080/gridjsdemo/list](http://localhost:8080/gridjsdemo/list)
76+
77+
---
78+
79+
## Run with Docker
80+
81+
### 0. Configure License Path
82+
In `docker-compose.yml` (line 10), set the correct path to your license file.
83+
84+
Example: If your license file is at `C:/license/aspose.lic`
85+
86+
Before:
87+
```yaml
88+
- D:/release/license/Aspose.Cells.lic:/app/license # optional: set Aspose license file
89+
```
90+
91+
After:
92+
```yaml
93+
- C:/license/aspose.lic:/app/license # optional: set Aspose license file
94+
```
95+
96+
### 1. Build and Start Containers
97+
```bash
98+
docker-compose up --build
99+
```
100+
101+
### 2. Access the App
102+
Open your browser and go to:
103+
[http://localhost:8080/gridjsdemo/list](http://localhost:8080/gridjsdemo/list)
104+
105+
---
106+
107+
## JavaScript/CSS Libraries Used
108+
- jquery.js v2.1.1
109+
- jquery-ui.js v1.12.1
110+
- jquery-ui.css v1.12.1
111+
- jszip.min.js v3.6.0
112+
- bootstrap.css v22.5.5.2
113+
- quantumui.css v22.5.5.2
114+
115+
---
116+
117+
## Resources
118+
- **Website:** [www.aspose.com](http://www.aspose.com)
119+
- **Product Home:** [Aspose.Cells for Java](http://www.aspose.com/products/cells/java)
120+
- **Download:** [Download Aspose.Cells for Java](https://downloads.aspose.com/cells/java)
121+
- **Documentation:** [Aspose.Cells for Java Documentation](https://docs.aspose.com/display/cellsjava/Home)
122+
- **Forum:** [Aspose.Cells for Java Forum](http://www.aspose.com/community/forums/aspose.cells-product-family/19/showforum.aspx)
123+
- **Blog:** [Aspose.Cells for Java Blog](https://blog.aspose.com/category/aspose-products/aspose-cells-product-family/)
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
version: '3.8'
2+
3+
services:
4+
# Java application
5+
app:
6+
build: . # build Dockerfile
7+
ports:
8+
- "8080:8080" # expose 8080 port
9+
volumes:
10+
- D:/release/licesnse/Aspose.Cells.lic:/app/license # optional : set Aspose license file
11+
environment:
12+
# database setting
13+
SPRING_DATASOURCE_URL: jdbc:mysql://mysql:3306/gridjsdemodb?createDatabaseIfNotExist=true&useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Jakarta&useSSL=false
14+
SPRING_DATASOURCE_USERNAME: root
15+
SPRING_DATASOURCE_PASSWORD: root
16+
SPRING_DATASOURCE_DRIVER_CLASS_NAME: com.mysql.cj.jdbc.Driver
17+
depends_on:
18+
mysql:
19+
condition: service_healthy # ensure MySQL run before app start
20+
21+
# MySQL service
22+
mysql:
23+
image: mysql:8.0 # use official MySQL 8.0 image
24+
environment:
25+
MYSQL_ROOT_PASSWORD: root
26+
MYSQL_DATABASE: gridjsdemodb # create a database with name:gridjsdemodb
27+
ports:
28+
- "3306:3306" # local optional for debug
29+
command: >
30+
--default-authentication-plugin=mysql_native_password
31+
--bind-address=0.0.0.0
32+
volumes:
33+
- mysql-data:/var/lib/mysql
34+
healthcheck:
35+
test: |
36+
bash -c '
37+
mysqladmin ping -h localhost -u root -proot --silent > /dev/null 2>&1 &&
38+
mysql -u root -proot -e "SELECT 1" > /dev/null 2>&1
39+
'
40+
interval: 5s
41+
timeout: 10s
42+
retries: 15
43+
start_period: 10s
44+
45+
# volumn:persistent for MySQL data
46+
volumes:
47+
mysql-data:

0 commit comments

Comments
 (0)