Fix bug, request focus no funcionaba
This commit is contained in:
@@ -148,6 +148,15 @@ public class LaunchController {
|
|||||||
this.controllers = new HashMap<>();
|
this.controllers = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BaseController getCard(PanelName name) {
|
||||||
|
return this.controllers.get(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
this.create();
|
||||||
|
this.frame.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
private void create() {
|
private void create() {
|
||||||
this.frame = new LaunchFrame();
|
this.frame = new LaunchFrame();
|
||||||
this.createCards();
|
this.createCards();
|
||||||
@@ -315,17 +324,8 @@ public class LaunchController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void showCard(PanelName name) {
|
public void showCard(PanelName name) {
|
||||||
this.controllers.get(name).show();
|
|
||||||
this.frame.showCard(name);
|
this.frame.showCard(name);
|
||||||
}
|
this.controllers.get(name).show();
|
||||||
|
|
||||||
public BaseController getCard(PanelName name) {
|
|
||||||
return this.controllers.get(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void run() {
|
|
||||||
this.create();
|
|
||||||
this.frame.setVisible(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -180,7 +180,6 @@ public class LibroCreateController extends BaseController {
|
|||||||
@Override
|
@Override
|
||||||
public void show() {
|
public void show() {
|
||||||
this.reload();
|
this.reload();
|
||||||
this.view.getIsbnField().requestFocus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reload() {
|
private void reload() {
|
||||||
@@ -188,6 +187,20 @@ public class LibroCreateController extends BaseController {
|
|||||||
this.loadCategoriasList();
|
this.loadCategoriasList();
|
||||||
this.loadAutorList();
|
this.loadAutorList();
|
||||||
this.loadEditorialCombo();
|
this.loadEditorialCombo();
|
||||||
|
this.cleanInput();
|
||||||
|
this.view.getIsbnField().requestFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cleanInput() {
|
||||||
|
this.view.getIsbnField().setText("");
|
||||||
|
this.view.getTituloField().setText("");
|
||||||
|
this.view.getPaginasField().setText("");
|
||||||
|
this.view.getAnoPublicacionField().setText("");
|
||||||
|
this.view.getPrecioReferenciaField().setText("");
|
||||||
|
this.view.getIdiomasList().clearSelection();
|
||||||
|
this.view.getAutoresList().clearSelection();
|
||||||
|
this.view.getCategoriasList().clearSelection();
|
||||||
|
this.view.getEditorialCombo().setSelectedIndex(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -27,13 +27,9 @@ public class LibroSearchController extends BaseController {
|
|||||||
this.setupListeners();
|
this.setupListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void loadLibroTable() {
|
||||||
public void show() {
|
List<Libro> libros = this.libroRepository.getAll();
|
||||||
this.reload();
|
this.loadLibroTable(libros);
|
||||||
}
|
|
||||||
|
|
||||||
public void reload() {
|
|
||||||
this.loadLibroTable();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupListeners() {
|
private void setupListeners() {
|
||||||
@@ -45,22 +41,15 @@ public class LibroSearchController extends BaseController {
|
|||||||
this.view.getVerButton().addActionListener(e -> this.view());
|
this.view.getVerButton().addActionListener(e -> this.view());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void view() {
|
private void loadLibroTable(List<Libro> libros) {
|
||||||
Libro libro = this.getSelectedLibro();
|
BaseTableModel<Libro> model = this.view.getLibrosModel();
|
||||||
if (libro != null) {
|
model.setRows(libros);
|
||||||
LibroViewController controller = (LibroViewController) this.getParentController().getCard(PanelName.LIBRO_VIEW);
|
|
||||||
controller.setLibro(libro);
|
|
||||||
this.getParentController().showCard(PanelName.LIBRO_VIEW);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void edit() {
|
private void search() {
|
||||||
Libro libro = this.getSelectedLibro();
|
String term = this.view.getBuscarField().getText();
|
||||||
if (libro != null) {
|
List<Libro> libros = this.libroRepository.search(term);
|
||||||
LibroUpdateController controller = (LibroUpdateController) this.getParentController().getCard(PanelName.LIBRO_UPDATE);
|
this.loadLibroTable(libros);
|
||||||
controller.setLibro(libro);
|
|
||||||
this.getParentController().showCard(PanelName.LIBRO_UPDATE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void delete() {
|
private void delete() {
|
||||||
@@ -82,25 +71,22 @@ public class LibroSearchController extends BaseController {
|
|||||||
this.reload();
|
this.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void search() {
|
private void edit() {
|
||||||
String term = this.view.getBuscarField().getText();
|
Libro libro = this.getSelectedLibro();
|
||||||
List<Libro> libros = this.libroRepository.search(term);
|
if (libro != null) {
|
||||||
this.loadLibroTable(libros);
|
LibroUpdateController controller = (LibroUpdateController) this.getParentController().getCard(PanelName.LIBRO_UPDATE);
|
||||||
|
controller.setLibro(libro);
|
||||||
|
this.getParentController().showCard(PanelName.LIBRO_UPDATE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadLibroTable(List<Libro> libros) {
|
private void view() {
|
||||||
BaseTableModel<Libro> model = this.view.getLibrosModel();
|
Libro libro = this.getSelectedLibro();
|
||||||
model.setRows(libros);
|
if (libro != null) {
|
||||||
|
LibroViewController controller = (LibroViewController) this.getParentController().getCard(PanelName.LIBRO_VIEW);
|
||||||
|
controller.setLibro(libro);
|
||||||
|
this.getParentController().showCard(PanelName.LIBRO_VIEW);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadLibroTable() {
|
|
||||||
List<Libro> libros = this.libroRepository.getAll();
|
|
||||||
this.loadLibroTable(libros);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BasePanel getView() {
|
|
||||||
return this.view;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Libro getSelectedLibro() {
|
private Libro getSelectedLibro() {
|
||||||
@@ -116,4 +102,19 @@ public class LibroSearchController extends BaseController {
|
|||||||
}
|
}
|
||||||
return this.view.getLibrosModel().getRow(selectedRow);
|
return this.view.getLibrosModel().getRow(selectedRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void reload() {
|
||||||
|
this.loadLibroTable();
|
||||||
|
this.view.getBuscarField().requestFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void show() {
|
||||||
|
this.reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BasePanel getView() {
|
||||||
|
return this.view;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ public class LibroUpdateController extends BaseController {
|
|||||||
|
|
||||||
private void setupListeners() {
|
private void setupListeners() {
|
||||||
this.view.getActualizarButton().addActionListener(e -> this.update());
|
this.view.getActualizarButton().addActionListener(e -> this.update());
|
||||||
|
this.view.getVolverButton().addActionListener(e -> this.getParentController().showCard(PanelName.LIBRO_SEARCH));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void update() {
|
private void update() {
|
||||||
@@ -154,6 +155,7 @@ public class LibroUpdateController extends BaseController {
|
|||||||
this.loadEditorialCombo();
|
this.loadEditorialCombo();
|
||||||
this.loadIdiomasList();
|
this.loadIdiomasList();
|
||||||
this.fillLibro();
|
this.fillLibro();
|
||||||
|
this.view.getIsbnField().requestFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadAutorList() {
|
private void loadAutorList() {
|
||||||
|
|||||||
@@ -76,6 +76,17 @@ public class Autor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return this.nombre + " " + this.apellidoPaterno + " " + this.apellidoMaterno;
|
return this.getNombreCompleto();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNombreCompleto() {
|
||||||
|
StringBuilder nombreCompleto = new StringBuilder();
|
||||||
|
nombreCompleto.append(this.nombre != null ? this.nombre : "")
|
||||||
|
.append(" ")
|
||||||
|
.append(this.apellidoPaterno != null ? this.apellidoPaterno : "")
|
||||||
|
.append(" ")
|
||||||
|
.append(this.apellidoMaterno != null ? this.apellidoMaterno : "");
|
||||||
|
|
||||||
|
return nombreCompleto.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -173,16 +173,6 @@
|
|||||||
</constraints>
|
</constraints>
|
||||||
<properties/>
|
<properties/>
|
||||||
</component>
|
</component>
|
||||||
<component id="16ee1" class="javax.swing.JButton" binding="actualizarButton" default-binding="true">
|
|
||||||
<constraints>
|
|
||||||
<grid row="18" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false">
|
|
||||||
<preferred-size width="150" height="-1"/>
|
|
||||||
</grid>
|
|
||||||
</constraints>
|
|
||||||
<properties>
|
|
||||||
<text value="Actualizar"/>
|
|
||||||
</properties>
|
|
||||||
</component>
|
|
||||||
<vspacer id="f08c">
|
<vspacer id="f08c">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="19" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
<grid row="19" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||||
@@ -198,6 +188,36 @@
|
|||||||
<grid row="19" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
<grid row="19" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
</hspacer>
|
</hspacer>
|
||||||
|
<grid id="e0471" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
|
<margin top="0" left="0" bottom="0" right="0"/>
|
||||||
|
<constraints>
|
||||||
|
<grid row="18" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties/>
|
||||||
|
<border type="none"/>
|
||||||
|
<children>
|
||||||
|
<component id="16ee1" class="javax.swing.JButton" binding="actualizarButton" default-binding="true">
|
||||||
|
<constraints>
|
||||||
|
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false">
|
||||||
|
<preferred-size width="150" height="-1"/>
|
||||||
|
</grid>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<text value="Actualizar"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<component id="162e" class="javax.swing.JButton" binding="volverButton">
|
||||||
|
<constraints>
|
||||||
|
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false">
|
||||||
|
<preferred-size width="150" height="-1"/>
|
||||||
|
</grid>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<text value="Volver"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
</children>
|
||||||
|
</grid>
|
||||||
</children>
|
</children>
|
||||||
</grid>
|
</grid>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ public class LibroUpdatePanel extends BasePanel {
|
|||||||
private JComboBox<Editorial> editorialCombo;
|
private JComboBox<Editorial> editorialCombo;
|
||||||
private DefaultComboBoxModel<Editorial> editorialModel;
|
private DefaultComboBoxModel<Editorial> editorialModel;
|
||||||
private JButton actualizarButton;
|
private JButton actualizarButton;
|
||||||
|
private JButton volverButton;
|
||||||
|
|
||||||
{
|
{
|
||||||
// GUI initializer generated by IntelliJ IDEA GUI Designer
|
// GUI initializer generated by IntelliJ IDEA GUI Designer
|
||||||
@@ -108,6 +109,10 @@ public class LibroUpdatePanel extends BasePanel {
|
|||||||
return this.actualizarButton;
|
return this.actualizarButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JButton getVolverButton() {
|
||||||
|
return this.volverButton;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method generated by IntelliJ IDEA GUI Designer >>> IMPORTANT!! <<< DO NOT edit this method OR call it in your code!
|
* Method generated by IntelliJ IDEA GUI Designer >>> IMPORTANT!! <<< DO NOT edit this method OR call it in your code!
|
||||||
*
|
*
|
||||||
@@ -191,11 +196,6 @@ public class LibroUpdatePanel extends BasePanel {
|
|||||||
contentPane.add(editorialCombo,
|
contentPane.add(editorialCombo,
|
||||||
new GridConstraints(17, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW,
|
new GridConstraints(17, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW,
|
||||||
GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(400, -1), null, 0, false));
|
GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(400, -1), null, 0, false));
|
||||||
actualizarButton = new JButton();
|
|
||||||
actualizarButton.setText("Actualizar");
|
|
||||||
contentPane.add(actualizarButton, new GridConstraints(18, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE,
|
|
||||||
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1),
|
|
||||||
null, 0, false));
|
|
||||||
final Spacer spacer1 = new Spacer();
|
final Spacer spacer1 = new Spacer();
|
||||||
contentPane.add(spacer1,
|
contentPane.add(spacer1,
|
||||||
new GridConstraints(19, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null,
|
new GridConstraints(19, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null,
|
||||||
@@ -208,6 +208,21 @@ public class LibroUpdatePanel extends BasePanel {
|
|||||||
contentPane.add(spacer3,
|
contentPane.add(spacer3,
|
||||||
new GridConstraints(19, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1,
|
new GridConstraints(19, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1,
|
||||||
null, null, null, 0, false));
|
null, null, null, 0, false));
|
||||||
|
final JPanel panel1 = new JPanel();
|
||||||
|
panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1));
|
||||||
|
contentPane.add(panel1, new GridConstraints(18, 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));
|
||||||
|
actualizarButton = new JButton();
|
||||||
|
actualizarButton.setText("Actualizar");
|
||||||
|
panel1.add(actualizarButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE,
|
||||||
|
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1),
|
||||||
|
null, 0, false));
|
||||||
|
volverButton = new JButton();
|
||||||
|
volverButton.setText("Volver");
|
||||||
|
panel1.add(volverButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE,
|
||||||
|
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1),
|
||||||
|
null, 0, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createUIComponents() {
|
private void createUIComponents() {
|
||||||
|
|||||||
Reference in New Issue
Block a user