Skip to content

Commit

Permalink
SDSFinance
Browse files Browse the repository at this point in the history
  • Loading branch information
evertonbrunosds committed Aug 16, 2020
1 parent b9cbddf commit d9a6009
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 23 deletions.
2 changes: 1 addition & 1 deletion nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ annotation.processing.processors.list=
annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
application.desc=Registre suas finan\u00e7as de forma organizada.
application.homepage=https://github.com/evertonbrunosds/SDSFinance.git
application.homepage=https://evertonbrunosds.github.io/sdsfinance
application.title=SDS Finance
application.vendor=Everton Bruno Silva dos Santos
auxiliary.org-netbeans-spi-editor-hints-projects.perProjectHintSettingsFile=nbproject/cfg_hints.xml
Expand Down
8 changes: 8 additions & 0 deletions src/view/managers/Show.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ public static void errorMessage(final String msg) {
public static void warningMessage(final String msg) {
JOptionPane.showMessageDialog(null, msg, "Mensagem de Aviso", JOptionPane.WARNING_MESSAGE);
}

/**
* Método responsável por exibir mensagens informativas.
* @param msg Refere-se ao conteúdo da mensagem.
*/
public static void informationMessage(final String msg) {
JOptionPane.showMessageDialog(null, msg, "Mensagem Informativa", JOptionPane.INFORMATION_MESSAGE);
}

/**
* Método responsável por exibir mensagens de questionamento.
Expand Down
19 changes: 18 additions & 1 deletion src/view/windows/AuthorAbout.form
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<Component id="labelNameDevAuthor" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="labelEmailDevAuthor" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="separatorTwo" alignment="2" max="32767" attributes="0"/>
<Component id="labelWebSite" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="15" max="-2" attributes="0"/>
</Group>
Expand All @@ -55,7 +56,9 @@
<Component id="labelNameDevAuthor" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="2" max="-2" attributes="0"/>
<Component id="labelEmailDevAuthor" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<EmptySpace min="-2" pref="2" max="-2" attributes="0"/>
<Component id="labelWebSite" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="2" max="-2" attributes="0"/>
<Component id="separatorTwo" min="-2" pref="10" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
</Group>
Expand Down Expand Up @@ -89,6 +92,20 @@
<Property name="text" type="java.lang.String" value="E-mail: evertonbrunogithub@yahoo.com"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="labelWebSite">
<Properties>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="ff" green="0" red="0" type="rgb"/>
</Property>
<Property name="text" type="java.lang.String" value="&lt;html&gt;&lt;u&gt;Web Site&lt;/u&gt;"/>
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
<Color id="Cursor em Forma de M&#xe3;o"/>
</Property>
</Properties>
<Events>
<EventHandler event="mouseReleased" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="labelWebSiteMouseReleased"/>
</Events>
</Component>
<Component class="javax.swing.JSeparator" name="separatorTwo">
</Component>
</SubComponents>
Expand Down
36 changes: 32 additions & 4 deletions src/view/windows/AuthorAbout.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
*/
package view.windows;

import java.io.IOException;
import java.net.URISyntaxException;
import view.managers.Show;

/**
* Classe responsável por comportar-se como janela de autoria.
* @author Everton Bruno Silva dos Santos.
Expand Down Expand Up @@ -73,6 +77,7 @@ private void initComponents() {
labelProductNameAndVersion = new javax.swing.JLabel();
labelNameDevAuthor = new javax.swing.JLabel();
labelEmailDevAuthor = new javax.swing.JLabel();
labelWebSite = new javax.swing.JLabel();
separatorTwo = new javax.swing.JSeparator();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
Expand All @@ -90,6 +95,15 @@ private void initComponents() {

labelEmailDevAuthor.setText("E-mail: evertonbrunogithub@yahoo.com");

labelWebSite.setForeground(new java.awt.Color(0, 0, 255));
labelWebSite.setText("<html><u>Web Site</u>");
labelWebSite.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
labelWebSite.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(final java.awt.event.MouseEvent evt) {
labelWebSiteMouseReleased(evt);
}
});

final javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
Expand All @@ -98,27 +112,41 @@ private void initComponents() {
.addComponent(separatorOne, javax.swing.GroupLayout.PREFERRED_SIZE, 400,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(labelProductNameAndVersion).addComponent(labelNameDevAuthor)
.addComponent(labelEmailDevAuthor).addComponent(separatorTwo)).addGap(15, 15, 15)));
.addComponent(labelEmailDevAuthor).addComponent(separatorTwo).addComponent(labelWebSite,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(15, 15, 15)));
layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup().addGap(20, 20, 20).addComponent(labelVersion)
.addGap(18, 18, 18).addComponent(labelProductNameAndVersion).addGap(7, 7, 7)
.addComponent(separatorOne, javax.swing.GroupLayout.PREFERRED_SIZE, 10,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, 0).addComponent(labelNameDevAuthor).addGap(2, 2, 2)
.addComponent(labelEmailDevAuthor)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(separatorTwo,
javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(labelEmailDevAuthor).addGap(2, 2, 2)
.addComponent(labelWebSite, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(2, 2, 2).addComponent(separatorTwo, javax.swing.GroupLayout.PREFERRED_SIZE, 10,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, 0)));

pack();
setLocationRelativeTo(null);
}// </editor-fold>//GEN-END:initComponents

private void labelWebSiteMouseReleased(final java.awt.event.MouseEvent evt) {//GEN-FIRST:event_labelWebSiteMouseReleased
try {
java.awt.Desktop.getDesktop().browse(new java.net.URI("https://evertonbrunosds.github.io/sdsfinance/"));
} catch (IOException | URISyntaxException ex) {
Show.errorMessage("Acesso indisponível.");
}
}//GEN-LAST:event_labelWebSiteMouseReleased

// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel labelEmailDevAuthor;
private javax.swing.JLabel labelNameDevAuthor;
private javax.swing.JLabel labelProductNameAndVersion;
private javax.swing.JLabel labelVersion;
private javax.swing.JLabel labelWebSite;
private javax.swing.JSeparator separatorOne;
private javax.swing.JSeparator separatorTwo;
// End of variables declaration//GEN-END:variables
Expand Down
15 changes: 13 additions & 2 deletions src/view/windows/MainForm.form
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,26 @@
<Property name="text" type="java.lang.String" value="Sobre"/>
</Properties>
<SubComponents>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem1">
<MenuItem class="javax.swing.JMenuItem" name="optUpdateChecker">
<Properties>
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
<KeyStroke key="Shift+Ctrl+A"/>
</Property>
<Property name="text" type="java.lang.String" value="Atualiza&#xe7;&#xf5;es"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="optUpdateCheckerActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="optLicense">
<Properties>
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
<KeyStroke key="Ctrl+L"/>
</Property>
<Property name="text" type="java.lang.String" value="Licen&#xe7;a"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem1ActionPerformed"/>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="optLicenseActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="optAuthor">
Expand Down
85 changes: 70 additions & 15 deletions src/view/windows/MainForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

import control.Record;
import exceptions.ElementNotFoundException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import javax.swing.SwingConstants;
import javax.swing.table.DefaultTableModel;
import model.business.IAcquisition;
Expand Down Expand Up @@ -106,8 +109,8 @@ public static void updateWindow() {
private void removeAcquisitions() throws ElementNotFoundException {
final int[] selectedRows = table.getSelectedRows();
if (selectedRows.length > 0) {
if (Show.questionMessage("Essa ação excluirá permanentemente todas as\n"
+ "aquisições selecionadas. Deseja prosseguir?", "Não", "Sim")) {
if (Show.questionMessage(
"Essa ação excluirá permanentemente todas as\n" + "aquisições selecionadas. Deseja prosseguir?", "Não", "Sim")) {
IAcquisition acquisition;
for (final int row : selectedRows) {
acquisition = (IAcquisition) table.getModel().getValueAt(row, 0);
Expand Down Expand Up @@ -137,6 +140,24 @@ private void updateOptions() {
}
}

/**
* Método responsável por retornar indicativo de que há atualizações.
* @return Retorna indicativo de que há atualizações.
* @throws Exception Exceção lançada caso hajam falhas no processo.
*/
public boolean thereAreUpdates() throws Exception {
final StringBuilder output = new StringBuilder();
final URL url = new URL("https://evertonbrunosds.github.io/sdsfinance/version");
final URLConnection uCon = url.openConnection();
try (InputStream input = uCon.getInputStream()) {
final byte[] buffer = new byte[2048];
while (input.read(buffer) != -1) {
output.append(new String(buffer));
}
}
return Converter.toDouble(output.toString()) > 1.0;
}

// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

Expand All @@ -156,7 +177,8 @@ private void initComponents() {
optProvider = new javax.swing.JMenuItem();
optExtracts = new javax.swing.JMenuItem();
optAbout = new javax.swing.JMenu();
jMenuItem1 = new javax.swing.JMenuItem();
optUpdateChecker = new javax.swing.JMenuItem();
optLicense = new javax.swing.JMenuItem();
optAuthor = new javax.swing.JMenuItem();

optAccessProvider.setText("Acessar Fornecedor");
Expand Down Expand Up @@ -193,11 +215,11 @@ public void mouseReleased(final java.awt.event.MouseEvent evt) {
}
});

table.setModel(new javax.swing.table.DefaultTableModel(new Object[][] {

}, new String[] { "Aquisição", "Fornecedor", "Quantidade", "Valor Unitário", "Valor Total", "Data" }) {
table.setModel(new javax.swing.table.DefaultTableModel(new Object[][] {},
new String[] { "Aquisição", "Fornecedor", "Quantidade", "Valor Unitário", "Valor Total", "Data" }) {
private static final long serialVersionUID = 1239724359305259903L;
boolean[] canEdit = new boolean[] { false, false, false, false, false, false };

public boolean isCellEditable(final int rowIndex, final int columnIndex) {
return canEdit[columnIndex];
}
Expand Down Expand Up @@ -258,7 +280,8 @@ public void actionPerformed(final java.awt.event.ActionEvent evt) {
});
optFile.add(optSaveFile);

optSaveAsFile.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
optSaveAsFile.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
optSaveAsFile.setText("Salvar Como");
optSaveAsFile.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(final java.awt.event.ActionEvent evt) {
Expand Down Expand Up @@ -298,14 +321,24 @@ public void actionPerformed(final java.awt.event.ActionEvent evt) {

optAbout.setText("Sobre");

jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_L, java.awt.event.InputEvent.CTRL_MASK));
jMenuItem1.setText("Licença");
jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
optUpdateChecker.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A,
java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
optUpdateChecker.setText("Atualizações");
optUpdateChecker.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(final java.awt.event.ActionEvent evt) {
jMenuItem1ActionPerformed(evt);
optUpdateCheckerActionPerformed(evt);
}
});
optAbout.add(jMenuItem1);
optAbout.add(optUpdateChecker);

optLicense.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_L, java.awt.event.InputEvent.CTRL_MASK));
optLicense.setText("Licença");
optLicense.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(final java.awt.event.ActionEvent evt) {
optLicenseActionPerformed(evt);
}
});
optAbout.add(optLicense);

optAuthor.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_D, java.awt.event.InputEvent.CTRL_MASK));
optAuthor.setText("Autoria");
Expand Down Expand Up @@ -418,9 +451,30 @@ private void optSaveFileActionPerformed(final java.awt.event.ActionEvent evt) {/
ViewControl.saveRecordToFile(this);
}//GEN-LAST:event_optSaveFileActionPerformed

private void jMenuItem1ActionPerformed(final java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
private void optLicenseActionPerformed(final java.awt.event.ActionEvent evt) {//GEN-FIRST:event_optLicenseActionPerformed
LicenseWindow.showModal();
}//GEN-LAST:event_jMenuItem1ActionPerformed
}//GEN-LAST:event_optLicenseActionPerformed

private void optUpdateCheckerActionPerformed(final java.awt.event.ActionEvent evt) {//GEN-FIRST:event_optUpdateCheckerActionPerformed
final Thread thread = new Thread() {
@Override
public void run() {
try {
if (thereAreUpdates()) {
if (!Show.questionMessage("Há atualizações disponíveis. Deseja baixar as atualizações?", "Sim",
"Não")) {
java.awt.Desktop.getDesktop().browse(new java.net.URI("https://evertonbrunosds.github.io/sdsfinance/"));
}
} else {
Show.informationMessage("O SDS Finance está atualizado.");
}
} catch (final Exception ex) {
Show.warningMessage("Não foi possível determinar o estado de atualização.");
}
}
};
thread.start();
}//GEN-LAST:event_optUpdateCheckerActionPerformed

/**
* Método responsável por comportar-se como o principal da classe.
Expand All @@ -447,20 +501,21 @@ public static void main(final String args[]) {
}

// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JMenu optAbout;
private javax.swing.JMenuItem optAccessProvider;
private javax.swing.JMenuItem optAuthor;
private javax.swing.JMenuItem optEditAcquisition;
private javax.swing.JMenuItem optExtracts;
private javax.swing.JMenu optFile;
private javax.swing.JMenuItem optLicense;
private javax.swing.JMenuItem optNewFile;
private javax.swing.JMenuItem optOpenFile;
private javax.swing.JMenuItem optProvider;
private javax.swing.JMenuItem optRemoveAcquisition;
private javax.swing.JMenuItem optSaveAsFile;
private javax.swing.JMenuItem optSaveFile;
private javax.swing.JMenu optShow;
private javax.swing.JMenuItem optUpdateChecker;
private javax.swing.JPopupMenu popupMenu;
private javax.swing.JScrollPane scrollPane;
private javax.swing.JTable table;
Expand Down

0 comments on commit d9a6009

Please sign in to comment.