Fix bug, request focus no funcionaba
This commit is contained in:
@@ -148,6 +148,15 @@ public class LaunchController {
|
||||
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() {
|
||||
this.frame = new LaunchFrame();
|
||||
this.createCards();
|
||||
@@ -315,17 +324,8 @@ public class LaunchController {
|
||||
}
|
||||
|
||||
public void showCard(PanelName name) {
|
||||
this.controllers.get(name).show();
|
||||
this.frame.showCard(name);
|
||||
}
|
||||
|
||||
public BaseController getCard(PanelName name) {
|
||||
return this.controllers.get(name);
|
||||
}
|
||||
|
||||
public void run() {
|
||||
this.create();
|
||||
this.frame.setVisible(true);
|
||||
this.controllers.get(name).show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -180,7 +180,6 @@ public class LibroCreateController extends BaseController {
|
||||
@Override
|
||||
public void show() {
|
||||
this.reload();
|
||||
this.view.getIsbnField().requestFocus();
|
||||
}
|
||||
|
||||
private void reload() {
|
||||
@@ -188,6 +187,20 @@ public class LibroCreateController extends BaseController {
|
||||
this.loadCategoriasList();
|
||||
this.loadAutorList();
|
||||
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
|
||||
|
||||
@@ -27,13 +27,9 @@ public class LibroSearchController extends BaseController {
|
||||
this.setupListeners();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
this.reload();
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
this.loadLibroTable();
|
||||
private void loadLibroTable() {
|
||||
List<Libro> libros = this.libroRepository.getAll();
|
||||
this.loadLibroTable(libros);
|
||||
}
|
||||
|
||||
private void setupListeners() {
|
||||
@@ -45,22 +41,15 @@ public class LibroSearchController extends BaseController {
|
||||
this.view.getVerButton().addActionListener(e -> this.view());
|
||||
}
|
||||
|
||||
private void view() {
|
||||
Libro libro = this.getSelectedLibro();
|
||||
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) {
|
||||
BaseTableModel<Libro> model = this.view.getLibrosModel();
|
||||
model.setRows(libros);
|
||||
}
|
||||
|
||||
private void edit() {
|
||||
Libro libro = this.getSelectedLibro();
|
||||
if (libro != null) {
|
||||
LibroUpdateController controller = (LibroUpdateController) this.getParentController().getCard(PanelName.LIBRO_UPDATE);
|
||||
controller.setLibro(libro);
|
||||
this.getParentController().showCard(PanelName.LIBRO_UPDATE);
|
||||
}
|
||||
private void search() {
|
||||
String term = this.view.getBuscarField().getText();
|
||||
List<Libro> libros = this.libroRepository.search(term);
|
||||
this.loadLibroTable(libros);
|
||||
}
|
||||
|
||||
private void delete() {
|
||||
@@ -82,25 +71,22 @@ public class LibroSearchController extends BaseController {
|
||||
this.reload();
|
||||
}
|
||||
|
||||
private void search() {
|
||||
String term = this.view.getBuscarField().getText();
|
||||
List<Libro> libros = this.libroRepository.search(term);
|
||||
this.loadLibroTable(libros);
|
||||
private void edit() {
|
||||
Libro libro = this.getSelectedLibro();
|
||||
if (libro != null) {
|
||||
LibroUpdateController controller = (LibroUpdateController) this.getParentController().getCard(PanelName.LIBRO_UPDATE);
|
||||
controller.setLibro(libro);
|
||||
this.getParentController().showCard(PanelName.LIBRO_UPDATE);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadLibroTable(List<Libro> libros) {
|
||||
BaseTableModel<Libro> model = this.view.getLibrosModel();
|
||||
model.setRows(libros);
|
||||
private void view() {
|
||||
Libro libro = this.getSelectedLibro();
|
||||
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() {
|
||||
@@ -116,4 +102,19 @@ public class LibroSearchController extends BaseController {
|
||||
}
|
||||
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() {
|
||||
this.view.getActualizarButton().addActionListener(e -> this.update());
|
||||
this.view.getVolverButton().addActionListener(e -> this.getParentController().showCard(PanelName.LIBRO_SEARCH));
|
||||
}
|
||||
|
||||
private void update() {
|
||||
@@ -154,6 +155,7 @@ public class LibroUpdateController extends BaseController {
|
||||
this.loadEditorialCombo();
|
||||
this.loadIdiomasList();
|
||||
this.fillLibro();
|
||||
this.view.getIsbnField().requestFocus();
|
||||
}
|
||||
|
||||
private void loadAutorList() {
|
||||
|
||||
@@ -76,6 +76,17 @@ public class Autor {
|
||||
|
||||
@Override
|
||||
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>
|
||||
<properties/>
|
||||
</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">
|
||||
<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"/>
|
||||
@@ -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"/>
|
||||
</constraints>
|
||||
</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>
|
||||
</grid>
|
||||
</form>
|
||||
|
||||
@@ -39,6 +39,7 @@ public class LibroUpdatePanel extends BasePanel {
|
||||
private JComboBox<Editorial> editorialCombo;
|
||||
private DefaultComboBoxModel<Editorial> editorialModel;
|
||||
private JButton actualizarButton;
|
||||
private JButton volverButton;
|
||||
|
||||
{
|
||||
// GUI initializer generated by IntelliJ IDEA GUI Designer
|
||||
@@ -108,6 +109,10 @@ public class LibroUpdatePanel extends BasePanel {
|
||||
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!
|
||||
*
|
||||
@@ -191,11 +196,6 @@ public class LibroUpdatePanel extends BasePanel {
|
||||
contentPane.add(editorialCombo,
|
||||
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));
|
||||
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();
|
||||
contentPane.add(spacer1,
|
||||
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,
|
||||
new GridConstraints(19, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1,
|
||||
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() {
|
||||
|
||||
Reference in New Issue
Block a user