Transférer les fichiers vers 'src/JsonInspector'

This commit is contained in:
2023-01-14 16:38:37 +01:00
parent 9828f30743
commit 700a9511b4
5 changed files with 193 additions and 48 deletions

View File

@@ -11,6 +11,7 @@ public class Frame extends JFrame {
private static final String DEFAULT_LINK = "https://gbfs.citibikenyc.com/gbfs/en/station_information.json";
private final CardLayout cards = new CardLayout();
private boolean showTab = true;
private JPanel secondCard;
private GraphicFile file;
private Node node;
private Tree tree;
@@ -26,7 +27,8 @@ public class Frame extends JFrame {
super("Inspecteur JSON");
this.node = node;
init();
this.add(secondCard());
secondCard = secondCard();
this.add(secondCard);
cards.last(this.getContentPane());
this.setVisible(true);
}
@@ -60,7 +62,9 @@ public class Frame extends JFrame {
gbc.gridx = 1;
panel.add(textField, gbc);
gbc.gridy = 1;
gbc.gridx = 0;
gbc.gridy = 1;
gbc.gridwidth = 2;
panel.add(button, gbc);
panel.setBackground(Parameters.IHM_COLOR);
@@ -68,7 +72,7 @@ public class Frame extends JFrame {
}
private JPanel secondCard() {
file = new GraphicFile(tree, showTab);
file = new GraphicFile(this, tree);
JButton showButton = new JButton();
JButton backButton = new JButton("Retour");
JPanel mainPanel = new JPanel(), southPanel = new JPanel();
@@ -85,7 +89,7 @@ public class Frame extends JFrame {
southPanel.add(backButton);
backButton.addActionListener((event) -> backAction(mainPanel));
southPanel.add(showButton);
showButton.addActionListener((event) -> showAction(mainPanel));
showButton.addActionListener((event) -> showAction());
southPanel.add(new JButton("convertir en PHP"));
mainPanel.add(file);
@@ -97,20 +101,54 @@ public class Frame extends JFrame {
}
private void showAction(JPanel panel) {
private JPanel secondCard(GraphicFile file) {
this.file = file;
JButton showButton = new JButton();
JButton backButton = new JButton("Retour");
JPanel mainPanel = new JPanel(), southPanel = new JPanel();
JScrollPane scroll = new JScrollPane();
mainPanel.setLayout(new BorderLayout());
if (showTab) {
showTab = false;
repaintFile(panel);
showButton.setText("Tout déplier");
} else {
showTab = true;
repaintFile(panel);
showButton.setText("Tout replier");
}
southPanel.setBackground(Parameters.IHM_COLOR);
southPanel.add(backButton);
backButton.addActionListener((event) -> backAction(mainPanel));
southPanel.add(showButton);
showButton.addActionListener((event) -> showAction());
southPanel.add(new JButton("convertir en PHP"));
mainPanel.add(file);
mainPanel.add(southPanel, BorderLayout.SOUTH);
mainPanel.add(scroll);
scroll.setViewportView(file);
return mainPanel;
}
private void repaintFile(JPanel panel) {
this.remove(panel);
this.add(secondCard());
private void showAction() {
if (showTab) {
showTab = false;
file.showAll();
} else {
showTab = true;
file.retreatAll();
}
repaintFile();
}
public void repaintFile() {
file = new GraphicFile(this, file.getLines());
this.remove(secondCard);
secondCard = secondCard(file);
this.add(secondCard);
cards.last(this.getContentPane());
}
@@ -118,13 +156,15 @@ public class Frame extends JFrame {
private void validationAction(JTextField field) {
try {
URL url = new URL(field.getText());
this.add(secondCard());
secondCard = secondCard();
this.add(secondCard);
cards.last(this.getContentPane());
} catch (MalformedURLException e) {
JOptionPane.showMessageDialog(this, "Invalid URL", "Error", JOptionPane.ERROR_MESSAGE);
}
}
private void backAction(JPanel panel) {
this.remove(panel);
cards.first(this.getContentPane());