Skip to content
This repository has been archived by the owner on Nov 28, 2019. It is now read-only.

Commit

Permalink
Merge pull request #2 from xman40100/andres
Browse files Browse the repository at this point in the history
Pull request para unir cambios importantes
  • Loading branch information
xman40100 authored Feb 20, 2019
2 parents 194e886 + c13aa6c commit fa3cca0
Show file tree
Hide file tree
Showing 10 changed files with 251 additions and 53 deletions.
5 changes: 5 additions & 0 deletions settings.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#3306
#Wed Feb 20 08:05:50 COT 2019
port=3306
hostname=localhost
daemon=true
81 changes: 62 additions & 19 deletions src/technomotica/java/forms/Configuration.form
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,44 @@
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel2" alignment="1" max="32767" attributes="0"/>
<Component id="jLabel4" alignment="0" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="23" max="-2" attributes="0"/>
<Component id="jButton2" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jButton1" min="-2" pref="93" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jButton3" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Component id="tEjecucion2do" min="-2" pref="107" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="23" max="-2" attributes="0"/>
<Component id="jButton2" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jButton1" min="-2" pref="93" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jButton3" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="20" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="jLabel1" min="-2" pref="205" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="txtHostname" max="32767" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="jLabel3" min="-2" pref="308" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel5" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="89" max="-2" attributes="0"/>
<Component id="tHostPort" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="20" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel1" min="-2" pref="318" max="-2" attributes="0"/>
<Component id="jLabel3" min="-2" pref="308" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
Expand All @@ -62,9 +74,19 @@
<Component id="tEjecucion2do" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel3" alignment="3" min="-2" pref="99" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
<Component id="jLabel1" min="-2" pref="49" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="42" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="32767" attributes="0"/>
<Component id="jLabel4" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel1" alignment="3" min="-2" pref="49" max="-2" attributes="0"/>
<Component id="txtHostname" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="tHostPort" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="19" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jButton1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jButton2" alignment="3" min="-2" max="-2" attributes="0"/>
Expand All @@ -86,7 +108,7 @@
</Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" value="&lt;html&gt;Ejecuci&#xf3;n en segundo plano: La ejecuci&#xf3;n en segundo plano permitir&#xe1; que la aplicaci&#xf3;n se siga ejecutando sin estar en tu barra de tareas.&lt;/html&gt;"/>
<Property name="text" type="java.lang.String" value="Direcci&#xf3;n/Nombre del host:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
Expand All @@ -111,6 +133,9 @@
<Properties>
<Property name="text" type="java.lang.String" value="Guardar configuraci&#xf3;n"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton2ActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="jButton3">
<Properties>
Expand All @@ -125,5 +150,23 @@
<Property name="text" type="java.lang.String" value="&lt;html&gt;Ejecuci&#xf3;n en segundo plano: La ejecuci&#xf3;n en segundo plano permitir&#xe1; que la aplicaci&#xf3;n se siga ejecutando sin estar en tu barra de tareas.&lt;/html&gt;"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel4">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="14" style="0"/>
</Property>
<Property name="horizontalAlignment" type="int" value="0"/>
<Property name="text" type="java.lang.String" value="Configuraci&#xf3;n avanzada"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="txtHostname">
</Component>
<Component class="javax.swing.JLabel" name="jLabel5">
<Properties>
<Property name="text" type="java.lang.String" value="Puerto de escucha del host:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="tHostPort">
</Component>
</SubComponents>
</Form>
114 changes: 96 additions & 18 deletions src/technomotica/java/forms/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@

import java.awt.Image;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import technomotica.objs.Config;

/**
*
* @author Andres
*/
public class Configuration extends javax.swing.JDialog {

private Config cfg = null;

public String VERSION = "Versión 0.1";

/**
Expand All @@ -28,6 +32,18 @@ public Configuration(java.awt.Frame parent, boolean modal) {
setIconImage(new ImageIcon("src/technomotica/media/L4.png").getImage());

setLocationRelativeTo(null);

cfg = new Config();
if(cfg.getConfigKey("daemon").equalsIgnoreCase("false")) {
tEjecucion2do.setText("Activar");
tEjecucion2do.setSelected(false);
}
else {
tEjecucion2do.setText("Desactivar");
tEjecucion2do.setSelected(true);
}
txtHostname.setText(cfg.getConfigKey("hostname"));
tHostPort.setText(cfg.getConfigKey("port"));
}

/**
Expand All @@ -46,6 +62,10 @@ private void initComponents() {
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
txtHostname = new javax.swing.JTextField();
jLabel5 = new javax.swing.JLabel();
tHostPort = new javax.swing.JTextField();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("Configuración - Tech Domotica");
Expand All @@ -57,7 +77,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
}
});

jLabel1.setText("<html>Ejecución en segundo plano: La ejecución en segundo plano permitirá que la aplicación se siga ejecutando sin estar en tu barra de tareas.</html>");
jLabel1.setText("Dirección/Nombre del host:");

jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
Expand All @@ -72,6 +92,11 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
});

jButton2.setText("Guardar configuración");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});

jButton3.setText("Restablecer predeterminados");
jButton3.addActionListener(new java.awt.event.ActionListener() {
Expand All @@ -82,31 +107,46 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {

jLabel3.setText("<html>Ejecución en segundo plano: La ejecución en segundo plano permitirá que la aplicación se siga ejecutando sin estar en tu barra de tareas.</html>");

jLabel4.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel4.setText("Configuración avanzada");

jLabel5.setText("Puerto de escucha del host:");

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addGap(23, 23, 23)
.addComponent(jButton2)
.addGap(18, 18, 18)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jButton3)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(tEjecucion2do, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(23, 23, 23)
.addComponent(jButton2)
.addGap(18, 18, 18)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jButton3)
.addGap(0, 0, Short.MAX_VALUE)))
.addGap(20, 20, 20)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 205, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(txtHostname))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 308, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel5)
.addGap(89, 89, 89)
.addComponent(tHostPort)))))
.addContainerGap())
.addGroup(layout.createSequentialGroup()
.addGap(20, 20, 20)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 318, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 308, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
Expand All @@ -116,9 +156,17 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(tEjecucion2do)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(42, 42, 42)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtHostname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(tHostPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(19, 19, 19)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1)
.addComponent(jButton2)
Expand All @@ -138,18 +186,44 @@ private void tEjecucion2doActionPerformed(java.awt.event.ActionEvent evt) {//GEN
// TODO add your handling code here:
if(tEjecucion2do.isSelected()) {
tEjecucion2do.setText("Desactivar");
tEjecucion2do.setSelected(true);
}
else {
tEjecucion2do.setText("Activar");
tEjecucion2do.setSelected(false);
}

}//GEN-LAST:event_tEjecucion2doActionPerformed

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
// TODO add your handling code here:

int confirm = JOptionPane.showConfirmDialog(null, "¿Estás seguro de que deseas reestablecer la configuración predeterminada?", "Reestablecer configuración", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if(confirm == JOptionPane.YES_OPTION) {
cfg.cambiarConfigKey("daemon", "true");
cfg.cambiarConfigKey("hostname", "localhost");
cfg.cambiarConfigKey("port", "3306");
cfg.closeConfigFile();
JOptionPane.showMessageDialog(null, "Configuración reestablecida.", "¡Éxito en la operación!", JOptionPane.INFORMATION_MESSAGE);
this.dispose();
}
}//GEN-LAST:event_jButton3ActionPerformed

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
// TODO add your handling code here:
if(!tHostPort.getText().isEmpty() && !txtHostname.getText().isEmpty()) {
int confirm = JOptionPane.showConfirmDialog(null, "¿Estás seguro de que deseas guardar esta configuración?", "Guardar configuración", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if(confirm == JOptionPane.YES_OPTION) {
cfg.cambiarConfigKey("daemon", (tEjecucion2do.isSelected()) ? "true" : "false");
cfg.cambiarConfigKey("port", tHostPort.getText());
cfg.cambiarConfigKey("hostname", txtHostname.getText());
cfg.closeConfigFile();
JOptionPane.showMessageDialog(null, "Configuración guardada.", "¡Éxito en la operación!", JOptionPane.INFORMATION_MESSAGE);
this.dispose();
}
}
else JOptionPane.showMessageDialog(null, "Uno de los campos de configuración está vacío.", "No se puede guardar", JOptionPane.ERROR_MESSAGE);
}//GEN-LAST:event_jButton2ActionPerformed

/**
* @param args the command line arguments
*/
Expand Down Expand Up @@ -195,6 +269,10 @@ public void windowClosing(java.awt.event.WindowEvent e) {
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JToggleButton tEjecucion2do;
private javax.swing.JTextField tHostPort;
private javax.swing.JTextField txtHostname;
// End of variables declaration//GEN-END:variables
}
Loading

0 comments on commit fa3cca0

Please sign in to comment.