Se aplico el estilo de codigo de google :3

https://github.com/google/styleguide
This commit is contained in:
Daniel Cortes
2019-03-01 23:28:43 -03:00
parent 412e128398
commit 95685b7f82
81 changed files with 8826 additions and 7757 deletions

View File

@@ -29,160 +29,201 @@ import com.intellij.uiDesigner.core.GridLayoutManager;
import com.intellij.uiDesigner.core.Spacer;
import danielcortes.xyz.views.components.YearSpinnerModel;
import danielcortes.xyz.views.listeners.WindowClosingListener;
import javax.swing.*;
import java.awt.*;
import java.awt.Insets;
import java.awt.event.KeyEvent;
import java.time.LocalDate;
import java.time.YearMonth;
import java.util.ArrayList;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.KeyStroke;
import javax.swing.SpinnerModel;
public class MonthSelectDialog extends JDialog {
private JPanel contentPane;
private JButton buttonOK;
private JButton buttonCancel;
private JComboBox<String> monthCombo;
private JSpinner yearSpinner;
private ArrayList<String> months;
private JPanel contentPane;
private JButton buttonOK;
private JButton buttonCancel;
private JComboBox<String> monthCombo;
private JSpinner yearSpinner;
private boolean acepted;
private ArrayList<String> months;
public MonthSelectDialog() {
$$$setupUI$$$();
setup();
private boolean acepted;
public MonthSelectDialog() {
$$$setupUI$$$();
setup();
}
private void setup() {
this.setContentPane(contentPane);
this.setModalityType(ModalityType.APPLICATION_MODAL);
this.getRootPane().setDefaultButton(buttonOK);
this.buttonOK.addActionListener(e -> onOK());
this.buttonCancel.addActionListener(e -> onCancel());
this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
this.addWindowListener((WindowClosingListener) e -> onCancel());
this.contentPane
.registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
this.setLocationRelativeTo(null);
pack();
}
public YearMonth execute() {
setVisible(true);
if (this.isAcepted()) {
return this.getMonth();
} else {
return null;
}
}
private void onOK() {
this.acepted = true;
dispose();
}
private void onCancel() {
this.acepted = false;
dispose();
}
private boolean isAcepted() {
return this.acepted;
}
private YearMonth getMonth() {
int year = Integer.valueOf((String) yearSpinner.getValue());
int month = this.months.indexOf(this.monthCombo.getSelectedItem()) + 1;
return YearMonth.of(year, month);
}
private void createUIComponents() {
createYearSpinner();
createMonthCombo();
}
private void createYearSpinner() {
SpinnerModel model = new YearSpinnerModel();
this.yearSpinner = new JSpinner();
this.yearSpinner.setModel(model);
((JSpinner.DefaultEditor) this.yearSpinner.getEditor()).getTextField().setEditable(true);
}
private void createMonthCombo() {
months = new ArrayList<>();
months.add("Enero");
months.add("Febrero");
months.add("Marzo");
months.add("Abril");
months.add("Mayo");
months.add("Junio");
months.add("Julio");
months.add("Agosto");
months.add("Septiembre");
months.add("Octubre");
months.add("Noviembre");
months.add("Diciembre");
monthCombo = new JComboBox<>();
for (String month : months) {
monthCombo.addItem(month);
}
private void setup() {
this.setContentPane(contentPane);
this.setModalityType(ModalityType.APPLICATION_MODAL);
this.getRootPane().setDefaultButton(buttonOK);
int currentMonth = LocalDate.now().getMonth().getValue() - 1;
monthCombo.setSelectedIndex(currentMonth);
}
this.buttonOK.addActionListener(e -> onOK());
/**
* Method generated by IntelliJ IDEA GUI Designer >>> IMPORTANT!! <<< DO NOT edit this method OR
* call it in your code!
*
* @noinspection ALL
*/
private void $$$setupUI$$$() {
createUIComponents();
contentPane = new JPanel();
contentPane.setLayout(new GridLayoutManager(2, 1, new Insets(10, 10, 10, 10), -1, -1));
final JPanel panel1 = new JPanel();
panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1));
contentPane.add(panel1,
new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null,
null, null, 0, false));
final Spacer spacer1 = new Spacer();
panel1.add(spacer1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER,
GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null,
0, false));
final JPanel panel2 = new JPanel();
panel2.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1, true, false));
panel1.add(panel2,
new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
null, 0, false));
buttonOK = new JButton();
buttonOK.setText("OK");
panel2.add(buttonOK, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER,
GridConstraints.FILL_HORIZONTAL,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
buttonCancel = new JButton();
buttonCancel.setText("Cancelar");
panel2.add(buttonCancel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER,
GridConstraints.FILL_HORIZONTAL,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final JPanel panel3 = new JPanel();
panel3.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1));
contentPane.add(panel3,
new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
null, 0, false));
final JLabel label1 = new JLabel();
label1.setText("Mes");
panel3.add(label1,
new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE,
GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0,
false));
panel3.add(monthCombo, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST,
GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final JLabel label2 = new JLabel();
label2.setText("Año");
panel3.add(label2,
new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE,
GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0,
false));
panel3.add(yearSpinner, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST,
GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final JLabel label3 = new JLabel();
label3.setText("Seleccione Mes y Año");
panel3.add(label3,
new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0,
false));
}
this.buttonCancel.addActionListener(e -> onCancel());
this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
this.addWindowListener((WindowClosingListener) e -> onCancel());
this.contentPane.registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
this.setLocationRelativeTo(null);
pack();
}
public YearMonth execute() {
setVisible(true);
if (this.isAcepted()) {
return this.getMonth();
} else {
return null;
}
}
private void onOK() {
this.acepted = true;
dispose();
}
private void onCancel() {
this.acepted = false;
dispose();
}
private boolean isAcepted() {
return this.acepted;
}
private YearMonth getMonth() {
int year = Integer.valueOf((String) yearSpinner.getValue());
int month = this.months.indexOf(this.monthCombo.getSelectedItem()) + 1;
return YearMonth.of(year, month);
}
private void createUIComponents() {
createYearSpinner();
createMonthCombo();
}
private void createYearSpinner() {
SpinnerModel model = new YearSpinnerModel();
this.yearSpinner = new JSpinner();
this.yearSpinner.setModel(model);
((JSpinner.DefaultEditor) this.yearSpinner.getEditor()).getTextField().setEditable(true);
}
private void createMonthCombo() {
months = new ArrayList<>();
months.add("Enero");
months.add("Febrero");
months.add("Marzo");
months.add("Abril");
months.add("Mayo");
months.add("Junio");
months.add("Julio");
months.add("Agosto");
months.add("Septiembre");
months.add("Octubre");
months.add("Noviembre");
months.add("Diciembre");
monthCombo = new JComboBox<>();
for (String month : months) {
monthCombo.addItem(month);
}
int currentMonth = LocalDate.now().getMonth().getValue() - 1;
monthCombo.setSelectedIndex(currentMonth);
}
/**
* Method generated by IntelliJ IDEA GUI Designer
* >>> IMPORTANT!! <<<
* DO NOT edit this method OR call it in your code!
*
* @noinspection ALL
*/
private void $$$setupUI$$$() {
createUIComponents();
contentPane = new JPanel();
contentPane.setLayout(new GridLayoutManager(2, 1, new Insets(10, 10, 10, 10), -1, -1));
final JPanel panel1 = new JPanel();
panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1));
contentPane.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, null, 0, false));
final Spacer spacer1 = new Spacer();
panel1.add(spacer1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
final JPanel panel2 = new JPanel();
panel2.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1, true, false));
panel1.add(panel2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
buttonOK = new JButton();
buttonOK.setText("OK");
panel2.add(buttonOK, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
buttonCancel = new JButton();
buttonCancel.setText("Cancelar");
panel2.add(buttonCancel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final JPanel panel3 = new JPanel();
panel3.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1));
contentPane.add(panel3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
final JLabel label1 = new JLabel();
label1.setText("Mes");
panel3.add(label1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
panel3.add(monthCombo, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final JLabel label2 = new JLabel();
label2.setText("Año");
panel3.add(label2, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
panel3.add(yearSpinner, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final JLabel label3 = new JLabel();
label3.setText("Seleccione Mes y Año");
panel3.add(label3, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
}
/**
* @noinspection ALL
*/
public JComponent $$$getRootComponent$$$() {
return contentPane;
}
/**
* @noinspection ALL
*/
public JComponent $$$getRootComponent$$$() {
return contentPane;
}
}