commit 90cd59ed9a2d13868ff56836b6c3f1f5c463a8d6 Author: Mysaa Date: Tue May 25 22:33:23 2021 +0200 Premier commit - Introduction au système git diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8dabef4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +.classpath +.settings +.project +bin/ +gradle/ +.gradle/ +gradlew +gradlew.bat diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..9a6e192 --- /dev/null +++ b/build.gradle @@ -0,0 +1,23 @@ +apply plugin: 'java' +apply plugin: 'maven' + +repositories { + jcenter() + mavenCentral() + + maven { + url "http://ftp.bernard.890m.com/mavenRepository/" + credentials { + username 'u890869027.maven' + password 'bernard' + } + } +} + +dependencies { + //Pour gradle + compile 'org.slf4j:slf4j-api:1.7.21' + testCompile 'junit:junit:4.12' + + compile 'com.bernard:bernardUtil:alpha' +} \ No newline at end of file diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..579b8bd --- /dev/null +++ b/settings.gradle @@ -0,0 +1,19 @@ +/* + * This settings file was auto generated by the Gradle buildInit task + * by 'Samy' at '02/02/17 18:25' with Gradle 3.2.1 + * + * The settings file is used to specify which projects to include in your build. + * In a single project build this file can be empty or even removed. + * + * Detailed information about configuring a multi-project build in Gradle can be found + * in the user guide at https://docs.gradle.org/3.2.1/userguide/multi_project_builds.html + */ + +/* +// To declare projects as part of a multi-project build use the 'include' method +include 'shared' +include 'api' +include 'services:webservice' +*/ + +rootProject.name = 'Zikator' diff --git a/src/main/java/com/bernard/zikator/Download.java b/src/main/java/com/bernard/zikator/Download.java new file mode 100644 index 0000000..842efb1 --- /dev/null +++ b/src/main/java/com/bernard/zikator/Download.java @@ -0,0 +1,34 @@ +package com.bernard.zikator; + +public class Download +{ + protected String type; + protected String downloadUrl; + protected String storeUrl; + protected long size; + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + public String getDownloadUrl() { + return downloadUrl; + } + public void setDownloadUrl(String downloadUrl) { + this.downloadUrl = downloadUrl; + } + public String getStoreUrl() { + return storeUrl; + } + public void setStoreUrl(String storeUrl) { + this.storeUrl = storeUrl; + } + public long getSize() { + return size; + } + public void setSize(long size) { + this.size = size; + } + +} diff --git a/src/main/java/com/bernard/zikator/ZiKonfig.java b/src/main/java/com/bernard/zikator/ZiKonfig.java new file mode 100644 index 0000000..0547ab1 --- /dev/null +++ b/src/main/java/com/bernard/zikator/ZiKonfig.java @@ -0,0 +1,23 @@ +package com.bernard.zikator; + +import java.awt.Color; + +public class ZiKonfig +{ + public Download[] downloads; + public Color progressColor; + public Color progressBackground; + public Color progressTextColor; + public String fileProgressFormat; + public String filesProgressFormat; + + public ZiKonfig() + { + downloads = new Download[0]; + progressColor = Color.GREEN; + progressBackground = Color.DARK_GRAY; + progressTextColor = Color.BLACK; + fileProgressFormat = "%l octets sur %l"; + filesProgressFormat = "Fichier %i sur %i"; + } +} diff --git a/src/main/java/com/bernard/zikator/Zikator.java b/src/main/java/com/bernard/zikator/Zikator.java new file mode 100644 index 0000000..57bc423 --- /dev/null +++ b/src/main/java/com/bernard/zikator/Zikator.java @@ -0,0 +1,19 @@ +package com.bernard.zikator; + +import com.bernard.zikator.view.MainFrame; + +public class Zikator { + + public static final MainFrame theFrame; + static{ + theFrame = new MainFrame(); + } + public static final ZiKonfig theKonfig; + static{ + theKonfig = new ZiKonfig(); + } + + public static void main(String[] args) { + + } +} diff --git a/src/main/java/com/bernard/zikator/view/MainFrame.java b/src/main/java/com/bernard/zikator/view/MainFrame.java new file mode 100644 index 0000000..bd73dc9 --- /dev/null +++ b/src/main/java/com/bernard/zikator/view/MainFrame.java @@ -0,0 +1,64 @@ +package com.bernard.zikator.view; + +import java.awt.BorderLayout; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; + +import javax.swing.JButton; +import javax.swing.JPanel; + +import com.bernard.util.ConfiguredFrame; +import com.bernard.zikator.ZiKonfig; + +public class MainFrame extends ConfiguredFrame +{ + + JButton addDownloadButton,viewDownloadsButton,switchDownloadButton; + + /** JFESH */ + private static final long serialVersionUID = 849892775235695501L; + + public MainFrame() + { + super("Zikator", 400, 600, ZiKonfig.class); + } + + @Override + public void init() + { + JPanel buttonsPanel = new JPanel(); + GridLayout buttonLayout = new GridLayout(3,1); + buttonLayout.setVgap(10); + buttonsPanel.setLayout(buttonLayout); + addDownloadButton = new JButton("Add a download"); + viewDownloadsButton = new JButton("View downloads"); + switchDownloadButton = new JButton("No downloads"); + buttonsPanel.add(addDownloadButton); + buttonsPanel.add(viewDownloadsButton); + buttonsPanel.add(switchDownloadButton); + + + JPanel progressPanel = new JPanel(); + + + this.getContentPane().setLayout(new BorderLayout()); + this.getContentPane().add(progressPanel, BorderLayout.SOUTH); + this.getContentPane().add(buttonsPanel,BorderLayout.CENTER); + } + + //TODO supress this function (for offline tests) + public ZiKonfig getConfig(){ + return new ZiKonfig(); + } + + @Override + public void actionPerformed(ActionEvent e) + { + // TODO Auto-generated method stub + + } + public static void main(String[] args) { + new MainFrame(); + } + +} diff --git a/src/main/java/com/bernard/zikator/view/ZikaProgressPanel.java b/src/main/java/com/bernard/zikator/view/ZikaProgressPanel.java new file mode 100644 index 0000000..f337fea --- /dev/null +++ b/src/main/java/com/bernard/zikator/view/ZikaProgressPanel.java @@ -0,0 +1,51 @@ +package com.bernard.zikator.view; + +import java.awt.Graphics; +import java.util.List; + +import javax.swing.JPanel; + +import com.bernard.zikator.Download; + +/** + * + * Affche deux barres de progression + * + * Cycle de vie : + * setDownloads(); + * prepareDownload(); return the next download in the list + * startDownload(); the download starts. before that,the progress bar will print "Preparing" + * setCurrentFileProgress();looping + * downloadFinished();//prints Done + * + * @author Mysaa + * + */ +public class ZikaProgressPanel extends JPanel { + + private static final long serialVersionUID = 3133794283368644062L; + + List download; + int currentDownload; + long currentFileProgress; + + + + public void setCurrentFileProgress(long currentProgress){ + currentFileProgress = currentProgress; + } + + public void setCurrentFileProgress(float currentProgress){ + currentFileProgress = (long)(currentProgress*download.get(currentDownload).getSize()); + } + + + @Override + protected void paintComponent(Graphics arg0) { + + int filesProgressWidth = (int) (Math.floorDiv(currentDownload*this.getWidth(),download.size())); + int fileProgressWidth = (int) (Math.floorDiv(currentFileProgress*this.getWidth(),download.get(currentDownload).getSize())); + + } + +}