Résolution #30 Fenetres changelog et a propos

This commit is contained in:
2020-12-19 19:39:54 +01:00
parent cddcfe89c0
commit e33e9af623
5 changed files with 270 additions and 1 deletions

View File

@@ -0,0 +1,2 @@
#Sat Dec 19 19:04:03 CET 2020
isFirstLaunch=true

View File

@@ -0,0 +1,114 @@
import javafx.scene.control.TextFormatter;
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
/**
* Fenêtre contenant les informations du logiciel
*/
public class AboutWindow extends JDialog {
/**
* Constructeur - Crée une fenêtre A propos
*/
public AboutWindow(){
//Paramétrage de la fenêtre
this.setTitle("About AppThinker");
this.setModal(true);
this.setSize(new Dimension(800, 375));
Image img = null;
try { img = ImageIO.read(AppThinker.class.getResource("img/logoAppThinker.png")); } catch (Exception ex) { }
this.setIconImage(img);
this.setResizable(false);
this.setLocationRelativeTo(null);
this.setLayout(new BorderLayout());
JPanel panel = new JPanel(){
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
RenderingHints rh = new RenderingHints(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g2.setRenderingHints(rh);
Image img = null;
try { img = ImageIO.read(AppThinker.class.getResource("img/logoAppThinker.png")); } catch (Exception ex) { }
g2.drawImage(img, 0, 20, 300, 300, this);
/*Informations du logiciel*/
g2.setColor(new Color(63, 169, 245));
g2.setFont(new Font("Arial", Font.BOLD, 40));
g2.drawString("AppThinker", 305, 45);
g2.setFont(new Font("Arial", Font.PLAIN, 20));
g2.drawString("Make your ideas come true", 305, 80);
g2.setFont(new Font("Arial", Font.PLAIN, 14));
g2.drawString("> Version : " + AppThinker.version, 305, 140);
g2.drawString("> Editing date : " + AppThinker.dateVersion, 305, 165);
g2.drawString("> Developer : " + AppThinker.developer, 305, 190);
g2.drawString(">", 305, 215);
g2.drawString(">", 305, 240);
g2.drawString(">", 305, 265);
g2.drawString(">", 305, 290);
}
};
panel.setLayout(null);
JButton updates = new JButton("Check for updates");
updates.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
//Ouverture du lien de téléchargement
try {
Desktop.getDesktop().browse(new URL("https://insset-my.sharepoint.com/:f:/g/personal/valentin_boulanger_insset_onmicrosoft_com/En4LybbeF2ZMpeSiesh_Af8BX3Fl1aDzTUWyw4dtQzJaag").toURI());
} catch (URISyntaxException | IOException ex) { }
}
});
panel.add(updates);
updates.setBounds(320, 200, 250, 20);
JButton changelog = new JButton("View Changelog");
changelog.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
ChangelogWindow changelog = new ChangelogWindow();
}
});
panel.add(changelog);
changelog.setBounds(320, 225, 250, 20);
JButton ideas = new JButton("Add your ideas to the software !");
ideas.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
//Ouverture du lien de téléchargement
try {
Desktop.getDesktop().browse(new URL("https://forms.gle/WG32HT947MKqdzhbA").toURI());
} catch (URISyntaxException | IOException ex) { }
}
});
panel.add(ideas);
ideas.setBounds(320, 250, 250, 20);
JButton donation = new JButton("Make a donation - Thanks !");
donation.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
//Ouverture du lien de téléchargement
try {
Desktop.getDesktop().browse(new URL("https://www.paypal.com/paypalme/valentinboulanger").toURI());
} catch (URISyntaxException | IOException ex) { }
}
});
panel.add(donation);
donation.setBounds(320, 275, 250, 20);
this.getContentPane().add(panel);
this.setVisible(true);
}
}

View File

@@ -1,6 +1,9 @@
import javax.swing.*; import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter; import javax.swing.filechooser.FileNameExtensionFilter;
import java.io.*; import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
/** /**
* La classe principale du logiciel AppThinker. * La classe principale du logiciel AppThinker.
@@ -8,6 +11,13 @@ import java.io.*;
*/ */
public class AppThinker { public class AppThinker {
//JavaDoc tags : @param @return @throws @author @version @see @since @serial @deprecated //JavaDoc tags : @param @return @throws @author @version @see @since @serial @deprecated
public static String version = "1.0.0-dev5";
public static String dateVersion = "18/12/2020";
public static List<String> changelog;
public static String developer = "V. BOULANGER";
public static Properties appProperties = new Properties();
private static AppThinkerWindow _window; private static AppThinkerWindow _window;
/** /**
@@ -16,10 +26,24 @@ public class AppThinker {
* @throws InterruptedException Interruption du thread lors de la pause du splashscreen. * @throws InterruptedException Interruption du thread lors de la pause du splashscreen.
*/ */
public static void main(String[] args) throws InterruptedException { public static void main(String[] args) throws InterruptedException {
//Création de la liste des modifications de la version actuelle
changelog = new ArrayList<String>();
changelog.add("Fenêtre A propos et fenêtre de changelog");
changelog.add("2ème note de version");
AppThinkerSplashscreen splash = new AppThinkerSplashscreen(); AppThinkerSplashscreen splash = new AppThinkerSplashscreen();
//Récupération des paramètres du logiciel
loadConfiguration();
Thread.sleep(3000); Thread.sleep(3000);
splash.dispose(); splash.dispose();
_window = new AppThinkerWindow(); _window = new AppThinkerWindow();
//Si le logiciel s'ouvre pour la 1ère fois, on affiche la fenêtre de changelog
if(appProperties.getProperty("isFirstLaunch").equals("true")) {
appProperties.setProperty("isFirstLaunch", "false");
storeConfiguration();
ChangelogWindow changelog = new ChangelogWindow();
}
} }
/** /**
@@ -29,4 +53,43 @@ public class AppThinker {
public static AppThinkerWindow getWindow(){ public static AppThinkerWindow getWindow(){
return _window; return _window;
} }
public static void loadConfiguration(){
InputStream input = null;
try {
input = new FileInputStream("app.properties");
//Chargement des préférences du logiciel
appProperties.load(input);
} catch (final IOException ex) {
ex.printStackTrace();
} finally {
if (input != null) {
try {
input.close();
} catch (final IOException e) {
e.printStackTrace();
}
}
}
}
public static void storeConfiguration(){
OutputStream output = null;
try {
output = new FileOutputStream("app.properties");
//Enregistrement des propriétés du logiciel
appProperties.store(output, null);
} catch (final IOException io) {
io.printStackTrace();
} finally {
if (output != null) {
try {
output.close();
} catch (final IOException e) {
e.printStackTrace();
}
}
}
}
} }

View File

@@ -1,6 +1,10 @@
import javax.swing.*; import javax.swing.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.Desktop;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
/** /**
* Affiche une barre de menu en entête de la fenêtre. * Affiche une barre de menu en entête de la fenêtre.
@@ -101,9 +105,24 @@ public class AppThinkerMenuBar extends JMenuBar {
_appSettings.setIcon(new ImageIcon(getClass().getResource("img/x16/settings.png"))); _appSettings.setIcon(new ImageIcon(getClass().getResource("img/x16/settings.png")));
_appMenu.add(_appSettings); _appMenu.add(_appSettings);
_appInfo = new JMenuItem("About AppThinker"); _appInfo = new JMenuItem("About AppThinker");
_appInfo.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
AboutWindow about = new AboutWindow();
}
});
_appInfo.setIcon(new ImageIcon(getClass().getResource("img/x16/info.png"))); _appInfo.setIcon(new ImageIcon(getClass().getResource("img/x16/info.png")));
_appMenu.add(_appInfo); _appMenu.add(_appInfo);
_appChangelog = new JMenuItem("News"); _appChangelog = new JMenuItem("Check for updates");
_appChangelog.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
//Ouverture du lien de téléchargement
try {
Desktop.getDesktop().browse(new URL("https://insset-my.sharepoint.com/:f:/g/personal/valentin_boulanger_insset_onmicrosoft_com/En4LybbeF2ZMpeSiesh_Af8BX3Fl1aDzTUWyw4dtQzJaag").toURI());
} catch (URISyntaxException | IOException ex) { }
}
});
_appChangelog.setIcon(new ImageIcon(getClass().getResource("img/x16/news.png"))); _appChangelog.setIcon(new ImageIcon(getClass().getResource("img/x16/news.png")));
_appMenu.add(_appChangelog); _appMenu.add(_appChangelog);

View File

@@ -0,0 +1,71 @@
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
/**
* Fenêtre d'affichage de la version actuelle et des modifications apportées.
*/
public class ChangelogWindow extends JDialog{
public ChangelogWindow(){
//Paramétrage de la fenêtre
this.setTitle("Version " + AppThinker.version);
this.setModal(true);
this.setSize(new Dimension(800, 375));
Image img = null;
try { img = ImageIO.read(AppThinker.class.getResource("img/logoAppThinker.png")); } catch (Exception ex) { }
this.setIconImage(img);
this.setResizable(false);
this.setLocationRelativeTo(null);
this.setLayout(new BorderLayout());
JPanel panel = new JPanel(){
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
RenderingHints rh = new RenderingHints(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g2.setRenderingHints(rh);
Image img = null;
try { img = ImageIO.read(AppThinker.class.getResource("img/logoAppThinker.png")); } catch (Exception ex) { }
g2.drawImage(img, 0, 20, 300, 300, this);
/*Informations du logiciel*/
g2.setColor(new Color(63, 169, 245));
g2.setFont(new Font("Arial", Font.BOLD, 40));
g2.drawString("Thanks for downloading AppThinker !", 50, 45);
g2.setFont(new Font("Arial", Font.PLAIN, 20));
g2.drawString("Version " + AppThinker.version, 305, 80);
g2.setFont(new Font("Arial", Font.PLAIN, 14));
int i = 140;
for(String a : AppThinker.changelog){
g2.drawString("> " + a, 305, i);
i += 25;
}
}
};
panel.setLayout(null);
JButton ideas = new JButton("Add your ideas to the software !");
ideas.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
//Ouverture du lien de téléchargement
try {
Desktop.getDesktop().browse(new URL("https://forms.gle/WG32HT947MKqdzhbA").toURI());
} catch (URISyntaxException | IOException ex) { }
}
});
panel.add(ideas);
ideas.setBounds(305, 90, 250, 20);
this.getContentPane().add(panel);
this.setVisible(true);
}
}